From Fedora Project Wiki
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:


== EXYNOS 2012 chromebook notes ==
== TEGRA K1 Nyan (Acer 2014) Chromebook notes ==
 
Assume developer mode has already been unlocked.
 
Copy the installed ChromeOS kernel to temp
<pre>
# dd if=/dev/mmcblk0p2 of=/tmp/kern-a
# dd if=/dev/mmcblk0p4 of=/tmp/kern-b
</pre>
 
 
Create a text file containing kernel cmdline parameters
(the rootfs will certainly need customization)
<pre>
# cat <<EOF > /tmp/cmdline.txt
console=tty1 debug verbose root=PARTUUID=83999adc-bd67-417e-bd9c-5e7d0aac6aa0 rootwait rw lsm.module_locking=0 selinux=0 audit=0
EOF
</pre>
 
NOTE: use blkid(1) to findout your rootfs PARTUUID or PARTLABEL. Very important because we do not have an initrd, so referencing the rootfs by UUID does not work. You can simply go with the device directly (E.G. /dev/mmcblk1p5) instead of referencing by PARTUUID or PARTLABEL.
 
Repack the ChromeOS kernel with your cmdline file:
<pre>
# vbutil_kernel --repack /tmp/kern-a-repack \
                --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
                --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
                --oldblob /tmp/kern-a --config /tmp/cmdline.txt
</pre>
 
You can verify the new cmdline settings are happy in the repacked kernel
<pre>
# vbutil_kernel --verbose --verify /tmp/kern-a-repack
</pre>
 
Write the kernel to the boot partition of your sdcard
<pre>
# dd if=/tmp/kern-a-repack of=/dev/mmcblk1p5
</pre>
 
 
Make sure the boot partition has high priority
<pre>
# cgpt add -i 1 -P 15 /dev/mmcblk1
</pre>
 
NOTE: consider lowering the priority of any other boot partitions if they were of equal priority here
 
 
Ok, so.. that is how you repack a chromeOS kernel using vboot_util in ChromeOS.
This will get you started porting Fedora to the Chromebook.
The logical next step is to get Fedora booting, git clone the chromeos kernel vendor tree, and rebuild.
I always start by disabling chromeos security, and enabling SELinux/Auditing.
 
== EXYNOS 5240 (Samsung 2012) Chromebook notes ==


Assume the chromebook in developer mode.
Assume the chromebook in developer mode.
Line 23: Line 76:
<pre>
<pre>
# dd if=/dev/mmcblk0p4 of=/tmp/kern-b.img conv=fsync
# dd if=/dev/mmcblk0p4 of=/tmp/kern-b.img conv=fsync
...
. . .
</pre>
</pre>


Line 29: Line 82:


<pre>
<pre>
cat <<-EOF > /tmp/cmdline
# cat <<-EOF > /tmp/cmdline
console=tty1 debug verbose root=/dev/mmcblk1p1 rootwait rw lsm.module_locking=0
console=tty1 debug verbose root=/dev/mmcblk1p1 rootwait rw lsm.module_locking=0
EOF
EOF
Line 37: Line 90:


<pre>
<pre>
vbutil_kernel --repack /tmp/kern-b-repack.img \
# vbutil_kernel --repack /tmp/kern-b-repack.img                               \
  --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
                --version    1                                                \
  --version 1 \
                --config=/tmp/config                                          \
  --signprivate \
                --oldblob /tmp/kern-b.img                                      \
      /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
                --keyblock   /usr/share/vboot/devkeys/kernel.keyblock         \
  --config=/tmp/config \
                --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk
  --oldblob /tmp/kern-b.img
</pre>
</pre>


Line 54: Line 106:
</pre>
</pre>


Extract the rootfs:


<pre>
# unxz -v Fedora-Xfce-armhfp-22_Beta-3-sda.raw.xz
. . .
</pre>




Map the partitions:


<pre>
# kpartx -avp _fedora_  Fedora-Xfce-armhfp-22_Beta-3-sda.raw
</pre>


Extract the rootfs:


<pre>


