Skip to main content

Libreboot for physical Suda

 

Libre-booting


Just as being able to choose (and share freely) the operating system and software you install on your hardware is a fundamental freedom ( see the FSF for more information) so is being able to change or alter the firmware that runs your hardware. This is why Suda is built on a fully libre operating system ( Parabola, Trisquel and Gnuinos) and libre software.


If I can install install linux on my xyz machine with stock firmware what's the problem ? As the Libreboot website states


You have rights. The right to privacy, freedom of thought, freedom of speech and the right to read. Free software gives you these rights. Your freedom matters. Right to repair matters. Many people use proprietary boot firmware, even if they use GNU+Linux. Non-free firmware often contains backdoors, and can be buggy. Libreboot was founded in in December 2013, with the express purpose of making Free Software accessible for non-technical users at the firmware level. Libreboot can be called Open Source, but you should call it Free Software.’


If you have ever owned a Thinkpad or other brands of laptop like those made by HP or Dell you may have come up against certain problems. On Thinkpads the wifi cards are controlled by what is known as a whitelist , if you want to use a card not in the whitelist ( which might work better with linux or to replace a broken card ) you can’t, the laptop will often refuse to boot until you have removed the card, and installed a manufacturer approved one . On Dell laptops if you try to use a non Dell charger the laptop will tell you that the charger is not approved and may reduce the speed of your laptop as well ( even though the charger is perfectly fine) and will not boot until you exit from the alarming message.


Manufacturers make it very difficult to find a way around these blocks making it hard for you the user/owner to fully control the hardware you have bought. It also contributes to a growing mountain of ewaste which, if we could get round these software and hardware locks, could be reused and recycled more effectively, breaking the vicious circle of built in obsolescence.


Libreboot combined with flashrom ( flashrom is used to flash the firmware built using libreboot) is one way around this problem. What is libreboot ? Libreboot is a firmware package which in some cases can allow us to build a replacement freedom respecting firmware which we can then flash to our hardware replacing the proprietary bios which stops or hinders us from doing with our hardware as we wish.


Hints and caveats. So far I have only been able to fully compile libreboot roms using an older version of Devuan Linux, Devuan Ascii. This is because though libreboot is fairly up to date in its versioning elements like coreboot and other required software references either older software or software no longer easily available. It is possible to build individual roms using current version of distributions such as Gnuinos, Trisquel and Devuan but so far using Parabola Linux we have been unsuccessful. This is possibly due to the differences between Debian based distribution which tend to use an LTS model ( long term support) and older more stable versions of software and Parabola which which is arch based and uses a rolling release model which uses more current and cutting edge software.



Methodology




1. Down libreboot using git

git clone https://notabug.org/libreboot/lbmk


documentation for building here https://libreboot.org/docs/build/#first-install-build-dependencies


2. cd lbmk


3. install dependencies ie


sudo make install-dependencies-debian ( or arch or ubuntu)


This runs a script that will install most if not all of the dependencies needed by libreboot to build the roms you need to replace the proprietary bios on your machine.


4. check at the end of this you have no error messages for missing dependencies

possibly depending on distro you may have to download and install Freetype and Unifont separately ( this is definitely the case on trisquel). If you have error messages at this stage install those missing dependencies manually as your package manager doesnt have them

so you will have to hunt them down. Generally Ive found other than on Trisquel its a simple matter of finding fonts-unifont and freetype as a download you have to compile

 

unifont here https://savannah.gnu.org/projects/unifont/ on Devuan ascii I cheated a little by finding the deb file for fonts-unifont which is ‘fonts-unifont_13.0.06-1_all.deb’ and installing that ( Devuan/Gnuinos-Chimera both have it in their repositories – Devuan Ascii does not)

freetype here https://freetype.org/ ( choose an older freetype version not the newest I went for version 2.8 from 2017 which avoided needing to install docwriter via sudo apt install python3-pip as I was using Devuan Ascii to compile the full set of libreboot roms)


compiling freetype on newer distributions ie Debian 11 based : If installed by compiling from source you will also need to install docwriter as later versions of freetype will not compile properly without it. Docwriter is installed via python and it must be Python >= 3.5 ! You also need to have python3-pip ( sudo apt install python3-pip) installed as we install doc writer using this command :


sudo python3 -m pip install docwriter’


After that do the usual .configure , make and sudo make install to install freetype2 ( this process worked on Devuan Chimera and Gnuinos a libre version of Devuan ( both Debian 11 based))


on Trisquel 10.0.1 we get this warning

configure: WARNING:

`make refdoc' will fail since pip package `docwriter' is not installed.

To install, run `python3 -m pip install docwriter', or to use a Python

virtual environment, run `make refdoc-venv' (requires pip package

`virtualenv'). These operations require Python >= 3.5.’


Trisquel won't allow python3-pip to be installed which is probably down to a freedom issue ie it might contain proprietary or non-free/libre blobs. We have to use synaptic to install replacements. Search for freetype2-demos libfreetype-dev and libfreetype6 and install those.


if you have succeeded in getting a succesful ‘sudo make install-dependencies-debian ( or arch or ubuntu)’ at this point move on to make or building just for one target



** Before running make configure git by doing this

git config --global user.email "you@example.com"

git config --global user.name “your-name”

I’m not sure why the make process fails without this but it works if you have.


5 choices: either run make now which will build all the roms libreboot can build ( make just runs this command ‘./build boot roms all’


6 or choose the rom you want to build and build only that by running ‘./build boot roms xyz’

for the board we will be using in the physical suda it will be ‘./build boot roms ga-g41m-es2l’


in the case of running make it will take a while as it is building all possible roms

but even if building only one rom libreboot will still pull in a lot of files

from web repositorys , such as coreboot and grub be patient!


if either of these methods fails to build roms check error messages at the end of the

process as this will tell you what might be missing


I have only been able to make this work on Devuan Ascii not Parabola,Trisquel or Devuan/gnuinos chimera!! On the other hand I have been able to compile individual roms on Trisquel , Devuan/Gnuinos Chimera but this was achieved not by running make or ./sudo make install-dependencies-debian but instead running /build boot roms “board name” ’ and checking error msgs at the end of each failed run and installing dependencies manually. For what its worth these are the dependencies I discovered were needed ( before I went back and read the documentation)


you will need to first do ‘sudo apt install build-essential’ on Debian/Ubuntu based systems on Arch based systems do 'sudo pacman -S base-devel' and install everything. Then install these :

bison, autoconf, flex, zlib1g-dev, autoconf, automake, autotools-dev, autopoint, gnat ( on parabola install gcc-ada) also install freetype and unifont and if you have problems with freetype installation just install these as I did for Trisquel, freetype2-demos libfreetype-dev and libfreetype6


Now we (should) have finished roms in the 'bin' folder within the lbmk directory we can move on to flashing the rom and freeing our bios. If you have had no success compiling the roms there are some precompiled roms available online but you will have to look for them ( there are a lot for thinkpads and some for our projects target board the ' ga-g41m-es2l'


Flashing the bios


This in some ways is the easiest part of the process, though there are two ways to flash the bios ie. internally or externally – I had to flash my x200 externally to begin with using a raspberry pi and leads, the motherboard we are concerned with here can be flashed internally which makes life easier. Before we flash the chip we have to find it either by looking at the chip on the motherboard / laptop motherboard and noting that down or by knowing what it is.
Its also good practice to take a copy of the stock bios so at first we will run this command blind
 sudo flashrom -p internal:laptop=force_I_want_a_brick,boardmismatch=force -r dump.bin If we get an error msg at this point which says  'No EEPROM/flash device found. Note: flashrom can never write if the flash chip isn't found automatically.' Then we can't flash the chip internally if at all and may have to look up how to flash externally but the board we will be flashing is known to be capable of internal flashing. And the above command should dump the bios but also give us the name of the flash chip. Now we have a copy of the stock bios we can move on to flashing to do that we do this .  On my X200 this command would look like this : 'sudo flashrom -p internal:laptop=force_I_want_a_brick,boardmismatch=force -c "MX25L6405D" -w grub_x200_8mb_libgfxinit_corebootfb_ukqwerty.rom'  note the -c then the “MX25L6405D” this tells flashrom that we are looking for the chip named “MX25L6405D” the -w indcates the rom we will flash onto our bios chip. The instructions for our target board would look like this ( full guide here https://libreboot.org/docs/install/ga-g41m-es2l.html ) Internal flashing is possible. Boot with the proprietary BIOS and GNU+Linux. There are 2 flash chips (one is backup). Remember to back up the stock bios first ie do this sudo flashrom -p internal:laptop=force_I_want_a_brick,boardmismatch=force -r dump.bin Then move onto flashing. Flash the first chip:  ./flashrom -p internal:dualbiosindex=0 -w libreboot.rom Flash the second chip:  ./flashrom -p internal:dualbiosindex=1 -w libreboot.rom

If any of this fails try again - but do not turn off or reboot the computer. If completed succesfully we now have a fully librebooted machine and can continue on to configuring the system to be the new home of Suda !