Hello.
I'm trying to make a bootloader for an ATmega4809.
I'm using this programmer
https://github.com/ElTangas/jtag2updi
And it works fine so far.
I'm using AtmelStudio 7.0.1931
I'm trying to flash two .elf files into the chip but according to my code, only one should be executed.
This is bootloader code
#include <atmel_start.h> #include <string.h> #include <stdio.h> #include <avr/delay.h> #include "src/console/console.h" int main(void) { /* Initializes MCU, drivers and middleware */ sei(); atmel_start_init(); while(1) { printLine("bootloader\r\n"); } }
This is main application code
#include <atmel_start.h> #include <string.h> #include <stdio.h> #include <avr/delay.h> #include "src/console/console.h" int main(void) { /* Initializes MCU, drivers and middleware */ sei(); atmel_start_init(); while(1) { printLine("main firmware\r\n"); } }
According to the datasheet. there are sections, BOOTEND, APPEND that are used only for flash memory protection.
I think I don't need that kind of protection for my tests now. So I can just flash both .elf files, one at the beginning and one just a few blocks further to see what the mcu is executing.
The BOOTEND and APPEND fuses has to setup in blocks of 256 bytes. So I chose to leave 8192 bytes for bootloader and write the main application there.
The flash address starts at 0x4000 + 0x2000 (8192 dec) = the main application should be at 0x6000.
I setup the AtmelStudio the address for the main application.
I'm flashing the "bootloader" firmware with
avrdude.exe -c jtag2updi -P com5 -p m4809 -e -U flash:w:bootloader.elf
I perform full chip erase before flashing the bootloader.elf.
and the "main application" firmware with
avrdude.exe -c jtag2updi -P com5 -p m4809 -D -U flash:w:main_app.elf
I think the -D flag prevents ISP programmer to erase anything...
When the main_app.elf is loaded, gibberish is printed on the terminal...
What am I doing wrong?