File:  [NetBSD Developer Wiki] / wikisrc / ports / evbarm / tegra-chromebook.mdwn
Revision 1.2: download - view: text, annotated - select for diffs
Thu Apr 27 22:07:03 2017 UTC (4 years, 3 months ago) by jmcneill
Branches: MAIN
CVS tags: HEAD
Fix links

[[!meta title="Tegra K1 Chromebook"]]

# Models
 - Acer Chromebook CB5-311 (*nyan-big*)

# Bootloader

The built-in bootloader is Depthcharge, which is deployed as a Coreboot payload. To boot from USB, you first need to [enable developer mode](https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices/acer-cb5-311-chromebook-13#TOC-Developer-Mode).

Once developer mode is enabled, you can press Ctrl-U to boot from a USB storage device.

# USB storage device setup

When booting from USB, the bootloader looks for a signed Flat Image Tree (FIT) written to a GPT partition of type fe3a2a5d-4f32-41a7-b725-accc3285a309 (*ChromeOS kernel*). The following commands (on Linux) can be used to prepare the device:

[[!template  id=programlisting text="""
DEV=/dev/sdb
sudo parted --script ${DEV} mklabel gpt
sudo cgpt create ${DEV}
sudo cgpt add -t kernel -l kernel -b 32 -s 32768 ${DEV}
sudo cgpt add -i 1 -S 1 -T 5 -P 1 ${DEV}
sudo blockdev --rereadpt ${DEV}
"""]]

The signed image can now be written to partition 1 of the device (*/dev/sdb1* in this example).

# Creating the Flat Image Tree (FIT)

The bootloader loads the FIT at 0x81000000. The "kernel" image within the fit is not relocated, so you will need to carefully pad the FIT image and adjust the base of your image to match.

The following .its script creates an image that results in an image that loads the "kernel" at 0x81000100.

[[!template  id=programlisting text="""
/dts-v1/;

/ {
    description = "U-Boot + FDT --------- THIS PADDING IS NEEDED SO THE IMAGE STARTS AT THE RIGHT OFFSET";
    #address-cells = <1>;
    images {
        kernel@1{
            description = "kernel";
            data = /incbin/("u-boot-dtb.bin");
            type = "kernel_noload";
            arch = "arm";
            os = "linux";
            compression = "none";
            load = <0>;
            entry = <0>;
        };
        fdt@1{
            description = "tegra124-nyan-big.dtb";
            data = /incbin/("dts/dt.dtb");
            type = "flat_dt";
            arch = "arm";
            compression = "none";
            hash@1{
                algo = "sha1";
            };
        };
    };
    configurations {
        default = "conf@1";
        conf@1{
            kernel = "kernel@1";
            fdt = "fdt@1";
        };
    };
};
"""]]

When building U-Boot, you need to set *CONFIG_SYS_TEXT_BASE* to 0x81000100 in *include/configs/tegra124-common.h*.

For the NetBSD kernel, set *KERNEL_BASE_PHYS* and *KERNEL_BASE_PHYS* to 0x81000100 in *sys/arch/evbarm/conf/std.tegra*.

To create the FIT image with this script, use *mkimage*:

[[!template  id=programlisting text="""
$ mkimage -f u-boot.its u-boot.fit
"""]]

# Signing the image

To sign the image, use the *vbutil_kernel* tool from Google's [Verified Boot reference implementation](https://chromium.googlesource.com/chromiumos/platform/vboot_reference/).

[[!template  id=programlisting text="""
$ vbutil_kernel --pack u-boot.signed \
    --keyblock devkeys/kernel.keyblock \
    --version 1 \
    --signprivate devkeys/kernel_data_key.vbprivk \
    --vmlinuz u-boot.fit \
    --arch arm
"""]]

# Other issues

## LPAE is enabled by the bootloader

U-Boot and the NetBSD kernel will get confused by LPAE being enabled when chainloaded from Coreboot.

[A patch for U-Boot](https://git.collabora.com/cgit/user/tomeu/u-boot.git/commit/?h=nyan-big&id=fe558a35ea61396edae885e8aeb4f3502f687333) is available to correct this issue. A similar patch could be made to *arch/evbarm/tegra/tegra_start.S*.

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb