--- /dev/null
+[[!toc levels=3]]
+
+##GRUB
+###Boot manually
+For some setups the default GRUB script does not work. Either try updating the grub.cfg or boot manually (below).
+
+ 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
+
+
+##Libreboot
+
+###General
+For flashing see this [guide](https://libreboot.org/docs/install/x200_external.html) for a general idea, however each system has their own chip configuration which differs a little.
+
+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.
+
+
+###X200
+####Flashing Externally [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"
+ clone libreboot ...
+
+ #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
+
+ ./download flashrom
+ cd flashrom
+ sudo apt-get install libusb-1.0-0-dev build-dep linux-image-$(uname -r)
+ make install #needs sudo?
+ make
+
+ #backup current rom
+ sudo ./flashrom -p internal -r ~/this_is_my0.rom
+ sudo ./flashrom -p internal -r ~/this_is_my1.rom
+ sudo ./flashrom -p internal -r ~/this_is_my2.rom
+
+
+ #build libreboot, for the ROM
+
+ #dependencies for Debian
+ sudo ./oldbuild dependencies trisquel7
+
+ #download and build necessary
+ ./download grub -y
+ ./download coreboot -y
+ ./oldbuild module grub
+ ./oldbuild module coreboot
+
+ #finally build the ROM we want
+ ./oldbuild roms withgrub x200_8mb
+
+ cd bin/grub
+ ls
+
+ #./oldbuild clean all
+
+
+ ## Moving on
+ #cp new.rom ich9deblob/x86_64
+ #cd ich9deblob/x86_64
+ #/ich9gen --macaddress XX:XX:XX:XX:XX:XX
+ #dd if=ich9fdgbe_8m.bin of=libreboot.rom bs=1 count=12k conv=notrunc #for 8mb chip
+ #mv new.rom ../../
+ #sudo ./flash update libreboot.rom
+
+
+
+###KGPE-D16
+####General
+ (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)
+ * 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
+ * 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)
+
+####Quirks
+ * In GRUB the USB keyboard is unusably slow. Fix: always have a PS/2 keyboard connected, but use the USB keyboard.
+
+####Our Systems
+Debian Stretch
+
+1x 6276 CPU
+
+2x 16GB 1600Mhz Reg-ECC *MT36JSF2G72PZ-1G6E1LG (HP: 672612-081)* [max 32GB/CPU!](https://www.coreboot.org/Board:asus/kgpe-d16/known_bad_configs)
+
+Nvidia GTX 660, Nouveau drivers but crashes when playing videos. Probably my fault however.
+
+For our software configs, see: [[https://github.com/Eliot-Roxbergh/dotFIles/]]
+
+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.
+
+[D16-chip](guider/resources/d16_chip.png)
+
+[Beagleboard Black P9 connector](guider/resources/BBB_P9.png)
+
+[Failed flashed try 1 (use Pomona holder), but should be correctly connected](guider/resources/fail_flash_1.png)
+
+[Failed flashed try 2 (use Pomona holder), but should be correctly connected](guider/resources/fail_flash_2.jpg)
+
+[Div pics a](guider/resources/div_pics/d16_a.jpg), [Div pics b](guider/resources/div_pics/d16_b.jpg), [Div pics c](guider/resources/div_pics/d16_c.jpg), [Div pics d](guider/resources/div_pics/d16_d.jpg), [Div pics e](guider/resources/div_pics/d16_e.jpg), [Div pics f](guider/resources/div_pics/d16_f.jpg), [Div pics g](guider/resources/div_pics/d16_g.jpg)
+
+
+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-holder (eg.): 3M IC test socket, DIP 18, 218-3341-00-0602J
+
+ 1 CS -> 17 SPIO_CSO (red)
+ 2 DO (IO1) -> 21 SPIO_DO (black)
+ 3 /WP (IO2) -> 3.3V (yellow)
+ 4 GND -> GND (green)
+
+ 8 VCC -> 3.3V (blue)
+ 7 /HOLD (IO3) -> 3.3V (orange)
+ 6 CLK -> 22 SPIO_SCLK (grey)
+ 5 DI (IO0) -> 18 (purple)
+
+
+ #change background (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
+
+ #remember to backup current image if you'd like
+ #can read current contents a nr of times and they should be the same
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -r factory.rom
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -r factory1.rom
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -r factory2.rom
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=1024 -r factory3.rom
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=1024 -r factory4.rom
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=1024 -r factory5.rom
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=256 -r factory6.rom
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=256 -r factory7.rom
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=256 -r factory8.rom
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=2048 -r factory9.rom
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=2048 -r factory10.rom
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=2048 -r factory11.rom
+ sha512sum factory*.rom #they should be the same..
+
+ #Flash ROM (can try different speeds)
+ ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -w ~/libreboot_r20160907_grub_kgpe-d16/kgpe-d16_svenska_txtmode.rom
+
+ ## NOTE ##
+ # In my case (KGPE-D16) it was very difficult - seemingly at random - to achieve a configuration such as read and write had good reliability.
+ # Furthermore, writing had good success rate while reading was more error prone.
+ # 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.
+
+##Coreboot
+
+##Fria wifi
+Note that many systems come with proprietary wifi, e g the X200 laptop or the S3 phone. In these cases another wifi chip is needed, either external (micro/)USB or internal.
+
+For hardware recommendations see [[rekommenderat]].
+
+##Fria mobilen
+Sadly phones are proprietary devices that track you.
+Nevertheless, [Replicant](https://www.replicant.us/) are good but slow. An interesting phone in development is [Librem 5](https://puri.sm/shop/librem-5/) (Q1 2019).
+For more hardware recommendations see [[rekommenderat]].
+
+
+We have some experience with Replicant, guides coming (TODO!).
+++ /dev/null
-[[!toc levels=3]]
-
-##GRUB
-###Boot manually
-For some setups the default GRUB script does not work. Either try updating the grub.cfg or boot manually (below).
-
- 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
-
-
-##Libreboot
-
-###General
-For flashing see this [guide](https://libreboot.org/docs/install/x200_external.html) for a general idea, however each system has their own chip configuration which differs a little.
-
-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.
-
-
-###X200
-####Flashing Externally [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"
- clone libreboot ...
-
- #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
-
- ./download flashrom
- cd flashrom
- sudo apt-get install libusb-1.0-0-dev build-dep linux-image-$(uname -r)
- make install #needs sudo?
- make
-
- #backup current rom
- sudo ./flashrom -p internal -r ~/this_is_my0.rom
- sudo ./flashrom -p internal -r ~/this_is_my1.rom
- sudo ./flashrom -p internal -r ~/this_is_my2.rom
-
-
- #build libreboot, for the ROM
-
- #dependencies for Debian
- sudo ./oldbuild dependencies trisquel7
-
- #download and build necessary
- ./download grub -y
- ./download coreboot -y
- ./oldbuild module grub
- ./oldbuild module coreboot
-
- #finally build the ROM we want
- ./oldbuild roms withgrub x200_8mb
-
- cd bin/grub
- ls
-
- #./oldbuild clean all
-
-
- ## Moving on
- #cp new.rom ich9deblob/x86_64
- #cd ich9deblob/x86_64
- #/ich9gen --macaddress XX:XX:XX:XX:XX:XX
- #dd if=ich9fdgbe_8m.bin of=libreboot.rom bs=1 count=12k conv=notrunc #for 8mb chip
- #mv new.rom ../../
- #sudo ./flash update libreboot.rom
-
-
-
-###KGPE-D16
-####General
- (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)
- * 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
- * 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)
-
-####Quirks
- * In GRUB the USB keyboard is unusably slow. Fix: always have a PS/2 keyboard connected, but use the USB keyboard.
-
-####Our Systems
-Debian Stretch
-
-1x 6276 CPU
-
-2x 16GB 1600Mhz Reg-ECC *MT36JSF2G72PZ-1G6E1LG (HP: 672612-081)* [max 32GB/CPU!](https://www.coreboot.org/Board:asus/kgpe-d16/known_bad_configs)
-
-Nvidia GTX 660, Nouveau drivers but crashes when playing videos. Probably my fault however.
-
-For our software configs, see: [[https://github.com/Eliot-Roxbergh/dotFIles/]]
-
-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.
-
-[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)
-
-[Failed flashed try 2 (use Pomona holder), but should be correctly connected](../resources/fail_flash_2.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)
-
-
-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-holder (eg.): 3M IC test socket, DIP 18, 218-3341-00-0602J
-
- 1 CS -> 17 SPIO_CSO (red)
- 2 DO (IO1) -> 21 SPIO_DO (black)
- 3 /WP (IO2) -> 3.3V (yellow)
- 4 GND -> GND (green)
-
- 8 VCC -> 3.3V (blue)
- 7 /HOLD (IO3) -> 3.3V (orange)
- 6 CLK -> 22 SPIO_SCLK (grey)
- 5 DI (IO0) -> 18 (purple)
-
-
- #change background (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
-
- #remember to backup current image if you'd like
- #can read current contents a nr of times and they should be the same
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -r factory.rom
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -r factory1.rom
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -r factory2.rom
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=1024 -r factory3.rom
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=1024 -r factory4.rom
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=1024 -r factory5.rom
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=256 -r factory6.rom
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=256 -r factory7.rom
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=256 -r factory8.rom
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=2048 -r factory9.rom
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=2048 -r factory10.rom
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=2048 -r factory11.rom
- sha512sum factory*.rom #they should be the same..
-
- #Flash ROM (can try different speeds)
- ./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -w ~/libreboot_r20160907_grub_kgpe-d16/kgpe-d16_svenska_txtmode.rom
-
- ## NOTE ##
- # In my case (KGPE-D16) it was very difficult - seemingly at random - to achieve a configuration such as read and write had good reliability.
- # Furthermore, writing had good success rate while reading was more error prone.
- # 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.
-
-##Coreboot
-
-##Fria wifi
-Note that many systems come with proprietary wifi, e g the X200 laptop or the S3 phone. In these cases another wifi chip is needed, either external (micro/)USB or internal.
-
-For hardware recommendations see [[rekommenderat]].
-
-##Fria mobilen
-Sadly phones are proprietary devices that track you.
-Nevertheless, [Replicant](https://www.replicant.us/) are good but slow. An interesting phone in development is [Librem 5](https://puri.sm/shop/librem-5/) (Q1 2019).
-For more hardware recommendations see [[rekommenderat]].
-
-
-We have some experience with Replicant, guides coming (TODO!).