2015-04-16

The bootloader, chained


OK, I guess it's high time I wrote about this because it's a bitch to collect all the different bits.

Current u-boot does support Snow board out of the box.
  • it can boot zImage
  • supports simplefb
  • you can hack it easily.
Installing u-boot in the SPI NOR flash has its issues
  • no support for accessing the flash under Linux out of the box (ALARM has some flashroom-google worth looking at and u-boot can access the flash).
  • part of the flash with the bootloader is readonly unless you take apart the chromebook and remove write protection
  • if you have no means accessing the flash offline from other system you might render your chromebook unbootable if you write wrong bootloader image in the flash
As workaround you can chainload u-boot packaged as Linux kernel from the existing u-boot in the onboard flash. There is a guide which kind of does not exactly apply to current u-boot. First you will need to build an u-boot for snow.
git clone git://git.denx.de/u-boot.git
cd u-boot
The u-boot preinstalled in flash has a bug that clobbers some memory so you need to change load address of u-boot using this patch. Since the patch does not apply to mainline you should apply it by hand. You can see that CONFIG_SYS_TEXT_BASE is set in include/configs/exynos5250-common.h so change it to 0x42400000
$ git grep -i 0x43e00000 | grep exynos
include/configs/exynos5250-common.h:#define CONFIG_SYS_TEXT_BASE        0x43E00000
$ vi include/configs/exynos5250-common.h
$ git diff
diff --git a/include/configs/exynos5250-common.h b/include/configs/exynos5250-common.h
index ae0e5ff..4226043 100644
--- a/include/configs/exynos5250-common.h
+++ b/include/configs/exynos5250-common.h
@@ -14,7 +14,7 @@
 #define CONFIG_EXYNOS5250

 #define CONFIG_SYS_SDRAM_BASE          0x40000000
-#define CONFIG_SYS_TEXT_BASE           0x43E00000
+#define CONFIG_SYS_TEXT_BASE           0x42400000

 /* MACH_TYPE_SMDK5250 macro will be removed once added to mach-types */
 #define MACH_TYPE_SMDK5250             3774
$ make ARCH=arm snow_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j6
This should produce  u-boot-dtb.bin To make this image bootable as linux kernel you first package it as uImage with load address as defined in CONFIG_SYS_TEXT_BASE. This uImage can then be signed and loaded as the kernel uImage. Use a dummy text file to make the sign tool happy that all pieces have been provided.
mkimage -A arm -O linux -T kernel -C none -a 0x42400000 -e 0x42400000 -n "u-boot" -d u-boot.dtb.bin u-boot-dtb.uImage
echo blah > dummy.txt
vbutil_kernel \
--pack u-boot.part \
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
--version 1 \
--vmlinuz u-boot-dtb.uImage \
--config dummy.txt \
--arch arm
Now writing u-boot.part to a kernel partition should produce a bootable medium.


No comments:

Post a Comment