正点原子stm32mp157开发板linux5.10移植 在stm32官网下载以下文件: en.SDK-x86_64-stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17.tar.xz en.SOURCES-stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17_tar.xz en.FLASH-stm32mp1-openstlinux-5-10-dunfell-mp1-21-11-17_tar.xz 解压en.SOURCES-stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17_tar.xz文件会得到源码文件,解压并安装en.SDK-x86_64-stm32mp1-openstlinux-5.10-dunfell-mp1-21-11-17.tar.xz可以得到一些必要的工具,比如fiptool-stm32mp和fiptool,不过fiptool可以在/tf-a-stm32mp-v2.4-stm32mp-r2-r0/tf-a-stm32mp-v2.4-stm32mp-r2/tools/fiptool编译得到。 Stm32官方编译自定义设备树教程参考 目录结构: 1. Tf-a 2.4 准备源码: tar xfz tf-a-stm32mp-v2.4-stm32mp-r2-r0.tar.gz cd tf-a-stm32mp-v2.4-stm32mp-r2 for p in `ls -1 ../*.patch`; do patch -p1 < $p; done 按照正点原子的教程修改设备树,修改完成后,我在这里遇到了第一个坑: 参考链接 ST官方最新TF-A 2.4 移植问题-OpenEdv-开源电子网, 然而他们的解决办法对我来说并没有用,修改代码甚至直接删除drivers/st/regulator/regulator_fixed.c文件都没用,尝试两天后,我再次编译了uboot,突然发现可以了,执行到修改的bl32代码了,终于松了一口气,不容易。因为改了很多调试信息比较乱,所以重新解压tfa源码。 只需要修改一个宏定义: tf-a-stm32mp-v2.4-stm32mp-r2-r0/tf-a-stm32mp-v2.4-stm32mp-r2/plat/st/stm32mp1/stm32mp1_def.h 中的 #define PLAT_NB_FIXED_REGS U(1) 改为 #define PLAT_NB_FIXED_REGS U(12) 执行以下命令编译: cd tf-a-stm32mp-v2.4-stm32mp-r2 export FIP_DEPLOYDIR_ROOT=$PWD/../../FIP_artifacts make -f ../Makefile.sdk TF_A_DEVICETREE=stm32mp157d-stm32 FIP_CONFIG=" trusted" FIP_BL32_CONF="tfa," TF_A_CONFIG="trusted emmc nand nor sdcard uart usb" DEPLOYDIR=$FIP_DEPLOYDIR_ROOT/arm-trusted-firmware stm32 得到以下文件:
2. Uboot 准备源码: tar xfz u-boot-stm32mp-v2020.10-stm32mp-r2-r0.tar.gz cd u-boot-stm32mp-v2020.10-stm32mp-r2 for p in `ls -1 ../*.patch`; do patch -p1 < $p; done 按照正点原子的教程修改设备树,修改完成后编译: cd u-boot-stm32mp-v2020.10-stm32mp-r2 export FIP_DEPLOYDIR_ROOT=$PWD/../../FIP_artifacts make -f ../Makefile.sdk all UBOOT_CONFIG=trusted UBOOT_DEFCONFIG=stm32mp15_trusted_defconfig UBOOT_BINARY=u-boot.dtb FIP_CONFIG="trusted" FIP_BL32_CONF="tfa," DEVICETREE="stm32mp157d-stm32" 得到以下文件: 问题注意: 3. Kernel 准备源码: tar xfJ linux-5.10.61.tar.xz cd linux-5.10.61 for p in `ls -1 ../*.patch`; do patch -p1 < $p; done 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" 按照正点原子的教程修改内核设备树,修改完成后添加设备树到makefile文件,编译: cd linux-5.10.61 make ARCH=arm -j4 uImage dtbs LOADADDR=0xC2000040 O="$PWD/../build" 4. 烧写 在en.FLASH-stm32mp1-openstlinux-5-10-dunfell-mp1-21-11-17_tar.xz中找到FlashLayout_emmc_stm32mp157d-ev1-trusted.tsv文件,修改内容如下: #Opt Id Name Type IP Offset Binary - 0x01 fsbl1-boot Binary none 0x0 arm-trusted-firmware/tf-a-stm32mp157d-stm32-usb.stm32 - 0x03 fip-boot Binary none 0x0 fip/fip-stm32mp157d-stm32-trusted.bin P 0x04 fsbl1 Binary mmc1 boot1 arm-trusted-firmware/tf-a-stm32mp157d-stm32-emmc.stm32 P 0x05 fsbl2 Binary mmc1 boot2 arm-trusted-firmware/tf-a-stm32mp157d-stm32-emmc.stm32 PD 0x06 fip Binary mmc1 0x00080000 fip/fip-stm32mp157d-stm32-trusted.bin P 0x10 boot System mmc1 0x00480000 boot/bootfs.ext4 P 0x11 rootfs FileSystem mmc1 0x04480000 rootfs.ext4 文件系统rootfs可以用以前编译好的buildroot文件系统 Uboot设置启动参数: mmc: setenv bootcmd 'ext4load mmc 1:2 c2000000 uImage;ext4load mmc 1:2 c4000000 stm32mp157d-stm32.dtb;bootm c2000000 - c4000000' 没有启用wifi的: setenv bootargs 'console=tty1 console=ttySTM0,115200 root=/dev/mmcblk1p3 rootwait rw' 启用wifi接口的: setenv bootargs 'console=tty1 console=ttySTM0,115200 root=/dev/mmcblk2p3 rootwait rw' 保存: saveenv 启动: boot 出现问题:屏幕无法正常显示,/sys/class/drm/ 目录下没有设备,但是触摸是可以的,后面看看能不能解决吧 附几张张启动日志:
|