# sudo dd if=/dev/mapper/loop0_fedora_3 \
          of=/tmp/Fedora-Xfce-armhfp-22_Beta-3.ext4 \
        conv=fsync


</pre>




Dismount the Fedora ARM disk image:


 
<pre>
 
# kpartx -dvp _fedora_  Fedora-Xfce-armhfp-22_Beta-3-sda.raw
 
</pre>


== OMAP5 uEVM notes ==
== OMAP5 uEVM notes ==

Latest revision as of 04:36, 8 October 2015

TEGRA K1 Nyan (Acer 2014) Chromebook notes

Assume developer mode has already been unlocked.

Copy the installed ChromeOS kernel to temp

# dd if=/dev/mmcblk0p2 of=/tmp/kern-a
# dd if=/dev/mmcblk0p4 of=/tmp/kern-b


Create a text file containing kernel cmdline parameters (the rootfs will certainly need customization)

# cat <<EOF > /tmp/cmdline.txt
console=tty1 debug verbose root=PARTUUID=83999adc-bd67-417e-bd9c-5e7d0aac6aa0 rootwait rw lsm.module_locking=0 selinux=0 audit=0
EOF

NOTE: use blkid(1) to findout your rootfs PARTUUID or PARTLABEL. Very important because we do not have an initrd, so referencing the rootfs by UUID does not work. You can simply go with the device directly (E.G. /dev/mmcblk1p5) instead of referencing by PARTUUID or PARTLABEL.

Repack the ChromeOS kernel with your cmdline file:

# vbutil_kernel --repack /tmp/kern-a-repack \
                --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
                --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
                --oldblob /tmp/kern-a --config /tmp/cmdline.txt

You can verify the new cmdline settings are happy in the repacked kernel

# vbutil_kernel --verbose --verify /tmp/kern-a-repack

Write the kernel to the boot partition of your sdcard

# dd if=/tmp/kern-a-repack of=/dev/mmcblk1p5


Make sure the boot partition has high priority

# cgpt add -i 1 -P 15 /dev/mmcblk1

NOTE: consider lowering the priority of any other boot partitions if they were of equal priority here


Ok, so.. that is how you repack a chromeOS kernel using vboot_util in ChromeOS. This will get you started porting Fedora to the Chromebook. The logical next step is to get Fedora booting, git clone the chromeos kernel vendor tree, and rebuild. I always start by disabling chromeos security, and enabling SELinux/Auditing.

EXYNOS 5240 (Samsung 2012) Chromebook notes

Assume the chromebook in developer mode.

Extract the chromeos kernel:

This used to be easy, ChromeOS no longer places the kernel in /boot. So you will extract the kernel from the partition. The Chromebook has three kernel partitions.

# cgpt show /dev/mmcblk0 | awk '/KERN/||/Attr/'
       20480       32768       2  Label: "KERN-A"
                                  Attr: priority=2 tries=0 successful=1
       53248       32768       4  Label: "KERN-B"
                                  Attr: priority=1 tries=0 successful=1
       16448           1       6  Label: "KERN-C"
                                  Attr: priority=0 tries=15 successful=0

KERN-B on partition 4 appears to contain the active boot kernel. So just extract the whole partition to a file.

# dd if=/dev/mmcblk0p4 of=/tmp/kern-b.img conv=fsync
. . .

Write down the Fedora kernel cmdline to a file.

# cat <<-EOF > /tmp/cmdline
console=tty1 debug verbose root=/dev/mmcblk1p1 rootwait rw lsm.module_locking=0
EOF

Repack the ChromeOS kernel:

# vbutil_kernel --repack /tmp/kern-b-repack.img                                \
                --version     1                                                \
                --config=/tmp/config                                           \
                --oldblob /tmp/kern-b.img                                      \
                --keyblock    /usr/share/vboot/devkeys/kernel.keyblock         \  
                --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk

Download the latest Fedora image of your choice: http://mirrors.kernel.org/fedora/releases/test/22_Beta/Images/armhfp/


$ wget http://mirrors.kernel.org/fedora/releases/test/22_Beta/Images/armhfp/Fedora-Xfce-armhfp-22_Beta-3-sda.raw.xz

Extract the rootfs:

# unxz -v Fedora-Xfce-armhfp-22_Beta-3-sda.raw.xz
. . .


Map the partitions:

# kpartx -avp _fedora_  Fedora-Xfce-armhfp-22_Beta-3-sda.raw

Extract the rootfs:


# sudo dd if=/dev/mapper/loop0_fedora_3 \
          of=/tmp/Fedora-Xfce-armhfp-22_Beta-3.ext4 \
        conv=fsync


Dismount the Fedora ARM disk image:

# kpartx -dvp _fedora_  Fedora-Xfce-armhfp-22_Beta-3-sda.raw

OMAP5 uEVM notes

Fedora 20 uENV.txt:

setenv bootm_size 0x20000000
setenv bootargs console=${console} vram=${vram} root=LABEL=_/ ro rootwait rhgb
ext4load mmc 0:3 0x82000000 /boot/vmlinuz-3.14.0-0.rc6.git4.1.fc21.armv7hl
ext4load mmc 0:3 0x88080000 /boot/uInitrd-3.14.0-0.rc6.git4.1.fc21.armv7hl
ext4load mmc 0:3 0x88000000 /boot/dtb-3.14.0-0.rc6.git4.1.fc21.armv7hl/omap5-uevm.dtb
bootz 0x82000000 0x88080000 0x88000000

Hopefully this table of uEVM sysboot jumper cofigurations saves somebody time. I was forced to research these settings in the TI technical reference manual. The following is from a text file I keep in my homedir:



                     TI OMAP-5432 uEVM sysboot table
      --------------------------------------------------------------
      |        SYSBOOT [3:0]        |      BOOT DEVICE ORDER       |
      |-----------------------------|------------------------------|
      |   1    2    3    4   | 3210 | 1st      | 2nd     | 3rd     |
      |----------------------|------|----------|---------|---------|
    A |  off  off  off  off  | 0000 | USB      | eMMC    | N/A     | P
    B |   on  off  off  off  | 0001 | USB      | NAND    | N/A     | e
   *C |  off   on  off  off  | 0010 | USB      | SD      | eMMC    | r
    D |   on   on  off  off  | 0011 | USB      | SATA    | SD      | i
    E |  off  off   on  off  | 0100 | USB      | UART    | XIP     | p
    F |   on  off   on  off  | 0101 | UART     | OneNAND | N/A     | h
      |----------------------|------|------------------------------| e
    G |  off   on   on  off  | 0110 |           Reserved           | r
      |----------------------|------|------------------------------| a
    H |   on   on   on  off  | 0111 | Fast-XIP | UART    | USB     | l
      |----------------------|------|----------|---------|---------|
      |----------------------|------|----------|---------|---------|
    I |  off  off  off   on  | 1000 | eMMC     | USB     | N/A     | 
    J |   on  off  off   on  | 1001 | NAND     | USB     | N/A     | M
   *K |  off   on  off   on  | 1010 | SD       | eMMC    | USB     | e
   *L |   on   on  off   on  | 1011 | SATA     | SD      | USB     | m
    M |  off  off   on   on  | 1100 | XIP      | USB     | UART    | o
    N |   on  off   on   on  | 1101 | OneNAND  | UART    | N/A     | r
      |----------------------|------|------------------------------| y
    O |  off   on   on   on  | 1110 |           Reserved           |
      |----------------------|------|------------------------------|
    P |   on   on   on   on  | 1111 | Fast-XIP | UART    | USB     |
      --------------------------------------------------------------
         Reference: http://www.ti.com/lit/ug/swcu130/swcu130.pdf


Remarks:
 
 The most significant bit (jumper 4) broadly determines if the ROM looks for bootstrap from 
 'peripheral device' or 'memory device' on 1st boot device

 Configuration K is probably the most flexible configuration.

 Configurations that support an external SD card have been noted with *

Fedora 21/rawhide notes

Install MLO and u-boot on non-vfat image: WARNING: BETA NOTES


sudo dd if=MLO           \
        of=/dev/sdz      \
      conv=fsync,notrunc \
      seek=128k

