오래간만에 새로운 Board를 하나 입수했다. 이름하여 BeaglePlay~ 앞으로 몇차례에 걸쳐 BeaglePlay 보드를 파헤쳐 보는 시간을 가져 보고자 한다(2번째 시간). 😎
The 2nd time
목차
4. Bootloader 올리기
5. Linux kernel 올리기
6. Device Tree & Device Drivers
7. References
개발 보드는 Reference 보드하고는 언제나 다르다(100% 진리). s/w 개발자의 의견은 고려하지 않은 채, 값싼 부품으로 교체하거나, 새로운 주변장치가 추가된다. Flash memory가 교체되고, size가 줄어들면서 flash layout을 변경해야 하는 일도 부지기수이다. 결국은 bootloader와 linux kernel을 보드에 어떻게 올리느냐가 문제이고, 이는 늘 s/w 개발자의 몫이다. 필요하다면 bootloader 코드부터 수정을 해야 한다. 🏄
이번 posting은 초심자가 쉽게 따라할 수 있도록 Embedded Linux Programming의 기초 과정을 담고자 하였다. 이번 posting의 내용과 더불어 이전 posting 내용도 함께 참고하면 좋을 듯 싶다.
4. Bootloader 올리기
이번 장에서는 BeaglePlay 보드의 bootloader를 개별적으로 build하여 올려 보는 과정을 소개하고자 한다. (3장의) Yocto project 상에서 (이미 build 환경이 갖추어진) bootloader를 build해 볼 수도 있겠으나, 여기서는 각각의 개별 source code를 직접 내려 받아 일일이 build해 보고자 한다.
📌 아래 내용은 TI AM62x bootloader 관련 코드를 한번씩 build해 보는 수준에 지나지 않는다. 😂 실전에서는 bootloader 코드를 최대한 이해하고, 필요한 코드(예: power 설정, GPIO 설정 등)를 추가하거나 수정하는 형태의 일이 진행되어야 한다.
1) tiboot3.bin 파일 생성하기
<ubuntu package 설치>
$ sudo apt install libssl-dev device-tree-compiler swig python3-distutils python3-dev python3-setuptools
<32bit toolchain download 하기>
$ wget https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/binrel/ \
arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz
$ tar xvf ./arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz
=> .bashrc에 PATH 환경변수 설정을 추가하도록 하자.
$ vi ~/.bashrc
export T_PATH=/mnt/hdd/workspace/bootlin/beagleplay/bootlin/toolchain/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi/bin
export PATH=$T_PATH:$PATH
export PATH=$T_PATH:$PATH
~
<R5용 U-Boot download & build 하기>
$ git clone https://git.beagleboard.org/beagleplay/u-boot.git
$ cd u-boot/
$ git checkout f036fb
$ mkdir -p ../build_uboot/r5
$ export CROSS_COMPILE=arm-none-eabi-
$ make am62x_evm_r5_defconfig O=../build_uboot/r5/
$ make O=../build_uboot/r5/
[그림 4.1] R5용 u-boot spl build 모습
[그림 4.2] tiboot3.bin image 구성 내용 [출처 - 참고문헌 7]
$ git clone https://git.ti.com/git/processor-firmware/ti-linux-firmware.git
$ cd ti-linux-firmware
$ git checkout c126d3864b9faf725ff40e620049ab5d56dedc5b
=> tifs firmware file을 download 한다.
$ git remote add stable https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux
$ git fetch stable
$ cd ..
$ git clone https://git.ti.com/cgit/k3-image-gen/k3-image-gen
$ cd k3-image-gen/
$ git checkout 150f1956b4bdcba36e7dffc78a4342df602f8d6e
=> x509 인증서 generator를 내려 받는다.
$ make SOC=am62x SBL=../build_uboot/r5/spl/u-boot-spl.bin SYSFW_PATH=../ti-linux-firmware/ti-sysfw/ti-fs-firmware-am62x-gp.bin
...
./scripts/gen_x509_combined_cert.sh -b ../build_uboot/r5/spl/u-boot-spl.bin -l 0x43c00000 -s ../ti-linux-firmware/ti-sysfw/ti-fs-firmware
-am62x-gp.bin -m 0x40000 -c "" -d out/soc/am62x/evm/combined-tifs-cfg.bin -n 0x67000 -t out/soc/am62x/evm/combined-dm-cfg.bin -y 0x43c3a8
00 -k ti-degenerate-key.pem -r 1 -o tiboot3-am62x-gp-evm.bin
-am62x-gp.bin -m 0x40000 -c "" -d out/soc/am62x/evm/combined-tifs-cfg.bin -n 0x67000 -t out/soc/am62x/evm/combined-dm-cfg.bin -y 0x43c3a8
00 -k ti-degenerate-key.pem -r 1 -o tiboot3-am62x-gp-evm.bin
[그림 4.3] tiboot3.bin image 생성 모습
chyi@earth:/mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/k3-image-gen$ ls -la
합계 456
drwxrwxr-x 7 chyi chyi 4096 7월 23 12:18 .
drwxrwxr-x 7 chyi chyi 4096 7월 23 12:15 ..
drwxrwxr-x 8 chyi chyi 4096 7월 23 12:16 .git
-rw-rw-r-- 1 chyi chyi 26 7월 23 12:16 .gitignore
-rw-rw-r-- 1 chyi chyi 1500 7월 23 12:16 LICENSE
-rw-rw-r-- 1 chyi chyi 9886 7월 23 12:16 Makefile
-rw-rw-r-- 1 chyi chyi 7656 7월 23 12:16 README.md
-rwxrwxr-x 1 chyi chyi 2603 7월 23 12:16 gen_its.sh
-rwxrwxr-x 1 chyi chyi 9652 7월 23 12:16 gen_x509_cert.sh
drwxrwxr-x 3 chyi chyi 4096 7월 23 12:16 include
drwxrwxr-x 3 chyi chyi 4096 7월 23 12:18 out
drwxrwxr-x 2 chyi chyi 4096 7월 23 12:16 scripts
drwxrwxr-x 10 chyi chyi 4096 7월 23 12:16 soc
-rw-rw-r-- 1 chyi chyi 64398 7월 23 12:16 system-firmware-image-gen-1.0-manifest.html
-rw-rw-r-- 1 chyi chyi 538 7월 23 12:16 ti-degenerate-key.pem
-rw-rw-r-- 1 chyi chyi 322645 7월 23 12:18 tiboot3-am62x-gp-evm.bin
lrwxrwxrwx 1 chyi chyi 24 7월 23 12:18 tiboot3.bin -> tiboot3-am62x-gp-evm.bin
합계 456
drwxrwxr-x 7 chyi chyi 4096 7월 23 12:18 .
drwxrwxr-x 7 chyi chyi 4096 7월 23 12:15 ..
drwxrwxr-x 8 chyi chyi 4096 7월 23 12:16 .git
-rw-rw-r-- 1 chyi chyi 26 7월 23 12:16 .gitignore
-rw-rw-r-- 1 chyi chyi 1500 7월 23 12:16 LICENSE
-rw-rw-r-- 1 chyi chyi 9886 7월 23 12:16 Makefile
-rw-rw-r-- 1 chyi chyi 7656 7월 23 12:16 README.md
-rwxrwxr-x 1 chyi chyi 2603 7월 23 12:16 gen_its.sh
-rwxrwxr-x 1 chyi chyi 9652 7월 23 12:16 gen_x509_cert.sh
drwxrwxr-x 3 chyi chyi 4096 7월 23 12:16 include
drwxrwxr-x 3 chyi chyi 4096 7월 23 12:18 out
drwxrwxr-x 2 chyi chyi 4096 7월 23 12:16 scripts
drwxrwxr-x 10 chyi chyi 4096 7월 23 12:16 soc
-rw-rw-r-- 1 chyi chyi 64398 7월 23 12:16 system-firmware-image-gen-1.0-manifest.html
-rw-rw-r-- 1 chyi chyi 538 7월 23 12:16 ti-degenerate-key.pem
-rw-rw-r-- 1 chyi chyi 322645 7월 23 12:18 tiboot3-am62x-gp-evm.bin
lrwxrwxrwx 1 chyi chyi 24 7월 23 12:18 tiboot3.bin -> tiboot3-am62x-gp-evm.bin
2) tispl.bin 및 u-boot.img 파일 생성하기
[그림 4.4] tispl.bin image 구성 내용 [출처 - 참고문헌 7]
<A53용 TF-A code build 하기>
$ . /opt/beagleplay/environment-setup-aarch64-poky-linux
=> 앞장에서 생성한 yocto sdk를 사용할 수 있도록 준비한다.
$ cd ..
$ git clone https://github.com/ARM-software/arm-trusted-firmware.git
$ cd arm-trusted-firmware/
$ git checkout v2.9
$ export CROSS_COMPILE=aarch64-poky-linux-
$ make ARCH=aarch64 PLAT=k3 TARGET_BOARD=lite
...
aarch64-poky-linux-ld.bfd: unrecognized option '-Wl,-O1'
...
$ unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
=> 위의 에러 발생 시, unset 명령을 실행해 주자.
$ make ARCH=aarch64 PLAT=k3 TARGET_BOARD=lite
Building k3
LD /mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/arm-trusted-firmware/build/k3/lite/rele
ase/bl31/bl31.elf
BIN /mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/arm-trusted-firmware/build/k3/lite/rele
ase/bl31.bin
Built /mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/arm-trusted-firmware/build/k3/lite/release/
bl31.bin successfully
OD /mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/arm-trusted-firmware/build/k3/lite/rele
ase/bl31/bl31.dump
LD /mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/arm-trusted-firmware/build/k3/lite/rele
ase/bl31/bl31.elf
BIN /mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/arm-trusted-firmware/build/k3/lite/rele
ase/bl31.bin
Built /mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/arm-trusted-firmware/build/k3/lite/release/
bl31.bin successfully
OD /mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/arm-trusted-firmware/build/k3/lite/rele
ase/bl31/bl31.dump
<tispl.bin & u-boot.img 파일 생성하기>
$ cd ..
$ mkdir build_uboot/a53/
$ cd u-boot/
$ export CROSS_COMPILE=aarch64-poky-linux-
$ make O=../build_uboot/a53/ am62x_evm_a53_defconfig
$ make O=../build_uboot/a53/ menuconfig
Environment --->
[*] Environment is in a EXT4 filesystem
(mmc) Name of the block device for the environment
(1:2) Device and partition for where to store the environemt in EXT4
(/uboot.env) Name of the EXT4 file to use for the environment
[ ] SPL Environment is in a EXT4 filesystem
$ make ATF=../arm-trusted-firmware/build/k3/lite/release/bl31.bin \
DM=../ti-linux-firmware/ti-dm/am62xx/ipc_echo_testb_mcu1_0_release_strip.xer5f \
O=../build_uboot/a53
...
FDTGREP spl/dts/k3-am625-sk.dtb
SECURE spl/dts/k3-am625-sk.dtb_HS
WARNING: TI_SECURE_DEV_PKG environment variable must be defined for TI secure devices. spl/dts/k3-am625-sk.dtb_HS was NOT secured!
MKITS u-boot-spl-k3_HS.its
WARNING ATF file ../arm-trusted-firmware/build/k3/lite/release/bl31.bin NOT found, resulting binary is non-functional
WARNING OPTEE file bl32.bin NOT found, resulting might be non-functional
WARNING DM file ../ti-linux-firmware/ti-dm/am62xx/ipc_echo_testb_mcu1_0_release_strip.xer5f NOT found, resulting might be non-functional
MKIMAGE tispl.bin_HS
FIT description: Configuration to load ATF and SPL
Created: Tue Jul 23 13:45:38 2024
Image 0 (atf)
Description: ARM Trusted Firmware
Created: Tue Jul 23 13:45:38 2024
Type: Firmware
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Architecture: AArch64
OS: ARM Trusted Firmware
Load Address: 0x9e780000
Image 1 (tee)
Description: OPTEE
Created: Tue Jul 23 13:45:38 2024
Type: Trusted Execution Environment Image
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Image 2 (dm)
Description: DM binary
Created: Tue Jul 23 13:45:38 2024
Type: Firmware
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Architecture: Unknown Architecture
OS: Unknown OS
Load Address: 0x89000000
Image 3 (spl)
Description: SPL (64-bit)
Created: Tue Jul 23 13:45:38 2024
Type: Standalone Program
Compression: uncompressed
Data Size: 311960 Bytes = 304.65 KiB = 0.30 MiB
Architecture: AArch64
Load Address: 0x80080000
Entry Point: 0x80080000
Image 4 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Created: Tue Jul 23 13:45:38 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18484 Bytes = 18.05 KiB = 0.02 MiB
Architecture: ARM
Image 5 (k3-am625-sk.dtb)
Description: k3-am625-sk
Created: Tue Jul 23 13:45:38 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18741 Bytes = 18.30 KiB = 0.02 MiB
Architecture: ARM
Default Configuration: 'k3-am625-beagleplay.dtb'
Configuration 0 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Kernel: unavailable
Firmware: atf
FDT: k3-am625-beagleplay.dtb
Loadables: tee
dm
spl
Configuration 1 (k3-am625-sk.dtb)
Description: k3-am625-sk
Kernel: unavailable
Firmware: atf
FDT: k3-am625-sk.dtb
Loadables: tee
dm
spl
MKIMAGE tispl.bin
FIT description: Configuration to load ATF and SPL
Created: Tue Jul 23 13:45:38 2024
Image 0 (atf)
Description: ARM Trusted Firmware
Created: Tue Jul 23 13:45:38 2024
Type: Firmware
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB # 뭔가 이상하다. ...................... (A)
Architecture: AArch64
OS: ARM Trusted Firmware
Load Address: 0x9e780000
Image 1 (tee)
Description: OPTEE
Created: Tue Jul 23 13:45:38 2024
Type: Trusted Execution Environment Image
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Image 2 (dm)
Description: DM binary
Created: Tue Jul 23 13:45:38 2024
Type: Firmware
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Architecture: Unknown Architecture
OS: Unknown OS
Load Address: 0x89000000
Image 3 (spl)
Description: SPL (64-bit)
Created: Tue Jul 23 13:45:38 2024
Type: Standalone Program
Compression: uncompressed
Data Size: 311960 Bytes = 304.65 KiB = 0.30 MiB
Architecture: AArch64
Load Address: 0x80080000
Entry Point: 0x80080000
Image 4 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Created: Tue Jul 23 13:45:38 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18484 Bytes = 18.05 KiB = 0.02 MiB
Architecture: ARM
Image 5 (k3-am625-sk.dtb)
Description: k3-am625-sk
Created: Tue Jul 23 13:45:38 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18741 Bytes = 18.30 KiB = 0.02 MiB
Architecture: ARM
Default Configuration: 'k3-am625-beagleplay.dtb'
Configuration 0 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Kernel: unavailable
Firmware: atf
FDT: k3-am625-beagleplay.dtb
Loadables: tee
dm
spl
Configuration 1 (k3-am625-sk.dtb)
Description: k3-am625-sk
Kernel: unavailable
Firmware: atf
FDT: k3-am625-sk.dtb
Loadables: tee
dm
spl
MKIMAGE spl/u-boot-spl.multidtb.fit
CAT spl/u-boot-spl-dtb.bin
COPY spl/u-boot-spl.bin
SYM spl/u-boot-spl.sym
COPY u-boot.dtb
MKIMAGE u-boot-dtb.img
===================== WARNING ======================
This board uses CONFIG_SPL_FIT_GENERATOR. Please migrate
to binman instead, to avoid the proliferation of
arch-specific scripts with no tests.
====================================================
CFGCHK u-boot.cfg
make[1]: 디렉터리 '/mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/build_uboot/a53' 나감
SECURE spl/dts/k3-am625-sk.dtb_HS
WARNING: TI_SECURE_DEV_PKG environment variable must be defined for TI secure devices. spl/dts/k3-am625-sk.dtb_HS was NOT secured!
MKITS u-boot-spl-k3_HS.its
WARNING ATF file ../arm-trusted-firmware/build/k3/lite/release/bl31.bin NOT found, resulting binary is non-functional
WARNING OPTEE file bl32.bin NOT found, resulting might be non-functional
WARNING DM file ../ti-linux-firmware/ti-dm/am62xx/ipc_echo_testb_mcu1_0_release_strip.xer5f NOT found, resulting might be non-functional
MKIMAGE tispl.bin_HS
FIT description: Configuration to load ATF and SPL
Created: Tue Jul 23 13:45:38 2024
Image 0 (atf)
Description: ARM Trusted Firmware
Created: Tue Jul 23 13:45:38 2024
Type: Firmware
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Architecture: AArch64
OS: ARM Trusted Firmware
Load Address: 0x9e780000
Image 1 (tee)
Description: OPTEE
Created: Tue Jul 23 13:45:38 2024
Type: Trusted Execution Environment Image
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Image 2 (dm)
Description: DM binary
Created: Tue Jul 23 13:45:38 2024
Type: Firmware
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Architecture: Unknown Architecture
OS: Unknown OS
Load Address: 0x89000000
Image 3 (spl)
Description: SPL (64-bit)
Created: Tue Jul 23 13:45:38 2024
Type: Standalone Program
Compression: uncompressed
Data Size: 311960 Bytes = 304.65 KiB = 0.30 MiB
Architecture: AArch64
Load Address: 0x80080000
Entry Point: 0x80080000
Image 4 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Created: Tue Jul 23 13:45:38 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18484 Bytes = 18.05 KiB = 0.02 MiB
Architecture: ARM
Image 5 (k3-am625-sk.dtb)
Description: k3-am625-sk
Created: Tue Jul 23 13:45:38 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18741 Bytes = 18.30 KiB = 0.02 MiB
Architecture: ARM
Default Configuration: 'k3-am625-beagleplay.dtb'
Configuration 0 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Kernel: unavailable
Firmware: atf
FDT: k3-am625-beagleplay.dtb
Loadables: tee
dm
spl
Configuration 1 (k3-am625-sk.dtb)
Description: k3-am625-sk
Kernel: unavailable
Firmware: atf
FDT: k3-am625-sk.dtb
Loadables: tee
dm
spl
MKIMAGE tispl.bin
FIT description: Configuration to load ATF and SPL
Created: Tue Jul 23 13:45:38 2024
Image 0 (atf)
Description: ARM Trusted Firmware
Created: Tue Jul 23 13:45:38 2024
Type: Firmware
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB # 뭔가 이상하다. ...................... (A)
Architecture: AArch64
OS: ARM Trusted Firmware
Load Address: 0x9e780000
Image 1 (tee)
Description: OPTEE
Created: Tue Jul 23 13:45:38 2024
Type: Trusted Execution Environment Image
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Image 2 (dm)
Description: DM binary
Created: Tue Jul 23 13:45:38 2024
Type: Firmware
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Architecture: Unknown Architecture
OS: Unknown OS
Load Address: 0x89000000
Image 3 (spl)
Description: SPL (64-bit)
Created: Tue Jul 23 13:45:38 2024
Type: Standalone Program
Compression: uncompressed
Data Size: 311960 Bytes = 304.65 KiB = 0.30 MiB
Architecture: AArch64
Load Address: 0x80080000
Entry Point: 0x80080000
Image 4 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Created: Tue Jul 23 13:45:38 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18484 Bytes = 18.05 KiB = 0.02 MiB
Architecture: ARM
Image 5 (k3-am625-sk.dtb)
Description: k3-am625-sk
Created: Tue Jul 23 13:45:38 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18741 Bytes = 18.30 KiB = 0.02 MiB
Architecture: ARM
Default Configuration: 'k3-am625-beagleplay.dtb'
Configuration 0 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Kernel: unavailable
Firmware: atf
FDT: k3-am625-beagleplay.dtb
Loadables: tee
dm
spl
Configuration 1 (k3-am625-sk.dtb)
Description: k3-am625-sk
Kernel: unavailable
Firmware: atf
FDT: k3-am625-sk.dtb
Loadables: tee
dm
spl
MKIMAGE spl/u-boot-spl.multidtb.fit
CAT spl/u-boot-spl-dtb.bin
COPY spl/u-boot-spl.bin
SYM spl/u-boot-spl.sym
COPY u-boot.dtb
MKIMAGE u-boot-dtb.img
===================== WARNING ======================
This board uses CONFIG_SPL_FIT_GENERATOR. Please migrate
to binman instead, to avoid the proliferation of
arch-specific scripts with no tests.
====================================================
CFGCHK u-boot.cfg
make[1]: 디렉터리 '/mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/build_uboot/a53' 나감
3) Bootable SD card 만들기
microSD 카드를 하나 준비한 후, 앞서 build한 3개의 binary 즉, tiboot3.bin, tispl.bin, u-boot.img 파일을 이용하여 bootable sdcard를 만들어 보자.
앞서 3장에서 yocto project build 결과물인 core-image-minimal-beagleplay-20240719091250.rootfs.wic 파일을 가지 dd 명령을 수행했던 것을, 이번에는 일일이 수작업으로 진행한다고 보면 될 듯 하다.
일단 sdcard의 기존 내용을 지우자.
$ sudo dd if=/dev/zero of=/dev/sdb bs=1M count=16
16+0 레코드 들어옴
16+0 레코드 나감
16777216 bytes (17 MB, 16 MiB) copied, 1.94944 s, 8.6 MB/s
16+0 레코드 들어옴
16+0 레코드 나감
16777216 bytes (17 MB, 16 MiB) copied, 1.94944 s, 8.6 MB/s
$ sudo fdisk /dev/sdb
이후, 2개의 partition을 만들고, 아래와 같이 설정한다.
- sdb1 : 128MB, W95 FAT32 (c 선택), Bootable 설정(a 선택)
- sdb2: 나머지, Linux(83 선택)
[그림 4.6] fdisk 명령 실행 모습
다음으로 각각의 파티션에 대해 그에 맞는 file system을 만들어 준다.
$ sudo mkfs.vfat -F 32 -n boot /dev/sdb1
=> 첫번째 파티션에 대해 FAT32 file system을 생성한다(bootable option 추가).
=> 첫번째 파티션에 대해 FAT32 file system을 생성한다(bootable option 추가).
mkfs.fat 4.2 (2021-01-31)
mkfs.fat: Warning: lowercase labels might not work properly on some systems
mkfs.fat: Warning: lowercase labels might not work properly on some systems
$ sudo mkfs.ext4 -L env -O ^metadata_csum /dev/sdb2
=> 두번째 파티션에 대한 ext4 file system을 생성한다(metadata checksum disable 함)
=> 두번째 파티션에 대한 ext4 file system을 생성한다(metadata checksum disable 함)
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 3856512 4k blocks and 964768 inodes
Filesystem UUID: 1b926c66-2833-4679-a1c5-fcf7b2ea9657
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
Creating filesystem with 3856512 4k blocks and 964768 inodes
Filesystem UUID: 1b926c66-2833-4679-a1c5-fcf7b2ea9657
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
자 이제, 앞서 build해 두었던, 3개의 binary를 microSD로 복사할 차례이다. 복사하기에 앞서, microSD를 PC에서 제거했다가 다시 삽입해 준다.
$ sudo umount /dev/sdb1 /dev/sdb2
<제거 후 다시 삽입>
$ df
파일 시스템 1K-블록 사용 가용 사용% 마운트위치
...
/dev/sdb1 129039 1 129039 1% /media/chyi/boot
/dev/sdb2 15077296 24 14289588 1% /media/chyi/env
파일 시스템 1K-블록 사용 가용 사용% 마운트위치
...
/dev/sdb1 129039 1 129039 1% /media/chyi/boot
/dev/sdb2 15077296 24 14289588 1% /media/chyi/env
$ cp bootloader/k3-image-gen/tiboot3.bin /media/chyi/boot
$ cp build_uboot/a53/tispl.bin /media/chyi/boot
$ cp build_uboot/a53/tispl.bin /media/chyi/boot
$ cp build_uboot/a53/u-boot.img /media/chyi/boot
[그림 4.7] microSD 카드 boot partition 모습
모든 준비가 끝났으니, kernel image(Image)와 rootfs는 없지만, 지금까지 작업한 내용이 정상 동작하는지 확인해 보자.
Target board에 microSD를 삽입한 후, USR 버튼을 누른 상태에서 USB-C 전원(혹은 reset button)을 넣어 주자. 오, 이런 TF-A(ATF)를 시작해야 하는데, 진행이 안되고 먹통이 된다. 왜 그럴까 ? 😓
[그림 4.8] 교체된 이미지로 Booting 모습 - 실패
U-Boot SPL 2021.01-gf036fbdc25 (Jul 23 2024 - 12:12:54 +0900)
SYSFW ABI: 3.1 (firmware rev 0x0009 '9.0.4--v09.00.04 (Kool Koala)')
SPL initial stack usage: 13384 bytes
Trying to boot from MMC2
spl_load_fit_image: Skip load 'atf': image size is 0! #이게 좀 이상하다.
spl_load_fit_image: Skip load 'tee': image size is 0!
spl_load_fit_image: Skip load 'dm': image size is 0!
Loading Environment from MMC... *** Warning - No MMC card found, using default environment
Starting ATF on ARM64 core... #얘는 R5 u-boot spl이 출려과는 내용임.
____________________________________________________________
SYSFW ABI: 3.1 (firmware rev 0x0009 '9.0.4--v09.00.04 (Kool Koala)')
SPL initial stack usage: 13384 bytes
Trying to boot from MMC2
spl_load_fit_image: Skip load 'atf': image size is 0! #이게 좀 이상하다.
spl_load_fit_image: Skip load 'tee': image size is 0!
spl_load_fit_image: Skip load 'dm': image size is 0!
Loading Environment from MMC... *** Warning - No MMC card found, using default environment
Starting ATF on ARM64 core... #얘는 R5 u-boot spl이 출려과는 내용임.
____________________________________________________________
앞서 tispl.bin & u-boot.img를 생성할 때, (A) 부분이 이상했었다. 아무래도 파일 위치를 못 찾아서 그런 것 같으니, full path를 주어 다시 build해 보자.
$ make ATF=/mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/arm-trusted-firmware/build/k3/lite/release/bl31.bin DM=/mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/ti-linux-firmware/ti-dm/am62xx/ipc_echo_testb_mcu1_0_release_str
ip.xer5f O=/mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/build_uboot/a53
ip.xer5f O=/mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/bootloader/build_uboot/a53
FIT description: Configuration to load ATF and SPL
Created: Tue Jul 23 15:51:44 2024
Image 0 (atf)
Description: ARM Trusted Firmware
Created: Tue Jul 23 15:51:44 2024
Type: Firmware
Compression: uncompressed
Data Size: 39368 Bytes = 38.45 KiB = 0.04 MiB # OK, 이번에는 제대로된 값이 보인다.
Architecture: AArch64
OS: ARM Trusted Firmware
Load Address: 0x9e780000
Image 1 (tee)
Description: OPTEE
Created: Tue Jul 23 15:51:44 2024
Type: Trusted Execution Environment Image
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Image 2 (dm)
Description: DM binary
Created: Tue Jul 23 15:51:44 2024
Type: Firmware
Compression: uncompressed
Data Size: 148388 Bytes = 144.91 KiB = 0.14 MiB
Architecture: Unknown Architecture
OS: Unknown OS
Load Address: 0x89000000
Image 3 (spl)
Description: SPL (64-bit)
Created: Tue Jul 23 15:51:44 2024
Type: Standalone Program
Compression: uncompressed
Data Size: 311960 Bytes = 304.65 KiB = 0.30 MiB
Architecture: AArch64
Load Address: 0x80080000
Entry Point: 0x80080000
Image 4 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Created: Tue Jul 23 15:51:44 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18484 Bytes = 18.05 KiB = 0.02 MiB
Architecture: ARM
Image 5 (k3-am625-sk.dtb)
Description: k3-am625-sk
Created: Tue Jul 23 15:51:44 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18741 Bytes = 18.30 KiB = 0.02 MiB
Architecture: ARM
Default Configuration: 'k3-am625-beagleplay.dtb'
Configuration 0 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Kernel: unavailable
Firmware: atf
FDT: k3-am625-beagleplay.dtb
Loadables: tee
dm
spl
Configuration 1 (k3-am625-sk.dtb)
Description: k3-am625-sk
Kernel: unavailable
Firmware: atf
FDT: k3-am625-sk.dtb
Loadables: tee
dm
spl
MKIMAGE tispl.bin
FIT description: Configuration to load ATF and SPL
Created: Tue Jul 23 15:51:44 2024
Image 0 (atf)
Description: ARM Trusted Firmware
Created: Tue Jul 23 15:51:44 2024
Type: Firmware
Compression: uncompressed
Data Size: 39368 Bytes = 38.45 KiB = 0.04 MiB
Architecture: AArch64
OS: ARM Trusted Firmware
Load Address: 0x9e780000
Image 1 (tee)
Description: OPTEE
Created: Tue Jul 23 15:51:44 2024
Type: Trusted Execution Environment Image
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Image 2 (dm)
Description: DM binary
Created: Tue Jul 23 15:51:44 2024
Type: Firmware
Compression: uncompressed
Data Size: 148388 Bytes = 144.91 KiB = 0.14 MiB
Architecture: Unknown Architecture
OS: Unknown OS
Load Address: 0x89000000
Image 3 (spl)
Description: SPL (64-bit)
Created: Tue Jul 23 15:51:44 2024
Type: Standalone Program
Compression: uncompressed
Data Size: 311960 Bytes = 304.65 KiB = 0.30 MiB
Architecture: AArch64
Load Address: 0x80080000
Entry Point: 0x80080000
Image 4 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Created: Tue Jul 23 15:51:44 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18484 Bytes = 18.05 KiB = 0.02 MiB
Architecture: ARM
Image 5 (k3-am625-sk.dtb)
Description: k3-am625-sk
Created: Tue Jul 23 15:51:44 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18741 Bytes = 18.30 KiB = 0.02 MiB
Architecture: ARM
Default Configuration: 'k3-am625-beagleplay.dtb'
Configuration 0 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Kernel: unavailable
Firmware: atf
FDT: k3-am625-beagleplay.dtb
Loadables: tee
dm
spl
Configuration 1 (k3-am625-sk.dtb)
Description: k3-am625-sk
Kernel: unavailable
Firmware: atf
FDT: k3-am625-sk.dtb
Loadables: tee
dm
spl
MKIMAGE spl/u-boot-spl.multidtb.fit
CAT spl/u-boot-spl-dtb.bin
COPY spl/u-boot-spl.bin
SYM spl/u-boot-spl.sym
COPY u-boot.dtb
MKIMAGE u-boot-dtb.img
Created: Tue Jul 23 15:51:44 2024
Image 0 (atf)
Description: ARM Trusted Firmware
Created: Tue Jul 23 15:51:44 2024
Type: Firmware
Compression: uncompressed
Data Size: 39368 Bytes = 38.45 KiB = 0.04 MiB # OK, 이번에는 제대로된 값이 보인다.
Architecture: AArch64
OS: ARM Trusted Firmware
Load Address: 0x9e780000
Image 1 (tee)
Description: OPTEE
Created: Tue Jul 23 15:51:44 2024
Type: Trusted Execution Environment Image
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Image 2 (dm)
Description: DM binary
Created: Tue Jul 23 15:51:44 2024
Type: Firmware
Compression: uncompressed
Data Size: 148388 Bytes = 144.91 KiB = 0.14 MiB
Architecture: Unknown Architecture
OS: Unknown OS
Load Address: 0x89000000
Image 3 (spl)
Description: SPL (64-bit)
Created: Tue Jul 23 15:51:44 2024
Type: Standalone Program
Compression: uncompressed
Data Size: 311960 Bytes = 304.65 KiB = 0.30 MiB
Architecture: AArch64
Load Address: 0x80080000
Entry Point: 0x80080000
Image 4 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Created: Tue Jul 23 15:51:44 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18484 Bytes = 18.05 KiB = 0.02 MiB
Architecture: ARM
Image 5 (k3-am625-sk.dtb)
Description: k3-am625-sk
Created: Tue Jul 23 15:51:44 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18741 Bytes = 18.30 KiB = 0.02 MiB
Architecture: ARM
Default Configuration: 'k3-am625-beagleplay.dtb'
Configuration 0 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Kernel: unavailable
Firmware: atf
FDT: k3-am625-beagleplay.dtb
Loadables: tee
dm
spl
Configuration 1 (k3-am625-sk.dtb)
Description: k3-am625-sk
Kernel: unavailable
Firmware: atf
FDT: k3-am625-sk.dtb
Loadables: tee
dm
spl
MKIMAGE tispl.bin
FIT description: Configuration to load ATF and SPL
Created: Tue Jul 23 15:51:44 2024
Image 0 (atf)
Description: ARM Trusted Firmware
Created: Tue Jul 23 15:51:44 2024
Type: Firmware
Compression: uncompressed
Data Size: 39368 Bytes = 38.45 KiB = 0.04 MiB
Architecture: AArch64
OS: ARM Trusted Firmware
Load Address: 0x9e780000
Image 1 (tee)
Description: OPTEE
Created: Tue Jul 23 15:51:44 2024
Type: Trusted Execution Environment Image
Compression: uncompressed
Data Size: 0 Bytes = 0.00 KiB = 0.00 MiB
Image 2 (dm)
Description: DM binary
Created: Tue Jul 23 15:51:44 2024
Type: Firmware
Compression: uncompressed
Data Size: 148388 Bytes = 144.91 KiB = 0.14 MiB
Architecture: Unknown Architecture
OS: Unknown OS
Load Address: 0x89000000
Image 3 (spl)
Description: SPL (64-bit)
Created: Tue Jul 23 15:51:44 2024
Type: Standalone Program
Compression: uncompressed
Data Size: 311960 Bytes = 304.65 KiB = 0.30 MiB
Architecture: AArch64
Load Address: 0x80080000
Entry Point: 0x80080000
Image 4 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Created: Tue Jul 23 15:51:44 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18484 Bytes = 18.05 KiB = 0.02 MiB
Architecture: ARM
Image 5 (k3-am625-sk.dtb)
Description: k3-am625-sk
Created: Tue Jul 23 15:51:44 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 18741 Bytes = 18.30 KiB = 0.02 MiB
Architecture: ARM
Default Configuration: 'k3-am625-beagleplay.dtb'
Configuration 0 (k3-am625-beagleplay.dtb)
Description: k3-am625-beagleplay
Kernel: unavailable
Firmware: atf
FDT: k3-am625-beagleplay.dtb
Loadables: tee
dm
spl
Configuration 1 (k3-am625-sk.dtb)
Description: k3-am625-sk
Kernel: unavailable
Firmware: atf
FDT: k3-am625-sk.dtb
Loadables: tee
dm
spl
MKIMAGE spl/u-boot-spl.multidtb.fit
CAT spl/u-boot-spl-dtb.bin
COPY spl/u-boot-spl.bin
SYM spl/u-boot-spl.sym
COPY u-boot.dtb
MKIMAGE u-boot-dtb.img
이 상태에서 다시 부팅 시도를 해 보니 ... OK, 이번에는 정상 동작한다. 😎
[그림 4.9] 교체된 이미지로 Booting 모습 - 성공
U-boot 구동 중, <Space> key를 눌러 command mode(u-boot prompt mode)로 진입해 보자.
현재 설정 상태를 확인해 보자.
=> printenv
addr_fit=0x90000000
arch=arm
args_all=setenv optargs ${optargs} earlycon=ns16550a,mmio32,0x02800000 ${mtdparts}
args_mmc=run finduuid;setenv bootargs console=${console} ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype}
args_usb=run finduuid;setenv bootargs console=${console} ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype}
baudrate=115200
board=am62x
board_name=am62x_play
board_rev=02
board_serial=SSSS
board_software_revision=01
boot=mmc
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootaa64.efi; if fdt addr ${fdt_addr_r}; ti
boot_efi_bootmgr=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr;fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_fdt=try
boot_fit=0
boot_net_usb_start=usb start
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc1 mmc0 pxe dhcp linux
bootcmd=run findfdt;run distro_bootcmd
bootcmd_dhcp=setenv devtype dhcp; run boot_net_usb_start; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; f;
bootcmd_linux=if test "${android_boot}" -eq 0; then;run findfdt; run envboot; run init_${boot};if test ${boot_fit} -eq 1; then;rui
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi
bootdelay=2
bootdir=/boot
bootenvfile=uEnv.txt
bootm_size=0x10000000
bootpart=1:2
bootscript=echo Running bootscript from mmc${mmcdev} ...; source ${loadaddr}
console=ttyS2,115200n8
cpu=armv8
default_device_tree=k3-am625-beagleplay.dtb
dfu_alt_info_emmc=rawemmc raw 0 0x800000 mmcpart 1;rootfs part 0 1 mmcpart 0;tiboot3.bin.raw raw 0x0 0x400 mmcpart 1;tispl.bin.ra1
dfu_alt_info_mmc=boot part 1 1;rootfs part 1 2;tiboot3.bin fat 1 1;tispl.bin fat 1 1;u-boot.img fat 1 1;uEnv.txt fat 1 1;sysfw.it1
dfu_alt_info_ospi=tiboot3.bin raw 0x0 0x080000;tispl.bin raw 0x080000 0x200000;u-boot.img raw 0x280000 0x400000;u-boot-env raw 0x0
dfu_alt_info_ram=tispl.bin ram 0x80080000 0x200000;u-boot.img ram 0x81000000 0x400000
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
dtboaddr=0x89000000
efi_dtb_prefixes=/ /dtb/ /dtb/current/
emmc_erase_boot0=mmc dev 0 1; mmc erase 0 0x2400;
envboot=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadbootscript; then run bootscript;e;
fdt_addr_r=0x88000000
fdtaddr=0x88000000
fdtcontroladdr=f7ec56c0
fdtoverlay_addr_r=0x80200000
findfdt=setenv name_fdt ${default_device_tree};if test $board_name = am62x_skevm; then setenv name_fdt k3-am625-sk.dtb; fi;if tes}
finduuid=part uuid ${boot} ${bootpart} uuid
get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${name_fdt}
get_fdt_usb=load usb ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
get_fit_mmc=load mmc ${bootpart} ${addr_fit} ${bootdir}/${name_fit}
get_fit_usb=load usb ${bootpart} ${addr_fit} ${bootdir}/${name_fit}
get_kern_mmc=load mmc ${bootpart} ${loadaddr} ${bootdir}/${name_kern}
get_kern_usb=load usb ${bootpart} ${loadaddr} ${bootdir}/${name_kern}
get_overlay_mmc=fdt address ${fdtaddr};fdt resize 0x100000;for overlay in $name_overlays;do;load mmc ${bootpart} ${dtboaddr} ${bo;
get_overlay_usb=fdt address ${fdtaddr};fdt resize 0x100000;for overlay in $name_overlays;do;load usb ${bootpart} ${dtboaddr} ${bo;
get_overlaystring=for overlay in $name_overlays;do;setenv overlaystring ${overlaystring}'#'${overlay};done;
importbootenv=echo Importing environment from mmc${mmcdev} ...; env import -t ${loadaddr} ${filesize}
init_mmc=run args_all args_mmc
init_usb=run args_all args_usb
kernel_addr_r=0x82000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x82000000
loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}
loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr
loadfdt=load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
mmcboot=mmc dev ${mmcdev}; devnum=${mmcdev}; devtype=mmc; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadim;
mmcdev=1
mmcloados=if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdtaddr}; else if ;
mmcrootfstype=ext4 rootwait
name_fit=fitImage
name_kern=Image
partitions=uuid_disk=${uuid_gpt_disk};name=rootfs,start=0,size=-,uuid=${uuid_gpt_rootfs}
partitions_android=uuid_disk=${uuid_gpt_disk};name=bootloader,start=5M,size=8M,uuid=${uuid_gpt_bootloader};name=tiboot3,start=4M,}
play_eeprom_dump=i2c dev ${play_eeprom_i2c_dev}; i2c md ${play_eeprom_i2c_addr} 0x00.2 40;
play_eeprom_erase=i2c dev ${play_eeprom_i2c_dev}; i2c md ${play_eeprom_i2c_addr} 0x00.2 40; gpio clear ${play_eeprom_wp_gpio}; i2
play_eeprom_i2c_addr=0x50;
play_eeprom_i2c_dev=0;
play_eeprom_production_program=i2c dev ${play_eeprom_i2c_dev}; i2c md ${play_eeprom_i2c_addr} 0x00.2 40; gpio clear ${play_eeprom
play_eeprom_wp_gpio=10;
pxefile_addr_r=0x80100000
ramdisk_addr_r=0x88080000
rd_spec=-
rdaddr=0x88080000
run_fit=bootm ${addr_fit}#${fdtfile}${overlaystring}
run_kern=booti ${loadaddr} ${rd_spec} ${fdtaddr}
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_e;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bot
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_boe
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefixi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; thee
scriptaddr=0x80000000
soc=k3
stderr=serial@2800000
stdin=serial@2800000
stdout=serial@2800000
update_to_fit=setenv loadaddr ${addr_fit}; setenv bootfile ${name_fit}
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
usbboot=setenv boot usb;setenv bootpart 0:2;usb start;run findfdt;run init_usb;run get_kern_usb;run get_fdt_usb;run run_kern
vendor=ti
Environment size: 14970/131068 bytes
=>
addr_fit=0x90000000
arch=arm
args_all=setenv optargs ${optargs} earlycon=ns16550a,mmio32,0x02800000 ${mtdparts}
args_mmc=run finduuid;setenv bootargs console=${console} ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype}
args_usb=run finduuid;setenv bootargs console=${console} ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype}
baudrate=115200
board=am62x
board_name=am62x_play
board_rev=02
board_serial=SSSS
board_software_revision=01
boot=mmc
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootaa64.efi; if fdt addr ${fdt_addr_r}; ti
boot_efi_bootmgr=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr;fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_fdt=try
boot_fit=0
boot_net_usb_start=usb start
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc1 mmc0 pxe dhcp linux
bootcmd=run findfdt;run distro_bootcmd
bootcmd_dhcp=setenv devtype dhcp; run boot_net_usb_start; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; f;
bootcmd_linux=if test "${android_boot}" -eq 0; then;run findfdt; run envboot; run init_${boot};if test ${boot_fit} -eq 1; then;rui
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi
bootdelay=2
bootdir=/boot
bootenvfile=uEnv.txt
bootm_size=0x10000000
bootpart=1:2
bootscript=echo Running bootscript from mmc${mmcdev} ...; source ${loadaddr}
console=ttyS2,115200n8
cpu=armv8
default_device_tree=k3-am625-beagleplay.dtb
dfu_alt_info_emmc=rawemmc raw 0 0x800000 mmcpart 1;rootfs part 0 1 mmcpart 0;tiboot3.bin.raw raw 0x0 0x400 mmcpart 1;tispl.bin.ra1
dfu_alt_info_mmc=boot part 1 1;rootfs part 1 2;tiboot3.bin fat 1 1;tispl.bin fat 1 1;u-boot.img fat 1 1;uEnv.txt fat 1 1;sysfw.it1
dfu_alt_info_ospi=tiboot3.bin raw 0x0 0x080000;tispl.bin raw 0x080000 0x200000;u-boot.img raw 0x280000 0x400000;u-boot-env raw 0x0
dfu_alt_info_ram=tispl.bin ram 0x80080000 0x200000;u-boot.img ram 0x81000000 0x400000
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
dtboaddr=0x89000000
efi_dtb_prefixes=/ /dtb/ /dtb/current/
emmc_erase_boot0=mmc dev 0 1; mmc erase 0 0x2400;
envboot=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadbootscript; then run bootscript;e;
fdt_addr_r=0x88000000
fdtaddr=0x88000000
fdtcontroladdr=f7ec56c0
fdtoverlay_addr_r=0x80200000
findfdt=setenv name_fdt ${default_device_tree};if test $board_name = am62x_skevm; then setenv name_fdt k3-am625-sk.dtb; fi;if tes}
finduuid=part uuid ${boot} ${bootpart} uuid
get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${name_fdt}
get_fdt_usb=load usb ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
get_fit_mmc=load mmc ${bootpart} ${addr_fit} ${bootdir}/${name_fit}
get_fit_usb=load usb ${bootpart} ${addr_fit} ${bootdir}/${name_fit}
get_kern_mmc=load mmc ${bootpart} ${loadaddr} ${bootdir}/${name_kern}
get_kern_usb=load usb ${bootpart} ${loadaddr} ${bootdir}/${name_kern}
get_overlay_mmc=fdt address ${fdtaddr};fdt resize 0x100000;for overlay in $name_overlays;do;load mmc ${bootpart} ${dtboaddr} ${bo;
get_overlay_usb=fdt address ${fdtaddr};fdt resize 0x100000;for overlay in $name_overlays;do;load usb ${bootpart} ${dtboaddr} ${bo;
get_overlaystring=for overlay in $name_overlays;do;setenv overlaystring ${overlaystring}'#'${overlay};done;
importbootenv=echo Importing environment from mmc${mmcdev} ...; env import -t ${loadaddr} ${filesize}
init_mmc=run args_all args_mmc
init_usb=run args_all args_usb
kernel_addr_r=0x82000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x82000000
loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}
loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr
loadfdt=load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
mmcboot=mmc dev ${mmcdev}; devnum=${mmcdev}; devtype=mmc; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadim;
mmcdev=1
mmcloados=if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdtaddr}; else if ;
mmcrootfstype=ext4 rootwait
name_fit=fitImage
name_kern=Image
partitions=uuid_disk=${uuid_gpt_disk};name=rootfs,start=0,size=-,uuid=${uuid_gpt_rootfs}
partitions_android=uuid_disk=${uuid_gpt_disk};name=bootloader,start=5M,size=8M,uuid=${uuid_gpt_bootloader};name=tiboot3,start=4M,}
play_eeprom_dump=i2c dev ${play_eeprom_i2c_dev}; i2c md ${play_eeprom_i2c_addr} 0x00.2 40;
play_eeprom_erase=i2c dev ${play_eeprom_i2c_dev}; i2c md ${play_eeprom_i2c_addr} 0x00.2 40; gpio clear ${play_eeprom_wp_gpio}; i2
play_eeprom_i2c_addr=0x50;
play_eeprom_i2c_dev=0;
play_eeprom_production_program=i2c dev ${play_eeprom_i2c_dev}; i2c md ${play_eeprom_i2c_addr} 0x00.2 40; gpio clear ${play_eeprom
play_eeprom_wp_gpio=10;
pxefile_addr_r=0x80100000
ramdisk_addr_r=0x88080000
rd_spec=-
rdaddr=0x88080000
run_fit=bootm ${addr_fit}#${fdtfile}${overlaystring}
run_kern=booti ${loadaddr} ${rd_spec} ${fdtaddr}
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_e;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bot
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_boe
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefixi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; thee
scriptaddr=0x80000000
soc=k3
stderr=serial@2800000
stdin=serial@2800000
stdout=serial@2800000
update_to_fit=setenv loadaddr ${addr_fit}; setenv bootfile ${name_fit}
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
usbboot=setenv boot usb;setenv bootpart 0:2;usb start;run findfdt;run init_usb;run get_kern_usb;run get_fdt_usb;run run_kern
vendor=ti
Environment size: 14970/131068 bytes
=>
(다음 장에서 사용하기 위해) 간만에 tftp 부팅을 시도하기 위한 준비 작업을 진행하자.
tftp client(target board, 192.168.8.200) -----> tftp server(PC, 192.168.8.162)
=> setenv ipaddr 192.168.8.200
=> setenv serverip 192.168.8.162
=> saveenv
조금 다른 내용이기는 하지만 u-boot의 code flow를 분석하고 싶다면, 오래전에 작성했던 아래 post 내용(5장)을 참조하는 것도 좋을 듯 하다.
부트로더가 어느 정도 준비되었으니, 이제는 Linux kernel로 넘어갈 차례가 되었다. Linux kernel 역시 별도로 download하여 build해 보도록 하자.
5. Linux Kernel 올리기
이번 장에서는 BeaglePlay 보드에 Linux kernel을 올리는 과정을 소개하고자 한다. Kernel code는 Torvalds 형님의 나와바리(?)인 mainline source을 먼저 받은 후, 그 위에 stable 버젼을 내려 받아 사용하기로 한다. 😋
1) Linux kernel download & build
$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux
$ cd linux
$ git fetch stable
$ git checkout stable/linux-6.6.y
=> 일단 이 버젼으로 전환하자(참고 문헌 2, 5 고려).
$ . /opt/beagleplay/environment-setup-aarch64-poky-linux
=> 3장에서 만든 yocto SDK(toolchain)를 이용하도록 하자.
Beagleplay용 kernel config가 있어야 하는데, 아래 site의 내용을 이용해 보도록 하자.
$ cp bb.org_defconfig arch/arm64/configs
=> 위에서 내려받은 파일을 제 위치에 복사하자.
$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-poky-linux-
$ make bb.org_defconfig
$ make menuconfig
$ make -j16
LD [M] net/nfc/nfc.o
LD [M] net/nfc/nfc_digital.o
AR net/built-in.a
LD [M] net/batman-adv/batman-adv.o
LD [M] net/mac80211/mac80211.o
make[1]: *** [/mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/linux/Makefile:1921: .] 오류 2
make: *** [Makefile:234: __sub-make] 오류 2
어라, 에러가 난다. 어디에서 나는지 확인하기 위해 다시 build 하자.
$ make
CALL scripts/checksyscalls.sh
make[6]: *** 'drivers/base/firmware_loader/builtin/regulatory.db.gen.o'에서 필요한 'firmware/regulatory.db' 타겟을 만들 규칙이 없습니다. 멈춤.
make[5]: *** [scripts/Makefile.build:480: drivers/base/firmware_loader/builtin] 오류 2
make[4]: *** [scripts/Makefile.build:480: drivers/base/firmware_loader] 오류 2
make[3]: *** [scripts/Makefile.build:480: drivers/base] 오류 2
make[2]: *** [scripts/Makefile.build:480: drivers] 오류 2
make[1]: *** [/mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/linux/Makefile:1921: .] 오류 2
make: *** [Makefile:234: __sub-make] 오류 2
내용을 보아하니, wireless lan(wifi) 관련 firmware가 필요한 모양인데 .... (아래처럼) firmware directory를 하나 만든 후, 아래 site에서 관련 파일 download 받아 복사해 보자(참고 문헌 2 참조).
$ mkdir firmware
$ cd ..
$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git
$ cd wireless-regdb
$ cp ./regulatory.db* ../linux/firmware
다시 build 시작 ...
$ make -j16
...
OK, build가 정상적으로 끝났다.
chyi@earth:/mnt/hdd/workspace/bootlin/beagleplay/bootlin/embedded-linux-beagleplay-labs/linux/arch/arm64/boot$ ls -la
합계 37092
drwxrwxr-x 3 chyi chyi 4096 7월 23 18:36 .
drwxrwxr-x 14 chyi chyi 4096 7월 23 18:14 ..
-rw-rw-r-- 1 chyi chyi 148 7월 23 18:36 .Image.cmd
-rw-rw-r-- 1 chyi chyi 106 7월 23 18:36 .Image.gz.cmd
-rw-rw-r-- 1 chyi chyi 64 7월 23 17:42 .gitignore
-rw-rw-r-- 1 chyi chyi 26751488 7월 23 18:36 Image
-rw-rw-r-- 1 chyi chyi 11280468 7월 23 18:36 Image.gz
-rw-rw-r-- 1 chyi chyi 1373 7월 23 17:42 Makefile
drwxrwxr-x 36 chyi chyi 4096 7월 23 17:42 dts
-rwxrwxr-x 1 chyi chyi 1001 7월 23 17:32 install.sh
합계 37092
drwxrwxr-x 3 chyi chyi 4096 7월 23 18:36 .
drwxrwxr-x 14 chyi chyi 4096 7월 23 18:14 ..
-rw-rw-r-- 1 chyi chyi 148 7월 23 18:36 .Image.cmd
-rw-rw-r-- 1 chyi chyi 106 7월 23 18:36 .Image.gz.cmd
-rw-rw-r-- 1 chyi chyi 64 7월 23 17:42 .gitignore
-rw-rw-r-- 1 chyi chyi 26751488 7월 23 18:36 Image
-rw-rw-r-- 1 chyi chyi 11280468 7월 23 18:36 Image.gz
-rw-rw-r-- 1 chyi chyi 1373 7월 23 17:42 Makefile
drwxrwxr-x 36 chyi chyi 4096 7월 23 17:42 dts
-rwxrwxr-x 1 chyi chyi 1001 7월 23 17:32 install.sh
device tree blob은 아래 위치에 생긴다.
~/linux/arch/arm64/boot/dts/ti$ ls -l *.dtb
-rw-rw-r-- 1 chyi chyi 49355 7월 23 18:13 k3-am62-lp-sk-hdmi-audio.dtb
-rw-rw-r-- 1 chyi chyi 49012 7월 23 18:13 k3-am62-lp-sk.dtb
-rw-rw-r-- 1 chyi chyi 39663 7월 23 18:13 k3-am625-beagleplay.dtb
-rw-rw-r-- 1 chyi chyi 35532 7월 23 18:13 k3-am625-phyboard-lyra-rdk.dtb
-rw-rw-r-- 1 chyi chyi 49074 7월 23 18:13 k3-am625-sk-hdmi-audio.dtb
-rw-rw-r-- 1 chyi chyi 48731 7월 23 18:13 k3-am625-sk.dtb
-rw-rw-r-- 1 chyi chyi 43863 7월 23 18:13 k3-am625-verdin-nonwifi-dahlia.dtb
-rw-rw-r-- 1 chyi chyi 44046 7월 23 18:13 k3-am625-verdin-nonwifi-dev.dtb
-rw-rw-r-- 1 chyi chyi 43487 7월 23 18:13 k3-am625-verdin-nonwifi-yavia.dtb
-rw-rw-r-- 1 chyi chyi 44192 7월 23 18:13 k3-am625-verdin-wifi-dahlia.dtb
-rw-rw-r-- 1 chyi chyi 44371 7월 23 18:13 k3-am625-verdin-wifi-dev.dtb
-rw-rw-r-- 1 chyi chyi 43816 7월 23 18:13 k3-am625-verdin-wifi-yavia.dtb
-rw-rw-r-- 1 chyi chyi 28888 7월 23 18:13 k3-am62a7-sk.dtb
-rw-rw-r-- 1 chyi chyi 7829 7월 23 18:13 k3-am62p5-sk.dtb
-rw-rw-r-- 1 chyi chyi 44829 7월 23 18:13 k3-am642-evm.dtb
-rw-rw-r-- 1 chyi chyi 41232 7월 23 18:13 k3-am642-phyboard-electra-rdk.dtb
-rw-rw-r-- 1 chyi chyi 44282 7월 23 18:13 k3-am642-sk.dtb
-rw-rw-r-- 1 chyi chyi 62640 7월 23 18:13 k3-am642-tqma64xxl-mbax4xxl-sdcard.dtb
-rw-rw-r-- 1 chyi chyi 62651 7월 23 18:13 k3-am642-tqma64xxl-mbax4xxl-wlan.dtb
-rw-rw-r-- 1 chyi chyi 62516 7월 23 18:13 k3-am642-tqma64xxl-mbax4xxl.dtb
-rw-rw-r-- 1 chyi chyi 50556 7월 23 18:13 k3-am6528-iot2050-basic-pg2.dtb
-rw-rw-r-- 1 chyi chyi 50457 7월 23 18:13 k3-am6528-iot2050-basic.dtb
-rw-rw-r-- 1 chyi chyi 67478 7월 23 18:13 k3-am654-base-board.dtb
-rw-rw-r-- 1 chyi chyi 68209 7월 23 18:13 k3-am654-gp-evm.dtb
-rw-rw-r-- 1 chyi chyi 70835 7월 23 18:13 k3-am6548-iot2050-advanced-m2.dtb
-rw-rw-r-- 1 chyi chyi 51334 7월 23 18:13 k3-am6548-iot2050-advanced-pg2.dtb
-rw-rw-r-- 1 chyi chyi 51235 7월 23 18:13 k3-am6548-iot2050-advanced.dtb
-rw-rw-r-- 1 chyi chyi 55998 7월 23 18:13 k3-am68-sk-base-board.dtb
-rw-rw-r-- 1 chyi chyi 54020 7월 23 18:13 k3-am69-sk.dtb
-rw-rw-r-- 1 chyi chyi 65011 7월 23 18:13 k3-j7200-common-proc-board.dtb
-rw-rw-r-- 1 chyi chyi 66121 7월 23 18:13 k3-j7200-evm.dtb
-rw-rw-r-- 1 chyi chyi 79337 7월 23 18:13 k3-j721e-beagleboneai64.dtb
-rw-rw-r-- 1 chyi chyi 113134 7월 23 18:13 k3-j721e-common-proc-board.dtb
-rw-rw-r-- 1 chyi chyi 114366 7월 23 18:13 k3-j721e-evm.dtb
-rw-rw-r-- 1 chyi chyi 80610 7월 23 18:13 k3-j721e-sk.dtb
-rw-rw-r-- 1 chyi chyi 75306 7월 23 18:13 k3-j721s2-common-proc-board.dtb
-rw-rw-r-- 1 chyi chyi 75923 7월 23 18:13 k3-j721s2-evm.dtb
-rw-rw-r-- 1 chyi chyi 61156 7월 23 18:13 k3-j784s4-evm.dtb
-rw-rw-r-- 1 chyi chyi 49355 7월 23 18:13 k3-am62-lp-sk-hdmi-audio.dtb
-rw-rw-r-- 1 chyi chyi 49012 7월 23 18:13 k3-am62-lp-sk.dtb
-rw-rw-r-- 1 chyi chyi 39663 7월 23 18:13 k3-am625-beagleplay.dtb
-rw-rw-r-- 1 chyi chyi 35532 7월 23 18:13 k3-am625-phyboard-lyra-rdk.dtb
-rw-rw-r-- 1 chyi chyi 49074 7월 23 18:13 k3-am625-sk-hdmi-audio.dtb
-rw-rw-r-- 1 chyi chyi 48731 7월 23 18:13 k3-am625-sk.dtb
-rw-rw-r-- 1 chyi chyi 43863 7월 23 18:13 k3-am625-verdin-nonwifi-dahlia.dtb
-rw-rw-r-- 1 chyi chyi 44046 7월 23 18:13 k3-am625-verdin-nonwifi-dev.dtb
-rw-rw-r-- 1 chyi chyi 43487 7월 23 18:13 k3-am625-verdin-nonwifi-yavia.dtb
-rw-rw-r-- 1 chyi chyi 44192 7월 23 18:13 k3-am625-verdin-wifi-dahlia.dtb
-rw-rw-r-- 1 chyi chyi 44371 7월 23 18:13 k3-am625-verdin-wifi-dev.dtb
-rw-rw-r-- 1 chyi chyi 43816 7월 23 18:13 k3-am625-verdin-wifi-yavia.dtb
-rw-rw-r-- 1 chyi chyi 28888 7월 23 18:13 k3-am62a7-sk.dtb
-rw-rw-r-- 1 chyi chyi 7829 7월 23 18:13 k3-am62p5-sk.dtb
-rw-rw-r-- 1 chyi chyi 44829 7월 23 18:13 k3-am642-evm.dtb
-rw-rw-r-- 1 chyi chyi 41232 7월 23 18:13 k3-am642-phyboard-electra-rdk.dtb
-rw-rw-r-- 1 chyi chyi 44282 7월 23 18:13 k3-am642-sk.dtb
-rw-rw-r-- 1 chyi chyi 62640 7월 23 18:13 k3-am642-tqma64xxl-mbax4xxl-sdcard.dtb
-rw-rw-r-- 1 chyi chyi 62651 7월 23 18:13 k3-am642-tqma64xxl-mbax4xxl-wlan.dtb
-rw-rw-r-- 1 chyi chyi 62516 7월 23 18:13 k3-am642-tqma64xxl-mbax4xxl.dtb
-rw-rw-r-- 1 chyi chyi 50556 7월 23 18:13 k3-am6528-iot2050-basic-pg2.dtb
-rw-rw-r-- 1 chyi chyi 50457 7월 23 18:13 k3-am6528-iot2050-basic.dtb
-rw-rw-r-- 1 chyi chyi 67478 7월 23 18:13 k3-am654-base-board.dtb
-rw-rw-r-- 1 chyi chyi 68209 7월 23 18:13 k3-am654-gp-evm.dtb
-rw-rw-r-- 1 chyi chyi 70835 7월 23 18:13 k3-am6548-iot2050-advanced-m2.dtb
-rw-rw-r-- 1 chyi chyi 51334 7월 23 18:13 k3-am6548-iot2050-advanced-pg2.dtb
-rw-rw-r-- 1 chyi chyi 51235 7월 23 18:13 k3-am6548-iot2050-advanced.dtb
-rw-rw-r-- 1 chyi chyi 55998 7월 23 18:13 k3-am68-sk-base-board.dtb
-rw-rw-r-- 1 chyi chyi 54020 7월 23 18:13 k3-am69-sk.dtb
-rw-rw-r-- 1 chyi chyi 65011 7월 23 18:13 k3-j7200-common-proc-board.dtb
-rw-rw-r-- 1 chyi chyi 66121 7월 23 18:13 k3-j7200-evm.dtb
-rw-rw-r-- 1 chyi chyi 79337 7월 23 18:13 k3-j721e-beagleboneai64.dtb
-rw-rw-r-- 1 chyi chyi 113134 7월 23 18:13 k3-j721e-common-proc-board.dtb
-rw-rw-r-- 1 chyi chyi 114366 7월 23 18:13 k3-j721e-evm.dtb
-rw-rw-r-- 1 chyi chyi 80610 7월 23 18:13 k3-j721e-sk.dtb
-rw-rw-r-- 1 chyi chyi 75306 7월 23 18:13 k3-j721s2-common-proc-board.dtb
-rw-rw-r-- 1 chyi chyi 75923 7월 23 18:13 k3-j721s2-evm.dtb
-rw-rw-r-- 1 chyi chyi 61156 7월 23 18:13 k3-j784s4-evm.dtb
2) Linux kernel 구동시키기
아직 rootfs가 준비되지는 않았지만, tftp로 부팅이 되는지 확인해 보도록 하자.
$ cp Image.gz /mnt/hdd/tftpboot/
$ cp k3-am625-beagleplay.dtb /mnt/hdd/tftpboot/
=> tftpserver base directory로 kernel image/dtb file을 복사한다.
<Target board>
=> setenv bootargs console=ttyS2,115200n8
=> saveenv
Saving Environment to EXT4... File System is consistent
file found, deleting
update journal finished
File System is consistent
update journal finished
done
OK
=> saveenv
Saving Environment to EXT4... File System is consistent
file found, deleting
update journal finished
File System is consistent
update journal finished
done
OK
=> tftp 0x80000000 Image.gz
Kernel 압축파일을 download 받아 RAM 0x80000000 번지에 load한다.
ethernet@8000000ethernet@8000000port@1 Waiting for PHY auto negotiation to complete....... done
link up on port 1, speed 1000, full duplex
Using ethernet@8000000ethernet@8000000port@1 device
TFTP from server 192.168.8.162; our IP address is 192.168.8.200
Filename 'Image.gz'.
Load address: 0x80000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
######################################################
1.8 MiB/s
done
Bytes transferred = 11280468 (ac2054 hex)
ethernet@8000000ethernet@8000000port@1 Waiting for PHY auto negotiation to complete....... done
link up on port 1, speed 1000, full duplex
Using ethernet@8000000ethernet@8000000port@1 device
TFTP from server 192.168.8.162; our IP address is 192.168.8.200
Filename 'Image.gz'.
Load address: 0x80000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
######################################################
1.8 MiB/s
done
Bytes transferred = 11280468 (ac2054 hex)
=> tftp 0x82000000 k3-am625-beagleplay.dtb
dtb 파일을 download 받아 RAM 0x82000000 번지에 load한다.
link up on port 1, speed 1000, full duplex
Using ethernet@8000000ethernet@8000000port@1 device
TFTP from server 192.168.8.162; our IP address is 192.168.8.200
Filename 'k3-am625-beagleplay.dtb'.
Load address: 0x82000000
Loading: ###
6.3 MiB/s
done
Bytes transferred = 39663 (9aef hex)
link up on port 1, speed 1000, full duplex
Using ethernet@8000000ethernet@8000000port@1 device
TFTP from server 192.168.8.162; our IP address is 192.168.8.200
Filename 'k3-am625-beagleplay.dtb'.
Load address: 0x82000000
Loading: ###
6.3 MiB/s
done
Bytes transferred = 39663 (9aef hex)
=> booti 0x80000000 - 0x82000000
kernel_comp_addr_r or kernel_comp_size is not provided!
booti 0x80000000 - 0x82000000
=> booti명령 사용법: booti [address of kernel] [address of ramdisk: filesize] paddress of dtb]
=> RAM에 올려져 있는 kernel(Image.gz), ramdisk rootfs, dtb 등을 이용하여 실제 booting을 시도하는 명령임.
=> ramdisk rootfs는 사용하지 않으므로, 그 자리에 '-' 를 대신 입력해 준다. 안그러면, dtb를 ramdisk로 오해할 수 있으니 ...
=> booti명령 사용법: booti [address of kernel] [address of ramdisk: filesize] paddress of dtb]
=> RAM에 올려져 있는 kernel(Image.gz), ramdisk rootfs, dtb 등을 이용하여 실제 booting을 시도하는 명령임.
=> ramdisk rootfs는 사용하지 않으므로, 그 자리에 '-' 를 대신 입력해 준다. 안그러면, dtb를 ramdisk로 오해할 수 있으니 ...
==========================================
어라, 에러가 발생한다.
Image.gz는 압축 파일이므로, u-boot은 부팅하기 전에 압축을 푼다. 문제는 압축을 푸는 위치와 압축이 풀렸을 때의 대략적인 size를 알고 있어야, 앞서 loading된 image의 위치와 겹치지 않도록 할 수가 있다. 이를 위해 u-boot에는 kernel_comp_addr_r(압축이 해제되는 RAM 상의 위치)과 kernel_comp_size(압축해제된 파일의 크기) 파라미터가 마련되어 있다.
(압축되지 않은) Image 파일은 (build 결과를 확인해 보니) 대략 26MB 쯤 되므로 압축해제된 파일의 대략적인 크기를 0x2000000 즉, 32MB로 하면 충분할 듯하다. 또한 압축이 해제되는 시작 번지도 0x85000000 정도로 설정해 두면 문제가 없을 것이다.
=> setenv kernel_comp_addr_r 0x85000000
=> setenv kernel_comp_size 0x2000000
=> saveenv
Saving Environment to EXT4... File System is consistent
file found, deleting
update journal finished
File System is consistent
update journal finished
done
OK
=> setenv kernel_comp_size 0x2000000
=> saveenv
Saving Environment to EXT4... File System is consistent
file found, deleting
update journal finished
File System is consistent
update journal finished
done
OK
=> booti 0x80000000 - 0x82000000
다시 부팅을 시도하니, 이번엔 정상 부팅된다. 😃
[그림 5.1] linux kernel booting 모습(1)
[그림 5.2] linux kernel booting 모습(2) - rootfs 관련 에러 발생
끝으로 bootcmd2 명령을 하나 만들어 두면 편하다.
=> setenv bootcmd2 'tftp 0x80000000 Image.gz; tftp 0x82000000 k3-am625-beagleplay.dtb; booti 0x80000000 - 0x82000000'
=> saveenv
=> run bootcmd2
3) RootFS 만들기(정확히는 NFS로 부팅하기)
rootfs를 일일이 만드는 방법을 소개할 수도 있겠으나, 그것 보다는 앞서 3장에서 yocto project를 통해 만들어 둔 rootfs를 이용해 NFS booting을 시도해 보자.
<Ubuntu desktop>
$ sudo apt-get install nfs-common nfs-kernel-server rpcbind
$ sudo vi /etc/exports...
/mnt/hdd/tftpboot/rootfs 192.168.8.200(rw,no_root_squash,no_subtree_check)
~
~
$ sudo systemctl enable nfs-server
$ sudo systemctl restart nfs-server
=> nfs server 설정을 한다. 참고로, 192.168.8.200은 target board의 ip이다.
$ sudo systemctl restart nfs-server
=> nfs server 설정을 한다. 참고로, 192.168.8.200은 target board의 ip이다.
$ tar xvJf core-image-minimal-beagleplay-20240719091250.rootfs.tar.xz -C /mnt/hdd/tftpboot/rootfs
=> 3장에서 미리 만들어둔 rootfs 파일을 tftp server로 복사한다.
<Target Board>
=> setenv bootargs ${bootargs} root=/dev/nfs ip=192.168.8.200:::::eth0 nfsroot=192.168.8.162:/mnt/hdd/tftpboot/rootfs,nfsvers=3,tcp rw
NFS client 설정을 한다.
=> saveenv
Saving Environment to EXT4... File System is consistent
file found, deleting
update journal finished
File System is consistent
update journal finished
done
OK
=> run bootcmd2
Saving Environment to EXT4... File System is consistent
file found, deleting
update journal finished
File System is consistent
update journal finished
done
OK
=> run bootcmd2
OK, 정상 부팅된다.
이상으로 linux kernel을 download -> build -> tftp booting하는 과정을 살펴 보았다. 다음 장에서는 BeaglePlay board의 device tree와 device driver에 관한 얘기를 하도록 하자.
6. Device Tree & Device Drivers
이번 장에서는 BeaglePlay를 위한 Device Tree와 Device Driver에 관한 얘기를 해 보고자 한다.
To be continued ...
7. References
[2] beagleplay.pdf, https://docs.beagleboard.org/
=> beagleplay & TI documents
[5] embedded-linux-beagleplay-labs.pdf, bootlin
[6] linux-kernel-beagleplay-labs.pdf, bootlin
[7] embedded-linux-slides.pdf, bootlin
=> bootlin documents, 요즘은 이분들이 대세다~
[12] And, Google~
Slowboot
댓글 없음:
댓글 쓰기