Go Down

Topic: Issue with uploading program after burning bootloader (Read 697 times) previous topic - next topic

kprims

Well I worked myself into a hole. :smiley-confuse:

Using the Arduino IDE 1.8.12, I have no problem with the Lock byte 0x3F, however, using avrdude version 6.3-20171130 I have the same problem as you are showing.

avrdude.conf for m2560 is different between the two versions.

My advice would be to use the .arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 that comes with IDE 1.8.12. or whatever comes with IDE1.8.13.

You should try to load your sketch now, your fuses look OK.

Travisha92

@kprims thanks for the help; and just to clarify the last bit  .arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 that comes with IDE 1.8.12. or whatever comes with IDE1.8.13.  you're referring the path to the avrdude conf ?


Also were you able to try to see if a sketch could be uploaded after you ran the command with avrdude while still receiving that address mismatch error ?

kprims

No, you would need both /bin/avrdude and /etc/avrdude.conf, like this. Easier to just use the IDE.

Code: [Select]
/home/kprims/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/home/kprims/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -patmega2560 -cstk500v1 -P/dev/ttyUSB0 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m  -Uflash:w:/home/kprims/.arduino15/packages/arduino/hardware/avr/1.8.3/bootloaders/stk500v2/stk500boot_v2_mega2560.hex:i -Ulock:w:0x0F:m


Today, I couldn't change fuses or upload a sketch with the address mismatch error.

Just some further info. I replaced arduino.conf at /etc/arduino.conf with the one used bye IDE 1.8.12 and nothing worked.
Then I overwrote the original /etc/arduino.conf ,two bits at location 10591,47 and 10591,49 from o to x and this worked for the m2560 chip.

Code: [Select]
memory "lock"
        size            = 1;
        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
                          "x x x x  x x x x   o o o o  o o o o";
 


Change to this.

Code: [Select]
memory "lock"
        size            = 1;
        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
                          "x x x x  x x x x   x x o o  o o o o";

Travisha92

You know what... if I ignore the the  xx != xx it will still allow me to upload! it's very annoying since im using the error codes to trigger lights when it successfully flashed but I mean it works!

kprims

Could you show me the avrdude command you are using now?

Travisha92




avrdude -v -p atmega2560  -c stk500v1 -P /dev/ttyACM0 -b 19200 -e -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U lfuse:w:0xFF:m'

avrdude -v -patmega2560 -cstk500v1 -P/dev/ttyACM0 -b19200 -U flash:w:bootloaders/stk500boot_v2_mega2560.hex:i -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m

Travisha92

Are you able to reproduce this error along with a successful sketch upload?

kprims

If you were using a new chip this would not work. If you had already programmed fuses for MegaCore this would not work. At least on my setup, the fuses do not get changed with the Lock bit failure.

If your board already has the correct fuses the the bootloader will be written and you will be able to upload sketches.

Travisha92

Hmm ok, this is getting really confusing you say new chip so you mean straight from the factory?  Cause if so that's a huge concern for me as the main purpose is to flash the new chips that are coming from the factory I guess what my next question would be is what is the correct setting here then for this?


I realize this may seem unheedingly complicated the way I'm trying to do it but I cannot hook it up to my computer the burn the bootloader this is not an option for us do to a lot of things and we have to use the avrdude command my setup is Raspberry Pi running a python application -> Arduino ISP -> target chip

kprims

Take what I say with a grain of salt. I just play around with this stuff .:)

1 -  Get an up to date Avrdude and avrdude.conf. You may be able to use the Download for Linux ARM 64 bit or 32 bit depending on what Raspberry Pi you are using.
https://www.arduino.cc/en/Main/Software

2 - Just overwrite the two bits I pointed out to you earlier and see if it works for you.


 I overwrote the original /etc/arduino.conf ,two bits at location 10591,47 and 10591,49 from o to x and this worked for the m2560 chip.

Code: [Select]
memory "lock"
        size            = 1;
        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
                          "x x x x  x x x x   o o o o  o o o o";
 


Change to this.

Code: [Select]
memory "lock"
        size            = 1;
        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
                          "x x x x  x x x x   x x o o  o o o o";

Regarding the fuse settings. You need to decide if you just want the setup we have just been working with ie  avrdude -v -p atmega2560  -c stk500v1 -P /dev/ttyACM0 -b 19200 -e -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U lfuse:w:0xFF:m

and the bootloader  stk500boot_v2_mega2560.hex, you would be good to go.

MegaCore would give you options for different clock(crystal) rates and a smaller bootloader if that would interest you.

Go Up