##GRUB
###Boot manually
--For some setups the default GRUB script does not work. Either try updating the grub.cfg or boot manually (below).
++For some setups the default GRUB script does not work. Either try updating the grub.cfg (next section) or boot manually (below).
-- Open commandline in GRUB
++ #Open commandline in GRUB
cryptomount -a #decrypt all HDDs
root=lvm/matrix-boot #default boot partition, or use `ls` to list partitions
linux=/vmlinuz #! choose the newest file, press TAB to list them !
initrd=/initrd #! choose the newest file, press TAB to list them !
boot
--
++
++###Boot automatically
++Add the below to the preferred boot option, in grub.cfg, for automatic boot. It is recommended to test this configuration with grubtest.cfg, before changing the main config grub.cfg
++
++ set root=lvm/matrix-rootvol
++ if [ -f "/vmlinuz" ]; then
++ linux /vmlinuz
++ if [ -f "/initrd.img" ]; then
++ initrd /initrd.img
++ fi
++ fi
##Libreboot
When installing an OS on a Libreboot (/Coreboot) system, use these [guides](https://libreboot.org/docs/gnulinux/).
--When installing Debian I used [this guide](https://libreboot.org/docs/gnulinux/encrypted_debian.html) in particular, while also encrypting /boot (named boot thus with the resulting full name lvm/matrix-boot, size a couple of hundreds MB). The guide uses LUKS->LVM->Partitions, thus everything is encrypted. You don't need to install GRUB since it is already on the libreboot ROM (if you're using the GRUB payload), however, using a local GRUB makes it possible to [change GRUB config](https://libreboot.org/docs/gnulinux/grub_cbfs.html) without reflashing ROM. But reflashing ROM can be done in the OS.
--If you don't encrypt /boot the default GRUB-scripts works better, i e it boots automatically, at least until the scripts are improved upon.
++When installing Debian I used [this guide](https://libreboot.org/docs/gnulinux/encrypted_debian.html) in particular. The guide uses LUKS->LVM->Partitions, thus everything is encrypted. You don't need to install GRUB since it is already on the libreboot ROM (if you're using the GRUB payload), however, using a local GRUB makes it possible to [change GRUB config](https://libreboot.org/docs/gnulinux/grub_cbfs.html) without reflashing ROM. But reflashing ROM can be done in the OS.
++If you have an unencrypted /boot the default GRUB-scripts works better, i e it boots automatically (using Libreboot2016).
++
++
++### OpenBSD guide
++When installing OpenBSD on the x200, the OS was first installed on the HDD then flashed. Then, add a "/grub" directory that allows grub to automatically boot into openbsd instead of going into command line.
++
++#### The manual way is to press "c" when the grub menu appears:
++```
++grub> kopenbsd (usb0,openbsd1)/6.1/amd64/bsd.rd
++grub> boot
++
++```
++#### The more nicer way (as root do):
++```
++mkdir /grub && cd grub
++echo '''
++default=0
++timeout=3
++
++menuentry "OpenBSD"{
++ kopenbsd (usb0,openbsd1)/6.1/amd64/bsd.rd
++}
++
++''' > libreboot_grub.cfg
--###Building Libreboot
++#cat libreboot_grub.cfg
++default=0
++timeout=3
++
++menuentry "OpenBSD"{
++ kopenbsd (usb0,openbsd1)/6.2/amd64/bsd.rd
++}
++
++
++#reboot
++```
++This works very good with openbsd6.0(and 6.2), read more [here](https://libreboot.org/docs/bsd/openbsd.html)(use amd64, X is not working with i386)
++
++[update] I have run openbsd 6.2 with libreboot on thinkpad x200 for about two months now without any errors, still no update on the harddisk crypto
++
++###Building Libreboot [WIP]
#Get a newer version of flashrom than in Debian repo
#In my case the older version did not detect the exact chip on x200
#This was fixed by cloning and building the most recent version
#mv new.rom ../../
#sudo ./flash update libreboot.rom
--
###X200
--####Flashing Internally [WIP]!
-- To internally flash your ROM use the kernel parameter "iomem=relaxed". Thus, if you boot manually you would enter e g "linux=vmlinuz.. iomem=relaxed"
-- #Get a newer version of flashrom than in Debian repo
-- #In my case the older version did not detect the exact chip on x200
-- #This was fixed by cloning and building the most recent version
++####Flashing Internally
++To internally flash your ROM use the kernel parameter "iomem=relaxed". Thus, if you boot manually you would enter e g "linux=vmlinuz.. iomem=relaxed".
-- ./download flashrom
-- cd flashrom
-- sudo apt-get install libusb-1.0-0-dev build-dep linux-image-$(uname -r)
-- make install #needs sudo?
-- make
++Get a newer version of flashrom than in Debian repo. In my case the older version did not detect the exact chip on x200, which was fixed by getting most recent version
++
++Note these tools are built and ready [at](https://www.mirrorservice.org/sites/libreboot.org/release/stable/20160907/libreboot_r20160907_util.tar.xz) or similar
#backup current rom
-- sudo ./flashrom -p internal -r ~/this_is_my0.rom
++ sudo ./flashrom -p internal -r libreboot.rom
#remove old GRUB (test) config
./cbfstool libreboot.rom remove -n grubtest.cfg
#get the new GRUB (test) config into your ROM
./cbfstool libreboot.rom add -n grubtest.cfg -f grubtest.cfg -t raw
-- #I think this should work
-- #sudo ./flashrom -p internal -w ../libreboot.rom
--
-- #Otherwise
-- #sudo ./flash update libreboot.rom
++ #change background in GRUB menu (dest must be called background.png /jpg)
++ #./cbfstool yourrom.rom remove background.png -n background.png
++ #./cbfstool yourrom.rom add -f background.png -n background.png -t raw
++
++ sudo ./flashrom -p internal -w libreboot.rom #updated image
++
###KGPE-D16
####General
-- (Libreboot-20160907)
++ Note these bugs and fixes were tested 2017 with the stable release _Libreboot-20160907_.
* Do NOT use cheap Chinese 12v connectors, they will melt!
* RAM is sensitive, less is more likely to work. See [coreboot wiki](https://www.coreboot.org/Board:asus/kgpe-d16) for working configurations
-- * Use 62xx-series CPUs, because Libreboot does not update (proprietary) microcode. However, this should be up to you. (See [Libreboot](https://libreboot.org/docs/hardware/kgpe-d16.html))
-- * Internal GPU works (for text mode only), note the hardware switch (see motherboard manual)
++ * RAM order is important, see motherboard manual
++ * Use 62xx-series CPUs, because Libreboot does not update (proprietary) microcode. However, this is up to you (we have not tried though). (See [Libreboot](https://libreboot.org/docs/hardware/kgpe-d16.html))
++ * Internal GPU works (for text mode only), note the hardware jumper (see motherboard manual)
* North bridge (?) gets hot
* A system with 2x 6276 CPUs draws between 200 and 400 watt, depending on the workload.
* There are two ethernet ports and one IPMI (not used)
-- * RAM order is important, see motherboard manual
* Hardware jumpers for GPU, ethernet etc.
* Note: It might be necessary to have a dedicated sound card or graphics card, if those features are desired.
--####Using
++####Using
* GRUB is recommended. But SeaBIOS has worked better when booting from CD-ROM or USB.
* When booting from USB, connect the USB-stick NOT BEFORE GRUB menu is shown.
* If problems booting, disconnect power and remove CMOS battery for a couple of seconds.
-- * The default script in GRUB does not work with encrypted boot-partition (can manually boot)
++ * The default script in GRUB does not work with encrypted boot-partition (can manually boot).
++ * When booting from GRUB, you might want to use "load config from external device" instead of "boot USB". Recommended when booting LiveCDs etc., if you dont have any particular configuration locally.
####Quirks
* In GRUB the USB keyboard is unusably slow. Fix: always have a PS/2 keyboard connected, but use the USB keyboard.
++ * In *earlier* versions of Libreboot the boot process could take up to five minutes (!), be patient.
++ * If you can't boot: reset CMOS (battery and power), make sure your graphic output correctly set (jumper on board). Otherwise, it is most likely a memory or ROM-image problem. You can use a serial cable to debug and get an idea about the issue.
++ * When I had major problems booting I had some help by sound cues and measuring current power draw, to recognize when the boot would likely fail (if you cannot use serial cable). When booting successfully the system (1x 6276, 32GB) drew 180->200->218->166w (GRUB), otherwise it had a different behavior. Furthermore, after disconnecting the power the system would never boot without also clearing CMOS. The system would get stuck and the fans would always go high. While in a healthy boot would start fans low and then ramp up when starting GRUB and then stay there (fans connects to board directly). These sound cues were useful as you can be quite sure the system booted successfully without having any graphic output. In some configurations the fans will always be low and the system fail to boot, which would also overheat the already stuck system (!), thus you might want to power the fans with PSU instead of board.
####Our Systems
Debian Stretch
TODO improve GRUB config
####Flashing
--Buy a couple of flash chips in case of you breaking them, and to test different payloads. Furthermore, one could buy a proprietary chip just to debug the hardware.
++Buy a couple of flash chips in case of you breaking them, and to test different payloads. Furthermore, one could buy a proprietary chip just to debug the hardware.
[D16-chip](resources/d16_chip.png)
[Beagleboard Black P9 connector](resources/BBB_P9.png)
--[Failed flashed try 1 (use Pomona holder), but should be correctly connected](resources/fail_flash_1.png)
++[PLEASE JUST POMONA HOLDER INSTEAD but should be correctly connected 1](resources/fail_flash_1.png)
++
++[PLEASE JUST POMONA HOLDER INSTEAD but should be correctly connected 2](resources/fail_flash_2.jpg)
--[Failed flashed try 2 (use Pomona holder), but should be correctly connected](resources/fail_flash_2.jpg)
++[PLEASE JUST POMONA HOLDER INSTEAD but should be correctly connected 3](resources/div_pics/d16_g.jpg)
--[Div pics a](resources/div_pics/d16_a.jpg), [Div pics b](resources/div_pics/d16_b.jpg), [Div pics c](resources/div_pics/d16_c.jpg), [Div pics d](resources/div_pics/d16_d.jpg), [Div pics e](resources/div_pics/d16_e.jpg), [Div pics f](resources/div_pics/d16_f.jpg), [Div pics g](resources/div_pics/d16_g.jpg)
++[Div pics a](resources/div_pics/d16_a.jpg), [Div pics b](resources/div_pics/d16_b.jpg), [Div pics c](resources/div_pics/d16_c.jpg), [Div pics d](resources/div_pics/d16_d.jpg), [Div pics e](resources/div_pics/d16_e.jpg), [Div pics f](resources/div_pics/d16_f.jpg)
++
++We recommend SPI-speed set to 2048. (spi=2048)
Use a holder for the ROM, do not solder. Use a female-male cable when connecting to BBB (or other board). According to Libreboot IRC shorter cables are NOT necessarily better. I found no cable length to be optimal (~5/10/20 cm), my final configuration used ~10 cm cables.
++
++When searching through my notes I found the following from Libreboot IRC;
++_"Try different cables max 30 cm long, add 50 ohm resistors in series and keep trying. While 1: flashrom -c 'your chip' #Should be constant"_
ROM-holder (eg.): 3M IC test socket, DIP 18, 218-3341-00-0602J
--ROM-chip (eg.): Winbond W25Q16DV (Note: the image built from Libreboot needs to match the ROM size. Specifically, if you're choosing pre-built this must match exactly AFAIK)
++ROM-chip (eg.): Winbond W25Q16DV (if ROM too small can extend, see: *Extend 2MB ROM to 8MB*)
1 CS -> 17 SPIO_CSO
# Thus, it is possible to write to the ROM and read (e.g.) 10 times and compare the resulting `sha512sum` to that of the ROM downloaded from Libreboot.
# If the sum EXACTLY matches atleast once, it is reasonable to assume that the write indeed succeeded.
++## Extend 2MB ROM to 8MB
++
++### Here is the script we use to flash 8mb chip
++
++```
++root@beaglebone:~# cat flashme_8mb.sh
++echo 'Creating a 8mb Libreboot Rom'
++echo 'creating the file /home/flashing_d16/libreSept16/8mb_free.rom'
++echo 'dd ing'
++touch /home/flashing_d16/libreSept16/8mb_free.rom
++echo ' ' > /home/flashing_d16/libreSept16/8mb_free.rom
++echo 'Zeros then image'
++dd if=/dev/zero bs=6144k count=1 of=/home/flashing_d16/libreSept16/8mb_free.rom
++echo 'Writing image'
++dd if=/home/flashing_d16/libreSept16/libreboot_r20160907_grub_kgpe-d16/kgpe-d16_svenska_txtmode.rom >> /home/flashing_d16/libreSept16/8mb_free.rom
++ls -lah /home/flashing_d16/libreSept16/8mb_free.rom
++echo 'Its flashing time'
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=2048 -w /home/flashing_d16/libreSept16/8mb_free.rom
++echo 'everything is done'
++echo 'plz verify'
++echo '
++cd directory-with-size
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -r factory.rom
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -r factory1.rom
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -r factory2.rom
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=1024 -r factory3.rom
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=1024 -r factory4.rom
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=1024 -r factory5.rom
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=256 -r factory6.rom
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=256 -r factory7.rom
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=256 -r factory8.rom
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=2048 -r factory9.rom
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=2048 -r factory10.rom
++/home/flashing_d16/libreSept16/libreboot_r20160907_util/flashrom/armv7l/flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=2048 -r factory11.rom
++sha512sum factory*.rom
++'
++
++```
++
++
##Coreboot
##Fria wifi