AVRxxDAxx not working with dxcore merge

Hello everyone,

Coming here because i really need some help, can’t find a solution myself

I started a little project to make myself few arduino with AVR64DA32 chips.
I wanted to use PlatformIO for it ( but ArduinoIDE is still compatible)
DXcore(v1.4.5) has been added to the atmelmegaavr lib so everything should work .

So before i order the PCBs i wanted to do some tests and see if everything is working as it should.

For last week tried to program and use the AVRxxDA32 chips without any luck,

First started with the usual default config but wasn’t able to do anything, errors on programming everywhere ( default is jtag2updi or something like that)
Then found “pyupdi” and used it with a home made programmer ( based on CH340B ) to put something on the AVR chip and start playing with it .
I was able to upload a little program that make a led blink and through Serial " test ok" to see if UART is working.

The problem is , anything that i uploaded to the chip, nothing worked even if the program and verify was completed .

To troubleshoot, went to dig back the arduinoIDE , installed the DXcore and boom, everything worked,
Bootload burn then UART upload worked too.

Then went back to platformIO ( keep in mind , the led was blinking at that moment ) , uploaded again using UPDI and , dead again .

So there i am , anyone had troubles with that too ? Or even any ideas, i can take everything .

If needed, can upload the project from platformIO .

Thanks for your time, and hopefully see you soon :slight_smile:

What is your exact platformio.ini and test program?

Hey max,
here you go, the platformio.ini

[env]
platform = atmelmegaavr
board = AVR64DA32
framework = arduino
monitor_port = ${env:Upload_UART.upload_port}

[env:Upload_using_pyupdi]
upload_protocol = SerialUPDI
upload_speed = 230340
upload_port = COM4
upload_flags =
  -t
  uart
  -d
  $BOARD_MCU
  -u
  $UPLOAD_PORT
  -c
  $UPLOAD_SPEED
upload_command = pymcuprog write $UPLOAD_FLAGS -f $SOURCE

[env:Upload_UART]
upload_protocol = arduino
upload_speed = 115200

and the program I’m using to test quickly a chip .

#include <Arduino.h>

int const pinLed = PIN_PF4;

void setup() {
  Serial.begin(9600);
  pinMode(pinLed, OUTPUT);
  digitalWrite(pinLed,LOW);

}

void loop() {
  digitalWrite(pinLed,HIGH);
  Serial.println("test ok");
  delay(5000);
  digitalWrite(pinLed,LOW);
  delay(2000);
}

As in the wiki, the new chips page are empty and there is not any examples, i tried few things and it’s the only thing i tried that uploaded something to the chip x)

That’s weird – I would expect upload_protocol = custom here so that the upload_command is used. But PlatformIO is uploading the program perfectly fine, it’s just that it does not do anything? Are you using the first or the second environment for uploading?

oh shit, made the modification yesterday to test things and left it in , but originally i used upload_protocol = custom

I’m using the first one env:Upload_using_pyupdi

Yes, after programming the chip, there is 0 activity , pins are at around 0.5V, serial pin low .
I can’t uderstand what is wrong,
With ArduinoIDE the same chip is working as it should .

EDIT1
Yesterday i bought a mplab_snap and a pickit4 , just received them, will try with that and hope it works so can see where is the problem .

So, i just tested mplab snap but not working too but with some changes .

I used for the mplab snap

[env:Upload_mplab_snap_updi]
upload_protocol = snap_updi

After programming the chip using “mplab snap” the LED goes HIGH full time and the Serial is spitting some
“ttttttttttttttt” .

Looks like a problem/bug in the dxcore inside platformio

Using the platformio.ini

[env]
platform = https://github.com/platformio/platform-atmelmegaavr.git
board = AVR64DA32
framework = arduino
monitor_port = ${env:Upload_using_pyupdi.upload_port}
platform_packages = 
    framework-arduino-megaavr-dxcore@https://github.com/maxgerhardt/DxCore/archive/refs/heads/master.zip

[env:Upload_using_pyupdi]
upload_protocol = custom
upload_speed = 230340
upload_port = COM4
upload_flags =
  -t
  uart
  -d
  $BOARD_MCU
  -u
  $UPLOAD_PORT
  -c
  $UPLOAD_SPEED
upload_command = pymcuprog write $UPLOAD_FLAGS -f $SOURCE

makes no difference?

nope nothing :frowning:
I even went to github , downloadeddxcore 1.4.7 release, and replaced what was in the package framework-arduino-megaavr-dxcore

but it did nothing

Looks like it’s uploading an empty .hex or something,
Even through UART it upload but nothing happens ( i burned a bootloader through ArduinoIDE and uploaded the sketch too but as soon as i upload something through platformIO, is stops working)

Uploading through ArduinoIDE tells me :
avrdude: Device signature = 0x1e9614 (probably avr64da32)
avrdude: writing flash (3048 bytes):
avrdude: 3048 bytes of flash verified

Uploading through PlatformIO tells me :
avrdude: Device signature = 0x1e9614 (probably avr64da32)
avrdude: writing flash (3090 bytes):
avrdude: 3090 bytes of flash verified
avrdude: safemode: Fuses OK (E:FF, H:FF, L:FF)

The fuses looks odd to me but i know nothing about it

i compared the 2 avrdude.conf and seems same

What configuration settings do you have in the Arduino IDE’s “Tool” menu for the chip?

image

In the Arduino IDE, can you enable in File → Preferences the verbose building of the firmware, then recompile the firmware and post the full compile command for the e.g. main sketch file here? In PlatformIO, execute the project task Clean, then Advanced → Verbose Build and copy one compile command here too. Then we can compare.

had to upload them in 2 .txt files as there is a limit of 30k characters and this things have 100k lol

