Building coreboot from source (official script)

Same issue, it’s severe because without an update of the BIOS, my Librem 13 v2 wont stop shutting down when I make it work a little hard because fans don’t spin fast enough. I am stuck with my work until this is fixed.

1 Like

@sboresch

Not really sure, what is going on, but I can confirm that the coreboot-script comes with crossgcc. The background is that your Librem has a 64it CPU, but Coreboot is compiled for 32bit. Hence the crosscompiler is needed. Also I think the coreboot-team patched this GCC, because there are some tweaks to the linker, that “normal” GCC sometimes cannot handle.
There is an option is Coreboot’s config that reads:

Many toolchains break when building coreboot since it uses quite unusual linker features.

The option is called CONFIG_ANY_TOOLCHAIN. To me this means that coreboot will per default build it’s own, tweaked version of CrossGCC.

Can you calrify, when the error occors? I guess you are using the vanilla script? When have you downloaded it?

KR
Max

On my end, it seems that when encountering the error, running the script again fixes the issue, even though it’s weird to have an error on first run.

I also had that mega issue and had to fix it, then re-run the script.

So I ran the script once, met the mega issue.
Ran the script again, met the flags compilation error.
Ran it again and it worked.

Hope this helps.

Hi,

thanks for the quick reply. Trying to give some answers to your questions:

I am attempting to build with ‘build_coreboot.sh’, which I downloaded from the ‘usual’ place’ (I wish there would be a clean download link with changelogs somewhere.) For the record, this is the md5sum:

4c2e2e82a9f81c29023b8de6c60b8e33 build_coreboot.sh

and it must be newer than the one I used to build coreboot-4.8.1-7-g30300027ce-4.8.1-Purism-3 presently on my system as there are entries for the librems 13v4 and 15v4.

I guess my first point is that while I could build 8-9 months ago, the build now fails. Whether this is a change in build_coreboot.sh, a change in the toolchain resulting from newer versions that were installed in PureOS, or changes in the coreboot source code I can’t tell.

The compile error happens when the freshly built (cross) compiler attempts to build the actual coreboot firmware. I add a longer output from the build output at the end of this post. This should help pinpoint where things go wrong.

For the record, I also encountered the mega download problem, but this is easy to workaround, and the attempt to automatically download this stuff almost never worked in the past. Further, my machine is a librem13v3, PureOS is regularly updated, and for whatever reasons my default comiler is still gcc/g++ v7 (although gcc8 is installed as well).

