Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

32u4: Code-accessible Storage?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

32u4: Code-accessible Storage?

by jason_mf on Tue Mar 23, 2021 7:09 pm

I'm currently using an ItsyBitsy 32u4 for keyboard macros over USB. It works great!

My current process to update the macros is to update them in the code and reflash the device. Is it possible to instead use part of the 28KB of onboard flash for arbitrary storage? I would love to be able to create a small tool that talks to the 32u4 over serial to update just the macros. This would also make it feasible to create the same device for friends who would feel overwhelmed having to update their macros using an IDE.

If this is possible, some direction for how to work with storage in C++ would be awesome.

jason_mf
 
Posts: 2
Joined: Sat Jul 04, 2020 4:25 pm

Re: 32u4: Code-accessible Storage?

by adafruit_support_mike on Thu Mar 25, 2021 11:01 pm

Unfortunately the ATmega32u4 can't write to its Flash memory from normal code. Only the bootloader can do that.

The ATmega32u4 has 1k of internal EEPROM that you can read and write from normal code.

If you want to stay with the ATmega32u4, it will probably be easiest to use some kind of external storage.. a micro-SD card would be simplest, though you'd only use a fraction of the storage and the cost would be relatively high.

If you need more space than that, the least expensive option would probably be an I2C EEPROM. You can get 32kbit chips (4k of storage) for 25c in lots of 100. If you put the chip on a removeable carrier,

If you're willing to switch to a 32-bit microcontroller, all of our M0 boards can read and write the Flash array from normal code. They also have a larger Flash array, so you can store more information. If you really want memory, our Express boards have a built-in 2MB external Flash chip.

adafruit_support_mike
 
Posts: 62799
Joined: Thu Feb 11, 2010 2:51 pm

Re: 32u4: Code-accessible Storage?

by jason_mf on Thu Mar 25, 2021 11:26 pm

For my purposes, being able to write to the 1Kb of EEPROM would be totally sufficient, even if it's slow since updating the macros would be infrequent. Is there a C++ library or other reference you can point me to?

jason_mf
 
Posts: 2
Joined: Sat Jul 04, 2020 4:25 pm

Re: 32u4: Code-accessible Storage?

by adafruit_support_mike on Sun Mar 28, 2021 6:17 pm

This is the Arduino EEPROM reference:

https://www.arduino.cc/en/Reference/EEPROM

adafruit_support_mike
 
Posts: 62799
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.