Hi, I have a board atmega328p xplained mini on hand:
The target chip is atmega328p, and there is a debugger (mEDBG) on the board. The IDE recommended by the microchip is “microchip studio”, but it’s too big and slow.
I want to use Platformio, and find this thread, following the instructions posted in the thread, I uploading the code successfully, thanks @ maxgerhardt.
The instructions for uploading:
step1: use zadig to change the driver to “libusb-win32”
step2: select “ATmega328P/PA(Microchip)” in the drop-down list of the Board when creating the platformio project
step3a: for the C code
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRD |= 0b00001000;
while (1)
{
PORTD &= 0b11110111;
_delay_ms(1000);
PORTD |= 0b00001000;
_delay_ms(1000);
}
}
the platformio.ini is:
[env:ATmega328P]
platform = atmelavr
board = ATmega328P
upload_protocol = custom
upload_flags =
-C
$PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
-p
atmega328p
-Pusb
-c
xplainedmini
-e
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i
step3b: for the arduino code
#include <Arduino.h>
unsigned char i = 0;
void setup()
{
pinMode(3,OUTPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(3,HIGH);
delay(500);
digitalWrite(3,LOW);
delay(500);
Serial.println(i++);
}
the platformio.ini is
[env:ATmega328P]
platform = atmelavr
board = ATmega328P
framework = arduino
upload_protocol = custom
upload_flags =
-C
$PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
-p
atmega328p
-Pusb
-c
xplainedmini
-e
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i
Both of step3a and step3b can be used for uploading successfully.
Then I want to debugging, as there is a debugger mEDBG on the board. There is a thread discussing atmega32 debugging on linux, but my OS is windows(10), and the debugger in the thread is avrice, not mEDBG.
I find that the default debugger used for atmega328p supported by platformio is avr-stub, but the atmega328p xplained mini board has a real debugger on board, can anyone tell me some instructions about how to configure platformio.ini to use the on board debugger mEDBG for debugging?
Best regards.