mirror of https://github.com/wolfSSL/wolfBoot.git
parent
01e22edb34
commit
e9d65b3bd2
11
Makefile
11
Makefile
|
@ -198,15 +198,18 @@ test-app/image.elf: wolfboot.elf
|
||||||
$(Q)$(MAKE) -C test-app WOLFBOOT_ROOT="$(WOLFBOOT_ROOT)" image.elf
|
$(Q)$(MAKE) -C test-app WOLFBOOT_ROOT="$(WOLFBOOT_ROOT)" image.elf
|
||||||
$(Q)$(SIZE) test-app/image.elf
|
$(Q)$(SIZE) test-app/image.elf
|
||||||
|
|
||||||
internal_flash.dd: $(BINASSEMBLE) wolfboot.bin $(BOOT_IMG) $(PRIVATE_KEY) test-app/image_v1_signed.bin
|
assemble_internal_flash.dd: FORCE
|
||||||
@echo "\t[MERGE] internal_flash.dd"
|
$(Q)$(BINASSEMBLE) internal_flash.dd \
|
||||||
$(Q)dd if=/dev/zero bs=1 count=$$(($(WOLFBOOT_SECTOR_SIZE))) > /tmp/swap
|
|
||||||
$(Q)$(BINASSEMBLE) $@ \
|
|
||||||
0 wolfboot.bin \
|
0 wolfboot.bin \
|
||||||
$$(($(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET))) test-app/image_v1_signed.bin \
|
$$(($(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET))) test-app/image_v1_signed.bin \
|
||||||
$$(($(WOLFBOOT_PARTITION_UPDATE_ADDRESS)-$(ARCH_FLASH_OFFSET))) /tmp/swap \
|
$$(($(WOLFBOOT_PARTITION_UPDATE_ADDRESS)-$(ARCH_FLASH_OFFSET))) /tmp/swap \
|
||||||
$$(($(WOLFBOOT_PARTITION_SWAP_ADDRESS)-$(ARCH_FLASH_OFFSET))) /tmp/swap
|
$$(($(WOLFBOOT_PARTITION_SWAP_ADDRESS)-$(ARCH_FLASH_OFFSET))) /tmp/swap
|
||||||
|
|
||||||
|
internal_flash.dd: $(BINASSEMBLE) wolfboot.bin $(BOOT_IMG) $(PRIVATE_KEY) test-app/image_v1_signed.bin
|
||||||
|
@echo "\t[MERGE] internal_flash.dd"
|
||||||
|
$(Q)dd if=/dev/zero bs=1 count=$$(($(WOLFBOOT_SECTOR_SIZE))) > /tmp/swap
|
||||||
|
make assemble_internal_flash.dd
|
||||||
|
|
||||||
factory.bin: $(BINASSEMBLE) wolfboot.bin $(BOOT_IMG) $(PRIVATE_KEY) test-app/image_v1_signed.bin
|
factory.bin: $(BINASSEMBLE) wolfboot.bin $(BOOT_IMG) $(PRIVATE_KEY) test-app/image_v1_signed.bin
|
||||||
@echo "\t[MERGE] $@"
|
@echo "\t[MERGE] $@"
|
||||||
$(Q)$(BINASSEMBLE) $@ \
|
$(Q)$(BINASSEMBLE) $@ \
|
||||||
|
|
|
@ -70,7 +70,31 @@ int do_cmd(const char *cmd)
|
||||||
if (strcmp(cmd, "reset") == 0) {
|
if (strcmp(cmd, "reset") == 0) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
if (strncmp(cmd, "get_tlv",7) == 0) {
|
||||||
|
uint8_t* imageHdr = (uint8_t*)WOLFBOOT_PARTITION_BOOT_ADDRESS;
|
||||||
|
uint8_t* ptr = NULL;
|
||||||
|
uint16_t tlv = 0x34; /* default */
|
||||||
|
int size;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
const char* tlvStr = strstr(cmd, "get_tlv=");
|
||||||
|
if (tlvStr) {
|
||||||
|
tlvStr += strlen("get_tlv=");
|
||||||
|
tlv = (uint16_t)atoi(tlvStr);
|
||||||
|
}
|
||||||
|
printf("Get TLV %04x\r\n", tlv);
|
||||||
|
|
||||||
|
size = wolfBoot_find_header(imageHdr + IMAGE_HEADER_OFFSET, tlv, &ptr);
|
||||||
|
if (size >= 0 && ptr != NULL) {
|
||||||
|
/* From here, the value 0xAABBCCDD is at ptr */
|
||||||
|
printf("TLV 0x%x:\n", tlv);
|
||||||
|
for (i=0; i<size; i++) {
|
||||||
|
printf(" 0x%02X ", ptr[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/* wrong command */
|
/* wrong command */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1085,7 +1085,10 @@ static int make_header_ex(int is_diff, uint8_t *pubkey, uint32_t pubkey_sz,
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
for (i = 0; i < CMD.custom_tlvs; i++) {
|
for (i = 0; i < CMD.custom_tlvs; i++) {
|
||||||
/* require 8-byte alignment */
|
/* require 8-byte alignment */
|
||||||
while ((header_idx % 8) != 0)
|
/* The offset '4' takes into account 2B Tag + 2B Len, so that the
|
||||||
|
* Value starts at (addr % 8 == 0) position.
|
||||||
|
*/
|
||||||
|
while ((header_idx % 8) != 4)
|
||||||
header_idx++;
|
header_idx++;
|
||||||
|
|
||||||
if (CMD.custom_tlv[i].buffer == NULL) {
|
if (CMD.custom_tlv[i].buffer == NULL) {
|
||||||
|
@ -1099,7 +1102,10 @@ static int make_header_ex(int is_diff, uint8_t *pubkey, uint32_t pubkey_sz,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add padding bytes. Sha-3 val field requires 8-byte alignment */
|
/* Add padding bytes. Sha-3 val field requires 8-byte alignment */
|
||||||
while ((header_idx % 8) != 0)
|
/* The offset '4' takes into account 2B Tag + 2B Len, so that the Value
|
||||||
|
* starts at (addr % 8 == 0) position.
|
||||||
|
*/
|
||||||
|
while ((header_idx % 8) != 4)
|
||||||
header_idx++;
|
header_idx++;
|
||||||
|
|
||||||
/* Calculate hashes */
|
/* Calculate hashes */
|
||||||
|
|
Loading…
Reference in New Issue