This article is one of the series of stm32mp157 Linux system transplantation and development. The development platform used by the author is Huaqing vision fs-mp1a development board (stm32mp157 development board). Stm32mp157 is an arm dual core, two A7 cores and one M4 core. Linux operating system can be run on A7 core, and real-time operating systems such as FreeRTOS and RT thread can be run on M4 core. Stm32mp157 development board, so you can learn both embedded Linux and STM32 MCU.

For fs-mp1a development board, in addition to Linux system transplantation, it also includes other series of tutorials, including cortex-a7 development, cortex-m4 development, expansion board driver transplantation, Linux application development, FreeRTOS system transplantation, linux driver development, hardware design, artificial intelligence machine vision, QT application programming, QT comprehensive project practice, etc.

————————————————

Description before system migration

About the command line prompt:

The operation of executing commands will be involved in the experimental steps. In order to distinguish whether the operation is completed on Ubuntu or on the development board, different operations will have different prompts:

When operating Ubuntu, the command line prompt is: [email protected] :$

When operating on the development board Linux system, the command line prompt is: [email protected] :$

During u-boot of the development board, the command prompt is: stm32mp >

Note: because some operations need to be completed in a specific directory, the command line prompt is long, such as:

[email protected] :~/FS-MP1A/stm32mp1-openstlinux-5.4-dunfell-mp1-20-06-24/sources/arm-ostl-linux-gnueabi/u-boot-stm32mp-2020.01-r0/u-boot-stm32mp-2020.01$

Too long command line prompt is not convenient for document writing, so all command line prompts in this article ignore the display of the current working directory. The command line prompt does not represent the current directory. Please determine the specific directory under which the current operation is completed in combination with the document context.

1. Source code compilation

1.1 source directory structure

1.1.1 compilation environment configuration

Because openstlinux involves many source codes and path dependence. So follow the instructions in this article to create a source folder.

Create a fs-mp1a folder in the user’s home directory.

[email protected] : $ cd ~

[email protected] : $ mkdir fs-mp1a

Switch the working directory to fs-mp1a directory and create Linux, optee OS, trusted firmware, u-boot and tools folders

[email protected] : $ cd ~/fs-mp1a

[email protected] : $ mkdir linux optee-os trusted-firmware u-boot tools

Be sure to create a folder according to this directory name, otherwise it will lead to subsequent openst Linux system compilation errors.

1.1.2 SDK tool chain installation

Openstlinux SDK is a software development kit for yocto SDK customized distribution. It provides an independent cross development tool chain and a specific link library for specific images.

The SDK provided in the development data CD is a customized cross compilation tool chain based on fs-mp1a development board, which can be used for compilation and debugging of all projects in fs-mp1a development board.

Download en.sdk-x86 of [Huaqing foresight fs-mp1a development data \ 01 tool software] on the data CD_ 64-stm32mp1-openstlinux-5.4-duncell-mp1-20-06-24.tar.xz can be copied to the Ubuntu host. You can share folders or use TFP to store the files in the tools folder under the fs-mp1a source directory for decompression.

[email protected] : $ tar -xvf en.SDK-x86_ 64-stm32mp1-openstlinux-5.4-dunfell-mp1-20-06-24.tar.xz -C /home/linux/fs-mp1a/tools/

Extract the SDK directory. After entering the SDK folder, the contents are as follows.

Execute st-image-weston-openstlinux-weston-stm32mp1-x86_ 64-toolchain-3.1-openstlinux-5.4-duncell-mp1-20-06-24.sh installation script.

[email protected] : $ ./st-image-weston-openstlinux-weston-stm32mp1-x86_ 64-toolchain-3.1-openstlinux-5.4-dunfell-mp1-20-06-24.sh

After running, you will be prompted to enter the installation location. Press enter directly to default:

Continue to ask whether to install the SDK, enter y and press enter

