STM32MP157-openLinux 更改、重建加载linux内核

编译内核:

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

3cd linux-4.19.49

如果有补丁,请在源代码上应用

for p in `ls -1 ../*.patch`; do patch -p1 < $p; done

5cd 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

 

修改配置内核:

 

https://wiki.st.com/stm32mpu/wiki/Menuconfig_or_how_to_configure_kernel#Menuconfig_and_Developer_Package

https://wiki.st.com/stm32mpu/wiki/How_to_cross-compile_with_the_Developer_Package#Modifying_the_Linux_kernel_device_tree所有步骤链接

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

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

竹中月

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值