7. External flash in block mode
Motivation
When working with Non-Memory-Mapped Flash memory, such as NAND flash, a driver must be developed in order for TouchGFX to use the assets stored within.
Read more about this topic in the Using Non-Memory Mapped flash for storing images section.
Note
Goal
The goal of this step is to create a driver that can read a number of bytes from a location in the non-mapped flash memory and store it in an array.
Verification
The verification points for this section are:
Verification Point | Rationale |
---|---|
Ensure contents of flash | Ensure that the contents read from the flash are correct. |
Verify performance | Ensure that read performance is in accordance with MCU configuration. |
Prerequisites
- Information about the flash, typically from a datasheet.
- Information about the connections between the MCU and the external flash.
- The flash speed.
Do
Typically, the NAND flash is configured via the FMC on your MCU.
Remember to configure the GPIOs that are connected to the flash.
A non-memory-mapped QSPI flash is configured in CubeMX like a memory-mapped QSPI flash.
Code
Write code that can read a number of bytes from a specific address of the Flash. An example of how this might look is provided below. The implementation of the driver depends on your flash chip.
void readNonaddressableFlash(uint32_t from, uint8_t *into, uint32_t n)
{
...
}
uint8_t bytes[1000];
//read external Flash
readNonaddressableFlash(0xab001212, bytes, 1000);
This code will be used later to develop the TouchGFX abstraction layer.