User:Mai

From ParabolaWiki
Jump to: navigation, search
This article is a stub.
This typically means the article is a placeholder for more content to come. Knowledgeable users are encouraged to help expand the article.

1 Status for Samsung Chromebook Plus v1 aka kevin aka gru-kevin aka xe513c24

1.1 Kernel

linux-libre-64 (armv7h) works but needs to be packed correctly to boot, the following is a rough guide on how i was able to boot this kernel on this hardware

1.2 what does not work

- onboard wifi
- probably more stuff

1.3 What you will need

- this laptop :P
- micro sd card at least 2GB, 8+GB reccomended
- another computer that has a linux environment so we can download / extract / pack the kernel and install rootfs

2 Unlock external booting

2.1 Switch to developer mode

  1. Turn off the laptop.
  2. To invoke Recovery mode, you hold down the ESC and Refresh keys and poke the Power button.
  3. At the Recovery screen press Ctrl-D (there’s no prompt - you have to know to do it).
  4. Confirm switching to developer mode by pressing enter, and the laptop will reboot and reset the system. This takes about 10-15 minutes.

Note: After enabling developer mode, you will need to press Ctrl-D each time you boot, or wait 30 seconds to continue booting.

2.2 Enable booting from external storage

  1. After booting into developer mode, hold Ctrl and Alt and poke the F2 key. This will open up the developer console.
  2. Type root to the login screen.
  3. Then type this to enable USB booting:
# crossystem dev_boot_usb=1
# crossystem dev_default_boot=usb

Reboot the system to allow the change to take effect.

Source: https://chromebooks.readthedocs.io/en/latest/source/README.html#switch-to-developer-mode

3 Install packages

pacman -S vboot-utils uboot-tools gptfdisk dtc

4 Gather files

$ mkdir parabola-armv7-64
$ cd parabola-armv7-64

$ wget -c https://redirector.parabola.nu/iso/armv7h-systemd-cli-2020.02/parabola-armv7h-systemd-cli-2020.02-tarball.tar.gz
$ wget -c https://redirector.parabola.nu/iso/armv7h-systemd-cli-2020.02/parabola-armv7h-systemd-cli-2020.02-tarball.tar.gz.sig
$ wget -c https://repomirror.parabola.nu/pool/parabola/linux-libre-64-5.11.11-3-armv7h.pkg.tar.xz
$ wget -c https://repomirror.parabola.nu/pool/parabola/linux-libre-64-5.11.11-3-armv7h.pkg.tar.xz.sig
$ wget -c https://git.parabola.nu/abslibre.git/plain/libre/linux-libre/kernel.keyblock
$ wget -c https://git.parabola.nu/abslibre.git/plain/libre/linux-libre/kernel_data_key.vbprivk


$ gpg --recv-keys FBCC5AD7421197B7ABA72853908710913E8C7778
$ gpg --verify parabola-armv7h-systemd-cli-2020.02-tarball.tar.gz.sig
$ gpg --recv-keys 782F9DDBE36BA7F3D4DE49065F5DFCC14177E263
$ gpg --verify linux-libre-64-5.11.11-3-armv7h.pkg.tar.xz.sig

save the following code as partition_vboot.sh

#!/bin/bash         
                    
DISK="$1"           
                    
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
    echo "This script must be run as root" 1>&2
    exit 1          
fi                  
                    
if [ x"$DISK" == 'x' ]; then
    echo "This script requires a base block device as its only arguement" 1>&2
    echo "example: $0 /dev/sdb"
    exit 1          
fi                  
                    
DISK_DEVICE_NAME="$(echo $DISK | awk -F'/' '{print $NF}')"
if [[ "$DISK_DEVICE_NAME" == *mmcblk* ]]; then
    ROOT_PARTITION="$DISK"p2
    SWAP_PARTITION="$DISK"p3
else
    ROOT_PARTITION="$DISK"2
    SWAP_PARTITION="$DISK"3
fi

# TODO allow specify TOTAL_SECTORS
TOTAL_SECTORS=$(cat /sys/block/$DISK_DEVICE_NAME/size)
SECTOR_SIZE=$(cat /sys/block/$DISK_DEVICE_NAME/queue/hw_sector_size)
                    
# the following are in sectors, 1MB = 2048 sectors
FIRST_GAP_SIZE=8192     # 2048 sectors * 4MB
LAST_GAP_SIZE=2048      # 2048 sectors * 1MB
SWAP_PART_SIZE=8388608  # 2048 sectors * 4096MB
KERNEL_PART_SIZE=65536  # 2048 sectors * 32MB
                    