The default installation path is installed in the opt directory. This directory needs root permission, so sudo installation needs to be used during installation. In the process, you need to enter the user’s sudo password (if the current user’s sudo function has been authorized, this password is the user’s login password). Enter the password and start the installation.

Enter the password and wait for installation. After installation, the following is displayed:

Import SDK

[email protected] : $ source /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi

Verify that the development tool is installed correctly, and the version information is displayed as shown in the figure below.

[email protected] : $ $CC –version

1.1.3 source code import

Bootloader source code

Import the u-boot-fsmp1a-2020.01.tar.xz and makefile.sdk under [Huaqing vision fs-mp1a development materials \ 02 program source code \ 05 pre installed system source code \ u-boot] in the CD-ROM into the u-boot folder under fs-mp1a directory

Unzip u-boot-fsmp1a-2020.01.tar.xz to get the u-boot-fsmp1a-2020.01 folder

[email protected] :$ tar -xvf u-boot-fsmp1a-2020.01.tar.xz

Trusted firmware source code

Import fsmp1a-trusted-firmware-2.2.tar.xz and makefile.sdk under [Huaqing vision fs-mp1a development materials \ 02 program source code \ 05 pre installed system source code \ TF-A] in the CD-ROM into the trusted firmware folder under fs-mp1a directory

Extract fsmp1a-trusted-firmware-2.2.tar.xz to get the fsmp1a-trusted-firmware-2.2 folder

[email protected] :$ tar -xvf fsmp1a-trusted-firmware-2.2.tar.xz

optee_ OS source code

Put fsmp1a optee under [Huaqing vision fs-mp1a development data \ 02 program source code \ 05 pre installed system source code \ optee] in the CD-ROM_ Import os-3.9.0.tar.xz and makefile.sdk into the optee OS folder under fs-mp1a directory

Fsmp1a optee_ After os-3.9.0.tar.xz is decompressed, fsmp1a optee is obtained_ Os-3.9.0 folder

[email protected] :$ tar -xvf fsmp1a-optee_ os-3.9.0.tar.xz

Linux source code

Import fsmp1a-linux-5.4.31.tar.xz under [Huaqing vision fs-mp1a development materials \ 02 program source code \ 05 pre installed system source code \ Linux] into the Linux folder under fs-mp1a directory

Extract fsmp1a-linux-5.4.31.tar.xz to get the fsmp1a-linux-5.4.31 folder

[email protected] :$ tar -xvf fsmp1a-linux-5.4.31.tar.xz

Yocto source code

Import fsmp1a-st-yocto.tar.xz under [Huaqing vision fs-mp1a development data \ 02 program source code \ 05 pre installed system source code \ yocto] into fs-mp1a directory

Extract fsmp1a-st-yocto.tar.xz to get the fsmp1a-st-yocto folder

[email protected] :$ tar -xvf fsmp1a-ST-Yocto.tar.xz

Download.tar.xz under [Huaqing vision fs-mp1a development data \ 02 program source code \ 05 pre installed system source code \ yocto] in the disk data is imported into the fsmp1a-st-yocto folder obtained by fsmp1a-st-yocto.tar.xz.

Unzip downloads.tar.xz to get the downloads folder.

[email protected] :$ tar -xvf downloads.tar.xz

So far, all the source code of openstlinux has been imported. After importing the source code, the fs-mp1a directory structure is as follows.

1.2 compilation of u-boot source code

Import the cross compilation tool chain and verify it

[email protected] :$ source /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi

[email protected] :$$CC –version

Switch the working directory to the u-boot-fsmp1a-2020.01 source directory.

[email protected] :$ cd ${HOME}/fs-mp1a/u-boot/u-boot-fsmp1a-2020.01

Import the configuration file.

The u-boot of fsmp1a can support three configurations: basic, trusted and optee. Corresponding to three configuration files.

The trusted configuration is used here to compile

[email protected] :$ make stm32mp15_ trusted_ defconfig

Compile source code

[email protected] :$ make DEVICE_ TREE=stm32mp157a-fsmp1a all

