X Tutup
Skip to content

llext: adding missing heap when llext is disabled#331

Draft
andreagilardoni wants to merge 8 commits intoarduino:mainfrom
andreagilardoni:sketch-heap
Draft

llext: adding missing heap when llext is disabled#331
andreagilardoni wants to merge 8 commits intoarduino:mainfrom
andreagilardoni:sketch-heap

Conversation

@andreagilardoni
Copy link

@andreagilardoni andreagilardoni commented Feb 12, 2026

When CONFIG_LLEXT=n llext_heap is not defined, thus raising compile time error when compiling with that option disabled. A further generic config is added, in order to customize the size of the heap (SKETCH_HEAP_SIZE)

NOTE that the only way to use a sketch with a loader compiled with llext disabled is to use static linkage mode. This could help save up some space.

@andreagilardoni andreagilardoni force-pushed the sketch-heap branch 4 times, most recently from 93ef78b to 3b90f8a Compare February 12, 2026 15:33
Copy link

@pillo79 pillo79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allowing to build with LLEXT=n is a worthy goal! But I believe some things need to be addressed here:

  • remove the last commit (LLEXT_EDK is an absolutely mandatory part of the build!)
  • fix various _defconfig typos in the first commit
  • use the opportunity to improve the logic in main.c

Thanks!

loader/main.c Outdated
typedef void (*entry_point_t)(struct k_heap *heap, size_t heap_size);
entry_point_t entry_point = (entry_point_t)(base_addr + HEADER_LEN + 1);
entry_point(&llext_heap, llext_heap.heap.init_bytes);
entry_point(&SKETCH_HEAP, SKETCH_HEAP.heap.init_bytes);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug that needed to be addressed anyway, so let's write this line like this:

Suggested change
entry_point(&SKETCH_HEAP, SKETCH_HEAP.heap.init_bytes);
entry_point(&SKETCH_HEAP, SKETCH_HEAP_SIZE);

Copy link
Author

@andreagilardoni andreagilardoni Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is entry_point expecting a KB measured or B measured value? I guess byte measured

loader/main.c Outdated
}
}

if (!IS_ENABLED(CONFIG_LLEXT)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's enough, let's not add more #ifs please! 😁

You can replace this with a global #ifdef CONFIG_LLEXT that goes all the way to the return 0 at the end of this function. In the meantime, get rid of all the other #if CONFIG_LLEXT that are now redundant.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to keep something that can notify an user that the loader is built with llext disabled when linking a sketch with dynamic link mode. I think it can be easy to forget of this build choice and troublesome to find out that the sketch is not running because of this

@andreagilardoni andreagilardoni force-pushed the sketch-heap branch 3 times, most recently from d3af987 to 3416a2a Compare February 24, 2026 12:24
@andreagilardoni andreagilardoni marked this pull request as draft February 24, 2026 16:50
@andreagilardoni andreagilardoni force-pushed the sketch-heap branch 4 times, most recently from 5ec2d57 to aa32654 Compare March 2, 2026 08:57
Defined config for sketch heap size, now LLEXT_HEAP_SIZE defaults to this
value

Signed-off-by: Andrea Gilardoni <a.gilardoni@arduino.cc>
When llext is disabled lext-edk include file generation had a recursion
bug

Signed-off-by: Andrea Gilardoni <a.gilardoni@arduino.cc>
When CONFIG_LLEXT=n llext_heap is not defined, thus raising compile time
error when compiling with that option disabled.
NOTE that the only way to use a sketch with a loader compiled with llext
disabled is to use static linkage mode. This could help save up some space.

Signed-off-by: Andrea Gilardoni <a.gilardoni@arduino.cc>
This commits make it possible to have the same exported symbols as an
llext build, when llext is disabled by means of:
- ephemeral symbols in section .exported_sym
- gen_provides: mechanism to include symbols through list of regex

Signed-off-by: Andrea Gilardoni <a.gilardoni@arduino.cc>
Making script gen_provides avoid failing when no symbol is provided,
instead it just prints a warning message. This is required to avoid
extra/build.sh fail when the loader is build without llext support

Signed-off-by: Andrea Gilardoni <a.gilardoni@arduino.cc>
rename kheap_llext_heap and kheap_llext_heap_size symbols to
kheap__sketch_heap

Signed-off-by: Andrea Gilardoni <a.gilardoni@arduino.cc>
In this way wew are able to use symbol linkage statically without the
need of the entire LLEXT runtime
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

Built 0.53.2-0.dev+34b3707

CI run FAILED: 🔥 giga, 🔥 nano33ble, 🔥 nano_matter, 🔥 niclasense, 🔥 opta, 🔥 portentac33, 🔥 portentah7, 🔥 unoq, 🔥 ek_ra8d1, 🔥 frdm_mcxn947, 🔥 frdm_rw612

ArtifactBoardCoreTestsRAMSketchesWarningsErrors
🔥 zephyr_contrib ek_ra8d1 🔥Core build failed!
frdm_mcxn947 🔥Core build failed!
frdm_rw612 🔥Core build failed!
🔥 zephyr_main giga 🔥Core build failed!
nano33ble 🔥Core build failed!
nano_matter 🔥Core build failed!
niclasense 🔥Core build failed!
opta 🔥Core build failed!
portentac33 🔥Core build failed!
portentah7 🔥Core build failed!
🔥 zephyr_unoq unoq 🔥Core build failed!
Legend

BoardTestStatus description
🔥 🔥 Test run failed to complete.
🔴 Test completed with unexpected errors.
✔️* 🚫 Test completed with errors, but all are known/expected.
✅* 🟡 Test completed with some warnings; no errors detected.
🟢 Test passed successfully, with no warnings or errors.
🌑 🌑 Test was skipped.

Caution

zephyr_contrib is blocked due to failures on ek_ra8d1, frdm_mcxn947, frdm_rw612!

Caution

zephyr_main is blocked due to failures on giga, nano33ble, nano_matter, niclasense, opta, portentac33, portentah7!

Caution

zephyr_unoq is blocked due to failures on unoq!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup