-
Notifications
You must be signed in to change notification settings - Fork 15
Feature/configurable vmem psram logic #11
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I've implemented new logic for the `TOTAL_VIRTUAL_MEMORY_KBS` option: - Setting `TOTAL_VIRTUAL_MEMORY_KBS` to a non-zero value enables a virtual memory mode for that many KBS and completely disables all PSRAM functionality (generic and onboard). The build name will include "-VMEM<size>k". - Setting `TOTAL_VIRTUAL_MEMORY_KBS` to "0" (the default) disables the virtual memory feature and enables PSRAM mode. In this mode, PSRAM (generic or onboard via `ONBOARD_PSRAM` option for RP2350) functions as it did before. Build name and compile definitions reflect the active PSRAM configuration. This change correctly interprets the requirement that enabling virtual memory (by setting a non-zero KBS value) means PSRAM should not be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @xrip, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the build system's flexibility by introducing configurable virtual memory support, allowing developers to choose between using PSRAM or a specified amount of virtual memory. This change ensures that the firmware is built with the appropriate memory management strategy, adapting to different hardware configurations and memory requirements.
Highlights
- Configurable Memory Management: Introduced a new CMake option,
TOTAL_VIRTUAL_MEMORY_KBS, allowing users to specify the amount of virtual memory to use. Setting this to a value greater than 0 enables virtual memory and automatically disables PSRAM, ensuring mutual exclusivity between the two memory management approaches. - Build System Integration: Updated the build process to reflect the chosen memory configuration. The build name now includes an indicator for virtual memory size (e.g.,
-SWAP2048k) or PSRAM details, providing clear identification of the compiled firmware's memory setup. - Compiler Definitions: Adjusted compiler definitions to correctly pass the selected memory configuration (either
TOTAL_VIRTUAL_MEMORY_KBSorPSRAM/ONBOARD_PSRAM_GPIO) to the application code, ensuring the software behaves according to the build-time memory choices. - CMake Formatting and Cleanup: Applied minor formatting improvements to CMake
if/else/foreachstatements for better readability and consistency, and reorderedpsramin thetarget_link_librarieslist.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a configurable virtual memory system using a swap file, as an alternative to PSRAM. The changes in CMakeLists.txt correctly add a new option TOTAL_VIRTUAL_MEMORY_KBS and adjust the build process. My review includes suggestions to improve the maintainability and consistency of the build script.
| # For now, keep it simple: if not ONBOARD_PSRAM, no specific PSRAM string is added here by default, | ||
| # unless drivers/psram itself adds something or we want a generic "-PSRAM" tag. | ||
| # The original file only added ONBOARD_PSRAM specifics. | ||
| message(STATUS "External PSRAM ON 18/19/20/21 pins") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $<$<BOOL:${USE_VIRTUAL_MEMORY_INSTEAD_OF_PSRAM}>:TOTAL_VIRTUAL_MEMORY_KBS=${TOTAL_VIRTUAL_MEMORY_KBS}> | ||
| # PSRAM related definitions (only if NOT using virtual memory) | ||
| $<$<NOT:$<BOOL:${USE_VIRTUAL_MEMORY_INSTEAD_OF_PSRAM}>>:PSRAM> | ||
| $<$<NOT:$<BOOL:${USE_VIRTUAL_MEMORY_INSTEAD_OF_PSRAM}>>:$<$<AND:$<NOT:$<STREQUAL:${PICO_PLATFORM},rp2040>>,$<BOOL:${ONBOARD_PSRAM}>>:ONBOARD_PSRAM_GPIO=${ONBOARD_PSRAM_GPIO}>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This nested generator expression is complex and hard to read. Simplify it by flattening the conditions into a single expression to improve readability and maintainability.
$<$<AND:$<NOT:$<BOOL:${USE_VIRTUAL_MEMORY_INSTEAD_OF_PSRAM}>>,$<NOT:$<STREQUAL:${PICO_PLATFORM},rp2040>>,$<BOOL:${ONBOARD_PSRAM}>>:ONBOARD_PSRAM_GPIO=${ONBOARD_PSRAM_GPIO}>>
No description provided.