Presentation is loading. Please wait.

Presentation is loading. Please wait.

Bootloader Porting Lecture #6.

Similar presentations


Presentation on theme: "Bootloader Porting Lecture #6."— Presentation transcript:

1 Bootloader Porting Lecture #6

2 목 차 부트로더 개요 u-boot 디렉토리와 소스 구조 u-boot 동작 이해 u-boot 빌드 부트로더 fusing하기

3 부트로더 개요 (1) 정의 부트로더의 메모리 위치
시스템의 하드웨어를 초기화하고 운영체제의 커널을 메모리에 실행시키는 시스템 프로그램 부트로더의 메모리 위치 일반적으로 시스템 메모리의 물리 주소 ‘0’번지에 위치 0x0000_0000 : Reset exception 부트로더의 주요 기능 : Startup, Monitoring mode, OS Boot 하드웨어 초기화 Clock 설정, memory(SDRAM) 설정, 인터럽트 disable 시리얼포트 초기화 네트워크 초기화 커널과 root filesystem 적재 커널과 root file system을 메모리에 적재하여 Linux 실행

4 부트로더 개요 (2) u-boot 개요 Universal Bootloader ppcboot + armboot
PPC와 ARM에 기반을 둔 임베디드용 Bootloader 다양한 cpu 지원 (PPC, ARM, MIPS, SH, x86…) Open Source

5 u-boot 디렉토리와 소스 구조 (1) 디렉토리 설명 board 상용 evaluation 보드와 관련된 파일
board/pro3 pro3보드와 관련된 파일 common architecture 독립적인 파일 cpu architecture에 의존적인 파일 각각의 cpu에 대한 startup 코드, serial, clock 등 cpu specific한 코드들이 존재 cpu/pxa pro3에서 사용하는 XScale코어 관련 파일 disk 디스크 드라이브와 파티션 관련 파일 doc u-boot 관련된 문서 drivers 외부장치의 드라이버 파일 examples u-boot를 위한 test 실행 파일 include header file include/config 보드 설정을 위한 header file net Network 관련 파일 post Power On Self Test rtc Real Time Clock driver 파일 tools U-boot 이미지나 S-Record 이미지를 생성하기 위한 tool (mkimage)

6 u-boot 디렉토리와 소스 구조 (2) 디렉토리 설명 include asm/arch-pxa/ pxa2xx를 위한 헤더파일
configs pro3.h 보드에 의존적인 메모리 정보, 사용될 하드웨어 및 소프트웨어 설정, 기본 환경 변수 지정 cpu pxa start.S u-boot에서 제일 처음 시작하는 부분으로 exception table을 가진다. interrupt.c 프로세서의 인터럽트관련 소스 파일 serial.c 시리얼 장치(uart)의 디바이스 드라이버를 구현한 소스 파일 cpu.c 캐시 관리, 소프트웨어 리셋 등 cpu를 관리 board pro3 config.mk u-boot의 코드가 동작할 텍스트 섹션 베이스 주소지정 u-boot.lds u-boot의 이미지 배치를 위한 링커 스크립트 pro3.c pro3 보드 설정 flash.c 플래시 디바이스 관리 drivers smc91111.c smc91111.h smc91111 Ethernet driver

7 u-boot의 동작 이해 (1) 부트로더의 실행 순서

8 u-boot 동작 이해 (2) start.S

9 u-boot 동작 이해 (3) Memory 배치 0x0200_0000 u-boot 0xA7F8_0000 root f/s
uImage 0x0008_0000 Bootloader parameters 0x0004_0000 u-boot 0x0000_0000 FLASH 0xA000_0000 Memory

10 u-boot 동작 이해 (4) u-boot 전체 흐름 [ASM] startup코드 (cpu/pxa/start.S)
cpu 초기화, sdram초기화, sdram으로 relocation, start_armboot()호출 [C]코드 start_armboot() (lib_arm/board.c) flash_init, eth_init console 초기화 main_loop() (common/main.c) 명령어 처리 루틴 autoboot Linux booting (lib_arm/armlinux.c) Linux booting (커널의 헤더를 읽어서 압축 풀고 리눅스로 제어권을 넘김)

11 Linux를 위한 boot 조건 (1) Linux booting에 필요한 두가지 이미지
Linux Kernel image FLASH/ROM에서 동작하기 위해 Kernel을 구성 Root File System(RFS) image Jffs2 image, RAMdisk 대부분의 boot-loaders는 다음의 두 가지 부팅모드를 지원 Bootloading – Local Booting 독립적으로 Kernel과 RFS를 내부 device(Flash)로부터 load한다(autoboot). Downloading – Remote Booting Kernel과 RFS를 외부 device(Host PC)로부터 download 처음에는 Kernel과 RFS를 install하기 위해 이 모드를 사용 또한 차후에 updates를 위해 사용

12 Linux를 위한 boot 조건 (2) Linux kernel의 제어권을 넘기기 전에 bootloader에서 해야 될 일 (1) Initialize base hardware CPU speed memory timings Detect machine type (passed to Kernel by r1) Initialize device Init UART to be Kernel console (passed to Kernel by tagged list, kernel boot option) Copy Kernel and RFS image to RAM Kernel을 위한 연속된 physical memory의 블록을 준비한다. 또한 RFS을 위한 memory도 준비한다 (인접할 필요는 없다). Copy (또는 download) 한 후에 Kernel과 RFS를 각각의 연속된 공간에 압축을 푼다. Setup the Kernel Tagged List (보드 정보) ppc : structure arm: physical ram 시작번지 + 0x100 (0xA000_0100)

13 Linux를 위한 boot 조건 (3) Linux kernel의 제어권을 넘기기 전에 bootloader에서 해야 될 일 (2) Calling the Linux Kernel with following settings CPU register settings R0 = 0, R1 = machine architecture number (the MACH_TYPE_XXX in kernel) (linux/include/asm/mach-types.h) Linux/arch/arm/tools/mach-types의 것과 일치해야 한다. R2 = base address of ATAG list (system RAM안에 있는 tagged list의 physical address) CPU mode All forms of interrupts must be disabled (IRQs, FIQs) CPU must be in SVC mode Cache, MMU MMU mustbe off D-cache must be off and no any stale data (I-Cache can be on/off)

14 Linux를 위한 boot 조건 (4) R0, R1, R2 레지스터를 설정하고 커널로 진입하는 부분
void do_bootm_linux(…) { void (*theKernel)(int zero, int arch, uint params); .. theKernel = (void (*)(int, int, uint))ntohl(hdr->ih_ep); theKernel (0, bd->bi_arch_number, bd->bi_boot_params); } u-boot/board/pro3/pro3.c gd->bd->bi_arch_number = 8894; linux/arch/arm/tools/mach-types pro3 ARCH_PRO3 PRO3 8894 gd->bd->bi_boot_params = 0xa ; // address of boot parameters u-boot/lib-arm/armlinux.c

15 u-boot 빌드 부트로더 이미지 생성 과정 부트로더 이미지 생성 # cd /root/pro3/Bootloader # ls
# tar xfz ./u-boot pro3-YYYYMMDD.tar.gz 부트로더 이미지 생성 cd ./u-boot pro3 make pro3_config make ls ./u-boot.bin cp ./u-boot.bin /tftpboot

16 부트로더 fusing하기 부트로더에서 Host PC와 Targetboard IP를 설정한 후에 tftp를 통해 이미지를 다운로드 할 수 있다. // Host PC와 Targetboard의 IP를 설정하기 PRO3> set serverip  [ host pc ip ] PRO3> set ipaddr  [ targetboard ip ] // u-boot image 파일 설정 및 fusing PRO3> set boot_file ./pxa255_pro3/u-boot.bin PRO3> run bootf

17 u-boot 명령어 cmp : 메모리 비교 cp : 메모리 복사 erase : flash 메모리 삭제
flinfo : flash 메모리 정보 출력 go : ‘addr’ 주소에서 시작 help : 도움말 출력 md : 메모리 출력 mm : 메모리 수정 mtest : 단순 RAM 테스트 mw : 메모리 쓰기 printenv : 환경 변수 출력 run :환경 변수를 실행하는 명령어 saveenv : 저장장치에 환경 변수 저장 setenv : 환경 변수 지정


Download ppt "Bootloader Porting Lecture #6."

Similar presentations


Ads by Google