powerpc/mpc85xx: SECURE BOOT-Copy Boot Script on RAM
authorAneesh Bansal <aneesh.bansal@freescale.com>
Tue, 16 Jun 2015 05:06:43 +0000 (10:36 +0530)
committerYork Sun <yorksun@freescale.com>
Fri, 31 Jul 2015 15:50:18 +0000 (08:50 -0700)
For running Chain of Trust when doing Secure Boot from NAND,
the Bootscript header and bootscript must be copied from NAND
to RAM(DDR).
The addresses and commands for the same have been defined.

Signed-off-by: Saksham Jain <saksham@freescale.com>
Signed-off-by: Ruchika Gupta <ruchika.gupta@freescale.com>
Signed-off-by: Aneesh Bansal <aneesh.bansal@freescale.com>
Reviewed-by: York Sun <yorksun@freescale.com>
arch/powerpc/include/asm/fsl_secure_boot.h
include/config_fsl_secboot.h
include/configs/corenet_ds.h

index 442853c239154dfe535fbb39b166250e5bf91cae..d57bb556927decb412a3ea271482997e012e0e1b 100644 (file)
 #endif
 
 #ifndef CONFIG_FIT_SIGNATURE
+/* If Boot Script is not on NOR and is required to be copied on RAM */
+#ifdef CONFIG_BOOTSCRIPT_COPY_RAM
+#define CONFIG_BS_HDR_ADDR_RAM         0x00010000
+#define CONFIG_BS_HDR_ADDR_FLASH       0x00800000
+#define CONFIG_BS_HDR_SIZE             0x00002000
+#define CONFIG_BS_ADDR_RAM             0x00012000
+#define CONFIG_BS_ADDR_FLASH           0x00802000
+#define CONFIG_BS_SIZE                 0x00001000
+
+#define CONFIG_BOOTSCRIPT_HDR_ADDR     CONFIG_BS_HDR_ADDR_RAM
+#else
+
 /* The bootscript header address is different for B4860 because the NOR
  * mapping is different on B4 due to reduced NOR size.
  */
 #define CONFIG_BOOTSCRIPT_HDR_ADDR     0xee020000
 #endif
 
+#endif
+
 #include <config_fsl_secboot.h>
 #endif
 
index 050b15790211992a29c64cbd51a3b2c783e0bd24..fc6788a7a614aced44fc38f7a937832ccb517533 100644 (file)
 
 /* For secure boot flow, default environment used will be used */
 #if defined(CONFIG_SYS_RAMBOOT)
+#ifdef CONFIG_BOOTSCRIPT_COPY_RAM
+#define CONFIG_BS_COPY_ENV \
+       "setenv bs_hdr_ram " __stringify(CONFIG_BS_HDR_ADDR_RAM)";" \
+       "setenv bs_hdr_flash " __stringify(CONFIG_BS_HDR_ADDR_FLASH)";" \
+       "setenv bs_hdr_size " __stringify(CONFIG_BS_HDR_SIZE)";" \
+       "setenv bs_ram " __stringify(CONFIG_BS_ADDR_RAM)";" \
+       "setenv bs_flash " __stringify(CONFIG_BS_ADDR_FLASH)";" \
+       "setenv bs_size " __stringify(CONFIG_BS_SIZE)";"
+
+#if defined(CONFIG_RAMBOOT_NAND)
+#define CONFIG_BS_COPY_CMD \
+       "nand read $bs_hdr_ram $bs_hdr_flash $bs_hdr_size ;" \
+       "nand read $bs_ram $bs_flash $bs_size ;"
+#endif /* CONFIG_RAMBOOT_NAND */
+#endif /* CONFIG_BOOTSCRIPT_COPY_RAM */
+
 #if defined(CONFIG_RAMBOOT_SPIFLASH)
 #undef CONFIG_ENV_IS_IN_SPI_FLASH
 #elif defined(CONFIG_RAMBOOT_NAND)
 
 #define CONFIG_ENV_IS_NOWHERE
 
+#ifndef CONFIG_BS_COPY_ENV
+#define CONFIG_BS_COPY_ENV
+#endif
+
+#ifndef CONFIG_BS_COPY_CMD
+#define CONFIG_BS_COPY_CMD
+#endif
+
+#define CONFIG_SECBOOT_CMD     CONFIG_BS_COPY_ENV \
+                               CONFIG_BS_COPY_CMD \
+                               CONFIG_SECBOOT
 /*
  * We don't want boot delay for secure boot flow
  * before autoboot starts
 #undef CONFIG_BOOTDELAY
 #define CONFIG_BOOTDELAY       0
 #undef CONFIG_BOOTCOMMAND
-#define CONFIG_BOOTCOMMAND             CONFIG_SECBOOT
+#define CONFIG_BOOTCOMMAND             CONFIG_SECBOOT_CMD
 
 /*
  * CONFIG_ZERO_BOOTDELAY_CHECK should not be defined for
index 7c8b73d06c3d186f1868b4dfbc8ccf34b85d7215..9aaa0f533b8f96d602076a82a198f77345da056d 100644 (file)
@@ -22,6 +22,7 @@
 #ifdef CONFIG_NAND
 #define CONFIG_RAMBOOT_NAND
 #endif
+#define CONFIG_BOOTSCRIPT_COPY_RAM
 #else
 #define CONFIG_RAMBOOT_TEXT_BASE       CONFIG_SYS_TEXT_BASE
 #define CONFIG_RESET_VECTOR_ADDRESS    0xfffffffc