SPI FLASH 2 in PYBD_SF2

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
Post Reply
User avatar
Meekdai
Posts: 39
Joined: Mon Jan 29, 2018 12:45 pm

SPI FLASH 2 in PYBD_SF2

Post by Meekdai » Thu Jun 27, 2019 11:51 am

2MByte external flash with code execution capabilities (extends internal flash)
I want to ask, is this the same as the internal RAM of the chip? Can pyboard(STM32F405) increase RAM (Memory mapping) in this way? Thanks.

User avatar
dhylands
Posts: 3204
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: SPI FLASH 2 in PYBD_SF2

Post by dhylands » Thu Jun 27, 2019 9:01 pm

No - this extends the flash, and not the RAM.

User avatar
Meekdai
Posts: 39
Joined: Mon Jan 29, 2018 12:45 pm

Re: SPI FLASH 2 in PYBD_SF2

Post by Meekdai » Fri Jun 28, 2019 12:54 am

dhylands wrote:
Thu Jun 27, 2019 9:01 pm
No - this extends the flash, and not the RAM.
I don't understand the difference between the two QSPI FLASH on SF2. I thought 'code execution capabilities'='Memory mapping'. I find that ESP32 supports external SPI RAM.

User avatar
dhylands
Posts: 3204
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: SPI FLASH 2 in PYBD_SF2

Post by dhylands » Fri Jun 28, 2019 1:39 am

RAM is voltaile and can be changed.

Flash is non-volatile and can't be changed like RAM. In order to change flash, you need to erase a block first and then write the contents of the block with the new data.

When you power off your MCU flash retains its contents and RAM doesn't.

On the SF2, one of the QSPIs has execute capability, which means that to the MCU it looks just like internal flash and you can execute code from it directly.

The second QSPI doesn't have execute capability and can only be read, erased or written as data. This is suitable for a flash based filesystem for storing files, rather than directly executing code.

Some of the ESP32s have PSRAM chips which extend the RAM. The SF2 doesn't.

Online
User avatar
jimmo
Posts: 427
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: SPI FLASH 2 in PYBD_SF2

Post by jimmo » Fri Jun 28, 2019 1:43 am

Memory mapped means that it's accessible as part of the memory space of the CPU, and accessible like RAM (which is why you can execute code from it). Unlike RAM, it is read-only.

User avatar
Meekdai
Posts: 39
Joined: Mon Jan 29, 2018 12:45 pm

Re: SPI FLASH 2 in PYBD_SF2

Post by Meekdai » Fri Jun 28, 2019 2:30 am

dhylands wrote:
Fri Jun 28, 2019 1:39 am
RAM is voltaile and can be changed.

Flash is non-volatile and can't be changed like RAM. In order to change flash, you need to erase a block first and then write the contents of the block with the new data.

When you power off your MCU flash retains its contents and RAM doesn't.

On the SF2, one of the QSPIs has execute capability, which means that to the MCU it looks just like internal flash and you can execute code from it directly.

The second QSPI doesn't have execute capability and can only be read, erased or written as data. This is suitable for a flash based filesystem for storing files, rather than directly executing code.

Some of the ESP32s have PSRAM chips which extend the RAM. The SF2 doesn't.
Thank you for your response, can I extend a PSRAM to SF2 via WBUS? I can design a WBUS PCB board that extends PSRAM, but I am not sure if it can be implemented in the software.

User avatar
dhylands
Posts: 3204
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: SPI FLASH 2 in PYBD_SF2

Post by dhylands » Fri Jun 28, 2019 2:35 am

I'm not sure - you'd need to check the datasheet for the SF2 and find out what it supports for external RAM, and then see if the pins to support that are available on WBUS.

And even then, I don't know what state micropython is in as far as supporting external RAM on the stm32. You'd probably need to make some changes to the firmware as well.

User avatar
Meekdai
Posts: 39
Joined: Mon Jan 29, 2018 12:45 pm

Re: SPI FLASH 2 in PYBD_SF2

Post by Meekdai » Fri Jun 28, 2019 3:07 am

dhylands wrote:
Fri Jun 28, 2019 2:35 am
I'm not sure - you'd need to check the datasheet for the SF2 and find out what it supports for external RAM, and then see if the pins to support that are available on WBUS.

And even then, I don't know what state micropython is in as far as supporting external RAM on the stm32. You'd probably need to make some changes to the firmware as well.
I understand that SRAM requires STM32's proprietary FSMC interface, but SPI RAM can use the same software SPI interface as external SPI FLASH.

https://www.sramsun.com/show-21-723-1.html This link uses the VTI7064 chip to extend the RAM to the STM32. I believe it can also be implemented on pyb. This is very helpful for applications with a large amount of RAM.

User avatar
dhylands
Posts: 3204
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: SPI FLASH 2 in PYBD_SF2

Post by dhylands » Fri Jun 28, 2019 4:14 am

I know you could add a SPI RAM and use it to read/write from (like a disk). I don't know if the stm32 used in the SF2 will transparently make it behave like internal RAM. You'll need to read through the datasheet and see if it supports something like that.

User avatar
Meekdai
Posts: 39
Joined: Mon Jan 29, 2018 12:45 pm

Re: SPI FLASH 2 in PYBD_SF2

Post by Meekdai » Fri Jun 28, 2019 5:18 am

dhylands wrote:
Fri Jun 28, 2019 4:14 am
I know you could add a SPI RAM and use it to read/write from (like a disk). I don't know if the stm32 used in the SF2 will transparently make it behave like internal RAM. You'll need to read through the datasheet and see if it supports something like that.
Thank you, if there is an idea, I will try it. I believe it will be as easy to use on PYB as SPI FLASH.

Post Reply