Uboot Script 이며, Uboot 에서 사용하는 Command들을 나열하여 사용하는 일종의 Shell Script이라고 생각하면 되겠다.
boot.txt or boot.cmd 로 uboot command를 정의한 후 이를 mkimage를 이용하여 변형을 해주고, Uboot에서 이를 load에서 해서 이 Uboot Script를 사용하면 된다.
https://www.denx.de/wiki/DULG/UBootScripts
1.1 How to make boot.scr
mkimage -A arm -T script -C none -n "Boot.scr for odroid" -d ./boot.txt ./boot.scr
- boot.txt : string
- boot.scr : result
1.2 Uboot 환경변수 설정소스 파악
기본적으로 Uboot에서 설정되는 환경설정값들을 각각의 EVM or Board마다 다르므로, 본인의 소스 위치를 파악하여 알아보자.
Uboot 에서 BOOTCOMAND는 bootcmd 의 환경설정값 이며, boot.scr 안에서 Kernel를 Load하고 본인이 원하는 기능을 추가하여 넣자.
- Uboot 의 CONFIG_BOOTCOMMAND (bootcmd )
$ vi /include/configs/smdk4412.h //EXYNOS의 UBOOT bootcmd 설정 #if defined(CONFIG_HKDK4412) && defined(CONFIG_EXYNOS_PRIME) #define CONFIG_BOOTCOMMAND \ " mmc rescan 0:1; mmc rescan 0:2; " \ " if run loadbootscript_1; " \ " then run bootscript; " \ " else " \ " if run loadbootscript_2; " \ " then run bootscript; " \ " else " \ " run default_bootcmd; " \ " fi ;" \ " fi ; " ...
- Uboot 기본환경설정
$ vi ./include/env_default.h // UBOOT 환경설정 값 const unsigned char default_environment[] = { #endif #if defined(CONFIG_HKDK4412) && defined(CONFIG_EXYNOS_PRIME) "bootscript=source 40008000\0" "default_bootcmd=echo >>> Run Default Bootcmd <<<;movi read kernel 0 40008000;movi read rootfs 0 41000000 100000;bootm 40008000 41000000\0" "loadbootscript_1=echo >>> Load Boot Script from mmc 0:1 <<<;fatload mmc 0:1 40008000 boot.scr\0" "loadbootscript_2=echo >>> Load Boot Script from mmc 0:2 <<<;fatload mmc 0:2 40008000 boot.scr\0" "usb_invert_clken=0\0" #endif ... #ifdef CONFIG_BOOTCOMMAND "bootcmd=" CONFIG_BOOTCOMMAND "\0" #endif
- Serial에서 Uboot 환경설정확인
Exynos4412 # pri baudrate=115200 bootargs=fb_x_res=1280 fb_y_res=720 hdmi_phy_res=720 bootcmd= mmc rescan 0:1; mmc rescan 0:2; if run loadbootscript_1; then run bootscript; else if run loadbootscript_2; then run bootscript; else run default_bootcmd; fi ; fi ; bootdelay=5 bootscript=source 40008000 default_bootcmd=echo >>> Run Default Bootcmd <<<;movi read kernel 0 40008000;movi read rootfs 0 41000000 100000;bootm 40008000 41000000 ethact=usb_ether loadbootscript_1=echo >>> Load Boot Script from mmc 0:1 <<<;fatload mmc 0:1 40008000 boot.scr loadbootscript_2=echo >>> Load Boot Script from mmc 0:2 <<<;fatload mmc 0:2 40008000 boot.scr preboot=setenv stdin serial,nc stderr=serial stdin=serial stdout=serial usb_invert_clken=0 usbethaddr=DE:AD:BE:EF:00:03
관련참고
http://elinux.org/ECE597_boot.scr ( OMAP 기준 설명)
http://forum.odroid.com/viewtopic.php?f=52&t=1104
https://wiki.linaro.org/Resources/HowTo/boot.scr
2. Android Image
ODROID에서 제공하는 Android Image들은 크게 아래와 같이 3 종류인 것 같으며, 각 설정에 변경이 되는 것 같다.
Download Site
http://dn.odroid.com/4412/Android/
2.1 ODROID-X2의 Android Image 종류
- emmc_self_installer.zip : Image를 emmc에 굽고, emmc에 모든것이 설치됨.
- sd2emmc_installer.zip : Image를 SD카드에 굽고, emmc에 모든것이 설치됨.
- sd_self_installer.zip : Image를 SD카드에 굽고 SD카드에 모든것이 설치됨.
#setenv device "0" #setenv ToSDMMC "0"
2.2 ODROID-X2의 Android Image 구조
- Download Image
- sd_self_installer.img의 구성
- 0~100M: BL1,BL2, UBOOT 있을 거라고 생각
- FAT: FAT Partion만 존재.
$ fdisk -l /media/sf_SHARED/images/sd_self_installer.img Disk /media/sf_SHARED/images/sd_self_installer.img: 524 MB, 524288000 bytes 189 heads, 61 sectors/track, 88 cylinders, total 1024000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00008403 Device Boot Start End Blocks Id System /media/sf_SHARED/images/sd_self_installer.img1 204800 1023999 409600 b W95 FAT32 // 204800 x 512 = 104857600 100M 부터설정, // Blocks: 1k단위로 되는 것 같고, Start,End 512 byte 단위로 되는 것 같다
- /media/sf_SHARED/images/sd_self_installer.img1
// offset 104857600= 204800 x 512 bytes $ sudo mount -o loop,offset=104857600 /media/sf_SHARED/images/sd_self_installer.img ./tmp1 or $ sudo mount -o loop,offset=$((512 * 204800)) /media/sf_SHARED/images/sd_self_installer.img ./tmp1 $ ls ./tmp1 bl1.bin cache_aa system_ac system_af system_ai system_al system_ao system_ar tzsw.bin userdata_ab bl2.bin system_aa system_ad system_ag system_aj system_am system_ap system_as u-boot.bin userdata_ac boot.scr system_ab system_ae system_ah system_ak system_an system_aq system_at userdata_aa zImage
한번 install이 되면, 그 이후에 아래의 구조가 존재하지 않는다.
Fastboot에 의해 Android 를 SD Write를 한다.
//앞부분, Image 정보부분이라서 깨짐 # BootScript for Odroid (2013/01/28) # # # Boot.scr make script # # mkimage -A arm -T script -C none -n "Boot.scr for odroid" -d ./boot.ini ./boot.scr # # EMMC Self Update #setenv device "0" #setenv ToSDMMC "0" # SD/MMC Self Update setenv device "0" setenv ToSDMMC "1" # EMMC Update from SD/EMMC #setenv device "1" #setenv ToSDMMC "0" # SD/MMC Update from EMMC #setenv device "1" #setenv ToSDMMC "1" setenv check_oldboot "check_value 1" setenv check_device_sd "check_value ${ToSDMMC}"; setenv check_device "check_value ${device}"; setenv mmc64gb_check "check_64gb ${device}" if run check_oldboot;then echo >> new-bootloader <<; else echo >> old-bootloader <<; reset; fi; #------------------------------------------------------------------------------------------------------ # UBOOT ENV Erase #------------------------------------------------------------------------------------------------------ mmc write 0 40008000 0x4CF 0x20 fatload mmc 0:1 41000000 zImage;movi w k ${device} 41000000; fatload mmc 0:1 44000000 system_aa; fatload mmc 0:1 45000000 system_ab; fatload mmc 0:1 46000000 system_ac; fatload mmc 0:1 47000000 system_ad; fatload mmc 0:1 48000000 system_ae; fatload mmc 0:1 49000000 system_af; fatload mmc 0:1 4A000000 system_ag; fatload mmc 0:1 4B000000 system_ah; fatload mmc 0:1 4C000000 system_ai; fatload mmc 0:1 4D000000 system_aj; fatload mmc 0:1 4E000000 system_ak; fatload mmc 0:1 4F000000 system_al; fatload mmc 0:1 50000000 system_am; fatload mmc 0:1 51000000 system_an; fatload mmc 0:1 52000000 system_ao; fatload mmc 0:1 53000000 system_ap; fatload mmc 0:1 54000000 system_aq; fatload mmc 0:1 55000000 system_ar; fatload mmc 0:1 56000000 system_as; fatload mmc 0:1 57000000 system_at; fatload mmc 0:1 58000000 userdata_aa; fatload mmc 0:1 59000000 userdata_ab; fatload mmc 0:1 5A000000 userdata_ac; fatload mmc 0:1 41000000 cache_aa; fdisk -c ${device} fastboot flash system 44000000 0 ${device}; fastboot flash userdata 58000000 0 ${device}; fastboot flash cache 41000000 0 ${device}; fatformat mmc ${device}:1; if run check_device; then fastboot poweroff; else reset; fi;
3. Ubuntu Image
https://wiki.odroid.com/old_product/odroid-x_u_q/odroid_u3/u3_partition_table
- Download Site
http://odroid.in/ubuntu_14.04lts/old_images/
http://odroid.in/ubuntu_14.04lts/
- Download Image
3.1 Ubuntu Image 구조
- Download Image
- Image Partition 구성
- 0~2048K: BL1,BL2,UBOOT 있을 거라고 예상
- FAT32: FAT가 2048K부터 구성,(약 2Mbyte)
- Linux : Linux 기본 Partion
- Partition으로 구성확인방법
fdisk -l xxxx.img //512 Byte 기준표시
parted -s xxxx.img unit B print // Byte 기준표시
$ fdisk -l odroidx2_20130125-linaro-ubuntu-desktop_SDeMMC_with_HDMI.img Disk odroidx2_20130125-linaro-ubuntu-desktop_SDeMMC_with_HDMI.img: 5904 MB, 5904530944 bytes 255 heads, 63 sectors/track, 717 cylinders, total 11532287 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000c4046 Device Boot Start End Blocks Id System odroidx2_20130125-linaro-ubuntu-desktop_SDeMMC_with_HDMI.img1 4096 266239 131072 b W95 FAT32 odroidx2_20130125-linaro-ubuntu-desktop_SDeMMC_with_HDMI.img2 266240 11532287 5633024 83 Linux
parted -s xxxxx unit B print 사용가능 (Byte 기준표시)
$ sudo parted -s /media/sf_SHARED/odroidx2_20130125-linaro-ubuntu-desktop_SDeMMC_with_HDMI.img unit B print
http://odroid.us/mediawiki/index.php?title=Updating_from_Root_File_System_Images
B. FAT32 Partition 정보확인
Booting에 필요한 주요파일로 구성되어 있으며, 간단히 구성을 보면 다음과 같다.
- board.dtb // Device Tree Binary
- boot.scr // Uboot Script
- boot.ini // Uboot Env 설정 File
- zImage,uImage // Kernel Image
- uInitrd // RAM Disk Image
$ mkdir tmp1 tmp2 // offset 2097152 = 4096 x 512 bytes $ sudo mount -o loop,offset=2097152 /media/sf_SHARED/odroidx2_20130125-linaro-ubuntu-desktop_SDeMMC_with_HDMI.img ./tmp1 or $ sudo mount -o loop,offset=$((512*4096)) /media/sf_SHARED/odroidx2_20130125-linaro-ubuntu-desktop_SDeMMC_with_HDMI.img ./tmp1 $ ls ./tmp1 board.dtb boot boot-hdmi1080.scr boot-hdmi1080.txt boot-hdmi720.scr boot-hdmi720.txt boot.ini boot.scr boot.txt uImage uInitrd zImage
C. Linux Partition 정보확인
Mount 되는 Linux Fliesystem 정보로 Host Linux에서 확인을 해보자.
// offset 136314880 = 266240 x 512 bytes $ sudo mount -o loop,offset=136314880 /media/sf_SHARED/odroidx2_20130125-linaro-ubuntu-desktop_SDeMMC_with_HDMI.img ./tmp2 or $ sudo mount -o loop,offset=$((512*266240)) /media/sf_SHARED/odroidx2_20130125-linaro-ubuntu-desktop_SDeMMC_with_HDMI.img ./tmp2 $ ls ./tmp2 bin boot dev etc home initrd.img lib lost+found media mnt opt proc root run sbin selinux srv sys tmp usr var vmlinuz
4. Uboot script
4.1 boot.scr (ubuntu)
ubuntu boot.scr 설치가 아닌 boot 이며,아래와 같이 기본 설정을 해준다.
setenv initrd_high "0xffffffff" setenv fdt_high "0xffffffff" setenv fb_x_res "1280" setenv fb_y_res "720" setenv hdmi_phy_res "720" setenv bootcmd "fatload mmc 0:1 0x40008000 zImage; fatload mmc 0:1 0x42000000 uInitrd; bootm 0x40008000 0x42000000" setenv bootargs "console=tty1 console=ttySAC1,115200n8 fb_x_res=${fb_x_res} fb_y_res=${fb_y_res} hdmi_phy_res=${hdmi_phy_res} root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro mem=2047M" boot
4.2 boot.scr (dnw 적용)
setenv initrd_high "0xffffffff" setenv fdt_high "0xffffffff" setenv bootcmd "dnw 0xc0008000; fatload mmc 0:1 0x42000000 uInitrd; bootm 0xc0008000 0x42000000" setenv bootargs "console=tty1 console=ttySAC1,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro mem=1023M" boot
4.3 boot.scr (printenv)
baudrate=115200 bootargs=fb_x_res=1280 fb_y_res=720 hdmi_phy_res=720 bootcmd= mmc rescan 0:1; mmc rescan 0:2; if run loadbootscript_1; then run bootscript; else if run loadbootscript_2; then run bootscript; else run default_bootcmd; fi ; fi ; bootdelay=1 bootscript=source 40008000 default_bootcmd=echo >>> Run Default Bootcmd <<<;movi read kernel 0 40008000;movi read rootfs 0 41000000 100000;bootm 40008000 41000000 ethaddr=00:40:5c:26:0a:5b gatewayip=192.168.0.1 ipaddr=192.168.0.20 loadbootscript_1=echo >>> Load Boot Script from mmc 0:1 <<<;fatload mmc 0:1 40008000 boot.scr loadbootscript_2=echo >>> Load Boot Script from mmc 0:2 <<<;fatload mmc 0:2 40008000 boot.scr netmask=255.255.255.0 serverip=192.168.0.10
5. mkimage 의 Image header 제거
mkimage를 사용할 경우 헤더가 64byte 가 사용이 되며, 이는 boot시 사용이 된다. 그리고, 이와 같은 이미지가 필요 없을 경우 아래와 같이 제거 한다.
mkimage를 사용하는 것은 ramdisk, kernel image, boot.scr이 있다.
dd if=image of=recovered file bs=64 skip=1
RAMDISK의 경우 아래와 같이 mkimage를 제거하고, 압축을 풀고 카피한 다음 분석가능
gunzip initrd.gz mkdir init cd init cpio -i < ../initrd
https://wiki.linaro.org/MichaelHope/Sandbox/DebuggingOnInitrd
댓글 없음 :
댓글 쓰기