Fix cardputer boot loop, and do some cleanup#10607
Merged
tannewt merged 4 commits intoadafruit:mainfrom Sep 4, 2025
Merged
Conversation
49024ef to
c121d73
Compare
- For `cardputer_keyboard.c`, allocate `DemuxKeyMatrix` it creates and the objects it holds (all the way down) on the port heap, because it lives past VM's. - To do the above, add support for non-VM heap for `DemuxKeyMatrix` and the `keypad` allocations it needs by passing an arg `use_gc_allocator`, as is done in `lvfontio`. - Add `mp_obj_port_malloc()`, `mp_obj_port_malloc_var()`, `mp_obj_new_port_tuple()`, all of which allocate on the port heap, not the VM heap. - Add `port_malloc_zero()`, because `port_malloc()` did not zero out its allocation, unlike VM heap allocations. I got caught by this. - Move `port_gc_collect()` from `main.c` to `supervisor/port.c` for consistency. This function is not actually used by anyone, but I was considering using it. - Add an `MP_WEAK` `mp_board_init()`, for board-specific initializations needed when a VM starts. Also considered, but not used. Added anyway for possible future use. - Add an `MP_WEAK` `board_gc_collect()`, for board-specific gc. Not used. - Add an `MP_WEAK` `port_gc_collect()`, for port-specific gc. Not used. - Don't duplicate keyboard code between `boards/m5stack_cardputer` and `boards/m5stack_cardputer_ros`. Instead, add a `ports/espressif/module` directory for this code, in the style of a port-specific `module` directory, like the port-specific `bindings` directories.
c121d73 to
de2efe0
Compare
Avoids the new Wunterminated-string-literal when compiled with gcc 15.1. It would be preferable to just disable this warning, but Clang -Wunknown-warning-option kicks in even when disabling warnings so this becomes fiddly to apply. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Avoids the new Wunterminated-string-literal when compiled with gcc 15.1. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Collaborator
Author
|
I cherry-picked two commits from micropython#17269 to fix a gcc 15 build problem on Windows. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detailed changes:
cardputer_keyboard.c, allocateDemuxKeyMatrixit creates and the objects it holds (all the way down) on the port heap, because it lives past VM's.DemuxKeyMatrixand thekeypadallocations it needs by passing an arguse_gc_allocator, as is done inlvfontio.mp_obj_port_malloc(),mp_obj_port_malloc_var(),mp_obj_new_port_tuple(), all of which allocate on the port heap, not the VM heap.port_malloc_zero(), becauseport_malloc()did not zero out its allocation, unlike VM heap allocations. I got caught by this.port_gc_collect()frommain.ctosupervisor/port.cfor consistency. This function is not actually used by anyone, but I was considering using it.-
Add anMP_WEAKmp_board_init(), for board-specific initializations needed when a VM starts. Also considered, but not used. Added anyway for possible future use.Add anMP_WEAKboard_gc_collect(), for board-specific gc. Not used.boards/m5stack_cardputerandboards/m5stack_cardputer_ros. Instead, add aports/espressif/moduledirectory for this code, in the style of a port-specificmoduledirectory, like the port-specificbindingsdirectories.My original approach to this was to make the
cardputer_keyboardobject be allocated when the VM started up. That required less pervasive changes, and it worked fine, except for thePress any key...when the VM finished. So I had to make it live across VM's.I tested and @dglaude also tested (thanks!).