A bootloader is a computer program that is responsible for booting a computer.
mcu에 부트로더가 있기도 하고, 온 칩으로 존재하기도 함
부트로더가 필요하지 않은 경우 :
- 펌웨어가 업데이트될 필요가 없는 제품
- 필드에서 혹은 소비자가 직접 펌웨어를 업데이트 할 필요 없는 경우
- 별도 부트로더가 필요없는 MCU : STM32 포함 대부분의 MCU는 별도 부트코드 필요없이 특정 툴을 사용해
내장 Flash Memory 에 Wirte하면 바로 실행 가능
부트로더를 추가하면 메모리 구조가 변경 되기 때문에 링커 스크립트 파일을 수정하여 펌웨어의 시작 위치와 인터럽트 벡터의 주소를 변경해야 한다.
Loading the OS kernel: The bootloader loads the OS kernel into memory and starts it.
Providing an interface: The bootloader provides an interface for the user to load an operating system and applications.
Ensuring data loading: The bootloader ensures that all relevant operating system data is loaded into the main memory when a device is started.
Protecting the device state: The bootloader guards the device state and is responsible for initializing the Trusted Execution Environment (TEE).
부트로더는 512 바이트이며 마지막에 55 AA 가 오는 것을 규칙으로 한다.
이유가 뭘까??
https://en.wikipedia.org/wiki/Master_boot_record
Master boot record - Wikipedia
From Wikipedia, the free encyclopedia First sector of a partitioned computer disk This article is about an IBM PC-specific type of boot sector on partitioned media. For the first sector on non-partitioned media, see volume boot record. A master boot record
en.wikipedia.org
바이오스가 첫 512byte(MBR)만 로드
바이오스가 MBR, 즉 첫 512바이트를 0x07C0에 로드하는것이 둘 사이에 정해진 인터페이스
부트로더 제작
sudo apt-get install nasm
------------------------------
[org 0]
[bits 16]
jmp 0x07C0:start
start:
mov ax, 0xB800
mov es, ax
mov byte[es:0], 'i'
mov byte[es:1], 0x09
mov byte[es:2], 'm'
mov byte[es:3], 0x0a
mov byte[es:4], ' '
mov byte[es:5], 0x0b
mov byte[es:6], 'd'
mov byte[es:7], 0x0c
mov byte[es:8], 'o'
mov byte[es:9], 0x0d
mov byte[es:10], 'n'
mov byte[es:11], 0x0e
mov byte[es:12], 'g'
mov byte[es:13], 0x0f
mov byte[es:14], 'h'
mov byte[es:15], 0x10
mov byte[es:16], 'a'
jmp $
times 510-($-$$) db 0
dw 0xAA55
--------------------------------
규약대로 asm 코딩한 것
nasm -f bin -o bios.img bios.asm
img로 구운 후 vmware workstation으로 돌려보면 아래와 같은 결과를 얻을 수 있다.
(이렇게 셋팅해주면 된다)
예상대로 작동하는 것을 확인할 수 있다.
IDA 로 열어보면 아래와 같이 나타난다.
0x1F0 + 0x10 = 512byte
끝자리 55 AA
모든 조건을 만족한 것을 확인할 수 있다.
'study' 카테고리의 다른 글
SVN 사용법 (0) | 2024.03.05 |
---|---|
[OS만들기]BOOTLOADER->KERNEL 시도... (0) | 2024.02.24 |
[WORKSTATION 구축]뻘짓진행 - NAS, DAS, SAN 정리 (0) | 2024.01.29 |
PGP 란, 이메일 암호화/복호화 (0) | 2024.01.28 |
[WORKSTATION 구축]뻘짓진행 - iDRAC 접속오류 (0) | 2024.01.25 |