build_kernel_image: Command line for NAND

This patch modifies the build scripts to create a kernel command line
with the appropriate parameters:
- The root device and hash device for dm-verity are /dev/ubi${n}_0,
  where n is the index of the kernel partition + 1.
- The root device if dm-verity is off retains its current value, but
  is substitutable by a script in the board overlay. This allows
  some boards that know they will have new firmware to use %R, which
  will switch to rootfs on ubiblock when applicable.
- Each ubi partition is attached and ubiblock is created.
A downside to this patch: ubi and ubiblock are attached whether or
not we have booted from NAND, if they are in the disk-layout.json.
This means that booting from USB gets a bunch of harmness UBI-related
error messages in the console.

TEST=Together with another patch in the Storm NAND overlay,
booted from NAND with rootfs and stateful on NAND.
root@localhost $ cat /proc/cmdline
cros_secure earlyprintk=ttyMSM0,115200n8 console=tty1
console=ttyMSM0,115200n8 loglevel=7 init=/sbin/init cros_secure
oops=panic panic=-1 root=/dev/ubiblock3_0 rootwait ro
dm_verity.error_behavior=3 dm_verity.max_bios=-1 dm_verity.dev_wait=0
noinitrd vt.global_cursor_default=0
kern_guid=e2ad1269-e247-2f46-97ea-d9f572cf87b1 ubi.mtd=8,0,0,8
ubi.mtd=1,0,0,1 ubi.mtd=5,0,0,5 ubi.block=5,0 ubi.mtd=3,0,0,3
Also boots successfully from USB.

Signed-off-by: Dan Ehrenberg <>
Change-Id: Ifdf10943bd57a876d6e1fba5f5b6ff2950259196
4 files changed