Hi,
I am doing a thesis which include adding functionality to flash sketches over CAN (using a module). Optiboot should be kept as original as possible since the author of the thesis want to keep possibilities for the original sketch upload.
At the moment I'm trying to flash a sketch (example blink sketch but with external LED connected to pin 7) where the data bytes of the hexfile is put into an uint8 array and then written to flash. This is working as expected, I've compared the flash content using my flash method to uploading the sketch using Arduino IDE. The content of flash is exactly the same.
The problem is that the application never starts running. At power on, neither the built in LED or the LED connected to pin 7 flashes. If i but the reset button, the built in LED flashes constantly.
I suspect that my way of end the flash procedure and jump to application doesn't work. From my understanding, when the watchdog with time 1 second runs out, there should be a jump to 0x0000 since Optiboot only runs after a external reset. However, it seems like I get stuck in a bootloader loop.
Hardware: Arduino nano with ATmega328p, using version 8 of Optiboot.
Can anyone help me to understand what needs to be done to start the application after written a sketch to flash?
Attaching my function that writes to flash, which gets called just before the forever for-loop that reads UART.
Except that, no changes have been done to Optiboot.
Best regards,
Henrik