This is an old revision of the document!
SAMA5Dx 에서는 전원이 공급되면 최초 실행되는 코드가 이미 ROM의 형태로 칩셋안에 내장되어 있다.
이 ROM 에 기록된 코드는 실행 코드가 들어 있을 저장 장치들을 차례로 찾아서 그 안에 특별한 형태를 가지고 있는 코드를 실행한다.
이 특별한 형태를 가진 코드를 Bootstrap이라 여기서는 표현을 하고 이 Bootstrap은 U-boot나 linux 커널을 실행 시키는 역할을 한다.
Bootstrap은 크기가 매우 제한적이므로 일반적으로는 저장 장치내에 있는 U-boot를 실행 시키고 U-boot에서 linux 커널을 실행 시키는 방식을 사용한다.
https://github.com/linux4sam/at91bootstrap/tree/master 에서 다운 받아 컴파일 한다.
at91bootstrap-master.zip 이란 파일이 다운 받아진다.
at92bootstrap-master.zip 파일이 다운된다.
나는 이를 buildroot 시에 사용했던 ~/SAMA5D4 에 복사한후 여기에서 압축해제 했다.
SAMA5D4/at91bootstrap-master/board 의 내용을 보면 여러 개발 보드가 나온다
우리는 sama5d4_xplained를 기본으로 시작하자.
SAMA5D4/at91bootstrap-master/board/sama5d4_xplained 의 내용을 보면 3개의 config 파일을 볼 수 있다.
sama5d4_xplaineddf_uboot_secure_defconfig → serial FLASH에서 부팅하는 설정
sama5d4_xplainednf_uboot_secure_defconfig → NAND FLASH에서 부팅하는 설정
sama5d4_xplainedsd_uboot_secure_defconfig → SD Card에서 부팅하는 설정
우리는 이중에 NAND FLASH에서 부팅하는 설정을 (sama5d4_xplainednf_uboot_secure_defconfig) 사용한다.
일단 초기화 한다.
cd SAMA5D4/at91bootstrap-master/ make mrproper
SAMA5D4x에 xplained 보드의 NAND FLASH에서 부팅으로 설정을 한다.
make sama5d4_xplainednf_uboot_secure_defconfig
menuconfig를 사용해 다시한번 설정을 확인하고 변경한다.
컴파일러를 어떤것을 쓸지 설정해야겠지.
make menuconfig
우선 기본설정인 xplaned board 와 우리 board 의 memory 크기가 틀리므로 이를 변경한다.
DDR-RAM의 크기가 다르므로 이를 변경한다.
32KHz Crystal 을 사용하므로 이것도 변경한다.
내부에 EEPROM도 없으므로 제거한다.
완료되면 bootstrap을 컴파일 한다.
우선 어떤 컴파일러를 사용할지 결정한다.
우리는 3가지의 컴파일러를 사용할 수 있다.
위의 세가지 컴파일러의 위치는 나의 경우(연결된 문서 참조) 아래와 같다.
> /home/stephanos/SAMA5D4/buildroot-2016.11.1/output/host/usr/bin/
> /home/stephanos/SAMA5D4/gcc-arm-none-eabi-6_2-2016q4/bin/
> /home/stephanos/SAMA5D4/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin/
at91bootstrap-master 폴더의 Makefile 의 상단에 아래의 내용을 추가하여 사용할 컴파일러를 선택한다.
CROSS_COMPILE=/home/stephanos/SAMA5D4/buildroot-2016.11.1/output/host/usr/bin/arm-none-eabi-
CROSS_COMPILE=/home/stephanos/SAMA5D4/gcc-arm-none-eabi-6_2-2016q4/bin/arm-none-eabi-
CROSS_COMPILE=/home/stephanos/SAMA5D4/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
나의 경우 linux cross compiler 사용하는 것으로 설정하였다.
완료되면 bootstrap을 컴파일 한다.
make
다음과 같은 내용이 출력되며 만들어진다.
stephanos@stephanos-VirtualBox:~/SAMA5D4/at91bootstrap-master$ make CC ======== /home/stephanos/SAMA5D4/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc 6.2.1 as FLAGS ======== -g -Os -Wall -I/home/stephanos/SAMA5D4/at91bootstrap-master/board/sama5d4_xplained -Iinclude -Icontrib/include -DJUMP_ADDR=0x26F00000 -DTOP_OF_MEMORY=0x210000 -DMACH_TYPE=9999 -Dsama5d4_xplained -DMACH_TYPE=9999 -DTOP_OF_MEMORY=0x210000 -DCRYSTAL_12_000MHZ -DSAMA5D4 -mcpu=cortex-a5 -mtune=cortex-a5 -DCONFIG_CPU_V7 -DCONFIG_SAMA5D4_XPLAINED gcc FLAGS ========= -nostdinc -isystem /home/stephanos/SAMA5D4/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/6.2.1/include -ffunction-sections -g -Os -Wall -mno-unaligned-access -fno-stack-protector -fno-common -I/home/stephanos/SAMA5D4/at91bootstrap-master/board/sama5d4_xplained -Icontrib/include -Iinclude -Ifs/include -I/home/stephanos/SAMA5D4/at91bootstrap-master/config/at91bootstrap-config -DAT91BOOTSTRAP_VERSION="3.8.7" -DCOMPILE_TIME="2017. 01. 03. (화) 17:06:49 KST" -DIMG_ADDRESS=0x00040000 -DIMG_SIZE=0x00080000 -DJUMP_ADDR=0x26F00000 -DOF_OFFSET= -DOF_ADDRESS= -DMEM_BANK= -DMEM_SIZE= -DIMAGE_NAME="u-boot.bin" -DCMDLINE="" -DTOP_OF_MEMORY=0x210000 -DMACH_TYPE=9999 -DCONFIG_DEBUG -DBANNER="AT91Bootstrap " AT91BOOTSTRAP_VERSION " (" COMPILE_TIME ")" -DCONFIG_HW_DISPLAY_BANNER -DCONFIG_HW_INIT -Dsama5d4_xplained -DMACH_TYPE=9999 -DTOP_OF_MEMORY=0x210000 -DCRYSTAL_12_000MHZ -DSAMA5D4 -mcpu=cortex-a5 -mtune=cortex-a5 -DCONFIG_SCLK -DCONFIG_SCLK_BYPASS -DCONFIG_CRYSTAL_12_000MHZ -DCONFIG_CPU_CLK_600MHZ -DCONFIG_BUS_SPEED_200MHZ -DCPU_HAS_PIO3 -DCONFIG_CPU_V7 -DCONFIG_MATRIX -DCONFIG_REDIRECT_ALL_INTS_AIC -DCPU_HAS_H32MXDIV -DCONFIG_SAMA5D4_XPLAINED -DCONFIG_DDRC -DCONFIG_DDR2 -DCONFIG_RAM_128MB -DCONFIG_NANDFLASH -DCONFIG_USE_PMECC -DCONFIG_ONFI_DETECT_SUPPORT -DCONFIG_USE_ON_DIE_ECC_SUPPORT -DBOOTSTRAP_DEBUG_LEVEL=DEBUG_INFO -DCONFIG_DISABLE_WATCHDOG -DCONFIG_TWI -DCONFIG_TWI0 -DCONFIG_TWI1 -DCONFIG_TWI2 -DCONFIG_TWI3 -DCONFIG_ACT8865 -DCONFIG_ACT8865_SET_VOLTAGE -DCONFIG_DISABLE_ACT8865_I2C -DCONFIG_PM -DCONFIG_MACB -DCONFIG_MAC0_PHY -DCONFIG_HDMI -DCONFIG_PM_PMIC -DCONFIG_AUTOCONFIG_TWI_BUS -DCPU_HAS_HSMCI0 ld FLAGS ======== -nostartfiles -Map=/home/stephanos/SAMA5D4/at91bootstrap-master/binaries/sama5d4_xplained-nandflashboot-uboot-3.8.7.map --cref -static -T elf32-littlearm.lds --gc-sections -Ttext 0x200000 AS /home/stephanos/SAMA5D4/at91bootstrap-master/crt0_gnu.S CC /home/stephanos/SAMA5D4/at91bootstrap-master/main.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/board/sama5d4_xplained/sama5d4_xplained.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/lib/string.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/lib/eabi_utils.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/lib/div.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/debug.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_slowclk.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/common.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_pio.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/pmc.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_pit.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_wdt.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_usart.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_rstc.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/lp310_l2cc.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/ddramc.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/nandflash.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/pmecc.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/matrix.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/pm.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_twi.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/act8865.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/macb.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/hdmi_SiI9022.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_aicredir.c mkdir -p /home/stephanos/SAMA5D4/at91bootstrap-master/binaries LD sama5d4_xplained-nandflashboot-uboot-3.8.7.elf Size of sama5d4_xplained-nandflashboot-uboot-3.8.7.bin is 17520 bytes [Succeeded] It's OK to fit into SRAM area [Attention] The space left for stack is 48016 bytes stephanos@stephanos-VirtualBox:~/SAMA5D4/at91bootstrap-master$
결과물은 /home/stephanos/SAMA5D4/at91bootstrap-master/binaries/ 내에 생성된다.
.bin파일이다.
.bin파일은 아트멜툴(SAM-BA) 로 NAND에 저장 할 수 있다.
.pmcc 파일은 일반 ROM-Writer로 NAND에저장 할 때 쓰인다.
두 파일을 비교하면 아래와 같은 차이점이 있다.
이는 SAMA5D42 Data-sheet, Reference Manual에 내용이 나와 있다.
우리는 sama5d4_xplained를 기본으로 시작했다.
이는 ATMEL에서 제공하는 개발보드의 설정이다.
이 보드는 VI에서 앞으로 개발할 보드의 설정과 다른점이 있다.
이에 VI 개발 보드에 맞추어 설정을 변경 하였다.
at91bootstrap-vi.zip 이란 파일로 만들었다.
이파일을 다운 받고 압축을 풀면 board에 새로운 폴더가 있음을 확인 할 수 있다.
SAMA5D4/at91bootstrap-vi/board/sama5d4_xplained 의 내용을 보면 3개의 config 파일을 볼 수 있다.
sama5d4_xplaineddf_uboot_secure_defconfig → serial FLASH에서 부팅하는 설정
sama5d4_xplainednf_uboot_secure_defconfig → NAND FLASH에서 부팅하는 설정
sama5d4_xplainedsd_uboot_secure_defconfig → SD Card에서 부팅하는 설정
우리는 이중에 NAND FLASH에서 부팅하는 설정을 (sama5d4_xplainednf_uboot_secure_defconfig) 사용한다.
일단 초기화 한다.
cd SAMA5D4/at91bootstrap-vi/ make mrproper
SAMA5D4x에 xplained 보드의 NAND FLASH에서 부팅으로 설정을 한다.
make sama5d4_xplainednf_uboot_secure_defconfig
중요 우리가 사용하는 NAND의 영향으로 CPU의 최대 스피드인 600MHz로 설정되면 NAND의 Access가 제대로 되지 않는다. 이에 우리는 CPU의 최대 스피드를 528MHz로 설정을 한다. 추후 이에 대한 수정이 있을 예정이다.
이에 따라 CPU의 최대 스피드 수정을 한다.
make menuconfig
완료되면 bootstrap을 컴파일 한다.
make
다음과 같은 내용이 출력되며 만들어진다.
CC ======== /home/stephanos/SAMA5D4/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc 6.2.1 as FLAGS ======== -g -Os -Wall -I/home/stephanos/SAMA5D4/at91bootstrap-master/board/sama5d4_vi_base -Iinclude -Icontrib/include -DJUMP_ADDR=0x26F00000 -DTOP_OF_MEMORY=0x210000 -DMACH_TYPE=9999 -Dsama5d4_vi_base -DMACH_TYPE=9999 -DTOP_OF_MEMORY=0x210000 -DCRYSTAL_12_000MHZ -DSAMA5D4 -mcpu=cortex-a5 -mtune=cortex-a5 -DCONFIG_CPU_V7 -DCONFIG_SAMA5D4_VI_BASE gcc FLAGS ========= -nostdinc -isystem /home/stephanos/SAMA5D4/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/6.2.1/include -ffunction-sections -g -Os -Wall -mno-unaligned-access -fno-stack-protector -fno-common -I/home/stephanos/SAMA5D4/at91bootstrap-master/board/sama5d4_vi_base -Icontrib/include -Iinclude -Ifs/include -I/home/stephanos/SAMA5D4/at91bootstrap-master/config/at91bootstrap-config -DAT91BOOTSTRAP_VERSION="3.8.7" -DCOMPILE_TIME="2017. 01. 11. (수) 11:48:50 KST" -DIMG_ADDRESS=0x00040000 -DIMG_SIZE=0x00080000 -DJUMP_ADDR=0x26F00000 -DOF_OFFSET= -DOF_ADDRESS= -DMEM_BANK= -DMEM_SIZE= -DIMAGE_NAME="u-boot.bin" -DCMDLINE="" -DTOP_OF_MEMORY=0x210000 -DMACH_TYPE=9999 -DCONFIG_DEBUG -DBANNER="AT91Bootstrap " AT91BOOTSTRAP_VERSION " (" COMPILE_TIME ")" -DCONFIG_HW_DISPLAY_BANNER -DCONFIG_HW_INIT -Dsama5d4_vi_base -DMACH_TYPE=9999 -DTOP_OF_MEMORY=0x210000 -DCRYSTAL_12_000MHZ -DSAMA5D4 -mcpu=cortex-a5 -mtune=cortex-a5 -DCONFIG_SCLK -DCONFIG_CRYSTAL_12_000MHZ -DCONFIG_CPU_CLK_600MHZ -DCONFIG_BUS_SPEED_200MHZ -DCPU_HAS_PIO3 -DCONFIG_CPU_V7 -DCONFIG_MATRIX -DCONFIG_REDIRECT_ALL_INTS_AIC -DCPU_HAS_H32MXDIV -DCONFIG_SAMA5D4_VI_BASE -DCONFIG_DDRC -DCONFIG_DDR2 -DCONFIG_RAM_128MB -DCONFIG_NANDFLASH -DCONFIG_USE_PMECC -DCONFIG_ONFI_DETECT_SUPPORT -DCONFIG_USE_ON_DIE_ECC_SUPPORT -DBOOTSTRAP_DEBUG_LEVEL=DEBUG_INFO -DCONFIG_DISABLE_WATCHDOG -DCONFIG_TWI -DCONFIG_TWI0 -DCONFIG_TWI1 -DCONFIG_TWI2 -DCONFIG_TWI3 -DCONFIG_ACT8865 -DCONFIG_ACT8865_SET_VOLTAGE -DCONFIG_DISABLE_ACT8865_I2C -DCONFIG_PM -DCONFIG_MACB -DCONFIG_MAC0_PHY -DCONFIG_HDMI -DCONFIG_PM_PMIC -DCONFIG_AUTOCONFIG_TWI_BUS -DCPU_HAS_HSMCI0 ld FLAGS ======== -nostartfiles -Map=/home/stephanos/SAMA5D4/at91bootstrap-master/binaries/sama5d4_vi_base-nandflashboot-uboot-3.8.7.map --cref -static -T elf32-littlearm.lds --gc-sections -Ttext 0x200000 AS /home/stephanos/SAMA5D4/at91bootstrap-master/crt0_gnu.S CC /home/stephanos/SAMA5D4/at91bootstrap-master/main.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/board/sama5d4_vi_base/sama5d4_vi_base.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/lib/string.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/lib/eabi_utils.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/lib/div.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/debug.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_slowclk.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/common.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_pio.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/pmc.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_pit.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_wdt.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_usart.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_rstc.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/lp310_l2cc.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/ddramc.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/nandflash.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/pmecc.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/matrix.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/pm.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_twi.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/act8865.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/macb.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/hdmi_SiI9022.c CC /home/stephanos/SAMA5D4/at91bootstrap-master/driver/at91_aicredir.c mkdir -p /home/stephanos/SAMA5D4/at91bootstrap-master/binaries LD sama5d4_vi_base-nandflashboot-uboot-3.8.7.elf Size of sama5d4_vi_base-nandflashboot-uboot-3.8.7.bin is 17540 bytes [Succeeded] It's OK to fit into SRAM area [Attention] The space left for stack is 47996 bytes
결과물은 /home/stephanos/SAMA5D4/at91bootstrap-vi/binaries/ 내에 생성된다.
.bin파일이다.
.bin파일은 아트멜툴(SAM-BA) 로 NAND에 저장 할 수 있다.
.pmcc 파일은 일반 ROM-Writer로 NAND에저장 할 때 쓰인다.