Hello PPL, normaly I am here offering my services to others, today however i need some help of my own to do something that it ouside of my comfort zone.
I need a bootloader for the ATMEGA2560 that loads firmware from a SD card.
The SPI pins are all standard asside from the DS pin.
I would also like to use an LED to indicate that the upload is progressing.
I started looking at the following project but it seems to be well out of date and, quite frankly, confusing to me.
Please DM me if you can help
With a budget in mind of < 50USD
Have you tried the code in the linked project? It compiles quite fine, IMO it should work out of the box when you modify hardware/microbridge/avr/bootloaders/microbridge/asmfunc.S to match your layout. IMO it woild be nicer to use a pin to trigger firmware download
The procedure is equivalent to defining a new board in the Arduino IDE, although it would be much similar to Mega with only a few changes.
What is required is to create a new board defination file with the attributes you require and compile that with the gcc tool chain and make to create your desired hex file of your custom Bootloader.
The github project seems to be making that easy for you, although it is indeed old and the IDE has evolved a lot since then.
Honestly, 50$ is too less of a budget to work on this for me.
Unfortunately i don’t have the tools. This is why i am asking for someone out there who does to compile a version for me with the correct DS and LED pins defined for my hardware.
Thanks for your input, What i am asking for is someone to compile the sample project that is posted into a binary i can load into my mega. I just need the DS and LED pins redefined to suite my hardware.
I thought about 50 USD was a reasonably good price for this piece of work.
When you post your pins I can send you the binary.
Excellent thank you, im not at my desk atm ill post it later
The SD_SS is on PB5 (Chip pin 24 on the atmega2560)
The LED is on PH3 (Chip pin 16 on the atmega2560)
Please let me send you something for this.
Let's see if this works ...
stk500boot_v2_mega2560.hex.zip (6.9 KB)
Thank you i will try this in the morning
Hi, sorry i have not had a minute to test it in the last few days. work keeps getting in the way. I will try and do some testing this afternoon. Thank you for your time and ill let you know.
I did note it is a hex file and not a bin. can i upload a hex directly ?
Cheers Pete.
The docs say to flash ist use:
avrdude -p m2560 -c stk500v2 -P /dev/ttyXXX -U flash:w:stk500boot_v2_mega2560.hex -U lock:w:0x0F:m -v
avrdude -c stk500v2 -p m2560 -P /dev/ttyXXX -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U lfuse:w:0xFF:m -e -v
... you may want to use a different paremeter on "-c"
OK cool thank ill give that a go later
OK adjusted the -p and -c to reflect my AVR programmer and it flashed the bootloader.
reloaded my program and it boots OK, nect i will compile a simple blink and see if it flashes it
OK i am confused, did you set up the bootloader to check for .HEX or .BIN files
where can i get avr-objcopy from ?
Ok a little update, I have the bootloader on the mage now and the LED is flashing at ~1hz.
it never comes out of the bootloader, even if there is no SD card.
It also does not load the firmware.bin file.
One thing that has occured to me. When using the SPI bus on the mega you MUST set the SPI default SS pin as an output for the bus to work. So in addition to my DS pin being set as an output you must also set PB0 (chip pin 19) as an output.
Could you please build me another version with this pin set.
Next try, PB0 is set to output. Sorry, I don't have a atmega2560 at hand, otherwise I could test.
stk500boot_v2_mega2560.hex.zip (6.9 KB)
Oh, there should be some debug messages on serial at 115200 baud - but I'm not sure if there really is any.
Note: the file on the SD-Card should be called "firmware.bin"
Thank for this latest, it is doing the same, just flashing the LED, never dropping out and running the program firmware. Also unfortunaltly nothing on the serial ports 0 and 1
Ok, dug a bit deeper. Now it sends "booting..." when entering the bootloader. Also some LED debugging should be turned on (fast flashes etc.), Did you set EEPROM 0x1FF to 0xF0?
stk500boot_v2_mega2560.hex.zip (7.1 KB)