Coreboot Tutorial
...as used in Chrome OS
(YMMV)
Presented at OSCON 2013
Agenda
(Don't panic - not every section is of equal length)
Intro / Background
Chrome OS Firmware
Development System
Preparing a Test System
Hands On
What Next?
Who are we?
We work for Google, but don't speak for them. All opinions are our own.
What is coreboot?
What is Chrome OS?
Coreboot in Chrome OS
Why coreboot?
Duncan Laurie, at linux.conf.au 2013:
Duncan Laurie, at linux.conf.au 2013:
Duncan Laurie, at linux.conf.au 2013:
Duncan Laurie, at linux.conf.au 2013:
Duncan Laurie, at linux.conf.au 2013:
Duncan Laurie, at linux.conf.au 2013:
Duncan Laurie, at linux.conf.au 2013:
Duncan Laurie, at linux.conf.au 2013:
Duncan Laurie, at linux.conf.au 2013:
Duncan Laurie, at linux.conf.au 2013:
Duncan Laurie, at linux.conf.au 2013:
Agenda
Intro / Background
Chrome OS Firmware
Development System
Preparing a Test System
Hands On
What Next?
Verified Boot
*Okay, the ME runs before the BIOS gets a chance. But that's a separate thing.
Coreboot
Duncan Laurie, at linux.conf.au 2013:
FMAP
�
$ dump_fmap -h link_bios.rom
# name start end size
SI_BIOS 00200000 00800000 00600000
WP_RO 00600000 00800000 00200000
RO_SECTION 00610000 00800000 001f0000
BOOT_STUB 00700000 00800000 00100000
GBB 00611000 00700000 000ef000
RO_FRID_PAD 00610840 00611000 000007c0
RO_FRID 00610800 00610840 00000040
FMAP 00610000 00610800 00000800
RO_UNUSED 00604000 00610000 0000c000
RO_VPD 00600000 00604000 00004000
RW_LEGACY 00400000 00600000 00200000
RW_UNUSED 003fe000 00400000 00002000
RW_VPD 003fc000 003fe000 00002000
RW_ENVIRONMENT 003f8000 003fc000 00004000
RW_SHARED 003f4000 003f8000 00004000
VBLOCK_DEV 003f6000 003f8000 00002000
SHARED_DATA 003f4000 003f6000 00002000
RW_ELOG 003f0000 003f4000 00004000
RW_MRC_CACHE 003e0000 003f0000 00010000
RW_SECTION_B 002f0000 003e0000 000f0000
RW_FWID_B 003dffc0 003e0000 00000040
EC_RW_B 003c0000 003dffc0 0001ffc0
FW_MAIN_B 00300000 003c0000 000c0000
VBLOCK_B 002f0000 00300000 00010000
RW_SECTION_A 00200000 002f0000 000f0000
RW_FWID_A 002effc0 002f0000 00000040
EC_RW_A 002d0000 002effc0 0001ffc0
FW_MAIN_A 00210000 002d0000 000c0000
VBLOCK_A 00200000 00210000 00010000
SI_ALL 00000000 00200000 00200000
SI_ME 00001000 00200000 001ff000
SI_DESC 00000000 00001000 00001000
$
�
$ dump_fmap -h parrot_bios.rom
# name start end size
SI_BIOS 00200000 00800000 00600000
WP_RO 00400000 00800000 00400000
RO_SECTION 00610000 00800000 001f0000
BOOT_STUB 00700000 00800000 00100000
GBB 00611000 00700000 000ef000
RO_FRID_PAD 00610840 00611000 000007c0
RO_FRID 00610800 00610840 00000040
FMAP 00610000 00610800 00000800
RO_UNUSED 00604000 00610000 0000c000
RO_VPD 00600000 00604000 00004000
RO_SI_ALL 00400000 00600000 00200000
RO_SI_ME 00401000 00600000 001ff000
RO_SI_DESC 00400000 00401000 00001000
RW_UNUSED 003fe000 00400000 00002000
RW_VPD 003fc000 003fe000 00002000
RW_ENVIRONMENT 003f8000 003fc000 00004000
RW_SHARED 003f4000 003f8000 00004000
VBLOCK_DEV 003f6000 003f8000 00002000
SHARED_DATA 003f4000 003f6000 00002000
RW_ELOG 003f0000 003f4000 00004000
RW_MRC_CACHE 003e0000 003f0000 00010000
RW_SECTION_B 002f0000 003e0000 000f0000
RW_FWID_B 003dffc0 003e0000 00000040
FW_MAIN_B 00300000 003dffc0 000dffc0
VBLOCK_B 002f0000 00300000 00010000
RW_SECTION_A 00200000 002f0000 000f0000
RW_FWID_A 002effc0 002f0000 00000040
FW_MAIN_A 00210000 002effc0 000dffc0
VBLOCK_A 00200000 00210000 00010000
SI_ALL 00000000 00200000 00200000
SI_ME 00001000 00200000 001ff000
SI_DESC 00000000 00001000 00001000
$
For example...
Link uses that extra 2M of read-write flash to hold a copy of SeaBIOS.
Parrot uses it for a backup read-only copy of the ME firmware. Although I don't think it's actually present...
Agenda
Intro / Background
Chrome OS Firmware
Development System
Preparing a Test System
Hands On
What Next?
Basic system
sudo apt-get install \
git-core gitk git-gui subversion curl
Flashrom
sudo apt-get install \
build-essential zlib1g-dev libftdi-dev pciutils-dev
make CONFIG_DEDIPROG=yes
sudo make install
Coreboot
$ sudo apt-get install libncurses5-dev m4 bison flex iasl
$ git clone http://review.coreboot.org/p/coreboot.git�$ cd coreboot�$ make menuconfig
$ make
build/coreboot.rom
$ make clean�$ make crossgcc
$ make
"make menuconfig" selections
General Setup
Allow use of binary-only repository
Mainboard
Vendor Google
Model Parrot
Chipset
Add a System Agent Binary
Filename: 3rdparty/northbridge/intel/sandybridge/systemagent-r6.bin
VGA BIOS
Add a VGA BIOS
Filename: 3rdparty/mainboard/google/parrot/snm_2130_coreboot.bin
make menuconfig (continued)
Console
Disable Serial port console output
Enable USB 2.0 EHCI debug dongle support
Enable Send console output to a CBMEM buffer
Save and Exit
Coreboot alternate source
$ git remote add cros-coreboot \
https://git.chromium.org/git/chromiumos/third_party/coreboot
$ git branch --track cros \ remotes/cros-coreboot/chromeos-2013.04
$ git checkout cros
$ make menuconfig
$ make
Agenda
Intro / Background
Chrome OS Firmware
Development System
Preparing a Test System
Hands On
What Next?
Which Chromebook?
Acer C7 Chromebook (aka "Parrot")
Back up the original BIOS!
From the root shell:
# mkdir /tmp/ho
# cd /tmp/ho
# flashrom -p internal:bus=spi -r orig_bios.bin
# chromeos-firmwareupdate --sb_extract .
# scp orig_bios.bin bios.bin USER@HOST:
Void your warranty
FIXME: need better photos!
Yes, all the photos are horrible. I only had my phone, in bad lighting. I'll replace them with better ones as soon as I can.
- Bill
BIOS flash write protection
BIOS flash write protection
Disable Write Protection
localhost ~ # flashrom -p internal:bus=spi --wp-status
WP: status: 0x98�WP: status.srp0: 1�WP: write protect is enabled.�WP: write protect range: start=0x00400000, len=0x00400000
localhost ~ #
Disable Write Protection
wpsw_boot = 1�wpsw_cur = 1
wpsw_boot = 1�wpsw_cur = 0
Disable Write Protect
flashrom -p internal:bus=spi --wp-disable�flashrom -p internal:bus=spi --wp-range 0 0
flashrom -p internal:bus=spi --wp-status
Reenable Write Protect (but not now)
flashrom -p internal:bus=spi \
--wp-range 0x00400000 0x00400000
flashrom -p internal:bus=spi --wp-enable�
Now you're ready to brick your Chromebook
flashrom -p internal:bus=spi -w coreboot.rom
Huh
What went wrong?
How can we make it work again?
A brief digression...
Disconnect the hard drive
How the connector works
Trackpad cable
Getting at the flash chip
Getting at the flash chip
Reflash the BIOS
$ sudo flashrom -p dediprog -w bios.bin
Wait, which BIOS do I restore?
Wait, which BIOS do I restore?
Wait, which BIOS do I restore?
Wait, which BIOS do I restore?
One more thing...
$ sudo flashrom -p dediprog -w bios.bin
How do we debug?
How do we debug
USB
coreboot-4.0-4428-g4 PDT 2013 starting...
Setting up static southbridge registers... done.
Disabling Watchdog reboot... done.
Setting up static northbridge registers... done.
Initializing Graphics...
Back from sandybridge_early_initialization()
SMBus controller enabled.
CPU id(206a7): Intel(R) Celeron(R) CPU 847 @ 1.10GHz
AES NOT supported, TXT NOT supported, VT supported
PCH type: NM70, device id: 1e5f, rev id 4
Intel ME early init
Intel ME firmware is ready
ME: Requested 16MB UMA
Starting UEFI PEI System Agent
REC MODE GPIO 68: 0
Read scrambler seed 0x00007d92 from CMOS 0x98
Read S3 scrambler seed 0x00004a81 from CMOS 0x9c
No FMAP found at ffe10000.
FMAP: area RW_MRC_CACHE not found
Example output from a bad BIOS
Agenda
Intro / Background
Chrome OS Firmware
Development System
Preparing a Test System
Hands On
What Next?
Let's do it!
Agenda
Intro / Background
Chrome OS Firmware
Development System
Preparing a Test System
Hands On
What Next?
Duh. What did you think I'd say?
Backup material
vboot_reference tools
sudo apt-get install libssl-dev uuid-dev liblzma-dev libyaml-dev libtspi-dev
git clone https://git.chromium.org/git/chromiumos/platform/vboot_reference
cd vboot_reference
make
sudo make install