<Spec>

  • target Board : STM32mp157f-ev1, STM32mp157d-dk1
  • Ubuntu : ubuntu-18.04.5-desktop-amd64
  • stm32mpu Major ecosystem releases version : v3.0.0
  • U-Boot : v2020.10
  • TF-A : v2.4
  • OP-TEE : v3.12.0

 

STM32MP1에서 제공되는 Developer Package를 이용해 개발 환경을 구축할 것이다.

uboot name을 customizing 하여 빌드 및 부팅되는지 확인한다.

 

-Working path

$ pwd 
~/STM/Developer-Package

 

1. Source download

https://wiki.st.com/stm32mpu/wiki/STM32MP1_Developer_Package

├── en.SDK-x86_64-stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31.tar.xz
├── en.SOURCES-kernel-stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31.tar.xz
├── en.SOURCES-optee-stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31.tar.xz
├── en.SOURCES-tf-a-stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31.tar.xz
└── en.SOURCES-u-boot-stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31.tar.xz

 

2. SDK 설치 

$ tar -xvf en.SDK-x86_64-stm32mp1-openstlinux-20-02-19.tar.xz
$ cd stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31/sdk/
$ ./st-image-weston-openstlinux-weston-stm32mp1-x86_64-toolchain-3.1-openstlinux-5.10-dunfell-mp1-21-03-31.sh -d ../../SDK

 

3. tf-a(fwconfig, bl32) build

 - 압축 풀기 및 패치

$ tar -xvf en.SOURCES-tf-a-stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31.tar.xz
$ cd stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31/sources/arm-ostl-linux-gnueabi/tf-a-stm32mp-2.4.r1-r0
$ tar -xvf tf-a-stm32mp-2.4.r1-r0.tar.gz
$ cd tf-a-stm32mp-2.4.r1
$ for p in `ls -1 ../*.patch`; do patch -p1 < $p; done

 

 - 소스 변경 및 추가

$ vi ../Makefile.sdk
$	# Makefile.sdk에 stm32mp157f-whatmam-ev1 추가
$ cp -rfvp fdts/stm32mp157f-ev1.dts fdts/stm32mp157f-whatmam-ev1.dts
$ cp -rfvp fdts/stm32mp157f-ev1-fw-config.dts fdts/stm32mp157f-whatmam-ev1-fw-config.dts
$	# stm32mp157f-whatmam-ev1 dtb 추가

 

 - Makefile.sdk 사용

$ source ~/STM/Developer-Package/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
$ export DEPLOYDIR=$PWD/../../FIP_artifacts/arm-trusted-firmware
$ make -f $PWD/../Makefile.sdk clean
$ make -f $PWD/../Makefile.sdk TF_A_DEVICETREE=stm32mp157f-whatmam-ev1 TF_A_CONFIG=trusted ELF_DEBUG_ENABLE='1' stm32

 

 - output files

$ tree -L 2 $DEPLOYDIR
├── bl32
│   ├── debug
│   └── stm32mp157f-whatmam-ev1-bl32.dtb
├── debug
└── fwconfig
    └── stm32mp157f-whatmam-ev1-fw-config-trusted.dtb

 

4. u-boot build

 - 압축풀기 및 패치

$ cd ~/STM/Developer-Package
$ tar -xvf en.SOURCES-u-boot-stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31.tar.xz
$ cd stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31/sources/arm-ostl-linux-gnueabi/u-boot-stm32mp-2020.10.r1-r0
$ tar -xvf u-boot-stm32mp-2020.10.r1-r0.tar.gz
$ cd u-boot-stm32mp-2020.10.r1
$ for p in `ls -1 ../*.patch`; do patch -p1 < $p; done

 

 - 소스 변경 및 추가

