MLK-16441 imx8qm/qxp: print commit hash for SCFW, 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 f0cb8b8e, IMX-MKIMAGE cc994971, ATF 0
      - U-Boot 2017.03-00031-g0596078-dirty
and set them to environment variables like:
    commit_atf=0a9efa7
    commit_mkimage=cc994971
    commit_scfw=45c567e8
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>
Signed-off-by: Ye Li <ye.li@nxp.com>
			
			
This commit is contained in:
		
							parent
							
								
									86b6e2b08c
								
							
						
					
					
						commit
						5b443e3e26
					
				|  | @ -21,6 +21,7 @@ | |||
| #include <fdt_support.h> | ||||
| #include <fdtdec.h> | ||||
| #include <asm/arch/cpu.h> | ||||
| #include <generated/version_autogenerated.h> | ||||
| 
 | ||||
| DECLARE_GLOBAL_DATA_PTR; | ||||
| 
 | ||||
|  | @ -616,6 +617,70 @@ bool is_usb_boot(void) | |||
| 	return get_boot_device() == USB_BOOT; | ||||
| } | ||||
| 
 | ||||
| #define FSL_SIP_BUILDINFO		0xC2000003 | ||||
| #define FSL_SIP_BUILDINFO_GET_COMMITHASH	0x00 | ||||
| extern uint32_t _end_ofs; | ||||
| 
 | ||||
| static void set_buildinfo_to_env(uint32_t scfw, char *mkimage, char *atf) | ||||
| { | ||||
| 	if (!mkimage || !atf) | ||||
| 		return; | ||||
| 
 | ||||
| 	env_set("commit_mkimage", mkimage); | ||||
| 	env_set("commit_atf", atf); | ||||
| 	env_set_hex("commit_scfw", (ulong)scfw); | ||||
| } | ||||
| 
 | ||||
| static void acquire_buildinfo(void) | ||||
| { | ||||
| 	sc_ipc_t ipc; | ||||
| 	uint32_t sc_build = 0, sc_commit = 0; | ||||
| 	char *mkimage_commit, *temp; | ||||
| 	uint64_t atf_commit = 0; | ||||
| 
 | ||||
| 	ipc = gd->arch.ipc_channel_handle; | ||||
| 
 | ||||
| 	/* Get SCFW build and commit id */ | ||||
| 	sc_misc_build_info(ipc, &sc_build, &sc_commit); | ||||
| 	if (sc_build == 0) { | ||||
| 		debug("SCFW does not support build info\n"); | ||||
| 		sc_commit = 0; /* Display 0 when the build info is not supported*/ | ||||
| 	} | ||||
| 
 | ||||
| 	/* Get imx-mkimage commit id.
 | ||||
| 	 * The imx-mkimage puts the commit hash behind the end of u-boot.bin | ||||
| 	 */ | ||||
| 	mkimage_commit = (char *)(ulong)(CONFIG_SYS_TEXT_BASE + _end_ofs + fdt_totalsize(gd->fdt_blob)); | ||||
| 	temp = mkimage_commit + 8; | ||||
| 	*temp = '\0'; | ||||
| 
 | ||||
| 	if (strlen(mkimage_commit) == 0) { | ||||
| 		debug("IMX-MKIMAGE does not support build info\n"); | ||||
| 		mkimage_commit = "0"; /* Display 0 */ | ||||
| 	} | ||||
| 
 | ||||
| 	/* Get ARM Trusted Firmware commit id */ | ||||
| 	atf_commit = call_imx_sip(FSL_SIP_BUILDINFO, FSL_SIP_BUILDINFO_GET_COMMITHASH, 0, 0, 0); | ||||
| 	if (atf_commit == 0xffffffff) { | ||||
| 		debug("ATF does not support build info\n"); | ||||
| 		atf_commit = 0x30; /* Display 0, 0 ascii is 0x30 */ | ||||
| 	} | ||||
| 
 | ||||
| 	/* Set all to env */ | ||||
| 	set_buildinfo_to_env(sc_commit, mkimage_commit, (char *)&atf_commit); | ||||
| 
 | ||||
| 	printf("\n BuildInfo: \n  - SCFW %08x, IMX-MKIMAGE %s, ATF %s\n  - %s \n\n", sc_commit, mkimage_commit, (char *)&atf_commit, U_BOOT_VERSION); | ||||
| } | ||||
| 
 | ||||
| #if defined(CONFIG_ARCH_MISC_INIT) | ||||
| int arch_misc_init(void) | ||||
| { | ||||
| 	acquire_buildinfo(); | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
| #endif | ||||
| 
 | ||||
| int print_bootinfo(void) | ||||
| { | ||||
| 	enum boot_device bt_dev; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue