Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@xrip
Copy link
Owner

@xrip xrip commented Jul 11, 2025

No description provided.

google-labs-jules bot and others added 2 commits July 11, 2025 09:09
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.
Copy link

@gemini-code-assist gemini-code-assist bot left a 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_KBS or PSRAM/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/foreach statements for better readability and consistency, and reordered psram in the target_link_libraries list.
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

  1. 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.

@xrip xrip merged commit 7c235c2 into master Jul 11, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a 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")

Choose a reason for hiding this comment

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

medium

Consider adding a suffix like -PSRAM to the BUILD_NAME when external PSRAM is enabled to maintain consistency with other memory configurations. This will help distinguish build artifacts.

            message(STATUS "External PSRAM ON 18/19/20/21 pins")
            set(BUILD_NAME "${BUILD_NAME}-PSRAM")

$<$<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}>>

Choose a reason for hiding this comment

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

medium

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}>>

@xrip xrip deleted the feature/configurable-vmem-psram-logic branch August 4, 2025 08:43
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