Add fw cmd to get UDI

This commit is contained in:
Daniel Lublin 2022-11-21 14:19:09 +01:00 committed by Michael Cardell Widerkrantz
parent 98a3a1240b
commit acb9c37ee7
No known key found for this signature in database
GPG Key ID: D3DB3DDF57E704E5
3 changed files with 24 additions and 1 deletions

View File

@ -15,10 +15,11 @@ static volatile uint32_t *switch_app = (volatile uint32_t *)TK1_MMIO_TK1_SWITCH_
static volatile uint32_t *name0 = (volatile uint32_t *)TK1_MMIO_TK1_NAME0;
static volatile uint32_t *name1 = (volatile uint32_t *)TK1_MMIO_TK1_NAME1;
static volatile uint32_t *ver = (volatile uint32_t *)TK1_MMIO_TK1_VERSION;
static volatile uint32_t *udi = (volatile uint32_t *)TK1_MMIO_TK1_UDI_FIRST;
static volatile uint32_t *cdi = (volatile uint32_t *)TK1_MMIO_TK1_CDI_FIRST;
static volatile uint32_t *app_addr = (volatile uint32_t *)TK1_MMIO_TK1_APP_ADDR;
static volatile uint32_t *app_size = (volatile uint32_t *)TK1_MMIO_TK1_APP_SIZE;
static volatile uint8_t *fw_ram = (volatile uint8_t *)TK1_MMIO_FW_RAM_BASE;
static volatile uint8_t *fw_ram = (volatile uint8_t *)TK1_MMIO_FW_RAM_BASE;
#define LED_RED (1 << TK1_MMIO_TK1_LED_R_BIT)
#define LED_GREEN (1 << TK1_MMIO_TK1_LED_G_BIT)
@ -138,6 +139,21 @@ int main()
fwreply(hdr, FW_RSP_NAME_VERSION, rsp);
break;
case FW_CMD_GET_UDI:
puts("FW_CMD_GET_UDI\n");
if (hdr.len != 1) {
// Bad cmd length
rsp[0] = STATUS_BAD;
fwreply(hdr, FW_RSP_GET_UDI, rsp);
break;
}
rsp[0] = STATUS_OK;
uint32_t udi_words[2];
wordcpy(udi_words, (void *)udi, 2);
memcpy(rsp + 1, udi_words, 2 * 4);
fwreply(hdr, FW_RSP_GET_UDI, rsp);
break;
case FW_CMD_LOAD_USS:
puts("cmd: load-uss\n");

View File

@ -96,6 +96,11 @@ void fwreply(struct frame_header hdr, enum fwcmd rspcode, uint8_t *buf)
nbytes = 128;
break;
case FW_RSP_GET_UDI:
len = LEN_32;
nbytes = 32;
break;
default:
puts("fwreply(): Unknown response code: 0x");
puthex(rspcode);

View File

@ -37,6 +37,8 @@ enum fwcmd {
FW_CMD_GET_APP_DIGEST = 0x09,
FW_CMD_LOAD_USS = 0x0a,
FW_RSP_LOAD_USS = 0x0b,
FW_CMD_GET_UDI = 0x0c,
FW_RSP_GET_UDI = 0x0d,
/* ... */
FW_RSP_GET_APP_DIGEST = 0x10, // encoded as 0x10 for backwards compatibility
};