DHCOR STM32MP1 Linux

From Wiki-DB
Jump to navigationJump to search


CAUTION! THIS PAGE IS UNDER CONSTRUCTION!


U-Boot Bootloader Commands

Activating Device Tree Overlays

Some of the hardware features can be activated with the help of a device tree overlay. To activate a device tree overlay, you have to go into the U-Boot console first. This can be done during the first seconds after startup, by simply hitting any button on a keyboard once the system tells you to do so.
When you are in the bootloder, you can view a list of all available device tree overlays with the following command.
> ls mmc 0:4 /boot
After that, you can select a device tree overlay with the following commands:
To activate CAN on the GPIOs :
> setenv loaddtos '#conf@stm32mp157a-avenger96.dtb#conf@stm32mp157a-avenger96-overlay-fdcan1-x6.dtbo#conf@stm32mp157a-avenger96-overlay-fdcan2-x6.dtbo'
To activate the 96Boards D3Camera Mezzanine Board enter:
> setenv loaddtos '#conf@stm32mp157a-avenger96.dtb#conf@stm32mp157a-avenger96-overlay-ov5640-x7.dtbo'
If you want to make use of the MIPI DSI interface, you can start with an MIPI DSI interface board developed by DH electronics. If you want to use it, simply contact us to find out more about it.
To activate the MIPI DSI Interface enter the following device tree overlay.
> setenv loaddtos '#conf@stm32mp157a-avenger96.dtb#conf@stm32mp157a-avenger96-overlay-644-100-x6-otm8009a.dtbo'
If you want to save your settings, so that you don't have to enter the device tree overlay after every reboot, enter this command:
> saveenv
To reset your device tree overlay, simply override the last settings:
> setenv loaddtos '#conf@stm32mp157a-avenger96.dtb'
Once the device tree overlay is set, you can boot up your board by entering boot:
> boot

Linux Userspace Commands

Logging in after Startup

After booting, you con login as the user "root" without any password. Note, that the standard console is connected to the UART 1 Port (96Boards Name).
dh-stm32mp1-dhcor-avenger96 login: root

Interacting with GPIOs

An GPIO can be activated with the gpioset command. To find out which GPIO is connected to what gpiochip-device, take a look at the Hardware Section below.
The GPIO "A" can be turned on by
# gpioset gpiochip0 14=1
and off by
# gpioset gpiochip0 14=0

Interacting with the User LEDs

In between the two USB-Host connectors of the Avenger96, you can find four so called User LEDs. These LEDs can be used for simple programming examples and be accessed and manipulated by the user form the userspace.
The LEDs are located under /sys/class/leds.
To disable the blinking of the LED0 hit following command:
# echo none > /sys/class/leds/green:user0/trigger
The LEDs can also be turned on or off permanently by writing either "1" or "0" to the following file:
# echo 1 > /sys/class/leds/green:user0/brightness
# echo 0 > /sys/class/leds/green:user0/brightness

Accessing Devices over I2C

Once you have connected some I2C devices to the Avenger96, you can scan the I2C bus and see if your device is available.
To scan for devices on the I2C-Bus 1 enter the following command:
# i2cdetect -y 1
To write on the device on the address 0x50 to its register number 0x10 the value 0x20 enter the following command:
# i2cset -y 1 0x50 0x10 0x20
To read the data of the device on the address 0x50 at its register 0x10 enter this:
# i2cget -y 1 0x50 0x10

Unsing the internal RTC

Read out the current date and time of the system (not the RTC itself)
# date
Set a specific system time
# date -s "2020-01-30 10:00:00"
Save the current system time to the RTC of the STM32MP1
# hwclock -w
When you allready have stored a date on the RTC and you want to read it out, use the next command. This command only gives back the time, but does not synchronize it with the system time. This is done in the next step.
# hwclock -r
The system time can be synchronised to the RTC by this command:
# hwclock -s

Using the second UART port

Dieser Teil muss noch ergänzt werden!:
--> TBD <--
# --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <--

