Skip to content

Support spi/qspi flash chips over 16MB. - #5166

Closed
andrewleech wants to merge 1 commit into
micropython:masterfrom
andrewleech:stm32-pybd-qspi
Closed

andrewleech wants to merge 1 commit into
micropython:masterfrom
andrewleech:stm32-pybd-qspi

Conversation

@andrewleech

Copy link
Copy Markdown
Contributor

Over 16MB, 32-bit addressing is required rather than the standard 24-bit.

These changes were originally part of dpgeorge#11

@dpgeorge was your commit "stm32/qspi: Abort any transfers if peripheral is busy." intentionally left out from the merging of your pybd branch?

I haven't done any of the suggested cleanup / separating of the larger spiflash support yet, this is just pushing a rebased version of my previous attempt here.

@andrewleech

Copy link
Copy Markdown
Contributor Author

@dpgeorge I just tested this newer change set on master and it works well for my 32MB spiflash chip, split into two partitions (fat and lfs).

@dpgeorge

Copy link
Copy Markdown
Member

was your commit "stm32/qspi: Abort any transfers if peripheral is busy." intentionally left out from the merging of your pybd branch?

Yes. That was trying to fix the problems with the CPU doing speculative reads from QSPI flash, and in the end it was not needed (at least so far I everything works fine).

I just tested this newer change set on master and it works well for my 32MB spiflash chip, split into two partitions (fat and lfs).

Great! I think I have an STM32F7 discovery board with >16MB flash which I can test this on.

Comment thread ports/stm32/qspi.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this is a macro this test could probably become static/compile-time, and this whole set of changes made compile-time configurable.

Although there could be value in keeping it dynamically selectable I think for now it'd be good to try and make it static.

Eg:

#if (MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 -3 -1) >= 24
#define QSPI_CMD 0xec
#define QSPI_ADSIZE 3
#else 
#define QSPI_CMD 0xeb
#define QSPI_ADSIZE 2
#endif 

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

While I like the idea of getting to the point of being able to configure spi / qspi flash devices at runtime, this does make sense to have static in the mean time! It can be reverted to a dynamic form if/when the rest of the module supports it!

@andrewleech

Copy link
Copy Markdown
Contributor Author

Memory map command settings now static / compile-time configured.

@iabdalkader

Copy link
Copy Markdown
Contributor

Is this going to be merged any time soon ?

Comment thread drivers/bus/qspi.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't this be (addr & 0xff000000)? Since addr is measured in bytes everywhere (I think, that would need to be verified).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wow... I'm, not sure now where the 0xF000 came from... unless in an earlier iteration of this change that val was in blocks?

Either way, yes I agree with the change. It also likely explains the corruption issue I've posted about.

Thanks for picking this up!

Comment thread drivers/bus/softqspi.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This needs to be cmd_buf[5] in the case of 32-bit addressing (gcc 9 caught this as a compile error).

@dpgeorge

Copy link
Copy Markdown
Member

Thanks @andrewleech for this, it's nice and clean. I tested it (with the 2 changes suggested above) on an STM32F769DISC with the 64MB spiflash configured for storage, and it seems to work correctly.

Over 16MB, 32-bit addressing is required rather than the standard 24-bit.
@dpgeorge

Copy link
Copy Markdown
Member

Rebased, some code-style changes made, and merged in 30501d3

Thank you!

@dpgeorge dpgeorge closed this Jan 30, 2020
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Aug 24, 2021
Don't double-list modules that MP_REGISTER_MODULE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants