Using old x86 hardware or QEMU to take control of CPU after Hard Reset. Overview of commonly used boot loaders , Preparing a custom message bootable USB stick and demo on x86-uboot with QEMU . It is discussed at
https://youtu.be/F71LGSrj9cc
blog: www.embedkari.com
Embedded Career: www.facebook.com/embedkari
2. Agenda
●
QEMU or Quick EMUlator
●
Bootloader overview
●
X86 booting mechanism
●
BIOS to boot sector code transfer demo
●
U-Boot demo for x86 using QEMU
3. Disclaimer
●
Presenter will not be responsible for for any
damage to USB or HDD due to experiments
followed.
●
Take a note of all the instructions carefully
●
Don’t use your hard disk for bootloader
experiments.
●
Presenter will use either QEMU or old x86
based system
4. QEMU
●
QEMU is a generic open source machine emulator and
virtualizer
●
Emulates program written for one architecture in another
●
It can run virtual machines like KVM in host CPU
●
Installation
–
sudo apt install qemu-system
–
If error
–
sudo apt install qemu-system --fix-missing
6. X86 booting mechanism
●
Hardware Reset
●
BIOS(Basic Input/Output System) or Platform Firmware in ASM
–
Resides in non-volatile memory and prepares all POST procedures
–
Interactive hardware configuration
–
Boot mode
●
UEFI / CSM(Compatibility Support Mode)/BIOS
●
Boot Loader
–
Extensible Firmware Interface (EFI)
–
Unified Extensible Firmware Interface(UEFI) written in C
●
Boot Partition Format
–
Boot loader support also depends on type of partition
●
MBR(Master Boot Record) disk partition
●
GPT(GUID Partion Table) disk partition
7. Custom boot.asm●
org 0x7C00 ;BIOS loads program here
●
bits 16 ;16-bit mode
●
start:
●
cli ;Disable Interrupts
●
mov si, welcm ;SI points to custom data
●
mov ah, 0x0E ; Tell BIOS to print characters
●
.loop lodsb ;load byte into AL
–
or al, al
–
jz halt
–
jmp .loop
●
halt: hlt
●
welcm: db “Embedkari Welcomes You! “
●
times 510 - ($ - $$) db 0 ;Fills remaining bytes except last two
●
dw 0xAA55
8. Custom boot sector
Experiment
●
nasm(Netwide Assembler) Open source s/w for x86
–
sudo apt update
–
Check and install build-essential if not present
–
sudo apt list | grep build | grep essential
–
sudo apt install nasm
●
nasm boot.asm -f bin -o boot.bin
●
You may verify assembly listing using
–
nasm boot.asm -l boot.lst
●
Check the binary in QEMU
●
qemu-system-i386 -fda boot.bin
9.
10. Program boot.bin to USB
●
USB data can be
verified if required
●
Start Cygwin as
adminstrator
●
dd if=/dev/sdb bs=512
count=4 of=test.bin
11. U-Boot-x86 @QEMU
●
git clone git://git.denx.de/u-boot-x86.git
●
cd u-boot-x86
●
export BUILD_ROM=y
●
make qemu-x86_defconfig
●
make all
●
Test U-boot in QEMU
●
qemu-system-i386 -nographic -bios u-
boot.rom -net nic -net user,tftp=/tftpboot
12. U-Boot build issue
●
You may get error due to absence of required
Libraries and this may lead to following additional
installation
●
For missing swig
–
sudo apt install swig
●
For Python 2
–
sudo apt install python-dev
●
For Python 3
–
sudo apt install python3-dev
14. THANKS
If you found this information usefule < Please
like this video AND subscribe to
www.youtube.com/c/embedkari
Embedded Career Information :
www.facebook.com/embedkari
Blog:www.embedkari.com