Flashing Arduino Mega2560 via SD Card (Barebones Setup)

Hello!
I have a project where I am using an atmega 2560 chip on a board done by me that monitors enviromental conditions and stores the data in an SD card. I upload the code with avrdudes and a usb avrisp xp2 but since i have some of them placed and it would be nice to just go around with an sd card to update any firmware instead of the whole cable and pc, and I have seen this should be possible.

I have looked into the MicroBridge option https://github.com/FleetProbe/MicroBridge-Arduino-ATMega2560/tree/master. but after a couple of days i have not managed to get it going and would need some help if anyone has tried this approach recently!

For what i have tried I should load first the bootloader from MicroBridge to my device with the correct fuse bites (BOOTRST selected) and then load my device code with the disable flash erase (-D) selected so the bootloader is not deleted when flashing the device again... The fuse bites I am using L=0xC0 H=0xD8 E=0xFD LB=0xFF (I am using an external clock that is why low fuse is set like that) Also the the SD pins i am using are the same as the ISP bootloader says.

The bootloader i have tried loading is the stk500boot.hex file in the repository, then loading my code .hex file by disabling the flash erase while programming. And then the file that i am using afterwards in the SD card is the .BIN file that the arduino generates in the sketches folder and change the name to FIRMWARE.BIN:


am i on the correct path or is there something i am missing? or a lot of things :sweat_smile:

I raised this issue for the 328P back in 2019, and found that there was already a project underway.

https://forum.arduino.cc/t/sd-card-bootloader/586264

You might want to contact @pert and others who participated in the thread to see if they can help.

I've never used a 2560, so can't really offer any advice. But if your project is anything like the one I did for the MSP430, you want the bootloader to first check the SD card for the presence of a particular filename, and if found, flash the new firmware from the card into the 2560. But do that only once.

It's not clear from your description where you are stuck. Are you able to write your revised bootloader to the 2560? Does it operate as a normal bootloader if the file is not present?

Ok, I managed to make it work finally after trying a bit more . And it seems to be working perfectly. Just had to follow instructions carefully. It seems like i was loading the wrong .bin file, I had to convert the hex file without bootloader with the cmd screen with avr-objcopy -I ihex -O binary RECEIVER_FINAL.ino.hex firmware.bin and load that to the sd card. Thanks for answering by the way!

Glad you got it working. Are you going to publish/post the entire process somewhere? Or is it essentially the MicroBridge process?

I will make a small guide of what i did with images to add to the Microbridge process here, it would have helped me a lot.

That's great. Now I wonder if this would work with the 328P.

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