Skip to content

Added raw QSPI functionality for the Arduino Giga#224

Open
cristidragomir97 wants to merge 7 commits intoarduino:mainfrom
cristidragomir97:main
Open

Added raw QSPI functionality for the Arduino Giga#224
cristidragomir97 wants to merge 7 commits intoarduino:mainfrom
cristidragomir97:main

Conversation

@cristidragomir97
Copy link
Copy Markdown

  • Device Tree Configuration (variants/arduino_giga_r1_stm32h747xx_m7/arduino_giga_r1_stm32h747xx_m7.overlay):

    • Added complete QSPI flash device tree node configuration
    • Configured QuadSPI controller with proper pinctrl mappings:
      • Clock: pf10
      • CS: pg6
      • IO0-IO3: pd11, pd12, pe2, pf6
    • Added qspi_flash device node with:
      • Compatible: st,stm32-qspi-nor
      • Size: 128 Mbits (16 MB)
      • Max frequency: 72 MHz
      • Bus width: 4 (quad mode)
  • Board Configuration (variants/arduino_giga_r1_stm32h747xx_m7/arduino_giga_r1_stm32h747xx_m7.conf):

    • Enabled QSPI flash support (previously commented out)
    • Added configuration options:
      • CONFIG_FLASH=y
      • CONFIG_FLASH_STM32_QSPI=y (corrected from invalid CONFIG_SPI_STM32_QSPI)
      • CONFIG_FLASH_MAP=y
      • CONFIG_FLASH_PAGE_LAYOUT=y
  • Library (libraries/QSPI)

    • bool begin() - Initialize QSPI flash
    • bool read(uint32_t address, void* data, size_t size) - Read data
    • bool write(uint32_t address, const void* data, size_t size) - Write data
    • bool erase(uint32_t address, size_t size) - Erase sector/block
    • size_t getFlashSize() - Get total flash size
    • size_t getSectorSize() - Get erase sector size
    • size_t getPageSize() - Get write page size
    • bool isReady() - Check if flash is ready
    • bool isValidAddress(uint32_t address, size_t size) - Validate address range
    • void end() - Deinitialize
  • ** Example Sketch**('libraries/QSPI/examples')
    Initialises flash storage, erases sectors, reads and writes in a loop.

Copy link
Copy Markdown

@pillo79 pillo79 left a comment

Choose a reason for hiding this comment

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

Thanks, a few remarks below. But on a more general note, why did you need any of the changes in the Giga variant folder? The only thing I think was required was defining a generic qspi_flash, but it can be done with a simple one-liner:

qspi_flash: &n25q128a1 {};

everything else should be already set up in the upstream board. Can you double check please?

Comment thread libraries/QSPI/README.md Outdated
- Get flash information (size, sector size, page size)


### Device Tree Setup
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not sure the following part is relevant for Arduino users, only a selected few know about any of this 🙂
Maybe you can move this info to a more specific file, such as README.zephyr.md?

Comment thread libraries/QSPI/QSPI.cpp Outdated
#define QSPI_FLASH_DEVICE DEVICE_DT_GET(QSPI_FLASH_NODE)
#else
#define QSPI_FLASH_DEVICE NULL
#warning "QSPI flash device not found in device tree"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
#warning "QSPI flash device not found in device tree"
#warning "No QSPI flash available on this board"

Comment thread libraries/QSPI/QSPI.cpp Outdated
flash_dev = QSPI_FLASH_DEVICE;

if (!device_is_ready(flash_dev)) {
flash_dev = nullptr;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use either NULL or nullptr in the file for consistency.

Comment thread libraries/QSPI/QSPI.cpp Outdated
return false;
}

return device_is_ready(flash_dev);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This does not verify the device can accept more commands, but simply that it's enabled and has passed init(). Since this is already tested in begin, IMO it's better to return true here.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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