Page 1 of 1

SPI FLASH 2 in PYBD_SF2

Posted: Thu Jun 27, 2019 11:51 am
by Meekdai
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.

Re: SPI FLASH 2 in PYBD_SF2

Posted: Thu Jun 27, 2019 9:01 pm
by dhylands
No - this extends the flash, and not the RAM.

Re: SPI FLASH 2 in PYBD_SF2

Posted: Fri Jun 28, 2019 12:54 am
by Meekdai
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.

Re: SPI FLASH 2 in PYBD_SF2

Posted: Fri Jun 28, 2019 1:39 am
by dhylands
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.

Re: SPI FLASH 2 in PYBD_SF2

Posted: Fri Jun 28, 2019 1:43 am
by jimmo
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.

Re: SPI FLASH 2 in PYBD_SF2

Posted: Fri Jun 28, 2019 2:30 am
by Meekdai
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.

Re: SPI FLASH 2 in PYBD_SF2

Posted: Fri Jun 28, 2019 2:35 am
by dhylands
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.

Re: SPI FLASH 2 in PYBD_SF2

Posted: Fri Jun 28, 2019 3:07 am
by Meekdai
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.

Re: SPI FLASH 2 in PYBD_SF2

Posted: Fri Jun 28, 2019 4:14 am
by dhylands
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.

Re: SPI FLASH 2 in PYBD_SF2

Posted: Fri Jun 28, 2019 5:18 am
by Meekdai
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.