Skip to content

EEPROM size for Raspberry Pi Pico #104

@obdevel

Description

@obdevel

Alex,

The NmraDcc.h sets MAXCV to 256 for the Raspberry Pi Pico. From the comment, it looks like this was a placeholder until a more sensible value could be determined.

The arduino-pico EEPROM library just creates a RAM cache of that size and reads in the values from the appropriate flash locations. The maximum size is 4096 bytes. It's perfectly safe to call EEPROM::begin again with different values; the library code will just recreate the cache with the new value. EEPROM::length reports the correct size at all times.

I suppose the main consideration is how much RAM and flash space should be allocated - and potentially wasted. Also, the write-back of the cache after EEPROM::commit takes slightly longer.

I suggest a few possibilities:

  1. just #define MAXCV to 4096; it's a drop in the ocean, particularly on the newer RP2350 and Pico 2

  2. provide the user with some mechanism to set the value, perhaps using the same weak callback mechanism as the other EEPROM functions, with a default value in case the function isn't implemented by the user's code. This should probably apply to all platforms with emulated EEPROM

  3. let people know that they can call EEPROM.begin(xxx) again anytime after Dcc.init()

I tripped across this on the DCC-to-CBUS bridge project I'm working on. I set the size to 4096 in my CBUS setup code and then the DCC init code happily reduced it to 256 ! I've redefined MAXCV to 4096 in my local copy of NmraDcc.h for the time being.

Duncan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions