Teensy 4.1 + Flash Memory: start address?

Uwe

Active member
Hello!

I have a Teensy 4.1 with a 128MBit flash mem soldered to its back. No PSRAM, Flash only.
I want to use this flash as "normal" RAM to read/write chunks of data. Don't want a file system being involved.
I suppose that the flash memory starts at 0x07000000 (up to 0x07FFFFFF).
Is that correct?
 
Is that correct?

No, not correct at all. Seems there are at least a couple wrong assumptions in this question.

The default startup code only initializes FlexSPI2 if it finds 1 or 2 PSRAM chips. To access anything else, you need to configure FlexSPI2. For flash chips, that config is normally done by LittleFS_QSPIFlash or LittleFS_QPINAND.

If you want to access anything other than PSRAM, and you don't want to use LittleFS, you have to initialize FlexSPI2. You can grab code from LittleFS or other older code, but you really need to understand none of this is done automatically. You have to do it. You must program the FlexSPI LUTs to perform the specific action needed to access the flash chip.

But no matter what you do, flash chips are NEVER directly writable as if they were normal memory, like you get with PSRAM. You can only read flash chips with memory mapped access. All writes have to be done using the FlexSPI IP CMD interface.

If you're going to use memory mapped access, don't forget about the MPU. Today the default setting is very permissive for FlexSPI2, but it may someday change to be automatically restrict memory mapped access to only the detected PSRAM chip(s). If you will access memory, best to explicitly configure the MPU to allow the range you will actually use.
 
Sorry I am not an expert on trying to use the Flash in that way.

That is I don't believe you can use Flash as if it were simple RAM.

That is I believe most(all) of them are setup with blocks/sectors, where you can read a sector or block or ... and likewise
write a sector/block... And at least with some of them (all?) you can only program them to change the bits one way. For example maybe you can only change 1s to 0s... To change back from 0s to 1s you need to erase that sector or block, which is a slow operation.

I would suggest taking a look at LittleFS classes (LittleFS_QSPIFlash or LittleFS_QPINAND depending on the type of flash you have. And look at all of the setup code in it and how it does reads and writes.

Alternatively when we were doing T4.1 beta there was information and code up in the github project: https://github.com/PaulStoffregen/teensy41_extram
 
Thanks to both of you! Very valuable information. I will use the SerialFlash lib now :)
 
Back
Top