by relghuar » Wed Feb 20, 2013 10:34 pm
$this->bbcode_second_pass_quote('stronnag', 'A')ny chance of an idoit's guide to nv-u-boot. I get the install on a KERN partition bit. How then do I configure it to pick up the root file system and Arch kernel? It would nice not to be building my own kernels and the vbutil_kernel / dd dance.
I installed nv-u-boot yesterday/today... One thing you'll have to do is create additional vfat or ext2 partition, nv-u-boot can't work with ext4 filesystem (not sure about ext3 though). This is my partitioning:
$this->bbcode_second_pass_code('', '
root@toaster-cb:~# gdisk -l /dev/mmcblk0
GPT fdisk (gdisk) version 0.8.6
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Disk /dev/mmcblk0: 30777344 sectors, 14.7 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): AFEB3EED-438B-4227-8820-940193D49399
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 30777310
Partitions will be aligned on 2048-sector boundaries
Total free space is 8158 sectors (4.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 8192 20479 6.0 MiB 7F00 kernel
2 20480 73727 26.0 MiB 8300 boot
3 73728 30777310 14.6 GiB 8300 root
root@toaster-cb:~# cgpt show /dev/mmcblk0
start size part contents
0 1 PMBR (Boot GUID: 7B55EB04-42BA-8C43-90E0-591F07EDF5BA)
1 1 Pri GPT header
2 32 Pri GPT table
8192 12288 1 Label: "kernel"
Type: ChromeOS kernel
UUID: BF883A91-81E4-4DAD-B6B5-49E7F0834873
Attr: priority=10 tries=15 successful=1
20480 53248 2 Label: "boot"
Type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
UUID: A2B7D37F-A9DC-46AA-9814-91A1D30BEFD0
73728 30703583 3 Label: "root"
Type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
UUID: B83F0A55-F580-418A-B42F-3AEE0D64F787
30777311 32 Sec GPT table
30777343 1 Sec GPT header
root@toaster-cb:~# mount
/dev/root on / type ext4 (rw,relatime,data=ordered)
/dev/mmcblk0p2 on /boot type ext2 (rw,relatime,errors=continue,user_xattr,acl)
')
6MB is more than enough for a full kernel image, definitely overkill for u-boot
But then some 26MB are also more than enough to store some boot scripts and kernel image on ext2 partition that u-boot can actually load it from, and this way I didn't have to touch my rootfs at all.
I have /dev/mmcblk0p2 mounted in /boot through /etc/fstab, so vmlinux.uimg lands there automatically on every update:
$this->bbcode_second_pass_code('', 'root@toaster-cb:~# ls -al /boot
total 4042
drwxr-xr-x 3 root root 1024 Feb 20 22:23 .
drwxr-xr-x 21 root root 4096 Feb 20 17:58 ..
-rw-r--r-- 1 root root 273 Feb 20 22:17 boot.scr
-rw-r--r-- 1 root root 345 Feb 20 22:17 boot.scr.uimg
drwx------ 2 root root 12288 Feb 20 16:25 lost+found
-rwxr-xr-x 1 root root 82 Feb 20 18:16 mkbootscr.sh
-rw-r--r-- 1 root root 4100620 Feb 19 20:17 vmlinux.uimg
root@toaster-cb:~# cat /boot/boot.scr
setenv bootargs 'cros_legacy console=ttySAC3,115200 console=tty8 debug earlyprintk ignore_loglevel oops=panic panic=30 sysrq_always_enabled root=/dev/mmcblk0p3 rootwait rw init=/sbin/init fbcon=scrollback:512k'
ext2load mmc 0:2 ${loadaddr} /vmlinux.uimg
bootm ${loadaddr}
root@toaster-cb:~# cat /boot/mkbootscr.sh
#!/bin/bash
mkimage -A arm -O linux -T script -C none -d boot.scr boot.scr.uimg
')
Now all you have to do is call mkbootscr.sh every time you change boot.scr (requires uboot-mkimage package), and a bit of tweaking in u-boot directly to automatically load that script and execute it , something like:
$this->bbcode_second_pass_code('', '
setenv bootcmd 'mmc dev 0; ext2load mmc 0:2 ${loadaddr} /boot.scr.uimg; source ${loadaddr}'
saveenv
')
It certainly helps to have an SD card ready with bootable system in case something goes wrong along the way
One thing I find very funny about nv-u-boot - its saveenv command actually writes custom configuration to chromebook's SPI Flash - same one used to store read-only firmware... shouldn't that be hardware write protected by the screw in the back?? Well, perhaps not all of it is protected. One day I'll have to find those uart3 pins in the ugly unpopulated debug connector next to sd card slot, then I may find courage to actually write the nv-u-boot to spi flash directly and get rid of that stupid verified boot completely!
Have fun!
rel