Add commands to support extract serial number from device.
Commands:
$ fastboot oem get-serial-number
$ fastboot get_staged <path-to-serial-number>
Test: serial number upload on imx8mm.
Change-Id: I5c905ab797d4fd28d76c8403914f191eaf2ef687
Signed-off-by: Ji Luo <ji.luo@nxp.com>
(cherry picked from commit
250ef119c1dc02908046113893df5eeb9ef40605)
*/
static u32 fastboot_bytes_expected;
-
/* Write the bcb with fastboot bootloader commands */
static void enable_fastboot_command(void)
{
printf("mppubk generated!\n");
strcpy(response, "OKAY");
}
+ } else if (endswith(cmd, FASTBOOT_GET_SERIAL_NUMBER)) {
+ char *serial = get_serial();
+
+ if (!serial)
+ strcpy(response, "FAILSerial number not support!");
+ else {
+ /* Serial number will not exceed 16 bytes.*/
+ strncpy(fastboot_buf_addr, serial, 16);
+ fastboot_bytes_received = 16;
+ printf("Serial number generated!\n");
+ strcpy(response, "OKAY");
+ }
}
#ifndef CONFIG_AVB_ATX
else if (endswith(cmd, FASTBOOT_SET_RPMB_KEY)) {
extern AvbOps fsl_avb_ops;
#endif
+#define IMX_SERIAL_LEN 32
+
int get_block_size(void);
void process_erase_mmc(const char *cmdbuf, char *response);
+char *get_serial(void);
#endif // FB_FSL_COMMON_H
return false;
}
-static char *get_serial(void)
+static char serial[IMX_SERIAL_LEN];
+
+char *get_serial(void)
{
#ifdef CONFIG_SERIAL_TAG
struct tag_serialnr serialnr;
- static char serial[32];
+ memset(serial, 0, IMX_SERIAL_LEN);
+
get_board_serial(&serialnr);
- sprintf(serial, "%08x%08x", serialnr.high, serialnr.low);
+ sprintf(serial, "%08x%08x", serialnr.high, serialnr.low);
return serial;
#else
return NULL;
#define FASTBOOT_APPEND_RSA_ATTESTATION_CERT_ENC "append-rsa-atte-cert-enc"
#define FASTBOOT_APPEND_EC_ATTESTATION_CERT_ENC "append-ec-atte-cert-enc"
#define FASTBOOT_GET_MPPUBK "get-mppubk"
+#define FASTBOOT_GET_SERIAL_NUMBER "get-serial-number"
#endif
#ifdef CONFIG_ANDROID_THINGS_SUPPORT