Stm32mp1 linux minimum root file system production tutorial (stm32mp157 development board practical operation)

Author: China Qingyuan see R & D center, Zhihao teacher.

Some users have feedback that regarding stm32mp1, the system officially provided by ST is too large, slow to boot, and takes up a lot of space. Based on this question, we have compiled the mirror image of the minimum root file system of Linux5.4.31 and the corresponding tutorial, hoping to help users who use the stm32mp157 development board.

1. Root file system development experiment

1.1 The purpose of the experiment

Familiar with the Linux file system directory structure, create your own file system, and pass the NFS test.

1.2 Experimental platform

Huaqing Vision Development Environment, FS-MP1A platform;

1.3 Experimental steps

1. Root file system production

You can download the busybox-1.29.3 source code from the http://busybox.net/downloads/ website to make the Linux file system. For convenience, the source code has been put on the CD.

Install the cross-compilation tool chain.

linux@ubuntu:$ sudo apt-get install gcc-arm-linux-gnueabihf
linux@ubuntu:$ sudo apt-get install g++-arm-linux-gnueabihf

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

linux@ubuntu:$ arm-linux-gnueabihf-gcc -v

Create source directory

linux@ubuntu:$ cd ~
linux@ubuntu:$ mkdir -p fs-mp1a

Copy busybox-1.29.3.tar.bz2 under [Huaqing Vision-FS-MP1A Development Materials\02-Program Source\04-Linux System Migration\01-Official Source] to this directory.

linux@ubuntu:$ tar xvf busybox-1.29.3.tar.bz2             //解压源码
linux@ubuntu:$ cd busybox-1.29.3

Configure busybox source code:

Modify the CROSS_COMPILE field in the Makefile in the top directory to "arm-linux-gnueabihf-"

You can use the following command to configure the source code

linux@ubuntu:$ make menuconfig

Compile the source code:

linux@ubuntu:$ make

installation:

The default installation path of busybox is _install in the source directory

linux@ubuntu:$ make install

Enter the installation directory:

linux@ubuntu:$ cd  _install
linux@ubuntu:$ ls
bin  linuxrc  sbin   usr

Create other required directories:

linux@ubuntu:$ mkdir   dev   etc  mnt   proc   var  tmp   sys   root

Add library:

Copy the library in the toolchain to the _install directory:

linux@ubuntu:$ cp /usr/arm-linux-gnueabihf/lib/ . -a

Delete the static library:

