Building coreboot on well supported platform such as Bay Trail is quite straightforward task, however we need to remember about some things in order to have coreboot working. First of all we need to provide up-to-date microcode and FSP (Firmware Support Package), which are not included in coreboot source tree and coreboot build system won’t complain about it. Second thing is that Bay Trail has TXE firmware on the same ROM as boot firmware so we have to make sure that we won’t corrupt it because it would brick the platform. Except those we have standard procedure, we need to get a toolchain.
Microcode
Newest microcode can be found on https://cloud.3mdeb.com/index.php/s/72tWrYQmYQ5gtTr We have to provide it because it’s a condition for warranty for CPU. It is provided as Intel-syntax assembly file with microcode as though it was ordinary data:
|
|
details of it’s structure are confidential. However for coreboot we need to provide it as comma separated list of values in C-style format, like this:
|
|
We can easily download and convert it using simple script:
|
|
FSP (Firmware Support Package)
FSP is binary package from Intel dedicated to firmware developers containing most important platform initialization (including IP). However there is non-FSP version of coreboot for Bay Trail however it won’t work without MRC (Memory Reference Code) which is confidential (available for trusted vendors) so we won’t cover this option.
Intel sites redirect to https://github.com/IntelFsp/FSP (branch BayTrail) where you can find it. We are interested mostly in BayTrailFspBinPkg/FspBin/BayTrailFSP.fd which is file we have to provide to coreboot. FSP can be configured using BCT (Binary Configuration Tools), which is optional — needed to enable Secure boot and FastBoot. The tool is available only as Windows application, but works well using Wine too.
In the same package you can find VgaBIOS which can be used too if you want to use graphic card: BayTrailFspBinPkg/Vbios/Vga.dat
ME region
Despite the name, ME region contains TXE firmware, as mentioned, we must not
corrupt it. The simplest way to avoid that is to read ROM layout from original
firmware image. In utils/ifdtool
of coreboot source tree we can find program
for reading layout from ROM image. The image can be taken from firmware package
or read using flashrom, using SPI interface:
|
|
Note that you may need to adjust -p
option according to used SPI programmer.
Use -p internal
if you use MinnowBoard’s internal programmer.
|
|
While flashing coreboot we should inform flashrom only to write bios
region
|
|
Be careful because this layout may vary between versions, so we should check it for each version separately. For mass reproduction it could be useful to read original firmware, apply coreboot on that image and flash it as a whole on each device.
In case of using wrong layout resulting in bricked platform flash stock firmware (or backup), reread layout and flash coreboot again.
Toolchain
coreboot needs specific versions of toolchain components, we have to take care of this. Makefile has rule for building toolchain:
|
|
Despite the fact that that we usually want to boot 64-bit OS, coreboot code is compiled for 32-bit. Moreover we have noticed that there’s problem with libpayload on 64-bit toolchain.
However this procedure may be problematic. It may take much time on older machine and compilation may fail on some GCC versions. It’s much easier to use docker, there is dedicated docker image with toolchain for coreboot:
|
|
If you don’t have installed docker, please follow official guide: https://docs.docker.com/install/
There is also our image with additional FSP package (under default path):
3mdeb/coreboot-trainings-sdk:latest
.
To run shell in docker environment:
|
|
NOTE: remember that it works as root, so you may want to change owner of new
files after build. This command must be ran in coreboot directory (there is
$PWD
in mount parameter -v
).
Configuration
coreboot is configured using make menuconfig
similar to Linux Kernel (needs
ncurses library). First in Mainboard
menu we set platform:
|
|
Except of this we have to configure microcode and enable FSP in Chipset
menu:
|
|
If we want to use VgaBIOS, we can configure it in Devices
:
|
|
On x86 by default, coreboot chooses SeaBIOS
as a payload so that it provides
legacy BIOS interface. You may want to use one of other options: GRUB (well
known, robust Open Source boot loader), Tianocore (UEFI), etc.
This is minimal configuration for MinnowBoard. However you probably want to
decrease log level (default 8:SPEW is much too verbose) in Console
menu:
|
|
Build & Flash
When configuration is complete, we can save it and run:
|
|
If everything goes well, output should end like this:
|
|
So we can flash it. If you are using docker image, remember that it doesn’t
contain flashrom
so you have to do that outside container:
|
|
Conclusion
This procedure is pretty straightforward, but in practice turns out to cause much trouble at first time. It also covers only most basic options. We are open to help if you have problem with that. Also if you don’t want to do that we provide such a service.
Building EDK2 based firmware for MinnowBoard
There are some options to build firmware for MinnowBoard, a Bay-Trail-based SBC (Single Board Computer) from Intel. We usually prefer coreboot as simplest and fastest, open source solution, but sometimes we want to have UEFI interface.
UEFI itself doesn’t cover whole boot procedure, so its open source reference implementation, EDK2 is not enough to build firmware for hardware plafrorms so we need to provide PI (Platform Initialization) phase implementation. In EDK2 repository we can find only implementation for virtualization (OVMF), this option is covered in this article.
coreboot could be used to provide PI phase, but this procedure is mostly covered in the article on building coreboot for MinnowBoard, but we need to choose Tianocore payload. In this article we cover building UEFI firmware using binary objects from Intel. Whole procedure can be done using following script:
|
|
in edk2-platforms repository we find open-source part of PI for various platforms including MinnowBoard. However, we need also some closed code from Intel’s site, which contains IP (Intellectual Property). Finally we have to fetch OpenSSL, which is another dependency.
When all those components are ready, we can build. We use dedicated docker
images to avoid toolchain compatibility problems. So running docker we mount
edk2
(main repository), edk2-platforms
and cache directory to respective
mount points in the image (build script assume that they are all located in the
same directory). So we enter edk2-platforms/Vlv2TbltDevicePkg/
and run
source Build_IFWI.sh MNW2 Debug
(for DEBUG version). If the build is
successfully complete, we can find the image in
edk2-platforms/Vlv2TbltDevicePkg/Stitch/MNW2MAX_X64_D_0097_01_GCC.bin
.