Connecting to a WiFi network

After bootup, you have to enter the following commands:
activating the wlan0 interface
# ifconfig wlan0 up
Enter the SSID and the WPA Key
# wpa_passphrase "YOUR SSID" your-wpa-key > wpa_supplicant.conf
Defining the settings
# wpa_supplicant -B -Dnl8011 -iwlan0 -cwpa_supplicant.conf

After that you should get the message "successfully initialized wpa_supplicant"

Requesting an IP-Address from the DHCP-Server
# udhcpc -i wlan0
Checking your IP Address
# ifconfig

Connecting to a Bluetooth Device

Dieser Teil muss noch ergänzt werden!:
--> TBD <--
# --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <-- --> TBD <--

Activating the CAN interface

The Avenger96 has two CAN FD ports which can be accessed from the GPIOs on the Low Speed Expansion Connector:
FDCAN 1:
PA12 - TX
PA11 - RX
FDCAN 2:
PB13 - TX
PB5 - RX
To activate them, you have to add a Device Tree Overlay in the bootloader, like mentioned in the beginning of this page.
Once this is done, you have to connect a CAN-Transceiver to the GPIOs and from here you can access the CAN-Bus.
Setup CAN interface with baudrate 500kbit/sec.
# ip link set can0 up type can bitrate 500000
Start to listen on CAN port
# candump can0
Send test message
# cansend can0 100#11.2233.44556677.88
Deinitialize CAN port
# ip link set can0 down

Activating the MIPI CSI Interface

The Avenger96 is compatible with the D3Camera Mezzanine Board available on the 96Boards website.
To activate this Mezzanine Board you have to connect it to the Avenger96 before you power it up. Note, that you also have to access the UART1 which is then available on the Solderpins of the D3Camera Mezzanine board.
Like for CAN you also have to activate the proper device tree overlay as describte in the beginning of this page.
Once the system is booted, you have to connect a display to the Avenger96 via HDMI and then enter the following command.
# XDG_RUNTIME_DIR=/var/run/user/0/ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=1280,height=720,pixelformat=RGB565 ! waylandsink

Kernel Userspace Interfaces to Access Hardware

The pinmuxing of the DHCOR STM32MP1 can be configured just as needed by you as a customer and therefore the interfaces used in each configuration might be different. However, to give you an easy way to start developing with the DHCOR STM32MP1 you can use the Avenger96 Board, which is the reference design for our DHCOR module. Thus, the interfaces described here, are the configuration for the Avenger96.

Serial (UART) Interfaces

96Boards Name Linux Name Hardware Name
UART 0 /dev/ttySTM1 UART 7
UART 1 /dev/ttySTM0 UART 4

I²C Interfaces

96Boards Name Linux Name Hardware Name
I2C0 /dev/i2c-1 I2C2
I2C1 /dev/i2c-0 I2C1
OnBoard /dev/i2c-2 I2C4

microSD and eMMC

96Boards Name Linux Name Hardware Name
?????????? ?????????? ??????????
?????????? ?????????? ??????????
?????????? ?????????? ??????????

GPIOs

96Boards Name Linux Name Hardware Name
A gpiochip0 14 PA14
B gpiochip1 11 PB11
C gpiochip2 3 PC3
D gpiochip3 8 PD8
E gpiochip3 14 PD14
F gpiochip3 15 PD15
G gpiochip5 12 PF12
H gpiochip5 13 PF13
I gpiochip0 12 PA12
J gpiochip1 5 PB5
K gpiochip0 11 PA11
L gpiochip1 13 PB13


Beside the GPIOs, the Avenger96 has also four user LEDs, which are controlled the same way as the GPIOs.
96Boards Name Linux Name Hardware Name
LED 0 /sys/class/leds/green:user0 PZ7
LED 1 /sys/class/leds/green:user1 PF3
LED 2 /sys/class/leds/green:user2 PG0
LED 3 /sys/class/leds/green:user3 PG1