optiBoot w/ EEPROM support through AVRDUDE?

Greetings,
Recently, I posted here my findings that the EEPROM r/w was not functioning in my Arduino "new" bootloader for Nano (328p). I received a quick and courteous reply from WestfW that this was indeed the case, and that I may be able to resolve this by using BIGBOOT as an alternative bootloader. In my case, the larger chunk of flash taken up by a 1K bootloader will be no problem, and I'd like to pursue this as a remedy.
Where I am having problems is where to find this bootloader and how to go about getting it into my target Nano boards. Also, I don't know if there are other implications with regard to it playing well with my ArduinoIDE or PlatformIO environments after the fact. Are there changes that will need to be made there as well if I am running a new bootloader?
Anyway, you may be able to tell from my writing here that I'm not a very sophisticated user, and my inquiry might seem a bit broad. I have tried to research this on my own and am thoroughly bogged down. Is there a simple path to doing this, or is it convoluted beyond the expectations of an amateur such as myself?
Regards,
Mark
(p.s. my AVRDUDE in the path which I hope to use is version 6.2 -20190619)

Oh. Sorry. I was going to respond, but I got hung up trying to figure out the simplest way to do this for an audience of unknown expertise.

If you're comfortable (or at least able) running avrdude from the command line, probably the easiest way is to take the attached .zip file, unpack it to yield a "bigboot_328.hex" file, and then issue the avrdude command:

avrdude -v -patmega328p -cstk500v1 -PCOM3 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDC:m -Ulfuse:w:0xFF:m -Uflash:w:bigboot_328.hex

Possibly changing the first few arguments to reflect whatever actual programmer you are using.
The important parts are the new setting of hfuse (was DE, now DC), and the new .hex file.

In theory, you should use a different arduino boards.txt file that knows that the max program size is different, but as long as you're not close to using up flash, that shouldn't matter.

I don't think that there should be any other issues.
bigboot_328.hex.zip (1.1 KB)

Thanks for the info! I gave that a try, and it looks like I'm still having a couple issues.
First off, I changed the programmer field to "-c arduino" and also, I changed the baud rate to "-b 115200" from 19200 as when I used 19200, it wouldn't sync. With 115200, it did, but here is the AVRDUDE verbose output. I did verify that the communication to the device was all good by successfully loading a couple sketches down the USB cable out of ArduinoIDE (and its call to avrdude)
Sorry if thus is not the right format for passing this information. Anyway, does this bring anything to mind? Any ideas what I might try?
Thanks,
Mark

C:\Users\trujo\Documents\Arduino\New_bootloader_workspace>avrdude -v -patmega328p -carduino -PCOM3 -b115200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDC:m -Ulfuse:w:0xFF:m -Uflash:w:bigboot_328.hex

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\AVRDUDE\avrdude.conf"

     Using Port                    : COM3
     Using Programmer              : arduino
     Overriding Baud Rate          : 115200
     AVR Part                      : ATmega328P
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PC2
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
       flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
       lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : Arduino
     Description     : Arduino
     Hardware Version: 3
     Firmware Version: 4.4
     Vtarget         : 0.3 V
     Varef           : 0.3 V
     Oscillator      : 28.800 kHz
     SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: erasing chip
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

Writing | | 0% 0.00s ***failed;
Writing | ################################################## | 100% 0.11s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3F:
avrdude: load data lock data from input file 0x3F:
avrdude: input file 0x3F contains 1 bytes
avrdude: reading on-chip lock data:

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

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

avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done. Thank you.

That probably means that you're connected/talking to the Arduino you want to change, and not to one that's running the Arduino as ISP sketch (or other programmer?) You need an external programmer (which can be a second arduino) to burn the bootloader.

1 Like

here I have a 328p definition for BIGBOOT. put it in your sketchbooks hardware folder, restart the IDE and select "Uno/Nano/Mini (Big Optiboot)" in Tools menu. you can use it to burn the bootloader and then use it to upload to the board.

theory

Oops! You are indeed correct! I had my Nano board (target) connected DIRECTLY to my Windows PC.
D'oohh! This seems good now... Here's the AVRDUDE output

C:\Users\trujo\Documents\Arduino\New_bootloader_workspace>avrdude -v -patmega328p -carduino -PCOM3 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDC:m -Ulfuse:w:0xFF:m -Uflash:w:bigboot_328.hex

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\AVRDUDE\avrdude.conf"

     Using Port                    : COM3
     Using Programmer              : arduino
     Overriding Baud Rate          : 19200
     AVR Part                      : ATmega328P
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PC2
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
       flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
       lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : Arduino
     Description     : Arduino
     Hardware Version: 2
     Firmware Version: 1.18
     Topcard         : Unknown
     Vtarget         : 0.0 V
     Varef           : 0.0 V
     Oscillator      : Off
     SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as FD
avrdude: erasing chip
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3F:
avrdude: load data lock data from input file 0x3F:
avrdude: input file 0x3F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xFD"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% -0.00s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFD:
avrdude: load data efuse data from input file 0xFD:
avrdude: input file 0xFD contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xDC"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDC:
avrdude: load data hfuse data from input file 0xDC:
avrdude: input file 0xDC contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% -0.00s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% -0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "bigboot_328.hex"
avrdude: input file bigboot_328.hex auto detected as Intel Hex
avrdude: writing flash (32768 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 32768 bytes of flash written
avrdude: verifying flash memory against bigboot_328.hex:
avrdude: load data flash data from input file bigboot_328.hex:
avrdude: input file bigboot_328.hex auto detected as Intel Hex
avrdude: input file bigboot_328.hex contains 32768 bytes
avrdude: reading on-chip flash data:

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

avrdude: verifying ...
avrdude: 32768 bytes of flash verified

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DC
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK (E:FD, H:DC, L:FF)

avrdude done. Thank you.

In my haste, I failed to THANK YOU for all your help on this, westfW.
Tomorrow I'll give the EEPROM r/w a shot, but it appears as though the bootloader burn was a go.
Cheers,
Mark

Final Note: I wanted to report back after successfully loading BIGBOOT bootloader into Nano and testing EEPROM r/w functions through AVRDUDE.
Everything seems to be working great and bootloader still performs other tasks without any issues !

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.