Hi, I am trying to use jdolinay’s avr_debug in a simple code using a custom board with and Atmega1284p, but I am not able to get it to work. I tried getting the latest optiboot bootloader, which according to jdolinay’s comments should be working after 2020 release, and changing the Make file to set the following information.
What I changed:
- The clock frequency from 16000000 to 8000000
- The baud rate to 38400
# Atmega1284p (8MHz full-swing xtal) @ 38400 baudrate
atmega1284_38: TARGET = atmega1284p
atmega1284_38: MCU_TARGET = atmega1284p
atmega1284_38: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=38400' '-DBIGBOOT'
atmega1284_38: AVR_FREQ = 8000000L
atmega1284_38: LDSECTIONS = -Wl,--section-start=.text=0x1fc00
atmega1284_38: $(PROGRAM)_atmega1284p_38.hex
atmega1284_38: $(PROGRAM)_atmega1284p_38.lst
atmega1284_38_isp: atmega1284_38
atmega1284_38_isp: TARGET = atmega1284p
atmega1284_38_isp: MCU_TARGET = atmega1284p
# 1024 byte boot
atmega1284_38_isp: HFUSE = DE
# Full swing xtal (8MHz) 14CK+65ms
atmega1284_38_isp: LFUSE = F7
# 2.7V brownout
atmega1284_38_isp: EFUSE = FD
atmega1284_38_isp: isp
After compiling and loading this new bootloader to my device, I am able to program it, but the debugger is not working.
main.cpp
#include <Arduino.h>
#include "avr8-stub.h"
#include "app_api.h"
void setup() {
debug_init();
breakpoint();
while(1);
}
void loop() {
}
platformio.ini
[env:custom]
platform = atmelavr
board = custom
framework = arduino
upload_port = COM13
monitor_port = COM13
monitor_speed = 38400
debug_tool = avr-stub
debug_port = \\.\COM13
debug_init_break = setup
lib_deps =
jdolinay/avr-debugger @ ~1.4
custom.json
{
"build": {
"core": "arduino",
"f_cpu": "8000000L",
"mcu": "atmega1284p",
"variant": "custom"
},
"debug": {
"simavr_target": "atmega1284p",
"avr-stub": {
"speed": 115200
}
},
"frameworks": [
"arduino"
],
"upload": {
"maximum_ram_size": 16384,
"maximum_size": 130048,
"protocol": "arduino",
"require_upload_port": true,
"speed": 38400
},
"name": "custom",
"url": "",
"vendor": ""
}
The error I am getting…
I also tried following the bootloader flash instructions in jdolinay’s avr_debug/bootloader/optiboot/readme_platformio.txt, but I cannot make it work.
Does anyone know how to make this debugger work with platformio on a custom avr board? If so, is there a tutorial I could follow to verify that the steps I am taking are not wrong?
Thanks!