编译内核:
1、将STM32MP15-Ecosystem-v1.1.0开发人员软件包源下载到以下目录
cd $ HOME / STM32MPU_workspace / STM32MP15-Ecosystem-v1.1.0 / Developer-Package
2、解压缩tarball文件以获得Linux®内核tarball,ST补丁和ST配置片段
tar xvf zh.SOURCES-kernel-stm32mp1-openstlinux-4.19-thud-mp1-19-10-09.tar.xz
提取linux源代码:
cd stm32mp1-openstlinux-4.19-thud-mp1-19-10-09 / sources / arm-openstlinux_weston-linux-gnueabi / linux-stm32mp-4.19-r0
tar xvf linux- 4.19.49.tar.xz
- 应用ST补丁
cd linux-4.19.49
for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
1.前提条件
2.通过SDK初始化交叉编译
3.准备内核源代码
4.管理内核源代码
5.配置内核源代码
6.编译内核源代码
7.更新板载软件
1、2、启动sdk:$> source <path to SDK>/environment-setup-cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi
验证是否启动ok:set | grep CROSS
3、cd linux-4.19.49
如果有补丁,请在源代码上应用
for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
5、cd linux-4.19.49
配置构建新的目录(新目录下)
mkdir -p ../build
make ARCH=arm O="$PWD/../build" multi_v7_defconfig fragment*.config
for f in `ls -1 ../fragment*.config`; do scripts/kconfig/merge_config.sh -m -r -O $PWD/../build $PWD/../build/.config $f; done
yes '' | make ARCH=arm oldconfig O="$PWD/../build"
6、编译内核到构建目录上
$> cd <build directory>
* Build kernel images (uImage and vmlinux) and device tree (dtbs)
$> make ARCH=arm uImage vmlinux dtbs LOADADDR=0xC2000040
* Build kernel module
$> make ARCH=arm modules
* Generate output build artifacts
$> make ARCH=arm INSTALL_MOD_PATH="$PWD/../build/install_artifact" modules_install
$> mkdir -p $PWD/../build/install_artifact/boot/
$> cp $PWD/../build/arch/arm/boot/uImage $PWD/../build/install_artifact/boot/
$> cp $PWD/../build/arch/arm/boot/dts/st*.dtb $PWD/../build/install_artifact/boot/
7、通过网络更新
* kernel + devicetree
$> cd <path to install_artifact dir>/install_artifact
$> ssh root@<ip of board> mount <device corresponding to bootfs> /boot
$> scp -r boot/* root@<ip of board>:/boot/
$> ssh root@<ip of board> umount /boot
* kernel modules
$> cd <path to install_artifact dir>/install_artifact
Remove the link on install_artifact/lib/modules/<kernel version>/
$> rm lib/modules/<kernel version>/source lib/modules/<kernel version>/build
Optionally, strip kernel modules (to reduce the size of each kernel modules)
$> find . -name "*.ko" | xargs $STRIP --strip-debug --remove-section=.comment --remove-section=.note --preserve-dates
Copy kernel modules:
$> scp -r lib/modules/* root@<ip of board>:/lib/modules/
Generate a list of module dependencies (modules.dep) and a list of symbols
provided by modules (modules.symbols):
$> ssh root@<ip of board> /sbin/depmod -a
Synchronize data on disk with memory
$> ssh root@<ip of board> sync
Reboot the board in order to take update into account
$> ssh root@<ip of board> reboot
修改配置内核:
cd <build-path>
make arch = ARM savedefconfig 保存初始配置
结果存储在defconfig文件中
PC $> cp defconfig defconfig.old
make menuconfig 配置内核
例如配置cma
dmesg | grep -i cma 查看初始大小
Navigate to "Device Drivers - Generic Driver Options"
- select "Size in Megabytes"
- modify its value to 256
- exit and save the new configuration
- Check that the configuration file (.config) has been modified
- PC $> grep -i CONFIG_CMA_SIZE_MBYTES .config
- CONFIG_CMA_SIZE_MBYTES=256
配置完成后
通过比较新的defconfig和旧的defconfig来检索配置更新(meld未发现则安装sudo apt-get install meld)
meld defconfig defconfig.old
PC $> make arch = ARM uImage LOADADDR = <内核的loadaddr>
PC $> cp arch/arm/boot/uImage install_artifact/boot/
- 更新板载Linux内核映像
PC $> scp install_artifact /boot/uImage root@<板ip地址>:/boot/
Board $> cd /boot; sync; systemctl reboot
同步、重启
dmesg | grep -i cma