return ret;
}
+static int parse_assembly_string(char *string_to_parse, u16 *assembly)
+{
+ if (string_to_parse[3] >= 'A' && string_to_parse[3] <= 'Z')
+ *assembly = string_to_parse[3] - 'A';
+ else if (string_to_parse[3] == '#')
+ *assembly = dectoul(&string_to_parse[4], NULL);
+ else
+ return -EINVAL;
+
+ return 0;
+}
+
static int get_cfgblock_interactive(void)
{
char message[CONFIG_SYS_CBSIZE];
char wb = 'n';
char mem8g = 'n';
int len = 0;
+ int ret = 0;
/* Unknown module by default */
tdx_hw_tag.prodid = 0;
}
while (len < 4) {
- sprintf(message, "Enter the module version (e.g. V1.1B): V");
+ sprintf(message, "Enter the module version (e.g. V1.1B or V1.1#26): V");
len = cli_readline(message);
}
tdx_hw_tag.ver_major = console_buffer[0] - '0';
tdx_hw_tag.ver_minor = console_buffer[2] - '0';
- tdx_hw_tag.ver_assembly = console_buffer[3] - 'A';
+
+ ret = parse_assembly_string(console_buffer, &tdx_hw_tag.ver_assembly);
+ if (ret) {
+ printf("Parsing module version failed\n");
+ return ret;
+ }
while (len < 8) {
sprintf(message, "Enter module serial number: ");
{
char message[CONFIG_SYS_CBSIZE];
int len;
+ int ret = 0;
printf("Supported carrier boards:\n");
printf("CARRIER BOARD NAME\t\t [ID]\n");
tdx_car_hw_tag.prodid = dectoul(console_buffer, NULL);
do {
- sprintf(message, "Enter carrier board version (e.g. V1.1B): V");
+ sprintf(message, "Enter carrier board version (e.g. V1.1B or V1.1#26): V");
len = cli_readline(message);
} while (len < 4);
tdx_car_hw_tag.ver_major = console_buffer[0] - '0';
tdx_car_hw_tag.ver_minor = console_buffer[2] - '0';
- tdx_car_hw_tag.ver_assembly = console_buffer[3] - 'A';
+
+ ret = parse_assembly_string(console_buffer, &tdx_car_hw_tag.ver_assembly);
+ if (ret) {
+ printf("Parsing module version failed\n");
+ return ret;
+ }
while (len < 8) {
sprintf(message, "Enter carrier board serial number: ");
#define SERIAL_STR_LEN 8
#define MODULE_VER_STR_LEN 4 // V1.1
-#define MODULE_REV_STR_LEN 1 // [A-Z]
+#define MODULE_REV_STR_LEN 3 // [A-Z] or #[26-99]
#ifdef CONFIG_TDX_CFG_BLOCK
static char tdx_serial_str[SERIAL_STR_LEN + 1];
}
#endif /* CONFIG_SERIAL_TAG */
+static const char *get_board_assembly(u16 ver_assembly)
+{
+ static char ver_name[MODULE_REV_STR_LEN + 1];
+
+ if (ver_assembly < 26) {
+ ver_name[0] = (char)ver_assembly + 'A';
+ ver_name[1] = '\0';
+ } else {
+ snprintf(ver_name, sizeof(ver_name),
+ "#%u", ver_assembly);
+ }
+
+ return ver_name;
+}
+
int show_board_info(void)
{
unsigned char ethaddr[6];
snprintf(tdx_serial_str, sizeof(tdx_serial_str),
"%08u", tdx_serial);
snprintf(tdx_board_rev_str, sizeof(tdx_board_rev_str),
- "V%1d.%1d%c",
+ "V%1d.%1d%s",
tdx_hw_tag.ver_major,
tdx_hw_tag.ver_minor,
- (char)tdx_hw_tag.ver_assembly + 'A');
+ get_board_assembly(tdx_hw_tag.ver_assembly));
env_set("serial#", tdx_serial_str);
snprintf(tdx_car_serial_str, sizeof(tdx_car_serial_str),
"%08u", tdx_car_serial);
snprintf(tdx_car_rev_str, sizeof(tdx_car_rev_str),
- "V%1d.%1d%c",
+ "V%1d.%1d%s",
tdx_car_hw_tag.ver_major,
tdx_car_hw_tag.ver_minor,
- (char)tdx_car_hw_tag.ver_assembly + 'A');
+ get_board_assembly(tdx_car_hw_tag.ver_assembly));
env_set("carrier_serial#", tdx_car_serial_str);
printf("Carrier: Toradex %s %s, Serial# %s\n",