# layout arithmatic 
FIRST_GAP_START=0   
FIRST_GAP_END=$(( $FIRST_GAP_SIZE - 1 ))
KERNEL_PART_START=$(( $FIRST_GAP_END + 1 ))
KERNEL_PART_END=$(( $FIRST_GAP_END + $KERNEL_PART_SIZE ))
ROOTFS_PART_START=$(( $KERNEL_PART_END + 1 ))
                    
LAST_GAP_END=$(( $TOTAL_SECTORS - 1 ))
LAST_GAP_START=$(( $LAST_GAP_END - $LAST_GAP_SIZE + 1 ))
if [ $TOTAL_SECTORS -lt 10000000 ]; then # if size of disk is less than 5GB do not make swap
    MAKESWAP='false' 
    ROOTFS_PART_END=$(( $LAST_GAP_START - 1 ))
    SWAP_PART_END=0
    SWAP_PART_START=0
else
    MAKESWAP='true' 
    SWAP_PART_END=$(( $LAST_GAP_START - 1 ))
    SWAP_PART_START=$(( $SWAP_PART_END - $SWAP_PART_SIZE + 1 ))
    ROOTFS_PART_END=$(( $SWAP_PART_START - 1 ))
fi

echo "TOTAL_SECTORS     = $TOTAL_SECTORS"
echo "SECTOR_SIZE       = $SECTOR_SIZE"
echo ""
echo "FIRST_GAP_SIZE    = $FIRST_GAP_SIZE"
echo "LAST_GAP_SIZE     = $LAST_GAP_SIZE"
echo "SWAP_PART_SIZE    = $SWAP_PART_SIZE"
echo "KERNEL_PART_SIZE  = $KERNEL_PART_SIZE"
echo ""
echo "FIRST_GAP_START   = $FIRST_GAP_START              $(( $FIRST_GAP_START / 2048 )) MB"
echo "FIRST_GAP_END     = $FIRST_GAP_END"
echo "KERNEL_PART_START = $KERNEL_PART_START    $(( $KERNEL_PART_START / 2048 )) MB"
echo "KERNEL_PART_END   = $KERNEL_PART_END"
echo "ROOTFS_PART_START = $ROOTFS_PART_START    $(( $ROOTFS_PART_START / 2048 )) MB"
echo "ROOTFS_PART_END   = $ROOTFS_PART_END"
echo "SWAP_PART_START   = $SWAP_PART_START      $(( $SWAP_PART_START / 2048 )) MB"
echo "SWAP_PART_END     = $SWAP_PART_END"
echo "LAST_GAP_START    = $LAST_GAP_START       $(( $LAST_GAP_START / 2048 )) MB"
echo "LAST_GAP_END      = $LAST_GAP_END"

# use `sgdisk --list-types' to get all possible type codes
KERNEL_PART_TYPE='7f00'
ROOTFS_PART_TYPE='7f01'
SWAP_PART_TYPE='8200'

# wipe disk, and create new gpt partition table
sgdisk --zap-all $DISK
sgdisk -o $DISK

# create the kernel partition
sgdisk --new=1:$KERNEL_PART_START:$KERNEL_PART_END $DISK
sgdisk --typecode=1:$KERNEL_PART_TYPE $DISK
sgdisk --change-name=1:Kernel $DISK
sgdisk --attributes=1:=:015A000000000000 $DISK

# create the rootfs partition 
sgdisk --new=2:$ROOTFS_PART_START:$ROOTFS_PART_END $DISK
sgdisk --typecode=2:$ROOTFS_PART_TYPE $DISK
sgdisk --change-name=2:Root $DISK
mkfs.ext4 $ROOT_PARTITION

# create the swap partition
if [ $MAKESWAP = 'true' ]; then
    sgdisk --new=3:$SWAP_PART_START:$SWAP_PART_END $DISK
    sgdisk --typecode=3:$SWAP_PART_TYPE $DISK
    sgdisk --change-name=3:Swap $DISK
    mkswap $SWAP_PARTITION
fi

sgdisk --print $DISK
lsblk $DISK

5 partition micro sd card & mount the rootfs partition

partition_vboot.sh is a replacement for cgpt i made that uses sgdisk to create a compatible partition layout for depthcharge chromebooks (asus c201 & samsung chromebook plus v1). I have tested it with cards as small as 2GB, it will automatically make a 4GB swap partition if the size of the disk is detected to be above 4GB, the rest of the disk will be used for the rootfs partition

# sh partition_vboot.sh /dev/sdX

if you dont want to run this script you can follow the partitioning instructions on the archlinuxarm wiki page for this device https://archlinuxarm.org/platforms/armv8/rockchip/samsung-chromebook-plus


after the rootfs partition is created and formated, mount it

# mkdir $MOUNTPOINT
# mount /dev/sdX2 $MOUNTPOINT

6 extract / copy files

# bsdtar -xf parabola-armv7h-systemd-cli-2020.02-tarball.tar.gz -C $MOUNTPOINT
# bsdtar -xf linux-libre-64-5.11.11-3-armv7h.pkg.tar.xz -C $MOUNTPOINT
# cp linux-libre-64-5.11.11-3-armv7h.pkg.tar.xz $MOUNTPOINT/var/cache/pacman/pkg/

# echo > $MOUNTPOINT/etc/fstab

# mkdir $MOUNTPOINT/boot/pack
# cp kernel.keyblock $MOUNTPOINT/boot/pack
# cp kernel_data_key.vbprivk $MOUNTPOINT/boot/pack
# cp $MOUNTPOINT/usr/lib/modules/5.11.11-gnu-3-64-ARCH/vmlinuz $MOUNTPOINT/boot/pack
# cp $MOUNTPOINT/boot/dtbs/linux-libre-64/rockchip/rk3399-gru-kevin.dtb $MOUNTPOINT/boot/pack

# cd $MOUNTPOINT/boot/pack

# lz4 -k vmlinuz
# echo "console=tty0 console=ttyS2,115200n8 earlyprintk=ttyS2,115200n8 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootwait rw noinitrd" > cmdline
# dd if=/dev/zero of=bootloader.bin bs=512 count=1

paste the following code into kernel.its

/dts-v1/;

/ {
    description = "Chrome OS kernel image with one or more FDT blobs";
    images {
        kernel@1{
            description = "kernel";
            data = /incbin/("vmlinuz.lz4");
            type = "kernel_noload";
            arch = "arm64";
            os = "linux";
            compression = "lz4";
            load = <0>;
            entry = <0>;
        };
        fdt@1{
            description = "rk3399-gru-kevin.dtb";
            data = /incbin/("rk3399-gru-kevin.dtb");
            type = "flat_dt";
            arch = "arm64";
            compression = "none";
            hash@1{
                algo = "sha1";
            };
        };
    };
    configurations {
        default = "conf@1";
        conf@1{
            kernel = "kernel@1";
            fdt = "fdt@1";
        };
    };
};
# mkimage -f kernel.its kernel.itb

if you see the following error message, just ignore, it will still work

kernel.its:6.17-15.11: Warning (unit_address_vs_reg): /images/kernel@1: node has a unit name, but no reg or ranges property
kernel.its:16.14-25.11: Warning (unit_address_vs_reg): /images/fdt@1: node has a unit name, but no reg or ranges property
kernel.its:22.19-24.15: Warning (unit_address_vs_reg): /images/fdt@1/hash@1: node has a unit name, but no reg or ranges property
kernel.its:29.15-32.11: Warning (unit_address_vs_reg): /configurations/conf@1: node has a unit name, but no reg or ranges property
mkimage: verify_header failed for FIT Image support with exit code 1

and paste the following code into pack_vboot.sh

futility --debug vbutil_kernel \
         --pack vmlinux.kpart \
         --version 1 \
         --vmlinuz kernel.itb \
         --arch aarch64 \
         --keyblock kernel.keyblock \
         --signprivate kernel_data_key.vbprivk \
         --config cmdline \
         --bootloader bootloader.bin

Now run the following commands:

# sh pack_vboot.sh
# dd if=vmlinux.kpart of=/dev/sdX1
# cd
# umount $MOUNTPOINT

7 Boot!

it should boot up. (press ctrl+u at the white bios screen if it still boots into chromeos)

login as root

in order to update the system you will need some way to connect to the internet, i am using a usb-c ethernet adapter https://www.amazon.com/Nekteck-Ethernet-Compatible-Pixelbook-Thunderbolt/dp/B0749DCDRV/

plug in the usb ethernet and dhcp should assign an ip

then sync the time

# systemctl restart systemd-timesyncd.service
# pacman -Sy
# pacman -S archlinux-keyring archlinux32-keyring archlinuxarm-keyring parabola-keyring

it will fail because of keyring, but you downloaded it!

# pacman -U /var/cache/pacman/pkg/*-keyring-*
# pacman -S archlinux-keyring archlinux32-keyring archlinuxarm-keyring parabola-keyring
# pacman -S archlinux-keyring archlinux32-keyring archlinuxarm-keyring parabola-keyring

TODO: get pacman-key --refresh to work. try: https://wiki.parabola.nu/Parabola_Keyring

as an alternative temporary way around, we will just disable signature checking for this test environment.

