an. How to make a large (flash) RAM drive with 1 MB or more inside a microcontroller?

#include "system_config.h"

const unsigned char __attribute__((space(prog),aligned(DRV_NVM_PAGE_SIZE))) diskImage[1457664] = {

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

.....

};

Next, you have to alter the *.c file content to tell PIC32 GCC compiler to make a flash RAM array. Simply change the memory definition to start like this:

But PIC32MZ microcontrollers can host 1 MB or even larger file systems. A simple trick is to find an old 1.44 MB MS DOS diskette and make a raw copy of it to a *.c file. How is this possible? Download a free HxD tool from the internet and you will be able to copy content of any diskette to *.c file.

Not all microcontrollers have a large RAM or a flash RAM. Therefore Microchip examples for USB drives are based on a device with a few tens of kB. A C-programming langue (*.c file) FAT12 (file allocation table) disk image is provided with all the examples. A FAT table is tiny and it usually prevents one to expand the drive beyond much more than 100 kB.

Now, you just have to include the disk image *.c file into your flash RAM project (see Microchip Harmony hid_msd examples).

If you prefer a USB RAM drive, leave the memory array definition as it is except for changing its name to diskImage. Static RAM is much smaller, but in PIC32MZ2048ECHxxx microcontrollers it still has 512 kB, so about 400 kB may be available... A USB RAM drive may also be a way of communicating commands to your microcontroller.