Skip to content

Commit

Permalink
pistachio: add and enable support for FIT image boot
Browse files Browse the repository at this point in the history
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 <Shraddha.Chaudhari@imgtec.com>
  • Loading branch information
shraddha-chaudhari-imgtec authored and Ham22 committed Sep 15, 2016
1 parent f55662b commit 89ffc51
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 9 deletions.
5 changes: 4 additions & 1 deletion arch/mips/dts/Makefile
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions arch/mips/dts/pistachio_beetle_mbub.dts
Expand Up @@ -10,6 +10,7 @@
/dts-v1/;

#include "pistachio_beetle.dtsi"
#include "pistachio_signature.dtsi"
#include <dt-bindings/sound/pistachio-bub-audio.h>

/ {
Expand Down
1 change: 1 addition & 0 deletions arch/mips/dts/pistachio_bub.dts
Expand Up @@ -10,6 +10,7 @@
/dts-v1/;

#include "pistachio.dtsi"
#include "pistachio_signature.dtsi"

/ {
model = "IMG Pistachio BuB";
Expand Down
1 change: 1 addition & 0 deletions arch/mips/dts/pistachio_concerto_mbub.dts
Expand Up @@ -10,6 +10,7 @@
/dts-v1/;

#include "pistachio.dtsi"
#include "pistachio_signature.dtsi"
#include <dt-bindings/sound/pistachio-bub-audio.h>

/ {
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/dts/pistachio_marduk.dts
Expand Up @@ -9,7 +9,7 @@
/dts-v1/;

#include "pistachio.dtsi"

#include "pistachio_signature.dtsi"
/ {
model = "IMG Marduk";
compatible = "img,pistachio-marduk", "img,pistachio";
Expand Down
18 changes: 18 additions & 0 deletions 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";
};
};
};
59 changes: 52 additions & 7 deletions include/configs/pistachio_bub.h
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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" \
Expand Down

0 comments on commit 89ffc51

Please sign in to comment.