Make a simple coreboot
On my Ubuntu 21.03 host, I follow the coreboot doc to build a simple ROM: https://doc.coreboot.org/tutorial/part1.html
This is the steps I take and a few screenshot below. This coreboot’s payload is a ELF coreinfo application.
sudo apt-get install -y bison build-essential curl flex git gnat libncurses5-dev m4 zlib1g-dev
git clone https://review.coreboot.org/coreboot
cd coreboot
make crossgcc-i386 CPUS=$(nproc)
make -C payloads/coreinfo olddefconfig
make -C payloads/coreinfo
make menuconfig
select 'Mainboard' menu
Beside 'Mainboard vendor' should be '(Emulation)'
Beside 'Mainboard model' should be 'QEMU x86 i440fx/piix4'
select < Exit >
select 'Payload' menu
select 'Add a Payload'
choose 'An Elf executable payload'
select 'Payload path and filename'
enter 'payloads/coreinfo/build/coreinfo.elf'
select < Exit >
select < Exit >
select < Yes >
make
The goal is to boot this coreboot.rom (256KB) on Simics and it looks like this
Intel Simics
Download from Intel, https://www.intel.com/content/www/us/en/download/645996/30403/simics-simulator-public-release-preview.html
or
https://software.intel.com/content/www/us/en/develop/articles/simics-simulator.html
Extract and install according to the installation guide, https://downloadmirror.intel.com/30403/eng/installation%20and%20getting%20started%20guide.pdf
Once done, create a script based on the “qsp-client-core.simics”
decl {
params from "%simics%/targets/qsp-x86/qsp-client-core.simics"
default enable_efi = FALSE
default bios_image = "/home/james/Works/coreboot/coreboot/build/coreboot.rom"
}
run-command-file "%simics%/targets/qsp-x86/qsp-client-core.simics"
Here is what printed on the serial console
then it reaches,
Debugging coreboot
To debug, Simics need to load the debug symbol, which located in the “build/cbfs/fallback/”
The very first elf file x86 run is bootblock (0xffff_fff0) -> romstage -> ramstage -> postcar
On Simics CLI or on the script we created earlier, add
enable-debugger
add-symbol-file "/home/james/Works/coreboot/coreboot/build/cbfs/fallback/bootblock.debug"
Now we are ready to do single stepping the code