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

avrdude memory type enhancement #1330

Closed
stefanrueger opened this issue Mar 28, 2023 · 5 comments · Fixed by #1538
Closed

avrdude memory type enhancement #1330

stefanrueger opened this issue Mar 28, 2023 · 5 comments · Fixed by #1538
Assignees
Labels
enhancement New feature or request

Comments

@stefanrueger
Copy link
Collaborator

There isn't really a good authority how the memory should be called that houses the lock bits. Neither the data sheets nor the atdf files have a systematic way of naming. AVRDUDE calls these memories lock unless it's a TPI part (t4, t5, ..., t40, t102, t104), in which case it's lockbits.

Or and that's the surprising bit: if it's the ATmega406 then this memory is also called lockbits.

Any rhyme or reason?

@stefanrueger stefanrueger added the question Further information is requested label Mar 28, 2023
@dl8dtl
Copy link
Contributor

dl8dtl commented Mar 28, 2023

No idea, and actually, I've never even held an ATmega406 in my fingers. It's a quite exotic part – even though it's still in production these days.

The datasheets of the non-Xmega AVRs call it "lock bit byte", the Xmegas call it "lock bit register".

@stefanrueger
Copy link
Collaborator Author

And the ATDFs call that register variously, lockbit (241x), lockbits (45x, Xmegas) and (... wait for it ...) key (37x, Dx).

How about calling the ATmega406's memory lock in avrdude.conf.in based on the strength of the datasheet that also calls that byte lock bit byte. It doesn't terribly matter, but it's kinda a bit more systematic. What actually should happen is that there ought to be an int parameter in each memory section whose bits tell us what the function of that memory is. This saves "AVRDUDE" from faffing around with quite a few strcmp() to figure that out, eg, MEM_IS_FLASH would be set for apptable, application, boot and flash, whilst the various fuses would have MEM_IS_CONFIG or similar. Mucho eleganto.

Screenshot from 2023-03-28 21-01-18

@dl8dtl
Copy link
Contributor

dl8dtl commented Mar 28, 2023

How about calling the ATmega406's memory lock

I am always hesitant to change things that have alway^H^H^H^H^Hfor a long time been the way they are. You never know whom you might shoot into the foot with renaming things. Frankly, I don't even have the slightest idea whether there's even a single ATmega406 AVRDUDE user – but I am sure, if you gratuitously rename things (even if for a good reason), you might suddenly learn how many active users of it have already been out there. :-)

That's opensource life: if something works, you'll (almost) never hear about it from the users.

@stefanrueger
Copy link
Collaborator Author

stefanrueger commented Mar 28, 2023

for a long time been the way they are

Fair point as to external representation.

For internal use in the code base, I advocate utilising a new memory field mem_type; basically either an internal cache that stores the result of the string of initial strcmp()s to determine the type, or an external facing avrdude.conf entry that can be set (and inherited). Then it doesn't matter (at all) how a memory is called as long as there are no name conflicts. Fun fact: memory names are sometimes invented by AVRDUDE anyway (good); for example, efuse neither occurs as string in the ATmega328P datasheet nor its ATDF (I know: I counted twice).

Attribute Memory
MEM_IS_EEPROM eeprom
MEM_IS_FLASH flash application apptable boot
MEM_IS_CONFIG lfuse hfuse efuse fuse fuse0 wdtcfg fuse1 bodcfg fuse2 osccfg fuse3 fuse4 tcd0cfg fuse5 syscfg0 fuse6 syscfg1 fuse7 append codesize fuse8 fuse9 bootend bootsize fuses
MEM_IS_LOCK lock lockbits
MEM_IS_CALIBRATION tempsense calibration osccal16 osccal20 osc16err osc20err
MEM_IS_SIGNATURE signature
MEM_IS_ID signature prodsig sernum usersig
MEM_IS_USER userrow usersig
MEM_IS_SRAM data

Note these are soft-assigned: usersig has two attributes, as does signature.

@mcuee
Copy link
Collaborator

mcuee commented Mar 30, 2023

@stefanrueger

Your proposal seems to be a good one. Maybe we can change this issue into an enhancement.

@mcuee mcuee added enhancement New feature or request and removed question Further information is requested labels Apr 24, 2023
@mcuee mcuee changed the title Is the ATmega406's lock bits memory really called lockbits? avrdude memory type enhancement May 20, 2023
@stefanrueger stefanrueger self-assigned this Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants