Skip to content

Instantly share code, notes, and snippets.

@muttiopenbts
Last active September 2, 2019 01:48
Show Gist options
  • Save muttiopenbts/2b1005cb8cfabeddb18cda4873dac8f2 to your computer and use it in GitHub Desktop.
Save muttiopenbts/2b1005cb8cfabeddb18cda4873dac8f2 to your computer and use it in GitHub Desktop.
This is a stripped down version of Boundary device's 6x_bootscript for hab signed kernel
# This is a stripped down version of Boundary device's 6x_bootscript
# which I used for learning and testing my hab images for imx6
# Prepare uboot script command
#u-boot-imx6$ ./tools/mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "my boot script" -d imx6_uboot_script.txt /tftpboot/imx6_uboot_script
setenv dtype mmc
setenv disk 0
setenv active_partition 1
# setenv kernel_img_name zImage
setenv kernel_img_name zImage_signed_10800000
setenv bootargs ''
setenv initrd_high 0xffffffff
m4=''
a_base=0x10000000
setexpr a_script ${a_base} + 0x00800000
setexpr a_zImage ${a_base} + 0x00800000
setexpr a_fdt ${a_base} + 0x03000000
setexpr a_ramdisk ${a_base} + 0x03800000
setexpr a_initrd ${a_base} + 0x03a00000
setexpr a_reset_cause_marker ${a_base} + 0x80
setexpr a_reset_cause ${a_base} + 0x84
dtbname=imx6q-${board}.dtb;
if itest.s x${bootpart} == x ; then
bootpart=1
fi
if load ${dtype} ${disk}:${bootpart} ${a_script} uEnv.txt ; then
env import -t ${a_script} ${filesize}
fi
setenv bootargs ${bootargs} console=${console},115200 vmalloc=400M consoleblank=0 rootwait fixrtc cpu=${cpu} board=${board}
if itest.s x == x${bootdir} ; then
bootdir=/
fi
if load ${dtype} ${disk}:${bootpart} ${a_fdt} ${bootdir}${dtbname} ; then
fdt addr ${a_fdt}
setenv fdt_high 0xffffffff
else
echo "!!!! Error loading ${bootdir}${dtbname}";
exit;
fi
bpart=2
# Tell kernel where root partition is
if test "sata" = "${dtype}" ; then
setenv bootargs "${bootargs} root=/dev/sda${bpart}" ;
elif test "usb" = "${dtype}" ; then
setenv bootargs "${bootargs} root=/dev/sda${bpart}" ;
else
setenv bootargs "${bootargs} root=/dev/mmcblk${disk}p${bpart}"
fi
if itest.s "x" != "x${show_fdt}" ; then
fdt print /
fi
if itest.s "x" != "x${show_env}" ; then
printenv
fi
# Boot kernel
# ===========
# TODO: Add check to ensure secure boot OTP fuse enabled
# location offset of ivt within img
ivt_offset=619000
# image_hex_len = includes kernel + padding + ivt + csf
image_hex_len=61a970
# TODO: verify possible bug. image_hex_len=619068 also passes hab_auth_img
if load ${dtype} ${disk}:${bootpart} ${a_zImage} /${kernel_img_name} ; then
if hab_auth_img ${a_zImage} ${image_hex_len} ${ivt_offset}; then
echo "Kernel signature verified.";
bootz ${a_zImage} - ${a_fdt}
else
echo "Kernel signature failed.";
fi
fi
echo "Error loading kernel image"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment