一、编译SBL
1.进入~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/build目录
2.编译SBL
执行
make BOARD=j721s2_evm CORE=mcu1_0 BUILD_PROFILE=release sbl_mmcsd_img -j8
生成~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/boot/sbl/binary/j721s2_evm/mmcsd/bin/sbl_mmcsd_img_mcu1_0_release.tiimage
将sbl_mmcsd_img_mcu1_0_release.tiimage拷贝到SD卡的BOOT分区根目录,并且重命名为tiboot3.bin。
由于SBL(tiboot3.bin)需要加载 tifs.bin(DMSC firmware binary),所以将rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/drv/sciclient/soc/V4目录下的tifs.bin拷贝到SD卡BOOT分区根目录。
二、编译Mcu1_0 App
1.修改代码:ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/mcusw/mcuss_demos/boot_app_mcu_rtos/boot.c 将demo中直接启动内核(tikernelimage_linux.appimage)更改为启动spl(u-boot-spl.appimage)。
static int32_t MMCSDBootStageImage(sblEntryPoint_t *pEntry, TCHAR *fileName)
{
int32_t status = E_FAIL;
# if defined(MPU1_HLOS_BOOT_ENABLED) || defined(MPU1_HLOS_BOOT_ONLY_ENABLED)
TCHAR *fileNameAtf = "0:/atf_optee.appimage";
# ifdef HLOS_BOOT_QNX_OS
TCHAR *fileHLOS = "0:/ifs_qnx.appimage";
# else
TCHAR *fileNameDtb = "0:/tidtb_linux.appimage";
TCHAR *fileHLOS = "0:/u-boot-spl.appimage"; /*junior add:*/
/*TCHAR *fileHLOS = "0:/tikernelimage_linux.appimage";*/
# endif
# endif
2.进入~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/mcusw/build目录
3.编译can_boot_app_mcu_rtos
执行
make can_boot_app_mcu_rtos HLOSBOOT=linux BOOTMODE=mmcsd BOARD=j721s2_evm SOC=j721s2 BUILD_PROFILE=release CORE=mcu1_0 BUILD_OS_TYPE=freertos TREAT_WARNINGS_AS_ERROR=no -j8
生成~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/mcusw/binary/can_boot_app_mcu_rtos/bin/j721s2_evm/can_boot_app_mcu_rtos_mcu1_0_release.appimage
将can_boot_app_mcu_rtos_mcu1_0_release.appimage拷贝到SD卡的BOOT分区根目录,并且重命名为app。
三、Mcu1_0 App启动u-boot-spl.appimage(通过Mcu1_0 App启动Uboot)
1.生成u-boot-spl.appimage:
a.修改uboot代码,更改为从MMC2(SD卡)启动
ti-processor-sdk-linux-j721s2-evm-08_06_00_10/board-support/u-boot-2021.01+gitAUTOINC+62a9e51344-g62a9e51344/common/spl目录下spl.c 491行:
__weak void board_boot_order(u32 *spl_boot_list)
{
/*spl_boot_list[0] = spl_boot_device();*/
spl_boot_list[0] = BOOT_DEVICE_MMC2; /*junior add:spl boot u-boot.image from MMC2*/
}
b.编译uboot
进入linux SDK根目录(ti-processor-sdk-linux-j721s2-evm-08_06_00_10目录)。
cd ~/linux/ti-processor-sdk-linux-j721s2-evm-08_06_00_10/
执行
make u-boot
在linux/ti-processor-sdk-linux-j721s2-evm-08_06_00_10/board-support/u-boot_build/a72目录下生成spl.bin u-boot.image。
在linux/ti-processor-sdk-linux-j721s2-evm-08_06_00_10/board-support/u-boot_build/a72/spl目录下生成u-boot-spl.bin。
将spl.bin和u-boot.image拷贝到SD卡的BOOT分区根目录。
c.将u-boot-spl.bin转化为u-boot-spl.appimage。
将u-boot-spl.bin拷贝到rtos SDK中:
cp board-support/u-boot_build/a72/spl/u-boot-spl.bin ~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/boot/sbl/tools/combined_appimage/bin/j721s2_evm
进入ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/boot/sbl/tools/combined_appimage目录
cd ~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/boot/sbl/tools/combined_appimage
①.将u-boot-spl.bin转化为u-boot-spl.elf。
执行
~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf/bin/aarch64-none-elf-ld -b binary -A aarch64 --oformat elf64-littleaarch64 -section-start=.data=0x80080000 -e 0x80080000 ~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/boot/sbl/tools/combined_appimage/bin/j721s2_evm/u-boot-spl.bin -o ~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/boot/sbl/tools/combined_appimage/bin/j721s2_evm/u-boot-spl.elf
②.将u-boot-spl.elf转化为u-boot-spl.rprc。
执行
mono --runtime=v4.0 ~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/boot/sbl/tools/out2rprc/bin/out2rprc.exe ~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/boot/sbl/tools/combined_appimage/bin/j721s2_evm/u-boot-spl.elf ~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/boot/sbl/tools/combined_appimage/bin/j721s2_evm/u-boot-spl.rprc
③.将u-boot-spl.rprc转化为u-boot-spl.appimage。
执行
~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/boot/sbl/tools/multicoreImageGen/bin/MulticoreImageGen LE 55 ~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/boot/sbl/tools/combined_appimage/bin/j721s2_evm/u-boot-spl.appimage 0 u-boot-spl.rprc
最终在~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/pdk_j721s2_08_06_00_31/packages/ti/boot/sbl/tools/combined_appimage/bin/j721s2_evm/目录下生成u-boot-spl.appimage u-boot-spl.elf u-boot-spl.rprc。
将u-boot-spl.appimage拷贝到SD卡的BOOT分区根目录。
四、生成tidtb_linux.appimage和atf_optee.appimage
①.进入~/rtos//ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/mcusw/mcuss_demos/boot_app_mcu_rtos/main_domain_apps/scripts/hlos目录。
cd ~/rtos/ti-processor-sdk-rtos-j721s2-evm-08_06_00_11/mcusw/mcuss_demos/boot_app_mcu_rtos/main_domain_apps/scripts/hlos
②.创建文件生成目录,默认lds文件在./linux目录下。
mkdir -p ../../binary/bin/j721s2_evm/
②.修改并运行脚本constructappimageshlos.sh
脚本修改处:
# OS options are: linux or qnx
OS=linux
# Linux-specific paths
# --------------------
# First, the directory where the needed Linux binaries are located needs to be defined.
# This directory should already contain the bl31.bin, bl32.bin,
# base-board.dtb (k3-j72*-common-proc-board.dtb), and Image files
# Linux build directory containing all the locally-built Linux-related binaries
#LINUX_BUILD_DIR_PATH=USER_DEFINED_PATH
LINUX_BUILD_DIR_PATH=/home/junior/linux/ti-processor-sdk-linux-j721s2-evm-08_06_00_10/board-support/prebuilt-images
执行
./constructappimageshlos.sh j721s2_evm
在./../binary/bin/j721s2_evm/目录会生成atf_optee.appimage、tidtb_linux.appimage、tikernelimage_linux.appimage文件。
将atf_optee.appimage、tidtb_linux.appimage拷贝到SD卡的BOOT分区根目录。