Commit a0ae3c321517a1279751130d0d8a264e558f55dd

Authored by Ye Li
1 parent 39bc3673a5

MLK-16441 imx8qm/qxp: print commit hash for SCFW, SECO, IMX-MKIMAGE and ATF

Since we have many software running on QM/QXP, it is better to print their
commit ids in u-boot to know their versions.

This patch enables the CONFIG_ARCH_MISC_INIT. In arch_misc_init to gets the
commit ids for SCFW and ATF via their APIs and get the commit for imx-mkimage
at the end of u-boot.bin loading address.

Once the commit ids are acquired, show them in console like:
    BuildInfo:
    - SCFW e2e62ca4, SECO-FW c121d4a4, IMX-MKIMAGE fe2ff1e9, ATF 8673a8e
    - U-Boot 2018.03-imx_v2018.03+g557a2e5

and set them to environment variables like:
    commit_atf=8673a8e
    commit_mkimage=fe2ff1e9
    commit_scfw=e2e62ca4
    commit_secofw=c121d4a4

If old software are running which does not support provide commit it, the patch
use 0 instead.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
(cherry picked from commit 5b443e3e26178e6df7cf76d98724a45871fcfaf1)

Showing 4 changed files with 129 additions and 1 deletions Side-by-side Diff

arch/arm/include/asm/arch-imx8/sci/rpc.h
... ... @@ -32,8 +32,10 @@
32 32 #define SC_RPC_SVC_PAD 6U
33 33 #define SC_RPC_SVC_MISC 7U
34 34 #define SC_RPC_SVC_IRQ 8U
35   -#define SC_RPC_SVC_ABORT 9U
  35 +#define SC_RPC_SVC_SECO 9U
  36 +#define SC_RPC_SVC_ABORT 10U
36 37  
  38 +
