Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

misc: Optimize flash and memory usage.#270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
iabdalkader wants to merge5 commits intoarduino:main
base:main
Choose a base branch
Loading
fromiabdalkader:add_debug_overlay

Conversation

@iabdalkader
Copy link

@iabdalkaderiabdalkader commentedNov 17, 2025
edited
Loading

This PR optimizes flash and memory usage, saving up to ~80KBs flash and ~50KBs RAM on some boards, by disabling the shell for production builds, CPP and using a unified heap for Zephyr and sketches. The saved memory is used to increase mbedtls heap to support cert loading, and the remaining added to main heap. For Portenta, ~100KBs should be available to user sketches.

Changes:

  • Disable libc heap (set to 0) and use a kernel heap for Zephyr and sketches.
  • 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.
  • 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

@iabdalkaderiabdalkader marked this pull request as draftNovember 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.

pennam reacted with thumbs up emoji

@iabdalkaderiabdalkader marked this pull request as ready for reviewNovember 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.

Add debug config fragment to easily build debug images.Usage: ./extra/build.sh <board> --debugThe 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>
@iabdalkaderiabdalkader changed the titleextra: Add debug config overlay.misc: Optimize flash and memory usage.Nov 26, 2025
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>
Replace the libc's malloc, free etc.. with wrappers that redirectmemory allocation Zephyr's kernel heap functions (k_malloc/k_free).Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This saves about 70KBs FLASH and ~47KBs RAM. The saved memoryis used to increase mbedtls heap to support cert loading, andthe remaining added to main heap.Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@pillo79pillo79Awaiting requested review from pillo79

@pennampennamAwaiting requested review from pennam

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@iabdalkader

[8]ページ先頭

©2009-2025 Movatter.jp