sudo dd if=u-boot.img    \
        of=/dev/sdz      \
     count=2             \
      seek=1             \
      conv=notrunc,fsync \
        bs=384k


F20 notes

  • download the f20 minimal image
wget http://download.fedoraproject.org/pub/fedora/linux/releases/20/Images/armhfp/Fedora-Minimal-VFAT-armhfp-20-1-sda.raw.xz
  • Decompress
unxz -v Fedora-Minimal-VFAT-armhfp-20-1-sda.raw.xz


  • Map the partitions
kpartx -avp _fedora_  Fedora-Minimal-VFAT-armhfp-20-1-sda.raw


  • Extract the rootfs
dd if=/dev/mapper/loop0_fedora_3 \
   of=f20-minimal-rootfs.ext4    \
 conv=fsync


  • Fix the Fedora rootfs image

(They have really weird filesystem labels)

tune2fs -L rootfs -m0 -r0 f20-minimal-rootfs.ext4 


  • Unmap the partitions
kpartx -dvp _fedora_  Fedora-Minimal-VFAT-armhfp-20-1-sda.raw


  • Optionally discard the official Fedora minimal image, we now have the essential rootfs.


  • Shrink the rootfs image file
e2fsck    -f  f20-minimal-rootfs.ext4 &> /dev/null
resize2fs -M  f20-minimal-rootfs.ext4


  • Create a new f20 disk image file
truncate -s 2G f20-minimal.disk


  • Partition the newly created VFAT disk image
parted -s -- f20-minimal.disk mklabel msdos
parted -s -- f20-minimal.disk unit MiB mkpart primary fat16       4  24
parted -s -- f20-minimal.disk unit MiB mkpart primary linux-swap 24 152
parted -s -- f20-minimal.disk unit MiB mkpart primary ext2      152  -1
parted -s -- f20-minimal.disk set 1 boot on


  • Map the partitions to loop devices
kpartx -avp _remix_ f20-minimal.disk


  • Format the partitions accordingly to the output of the previous kpartx cmd.
mkfs.vfat -n uboot -F 16              /dev/mapper/loop0_remix_1

mkswap -L swap -U $(uuidgen)          /dev/mapper/loop0_remix_2

#mkfs.ext4 -L rootfs -U $(uuidgen) -m0 /dev/mapper/loop0_remix_3


  • Copy the Fedora-20 minimal rootfs to the appropriate partition
dd if=f20-minimal-rootfs.ext4   \
   of=/dev/mapper/loop0_remix_3 \
   bs=4M conv=fsync 


  • Inflate the rootfs on the partition
resize2fs -fp /dev/mapper/loop0_remix_3


  • Mount the rootfs filesystem
mkdir /tmp/rootfs/
mount /dev/mapper/loop0_remix_3  /tmp/rootfs/
mount /dev/mapper/loop0_remix_1  /tmp/rootfs/boot/uboot/


  • Create the /etc/fstab
cat <<EOF > /tmp/rootfs/etc/fstab
UUID=$(blkid  -sUUID -o value /dev/mapper/loop0_remix_1)   /boot/uboot    vfat    defaults            1 2
UUID=$(blkid  -sUUID -o value /dev/mapper/loop0_remix_2)   swap           swap    defaults            0 0
UUID=$(blkid  -sUUID -o value /dev/mapper/loop0_remix_3)   /              ext4    defaults,discard    1 1
EOF

NOTE: you could optionally choose to use the LABLE format (non vfat only):

UUID=$(blkid  -sUUID -o value /dev/mapper/loop0_remix_1)   /boot/uboot    vfat    defaults            1 2
LABEL=swap    swap           swap    defaults            0 0
LABEL=rootfs  /              ext4    defaults,discard    1 1


  • Copy into place Das U-boot files for the board (in this example TI uEVM)

cp /tmp/rootfs{/usr/share/uboot-uevm/*,/boot/uboot/}


cat <<EOF > /tmp/rootfs/boot/uboot/uEnv.txt
# uEVM omap5
setenv bootm_size 0x20000000
setenv bootargs console=\${console} vram=\${vram} root=$(awk '/ \/ / {print $1}' /tmp/rootfs/etc/fstab) ro rootwait
ext4load mmc 0:3 0x82000000 /boot/vmlinuz-3.11.10-301.fc20.armv7hl
ext4load mmc 0:3 0x88080000 /boot/uInitrd-3.11.10-301.fc20.armv7hl
ext4load mmc 0:3 0x88000000 /boot/dtb-3.11.10-301.fc20.armv7hl/omap5-uevm.dtb
bootz 0x82000000 0x88080000 0x88000000
EOF


  • Unmap the partition loops devs
kpartx -dvp _remix_ f20-minimal.disk

Tips & Tricks

You can monitor the DD command in an easy one liner.

dd if=/dev/sdc3 of=f20-minimal-rootfs.ext4-ORIG &   while ps -p $! &>/dev/null ; do kill -USR1 $! ; sleep 5 ; done

This signals the DD process to spew progress info every five seconds. Especially useful on very slow sdcard, or large data transfers.


Use fsync with DD to avoid potentially dangerous filesystem buffer cache issues. My computers have large amounts of memory, and it is possible an entire file would be buffered into filesystem cache. The effect is the DD write operation appearing to finish very fast, but the filesystem empty the buffer/cache in the background asynchronously. This is like typing "sync" after the DD command, but instead happens during writes.


dd if=/dev/foo
   of=/dev/bar
 conv=[fsync|fdatasync]




Here is a script that I use all the time. It installs a kernel onto an sdcard via chroot. Handy for board bring-up when you might want to try a rawhide kernel on the board.

#!/bin/bash

set -x
set -e

function cleanup {
  umount -R /tmp/rootfs/{dev,sys,proc,boot/uboot,}
}

trap cleanup EXIT


# About the time of f21 branching from rawhide
kernel=https://kojipkgs.fedoraproject.org//packages/kernel/3.16.0/0.rc4.git3.1.fc21/armv7hl/kernel-3.16.0-0.rc4.git3.1.fc21.armv7hl.rpm
modules=https://kojipkgs.fedoraproject.org//packages/kernel/3.16.0/0.rc4.git3.1.fc21/armv7hl/kernel-modules-3.16.0-0.rc4.git3.1.fc21.armv7hl.rpm
kerncore=https://kojipkgs.fedoraproject.org//packages/kernel/3.16.0/0.rc4.git3.1.fc21/armv7hl/kernel-core-3.16.0-0.rc4.git3.1.fc21.armv7hl.rpm

dev="/dev/sdb"
chroot='/tmp/rootfs/'

test -b "$dev"
case $? in
 0) printf 'found sdcard on ${dev}\n' ;;
 *) printf 'insert card and try again\n'
    exit 255 ;;
esac


mkdir -p "$chroot" || true
mount  ${dev}3  "$chroot" 
mount  ${dev}1  "${chroot}/boot/uboot"

mount -t proc proc ${chroot}/proc
mount -t sysfs sys ${chroot}/sys/
mount -o mode=0755 -t devtmpfs dev ${chroot}/dev

if [ ! -f "${chroot}/root/${kernel##*/}" ]
  then
       wget -P ${chroot}/root/ "$kernel" \
                               "$modules"\
                               "$kerncore"
fi
chroot "$chroot" rpm -ivh --force /root/${kerncore##*/} \
                                  /root/${modules##*/} \
                                  /root/${kernel##*/}

#chroot "$chroot" rpm -q ${kernel##*/}


kernel=${kernel##*/}
kernel=${kernel%.rpm}

# write out the uENV.txt for uevm board
cat <<EOF > ${chroot}/boot/uboot/uEnv.txt
setenv bootm_size 0x20000000
setenv bootargs console=\${console} vram=\${vram} root=LABEL=rootfs ro rootwait
ext4load mmc 0:3 0x82000000 /boot/vmlinuz-${kernel#kernel-}
ext4load mmc 0:3 0x88080000 /boot/uInitrd-${kernel#kernel-}
ext4load mmc 0:3 0x88000000 /boot/dtb-${kernel#kernel-}/omap5-uevm.dtb
bootz 0x82000000 0x88080000 0x88000000
EOF


sync