$ vi ../Makefile.sdk
$ vi arch/arm/dts/Makefile
$	# Makefile.sdk에 stm32mp157f-whatmam-ev1 추가
$ cp -rfvp arch/arm/dts/stm32mp157f-ev1.dts arch/arm/dts/stm32mp157f-whatmam-ev1.dts
$ cp -rfvp arch/arm/dts/stm32mp157f-ev1-u-boot.dtsi arch/arm/dts/stm32mp157f-whatmam-ev1-u-boot.dtsi
$	# *-u-boot.dtsi 없으면 빌드는 되나, 부팅이 안됨.
$	# dtb model명 변경하여 디버그에서 변경 되는지 확인 하도록 수정

 

 - Makefile.sdk 사용

$ source ~/STM/Developer-Package/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
$ export DEPLOYDIR=$PWD/../../FIP_artifacts/u-boot
$ make -f $PWD/../Makefile.sdk clean
$ make -f $PWD/../Makefile.sdk UBOOT_CONFIGS=stm32mp15_trusted_defconfig,trusted,u-boot.dtb DEVICE_TREE="stm32mp157f-whatmam-ev1" uboot

 

 - output files

$ tree -L 1 $DEPLOYDIR
├── debug
├── u-boot-nodtb-stm32mp15.bin
└── u-boot-stm32mp157f-whatmam-ev1-trusted.dtb

 

아래와 같은 make 실행하여 .config 생성된 상태라면 make mrproper 꼭 해줘야 한다.

 

 - Makefile 사용

$ make stm32mp15_trusted_defconfig
$ make DEVICE_TREE=stm32mp157f-ev1 all

 > Makefile.sdk 사용 시 하지 않아도 된다.

 

5. optee build

 - 압축 풀기 및 패치

$ cd ~/STM/Developer-Package
$ tar -xvf en.SOURCES-optee-stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31.tar.xz
$ cd stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31/sources/arm-ostl-linux-gnueabi/optee-os-stm32mp-3.12.0.r1-r0
$ tar -xvf optee-os-stm32mp-3.12.0.r1-r0.tar.gz
$ cd optee-os-stm32mp-3.12.0.r1
$ for p in `ls -1 ../*.patch`; do patch -p1 < $p; done

 

 - 소스 변경 및 추가

$ vi ../Makefile.sdk
$	# Makefile.sdk에 stm32mp157f-whatmam-ev1 추가
$ cp -rfvp core/arch/arm/dts/stm32mp157f-ev1.dts core/arch/arm/dts/stm32mp157f-whatmam-ev1.dts

 

- Makefile.sdk 사용

$ source ~/STM/Developer-Package/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
$ export DEPLOYDIR=$PWD/../../FIP_artifacts/optee
$ make -f $PWD/../Makefile.sdk clean
$ make -f $PWD/../Makefile.sdk CFG_EMBED_DTB_SOURCE_FILE=stm32mp157f-whatmam-ev1 optee

 

 - output files

$ tree -L 1 $DEPLOYDIR
├── debug
├── tee-header_v2-stm32mp157f-whatmam-ev1.bin
├── tee-pageable_v2-stm32mp157f-whatmam-ev1.bin
└── tee-pager_v2-stm32mp157f-whatmam-ev1.bin

 

6. fip build

fip는 tf-a, uboot, optee 어디든 빌드가 가능하다.

빌드된 파일들이 모여있는 FIP_artifacts의 폴더를 지정하고 tf-a에 있는 Makefile.sdk을 사용하도록 하겠다.

$ cd ~/STM/Developer-Package/stm32mp1-openstlinux-5.10-dunfell-mp1-21-03-31/sources/arm-ostl-linux-gnueabi/tf-a-stm32mp-2.4.r1-r0/tf-a-stm32mp-2.4.r1
$ source ~/STM/Developer-Package/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
$ export DEPLOYDIR=$PWD/../../FIP_artifacts/arm-trusted-firmware
$ export FIP_DEPLOYDIR_ROOT=$PWD/../../FIP_artifacts
$ make -f $PWD/../Makefile.sdk TF_A_DEVICETREE=stm32mp157f-whatmam-ev1 ELF_DEBUG_ENABLE='1' fip

 

 - output files