Could you try a fresh recompile/build (pulling everything from git – this is what I did, I ran build_coreboot.sh in a pristine directory, not trying to update older builds?

Thanks for your help!

Stefan


… [much more earlier output …]

You can now run IASL ACPI compiler from /home/sboresch/stuff/morestuff/coreboot/util/crossgcc/xgcc
#
# configuration written to /home/sboresch/stuff/morestuff/coreboot/.config
#
Skipping submodule ‘3rdparty/blobs’
#
# configuration written to /home/sboresch/stuff/morestuff/coreboot/.config
#
HOSTCC util/sconfig/lex.yy.o
HOSTCC util/sconfig/sconfig.tab.o
HOSTCC util/sconfig/main.o
HOSTCC util/sconfig/sconfig (link)
SCONFIG mainboard/purism/librem_skl/variants/librem13v2/devicetree.cb
CC bootblock/mainboard/purism/librem_skl/static.o
CC bootblock/arch/x86/boot.o
CC bootblock/arch/x86/bootblock_crt0.o
CC bootblock/arch/x86/cpu_common.o
GEN build.h
CC bootblock/arch/x86/id.o
CC bootblock/arch/x86/memcpy.o
CP bootblock/arch/x86/memlayout.ld
CC bootblock/arch/x86/memset.o
CC bootblock/arch/x86/mmap_boot.o
CC bootblock/arch/x86/timestamp.o
CC bootblock/commonlib/cbfs.o
CC bootblock/commonlib/iobuf.o
CC bootblock/commonlib/lz4_wrapper.o
CC bootblock/commonlib/mem_pool.o
CC bootblock/commonlib/region.o
CC bootblock/console/console.o
CC bootblock/console/die.o
CC bootblock/console/init.o
CC bootblock/console/post.o
CC bootblock/console/printk.o
CC bootblock/console/vsprintf.o
CC bootblock/console/vtxprintf.o
CC bootblock/cpu/intel/fit/fit.o
CC bootblock/cpu/x86/lapic/boot_cpu.o
CC bootblock/cpu/x86/mtrr/earlymtrr.o
CC bootblock/cpu/x86/pae/pgtbl.o
CC bootblock/cpu/x86/tsc/delay_tsc.o
CC bootblock/device/device_simple.o
CC bootblock/device/i2c.o
CC bootblock/drivers/i2c/designware/dw_i2c.o
CC bootblock/drivers/pc80/rtc/mc146818rtc.o
CC bootblock/drivers/pc80/rtc/mc146818rtc_boot.o
CC bootblock/drivers/spi/bitbang.o
CC bootblock/drivers/spi/boot_device_rw_nommap.o
CC bootblock/drivers/spi/spi-generic.o
CC bootblock/drivers/spi/spi_flash.o
CC bootblock/lib/boot_device.o
CC bootblock/lib/bootblock.o
CC bootblock/lib/bootmode.o
HOSTCC cbfstool/fmaptool.o
HOSTCC cbfstool/cbfs_sections.o
HOSTCC cbfstool/fmap_from_fmd.o
HOSTCC cbfstool/fmd.o
In file included from /home/sboresch/stuff/morestuff/coreboot/util/cbfstool/fmd.c:19:0:
fmd_parser.y:54:20: error: ‘union flashmap_flags’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
In file included from /home/sboresch/stuff/morestuff/coreboot/util/cbfstool/fmd.c:19:0:
fmd_parser.y:30:23: error: field ‘flags’ has incomplete type
cc1: all warnings being treated as errors
make: *** [util/cbfstool/Makefile.inc:110: build/util/cbfstool/fmd.o] Error 1
sboresch@sbpuri:~/stuff/morestuff$
sboresch@sbpuri:~/stuff/morestuff$ cd coreboot/
sboresch@sbpuri:~/stuff/morestuff/coreboot$ less .config
sboresch@sbpuri:~/stuff/morestuff/coreboot$ make
Skipping submodule ‘3rdparty/blobs’
HOSTCC cbfstool/fmd.o
In file included from /home/sboresch/stuff/morestuff/coreboot/util/cbfstool/fmd.c:19:0:
fmd_parser.y:54:20: error: ‘union flashmap_flags’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
In file included from /home/sboresch/stuff/morestuff/coreboot/util/cbfstool/fmd.c:19:0:
fmd_parser.y:30:23: error: field ‘flags’ has incomplete type
cc1: all warnings being treated as errors
make: *** [util/cbfstool/Makefile.inc:110: build/util/cbfstool/fmd.o] Error 1’

Exact same issue here (Librem 13v2). I downloaded the script today, ran it on a fully updated PureOS, had to download that one MEGA file manually, and got the same error about ‘union flashmap_flags’ and whatnot. Running the script again also magically fixed the issue for me.

revamping the build script to not use any external sources is near the top of my to-do list. In the meantime, I’ve added the option to download/flash precompiled coreboot images for all Librem 13/15 devices. While still in the testing phase (read: consider it BETA), it seems to work without issue in all my tests. From a terminal:

mkdir update && cd update
curl -LO https://source.puri.sm/coreboot/releases/raw/master/update_coreboot.sh
sudo bash update_coreboot.sh

the script will prompt you to select your model, and then a few options dependent thereof, including the ability to set the default boot order. Feedback is welcomed

edit: updated script URL to use master branch

1 Like

Thank you so much @MrChromebox. Once I installed the build dependencies this worked great. Now my Librem 13 boots straight from my Nitrokey storage. I’ve even managed to get the luks smartcard script to work :smile:

I think I’ll wait a bit to try flashing HEADS on it though as I’m running Debian Testing & don’t have a Librem key yet.

How are ya’ll getting past the megadown issue?

I downloaded the file manually, renamed it to “me_11_repository.rar”, and moved the file into “/home/anon/building-coreboot/coreboot/megadown”

Then when running the script: “chmod +x build_coreboot.sh && ./build_coreboot.sh”, it runs up to:

"Downloading ME 11 Repository from https://mega.nz/#!6JlAla6a!hvulc0ZYCj19OzOZoyKimZSh8bxHw9Qmy6bQ8h_xKTU
Please be patient while the download finishes…

Reading link metadata…" … and just stops.

Am I missing a step? I followed all other steps from https://puri.sm/coreboot/, and tried to follow the error workarounds from here, with no luck.

Any ideas? Thanks!

@dc3p
Don’t move the file to “/home/anon/building-coreboot/coreboot/megadown”.
Move it to “/home/anon/building-coreboot/coreboot/”.

Everything else is fine.

1 Like

And I am off to the races! Thank you very much.

1 Like

Which option should I select when prompted for serial?

Which serial number do you want to set :
1 - Extracted from the coreboot image (L15V4US1903073)
2 - Fetch the serial number from your local system
3 - Enter serial number manually
4 - Do not set a serial number

Enter your choice (default: 1): 1

@dc3p
Just my two cents, but taking option no. 1 always worked for me. Plus I think that serial is (in the end) not that important.

If someone else could elaborate on my statement, that would be great :slight_smile:

1 Like

I’ve hit another wall:

Building GCC v6.3.0 for target ... failed. Check 'build-i386-elf-GCC/build.log'.
make[2]: *** [Makefile:26: build_gcc] Error 1
make[1]: *** [Makefile:48: build-i386] Error 2
make: *** [util/crossgcc/Makefile.inc:46: crossgcc-i386] Error 2

the log it points to says:

sem_attr.adb:50:16: warning: use clause for package "Sdefault" has no effect
make[1]: *** [../../gcc-6.3.0/gcc/ada/gcc-interface/Make-lang.in:119: ada/sem_attr.o] Error 1
make[1]: *** Waiting for unfinished jobs....
../../gcc-6.3.0/gcc/ada/sem_case.adb: In function 'Sem_Case.Check_Choice_Set':
../../gcc-6.3.0/gcc/ada/sem_case.adb:848:37: warning: 'Prev_Choice' may be used uninitialized in this function [-Wmaybe-uninitialized]
make[1]: Leaving directory '/home/anon/building-coreboot/coreboot/util/crossgcc/build-i386-elf-GCC/gcc'
make: *** [Makefile:4108: all-gcc] Error 2
/bin/bash ../gcc-6.3.0/mkinstalldirs /home/anon/building-coreboot/coreboot/util/crossgcc/xgcc /home/anon/building-coreboot/coreboot/util/crossgcc/xgcc
/bin/bash: line 3: cd: i386-elf/libgcc: No such file or directory
make: *** [Makefile:10796: install-target-libgcc] Error 1

Reading up says this could be due to multiple repos or having a newer version of gcc installed? The only non-PureOS green repo I have is the Debian main.

I can remove the Debian repo if needed, or downgrade gcc if needed (I would need a little help with the latter, if that was the case).

Thanks for all the help you have provided so far.

I just tried disabling the Debian repos and installing gcc-3; the build fails with the same errors as above.

I’m sorry all, but is this the solution to both the broken build and being able to alter boot order?

I just ran through MrChromebox’ script, and it worked like a charm! Sorry for all the posts, but I appreciate all of your help.

One last question is: I have a Librem Key coming soon. Is there any harm in installing PureBoot / heads now and setting up the key when it comes in, or do you need to have the key at initial run?

you’d have to configure it to either use a different validation method in the meantime, or simply ignore all the warnings etc until you got the librem key to set everything up. I’d probably just wait since there’s no benefit in flashing the Pureboot firmware ahead of time

1 Like

yes. flashing the precompiled firmware has no dependencies beyond those needed for flashrom to flash it, and everything is downloaded from Purism servers. The updater script also provides the option to customize the boot order prior to flashing when using the standard/SeaBIOS firmware.

1 Like

You rock, good sir! Thank you again.

I successfully ran the update script, changed the boot order, everything is good there. I also flashed heads to the system, and that is running OK - thought without a Librem Key.

I have a Yubikey, and was going to try setting up yubikey-luks, but i think i need standard firmware – not heads.

When trying to flash back to coreboot, i get:

Initializing internal Flash Programmer

ERROR!!! Error flashing coreboot!

Can you not go back once heads is installed?