Skip to content

Commit 56c61bc

Browse files
committed
post_build: offset fixed to 16 bytes
1 parent ecd7be9 commit 56c61bc

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

extra/post_build_tool/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ func main() {
3636
// Create the new content with the length in front
3737
len_str := fmt.Sprintf("%d", length)
3838
newContent := append([]byte(len_str), 0, byte(debug))
39+
// make newContent 16 bytes
40+
tmp := make([]byte, 16-len(newContent))
41+
newContent = append(newContent, tmp...)
3942
newContent = append(newContent, content...)
4043

4144
// Write the new content to the new file

loader/main.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,24 @@ static int loader(const struct shell *sh)
5353
return 0;
5454
}
5555

56-
int header_len = endptr - header + 2;
56+
int header_len = 16;
5757

58+
#if defined(CONFIG_LLEXT_STORAGE_WRITABLE)
5859
uint8_t* sketch_buf = k_aligned_alloc(4096, sketch_buf_len);
5960

61+
if (!sketch_buf) {
62+
printk("Unable to allocate %d bytes\n", sketch_buf_len);
63+
}
64+
6065
rc = flash_area_read(fa, header_len, sketch_buf, sketch_buf_len);
6166
if (rc) {
6267
printk("Failed to read sketch area, rc %d\n", rc);
6368
return rc;
6469
}
70+
#else
71+
uint32_t offset = FIXED_PARTITION_OFFSET(user_sketch);
72+
uint8_t* sketch_buf = (uint8_t*)(offset+header_len);
73+
#endif
6574

6675
struct llext_buf_loader buf_loader = LLEXT_BUF_LOADER(sketch_buf, sketch_buf_len);
6776
struct llext_loader *ldr = &buf_loader.loader;

0 commit comments

Comments
 (0)