0
\$\begingroup\$

It is just a general question. I have designed some micro controller boards with On-Board EEPROM. This EEPROM is to store some configuration parameters for program like calibration data and system IDs. Now when i want to write some configuration parameters,I load some program to write to that specific EEPROM address and run once. Then I load application program. I think this not the most efficient way to do that task. What is general method to write EEPROM data. One way to provide some external interface to EEPROM and then using some PC program write direcly into it. But I guess this exposes external interface andleads to vulnerable system. Other could be to add methods in application program itself using serial port and define some API to change those parameters. I just want to know the acceptable practice in community from accessibility and security point of view. If it involves any hardware change i can incorporate in future design. Thanks

EDIT- On-Board EEPROM is external EEPROM.

\$\endgroup\$
1
\$\begingroup\$

The way I usually do it is to have an "EEPROM Is Valid" flag in the EEPROM. Then the main program contains a set of defaults, and if the EEPROM isn't "valid" it loads the defaults into the EEPROM and sets the valid flag.

That way the first time the board is powered up it sets up the EEPROM for you, but subsequent powerups just use the EEPROM data that's already set.

Also has the benefit that it can be reset to factory settings if you want.

Of course, it's then up to the main program to update those values as needed, but without knowing what your system does I can't comment on that.

\$\endgroup\$
  • \$\begingroup\$ Yes, this method is useful for restoring default data. But suppose I want to just change some parameters without loading main program. \$\endgroup\$ – ragdarbari Feb 28 '15 at 12:25
  • \$\begingroup\$ I want to tell the operation of main program is dependent on these configuration parameters. \$\endgroup\$ – ragdarbari Feb 28 '15 at 12:26
  • \$\begingroup\$ So have a section in the main program that allows you to change those parameters. \$\endgroup\$ – Majenko Feb 28 '15 at 12:27
  • \$\begingroup\$ Yeah, that's what I described as a second method in main question.Any ways, thanks for your insight. \$\endgroup\$ – ragdarbari Feb 28 '15 at 12:31
  • \$\begingroup\$ You could have a "first power on calibration" routine that runs the first time you power the board up and allows you to calibrate it - however that is done - and a way to re-calibrate, maybe using a jumper on the PCB to enter calibration mode or something like that. Without knowing your board, application, or what the calibration data might be it's impossible to recommend a "best" way of doing it. \$\endgroup\$ – Majenko Feb 28 '15 at 12:33
1
\$\begingroup\$

Another approach is not to store it on the internal EEPROM but on an external SPI EEPROM. This can be programmed separately, or you can add a programming connector to the board to program it.

If the EEPROM is within the microcontroller, then you have to find some way of programming it from within your application. Possibly through the in-circuit debugger, if you have connections for that. Otherwise you'll have to implement a communications protocol.

\$\endgroup\$
  • \$\begingroup\$ Actually, i was talking about external SPI EEPROM only. Sorry, if that was not clear in the question. \$\endgroup\$ – ragdarbari Feb 28 '15 at 12:32
  • \$\begingroup\$ Well then: bring out the power/ground/SPI and microcontroller reset to a connector (0.1in header, flat flexible, Tag-Connect, whatever), then you can put the microcontroller into reset and write to the SPI from a PC (using a Bus Pirate or similar usb-to-spi device). \$\endgroup\$ – pjc50 Feb 28 '15 at 14:16
1
\$\begingroup\$

An API to read/write the EEPROM, available via UART or any other interface, is quite flexible: Then the functions are always available without the need for replacing the firmware. Of course you have to check if this is acceptable for your specific application.

As for the vulnerability: In case of an "on-board EEPROM" (attached to the MCU via SPI or I2C) this possibly requires further actions (like encryption), otherwise with some effort you can always access the EEPROM.

If a certain level of security is necessary there is "on-mcu EEPROM" with HW password support in the MCU; for example this is available on the ARMs from TI. Possibly combined with something like a SD-Card or USB-Stick as a means to provide (and remove) the password.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.