[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#858308: flash-kernel: documentation for upgrading Odroid-U2/U3 to flash-kernel

Package: flash-kernel
Version: 3.76
Severity: wishlist
Tags: patch

Please include the attached file in /usr/share/doc of either flash-kernel or
perhaps u-boot-exynos.  It documents how to upgrade a system using the
vendor image to Debian's u-boot, flash-kernel and modern kernels.

There already is a somewhat similar file,
/usr/share/doc/u-boot-exynos/README.odroid.gz, but it's quite obsolete
(meant for 3.8 without packaged tools) and vague.

I've also tried to explain concepts ARM porters may take for granted
but are not obvious to an average DD-level reader.

-- System Information:
Debian Release: 9.0
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: armhf (armv7l)

Kernel: Linux 4.11.0-rc3-00017-ge449e163607e (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages flash-kernel depends on:
ii  debconf [debconf-2.0]  1.5.60
ii  devio                  1.2-1.2+b1
ii  initramfs-tools        0.127
ii  linux-base             4.5
ii  mtd-utils              1:2.0.0-1
ii  ucf                    3.0036

Versions of packages flash-kernel recommends:
ii  u-boot-tools  2016.11+dfsg1-3

flash-kernel suggests no packages.

-- debconf information:
* flash-kernel/linux_cmdline: console=tty1 console=ttySAC1,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro  mem=2047M vm.min_free_kbytes=16384
How to upgrade an Odroid-U2/U3 to the modern kernel.


While strictly speaking, with perfect luck you don't need any extra bits,
in reality you need at least:
* an eMMC reader (if you bought your eMMC from Hardkernel, the included
  adapter works well in _some_ SD readers)
* a serial console (UART).  If you don't have one yet, with shipping it
  costs its weight in gold -- but fortunately it's not too heavy.

u-boot and other pre-kernel gubbins

apt install u-boot-exynos
wget http://odroid.in/guides/ubuntu-lfs/boot.tar.gz

Replace u-boot.bin from that tarball (2013 Samsung-private build) with
/usr/lib/u-boot/odroid/u-boot.bin (2016 vanilla), the other pieces are ok.

If you're booting from a SD card, skip until running sd-fusing.sh

On eMMC:

Edit sd_fusing.sh, change sector numbers to those listed in
/usr/share/doc/u-boot-exynos/README.odroid.gz :

You may notice that these positions look wrong: on your eMMC (as originally
shipped) you have all those pieces in "SD" positions.  Tʜᴏꜱᴇ ᴀʀᴇ ᴅᴇᴄᴏʏꜱ ᴍᴀᴅᴇ
ᴛᴏ ᴡᴀꜱᴛᴇ ʏᴏᴜʀ ᴛɪᴍᴇ!  Replacing them does exactly nothing, the real bits are
on hidden parts of the eMMC.

There are rumours that it is possible to access them from a SD reader by a
"partition switch", but despite hours of searching I found no information
how to do that.  The only way seems to be using the U2 itself.  Which is a
dangerous thing as if anything goes wrong you won't be able to boot. 
Fortunately, recovery is possible with a micro-USB cable and a SD card with
a special image: http://forum.odroid.com/viewtopic.php?f=53&t=969 -- I did
not have the need to test that, though.

On the U2, you need to unlock the secret partition first:
echo 0 > /sys/block/mmcblk0boot0/force_ro
The device name does vary: it's /dev/mmcblk0 on some kernels (vendor and
Debian's 4.10-trunk-armmp), /dev/mmcblk1 on others (Debian 4.9 and vanilla
4.11-rc2).  Only boot0 has anything, boot1 and rpmb are full of zeroes.

./sd-fusing.sh /dev/mmcblk0boot0
Watch the output -- it has no error detection at all and will lie that all
went ok even if it didn't!

Now pray and reboot.

u-boot console

Fortunately, unlike some other SoCs, modern u-boot _can_ boot both vendor
and mainline kernels.  Be prepared to do some manual loading, though.  For
convenience, here are relevant bits of old /boot/boot.scr:
setenv bootcmd "fatload mmc 0:1 0x40008000 zImage; fatload mmc 0:1 0x42000000 uInitrd; bootm 0x40008000 0x42000000"
setenv bootargs "console=tty1 console=ttySAC1,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro  mem=2047M"

If boot fails, type the commands inside bootcmd manually, perhaps replacing
"fatload" with "ext4load" (also helpful "ext4ls mmc 0:1" and so on).  The
"bootm" command is wrong: you need to replace it with "bootz".

fat -> ext4

Debian's kernel installation is heavily married to POSIX features that are
unavailable on fat.  And the Odroid image uses fat for /boot (and so does
every single SoC image I've seen).  Changing ln to cp and so on is not
enough, I've gave up and reformatted.  Tar your /boot up, unmount, mkfs.ext4
/dev/mmcblk0p1, untar, recheck that the files are in /boot rather than
/boot/boot :þ then edit /etc/fstab (survivable with sysvinit, you're screwed
with systemd -- you can recover by editing the card via a reader).  Reboot,
do the manual u-boot ritual.

Obviously, don't delete that tarball yet.


As kernel hooks fail if flash-kernel is unhappy, you need to unpack the
kernel image first.  Grabbing linux-image-armmp from the Debian archive lets
you boot but nothing more: I didn't manage to get even ethernet to work, and
without network getting other images is unpleasant.  The in-archive 4.9 also
sucks speed-wise compared to both vendor 3.8 and to linus/master.  Thus,
let's take a kernel from that Linus guy.  4.11-rc2 works fine for me:

CPU test: gcc -O2  for(int i=0;i<1048576*256;i++) rand();
I/O test: dd if=/dev/mmcblk0 of=/dev/null bs=1048576 count=20000

                     CPU     I/O
vendor 3.8           15s     51MB/s
Debian 4.9           18.8s   71MB/s
vanilla 4.11-rc2     15s     84MB/s

git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
make exynos_defconfig
make menuconfig  # edit to taste
make -j4 bindeb-pkg
dpkg -i just the image


apt install flash-kernel
When asked by debconf about kernel cmdline, copy the bootargs:
console=tty1 console=ttySAC1,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro  mem=2047M
(with whatever extras you want).

Autodetection will fail, you need to:
echo "Hardkernel ODROID-U3 board based on Exynos4412" >/etc/flash-kernel/machine
(Both U2 and U3 use the same DT ("device tree" -- a machine description).)

flash-kernel, reboot.  If it fails and you can't get it up via u-boot
console, use the SD/eMMC reader on your big box to restore boot.scr, zImage
and uInitrd from the /boot tarball you saved.


I didn't manage to get the network driver, smsc95xx over usbnet, to work on
Debian-shipped kernels.  It works on vanilla 4.11-rc2.

Also it seems you need to change "allow-hotplug eth0" to "auto eth0" in

what doesn't work

* rebooting: the machine gets stuck and needs to be physically power-cycled

* audio

* the kernel whines about broken HDMI, video capture -- I can't even test
  those but I don't care

* the machine gets very hot; with 3.8 it never was even noticeably warm

Reply to: