Third party cookies may be stored when visiting this site. Please see the cookie information.

PenguinTutor YouTube Channel

Accessing flash memory on the Arduino Nano RP2040 and Raspberry Pi Pico using C++

This is a video I created when trying to work out how best to access large amounts of data on the flash memory of an Arduino Nano RP2040 Connect. This was for my Arduino RP2040 wireless NeoPixel project.

The video explains about how you can transfer text files to the Flash memory and then how you can use that in the RAM memory of the RP2040. This is based around the Arduino IDE using C++. It then explains about the performance issues with the programme and how you can identify bottlenecks using computer science techniques with benchmarking of the performance to ensure that the changes actually improve the performance.

Arduino Nano RP2040 connect - with 16MB SPI flash and 256kB RAM

Both the Arduino Nano RP2040 and the Raspberry Pi Pico have much more flash storage than RAM on the microcontroller. This can be a problem if you would like to read a lot of information from flash memory as it could exceed the size of the available RAM. I explored a few different options for storing information on the Flash and then how to retrieve it. My first "successful" attempt was so slow that it was unusable.

The next stage was to address the performance issue by creating a character array as a buffer in RAM and store information in that. In this video I explain how to look at tackling performance issues introducing a process which includes benchmarking and comparison to ensure that it did genuinely result in performance improvements.

Although the tutorial is based around the Arduino RP2020 you should be able to use the same techniques for the Raspberry Pi Pico.

Summary

The video shows how you can store text files on the flash memory by including them into a C++ .h header file. The file is then transferred to the flash memory using the Arduino IDE.

The data can then be read into RAM a character at a time by using a char pointer.

If that is sent to the client one byte at a time then it is incredibly slow, but by creating a 1000 byte buffer in the RAM then significant performance improvements can be made.

More information

Blog links and videos on programming

Previous MicroPython on Arduino NANO RP2040
MicroPython on Arduino NANO RP2040
Next Programming Raspberry Pi Pico with CircuitPython
Programming Raspberry Pi Pico with CircuitPython