After compilation, the u-boot.img file is obtained

Compile using makefile.sdk

In addition to the traditional compilation method, you can also compile the image through makefile.sdk in the upper directory. Using this method, you need to clear the previously compiled source code before compiling, otherwise it will lead to compilation errors.

[email protected] :$ make distclean

Compile basic image

[email protected] :$ make -f $PWD/../Makefile.sdk all UBOOT_ CONFIGS=stm32mp15_ fsmp1a_ basic_ defconfig,basic,u-boot.img

After successful compilation, the build basic directory will be generated in the parent directory. U-boot-stm32mp157a-fsmp1a-basic.img and u-boot-spl.stm32-stm32mp157a-fsmp1a-basic are the generated burn images

Compiling trusted images

[email protected] :$make -f $PWD/../Makefile.sdk all UBOOT_ CONFIGS=stm32mp15_ fsmp1a_ trusted_ defconfig,trusted,u-boot.stm32

After successful compilation, the build trusted directory will be generated in the parent directory. U-boot-stm32mp157a-fsmp1a-trusted.stm32 is the generated burn image

Compile optee image

[email protected] :$ make -f $PWD/../Makefile.sdk all UBOOT_ CONFIGS=stm32mp15_ fsmp1a_ trusted_ defconfig,optee,u-boot.stm32

After successful compilation, the build optee directory will be generated in the parent directory. U-boot-stm32mp157a-fsmp1a-optee.stm32 is the generated burn image

Compile basic, trusted, and optee images

[email protected] :$ make -f $PWD/../Makefile.sdk all

After successful compilation, build basic, build trusted and build optee directories will be generated in the parent directory at the same time.

1.3 TF-A source code compilation

Import the cross compilation tool chain and verify it

[email protected] :$ source /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi

[email protected] :$ $CC –version

Switch the working directory to the fsmp1a-trusted-firmware-2.2 source directory.

[email protected] :$ cd ${HOME}/fs-mp1a/trusted-firmware/fsmp1a-trusted-firmware-2.2

Compiling trusted images

[email protected] :$ make -f $PWD/../Makefile.sdk TFA_ DEVICETREE=stm32mp157a-fsmp1a TF_ A_ CONFIG=trusted ELF_ DEBUG_ ENABLE=’1′ all

After successful compilation, the build directory will be generated in the superior directory. Tf-a-stm32mp157a-fsmp1a-trusted.stm32 in the trusted directory under the build directory is the burning image.

Compile optee image

[email protected] :$ make -f $PWD/../Makefile.sdk TFA_ DEVICETREE=stm32mp157a-fsmp1a TF_ A_ CONFIG=optee ELF_ DEBUG_ ENABLE=’1′ all

After successful compilation, the build directory will be generated in the parent directory. Tf-a-stm32mp157a-fsmp1a-optee.stm32 in the optee directory under the build directory is the burning image.

Compile trusted and optee images

[email protected] :$ make -f $PWD/../Makefile.sdk all

After the compilation is successful, the build directory will be generated in the parent directory, where both trusted and optee directories are generated at the same time.

1.4 optee OS source code compilation

Import the cross compilation tool chain and verify it

[email protected] :$ source /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi

[email protected] :$ $CC –version

Switch the working directory to fsmp1a optee_ Os-3.9.0 source directory.

[email protected] :$ cd ${HOME}/fs-mp1a/optee-os/fsmp1a-optee_ os-3.9.0

Compile source code

[email protected] :$ make -f $PWD/../Makefile.sdk CFG_ EMBED_ DTB_ SOURCE_ FILE=stm32mp157a-fsmp1a

After the compilation is successful, the build directory will be generated in the parent directory, and the tee header in its directory will be generated_ v2-stm32mp157a-fsmp1a-optee.stm32、tee-pageable_ v2-stm32mp157a-fsmp1a-optee.stm32、tee-pager_ V2-stm32mp157a-fsmp1a-optee.stm32 is the burning image.

