Second step, it to flash it I tried two commands but failed to succeed:
- Using the hex file that I made, update fails:
sudo avrdude -p m2560 -b 115200 -c stk500v2 -D -P /dev/ttyUSB0 -U flash:w:stk500boot_v2_mega2560.hex -V
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.04s
avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: reading input file "stk500boot_v2_mega2560.hex"
avrdude: input file stk500boot_v2_mega2560.hex auto detected as Intel Hex
avrdude: writing flash (259880 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 259880 bytes of flash written
avrdude: verifying flash memory against stk500boot_v2_mega2560.hex:
avrdude: load data flash data from input file stk500boot_v2_mega2560.hex:
avrdude: input file stk500boot_v2_mega2560.hex auto detected as Intel Hex
avrdude: input file stk500boot_v2_mega2560.hex contains 259880 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x3e0e4
0x41 != 0x2a
avrdude: verification error; content mismatch
avrdude: safemode: Fuses OK (E:FD, H:D8, L:FF)
avrdude done. Thank you.
- Done it using the elf, as I saw a post that was suggesting it, but still fails:
sudo avrdude -p m2560 -b 115200 -c stk500v2 -D -P /dev/ttyUSB0 -U flash:w:stk500boot.elf -V
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.04s
avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: reading input file "stk500boot.elf"
avrdude: input file stk500boot.elf auto detected as ELF
avrdude: writing flash (259880 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 259880 bytes of flash written
avrdude: verifying flash memory against stk500boot.elf:
avrdude: load data flash data from input file stk500boot.elf:
avrdude: input file stk500boot.elf auto detected as ELF
avrdude: input file stk500boot.elf contains 259880 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x3e0e4
0x41 != 0x2a
avrdude: verification error; content mismatch
avrdude: safemode: Fuses OK (E:FD, H:D8, L:FF)
avrdude done. Thank you.
- Update it successfully using the 21KB hex file, so I can conclude that a missing something in the Makefile configuration:
sudo avrdude -p m2560 -b 115200 -c stk500v2 -D -P /dev/ttyUSB0 -U flash:w:stk500boot_v2_mega2560.hex -V
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.04s
avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: reading input file "stk500boot_v2_mega2560.hex"
avrdude: input file stk500boot_v2_mega2560.hex auto detected as Intel Hex
avrdude: writing flash (261406 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 261406 bytes of flash written
avrdude: verifying flash memory against stk500boot_v2_mega2560.hex:
avrdude: load data flash data from input file stk500boot_v2_mega2560.hex:
avrdude: input file stk500boot_v2_mega2560.hex auto detected as Intel Hex
avrdude: input file stk500boot_v2_mega2560.hex contains 261406 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: 261406 bytes of flash verified
avrdude: safemode: Fuses OK (E:FD, H:D8, L:FF)
avrdude done. Thank you.
Last step will be to do the following modification in stk500boot.c and flash the new version:
527c527
< void (*app_start)(void) = 0x0000;
---
> void (*app_start)(uint8_t mcuStatusReg) = 0x0000;
575c575
< app_start();
---
> app_start(mcuStatusReg);