sed -i '/^SigLevel.*/SigLevel = Never/' /etc/pacman.conf
# pacman -S linux-libre-64 --overwrite '/*'
# pacman -Su linux-libre-firmware acpi vim nano networkmanager

8 Bonus extra info

8.1 make your own debug port breakout

I dont know where to get a servo board but the you can make your own debug header breakout to get serial console access / early boot logs etc

the breakout https://www.amazon.com/Proto-Advantage-DR040D254P050-50-Pin-Connector-Adapter/dp/B097S2268V or https://www.ebay.com/itm/202502988342

the connector https://www.digikey.com/en/products/detail/panasonic-electric-works/AXK850145WG/1986616

usb <--> rs232 https://www.amazon.com/HiLetgo-CP2102-Converter-Adapter-Downloader/dp/B00LODGRV8 (get 2)

servo connector pinout is described in this pdf (page 14) (V2 DEBUG HEADER)

https://www.chromium.org/chromium-os/servo/810-10010-03_20120227_servo_SCH_0.pdf

you can use a continuity meter to determine connector orientation by finding the corner pin that is ground



 PIN-33 UART1_DUT_SERVO_TX --+       +-- PIN-17 UART2_DUT_SERVO_TX
                             |       |
                             |       |
                             |       |
                  49         vG      vG      G 1
                     |||||||||||||||||||||||||
                     9753197531975319753197531
                     1234567890123210987654321
                     0864208642086420864208642
                     |||||||||||||||||||||||||
                  50     G  G ^     G ^   G    2
                              |       |
                              |       |
                              |       |
  PIN-32 UART1_SERVO_DUT_TX --+       +-- PIN-16 UART2_SERVO_DUT_TX


                 GND PINS = 1, 8, 15, 20, 31, 36, 42

8.2 set bios boot timeout to 2 seconds

https://old.reddit.com/r/Crouton/comments/2szn59/how_to_shorten_os_verfication_warning_screen_on/

https://old.reddit.com/r/chromeos/comments/6j5ig9/chromebook_pro_hardware_writeprotect/dll73kq/

install package from aur flashrom-chromeos

info about gbb flags

/* Flags for .flags field */
/* Reduce the dev screen delay to 2 sec from 30 sec to speedup factory. */
#define GBB_FLAG_DEV_SCREEN_SHORT_DELAY		0x00000001
/*
 * BIOS should load option ROMs from arbitrary PCI devices. We'll never enable
 * this ourselves because it executes non-verified code, but if a customer
 * wants to void their warranty and set this flag in the read-only flash, they
 * should be able to do so.
 */
#define GBB_FLAG_LOAD_OPTION_ROMS			0x00000002
/*
 * The factory flow may need the BIOS to boot a non-ChromeOS kernel if the
 * dev-switch is on. This flag allows that.
 */
#define GBB_FLAG_ENABLE_ALTERNATE_OS			0x00000004
/* Force dev switch on, regardless of physical/keyboard dev switch position. */
#define GBB_FLAG_FORCE_DEV_SWITCH_ON			0x00000008
/* Allow booting from USB in dev mode even if dev_boot_usb=0. */
#define GBB_FLAG_FORCE_DEV_BOOT_USB			0x00000010
/* Disable firmware rollback protection. */
#define GBB_FLAG_DISABLE_FW_ROLLBACK_CHECK		0x00000020
/* Allow Enter key to trigger dev->tonorm screen transition */
#define GBB_FLAG_ENTER_TRIGGERS_TONORM			0x00000040
/* Allow booting Legacy OSes in dev mode even if dev_boot_legacy=0. */
#define GBB_FLAG_FORCE_DEV_BOOT_LEGACY			0x00000080
/* Allow booting using alternate keys for FAFT servo testing */
#define GBB_FLAG_FAFT_KEY_OVERIDE			0x00000100
/* Disable EC software sync */
#define GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC		0x00000200
/* Default to booting legacy OS when dev screen times out */
#define GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY		0x00000400
/* Disable PD software sync */
#define GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC		0x00000800
/* Disable shutdown on lid closed */
#define GBB_FLAG_DISABLE_LID_SHUTDOWN			0x00001000
/*
 * Allow full fastboot capability in firmware even if
 * dev_boot_fastboot_full_cap=0.
 */
#define GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP	0x00002000
/* Enable serial console */
#define GBB_FLAG_ENABLE_SERIAL				0x00004000

source: https://chromium.googlesource.com/chromiumos/platform/vboot/+/master/_vboot_reference/firmware/include/gbb_header.h

8.3 blobless coreboot / etc

https://gitlab.com/vicencb/kevinboot/