Burn bootloader and a program at the same time

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm looking for a way to burn a bootloader with a test program so that once the bootloader is flashed a program would launch immediately (that I'll use to test the MCU pins for soldering problems).

I need them to be flashed without having to disconnect the ISP plug, so it can be in 2 parts: load bootloader, flash program memory... but that'll erase the bootloader (or am I mistaken).

Does anybody know such project? I've seen it done, but I haven't got the source.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There's a lot of threads on here about how to put application and boot loader together in a single .hex file, to be written in a single 'burn'.

That seems like a hassle, when it can be done with a simple script.

Assuming you're using avrdude, and have two .hex files, we'll call them test.hex and boot.hex, here's one way to do it...

#!/bin/bash

avrdude -p atmega328 -P /dev/cu.usberial -c stk500v1 -U:w:flash:test.hex:i
avrdude -D -p atmega328 -P /dev/cu.usberial -c stk500v1 -U:w:flash:boot.hex:i

Note the -D switch on the second line. That tells avrdude to NOT perform a chip erase.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

what about programming the bootloader and use the bootloader to program the application. By that way you can also ensure that the bootloader is also working.. ;)