5.1. ARM에서 설치 프로그램 부팅하기

5.1.1. 부팅 이미지 형식

ARM 시스템에서는 대부분의 경우 1가지나 2가지의 부팅 이미지 형식을 사용합니다. (1) 표준 리눅스 zImage 형식의 커널 (vmlinuz) 및 표준 리눅스 초기 램디스크(initrd.gz), (2) uImage 형식의 커널 (uImage) 및 거기 해당하는 최초 램디스크(uInitrd).

uImage/uInitrd는 u-boot 펌웨어에서 사용하려고 만들어진 이미지 형식입니다. u-boot는 여러 ARM 시스템에서 사용합니다. 예전 버전의 u-boot에서는 uImage/uInitrd 형식의 파일만 부팅할 수 있습니다. 즉 이 형식은 예전의 armel 시스템에서 주로 사용합니다. 최근 버전의 u-boot에서는 uImage/uInitrd 부팅 말고 표준 리눅스 커널과 램디스크 이미지로 부팅할 수 있습니다. 하지만 uImage 부팅과는 명령어 문법이 약간 다릅니다.

플랫폼 커널을 사용하는 시스템에서는, 커널과 최초 램디스크 외에 디바이스-트리 파일(device-tree blob, DTB라고도 합니다)이 필요합니다. 이 파일은 지원하는 시스템마다 다르고, 특정 하드웨어에 대한 설정이 들어 있습니다.

5.1.2. TFTP로 부팅하기

네트워크에서 부팅하려면, 네트워크에 연결되어 있어야 하고 TFTP 네트워크 부팅 서버가(그리고 네트워크 자동 설정에 필요한 DHCP, RARP 혹은 BOOTP 서버가) 필요합니다.

서버 쪽에서 네트워크 부팅을 설정하는 방법은 4.3절. “TFTP 네트워크 부팅에 필요한 파일 준비하기”에 설명되어 있습니다.

5.1.2.1. u-boot에서 TFTP 부팅

u-boot 펌웨어를 사용하는 시스템에서 네트워크 부팅은 3가지 단계로 이루어져 있습니다: (1) 네트워크 설정, (2) 이미지(커널/최초 램디스크/DTB) 메모리에 읽어들이기, (3) 읽어들인 코드 실행.

먼저 네트워크를 설정해야 합니다. 다음을 실행해 DHCP로 자동 설정할 수 있습니다:

setenv autoload no
dhcp

아니면 수동으로 환경 변수를 설정할 수 있습니다:

setenv ipaddr <클라이언트의 IP 주소>
setenv netmask <네트마스크>
setenv serverip <TFTP 서버의 IP 주소>
setenv dnsip <네임서버의 IP 주소>
setenv gatewayip <기본 게이트웨이의 IP 주소>

위 설정을 저장하고 싶으면 다음과 같이 합니다:

saveenv

그 다음에 이미지(커널/최초 램디스크/DTB)를 메모리에 읽어들여야 합니다. TFTP 명령에 메모리를 읽어들일 위치의 주소를 써야 합니다. 하지만 메모리 배치가 시스템마다 다르기 때문에 어떤 주소를 사용해야 하는지는 일반적인 규칙은 없습니다.

일부 시스템에서는, u-boot에 적합한 로딩 주소가 환경 변수로 미리 정의되어 있습니다: kernel_addr_r, ramdisk_addr_r 및 fdt_addr_r. 이 환경 변수가 정의되어 있는지 여부를 다음 명령으로 확인해 볼 수 있습니다

printenv kernel_addr_r ramdisk_addr_r fdt_addr_r

이 값이 정의되어 있지 않으면, 시스템의 문서에서 적절한 값을 확인해 보고 직접 값으 지정해야 합니다. 예를 들어 Allwinner SunXi SOC 기반 시스템(예: Allwinner A10, 아키텍쳐 이름 sun4i 또는 Allwinner A20, 아키텍쳐 이름 sun7i)의 경우, 다음 값을 사용합니다.

