Skip to content

Conversation

@iabdalkader
Copy link

@iabdalkader iabdalkader commented Nov 17, 2025

This PR optimizes flash and memory usage.

Changes:

  • Disable CPP. This saves flash and memory used by libc heap.
  • Disable the shell for production builds. This saves about 70KBs FLASH and ~47KBs RAM.
  • Relocate llext heap to another SRAM and main stack to DTCM.
  • Add debug config overlay to easily build debug images.

To build debug images use: ./extra/build.sh <board> --debug
The build includes extra/debug.conf which enables:

  • Debug mode with assertions and verbose output
  • Debug-level logging (level 4)
  • Stack overflow detection
  • Thread monitoring
  • Debug optimizations (-Og)
  • Enable the shell

Needs:

@iabdalkader iabdalkader requested a review from pillo79 November 18, 2025 08:12
@iabdalkader iabdalkader marked this pull request as draft November 21, 2025 07:36
@iabdalkader
Copy link
Author

FYI @pillo79 @pennam for some reason enabling log level=4 (debug for everything) causes a hardfault on Portenta-H7. It shouldn't be a stack overflow issue, but I tried increasing all stacks anyway and it doesn't help. That said, it is very convenient and I have been using it locally, instead of adding debug options manually to conf files, so I will get it fixed somehow and let you know.

@iabdalkader iabdalkader marked this pull request as ready for review November 21, 2025 14:14
@iabdalkader
Copy link
Author

Actually, it turns out that it's just some log thread overflow, fixable by increasing stack sizes. However,, I decided to Not enable debug logs globally, because we don't really have extra memory for that and it makes it much harder to see the debug log you're looking for.

@iabdalkader iabdalkader requested a review from pennam November 21, 2025 14:19
@iabdalkader iabdalkader force-pushed the add_debug_overlay branch 2 times, most recently from 0cf7454 to ccd08d2 Compare November 26, 2025 14:11
@iabdalkader iabdalkader changed the title extra: Add debug config overlay. misc: Optimize flash and memory usage. Nov 26, 2025
@iabdalkader iabdalkader force-pushed the add_debug_overlay branch 2 times, most recently from 3fed70a to 5d1e8f5 Compare November 27, 2025 13:02
Add debug config fragment to easily build debug images.

Usage: ./extra/build.sh <board> --debug

The build includes extra/debug.conf which enables:

- Debug mode with assertions and verbose output
- Debug-level logging (level 4)
- Stack overflow detection
- Thread monitoring
- Debug optimizations (-Og)
- Enable shell.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
The created sketch log structures depends on the config:

CONFIG_LOG (IMMEDIATE/DEFERRED): creates log_const_sketch struct.
CONFIG_LOG_RUNTIME_FILTERING (implied by CONFIG_SHELL): creates log_dynamic_sketch struct.
CONFIG_LOG_MODE_IMMEDIATE + CONFIG_SHELL: creates both.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
- Disable CPP
- Disable shell
- Disable any debug log level
- Disable init stacks.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
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.

3 participants