2023-09-18 08:23 PM
Take MYIR’s MYD-YF13X and the STM32MP135F-DK as examples to share training course on how to use STM32CubeMX combined with the developer package to implement the booting of the minimal system.
https://www.myirtech.com/news_list.asp?id=877
1. Development Preparation
1.1 Developer package preparation
a. Developer Package Download:
https://www.st.com/en/embedded-software/stm32mp1dev.html
b. Unzip it and Access the Source Folder:
c. Source Code Preparation (can be prepared according to the third point in README.HOW_TO.txt in each source folder):
$> cd tf-a-stm32mp-v2.6-stm32mp-r2-r0
$> tar xf tf-a-stm32mp-v2.6-stm32mp-r2-r0.tar.xz
$> cd tf-a-stm32mp-v2.6-stm32mp-r2
$> for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
$> cd optee-os-stm32mp-3.16.0-stm32mp-r2-r0
$> tar xf optee-os-stm32mp-3.16.0-stm32mp-r2-r0.tar.xz
$> cd optee-os-stm32mp-3.16.0-stm32mp-r2
$> tar xf ../fonts.tar.gz
$> for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
$> cd u-boot-stm32mp-v2021.10-stm32mp-r2-r0
$> tar xf u-boot-stm32mp-v2021.10-stm32mp-r2-r0.tar.xz
$> cd u-boot-stm32mp-v2021.10-stm32mp-r2
$> for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
$> cd linux-stm32mp-5.15.67-stm32mp-r2-r0
$> tar xf linux-5.15.67.tar.xz
$> cd linux-5.15.67
$> for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
1.2 SDK Installation
Please read the WIKI to complete Install_the_SDK.
1.3 STM32CubeProgrammer Installation
Please follow the commands/steps given by WIKI to install CubeProgrammer and libusb Installation.
2. Block Diagram
First please review MYIR's schematic framework:
The following hardware configuration information can be derived from the block diagram:
1. STM32MP135DAF7
2. DDR3L
3. Separate power supply design
4. Support QSPI NAND, SD card boot
5. Dual Gigabit Ethernet ports
6. USB Host
7. USB OTG (for burning)
8. UART4 debug serial port
9. External Clock Source, HSE (24MHz), LSE (32.768KHz)
3. STM32CubeMX Project Creation
Open STM32CubeMX, select the correct chip package according to the chip's part number and start the project creation. e.g. MYIR uses STM32MP135DAF7.
Clicking "Generate Code" will create a nearly empty project, the device tree structure:
NOTE: The rule for STM32CubeMX is to build the Kernel dts first, then copy the generated dts file to the u-boot folder. In other words, the device tree of u-boot stm32mp135d-myir_bring_up-mx.dts is copied from the Kernel directory, so when you modify the device tree and add User code in U-Boot stage, please modify the device tree of Kernel synchronously, or copy the modified device tree to the Kernel directory. This will prevent the modification of the u-boot part from being overwritten by the unmodified device tree of the kernel when CubeMX builds the device tree next time.
Creates the device tree link:
PC $> cd
PC $> ln -s /local/home/xxx/Desktop/STM32CubeMX/myir_bring_up/DeviceTree/myir_bring_up/tf-a/* fdts/
PC $> cd
PC $> ln -s /local/home/xxx/Desktop/STM32CubeMX/myir_bring_up/DeviceTree/myir_bring_up/optee-os/* core/arch/arm/dts/
PC $> cd
PC $> ln -s /local/home/xxx/Desktop/STM32CubeMX/myir_bring_up/DeviceTree/myir_bring_up/u-boot/* arch/arm/dts/
2023-09-18 10:38 PM - edited 2023-09-18 10:55 PM
Very nice to see some help from module suppliers. Followed all these basic steps for STM32MP157 as well, specialy clock configuration, but its just the beginning of a journey full of problems.
and
This will prevent the modification of the u-boot part from being overwritten by the unmodified device tree of the kernel when CubeMX builds the device tree next time.
Great note. it should marked as a bug, CubeMX should not touch user areas.
2023-09-20 01:54 AM
Thanks for your attention. The rule of STM32CubeMX is to generate Kernel dts and then copy the generated dts file to the u-boot directory. In other words, the u-boot device tree stm32mp135d-myir_bring_up-mx.dts is copied from the kernel directory. Therefore, when modifying the device tree in the U-Boot phase and adding User code, modify the kernel device tree at the same time or copy the modified device tree to the Kernel directory to prevent the u-boot modification from being overwritten by the unmodified device tree in the kernel next time when CubeMX is used to generate the device tree.