使用systemd启动方式制作buildroot根文件系统

目录

1、make menuconfig 将busybox改成systemd

2、解决错误

(1)id: ‘privoxy’: no such user

(2)g++: fatal error: Killed signal terminated program cc1plus

(3)error: .obj/qwidget.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC

(4)mkfs.ext4: Could not allocate block in ext2 filesystem while populating file system


移植蓝牙驱动需要使用到systemctl命令,但是根文件系统中没有,我只能修改buildroot。

系统的初始化方式有多种:

busybox(集成了很多常用的命令)、

systemd(一种服务管理机制,很复杂,大大减慢了系统启动,systemctl是其主要命令)、

System V init(比较老的方式,service命令出自它)

1、make menuconfig 将busybox改成systemd

在按照正点教程使用busybox方式配置好了buildroot,然后make menuconfig搜索systemd,定位到具体位置,将busybux改为systemd,再make -j12编译。
注意systemd依赖glibc库,先选中这个库:在Toolchain下的C library中先选择glibc。

2、解决错误

(1)id: ‘privoxy’: no such user


编译时报错: 

Installing templates to /home/wang/linux/buildroot/buildroot-2020.02.6/output/target/etc/templates
id: ‘privoxy’: no such user
******************************************************************
 WARNING! WARNING! installing config files as root!
 It is strongly recommended to run privoxy as a non-root user,
 and to install the config files as that user and/or group!
 Please read INSTALL, and create a privoxy user and group!
*******************************************************************
GNUmakefile:800: recipe for target 'install' failed
make[1]: *** [install] Error 1
make[1]: Leaving directory '/home/wang/linux/buildroot/buildroot-2020.02.6/output/build/privoxy-3.0.26'
package/pkg-generic.mk:360: recipe for target '/home/wang/linux/buildroot/buildroot-2020.02.6/output/build/privoxy-3.0.26/.stamp_target_installed' failed

我不需要privoxy。
在make menuconfig中搜索privoxy,不选中它,再重新make。

(2)g++: fatal error: Killed signal terminated program cc1plus

又出错:

g++: fatal error: Killed signal terminated program cc1plus


原因是虚拟机的内存不够,添加虚拟内容swap。

sudo dd if=/dev/zero of=/swapfile bs=1M count=2048    # 1 * 2048 = 2048 创建 1 g 的内存分区
sudo mkswap /swapfile
sudo swapon /swapfile
# free -m    #可以查看内存使用
# 创建完交换分区之后就可以继续编译
# 编译完之后记得用以下命令关闭交换分区
# 某次我就是忘了关闭交换分区,导致开不了机,然后切换 tty1 ,登进去之后关闭交换分区才可以进入桌面的。
#2. 关闭分区
sudo swapoff /swapfile
sudo rm /swapfile

(3)error: .obj/qwidget.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC

编译再次遇到问题:

/usr/local/arm/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/../../../../arm-none-linux-gnueabihf/bin/ld.gold: error: .obj/qwidget.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC


这个问题没找到解决方案。

我make clean,重新改成systemd,再make

(4)mkfs.ext4: Could not allocate block in ext2 filesystem while populating file system


又报错: 

Copying files into the device: __populate_fs: Could not allocate block in ext2 filesystem while writing file "oldphone.wav"
mkfs.ext4: Could not allocate block in ext2 filesystem while populating file system
*** Maybe you need to increase the filesystem size (BR2_TARGET_ROOTFS_EXT2_SIZE)

根据提示,我把配置BR2_TARGET_ROOTFS_EXT2_SIZE由一开始的60M改成了500M,这次终于编译通过了!

实际编译得到的rootfs.tar大小是167,只要BR2_TARGET_ROOTFS_EXT2_SIZE比167大即可。

你可能感兴趣的:(驱动和内核,STM32MP157驱动调试,linux,linux,buildroot,systemd)