Problem upgrading kernel

I also had some problems with system start after upgrading reform-tools. Currently flash-kernel ignores settings from ‘/etc/default/flash-kernel’.

Looking at both flash-kernel and reform-tools, it looks like they moved configuration files from /etc to /usr/share/flash-kernel, including 00reform2_ubootenv (from /etc/flash-kernel/ubootenv.d to /usr/share/flash-kernel/ubootenv.d/) and flash-kernel (from /etc/default to /usr/share/flash-kernel/default/). I can see two problems with this change:

  1. It ignores any potential changes done in files in /etc. It was problem for me: I added parameter setting initial btrfs subvolume, which was ignored when generating boot.scr.
  2. As files are now in /usr (so not configuration files), any changes in them are overwritten during package upgrade. When files were in /etc, dpkg was asking about replacement - now no more.

I’m not sure if this change was the result of recent discussion on debian-devel related to moving everything to /usr, or not.

Currently, to avoid nasty surprises, I pinned reform-tools at version 1.29.

Technical description of how boot.scr file is generated follows.

Description of machines are held in /usr/share/flash-kernel/db/all.db. It’s text file with descriptions of machines, which is parsed by function get_machine_field in file /usr/share/flash-kernel/functions.

File boot.scr is generated by function mkimage_script, called in line 1023. Function begins in line 467. It requires template, prepared in lines 1019-1022 from file /etc/flash-kernel/bootscript/bootscr.uboot-generic. Function mkimage_script injects files found in /etc/flash-kernel/ubootenv.d and in /usr/share/flash-kernel/ubootenv.d into template (using function gen_ubootenv - variable @@UBOOT_ENV_EXTRA@@); the same for files in /etc/flash-kernel/preboot.d and /usr/share/flash-kernel/preboot.d - function gen_preboot and variable @@UBOOT_PREBOOT_EXTRA@@.

The rest is adding kernel version, command line arguments, and few other
values. What is interesting: kernel command line arguments are read from
/etc/default/flash-kernel!
But following code, taken from /usr/share/flash-kernel/ubootenv.d/00reform2_ubootenv, overwrites those values.

After preparing full file function mkimage_script calls program mkimage:

mkimage -A arm64 -O linux -T script -C none -a "" -e "" -n "boot script" -d /tmp/boot.in /boot/boot.scr

Warning! boot.scr contains checksum, so editing it directly will make boot to fail. mkimage creates correct structure.

Using those steps I was able to bring system back to booting.