Skip to content

Conversation

fulda1
Copy link

@fulda1 fulda1 commented May 17, 2016

Hello,

I'm not good in java programming and using github, but I would like to present small update for uploadre to recognize new eep file and upload them to eeprom of arduino. See bug #1318 https://github.com/arduino/Arduino/issues/1318

It is necessary to extract also SerialUploader.java from my patch-1

fulda1 added 2 commits May 17, 2016 20:33
added parameter for write eeprom from eep file
@Chris--A
Copy link
Contributor

Chris--A commented May 19, 2016

This (IMO) will need to be implemented with a switch in the settings. It is fairly well accepted that while using the IDE, what you place in the EEPROM while a sketch is running will stay there when you upload the next version of your code.

The attribute EEMEM is not widely known (if at all in the Arduino community) and this feature would cause absolute havoc with many peoples sketches and tutorials if enabled by default.

It definitely would be a good feature to have. For one my EEWrap library would have its productivity value increased significantly if you were able to initialize EEMEM variables.

As it is an AVR specific switch, careful consideration of where to put it in the IDE may be required.

@fulda1
Copy link
Author

fulda1 commented May 19, 2016

Well, this is good "chicken / egg" question. Searching forums I found lot of questions why arduino not uploading those eep files. Once you would like to be conservative, then here can be configuration in prefferences.txt with default "false". Then you will see reaction of users.
I'm not sure I'm good programmer for that complex patch.

Or from the other hand - default for platform.txt can be empty "tools.avrdude.upload.params.uploadeep" with some comment how to set it for enable uploading.

@Chris--A
Copy link
Contributor

You wont find questions arguing the former, due to it being accepted, and widely known. Arduino is a large platform, so a number of questions still only represents a small number of the total user base.

@fulda1
Copy link
Author

fulda1 commented May 24, 2016

OK, you are right. But anyway, once you are interested in, you can try it can try it:
HERE is description how to change the IDE.

But until EEPROM library documentation will not contain info about using EEMEM directive, it will not be widely used.

@sandeepmistry sandeepmistry added the Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) label Jul 19, 2016
@sandeepmistry
Copy link
Contributor

Hi @fulda1,

I am trying this change out with my Uno and the eeprom_read.ino example sketch. However, when I add the following to the sketch:

char ee_data[] EEMEM = { 'h', 'e', 'l', 'l', 'o' };

The uploading with verbose logging outputs:

avrdude: writing eeprom (5 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 5 bytes of eeprom written
avrdude: verifying eeprom memory against /var/folders/m9/y22yzb0d49x_kws_6jtwdphw0000gn/T/build754a3b352d03b45e4b62df0151980356.tmp/eeprom_read.ino.eep:
avrdude: load data eeprom data from input file /var/folders/m9/y22yzb0d49x_kws_6jtwdphw0000gn/T/build754a3b352d03b45e4b62df0151980356.tmp/eeprom_read.ino.eep:
avrdude: input file /var/folders/m9/y22yzb0d49x_kws_6jtwdphw0000gn/T/build754a3b352d03b45e4b62df0151980356.tmp/eeprom_read.ino.eep contains 5 bytes
avrdude: reading on-chip eeprom data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0xff != 0x68
avrdude: verification error; content mismatch

Based on the following forum post, the optiboot boot loader for the Uno does not contain support for write EEPROM data with AVR dude: http://forum.arduino.cc/index.php?topic=335117.msg2310790#msg2310790

Which board have you been testing with?

Note: If the sketch contains no EEMEM variables an empty .eep file is created:

:00000001FF

@sandeepmistry sandeepmistry added the Waiting for feedback More information must be provided before we can proceed label Jul 19, 2016
@fulda1
Copy link
Author

fulda1 commented Jul 19, 2016

Hello sandeepmistry,

I'm using default boot loader I received in my boards from china. I'm using Nano and Pro Mini boards (variety of, from various suppliers). All of them (minimum 3 types tested) support upload of eeprom.

Regarding empty eep file - yes, that is why I was added condition for minimum file size 13 octets, because empty intel hex file not mean 0 file size.

@sandeepmistry sandeepmistry changed the title Update platform.txt Add support to use AVR dude to upload .eep files on sketch upload Jul 20, 2016
@sandeepmistry
Copy link
Contributor

sandeepmistry commented Jul 20, 2016

Hi @fulda1,

I was able to do some more tests and have this patch working with my Leonardo and Mega 2560 boards. However, still no success with the Uno.

I now understand why you check the minimum file size, AVR dude hangs if it tries to write a zero length .eep data:

avrdude: 0 bytes of eeprom written
avrdude: verifying eeprom memory against /var/folders/m9/y22yzb0d49x_kws_6jtwdphw0000gn/T/build754a3b352d03b45e4b62df0151980356.tmp/eeprom_read.ino.eep:
avrdude: load data eeprom data from input file /var/folders/m9/y22yzb0d49x_kws_6jtwdphw0000gn/T/build754a3b352d03b45e4b62df0151980356.tmp/eeprom_read.ino.eep:
avrdude: input file /var/folders/m9/y22yzb0d49x_kws_6jtwdphw0000gn/T/build754a3b352d03b45e4b62df0151980356.tmp/eeprom_read.ino.eep contains 0 bytes
avrdude: reading on-chip eeprom data:

Reading | 

Since this feature doesn't work with the Uno, and might be incompatible with other official Arduino boards I'm thinking it needs to be board specific now.

@cmaglie @facchinm what do you think about this?

@fulda1
Copy link
Author

fulda1 commented Jul 20, 2016

Or it is possible it is specific for bootloader version or for MCU version. I have only 328 types and no 168.
Do you know this page: http://www.fucik.name/Arduino/eemem.php ??

@matthijskooijman
Copy link
Collaborator

IIRC optiboot does not support writing to EEPROM when compiled with the default options. I guess you could be seeing this, since I think the Uno uses optiboot, but the Mega2560 does not?

@Chris--A
Copy link
Contributor

Chris--A commented Jul 21, 2016

This should also be an option in the menus. Like where you can choose the native/programming usb for Due, this could also be a board specific option.

If it is enforced, there isn't an easy way to update an AVR program that has data already in the EEPROM. For building/debugging purposes this is really working against the user. I mean, lets face it, people do not use the EEPROM for static data.

Maybe for boards that support it, show an additional upload button with some nice modification to the graphic. This can signify upload EEPROM data as well.

Although, it would be better suited as a board specific menu item though as there are now probably more boards supported by the IDE, than the AVR's with EEPROM (or at least will be in the future).

facchinm pushed a commit to arduino/ArduinoCore-avr that referenced this pull request Nov 13, 2017
@facchinm
Copy link
Member

I'm closing the issue here; if anyone wants to adopt this functionality (after carefully testing it with latest avrdude and a range of official boards) please reopen it using this link https://github.com/arduino/ArduinoCore-avr/compare/pr_4963

@facchinm facchinm closed this Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Waiting for feedback More information must be provided before we can proceed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants