Skip to content

Conversation

cristidragomir97
Copy link

  • 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

@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?

- Get flash information (size, sector size, page size)


### Device Tree Setup
Copy link

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?

#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

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"

flash_dev = QSPI_FLASH_DEVICE;

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

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.

return false;
}

return device_is_ready(flash_dev);
Copy link

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.

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