Programspace as EEPROM

Hi,
Anybody know if this is possible ? I would like more eeprom space on 328p au but dont have physical space (custom board),
would rather not have to redesign with a better chip ie arm,
Is there any way to write/access progmem by address ? at runtime ? ie so one can reference after power cycle ?
I know the bootloader has autonomy here but... is it possible ?

TIA...

read about SPM. here is a google hit

you could also go to Optiboot bootloader --> read this

https://majek.sh/en/writing-to-internal-flash-on-arduino/

the easiest way is to use an external storage...

1 Like

Thanks,
Both good resources, The optiboot fork looks like it will do the trick, ill test later this week,
Also SPM may be able to send updates over lan with this mehtod... interesting,

The modified optiboot works.
If it is turned off during writing to Flash, then I don't know if the sketch will still run.

What are you storing in EEPROM ? Perhaps there is an other way.

Strongly STRONGLY suggest using MCUDude's MiniCore for this - not only does it come with an Optiboot version that supports that (so you'd just need to reburn bootloader with MiniCore), it comes with example sketches showing how to use it. MiniCore is generally better than the official cores anyway :stuck_out_tongue:

@Dome: if the chip is powered off or reset during a write, as long as the write was to something that isn't part of the instructions that get executed,it will just start next time with an empty page of flash.
I am very familiar with this phenomenon, because on chips WITHOUT full bootloader support (in other words, classic ATTiny parts that I support with ATTinyCore), the "virtualboot" function of Optiboot will trash the bootloader in event of a reset while erasing the first page of flash. Is a major problem if you want reliable operation with a lot of the parts supported by ATTinyCore. Micronucleus bootloader follows a proper procedure for erasing and storing app vector, and is no impacted, but porting that to optiboot is unlikely to happen - I tried and couldn't figure out how to pull it off)

Thanks for the info, I am storing datetime with button press so 5 bytes per press, store about 200 operations in eeprom,
Would like to store more though such as gps coordinates , sketch uses up less than 5k so lots of spare mem in there !
Just thin on hardware space.

Also interested in programming ATTiny parts, ie looking at weather software serial can run on attiny10 for the purpose of encryption keys...

ATTiny10? Doesn't that have a hardware serial port? 1k of flash definitely is not enough for software serial implementation if you want it to do anything else with it. Arduino support for those parts is also really rudimentary.
Why not step up to at LEAST an ATtiny412/402? Those are cheap, have more flash, and because they have all the same modern peripherals as the latest parts, you'll get more comfortable with things that are the future of the AVR architecture, and my megaTinyCore is a full featured core dedicated to making the most out of tinyAVR 0/1/2-series* parts (it supports all parts with >1k of flash, AKA, all the parts that do AVRxt instruction set variant, as opposed to AVRrc,. (AVRxt is basically AVRe+, which classic ATmega's have, except where the AVRxm (from the xMega series) variant has better instruction timing, in which cases it matches that. (classic tinies have AVRe which is the same as e+ except no hardware multiply, so math is slow. Modern (ie, 0/1/2-series) tinies have the full AVRxt instruction set).

  • a modern tinyAVR 0/1/2-series part is one named ATtiny followed by a 3 or 4 digit number, wherein the one's digit is a 2, 4, 6, or 7 (indicating that the part has 8, 14, 20 or 24 pins, respectvely), the ten's digit s a 0, 1, or 2 (indicating series), and the hundreds/thousands indicates flash size in kb.

0-series has rather basic peripherals, it's the budget one, 1-series traditional ADC, a DAC, type D hghspeed timer giving 2 extra PWM channels (on 20/24 pin parts - the others have it but it doesn't do any pins that the other timer can;t do) and 1 serial port, while 2 series has more RAM, a super-fancy ADC, no DAC, and an extra serial port and second type b timer (plus 4 logic blocks instead of 2 and a normal event system instead of the wacky one that the 0/1 got). All three modern tinyAVR series have 1 SPI and 1 master/slave I2C interface as well as a type A timer (up to six 8-bit PWM channels, 4 on 8-pin parts, plus type B timer (for Servo, Tone, and stuff like that - my core includes compatible versions of those libraries) ; 1-series (only) with 16k or 32k of flash have a second traditional ADC, 2 extra analog comparators, and a second Type B timer and the full 2k of SRAM even on 16k parts). There are no 8-pin 2-series parts. I am not privy to their plans for 8-pin tinies moving forward, though I'm praying that it's just because the pin restrictions are tight enough that an 8-pin tiny really shouldn't try to use the same peripheral layout that parts with more pins do, and as soon as they get the full 2-sereis ramped up and the EA-series out the door, their next project will be a killer 8-pin part.... That's what I'm praying for at least.

Great stuff, thank you for the info !

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.