-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(elf2image): Try to correct MMU page size if not specified
This commit fixes issue with using elf2image command without --flash-mmu-page-size. In that case, app info segment might be incorrectly placed in the image. This is fixed by checking if app info segment is present and if so, use page size from it or from its alignment. Closes #1062
- Loading branch information
Showing
8 changed files
with
344 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CC = riscv32-esp-elf-gcc | ||
CFLAGS = -Os -ffreestanding -nostdlib | ||
LDFLAGS = -T esp32c6-appdesc.ld | ||
|
||
TARGET = esp32c6-appdesc.elf | ||
SRC = main.c | ||
OBJ = main.o | ||
|
||
all: $(TARGET) | ||
|
||
$(TARGET): $(OBJ) | ||
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) | ||
|
||
%.o: %.c | ||
$(CC) $(CFLAGS) -c $< -o $@ | ||
|
||
clean: | ||
rm -f $(OBJ) $(TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
MEMORY | ||
{ | ||
/** | ||
* 0x42000000 is start of flash + 0x20 for image + extended header and segment header | ||
* 0x14c is length of esp_app_desc_t structure | ||
*/ | ||
drom_seg (R) : org = 0x42000020, len = 0x14c | ||
} | ||
|
||
SECTIONS | ||
{ | ||
.flash.appdesc : | ||
{ | ||
KEEP(*(.flash.appdesc)) | ||
} > drom_seg | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <stdint.h> | ||
|
||
// This is the structure of the application description section in the binary image (taken from ESP-IDF). | ||
typedef struct { | ||
uint32_t magic_word; | ||
uint32_t secure_version; | ||
uint32_t reserv1[2]; | ||
char version[32]; | ||
char project_name[32]; | ||
char time[16]; | ||
char date[16]; | ||
char idf_ver[32]; | ||
uint8_t app_elf_sha256[32]; | ||
uint16_t min_efuse_blk_rev_full; | ||
uint16_t max_efuse_blk_rev_full; | ||
uint8_t mmu_page_size; | ||
uint8_t reserv3[3]; | ||
uint32_t reserv2[18]; | ||
} esp_app_desc_t; | ||
|
||
__attribute__((section(".flash.appdesc"))) | ||
esp_app_desc_t my_app_desc = { | ||
.magic_word = 0xABCD5432, | ||
.secure_version = 0xffffffff, | ||
.reserv1 = {0xffffffff, 0xffffffff}, | ||
.version = "_______________________________", | ||
.project_name = "-------------------------------", | ||
.time = "xxxxxxxxxxxxxxx", | ||
.date = "yyyyyyyyyyyyyyy", | ||
.idf_ver = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", | ||
.app_elf_sha256 = { | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
}, | ||
.min_efuse_blk_rev_full = 0xffff, | ||
.max_efuse_blk_rev_full = 0xffff, | ||
.mmu_page_size = 0, | ||
.reserv3 = {0xff, 0xff, 0xff}, | ||
.reserv2 = { | ||
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, | ||
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, | ||
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, | ||
0xffffffff, 0xffffffff, 0xffffffff | ||
}, | ||
}; |
Oops, something went wrong.