DHCOR STM32MP1 Linux: Difference between revisions
Mschmoeller (talk | contribs) |
|||
(118 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
''' | == 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. | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''> ls mmc 0:4 /boot </tt> | |||
|} | |||
:After that, you can select a device tree overlay with the following commands: | |||
:To activate CAN support: | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''> setenv loaddtos '#conf-stm32mp157a-avenger96.dtb#conf-stm32mp15xx-avenger96-overlay-fdcan1-x6.dtbo#conf-stm32mp157a-avenger96-overlay-fdcan2-x6.dtbo' </tt> | |||
|} | |||
:To activate the 96Boards D3Camera Mezzanine Board enter: | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''> setenv loaddtos '#conf-stm32mp157a-avenger96.dtb#conf-stm32mp15xx-avenger96-overlay-ov5640-x7.dtbo' </tt> | |||
|} | |||
: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. | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''> setenv loaddtos '#conf-stm32mp157a-avenger96.dtb#conf-stm32mp15xx-avenger96-overlay-644-100-x6-otm8009a.dtbo' </tt> | |||
|} | |||
: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: | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''> saveenv </tt> | |||
|} | |||
:To reset your device tree overlay, simply override the last settings: | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''> setenv loaddtos '#conf-stm32mp157a-avenger96.dtb' </tt> | |||
|} | |||
:Once the device tree overlay is set, you can boot up your board by entering boot: | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''> boot </tt> | |||
|} | |||
== Linux Userspace Commands == | == 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). | ||
:{| class="wikitable" style=" | :{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | ||
|| | |<tt>dh-stm32mp1-dhcor-avenger96 login: '''root'''</tt> | ||
|- | |} | ||
|| | |||
|} | === 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 | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# gpioset gpiochip0 14=1</tt> | |||
|} | |||
:and off by | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# gpioset gpiochip0 14=0</tt> | |||
|} | |||
=== 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: | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# echo none > /sys/class/leds/green:user0/trigger</tt> | |||
|} | |||
:The LEDs can also be turned on or off permanently by writing either "1" or "0" to the following file: | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# echo 1 > /sys/class/leds/green:user0/brightness</tt> | |||
|} | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# echo 0 > /sys/class/leds/green:user0/brightness</tt> | |||
|} | |||
=== 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: | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# i2cdetect -y 1 </tt> | |||
|} | |||
:To write on the device on the address 0x50 to its register number 0x10 the value 0x20 enter the following command: | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# i2cset -y 1 0x50 0x10 0x20 </tt> | |||
|} | |||
:To read the data of the device on the address 0x50 at its register 0x10 enter this: | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# i2cget -y 1 0x50 0x10 </tt> | |||
|} | |||
:For a dump of the entire registers of the device at address 0x50 enter the following command: | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# i2cdump -f 1 0x50 </tt> | |||
|} | |||
=== Unsing the internal RTC === | |||
:Read out the current date and time of the system (not the RTC itself) | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# date</tt> | |||
|} | |||
:Set a specific system time | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# date -s "2020-01-30 10:00:00"</tt> | |||
|} | |||
:Save the current system time to the RTC of the STM32MP1 | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# hwclock -w</tt> | |||
|} | |||
: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. | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# hwclock -r</tt> | |||
|} | |||
:The system time can be synchronised to the RTC by this command: | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# hwclock -s</tt> | |||
|} | |||
=== Using the second UART port === | |||
:If you want to use the second UART Port available on the Low Speed Expansion Connector of the Avenger96, you can access it easily with the tool called minicom | |||
:To open up its configuration enter the following command | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# minicom -s</tt> | |||
|} | |||
:Once you've opend minicom, navigate to ''<tt>Serial port setup</tt>'' and change the Serial Device to ''<tt>/dev/ttySTM1</tt>''. | |||
:Now you can hit ''<tt>exit</tt>'' and you are in a terminal which is connected to the second UART port. | |||
:To reopen the settings of minicom press ''<tt>CTRL + A</tt>'' and then ''<tt>O</tt>'' on your keyboard. | |||
:To close minicom press ''<tt>CTRL + A</tt>'' and then ''<tt>X</tt>'' on your keyboard. | |||
=== Connecting to a WiFi network === | |||
:After bootup, you have to enter the following commands: | |||
:activating the wlan0 interface | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# ifconfig wlan0 up</tt> | |||
|} | |||
:Enter the SSID and the WPA Key | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# wpa_passphrase "YOUR SSID" your-wpa-key > wpa_supplicant.conf </tt> | |||
|} | |||
:Defining the settings | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# wpa_supplicant -B -Dnl8011 -iwlan0 -cwpa_supplicant.conf </tt> | |||
|} | |||
:After that you should get the message "successfully initialized wpa_supplicant" | |||
:Requesting an IP-Address from the DHCP-Server | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# udhcpc -i wlan0 </tt> | |||
|} | |||
:Checking your IP Address | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# ifconfig </tt> | |||
|} | |||
=== Connecting to a Bluetooth Device === | |||
:In this example you can see how to connect a bluetooth headset to the Avenger96 and play a song over it. | |||
:For this you have to first store a *.wav audiofile in the home directory (/home/root). | |||
:First start pulsaudio | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# pulseaudio --start</tt> | |||
|} | |||
:Bring up the Bluetooth Device | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# hciconfig hci0 up</tt> | |||
|} | |||
:Start the Bluetooth configuration tool | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# bluetoothctl</tt> | |||
|} | |||
:Now you are controlling the configuration tool. Here you can start the scanning for bluetooth devices | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''[bluetooth]# scan on</tt> | |||
|} | |||
:Once you see the device you like to connect to stop the scanning. | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''[bluetooth]# scan off</tt> | |||
|} | |||
:Now Copy the MAC-address of your bluetooth device and pair to it | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''[bluetooth]# pair xx:xx:xx:xx:xx:xx</tt> | |||
|} | |||
:Next add it to the list of trusted devices | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''[bluetooth]# trust xx:xx:xx:xx:xx:xx</tt> | |||
|} | |||
:Finally connect to it | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''[bluetooth]# connect xx:xx:xx:xx:xx:xx</tt> | |||
|} | |||
:Your Headphone should now be connected to the Avenger96, so you can leave the bluetooth configuration tool | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''[bluetooth]# exit</tt> | |||
|} | |||
:Now you can start playing your audiofile | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# aplay audiofile.wav</tt> | |||
|} | |||
:When you want to remove your device from the Avenger96, open ''<tt>bluetoothctl</tt>'' again and remove its MAC-address | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''[bluetooth]# remove xx:xx:xx:xx:xx:xx</tt> | |||
|} | |||
=== 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. | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# ip link set can0 up type can bitrate 500000</tt> | |||
|} | |||
:Start to listen on CAN port | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# candump can0</tt> | |||
|} | |||
:Send test message | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# cansend can0 100#11.2233.44556677.88</tt> | |||
|} | |||
:Deinitialize CAN port | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# ip link set can0 down</tt> | |||
|} | |||
=== Activating the MIPI CSI Interface === | |||
:The Avenger96 is compatible with the [https://www.96boards.org/product/d3camera/ 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 UART0 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. | ||
: | :{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | ||
:{| class="wikitable" style=" | |<tt>''# 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</tt> | ||
|} | |||
=== Mounting a USB Drive === | |||
:To mount a USB drive connect it to the Avenger96 and mount it with the following command | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# mount /dev/sda1 /mnt</tt> | |||
|} | |||
: | :Now your USB drive is available under the following directory | ||
:{| class="wikitable" | :{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | ||
|<tt>'' | |<tt>''# cd /mnt</tt> | ||
|} | |} | ||
: | :To unmount the drive enter the following command | ||
:{| class="wikitable" | :{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | ||
|<tt>'' | |<tt>''# umount /dev/sda1 </tt> | ||
|} | |} | ||
: | === Formatting and mounting the eMMC === | ||
:{| class="wikitable" | :At first you can check all block devices by this command | ||
|<tt>'' | :{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | ||
|<tt>''# lsblk</tt> | |||
|} | |} | ||
: | :First partitionate the eMMC device | ||
:{| class="wikitable" | :{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | ||
|<tt>'' | |<tt>''# cfdisk /dev/mmcblk2</tt> | ||
|} | |} | ||
:''' | :Now select the partitiontable ''<tt>gpt</tt>''. Then in the menu you can add a new partiton by entering ''<tt>new</tt>'' and then the size of your partition e.g. ''<tt>7G</tt>''. | ||
:* [[ | :After that enter ''<tt>write</tt>'' and confirm it with ''<tt>yes</tt>''. Then you can ''<tt>quit</tt>'' this tool. | ||
:Now you can format the new partition | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# mkfs.ext4 /dev/mmcblk2p1</tt> | |||
|} | |||
:To access this partition you have to mount it just like an USB-Stick | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# mount /dev/mmcblk2p1 /mnt</tt> | |||
|} | |||
=== Read out the ADC Pins === | |||
:The GPIOs G and H are mapped as ADC pins. These pins can meassure a value from 0 V to 2,9 V. This reference voltage of 2,9 V is driven by the LDO1 of the PMIC. | |||
:The value measured is calculated as followed: | |||
::''<tt>Umeassured = ( RAW + OFFSET ) * SCALE</tt>'' | |||
:You can read out the values as followed: | |||
:'''GPIO G:''' | |||
:Navigate to its directory | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# cd /sys/bus/iio/devices/iio:device0</tt> | |||
|} | |||
:Read out ''<tt>SCALE</tt>'' | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# cat in_voltage_scale</tt> | |||
|} | |||
:Read out ''<tt>OFFSET</tt>'' | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# cat in_voltage_offset</tt> | |||
|} | |||
:Once you know these two values, you can read the actual ADC value | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# cat in_voltage6_raw</tt> | |||
|} | |||
:'''GPIO H:''' | |||
:Navigate to its directory | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# cd /sys/bus/iio/devices/iio:device1</tt> | |||
|} | |||
:Read out ''<tt>SCALE</tt>'' | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# cat in_voltage_scale</tt> | |||
|} | |||
:Read out ''<tt>OFFSET</tt>'' | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# cat in_voltage_offset</tt> | |||
|} | |||
:Once you know these two values, you can read the actual ADC value | |||
:{| class="wikitable" align="center" | style="color: #000000; background: #FFFFFF;" valign="top" | | |||
|<tt>''# cat in_voltage2_raw</tt> | |||
|} | |||
== 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 === | |||
:{| class="wikitable" | |||
! style="background-color:#efefef; width: 200px; text-align:left" | 96Boards Name | |||
! style="background-color:#efefef; width: 200px; text-align:left" | Linux Name | |||
! style="background-color:#efefef; width: 200px; text-align:left" | Hardware Name | |||
|- | |||
| UART 0 | |||
| <tt>/dev/ttySTM1</tt> | |||
| UART 7 | |||
|- | |||
| UART 1 (Standard UART) | |||
| <tt>/dev/ttySTM0</tt> | |||
| UART 4 | |||
|} | |||
=== I²C Interfaces === | |||
:{| class="wikitable" | |||
! style="background-color:#efefef; width: 200px; text-align:left" | 96Boards Name | |||
! style="background-color:#efefef; width: 200px; text-align:left" | Linux Name | |||
! style="background-color:#efefef; width: 200px; text-align:left" | Hardware Name | |||
|- | |||
| I2C0 | |||
| <tt>/dev/i2c-1</tt> | |||
| I2C2 | |||
|- | |||
| I2C1 | |||
| <tt>/dev/i2c-0</tt> | |||
| I2C1 | |||
|- | |||
| OnBoard | |||
| <tt>/dev/i2c-2</tt> | |||
| I2C4 | |||
|} | |||
=== microSD and eMMC === | |||
:{| class="wikitable" | |||
! style="background-color:#efefef; width: 200px; text-align:left" | 96Boards Name | |||
! style="background-color:#efefef; width: 200px; text-align:left" | Linux Name | |||
! style="background-color:#efefef; width: 200px; text-align:left" | Hardware Name | |||
|- | |||
| microSD | |||
| <tt>mmcblk1</tt> | |||
| SDMMC1 | |||
|- | |||
| eMMC | |||
| <tt>mmcblk2</tt> | |||
| SDMMC2 | |||
|} | |||
=== GPIOs === | |||
:{| class="wikitable" | |||
! style="background-color:#efefef; width: 200px; text-align:left" | 96Boards Name | |||
! style="background-color:#efefef; width: 200px; text-align:left" | Linux Name | |||
! style="background-color:#efefef; width: 200px; text-align:left" | Hardware Name | |||
|- | |||
| A | |||
| <tt>gpiochip0 14</tt> | |||
| PA14 | |||
|- | |||
| B | |||
| <tt>gpiochip1 11</tt> | |||
| PB11 | |||
|- | |||
| C | |||
| <tt>gpiochip2 3</tt> | |||
| PC3 | |||
|- | |||
| D | |||
| <tt>gpiochip3 8</tt> | |||
| PD8 | |||
|- | |||
| E | |||
| <tt>gpiochip3 14</tt> | |||
| PD14 | |||
|- | |||
| F | |||
| <tt>gpiochip3 15</tt> | |||
| PD15 | |||
|- | |||
| G (mapped as ADC) | |||
| <tt>gpiochip5 12</tt> | |||
| PF12 | |||
|- | |||
| H (mapped as ADC) | |||
| <tt>gpiochip5 13</tt> | |||
| PF13 | |||
|- | |||
| I | |||
| <tt>gpiochip0 12</tt> | |||
| PA12 | |||
|- | |||
| J | |||
| <tt>gpiochip1 5</tt> | |||
| PB5 | |||
|- | |||
| K | |||
| <tt>gpiochip0 11</tt> | |||
| PA11 | |||
|- | |||
| L | |||
| <tt>gpiochip1 13</tt> | |||
| PB13 | |||
|} | |||
:Beside the GPIOs, the Avenger96 has also four user LEDs, which are controlled the same way as the GPIOs. | |||
:{| class="wikitable" | |||
! style="background-color:#efefef; width: 200px; text-align:left" | 96Boards Name | |||
! style="background-color:#efefef; width: 200px; text-align:left" | Linux Name | |||
! style="background-color:#efefef; width: 200px; text-align:left" | Hardware Name | |||
|- | |||
| LED 0 | |||
| <tt>/sys/class/leds/green:user0</tt> | |||
| PZ7 | |||
|- | |||
| LED 1 | |||
| <tt>/sys/class/leds/green:user1</tt> | |||
| PF3 | |||
|- | |||
| LED 2 | |||
| <tt>/sys/class/leds/green:user2</tt> | |||
| PG0 | |||
|- | |||
| LED 3 | |||
| <tt>/sys/class/leds/green:user3</tt> | |||
| PG1 | |||
|} | |||
== Linux Kernel == | |||
<!-- === Sources: Look at page [[DHCOM iMX6ULL-D2#BSP Sources|i.MX6ULL BSP Sources]] === --> | |||
=== How to build a Kernel === | |||
{| class="wikitable" align="center" | style="width: 98%; background: #f3f3f3;" valign="top" | | |||
| | |||
Get sources from Github | |||
{| class="wikitable" style="width: 100%; color: #000000; background: #ffffff;" | | |||
| | |||
1. Start the Console on Linux<br/> | |||
2. <tt>''git clone https://github.com/dh-electronics/linux-stm32mp1.git --branch dev/5.4.69_dhsom''</tt><br/> | |||
3. <tt>''cd linux-stm32mp1''</tt> | |||
|} | |||
Configure and build the Device Tree + Kernel | |||
{| class="wikitable" style="width: 100%; color: #000000; background: #ffffff;" | | |||
| | |||
4. <tt>''ARCH=arm CROSS_COMPILE=/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- make stm32mp1_dhsom_defconfig''</tt><br/> | |||
5. <tt>''ARCH=arm CROSS_COMPILE=/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- make menuconfig''</tt> (optional: If you want to add/remove Kernel features)<br/> | |||
6. <tt>''ARCH=arm CROSS_COMPILE=/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- make dtbs''</tt><br/> | |||
7. <tt>''ARCH=arm CROSS_COMPILE=/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- make zImage</tt> | |||
|} | |||
Create the FIT-image with our script ([https://www.dropbox.com/s/0jtyget66cxgq30/dh-create-fitimage_1.0_all.deb?raw=1 Download link]) | |||
{| class="wikitable" style="width: 100%; color: #000000; background: #ffffff;" | | |||
|- | |||
| '''Interactive mode for selecting device trees''' | |||
| '''Device trees are set as parameter''' | |||
|- | |||
| | |||
8. <tt>''create_fitimage''</tt><br/> | |||
Enter the numbers (space seperated) of the device trees to include (e.g. if you want to include the device tree for the Avenger96 include the number of <tt>''./arch/arm/boot/dts/stm32mp157a-avenger96.dtb''</tt> (usually 1).<br/> | |||
Enter the numbers (space seperated) of the device trees overlays to include (e.g. for the Avenger96 enter the files which contain <tt>''Avenger96''</tt> (usually 0 1 2 3 4 5 6 7). | |||
| | |||
(Example is for the Avenger96) <br> | |||
8. <tt>''create_fitimage --dtb ./arch/arm/boot/dts/stm32mp157a-avenger96.dtb --dtbo ./arch/arm/boot/dts/stm32mp157a-avenger96-overlay-644-100-x6-otm8009a.dtbo,./arch/arm/boot/dts/stm32mp157a-avenger96-overlay-644-100-x6-rpi7inch.dtbo,./arch/arm/boot/dts/stm32mp157a-avenger96-overlay-fdcan1-x6.dtbo,./arch/arm/boot/dts/stm32mp157a-avenger96-overlay-fdcan2-x6.dtbo,./arch/arm/boot/dts/stm32mp157a-avenger96-overlay-i2c1-eeprom-x6.dtbo,./arch/arm/boot/dts/stm32mp157a-avenger96-overlay-i2c2-eeprom-x6.dtbo,./arch/arm/boot/dts/stm32mp157a-avenger96-overlay-ov5640-x7.dtbo,./arch/arm/boot/dts/stm32mp157a-avenger96-overlay-spi2-eeprom-x6.dtbo''</tt> | |||
|} | |||
|} |
Latest revision as of 11:43, 22 February 2022
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 support:
> setenv loaddtos '#conf-stm32mp157a-avenger96.dtb#conf-stm32mp15xx-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-stm32mp15xx-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-stm32mp15xx-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
- For a dump of the entire registers of the device at address 0x50 enter the following command:
# i2cdump -f 1 0x50
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
- If you want to use the second UART Port available on the Low Speed Expansion Connector of the Avenger96, you can access it easily with the tool called minicom
- To open up its configuration enter the following command
# minicom -s
- Once you've opend minicom, navigate to Serial port setup and change the Serial Device to /dev/ttySTM1.
- Now you can hit exit and you are in a terminal which is connected to the second UART port.
- To reopen the settings of minicom press CTRL + A and then O on your keyboard.
- To close minicom press CTRL + A and then X on your keyboard.
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
- In this example you can see how to connect a bluetooth headset to the Avenger96 and play a song over it.
- For this you have to first store a *.wav audiofile in the home directory (/home/root).
- First start pulsaudio
# pulseaudio --start
- Bring up the Bluetooth Device
# hciconfig hci0 up
- Start the Bluetooth configuration tool
# bluetoothctl
- Now you are controlling the configuration tool. Here you can start the scanning for bluetooth devices
[bluetooth]# scan on
- Once you see the device you like to connect to stop the scanning.
[bluetooth]# scan off
- Now Copy the MAC-address of your bluetooth device and pair to it
[bluetooth]# pair xx:xx:xx:xx:xx:xx
- Next add it to the list of trusted devices
[bluetooth]# trust xx:xx:xx:xx:xx:xx
- Finally connect to it
[bluetooth]# connect xx:xx:xx:xx:xx:xx
- Your Headphone should now be connected to the Avenger96, so you can leave the bluetooth configuration tool
[bluetooth]# exit
- Now you can start playing your audiofile
# aplay audiofile.wav
- When you want to remove your device from the Avenger96, open bluetoothctl again and remove its MAC-address
[bluetooth]# remove xx:xx:xx:xx:xx:xx
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 1:
- FDCAN 2:
- PB13 - TX
- PB5 - RX
- FDCAN 2:
- 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 UART0 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
Mounting a USB Drive
- To mount a USB drive connect it to the Avenger96 and mount it with the following command
# mount /dev/sda1 /mnt
- Now your USB drive is available under the following directory
# cd /mnt
- To unmount the drive enter the following command
# umount /dev/sda1
Formatting and mounting the eMMC
- At first you can check all block devices by this command
# lsblk
- First partitionate the eMMC device
# cfdisk /dev/mmcblk2
- Now select the partitiontable gpt. Then in the menu you can add a new partiton by entering new and then the size of your partition e.g. 7G.
- After that enter write and confirm it with yes. Then you can quit this tool.
- Now you can format the new partition
# mkfs.ext4 /dev/mmcblk2p1
- To access this partition you have to mount it just like an USB-Stick
# mount /dev/mmcblk2p1 /mnt
Read out the ADC Pins
- The GPIOs G and H are mapped as ADC pins. These pins can meassure a value from 0 V to 2,9 V. This reference voltage of 2,9 V is driven by the LDO1 of the PMIC.
- The value measured is calculated as followed:
- Umeassured = ( RAW + OFFSET ) * SCALE
- You can read out the values as followed:
- GPIO G:
- Navigate to its directory
# cd /sys/bus/iio/devices/iio:device0
- Read out SCALE
# cat in_voltage_scale
- Read out OFFSET
# cat in_voltage_offset
- Once you know these two values, you can read the actual ADC value
# cat in_voltage6_raw
- GPIO H:
- Navigate to its directory
# cd /sys/bus/iio/devices/iio:device1
- Read out SCALE
# cat in_voltage_scale
- Read out OFFSET
# cat in_voltage_offset
- Once you know these two values, you can read the actual ADC value
# cat in_voltage2_raw
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 (Standard UART) /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 microSD mmcblk1 SDMMC1 eMMC mmcblk2 SDMMC2
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 (mapped as ADC) gpiochip5 12 PF12 H (mapped as ADC) 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
Linux Kernel
How to build a Kernel
Get sources from Github
Configure and build the Device Tree + Kernel
Create the FIT-image with our script (Download link)
|