37 39 /* Types */
38 40  
39 41 struct sc_rpc_msg_s {
... ... @@ -154,6 +156,29 @@
154 156 #define RM_FUNC_SET_PAD_MOVABLE 24U
155 157 #define RM_FUNC_IS_PAD_OWNED 25U
156 158 #define RM_FUNC_DUMP 27U
  159 +
  160 +/* SECO RPC */
  161 +#define SECO_FUNC_UNKNOWN 0 /*!< Unknown function */
  162 +#define SECO_FUNC_IMAGE_LOAD 1U /*!< Index for seco_image_load() RPC call */
  163 +#define SECO_FUNC_AUTHENTICATE 2U /*!< Index for seco_authenticate() RPC call */
  164 +#define SECO_FUNC_FORWARD_LIFECYCLE 3U /*!< Index for seco_forward_lifecycle() RPC call */
  165 +#define SECO_FUNC_RETURN_LIFECYCLE 4U /*!< Index for seco_return_lifecycle() RPC call */
  166 +#define SECO_FUNC_COMMIT 5U /*!< Index for seco_commit() RPC call */
  167 +#define SECO_FUNC_ATTEST_MODE 6U /*!< Index for seco_attest_mode() RPC call */
  168 +#define SECO_FUNC_ATTEST 7U /*!< Index for seco_attest() RPC call */
  169 +#define SECO_FUNC_GET_ATTEST_PKEY 8U /*!< Index for seco_get_attest_pkey() RPC call */
  170 +#define SECO_FUNC_GET_ATTEST_SIGN 9U /*!< Index for seco_get_attest_sign() RPC call */
  171 +#define SECO_FUNC_ATTEST_VERIFY 10U /*!< Index for seco_attest_verify() RPC call */
  172 +#define SECO_FUNC_GEN_KEY_BLOB 11U /*!< Index for seco_gen_key_blob() RPC call */
  173 +#define SECO_FUNC_LOAD_KEY 12U /*!< Index for seco_load_key() RPC call */
  174 +#define SECO_FUNC_GET_MP_KEY 13U /*!< Index for seco_get_mp_key() RPC call */
  175 +#define SECO_FUNC_UPDATE_MPMR 14U /*!< Index for seco_update_mpmr() RPC call */
  176 +#define SECO_FUNC_GET_MP_SIGN 15U /*!< Index for seco_get_mp_sign() RPC call */
  177 +#define SECO_FUNC_BUILD_INFO 16U /*!< Index for seco_build_info() RPC call */
  178 +#define SECO_FUNC_CHIP_INFO 17U /*!< Index for seco_chip_info() RPC call */
  179 +#define SECO_FUNC_ENABLE_DEBUG 18U /*!< Index for seco_enable_debug() RPC call */
  180 +#define SECO_FUNC_GET_EVENT 19U /*!< Index for seco_get_event() RPC call */
  181 +#define SECO_FUNC_FUSE_WRITE 20U /*!< Index for seco_fuse_write() RPC call */
157 182  
158 183 #endif /* SC_RPC_H */
arch/arm/include/asm/arch-imx8/sci/sci.h
... ... @@ -94,5 +94,9 @@
94 94 int sc_rm_set_master_sid(sc_ipc_t ipc, sc_rsrc_t resource,
95 95 sc_rm_sid_t sid);
96 96  
  97 +/* SECO API */
  98 +void sc_seco_build_info(sc_ipc_t ipc, uint32_t *version,
  99 + uint32_t *commit);
  100 +
97 101 #endif
arch/arm/mach-imx/imx8/cpu.c
... ... @@ -23,6 +23,7 @@
23 23 #include <linux/libfdt.h>
24 24 #include <fdt_support.h>
25 25 #include <fdtdec.h>
  26 +#include <generated/version_autogenerated.h>
26 27  
27 28 DECLARE_GLOBAL_DATA_PTR;
28 29  
... ... @@ -337,6 +338,77 @@
337 338 imx8_config_smmu_sid(dev_sids, ARRAY_SIZE(dev_sids));
338 339 #endif
339 340 }
  341 +
  342 +#if defined(CONFIG_ARCH_MISC_INIT)
  343 +#define FSL_SIP_BUILDINFO 0xC2000003
  344 +#define FSL_SIP_BUILDINFO_GET_COMMITHASH 0x00
  345 +extern uint32_t _end_ofs;
  346 +
  347 +static void set_buildinfo_to_env(uint32_t scfw, uint32_t secofw, char *mkimage, char *atf)
  348 +{
  349 + if (!mkimage || !atf)
  350 + return;
  351 +
  352 + env_set("commit_mkimage", mkimage);
  353 + env_set("commit_atf", atf);
  354 + env_set_hex("commit_scfw", (ulong)scfw);
  355 + env_set_hex("commit_secofw", (ulong)secofw);
  356 +}
  357 +
  358 +static void acquire_buildinfo(void)
  359 +{
  360 + uint32_t sc_build = 0, sc_commit = 0;
  361 + uint32_t seco_build = 0, seco_commit = 0;
  362 + char *mkimage_commit, *temp;
  363 + uint64_t atf_commit = 0;
  364 +
  365 + /* Get SCFW build and commit id */
  366 + sc_misc_build_info(-1, &sc_build, &sc_commit);
  367 + if (sc_build == 0) {
  368 + debug("SCFW does not support build info\n");
  369 + sc_commit = 0; /* Display 0 when the build info is not supported*/
  370 + }
  371 +
  372 + /* Get SECO FW build and commit id */
  373 + sc_seco_build_info(-1, &seco_build, &seco_commit);
  374 + if (seco_build == 0) {
  375 + debug("SECO FW does not support build info\n");
  376 + seco_commit = 0; /* Display 0 when the build info is not supported*/
  377 + }
  378 +
  379 + /* Get imx-mkimage commit id.
  380 + * The imx-mkimage puts the commit hash behind the end of u-boot.bin
  381 + */
  382 + mkimage_commit = (char *)(ulong)(CONFIG_SYS_TEXT_BASE + _end_ofs + fdt_totalsize(gd->fdt_blob));
  383 + temp = mkimage_commit + 8;
  384 + *temp = '\0';
  385 +
  386 + if (strlen(mkimage_commit) == 0) {
  387 + debug("IMX-MKIMAGE does not support build info\n");
  388 + mkimage_commit = "0"; /* Display 0 */
  389 + }
  390 +
  391 + /* Get ARM Trusted Firmware commit id */
  392 + atf_commit = call_imx_sip(FSL_SIP_BUILDINFO, FSL_SIP_BUILDINFO_GET_COMMITHASH, 0, 0, 0);
  393 + if (atf_commit == 0xffffffff) {
  394 + debug("ATF does not support build info\n");
  395 + atf_commit = 0x30; /* Display 0, 0 ascii is 0x30 */
  396 + }
  397 +
  398 + /* Set all to env */
  399 + set_buildinfo_to_env(sc_commit, seco_commit, mkimage_commit, (char *)&atf_commit);
  400 +
  401 + printf("\n BuildInfo: \n - SCFW %08x, SECO-FW %08x, IMX-MKIMAGE %s, ATF %s\n - %s \n\n",
  402 + sc_commit, seco_commit, mkimage_commit, (char *)&atf_commit, U_BOOT_VERSION);
  403 +}
  404 +
  405 +int arch_misc_init(void)
  406 +{
  407 + acquire_buildinfo();
  408 +
  409 + return 0;
  410 +}
  411 +#endif
340 412  
341 413 int print_bootinfo(void)
342 414 {
drivers/misc/imx8/scu_api.c
... ... @@ -442,4 +442,31 @@
442 442  
443 443 return ret;
444 444 }
  445 +
  446 +void sc_seco_build_info(sc_ipc_t ipc, uint32_t *version,
  447 + uint32_t *commit)
  448 +{
  449 + struct udevice *dev = gd->arch.scu_dev;
  450 + struct sc_rpc_msg_s msg;
  451 + int size = sizeof(struct sc_rpc_msg_s);
  452 +
  453 + RPC_VER(&msg) = SC_RPC_VERSION;
  454 + RPC_SVC(&msg) = (u8)(SC_RPC_SVC_SECO);
  455 + RPC_FUNC(&msg) = (u8)(SECO_FUNC_BUILD_INFO);
  456 + RPC_SIZE(&msg) = 1U;
  457 +
  458 + misc_call(dev, SC_FALSE, &msg, size, &msg, size);
  459 +
  460 + if (version != NULL)
  461 + {
  462 + *version = RPC_U32(&msg, 0U);
  463 + }
  464 +
  465 + if (commit != NULL)
  466 + {
  467 + *commit = RPC_U32(&msg, 4U);
  468 + }
  469 +
  470 + return;
  471 +}