Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Add utility to flash to STM32 data EEPROM area #333

Closed
dflogeras opened this issue Aug 18, 2015 · 14 comments
Closed

[feature] Add utility to flash to STM32 data EEPROM area #333

dflogeras opened this issue Aug 18, 2015 · 14 comments

Comments

@dflogeras
Copy link
Contributor

It would be great to have a command line utility to flash a binary file directly to the data EEPROM in STM32 devices (ie address starting 0x8080000 on the STM32Lxx devices). I use this to store things like a device serial number, which is separate and distinct from the program EEPROM version. Currently I write a small program to store what I need in the data EEPROM, then replace it with the real firmware, but it would be good to eliminate this step and just use stlink to do it.

@niallp
Copy link

niallp commented Dec 15, 2015

A related feature would be the capability to erase the EEPROM space, the bulk erase presently only clears the main FLASH.

@xor-gate xor-gate added this to the Unplanned (Contributions Welcome) milestone May 21, 2016
@xor-gate xor-gate modified the milestones: v1.3.0, Unplanned (Contributions Welcome) Dec 30, 2016
@xor-gate xor-gate modified the milestones: v1.3.0, Unplanned (Contributions Welcome) Jan 14, 2017
@manuvelayudhan
Copy link

Had a similar requirement for an STM32L051 device. While searching for methods to do the same, came across the following..
https://www.purplealienplanet.com/node/56

Based on the approach mentioned in that page, made some modifications in order to use the existing flash write functions to program the EEPROM. What I did was,

  1. Added EEPROM base address, size and page size fields to the device parameter structures.
  2. In main(), after ruling out flash & RAM as destinations for write operation, one more check is performed to see if it is a valid EEPROM address for the connected device.
  3. If yes, the flash params (base, size and page size) of the _stlink structure (sl) are overwritten with the EEPROM params and the existing flash write APIs are used for writing to EEPROM.

I was able to successfully write to the EEPROM of the following STM32L0 devices
a. STM32L031K6 (Nucleo 32 board)
b. STM32L051K8 (custom board)

The changes are available in the fork I created.
https://github.com/manuvelayudhan/stlink

If someone can review the same to verify if this is the right approach to the problem, it will be helpful.

Possible improvements are

  1. Instead of using the existing flash write APIs, a new set of dedicated EEPROM write APIs can be added.
  2. Current version will work for STM32L0 category 2/category 3 devices only.

@niallp
Copy link

niallp commented Jun 25, 2018

@manuvelayudhan your fork works for me to allow for eeprom writing, would be nice to see it pulled into mainline.

@manuvelayudhan
Copy link

Not sure if the current implementation is the best possible / correct one.. Any suggestions to improve it? Or should I just create a pull request from the current state?

@niallp
Copy link

niallp commented Jun 26, 2018

@manuvelayudhan ... I haven't looked too deeply but it seems a fairly minor tweak for useful functionality, all I'd suggest is merging in master and making sure nothing breaks in the latest (didn't see anything obvious).

@Nightwalker-87 Nightwalker-87 modified the milestones: Unplanned (Contributions Welcome), Next Feb 19, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: General, v1.7.0, Feedback required Mar 14, 2020
@Nightwalker-87
Copy link
Member

@dflogeras @manuvelayudhan @niallp: I believe this feature is still missing. What is the current state of this for all of you?

@dflogeras
Copy link
Contributor Author

I agree this is unimplemented, but I have no opinion on how to proceed. In recent times, when I've needed said function, I've had access to a windows computer and just used ST's utility to do so.

@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Mar 20, 2020

I see, but it may be useful for others. This makes me feel like we should leave this open, but of course can keep you out of the topic for the ongoing conversation.

@niallp
Copy link

niallp commented Mar 23, 2020 via email

@Nightwalker-87
Copy link
Member

This should better go into the code. I'm not so happy if such workarounds remain present for too long. As it reads, this could also be an ordinary feature.

@Nightwalker-87 Nightwalker-87 changed the title Add utility to flash to STM32 data EEPROM area [feature] Add utility to flash to STM32 data EEPROM area Mar 24, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: v1.6.1, v1.6.2 Mar 24, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: v1.6.2, v1.6.3 Mar 10, 2021
@Nightwalker-87
Copy link
Member

@Ant-ON: Is there still a reasonable way of implementing this after the recent contributions to the st-flash source code?
Unfortunately @manuvelayudhan seems to be inactive by now, but the patch is still present in his fork.

@Ant-ON
Copy link
Collaborator

Ant-ON commented May 4, 2021

@Nightwalker-87 Doesn't look like a good implementation manuvelayudhan@fc1b5fb

@Nightwalker-87
Copy link
Member

Hm, ok. Thanks for the feedback. Maybe someone else has a better idea then.

@Nightwalker-87
Copy link
Member

Closing this issue due to inactivity and in relation to the given feedback above.

@stlink-org stlink-org locked as resolved and limited conversation to collaborators Aug 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants