[Intel AI SW 아카데미] U-Boot Bootloader

Jimeaning·2024년 2월 7일
0

Intel AIoT

목록 보기
31/38

24.02.07 (수)

U-Boot Bootloader 빌드

Bootloader란?

부트로더(boot loader)란 운영 체제가 시동되기 이전에 미리 실행되면서
커널이 올바르게 시동되기 위해 필요한 모든 관련 작업을 마무리하고.
최종적으로 운영 체제를 시동시키기 위한 목적을 가진 프로그램을 말한다.

임베디드 보드에 전원이 인가되었을 때, 메모리, 하드웨어(네트워크, 프로세서 속도, 인터럽트), 코드/데이터/스택 영역의 설정 및 초기화를 진행하며 커널을 메모리에 적재하여 커널을 실행시키는 역할을 한다.

설치 과정

  • 디렉토리 생성 및 이동
$ mkdir pi_bsp ; cd pi_bsp
$ mkdir pi_bsp && cd pi_bsp

둘 다 가능 !
;이나 &&을 하면 좋은 점 : 오래 걸리는 작업의 경우 써놓고 다른 작업을 하면서 기다릴 수 있음

  • 필수 패키지 설치
$ sudo apt-get install gawk git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python-setuptools python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev xterm rsync curl zstd lz4 bison flex
$ sudo apt install crossbuild-essential-armhf 	//arm 32bit 툴체인 설치
  • 설치되었는지 확인
    arm 치고 tab키 누르면 arm에 관련한 명령어를 확인할 수 있다

cd - : 조금 전에 있었던 디렉토리로 이동할 수 있다
wc : word count
wc -l : 라인 수
more : 한 페이지별로 보여주겠다

  • u-boot 다운로드
$ git clone git://git.denx.de/u-boot.git
$ cd u-boot
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- rpi_4_32b_defconfig

최초에 한 번만 실행 ! 수정한 config가 날아가게 됨


$ sudo apt install libncurses-dev
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

$ vi .config
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all

오류가 나면 ..

$ sudo apt update
$ sudo apt install -y libssl-dev


u-boot.bin이 만들어지면 된다

  • u-boot.bin sd카드 복사
    라즈베리파이 SD카드 ubuntu 연결 후 df 명령어로 확인

연결하지 않고 하는 방법

~/pi_bsp/u-boot$ cd /srv/nfs/
pi@pi09:~$ cd /mnt/ubuntu_nfs/
$ sudo cp u-boot.bin /boot/.
$ ls -l config.txt
$ cd firmware
$ sudo vi config.txt
kernel=u-boot.bin
$ sudo mv ../u-boot.bin .
  • u-boot 부팅
$ sudo reboot

U-Boot> setenv bootargs 8250.nr_uarts=1 console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait rw
U-Boot> setenv bootcmd 'run user_mmc_boot'

U-Boot> setenv user_mmc_boot 'mmc dev 0; fatload mmc 0:1 ${kernel_addr_r} kernel7l.img; fatload mmc 0:1 ${fdt_addr_r} bcm2711-rpi-4-b.dtb; bootz ${kernel_addr_r} - ${fdt_addr_r} '

환경변수 저장

U-Boot> saveenv

재부팅

U-Boot> reset

빌드 시간 확인 - 부팅 메시지 첫 번째 메시지

U-Boot 2024.04-rc1-00063-gdaa3100250 (Feb 07 2024 - 11:36:12 +0900)
  • u-boot 메모리 read/write 테스트 - 데이터시트 확인
U-Boot> md.l 0xfe200000 4

  • GPFSEL0 gpio6(1번 핀) output
U-Boot> mw.l 0xfe200000 0x00040000
  • GPSET0 gpio6 Set(LED0 On)
U-Boot> mw.l 0xfe20001c 0x00000040
  • GPSET0 gpio6 Clear(LED0 Off)
U-Boot> mw.l 0xfe200028 0x00000040
  • GPFSEL0 gpio6~9(1~4번 핀) output
U-Boot> mw.l 0xfe200000 0x09240000
  • GPFSEL0 gpio6~9(1~4번 핀) output
U-Boot> mw.l 0xfe200004 0x00012249
  • GPSET0 gpio6~13 Set(LED All On)
U-Boot> mw.l 0xfe200028 0x00000040
  • GPSET0 gpio6~13 Clear(LED All Off)
U-Boot> mw.l 0xfe200028 0x00003fc0
profile
I mean

0개의 댓글