EDIT1

i see dome differences but no idea what or how to add them in plaformio

this is plafromio
-DARDUINO_AVR_AVR64DA32 -DARDUINO_avrda -DF_CPU=24000000L -DARDUINO_ARCH_MEGAAVR -DARDUINO=10808 -DCLOCK_SOURCE=0 -DDXCORE=\"1.4.7\" -DDXCORE_MAJOR=1UL -DDXCORE_MINOR=4UL -DDXCORE_PATCH=7UL -DDXCORE_RELEASED=1 -DCORE_ATTACH_ALL -DTWI_MORS_SINGLE -DMILLIS_USE_TIMERB2

And here arduinoIDE
-mmcu=avr64da32 -DF_CPU=24000000L -DCLOCK_SOURCE=0 -DCORE_ATTACH_ALL -DTWI_MORS_SINGLE -DMILLIS_USE_TIMERB2 -DARDUINO=10815 -DARDUINO_avrda -DARDUINO_ARCH_MEGAAVR "-DDXCORE=\"1.4.7\"" -DDXCORE_MAJOR=1UL -DDXCORE_MINOR=4UL -DDXCORE_PATCH=7UL -DDXCORE_RELEASED=0 -DSERIAL_PORT_BOOT=Serial -DSERIAL_PORT_BOOT_PORTMUX=0 -DUSING_OPTIBOOT

1 Like

Alright that will help a lot when I take a look at it later. Can you also activate verbose upload in the Arduino IDE (File → Preferences) and log that, and in the same way do a Advanced → Verbose Upload in PlatformIO for comparison. (not e.g. that the firmware in PlatformIO is simply uploaded to the wrong address)

Thank you a lot for your time, this chips are fairly new and not much infos are available .

Both uploads are done through UART so the bootloader is still there

When we find the solution, first thing i will try to put it on the wiki when i have time

EDIT1
Just tried by curiosity to burn the bootloader through platformIO and it gives me and error

> Executing task in folder Test_PCB_AVRxxDx Arduino: C:\Users\Matou\.platformio\penv\Scripts\platformio.exe run --target bootloader --environment Upload_using_pyupdi <

Processing Upload_using_pyupdi (platform: atmelmegaavr; board: AVR64DA32; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/AVR64DA32.html
PLATFORM: Atmel megaAVR (1.5.0+sha.abbc969) > AVR64DA32
HARDWARE: AVR64DA32 24MHz, 8KB RAM, 64KB Flash
PACKAGES:
 - framework-arduino-megaavr-dxcore 1.4.7
 - tool-avrdude-megaavr 3.60300.220118 (6.3.0)
 - toolchain-atmelavr 3.70300.0 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 16 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Error: missing bootloader configuration!
============================================================ [FAILED] Took 0.61 seconds ============================================================

Environment          Status    Duration
-------------------  --------  ------------
Upload_using_pyupdi  FAILED    00:00:00.615

EDIT2

Found a strange thing in eeprom size
ArduinoIDE line 140

           eeprom         0     0     0    0 no        512   32      0     0     0 0x00 0x00

PlatformIO line 136

       eeprom         0     0     0    0 no        512    1      0     0     0 0x00 0x00

finally got something to work

Managed to get working the classic UART upload but uplading through updi still not working

To sum up
1- Bootloader burned with arduinoIDE ( can’t get it working in platformIO for now)
2- Then uploading a simple blinking led sketch through UART (Serial) still with arduinoIDE , worked as it should
3- Went into platformIO and uploaded the same thing but the LED went HIGH and nothing happened .

maxgerhardt asked verbose logs from arduinoIDE and platfotmIO to see the differences .

Found some arguments not present in platfomio and last 2 says didn’t touch it as i know shit about it .

Today went inside of .platformio\platforms\atmelmegaavr\boards\avr64da32.json and added
-DUSING_OPTIBOOT to line 4 (because well, you got it , no idea how to where to put it in platformio.ini )


And miracle, the led is working lol

Now 1 problem is solved but 2 others still there
Sketch upload Through UPDI ( without bootloader) is still not working
And Bootloader Burn can’t get it working too …

1 Like

Found how to add the extra flags
image
So i don’t need to modify the .json files to add them :smiley:

Now will try to find and add them to the updi upload and see maybe it will work

Do someone know how to get the bootloader burning to work ? or just to give me a path to follow ?
Found few things from usual atmega chips but can’t get it working :frowning:

1 Like

Sorry I was too busy with other things.

This is crucial. Please file a bug in Issues · platformio/platform-atmelmegaavr · GitHub. That has to be at least documented or the default in the board’s JSON file if people pretty much always use it with a bootloader.

1 Like

Same about this, the bootloader path data in platform-atmelmegaavr/boards/AVR64DA64.json at develop · platformio/platform-atmelmegaavr · GitHub has to be added and used in platform-atmelmegaavr/builder/bootloader.py at develop · platformio/platform-atmelmegaavr · GitHub. Bootloader programming for AVRxxDAxx chips can be opened as a separate issue.

1 Like

okay i will do that, thank you again for the time and help :slight_smile:

EDIT

In case someone comes by and search informations or have ideas , here are the GitHub posts

1 Like

Hello,
Just in case , I’m posting here my working platformio.ini for upload through UART with bootloader already on the chip

[env]
platform = atmelmegaavr
board = AVR64DA32
framework = arduino
board_build.f_cpu = 24000000L

[env:Upload_UART]
build_flags = -DUSING_OPTIBOOT
upload_protocol = arduino
upload_speed = 115200

Tried some things for bootloader burn through platformio but too complicated for me, can’t do shit for it x)
At least uart is working