- 대부분의 사용자들은 PC라는 동일한 환경에서 프로그램을 작성 및 컴파일하고 동일한 환경에서 실행한다. 이 때 컴파일을 네이티브컴파일이라 하고
PC 환경에서 라즈베리용 모듈을 컴파일하여라즈베리 환경에서 실행. 즉 컴파일은 PC에서 하였고 실행은 라즈베리 파이 환경에서 하는데 이렇게 동작하는 환경과 시스템이 다를 때 이 컴파일을 크로스 컴파일이라고 함
1. 라즈베리 파이 커널 소스 다운로드
$ git clone --depth=1 https://github.com/raspberrypi/linux //depth의 경우 히스토리는 복제하지 않기 때문에 빠름
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
bcm2709_defconfig
-2번째 줄의 경우 라즈베리파이2는 kernel7이다. 라즈베리파이2의 boot partition에는 kernel도 있고 kernel7도 있으니 혼동 주의
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage
modules dtbs
-Note: To speed up compilation on
multiprocessor systems, and get some improvement on single processor ones,use -j
n where n is number of processors * 1.5. Alternatively, feel free to
experiment and see what works
4. SD card에 직접 설치
-리눅스머신에서$lsblk을 입력할 경우(SD card input) sdb1,2가 나오는 것을 확인할 수 있다.(NOOBS의 경우 최소 5개)이 때, 1은 FAT partion, 2는 ext4 partion이다.
-mount
$ mkdir mnt/fat32
$ mkdir mnt/ext4
$ sudo mount /dev/sdb1 mnt/fat32
$ sudo mount /dev/sdb2 mnt/ext4
-모듈설치
$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
INSTALL_MOD_PATH=mnt/ext4 modules_install
*arm-linux-gnueabihf는 앞 장의 컴파일러 path, INSTALL_MOD_PATH는 설치할 path 경로
- kernel image(mkknlimg스크립트로 변환 필요), dtb(device tree blob) 복사
- A standalone .img
file is a complete byte-for-byte image of an entire SD card. It includes the MBR (which stores
the partition table) as well as all the raw partitions.This is the lowest-level possible way
of writing an SD card, but it's the only way to access multiple partitions on an SD card using Windows (via the Win32DiskImager software).
-Raspbian이미지를 설치하면 2개의 파티션 boot(fat)와 file system(ext4)로 나뉘게 됨
-Boot(fat, sdb1) – boot partion으로 라즈베리파이펌웨어와컴파일드 된 리눅스커널과 몇 개의 config파일을 가짐
-File system(ext4,
sdb2)- root partition으로 application과 home directory등 리눅스에서 사용되는 파일들을 포함
-SD카드에 직접 이미지를 복사하게 때문에 큰 용량의 SD카드의 경우 지정된 용량의 공간을 할당하게 된다. 그렇기 때문에 앞서 설명했듯이, raspi-config에서 1. Expand_FileSystem으로최적화 시켜야 됨
§Standalone booting
-라즈베리파이는 bootstrap code를 사용하지 않음
1.Boot partition에 있는 bootcode.bin을 load
2.Run start.elf(and fixup.dat)
3.Config.txt 파일을 읽고 GPU configuration을 set up
4.Cmdline.txt(ext4 읽으라는 내용 포함 되어 있음)파일을 읽고 kernel.img 파일을 실행