setenv kernel_addr_r 0x46000000
setenv fdt_addr_r 0x47000000
setenv ramdisk_addr_r 0x48000000

로딩 주소를 지정하면, 다음과 같이 앞에서 지정한 TFTP 서버에서 이미지를 메모리에 읽어들일 수 있습니다:

tftpboot ${kernel_addr_r} <커널 이미지 파일 이름>
tftpboot ${fdt_addr_r} <DTB 파일 이름>
tftpboot ${ramdisk_addr_r} <최초 램디스크 이미지 파일 이름>

3번째는 커널 커맨드라인을 설정하고 읽어들인 코드를 실행하는 부분입니다. u-boot는 bootargs 환경 변수의 내용을 커널의 커맨드라인으로 넘깁니다. 그러므로 커널 및 설치 프로그램의 파라미터는(콘솔 장치(5.3.1절. “부팅 콘솔” 참고) 또는 미리 설정 옵션(5.3.2절. “데비안 설치프로그램 파라미터”부록 B. 미리 설정을 이용한 설치 자동화 참고)) 다음과 같은 명령으로 설정할 수 있습니다:

setenv bootargs console=ttyS0,115200 rootwait panic=10

읽어들인 코드를 실행하는 정확한 명령은 이미지 형식에 따라 다릅니다. uImage/uInitrd의 경우 명령어는 다음과 같고,

bootm ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}

네이티브 리눅스 이미지의 경우 다음과 같습니다:

bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}

표준 리눅스 이미지로 부팅할 때, 커널과 DTB를 읽어들이고 다음에 최초 램디스크 이미지를 읽어들이는 게 중요합니다. u-boot에서는 파일 크기 변수를 마지막에 읽어들인 파일의 크기로 설정하고, bootz 명령이 제대로 동작하려면 램디스크 이미지의 크기가 필요하기 떄문입니다. 플랫폼 전용 커널로 부팅하는 경우(예를 들어 디바이스 트리 없는 커널)에는 ${fdt_addr_r} 파라미터를 생략하면 됩니다.

5.1.3. Booting from a USB stick in u-boot

Many modern u-boot versions have USB support and allow booting from USB mass storage devices such as USB sticks. Unfortunately the exact steps required to do that can vary quite a bit from device to device.

U-Boot v2014.10 has introduced a common commandline handling and autoboot framework. This allows building generic boot images that work on any system implementing this framework. The debian-installer supports installation from a USB stick on such systems, but unfortunately not all platforms have adopted this new framework yet.

To build a bootable USB stick for installing 데비안, unpack the hd-media tarball (see 4.2.1절. “설치 이미지를 찾을 위치”) onto a USB stick formatted with a filesystem supported by the u-boot version on your device. For modern u-boot versions, any of FAT16 / FAT32 / ext2 / ext3 / ext4 usually works. Then copy the ISO image file of the first 데비안 installation CD or DVD onto the stick.

The autoboot framework in modern u-boot versions works similar to the boot ordering options in a PC BIOS, i.e. it checks a list of possible boot devices for a valid boot image and starts the first one it finds. If there is no operating system installed, plugging in the USB stick and powering up the system should result in starting the installer. You can also initiate the USB-boot process any time from the u-boot prompt by entering the run usb_boot command.

One problem that can come up when booting from a USB stick while using a serial console can be a console baudrate mismatch. If a console variable is defined in u-boot, the debian-installer boot script automatically passes it to the kernel to set the primary console device and, if applicable, the console baudrate. Unfortunately the handling of the console variable varies from platform to platform - on some platforms, the console variable includes the baudrate (as in console=ttyS0,115200), while on other platforms the console variable contains only the device (as in console=ttyS0). The latter case leads to a garbled console output when the default baudrate differs between u-boot and the kernel. Modern u-boot versions often use 115200 baud while the kernel still defaults to the traditional 9600 baud. If this happens, you should manually set the console variable to contain the correct baudrate for your system and then start the installer with the run usb_boot command.