I have managed to produce a minimal boot sector that works with QEMU 2.0.0 Ubuntu 14.04:
.code16
.global _start
_start:
cli
mov $msg, %si
mov $0x0e, %ah
loop:
lodsb
or %al, %al
jz halt
int $0x10
jmp loop
halt:
hlt
msg:
.asciz "hello world"
.org 510
.word 0xaa55
Compiled with:
as -o main.o main.S
ld --oformat binary -o main.img -Ttext 0x7C00 main.o
The example is available on this repo: https://github.com/cirosantilli/x86-bare-metal-examples/tree/2b79ac21df801fbf4619d009411be6b9cd10e6e0/no-ld-script
Upon:
qemu -hda main.img
it shows hello world
on the emulator screen as expected.
But if I try to burn to a USB:
sudo dd if=main.img of=/dev/sdb
then plug the USB into a ThinkPad T400 or T430, hit F12, and select the USB what I observe is:
- some boot messages show up quickly
- then the screen goes blank, with only a underscore cursor at the top
I have also tested the same USB with a Ubuntu 14.04 image, and it booted fine, so the USB is working.
How should I change this example so that it will boot on the hardware and show the hello world message?
What is the difference between the Ubuntu image and the one I've created?
Where is this documented?
I have uploaded the output of sudo dmidecode
on the T400 to: https://gist.github.com/cirosantilli/d47d35bacc9be588009f#file-lenovo-t400
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…