linux@ubuntu:$ rm lib/*.a	

Add system startup files:

Add the file inittab under etc. The content of the file is as follows:

Note: The modified files are all in the _install directory

etc/inittab

#this is run first except when booting in single-user mode.
::sysinit:/etc/init.d/rcS
# /bin/sh invocations on selected ttys
# start an "askfirst" shell on the console (whatever that may be)
::askfirst:-/bin/sh
# stuff to do when restarting the init process
::restart:/sbin/init
# stuff to do before rebooting
::ctrlaltdel:/sbin/reboot

Add the file fstab under etc. The contents of the file are as follows:

/etc/fstab

#device	mount-point	type	options    dump	fsck	order
proc 	/proc		proc 	defaults	0		0
tmpfs	/tmp		tmpfs	defaults	0		0
sysfs	/sys		sysfs	defaults	0		0
tmpfs	/dev		tmpfs	defaults	0		0

The file system we mounted here has three proc, sysfs and tmpfs.

Go back to the created file system, create the init.d directory under etc, and create the rcS file under init.d, the content of the rcS file is:

etc/init.d/rcS

#!/bin/sh
# This is the first script called by init process
/bin/mount   -a
/sbin/mdev   -s

Add executable permissions to rcS:

linux@ubuntu:$ chmod a+x init.d/rcS

Add a profile file under etc. The content of the file is:

etc/profile

#!/bin/sh
export HOSTNAME=fsmp1a
export USER=root
export HOME=root
export PS1="[$USER@$HOSTNAME \W]\# "
PATH=/bin:/sbin:/usr/bin:/usr/sbin
LD_LIBRARY_PATH=/lib:/usr/lib:$LD_LIBRARY_PATH
export PATH   LD_LIBRARY_PATH

2. NFS test

Delete the original /source/rootfs:

linux@ubuntu:$ sudo rm -rf /source/rootfs

Copy our newly created root file system to the /source/rootfs directory

linux@ubuntu:$ sudo mkdir /source/rootfs
linux@ubuntu:$ sudo cp _install/* /source/rootfs -a

Modify the /tftpboot/pxelinux.cfg/01-00-80-e1-42-60-17 file in the ubuntu host to add the nfs boot option

# Generic Distro Configuration file generated by OpenEmbedded
menu title Select the boot mode
MENU BACKGROUND /splash.bmp
TIMEOUT 20
DEFAULT stm32mp157a-fsmp1a-emmc
LABEL stm32mp157a-fsmp1a-emmc
    KERNEL /uImage
    FDT /stm32mp157a-fsmp1a.dtb
    APPEND root=/dev/mmcblk2p4 rootwait rw console=ttySTM0,115200
LABEL stm32mp157a-fsmp1a-nfs
    KERNEL /uImage
    FDT /stm32mp157a-fsmp1a.dtb
    APPEND root=/dev/nfs nfsroot=192.168.11.251:/source/rootfs ip=dhcp rootwait rw earlyprintk console=ttySTM0,115200

There are two startup items in the above configuration: stm32mp157a-fsmp1a-emmc and stm32mp157a-fsmp1a-nfs. Among them, the stm32mp157a-fsmp1a-emmc option is the normal startup configuration; stm32mp157a-fsmp1a-nfs is the nfs mounting method. It should be noted here that the ip of the nfsroot=192.168.11.251 part needs to be filled in according to the actual ip of the ubunut host.

Restart the development board and select the nfs startup option.

Check whether it can be mounted normally and whether the function is normal

 

2. Make the root file system mirror

The root file system has been created in the previous section, and it has been successfully booted from NFS. This section will make a root file system image for subsequent curing and burning.

2. Make a file system in ext4 format

Create an empty EXT4 file in ubuntu, here is set to 300M size, because the file system will be very large when more software is installed, the user can change it according to the situation.

linux@ubuntu:$ dd if=/dev/zero of= fsmp1x_rootfs.ext4 bs=300M count=1
linux@ubuntu:$ sudo mkfs.ext4 fsmp1x_rootf.ext4

2. Copy the file system

Mount the fuubuntu18_rootfs.ext4 file in the file system that we transplanted in the previous section to the temporary directory /mnt, and copy the file system.

linux@ubuntu:$ sudo mount -o loop fsmp1x_rootf.ext4 /mnt

If we have made the previous file system, just copy the files under /source/rootfs/

linux@ubuntu:$ sudo cp /source/rootfs/* /mnt -a

If we did not compile and make the file system before, we can also use the rootfs.tar.xz file under [Huaqing Vision-FS-MP1A Development Information\02-Program Source\04-Linux System Migration\02-Migrated System Image File] Import it into the virtual machine and use the file system we have already transplanted to make.

linux@ubuntu:$ sudo tar -xvf rootfs.tar.xz -C /mnt

3. Unmount the mounted fsmp1x_rootf.ext4 file

linux@ubuntu:$ sudo umount /mnt

The mirroring with the file system is now complete. You can export this file to Windows and burn it to the development board to run.

4. Modify the burning file

If you want to burn to the development board, you need to modify and burn the file. Here we take the trusted image started by eMMC as an example. The modification methods for other startups are similar.

Modify the FlashLayout_sdcard_stm32mp157a-fsmp1a-trusted.tsv file under flashlayout_fs-mp1a-weston\trusted to change the rootfs partition mirror name with the Id 0x23 from fs-mp1a-weston-openstlinux-weston-fsmp1a.ext4 to fsmp1x_rootf.ext4. Follow the "STM32CubeProgrammer Programming Method" chapter to burn.

Guess you like

Origin blog.csdn.net/u014170843/article/details/109642652