티스토리 뷰

xilinx에서 나온 zc706보드를 가지고 linux booting시 제일 먼저 다뤄야 할게 bootloader 설정이다.

왠만한게 wiki에 나와있다고는 하는데, 안나와있는 내용도 많아서 삽질을 좀 많이 했다. 아무튼 u-boot을 쓰는 사람에게는 

모두 적용되는 이야기가 될듯 해서 좀 남겨본다.

참고로 내가 하려고 했던 것은 zc706상의 flash memory에 Linux kernel과 device tree를 올리고 이를 통해서 부팅하려고 했던 것이다.

  • 필요 조건
    •  SD카드에 FAT 파티션을 만들고 해당 이미지들을 복사해서 넣어야 한다. (이유 u-boot에서 fatload를 사용해서 해당 이미지를 읽어오기 위해서는 해당 파티션이 FAT로 정의되어야 함)
      • boot.bin
      • u-boot.elf
      • uImage (zImage + u-boot header)
      • devicetree.dtb
      • uramdisk.image.gz
    • 이를 위해서 Linux machine에서 SD카드를 포맷한 후 사용자가 정의한 이미지들을 FAT 영역에 집어넣었다. (테스트시 prebuilt된 이미지를 사용했음(http://www.wiki.xilinx.com/Zynq+Releases))
    • 아마 Driver나 Application Test를 위해서는 uImage와 devicetree만 수정해서 다시 flashing하면 되지 않을까 생각됨

 

 - 우선 sd카드로 부팅시(스위치 설정 확인) u-boot모드로 진입한 후, 해당 명령을 수행한다.

zynq-uboot
# flash memory 인식후 초기화시킴
zynq-uboot> sf probe 0 0 0
zynq-uboot> sf erase 0 0x1000000
 
# fatload를 통해서 boot.bin를 읽어온 후 0x40000에 load함
zynq-uboot> fatload mmc 0 0x40000 boot.bin
reading boot.bin
552360 bytes read in 63 ms (8.4 MiB/s)
 
# 해당 memory 영역을 flash상에 write시킴 (boot.bin 크기 : 0x87000)
zynq-uboot> sf write 0x40000 0 0x87000
device 0 offset 0x0, size 0x87000
SF: 552960 bytes @ 0x0 Written: OK
# qspi boot mode 설정후 재부팅. 이때 정상적으로 써졌다면 u-boot으로 다시 진입함
# 이후 차례대로 uImage, devicetree.dtb, uramdisk.image.gz 을 flash에 write 해줌
 
# uImage flash (uImage 크기: 0x330000)
zynq-uboot> fatload mmc 0 0x40000 uImage
zynq-uboot> sf write 0x40000 0x100000 0x330000 (참고: 중간에 address는 반드시 0x100000으로 정의해야 됨)
device 0 offset 0x100000, size 0x330000
SF: 3342336 bytes @ 0x100000 Written: OK
 
# devicetree flash (devicetree 크기: 0x3500
zynq-uboot> fatload mmc 0 0x40000 devicetree.dtb
reading devicetree.dtb
13222 bytes read in 15 ms (860.4 KiB/s)
zynq-uboot> sf write 0x40000 0x600000 0x3500 (참고: 중간에 address는 반드시 0x600000으로 정의해야 됨)
device 0 offset 0x600000, size 0x3500
SF: 13568 bytes @ 0x600000 Written: OK
 
# ramdisk flash (uramdisk.image.gz 크기 : 0x510000)
zynq-uboot> fatload mmc 0 0x40000 uramdisk.image.gz
reading uramdisk.image.gz
5261701 bytes read in 495 ms (10.1 MiB/s)
zynq-uboot> sf write 0x40000 0x620000 0x510000 (참고: 중간에 address는 반드시 0x620000으로 정의해야 됨)
device 0 offset 0x620000, size 0x510000
SF: 5308416 bytes @ 0x620000 Written: OK 
 
zynq-uboot> printenv

printenv까지 수행하면 u-boot상에 정의된 주소 및 환경변수들이 출력되는데 이때 각 이미지들의 load address와 size를 변경해줘야 한다.

setenv
# 변수 설정
zynq-uboot> setenv kernel_load_address 0x3000000
zynq-uboot> setenv kernel_size 0x330000
zynq-uboot> setenv devicetree_load_address 0x2A00000
zynq-uboot> setenv devicetree_size 0x3500
zynq-uboot> setenv ramdisk_load_address 0x2000000
zynq-uboot> setenv ramdisk_size 0x510000
 
# flash로 저장
zynq-uboot> saveenv
Saving Environment to SPI Flash...
Erasing SPI flash...Writing to SPI flash...done

 

이렇게 하고 재부팅시 정상적으로 kernel booting이 수행됨

  • 정상일때의 log
u-boot log
U-Boot 2015.07 (Dec 08 2015 - 17:47:53 -0800)
Model: Zynq ZC706 Development Board
I2C:   ready
DRAM:  ECC disabled 1 GiB
MMC:   zynq_sdhci: 0
SF: Detected S25FL128S_64K with page size 512 Bytes, erase size 128 KiB, total 32 MiB
In:    serial
Out:   serial
Err:   serial
Model: Zynq ZC706 Development Board
Net:   Gem.e000b000
Hit any key to stop autoboot:  0
Copying Linux from QSPI flash to RAM...
SF: Detected S25FL128S_64K with page size 512 Bytes, erase size 128 KiB, total 32 MiB
device 0 offset 0x100000, size 0x330000
SF: 3342336 bytes @ 0x100000 Read: OK
device 0 offset 0x600000, size 0x3500
SF: 13568 bytes @ 0x600000 Read: OK
Copying ramdisk...
device 0 offset 0x620000, size 0x510000
SF: 5308416 bytes @ 0x620000 Read: OK
## Booting kernel from Legacy Image at 03000000 ...
   Image Name:   Linux-4.0.0-xilinx-dev
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3332624 Bytes = 3.2 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 02000000 ...
   Image Name:   core-image-minimal-zc706-zynq7-2
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    5261637 Bytes = 5 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 02a00000
   Booting using the fdt blob at 0x2a00000
   Loading Kernel Image ... OK
   Loading Ramdisk to 1fafb000, end 1ffff945 ... OK
   Loading Device Tree to 1faf4000, end 1fafa3a5 ... OK
Starting kernel ...
  • 정상이 아닐때의 log
fail log
U-Boot 2015.07 (Dec 08 2015 - 17:47:53 -0800)
Model: Zynq ZC706 Development Board
I2C:   ready
DRAM:  ECC disabled 1 GiB
MMC:   zynq_sdhci: 0
SF: Detected S25FL128S_64K with page size 512 Bytes, erase size 128 KiB, total 32 MiB
In:    serial
Out:   serial
Err:   serial
Model: Zynq ZC706 Development Board
Net:   Gem.e000b000
Hit any key to stop autoboot:  0
Copying Linux from QSPI flash to RAM...
SF: Detected S25FL128S_64K with page size 512 Bytes, erase size 128 KiB, total 32 MiB
device 0 offset 0x100000, size 0x330000
SF: 3342336 bytes @ 0x100000 Read: OK
device 0 offset 0x600000, size 0x3500
SF: 13568 bytes @ 0x600000 Read: OK
Copying ramdisk...
device 0 offset 0x620000, size 0x510000
SF: 5308416 bytes @ 0x620000 Read: OK
Wrong Image Format for bootm command
ERROR: can't get kernel image!

 

'Study > Linux' 카테고리의 다른 글

[Linux] Service  (0) 2016.04.24
[Linux] SysVinit runlevel  (0) 2016.04.22
[Linux] init process  (0) 2016.04.21
[Linux] GPIO를 사용하는 subsystem driver  (0) 2015.10.13
[Linux] GPIO Descriptor Driver Interface  (0) 2015.10.12
[Linux] GPIO Descriptor Consumer Interface  (0) 2015.10.12
[Linux] GPIO interface  (0) 2015.10.12
댓글