1.5 Linux source code compilation

Import the cross compilation tool chain and verify it

[email protected] :$ [email protected] :$ source /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi

[email protected] :$ $CC –version

Switch the working directory to the fsmp1a-linux-5.4.31 source directory.

[email protected] :$cd ${HOME}/fs-mp1a/linux/fsmp1a-linux-5.4.31

Import profile

[email protected] :$make stm32_ fsmp1a_ defconfig

If you need to modify the configuration, you can use the following command to start menuconfig

[email protected] :$make menuconfig

Compile kernel image

[email protected] :$make -j4 ARCH=arm uImage vmlinux LOADADDR=0xC2000040

After successful compilation, the uimage file will be generated in the arch / arm / boot / directory

Generate vmlinux files for debugging in the source directory

Compile device tree file

[email protected] :$make ARCH=arm dtbs

After successful compilation, stm32mp157a-fsmp1a.dtb, stm32mp157a-fsmp1a-rgb070.dtb and stm32mp157a-fsmp1a-mipi050.dtb files will be generated in the arch / arm / boot / DTS directory

Stm32mp157a-fsmp1a-rgb070.dtb is the device tree file of RGB screen

Stm32mp157a-fsmp1a-mipi050.dtb is the device tree file of Mipi screen

Compiling kernel modules

[email protected] :$make ARCH=arm modules

[email protected] :$make ARCH=arm INSTALL_ MOD_ PATH=”$PWD/../build/install_arTIfact” modules_ install

After successful compilation, the build directory will be generated in the upper directory, including install_ Stored in the artifact directory is the exported driver module.

1.6 yocto build system

Switch the working directory to the fsmp1a St yocto source directory.

[email protected] :$cd ${HOME}/fs-mp1a/ fsmp1a-ST-Yocto

Import compilation configuration

[email protected] :$DISTRO=openstlinux-weston MACHINE=fsmp1a source layers/meta-farsight/scripts/envsetup.sh

The following interface prompts that the Ubuntu version of the host is different from the expected version. Enter y here

If this is the first configuration, you need to agree to some protocols and enter y..

Then press the spacebar to the bottom of the protocol

Enter y and the following interface will appear

Compile source code

[email protected] :$bitbake fs-mp1a-weston

Note: when compiling the yocto system, ensure that the Ubuntu host can connect to the Internet

Because openstlinux involves a lot of source code, compilation will be more time-consuming.

After compilation, the generated image file is saved in the TMP glibc / deploy / images / fsmp1a / directory.

Here, the burning image required by fs-mp1a development board is generated, including basic, trusted and optee.

Basic proprietary image

u-boot-spl.stm32-stm32mp157a-fsmp1a-basic

u-boot-stm32mp157a-fsmp1a-basic.img

Trusted proprietary image

tf-a-stm32mp157a-fsmp1a-trusted.stm32

u-boot-stm32mp157a-fsmp1a-trusted.stm32

Optee proprietary image

tf-a-stm32mp157a-fsmp1a-optee.stm32

u-boot-stm32mp157a-fsmp1a-optee.stm32

tee-header_ v2-stm32mp157a-fsmp1a-optee.stm32

tee-pageable_ v2-stm32mp157a-fsmp1a-optee.stm32

tee-pager_ v2-stm32mp157a-fsmp1a-optee.stm32

Common mirror

st-image-bootfs-openstlinux-weston-fsmp1a.ext4

st-image-userfs-openstlinux-weston-fsmp1a.ext4

st-image-vendorfs-openstlinux-weston-fsmp1a.ext4

fs-mp1a-weston-openstlinux-weston-fsmp1a.ext4

configuration file

flashlayout_ The fs-mp1a-weston folder stores the configuration files used during burning

As can be seen from the figure above, the configuration file is divided into sdcard burning configuration and EMMC burning configuration.

Leave a Reply

Your email address will not be published. Required fields are marked *