config_fsl_chain_trust.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright 2015 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __CONFIG_FSL_CHAIN_TRUST_H
  7. #define __CONFIG_FSL_CHAIN_TRUST_H
  8. /* For secure boot, since ENVIRONMENT in flash/external memories is
  9. * not verified, undef CONFIG_ENV_xxx and set default env
  10. * (CONFIG_ENV_IS_NOWHERE)
  11. */
  12. #ifdef CONFIG_SECURE_BOOT
  13. #undef CONFIG_ENV_IS_IN_EEPROM
  14. #undef CONFIG_ENV_IS_IN_NAND
  15. #undef CONFIG_ENV_IS_IN_MMC
  16. #undef CONFIG_ENV_IS_IN_SPI_FLASH
  17. #undef CONFIG_ENV_IS_IN_FLASH
  18. #define CONFIG_ENV_IS_NOWHERE
  19. #endif
  20. #ifdef CONFIG_CHAIN_OF_TRUST
  21. #ifndef CONFIG_EXTRA_ENV
  22. #define CONFIG_EXTRA_ENV ""
  23. #endif
  24. /*
  25. * Control should not reach back to uboot after validation of images
  26. * for secure boot flow and therefore bootscript should have
  27. * the bootm command. If control reaches back to uboot anyhow
  28. * after validating images, core should just spin.
  29. */
  30. /*
  31. * Define the key hash for boot script here if public/private key pair used to
  32. * sign bootscript are different from the SRK hash put in the fuse
  33. * Example of defining KEY_HASH is
  34. * #define CONFIG_BOOTSCRIPT_KEY_HASH \
  35. * "41066b564c6ffcef40ccbc1e0a5d0d519604000c785d97bbefd25e4d288d1c8b"
  36. */
  37. #ifdef CONFIG_BOOTARGS
  38. #define CONFIG_SET_BOOTARGS "setenv bootargs \'" CONFIG_BOOTARGS" \';"
  39. #else
  40. #define CONFIG_SET_BOOTARGS "setenv bootargs \'root=/dev/ram " \
  41. "rw console=ttyS0,115200 ramdisk_size=600000\';"
  42. #endif
  43. #ifdef CONFIG_BOOTSCRIPT_KEY_HASH
  44. #define CONFIG_SECBOOT \
  45. "setenv bs_hdraddr " __stringify(CONFIG_BOOTSCRIPT_HDR_ADDR)";" \
  46. CONFIG_SET_BOOTARGS \
  47. CONFIG_EXTRA_ENV \
  48. "esbc_validate $bs_hdraddr " \
  49. __stringify(CONFIG_BOOTSCRIPT_KEY_HASH)";" \
  50. "source $img_addr;" \
  51. "esbc_halt\0"
  52. #else
  53. #define CONFIG_SECBOOT \
  54. "setenv bs_hdraddr " __stringify(CONFIG_BOOTSCRIPT_HDR_ADDR)";" \
  55. CONFIG_SET_BOOTARGS \
  56. CONFIG_EXTRA_ENV \
  57. "esbc_validate $bs_hdraddr;" \
  58. "source $img_addr;" \
  59. "esbc_halt\0"
  60. #endif
  61. #ifdef CONFIG_BOOTSCRIPT_COPY_RAM
  62. #define CONFIG_BS_COPY_ENV \
  63. "setenv bs_hdr_ram " __stringify(CONFIG_BS_HDR_ADDR_RAM)";" \
  64. "setenv bs_hdr_device " __stringify(CONFIG_BS_HDR_ADDR_DEVICE)";" \
  65. "setenv bs_hdr_size " __stringify(CONFIG_BS_HDR_SIZE)";" \
  66. "setenv bs_ram " __stringify(CONFIG_BS_ADDR_RAM)";" \
  67. "setenv bs_device " __stringify(CONFIG_BS_ADDR_DEVICE)";" \
  68. "setenv bs_size " __stringify(CONFIG_BS_SIZE)";"
  69. /* For secure boot flow, default environment used will be used */
  70. #if defined(CONFIG_SYS_RAMBOOT)
  71. #if defined(CONFIG_RAMBOOT_NAND)
  72. #define CONFIG_BS_COPY_CMD \
  73. "nand read $bs_hdr_ram $bs_hdr_device $bs_hdr_size ;" \
  74. "nand read $bs_ram $bs_device $bs_size ;"
  75. #endif /* CONFIG_RAMBOOT_NAND */
  76. #elif defined(CONFIG_SD_BOOT)
  77. #define CONFIG_BS_COPY_CMD \
  78. "mmc read $bs_hdr_ram $bs_hdr_device $bs_hdr_size ;" \
  79. "mmc read $bs_ram $bs_device $bs_size ;"
  80. #else /* CONFIG_SD_BOOT */
  81. #define CONFIG_BS_COPY_CMD \
  82. "cp.b $bs_hdr_device $bs_hdr_ram $bs_hdr_size ;" \
  83. "cp.b $bs_device $bs_ram $bs_size ;"
  84. #endif
  85. #endif /* CONFIG_BOOTSCRIPT_COPY_RAM */
  86. #ifndef CONFIG_BS_COPY_ENV
  87. #define CONFIG_BS_COPY_ENV
  88. #endif
  89. #ifndef CONFIG_BS_COPY_CMD
  90. #define CONFIG_BS_COPY_CMD
  91. #endif
  92. #define CONFIG_CHAIN_BOOT_CMD CONFIG_BS_COPY_ENV \
  93. CONFIG_BS_COPY_CMD \
  94. CONFIG_SECBOOT
  95. #endif
  96. #endif