From 89ffc511f185058ac6bf3fdaa44c932227d3416e Mon Sep 17 00:00:00 2001 From: Shraddha Chaudhari Date: Wed, 6 Apr 2016 20:52:58 +0530 Subject: [PATCH] pistachio: add and enable support for FIT image boot Add support for booting fitImage for dualnandboot, it will be verified boot with signature taken from u-boot.dtb file. dualnandboot will boot fitImage if file is present else uImage, this is for supporting builds which still don't have fitImage. Added bootm_verify flag to enable/disable checking of hashes and signature. Bug-Id: KIN-1981 Change-Id: I80aad43649b921bd9f2ce8699bd2e3e9a0d99cb4 Signed-off-by: Shraddha Chaudhari --- arch/mips/dts/Makefile | 5 +- arch/mips/dts/pistachio_beetle_mbub.dts | 1 + arch/mips/dts/pistachio_bub.dts | 1 + arch/mips/dts/pistachio_concerto_mbub.dts | 1 + arch/mips/dts/pistachio_marduk.dts | 2 +- arch/mips/dts/pistachio_signature.dtsi | 18 +++++++ include/configs/pistachio_bub.h | 59 ++++++++++++++++++++--- 7 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 arch/mips/dts/pistachio_signature.dtsi diff --git a/arch/mips/dts/Makefile b/arch/mips/dts/Makefile index cad3aad009..d244779912 100644 --- a/arch/mips/dts/Makefile +++ b/arch/mips/dts/Makefile @@ -3,7 +3,10 @@ dtb-$(CONFIG_MACH_PISTACHIO) += pistachio_bub.dtb pistachio_marduk.dtb pistachio targets += $(dtb-y) # Add any required device tree compiler flags here -DTC_FLAGS += +ifdef CONFIG_FIT +# -p for adding padding bytes in the end, this is required by mkimage to add rsa keys +DTC_FLAGS += -p 0x1000 +endif PHONY += dtbs dtbs: $(addprefix $(obj)/, $(dtb-y)) diff --git a/arch/mips/dts/pistachio_beetle_mbub.dts b/arch/mips/dts/pistachio_beetle_mbub.dts index 3c2ccd0fe6..a24a736eca 100644 --- a/arch/mips/dts/pistachio_beetle_mbub.dts +++ b/arch/mips/dts/pistachio_beetle_mbub.dts @@ -10,6 +10,7 @@ /dts-v1/; #include "pistachio_beetle.dtsi" +#include "pistachio_signature.dtsi" #include / { diff --git a/arch/mips/dts/pistachio_bub.dts b/arch/mips/dts/pistachio_bub.dts index fb01f9b590..fe4dd13c42 100644 --- a/arch/mips/dts/pistachio_bub.dts +++ b/arch/mips/dts/pistachio_bub.dts @@ -10,6 +10,7 @@ /dts-v1/; #include "pistachio.dtsi" +#include "pistachio_signature.dtsi" / { model = "IMG Pistachio BuB"; diff --git a/arch/mips/dts/pistachio_concerto_mbub.dts b/arch/mips/dts/pistachio_concerto_mbub.dts index 95d5a37889..fbb8ab2caf 100644 --- a/arch/mips/dts/pistachio_concerto_mbub.dts +++ b/arch/mips/dts/pistachio_concerto_mbub.dts @@ -10,6 +10,7 @@ /dts-v1/; #include "pistachio.dtsi" +#include "pistachio_signature.dtsi" #include / { diff --git a/arch/mips/dts/pistachio_marduk.dts b/arch/mips/dts/pistachio_marduk.dts index 39b12673ba..1232d8c904 100644 --- a/arch/mips/dts/pistachio_marduk.dts +++ b/arch/mips/dts/pistachio_marduk.dts @@ -9,7 +9,7 @@ /dts-v1/; #include "pistachio.dtsi" - +#include "pistachio_signature.dtsi" / { model = "IMG Marduk"; compatible = "img,pistachio-marduk", "img,pistachio"; diff --git a/arch/mips/dts/pistachio_signature.dtsi b/arch/mips/dts/pistachio_signature.dtsi new file mode 100644 index 0000000000..971b3a1987 --- /dev/null +++ b/arch/mips/dts/pistachio_signature.dtsi @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2015 Imagination Technologies Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + + +/ { + signature { + key-dev { + required = "conf"; + algo = "sha1,rsa2048"; + key-name-hint = "dev"; + }; + }; +}; diff --git a/include/configs/pistachio_bub.h b/include/configs/pistachio_bub.h index cfcdc9d021..be36e81234 100644 --- a/include/configs/pistachio_bub.h +++ b/include/configs/pistachio_bub.h @@ -32,6 +32,25 @@ #define CONFIG_PHYS_TO_BUS +/* + *FIT Image +*/ +#define CONFIG_FIT +#ifdef CONFIG_FIT +#define CONFIG_FIT_BEST_MATCH +#define CONFIG_FIT_SIGNATURE +#define CONFIG_FIT_VERBOSE +#define CONFIG_RSA +#define CONFIG_RSA_SOFTWARE_EXP +#define CONFIG_IMAGE_FORMAT_LEGACY +#define FITBOOT_VARIABLES \ + "fitfile=fitImage\0" \ + "fitconf="PISTACHIO_BOARD_NAME"_config@1\0" \ + "bootm_verify=y\0" +#else +#define FITBOOT_VARIABLES "" +#endif + /* * Memory map */ @@ -278,18 +297,43 @@ "ubifsload $fdtaddr $bootdir$fdtfile;" \ "bootm $loadaddr - $fdtaddr;" -#define DUAL_NAND_BOOTCOMMAND \ +#define DUAL_NAND_BOOT_INIT \ "sf probe 1:0;" \ "mtdparts default;" \ "setenv nandroot ubi.mtd=firmware${boot_partition} root=ubi0:rootfs rootfstype=ubifs;" \ "setenv bootargs $console $earlycon $nandroot $bootextra $mtdparts panic=2;" \ - "setenv verify n;" \ - "ubi part firmware${boot_partition};" \ - "setenv ubifs_bootm_cmd \"ubifsmount ubi:rootfs && " \ - "ubifsload $loadaddr $bootdir$bootfile && " \ - "ubifsload $fdtaddr $bootdir$fdtfile && " \ - "bootm $loadaddr - $fdtaddr\";" \ + "setenv verify $bootm_verify;" \ + "ubi part firmware${boot_partition};" \ + "ubifsmount ubi:rootfs || reset;" + +#define DUAL_NAND_UIMAGE_BOOT \ + "setenv ubifs_bootm_cmd \"ubifsload $loadaddr $bootdir$bootfile && " \ + "ubifsload $fdtaddr $bootdir$fdtfile && " \ + "bootm $loadaddr - $fdtaddr\";" + +#define DUAL_NAND_FITIMAGE_BOOT \ + "setenv ubifs_bootm_cmd \"ubifsload $loadaddr $bootdir$fitfile && " \ + "bootm $loadaddr#$fitconf\";" + + +#ifdef CONFIG_FIT +/* + If fitImage file is found boot that, else try uImage +*/ +#define DUAL_NAND_BOOTCOMMAND \ + DUAL_NAND_BOOT_INIT \ + "if ubifsls $bootdir$fitfile; then " \ + DUAL_NAND_FITIMAGE_BOOT \ + "else " \ + DUAL_NAND_UIMAGE_BOOT \ + "fi;" \ "run ubifs_bootm_cmd || reset;" +#else +#define DUAL_NAND_BOOTCOMMAND \ + DUAL_NAND_BOOT_INIT \ + DUAL_NAND_UIMAGE_BOOT \ + "run ubifs_bootm_cmd || reset;" +#endif #ifdef CONFIG_BOOTCOUNT_LIMIT @@ -348,6 +392,7 @@ "fdtaddr=0x0D000000\0" \ "fdtfile="PISTACHIO_BOARD_NAME".dtb\0" \ "bootfile=uImage\0" \ + FITBOOT_VARIABLES \ "loadaddr=0x0E000000\0" \ "bootdir=/\0" \ "usbdev=0\0" \