【STM32MP135F-DK】玩转ecosystem软件包,内核编译初尝试
[复制链接]
本帖最后由 fangkaixin 于 2023-12-24 16:34 编辑
软件包分类
ST官方提供了大量的入门资料,以便于我们使用STM32MP135x-DK探索套件进行开发测试。
如上图,ST为我们不同程度的开发者提供了不同类别的软件包,而且提供了linux和裸机样例程序两种代码可供选用,面对详尽的资料,往往不知道从哪开始入手,今天就为大家整理一下ST为我们免费提供的软件包和其使用方法。
首先,对于STM32MP135x-DK探索套件的发行版,ST官方提供了三类软件包,分别如下
- 入门包(Starter Package )(软件映像)
- 开发者包(Developer Package )(用于交叉开发的 SDK,发行版 BSP 的源代码)
- 分发包(Distribution Package )(在 Linux 主机 PC 上构建框架,整个分发的源代码)
我整理了这张表格方便大家比较
其中,虽然分发包(Distribution Package )是相对最全的,但我们暂且用不到(它来发布一个新的版本),所以今天这一篇就介绍下,如何使用开发者包(Developer Package )对linux内核进行编译安装,以及如何使用入门包(Starter Package )提供的软件映像来进行故障恢复。
使用Developer Package重新编译与更新内核
前面的文章中已经介绍了如何安装SDK包,以及环境变量设置的小技巧,如果有不清楚的可以回顾上一篇 《核心功能评估》中的“安装SDK”部分。这一部分将介绍重新编译和更新linux内核的方法。
除了SDK包之外,我们还需要从ST官网下载 源码:en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21.tar.gz,之前我们也已经下载过了,和SDK的下载链接是同一个
接着,我们将源码文件放到WSL2的开发路径中解压
- tar xvf en.sources-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21.tar.gz
接着解压linux源码
- cd stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/sources/arm-ostl-linux-gnueabi/linux-stm32mp-6.1.28-stm32mp-r1-r0
- tar xvf linux-6.1.28.tar.xz
这里的源码是linux官方内核,需要打上ST的补丁才能在135F-DK上使用
- cd linux-6.1.28
- for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
- make ARCH=arm multi_v7_defconfig "fragment*.config"
- for f in `ls -1 ../fragment*.config`; do scripts/kconfig/merge_config.sh -m -r .config $f; done
- yes '' | make ARCH=arm oldconfig
做完这一切之后,就可以开始编译内核,然后就是漫长的等待
- make ARCH=arm uImage vmlinux dtbs LOADADDR=0xC2000040
- make ARCH=arm modules
编译完成后,生成输出项目
- mkdir -p $PWD/install_artifact/
- make ARCH=arm INSTALL_MOD_PATH="$PWD/install_artifact" modules_install
然后在板子上部署linux内核,通过ssh将编译好的内核和设备树文件推送到开发板中
- scp arch/arm/boot/uImage root@<board ip address>:/boot
- scp arch/arm/boot/dts/stm32mp1xx*.dtb root@<board ip address>:/boot
删除在 install_artifact/lib/modules/<kernel version> 目录中创建的链接
- rm install_artifact/lib/modules/6.1.28/build install_artifact/lib/modules/6.1.28/source
剥离内核模块(以减小每个内核模块的大小)(可选)
- find install_artifact/ -name "*.ko" | xargs $STRIP --strip-debug --remove-section=.comment --remove-section=.note --preserve-dates
复制内核模块
- scp -r install_artifact/lib/modules/* root@<ip of board>:/lib/modules
使用 Linux 控制台,重新生成模块依赖项列表 (modules.dep) 和模块提供的符号列表 (modules.symbols)
- /sbin/depmod -a
同步数据到磁盘,随后重启
- sync
- reboot
到这里,等待系统重启完成,查看一下
系统内核已经更新到6.1.28了,与我们刚才编译的源码版本一致,说明更新成功了
使用Starter Package进行故障恢复
编译内核的过程,容易因为一些疏漏导致系统更新失败,下面就介绍下重新烧写系统的方法,烧写系统后,再重新执行之前的各项指令,可以帮助我们排查并最终找到出错的具体原因。
这一部分可以借助Starter Package中提供的软件映像来实现。
下载软件映像:
解压文件:
tar xvf en.flash-stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21.tar.gz
二进制文件和 Flash 布局文件位于 <Starter Package 安装目录>/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/images/stm32mp1/ 目录中:
stm32mp1
├── arm-trusted-firmware TF-A binaries for FSBL partitions and supported boot chains
│ ├── metadata.bin Meta data binary for METADATA partition for the supported boards
│ ├── tf-a-stm32mp135f-dk-sdcard.stm32 TF-A binary for FSBL partition (microSD card boot device) for STM32MP135F-DK → STM32MP13 Discovery kits
│ ├── tf-a-stm32mp135f-dk-uart.stm32 TF-A binary for uart serial boot mode (STM32CubeProgrammer) for STM32MP135F-DK → STM32MP13 Discovery kits
│ ├── tf-a-stm32mp135f-dk-usb.stm32 TF-A binary for usb serial boot mode (STM32CubeProgrammer) for STM32MP135F-DK → STM32MP13 Discovery kits
│ ├── tf-a-stm32mp157a-dk1-sdcard.stm32 TF-A binary for FSBL partition (microSD card boot device) for STM32MP157A-DK1 → STM32MP15 Discovery kits
│ ├── tf-a-stm32mp157a-dk1-uart.stm32 TF-A binary for uart serial boot mode (STM32CubeProgrammer) for STM32MP157A-DK1 → STM32MP15 Discovery kits
│ ├── tf-a-stm32mp157a-dk1-usb.stm32 TF-A binary for usb serial boot mode (STM32CubeProgrammer) for STM32MP157A-DK1 → STM32MP15 Discovery kits
│ ├── tf-a-stm32mp157a-ev1-emmc.stm32 TF-A binary for FSBL partition (eMMC boot device) for STM32MP157A-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157a-ev1-nand.stm32 TF-A binary for FSBL partition (NAND boot device) for STM32MP157A-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157a-ev1-nor.stm32 TF-A binary for FSBL partition (NOR boot device) for STM32MP157A-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157a-ev1-sdcard.stm32 TF-A binary for FSBL partition (microSD card boot device) for STM32MP157A-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157a-ev1-uart.stm32 TF-A binary for uart serial boot mode (STM32CubeProgrammer) for STM32MP157A-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157a-ev1-usb.stm32 TF-A binary for usb serial boot mode (STM32CubeProgrammer) for STM32MP157A-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157c-dk2-sdcard.stm32 TF-A binary for FSBL partition (microSD card boot device) for STM32MP157C-DK2 → STM32MP15 Discovery kits
│ ├── tf-a-stm32mp157c-dk2-uart.stm32 TF-A binary for uart serial boot mode (STM32CubeProgrammer) for STM32MP157C-DK2 → STM32MP15 Discovery kits
│ ├── tf-a-stm32mp157c-dk2-usb.stm32 TF-A binary for usb serial boot mode (STM32CubeProgrammer) for STM32MP157C-DK2 → STM32MP15 Discovery kits
│ ├── tf-a-stm32mp157c-ed1-emmc.stm32 TF-A binary for FSBL partition (eMMC boot device) for STM32MP157C-ED1 → STM32MP15 Evaluation daughter boards
│ ├── tf-a-stm32mp157c-ed1-sdcard.stm32 TF-A binary for FSBL partition (microSD card boot device) for STM32MP157C-ED1 → STM32MP15 Evaluation daughter boards
│ ├── tf-a-stm32mp157c-ed1-uart.stm32 TF-A binary for uart serial boot mode (STM32CubeProgrammer) for STM32MP157C-ED1 → STM32MP15 Evaluation daughter boards
│ ├── tf-a-stm32mp157c-ed1-usb.stm32 TF-A binary for usb serial boot mode (STM32CubeProgrammer) for STM32MP157C-ED1 → STM32MP15 Evaluation daughter boards
│ ├── tf-a-stm32mp157c-ev1-emmc.stm32 TF-A binary for FSBL partition (eMMC boot device) for STM32MP157C-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157c-ev1-nand.stm32 TF-A binary for FSBL partition (NAND boot device) for STM32MP157C-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157c-ev1-nor.stm32 TF-A binary for FSBL partition (NOR boot device) for STM32MP157C-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157c-ev1-sdcard.stm32 TF-A binary for FSBL partition (microSD card boot device) for STM32MP157C-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157c-ev1-uart.stm32 TF-A binary for uart serial boot mode (STM32CubeProgrammer) for STM32MP157C-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157c-ev1-usb.stm32 TF-A binary for usb serial boot mode (STM32CubeProgrammer) for STM32MP157C-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157d-dk1-sdcard.stm32 TF-A binary for FSBL partition (microSD card boot device) for STM32MP157D-DK1 → STM32MP15 Discovery kits
│ ├── tf-a-stm32mp157d-dk1-uart.stm32 TF-A binary for serial boot mode (STM32CubeProgrammer) for STM32MP157D-DK1 → STM32MP15 Discovery kits
│ ├── tf-a-stm32mp157d-dk1-usb.stm32 TF-A binary for usb serial boot mode (STM32CubeProgrammer) for STM32MP157D-DK1 → STM32MP15 Discovery kits
│ ├── tf-a-stm32mp157d-ev1-emmc.stm32 TF-A binary for FSBL partition (eMMC boot device) for STM32MP157D-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157d-ev1-nand.stm32 TF-A binary for FSBL partition (NAND boot device) for STM32MP157D-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157d-ev1-nor.stm32 TF-A binary for FSBL partition (NOR boot device) for STM32MP157D-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157d-ev1-sdcard.stm32 TF-A binary for FSBL partition (microSD card boot device) for STM32MP157D-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157d-ev1-uart.stm32 TF-A binary for uart serial boot mode (STM32CubeProgrammer) for STM32MP157D-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157d-ev1-usb.stm32 TF-A binary for usb serial boot mode (STM32CubeProgrammer) for STM32MP157D-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157f-dk2-sdcard.stm32 TF-A binary for FSBL partition (microSD card boot device) for STM32MP157F-DK2 → STM32MP15 Discovery kits
│ ├── tf-a-stm32mp157f-dk2-uart.stm32 TF-A binary for uart serial boot mode (STM32CubeProgrammer) for STM32MP157F-DK2 → STM32MP15 Discovery kits
│ ├── tf-a-stm32mp157f-dk2-usb.stm32 TF-A binary for usb serial boot mode (STM32CubeProgrammer) for STM32MP157F-DK2 → STM32MP15 Discovery kits
│ ├── tf-a-stm32mp157f-ed1-emmc.stm32 TF-A binary for FSBL partition (eMMC boot device) for STM32MP157F-ED1 → STM32MP15 Evaluation daughter boards
│ ├── tf-a-stm32mp157f-ed1-sdcard.stm32 TF-A binary for FSBL partition (microSD card boot device) for STM32MP157F-ED1 → STM32MP15 Evaluation daughter boards
│ ├── tf-a-stm32mp157f-ed1-uart.stm32 TF-A binary for uart serial boot mode (STM32CubeProgrammer) for STM32MP157F-ED1 → STM32MP15 Evaluation daughter boards
│ ├── tf-a-stm32mp157f-ed1-usb.stm32 TF-A binary for usb serial boot mode (STM32CubeProgrammer) for STM32MP157F-ED1 → STM32MP15 Evaluation daughter boards
│ ├── tf-a-stm32mp157f-ev1-emmc.stm32 TF-A binary for FSBL partition (eMMC boot device) for STM32MP157F-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157f-ev1-nand.stm32 TF-A binary for FSBL partition (NAND boot device) for STM32MP157F-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157f-ev1-nor.stm32 TF-A binary for FSBL partition (NOR boot device) for STM32MP157F-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157f-ev1-sdcard.stm32 TF-A binary for FSBL partition (microSD card boot device) for STM32MP157F-EV1 → STM32MP15 Evaluation boards
│ ├── tf-a-stm32mp157f-ev1-uart.stm32 TF-A binary for uart serial boot mode (STM32CubeProgrammer) for STM32MP157F-EV1 → STM32MP15 Evaluation boards
│ └── tf-a-stm32mp157f-ev1-usb.stm32 TF-A binary for usb serial boot mode (STM32CubeProgrammer) for STM32MP157F-EV1 → STM32MP15 Evaluation boards
├── fip FIP binaries for FIP partitions and supported boot chains
│ ├── fip-stm32mp135f-dk-optee.bin FIP binary for FIP partition (optee boot chain) for STM32MP135F-DK → STM32MP13 Discovery kits
│ ├── fip-stm32mp157a-dk1-optee.bin FIP binary for FIP partition (optee boot chain) for STM32MP157A-DK1 → STM32MP15 Discovery kits
│ ├── fip-stm32mp157a-ev1-optee.bin FIP binary for FIP partition (optee boot chain) for STM32MP157A-EV1 → STM32MP15 Evaluation boards
│ ├── fip-stm32mp157c-dk2-optee.bin FIP binary for FIP partition (optee boot chain) for STM32MP157C-DK2 → STM32MP15 Discovery kits
│ ├── fip-stm32mp157c-ed1-optee.bin FIP binary for FIP partition (optee boot chain) for STM32MP157C-ED1 → STM32MP15 Evaluation daughter boards
│ ├── fip-stm32mp157c-ev1-optee.bin FIP binary for FIP partition (optee boot chain) for STM32MP157C-EV1 → STM32MP15 Evaluation boards
│ ├── fip-stm32mp157d-dk1-optee.bin FIP binary for FIP partition (optee boot chain) for STM32MP157D-DK1 → STM32MP15 Discovery kits
│ ├── fip-stm32mp157d-ev1-optee.bin FIP binary for FIP partition (optee boot chain) for STM32MP157D-EV1 → STM32MP15 Evaluation boards
│ ├── fip-stm32mp157f-dk2-optee.bin FIP binary for FIP partition (optee boot chain) for STM32MP157F-DK2 → STM32MP15 Discovery kits
│ ├── fip-stm32mp157f-ed1-optee.bin FIP binary for FIP partition (optee boot chain) for STM32MP157F-ED1 → STM32MP15 Evaluation daughter boards
│ └── fip-stm32mp157f-ev1-optee.bin FIP binary for FIP partition (optee boot chain) for STM32MP157F-EV1 → STM32MP15 Evaluation boards
├── flashlayout_st-image-weston Flash layout files (description of the partitions) for the supported boot chains on supported boot devices and boards
│ ├── extensible Flash layout files for microSD card boot device with no userfs partition but a rootfs partition extended to microSD card size
│ │ ├── FlashLayout_sdcard_stm32mp135f-dk-optee.tsv (recommended setup for package repository service) microSD card boot device for STM32MP135F-DK → STM32MP13 Discovery kits
│ │ ├── FlashLayout_sdcard_stm32mp157a-dk1-extensible.tsv (recommended setup for package repository service) microSD card boot device with rootfs partition extended to microSD card size for STM32MP157A-DK1 → STM32MP15 Discovery kits
│ │ ├── FlashLayout_sdcard_stm32mp157c-dk2-extensible.tsv (recommended setup for package repository service) microSD card boot device with rootfs partition extended to microSD card size for STM32MP157C-DK2 → STM32MP15 Discovery kits
│ │ ├── FlashLayout_sdcard_stm32mp157d-dk1-extensible.tsv (recommended setup for package repository service) microSD card boot device with rootfs partition extended to microSD card size for STM32MP157D-DK1 → STM32MP15 Discovery kits
│ │ └── FlashLayout_sdcard_stm32mp157f-dk2-extensible.tsv (recommended setup for package repository service) microSD card boot device with rootfs partition extended to microSD card size for STM32MP157F-DK2 → STM32MP15 Discovery kits
│ └── optee Flash layout files for optee boot chain
│ ├── FlashLayout_emmc_stm32mp157a-ev1-optee.tsv eMMC boot device for STM32MP157A-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_emmc_stm32mp157c-ed1-optee.tsv eMMC boot device for STM32MP157C-ED1 → STM32MP15 Evaluation daughter boards
│ ├── FlashLayout_emmc_stm32mp157c-ev1-optee.tsv eMMC boot device for STM32MP157C-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_emmc_stm32mp157d-ev1-optee.tsv eMMC boot device for STM32MP157D-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_emmc_stm32mp157f-ed1-optee.tsv eMMC boot device for STM32MP157F-ED1 → STM32MP15 Evaluation daughter boards
│ ├── FlashLayout_emmc_stm32mp157f-ev1-optee.tsv eMMC boot device for STM32MP157F-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_nand-4-256_stm32mp157a-ev1-optee.tsv NAND boot device for STM32MP157A-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_nand-4-256_stm32mp157c-ev1-optee.tsv NAND boot device for STM32MP157C-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_nand-4-256_stm32mp157d-ev1-optee.tsv NAND boot device for STM32MP157D-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_nand-4-256_stm32mp157f-ev1-optee.tsv NAND boot device for STM32MP157F-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_nor-sdcard_stm32mp157a-ev1-optee.tsv NOR boot device and microSD card device for STM32MP157A-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_nor-sdcard_stm32mp157c-ev1-optee.tsv NOR boot device and microSD card device for STM32MP157C-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_nor-sdcard_stm32mp157d-ev1-optee.tsv NOR boot device and microSD card device for STM32MP157D-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_nor-sdcard_stm32mp157f-ev1-optee.tsv NOR boot device and microSD card device for STM32MP157F-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_sdcard_stm32mp135f-dk-optee.tsv (recommended setup) microSD card boot device for STM32MP135F-DK → STM32MP13 Discovery kits
│ ├── FlashLayout_sdcard_stm32mp157a-dk1-optee.tsv microSD card boot device for STM32MP157A-DK1 → STM32MP15 Discovery kits
│ ├── FlashLayout_sdcard_stm32mp157a-ev1-optee.tsv microSD card boot device for STM32MP157A-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_sdcard_stm32mp157c-dk2-optee.tsv microSD card boot device for STM32MP157C-DK2 → STM32MP15 Discovery kits
│ ├── FlashLayout_sdcard_stm32mp157c-ed1-optee.tsv microSD card boot device for STM32MP157C-ED1 → STM32MP15 Evaluation daughter boards
│ ├── FlashLayout_sdcard_stm32mp157c-ev1-optee.tsv microSD card boot device for STM32MP157C-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_sdcard_stm32mp157d-dk1-optee.tsv microSD card boot device for STM32MP157D-DK1 → STM32MP15 Discovery kits
│ ├── FlashLayout_sdcard_stm32mp157d-ev1-optee.tsv microSD card boot device for STM32MP157D-EV1 → STM32MP15 Evaluation boards
│ ├── FlashLayout_sdcard_stm32mp157f-dk2-optee.tsv microSD card boot device for STM32MP157F-DK2 → STM32MP15 Discovery kits
│ ├── FlashLayout_sdcard_stm32mp157f-ed1-optee.tsv microSD card boot device for STM32MP157F-ED1 → STM32MP15 Evaluation daughter boards
│ └── FlashLayout_sdcard_stm32mp157f-ev1-optee.tsv microSD card boot device for STM32MP157F-EV1 → STM32MP15 Evaluation boards
├── scripts
│ └── create_sdcard_from_flashlayout.sh
├── st-image-bootfs-openstlinux-weston-stm32mp1.ext4 Binary for bootfs partition on eMMC and microSD card devices
├── st-image-bootfs-openstlinux-weston-stm32mp1.manifest
├── st-image-userfs-openstlinux-weston-stm32mp1.ext4 Binary for userfs partition on eMMC and microSD card devices
├── st-image-userfs-openstlinux-weston-stm32mp1.manifest
├── st-image-vendorfs-openstlinux-weston-stm32mp1.ext4 Binary for vendorfs partition on eMMC and microSD card devices
├── st-image-vendorfs-openstlinux-weston-stm32mp1.manifest
├── st-image-weston-openstlinux-weston-stm32mp1.ext4 Binary for rootfs partition on eMMC and microSD card devices
├── st-image-weston-openstlinux-weston-stm32mp1.license
├── st-image-weston-openstlinux-weston-stm32mp1-license_content.html License summary for all packages needed to feed all partitions
├── st-image-weston-openstlinux-weston-stm32mp1.manifest
└── st-image-weston-openstlinux-weston-stm32mp1_nand_4_256_multivolume.ubi Binary for bootfs, vendorfs, rootfs and userfs partitions on NAND device
将下载的映像刷入 microSD 卡:
- 将启动开关设置为从 USB 位置启动:
- 连接 USB Type-C™ (OTG)端口 (9) 到包含下载映像的主机 PC
- 将随附的 microSD 卡插入专用插槽 ('4)
- 将随附的电源连接到 USB Type-C™端口 (8)
- 按下复位按钮 (12) 复位板
- 找到要刷写的flashlayout_st-image-weston/optee/FlashLayout_sdcard_stm32mp135f-dk-optee.tsv文件,其在<Starter-Package>/stm32mp1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/images/stm32mp1路径下;打开STM32CubeProgrammer,并且通过USB信号连接到开发板,选择USB,并且点击CONNECT,随后点OPEN选择刷写的文件,Binary Path填写到stm32mp1即可,具体如下图所示
- 然后点击Download烧写固件,等待烧写完成
- 烧写成功后,启动开发板进行验证,将拨码开关设为从TF卡启动
- 屏幕出现OpenSTLinux的图标,并进入系统,更新成功
|