$ tree -L 1 $FIP_DEPLOYDIR_ROOT/fip
├── fip-stm32mp157f-whatmam-ev1-optee.bin
└── fip-stm32mp157f-whatmam-ev1-trusted.bin
$ tree -L 1 $DEPLOYDIR
├── bl32
├── debug
├── fwconfig
├── tf-a-stm32mp157f-whatmam-ev1-emmc.stm32
├── tf-a-stm32mp157f-whatmam-ev1-nand.stm32
├── tf-a-stm32mp157f-whatmam-ev1-nor.stm32
├── tf-a-stm32mp157f-whatmam-ev1-sdcard.stm32
├── tf-a-stm32mp157f-whatmam-ev1-uart.stm32
└── tf-a-stm32mp157f-whatmam-ev1-usb.stm32

 

7. FIP_artifacts 확인

$ cd $FIP_DEPLOYDIR_ROOT
$ find . -name "debug" -type d | xargs rm -rf
$ tree -L 3
├── arm-trusted-firmware
│   ├── bl32
│   │   ├── stm32mp157f-whatmam-ev1-bl32.dtb
│   │   └── tf-a-bl32-stm32mp15.bin
│   ├── fwconfig
│   │   ├── stm32mp157f-whatmam-ev1-fw-config-optee.dtb
│   │   └── stm32mp157f-whatmam-ev1-fw-config-trusted.dtb
│   ├── tf-a-stm32mp157f-whatmam-ev1-emmc.stm32
│   ├── tf-a-stm32mp157f-whatmam-ev1-nand.stm32
│   ├── tf-a-stm32mp157f-whatmam-ev1-nor.stm32
│   ├── tf-a-stm32mp157f-whatmam-ev1-sdcard.stm32
│   ├── tf-a-stm32mp157f-whatmam-ev1-uart.stm32
│   └── tf-a-stm32mp157f-whatmam-ev1-usb.stm32
├── fip
│   ├── fip-stm32mp157f-whatmam-ev1-optee.bin
│   └── fip-stm32mp157f-whatmam-ev1-trusted.bin
├── optee
│   ├── tee-header_v2-stm32mp157f-whatmam-ev1.bin
│   ├── tee-pageable_v2-stm32mp157f-whatmam-ev1.bin
│   └── tee-pager_v2-stm32mp157f-whatmam-ev1.bin
└── u-boot
    ├── u-boot-nodtb-stm32mp15.bin
    └── u-boot-stm32mp157f-whatmam-ev1-trusted.dtb

 - 빌드 순서 요약 : tf-a, uboot, optee는 독립적으로 빌드 후 최종 fip빌드는 3중 아무곳에서 해도 됩니다.

 

8. Create SD Card

$ cd $FIP_DEPLOYDIR_ROOT/arm-trusted-firmware
$ sudo dd if=tf-a-stm32mp157f-whatmam-ev1-sdcard.stm32 of=/dev/sdb1 conv=fdatasync
$ sudo dd if=tf-a-stm32mp157f-whatmam-ev1-sdcard.stm32 of=/dev/sdb2 conv=fdatasync

$ cd $FIP_DEPLOYDIR_ROOT/fip
$ sudo dd if=/dev/zero of=/dev/sdb3 conv=fdatasync
$ sudo dd if=fip-stm32mp157f-whatmam-ev1-trusted.bin of=/dev/sdb3 conv=fdatasync
$ umount /media/whatmam/*

 sd Card의 Partitions 1,2에 tf-a-stm32mp157f-whatmam-ev1-sdcard.stm32

               Partitions 3에 fip-stm32mp157f-whatmam-ev1-trusted.bin

'STM32' 카테고리의 다른 글

4. STM32mp157 u-boot 분석  (0) 2021.07.20
3. STM32mp157 eMMC Booting  (1) 2021.07.19
2-3. STM32mp157 Distibution Package - galcore  (0) 2021.07.13
2-2. STM32mp157 Distibution Package - Kernel  (0) 2021.07.13
1. STM32mp157 Yocto build  (0) 2021.07.13

+ Recent posts