Skip to content

Commit 89ffc51

Browse files
shraddha-chaudhari-imgtecHam22
authored andcommitted
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 <[email protected]>
1 parent f55662b commit 89ffc51

7 files changed

+78
-9
lines changed

arch/mips/dts/Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ dtb-$(CONFIG_MACH_PISTACHIO) += pistachio_bub.dtb pistachio_marduk.dtb pistachio
33
targets += $(dtb-y)
44

55
# Add any required device tree compiler flags here
6-
DTC_FLAGS +=
6+
ifdef CONFIG_FIT
7+
# -p for adding padding bytes in the end, this is required by mkimage to add rsa keys
8+
DTC_FLAGS += -p 0x1000
9+
endif
710

811
PHONY += dtbs
912
dtbs: $(addprefix $(obj)/, $(dtb-y))

arch/mips/dts/pistachio_beetle_mbub.dts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
/dts-v1/;
1111

1212
#include "pistachio_beetle.dtsi"
13+
#include "pistachio_signature.dtsi"
1314
#include <dt-bindings/sound/pistachio-bub-audio.h>
1415

1516
/ {

arch/mips/dts/pistachio_bub.dts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
/dts-v1/;
1111

1212
#include "pistachio.dtsi"
13+
#include "pistachio_signature.dtsi"
1314

1415
/ {
1516
model = "IMG Pistachio BuB";

arch/mips/dts/pistachio_concerto_mbub.dts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
/dts-v1/;
1111

1212
#include "pistachio.dtsi"
13+
#include "pistachio_signature.dtsi"
1314
#include <dt-bindings/sound/pistachio-bub-audio.h>
1415

1516
/ {

arch/mips/dts/pistachio_marduk.dts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/dts-v1/;
1010

1111
#include "pistachio.dtsi"
12-
12+
#include "pistachio_signature.dtsi"
1313
/ {
1414
model = "IMG Marduk";
1515
compatible = "img,pistachio-marduk", "img,pistachio";
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (C) 2015 Imagination Technologies Ltd.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*/
8+
9+
10+
/ {
11+
signature {
12+
key-dev {
13+
required = "conf";
14+
algo = "sha1,rsa2048";
15+
key-name-hint = "dev";
16+
};
17+
};
18+
};

include/configs/pistachio_bub.h

+52-7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,25 @@
3232

3333
#define CONFIG_PHYS_TO_BUS
3434

35+
/*
36+
*FIT Image
37+
*/
38+
#define CONFIG_FIT
39+
#ifdef CONFIG_FIT
40+
#define CONFIG_FIT_BEST_MATCH
41+
#define CONFIG_FIT_SIGNATURE
42+
#define CONFIG_FIT_VERBOSE
43+
#define CONFIG_RSA
44+
#define CONFIG_RSA_SOFTWARE_EXP
45+
#define CONFIG_IMAGE_FORMAT_LEGACY
46+
#define FITBOOT_VARIABLES \
47+
"fitfile=fitImage\0" \
48+
"fitconf="PISTACHIO_BOARD_NAME"_config@1\0" \
49+
"bootm_verify=y\0"
50+
#else
51+
#define FITBOOT_VARIABLES ""
52+
#endif
53+
3554
/*
3655
* Memory map
3756
*/
@@ -278,18 +297,43 @@
278297
"ubifsload $fdtaddr $bootdir$fdtfile;" \
279298
"bootm $loadaddr - $fdtaddr;"
280299

281-
#define DUAL_NAND_BOOTCOMMAND \
300+
#define DUAL_NAND_BOOT_INIT \
282301
"sf probe 1:0;" \
283302
"mtdparts default;" \
284303
"setenv nandroot ubi.mtd=firmware${boot_partition} root=ubi0:rootfs rootfstype=ubifs;" \
285304
"setenv bootargs $console $earlycon $nandroot $bootextra $mtdparts panic=2;" \
286-
"setenv verify n;" \
287-
"ubi part firmware${boot_partition};" \
288-
"setenv ubifs_bootm_cmd \"ubifsmount ubi:rootfs && " \
289-
"ubifsload $loadaddr $bootdir$bootfile && " \
290-
"ubifsload $fdtaddr $bootdir$fdtfile && " \
291-
"bootm $loadaddr - $fdtaddr\";" \
305+
"setenv verify $bootm_verify;" \
306+
"ubi part firmware${boot_partition};" \
307+
"ubifsmount ubi:rootfs || reset;"
308+
309+
#define DUAL_NAND_UIMAGE_BOOT \
310+
"setenv ubifs_bootm_cmd \"ubifsload $loadaddr $bootdir$bootfile && " \
311+
"ubifsload $fdtaddr $bootdir$fdtfile && " \
312+
"bootm $loadaddr - $fdtaddr\";"
313+
314+
#define DUAL_NAND_FITIMAGE_BOOT \
315+
"setenv ubifs_bootm_cmd \"ubifsload $loadaddr $bootdir$fitfile && " \
316+
"bootm $loadaddr#$fitconf\";"
317+
318+
319+
#ifdef CONFIG_FIT
320+
/*
321+
If fitImage file is found boot that, else try uImage
322+
*/
323+
#define DUAL_NAND_BOOTCOMMAND \
324+
DUAL_NAND_BOOT_INIT \
325+
"if ubifsls $bootdir$fitfile; then " \
326+
DUAL_NAND_FITIMAGE_BOOT \
327+
"else " \
328+
DUAL_NAND_UIMAGE_BOOT \
329+
"fi;" \
292330
"run ubifs_bootm_cmd || reset;"
331+
#else
332+
#define DUAL_NAND_BOOTCOMMAND \
333+
DUAL_NAND_BOOT_INIT \
334+
DUAL_NAND_UIMAGE_BOOT \
335+
"run ubifs_bootm_cmd || reset;"
336+
#endif
293337

294338
#ifdef CONFIG_BOOTCOUNT_LIMIT
295339

@@ -348,6 +392,7 @@
348392
"fdtaddr=0x0D000000\0" \
349393
"fdtfile="PISTACHIO_BOARD_NAME".dtb\0" \
350394
"bootfile=uImage\0" \
395+
FITBOOT_VARIABLES \
351396
"loadaddr=0x0E000000\0" \
352397
"bootdir=/\0" \
353398
"usbdev=0\0" \

0 commit comments

Comments
 (0)