yocto project - SD Card 포팅하기(수동)

박남호·2022년 11월 2일
0

이번엔 메뉴얼 IMX_LINUX_USERS_GUIDE 4.3.3을 참조하여 sd card 파티션을 나누고 직접 부트로더, dtb, rootfs, 커널 이미지를 복사 해보겠다. 일단 파티션을 나누는 과정 부터 설명하겠다. df -h로 sd card가 sdx 어디에 할당 되었는지 확인한다.

sdb에 할당 되었다. 이제 파티션 포맷 및 할당 작업을 해보겠다.
$ sudo umonut /dev/sdx //먼저 언마운트를 해준다. 중요!
$ sudo fdisk /dev/sdx
p [lists the current partitions]
d [to delete existing partitions. Repeat this until no unnecessary partitions are reported by the 'p' command to start fresh.]
n [create a new partition]
p [create a primary partition - use for both partitions]
1 [the first partition]
20480 [starting at offset sector]
1024000 [ending position of the first partition to be used for the boot images]
p [to check the partitions]
n p 2
1228800 [starting at offset sector, which leaves enough space for the kernel, the bootloader and its configuration data]
<'enter'> [using the default value will create a partition that extends to the last sector of the media]
p [to check the partitions]
w [this writes the partition table to the media and fdisk exits]


이렇게 sd card 포맷과 파티션을 나누어 준다. sdb1과 sdb2로 파티션이 나누어진것을 확인할 수 있다. 이제 부트로더, 커널 이미지, rootfs, 디바이스 트리 파일들을 복사해 보겠다. 먼저 부트로더를 넣는 방법이다.
$ sudo dd if=<'U-Boot image'> of=/dev/sdx bs=1k seek=<'offset'> conv=fsync
이렇게 명령어를 입력하면 된다. offset은 i.mx 시리즈마다 차이가 있는데 i.mx7은 1이다.

부트로더 복사가 완료 되었다. 이제 커널 이미지와 디바이스 트리를 복사해 보겠다.

  1. Format partition 1 on the card as VFAT with this command:
    $ sudo mkfs.vfat /dev/sdx1
  2. Mount the formatted partition with this command:
    $ mkdir mountpoint
    $ sudo mount /dev/sdx1 mountpoint
  3. Copy the zImage and *.dtb files to the mountpoint by using cp. The device tree names should match the one used by the
    variable specified by U-Boot. Unmount the partition with this command:
    $ sudo umount mountpoint

mountpoint 폴더를 만들고 sdb1과 mountpoint 폴더를 마운트한다. 그리고 dtb,zimage 등 필요한 파일들을 복사하면 끝.


위 사진과 같이 복사를 해주면되고 총 3개 파일을 복사해서 넣었다. (uTee-7dsdb는 무슨 파일인지 스터디가 필요할것 같다. 없으면 커널 부팅이 안됨.)

이제 rootfs 파일을 sdb2에 복사를 해보겠다. 과정이 복잡한것 같지만 결국은 rootfs.tar를 sdb2에 복사하는 것이다.

$ sudo mkfs.ext3 /dev/sdx2
Or
$ sudo mkfs.ext4 /dev/sdx2
Copy the target file system to the partition:
$ mkdir /home/user/mountpoint
$ sudo mount /dev/sdx2 /home/user/mountpoint
Extract a rootfs package to a directory: for example, extract imx-image-multimedia-imx7ulpevk.tar.bz2 to /home/
user/rootfs:
$ cd /home/user/rootfs
$ tar -jxvf imx-image-multimedia-imx7ulpevk.tar.bz2
The rootfs directory needs to be created manually.
Assume that the root file system files are located in /home/user/rootfs as in the previous step:
$ cd /home/user/rootfs
$ sudo cp -a * /home/user/mountpoint
$ sudo umount /home/user/mountpoint
$ sync


정상적으로 복사가 끝났다. 이제 타겟보드에서 부팅을 해보겠다.

부팅은 아주 잘된다. ftp까지 잘 설치되어있다.

profile
NamoPark

0개의 댓글