stm32mp1 系列已经出来有一段时间了,最近需要用到,具体的上网查了查,发现 stm32mp1 系列的芯片使用的文件系统都是比较大的,针对一些应用场合是用不到的,本文对其进行最小文件系统的制作,以及制作过程出现的相关问题。制作文件系统还是使用 busybox。其过程基本上都能在网上查到,本文主要做相关记录。
相关环境、软件
编译器:i2som-image-weston-openstlinux-weston-pangu-x86_64-toolchain-2.6-snapshot
软件版本:busybox-1.31.0
下载编译器等文件路径 下载
编译
解压 busybox-1.31.0.tar.bz2 文件,进入文件夹,输入 make menuconfig 进入配置 界面,定义动态库、编译器、安装目录。
Settings —>
[ * ] Build shared libbusybox
(arm-openstlinux_weston-linux-gnueabi-) Cross compiler prefix
(./rootfs) Destination path for ‘make install’
添加环境变量,否则编译后会出现错误。在 busybox-1.31.0 目录下,输入 env 会出现如下环境变量
填写以下3个环境变量,
Settings —>
() Path to sysroot
() Additional CFLAGS
() Additional LDFLAGS
- Path to sysroot 填入 --sysroot= 后面的编译器环境变量,
- Additional CFLAGS 填入 CPP 的 -E 后面的变量,
- Additional LDFLAGS 填入 --sysroot= 及其后面的编译器环境变量。
保存配置,然后 make,完成后 make install ,在 rootfs 目录下就有了4个文件夹1个文件
编辑
在安装的 rootfs 上添加目录 dev etc home mnt opt proc root sys tmp var
在etc 目录下添加文件 fstab group inittab passwd profile 等文件(注意:所有文件的换行符为 \n),
fstab
proc /proc proc defaults 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
tmpfs /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
inittab
::sysinit:/etc/init.d/rcS
ttySTM0::respawn:-/bin/ash
::restart:/sbin/init
::shutdown:/bin/umount -a -r
注:stm32mp1 上的串口为 ttySTM0
profile
export PS1="[\u@\h \W]# "
if [ ! -z ${SSH_TTY} ]; then
export PATH=/sbin:/usr/sbin:/bin:/usr/bin
fi
group
root:x:0:
passwd
root:x:0:0:root:/root:/bin/sh
rcS
在 etc 目录下新建目录 init.d,并在新建的 init.d 目录下新建文件 rcS,同时让其获取执行权限 chmod 755 rcS
echo "Starting rcS..."
echo "++ Mounting filesystem"
mkdir -p /dev/pts
mkdir -p /dev/i2c
mount -a
echo "++ Setting wathcdog"
watchdog -t 30 /dev/watchdog0
echo "++ Setting up mdev"
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
echo "rcS Complete"
注:stm32mp1 默认开启看门狗
,故需要在启动文件加上喂狗操作,否则系统会不断重启。此处添加30s 喂狗操作 watchdog -t 30 /dev/watchdog0
。
除此之外,还需要把编译器下的 sysroots/cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi/lib 目录的所有库文件复制到 rootfs 里的 lib 目录下,至此,文件系统制作基本完成。
问题
1、 编译出现 limits.h:194:61: error: no include path in which to search for limits.h
,如下
include-fixed/limits.h:194:61: error: no include path in which to search for limits.h
#include_next <limits.h> /* recurse down to the real one */
^
In file included from include/libbb.h:13,
from include/busybox.h:8,
from applets/applets.c:9:
include/platform.h:164:11: fatal error: byteswap.h: No such file or directory
# include <byteswap.h>
^~~~~~~~~~~~
compilation terminated.
scripts/Makefile.build:197: recipe for target 'applets/applets.o' failed
解决方法
:如文章上述说明,填写以下3个环境变量,
Settings —>
() Path to sysroot
() Additional CFLAGS
() Additional LDFLAGS
2、 制作完系统后,系统一直重启。
解决方法
:如文章上述说明,在启动文件 /etc/init.d/rcS
文件中添加喂狗操作 watchdog -t 30 /dev/watchdog0
3、 系统启动时出现 can't run '/etc/init.d/rcS': Permission denied
解决方法
:使用chmod
命令获取运行权限, chmod 755 rcS
4、系统启动后, /sys
目录为空
解决方法
:如文章上述说明,在 fstab
文件中添加 sysfs /sys sysfs defaults 0 0
,让其启动后挂载。
附
busybox 中没有 mkfs.ext4 命令,可使用 e2fsprogs 源码包来编译生成。下载解压,进入目录配置:
./configure --prefix=/home/XXX/out/ --host=arm
然后 make
与 make install
就可以在 out/sbin
文件夹下发现 mkfs.ext4
,将其放入文件系统的 /sbin
目录下即可使用。