Skip to content

Latest commit

History

61 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Bootloader

Simple Multiboot 1 bootloader, originally for naos.

See also my blog article about this project, which describes how it internally works.

Building

This project has some dependencies, which will have to be installed on your system:

  • nasm: Assembler used in the project, see its website.
  • mcopy (usually from the mtools package): Used to copy the bootloader binaries into the generated FAT12 image file.
  • Cross-compiled i686 linker: This can be obtained from my i686-cross-compiler repo.

Optionally, you will need the Qemu virtual machine for testing the bootloader.

Once you have the necessary dependencies installed, you can clone this repository and build the bootloader:

$ git clone https://github.com/8dcc/sl
$ cd sl
$ make...

Testing and debugging

To test the bootloader simply use the qemu target:

$ make qemu...(qemu) # Enter Qemu commands here

For debugging, use the qemu-debug target, which also opens a GDB server on TCP port 1234 (-s option), and pausing the CPU on startup (-S option).

$ make qemu-debug # Will hang at startup....(qemu) # Enter Qemu commands here

Then, you can connect to this remote server through GDB:

(gdb) target remote :1234Remote debugging using :12340x0000fff0 in ?? ()(gdb) ... # Set breakpoints, etc.(gdb) cContinuing.

Furthermore, if you want to load some debugging information, you can build the ELF binaries with the elf-bins target, and then load them into GDB.

$ make elf-bins...
$ ls *.elfstage1.elf stage2.elf
$ gdb(gdb) target remote :1234Remote debugging using :12340x0000fff0 in ?? ()(gdb) add-symbol-file stage1.elfadd symbol table from file "stage1.elf"(y or n) yReading symbols from stage1.elf...(gdb) add-symbol-file stage2.elfadd symbol table from file "stage2.elf"(y or n) yReading symbols from stage2.elf...(gdb) break stage2_entryBreakpoint 1 at 0xa000: file src/stage2.asm, line 37.(gdb) cContinuing.Breakpoint 1, stage2_entry () at src/stage2.asm:3737 mov si, str_stage2_loaded(gdb)

Some other useful commands include addr2line, for obtaining the source number of addresses:

$ addr2line --pretty-print --basenames --addresses --functions --exe stage1.elf 0x7c000x00007c00: stage1_entry at stage1.asm:66
$ sed -n '65,67p' src/stage1.asmstage1_entry: jmp short stage1_main nop

About

Simple Multiboot 1 bootloader

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages