Closed brunob45 closed 1 year ago
oh nice work :D
hello @brunob45 , Found finally some time to test your things but it didn't change Still the error message when trying to burn the bootloader to a AVR64DA32 or AVR64DA64 chips ( the command 'pio run -t bootloader' is working tough )
The flag 'USING_OPTIBOOT' not working, i still need to add it to the 'build_flag=' myself to platformio.ini if i want to use bootloader
Maybe it's not finished ? i don't know much about this kind of code
Hello @matou78 ,
May I get a copy of your platformio.ini
config file to try it out?
Sorry for the delay, too much work ... the build_flags is deactivated because i tried your modifications
[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
[env:serial_updi]
upload_protocol = serialupdi
upload_flags = -e
-v
@matou78 I just pushed a commit to use the latest version of avrdude. Could you try this config?
[env]
; platform is using this PR
platform = https://github.com/brunob45/platform-atmelavrdx#dev/avrea
board = AVR64DA32
framework = arduino
board_build.f_cpu = 24000000L
; Set bootloader serial port : ser0, ser1, or ser2
; For uploads with manual reset (no autoreset circuit), add <_8sec> to the selected port (ex. ser1_8sec)
board_hardware.uart = ser1_8sec
[env:Upload_UART]
upload_protocol = arduino
upload_speed = 115200
[env:serial_updi]
upload_protocol = serialupdi
upload_flags = -e -v
Then, to load the bootloader
pio run -e serial_updi -t bootloader
and to upload the code
pio run -e Upload_UART -t upload
By using the _8sec
bootloader, I'm able to power cycle the chip, then quickly launch the upload
target. It will execute within this 8 seconds timeout and upload successfully. Be sure to select the correct USART port (0,1, or 2) in the platformio.ini file.
Thanks :) will try it asap
@brunob45 Just gave it a try , there is few wrong things i found
the name of the .hex files that the builder is calling is wrong , for example the file called is optiboot_dx64_ser1_8sec.hex
but the correct one found in the framework is optiboot_64dx_ser1_all_8sec.hex
after i renamed the .hex so it get called without error ,when setting fuses , avrdude was showing an error but i solved it
the error was avrdude: unknown option --
because of the upload_flags = -e -v
because every upload flag has to be 1 per line
Now that the first part is working i get this
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/AVR64DA32.html
PLATFORM: Atmel megaAVR (1.7.0+sha.e5ca771) > AVR64DA32
HARDWARE: AVR64DA32 24MHz, 8KB RAM, 64KB Flash
PACKAGES:
- framework-arduino-megaavr-dxcore @ 1.4.10
- tool-avrdude @ 1.70100.0 (7.1.0)
- toolchain-atmelavr @ 3.70300.220127 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 18 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Using bootloader optiboot_dx64_ser1_8sec.hex
TARGET CONFIGURATION:
-------------------------
Target = avr64da32
Clock speed = 24000000L
Oscillator = internal
BOD level = 2.6v
Save EEPROM = yes
Reset pin mode = reset
-------------------------
Auto-detected: COM7
Selected fuses:
-------------------------
[fuse0 / wdtcfg = 0x00]
[fuse1 / bodcfg = 0x00]
[fuse2 / osccfg = 0x00]
[fuse4 / tcd0cfg = 0x00]
[fuse5 / syscfg0 = 0xC9]
[fuse6 / syscfg1 = 0x06]
[fuse7 / codesize = 0x00]
[fuse8 / bootsize = 0x01]
[lock / lockbit = 0x5CC5C55C]
-------------------------
Setting fuses...
avrdude: Version 7.1-arduino.1
Copyright the AVRDUDE authors;
see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is C:\Users\Matou\.platformio\packages\tool-avrdude\avrdude.conf
Using Port : COM7
Using Programmer : serialupdi
AVR Part : AVR64DA32
RESET disposition : dedicated
RETRY pulse : SCK
Serial program mode : yes
Parallel program mode : yes
Memory Detail :
Block Poll Page Polled
Memory Type Alias Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
fuse0 wdtcfg 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse1 bodcfg 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse2 osccfg 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse4 tcd0cfg 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse5 syscfg0 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse6 syscfg1 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse7 codesize 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse8 bootsize 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuses 0 0 0 0 no 9 16 0 0 0 0x00 0x00
lock 0 0 0 0 no 4 1 0 0 0 0x00 0x00
tempsense 0 0 0 0 no 2 1 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 1 0 0 0 0x00 0x00
prodsig 0 0 0 0 no 125 125 0 0 0 0x00 0x00
sernum 0 0 0 0 no 16 1 0 0 0 0x00 0x00
userrow usersig 0 0 0 0 no 32 32 0 0 0 0x00 0x00
data 0 0 0 0 no 0 1 0 0 0 0x00 0x00
eeprom 0 0 0 0 no 512 1 0 0 0 0x00 0x00
flash 0 0 0 0 no 65536 512 0 0 0 0x00 0x00
Programmer Type : serialupdi
Description : SerialUPDI
avrdude: NVM type 2: 24-bit, word oriented write
avrdude: entering NVM programming mode
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9614 (probably avr64da32)
avrdude: erasing chip
avrdude: reading input file 0x00 for fuse0/wdtcfg
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte fuse0/wdtcfg ...
avrdude: 1 byte of fuse0/wdtcfg written
avrdude: verifying fuse0/wdtcfg memory against 0x00
avrdude: 1 byte of fuse0/wdtcfg verified
avrdude: reading input file 0x00 for fuse1/bodcfg
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte fuse1/bodcfg ...
avrdude: 1 byte of fuse1/bodcfg written
avrdude: verifying fuse1/bodcfg memory against 0x00
avrdude: 1 byte of fuse1/bodcfg verified
avrdude: reading input file 0x00 for fuse2/osccfg
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte fuse2/osccfg ...
avrdude: 1 byte of fuse2/osccfg written
avrdude: verifying fuse2/osccfg memory against 0x00
avrdude: 1 byte of fuse2/osccfg verified
avrdude: reading input file 0x00 for fuse4/tcd0cfg
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte fuse4/tcd0cfg ...
avrdude: 1 byte of fuse4/tcd0cfg written
avrdude: verifying fuse4/tcd0cfg memory against 0x00
avrdude: 1 byte of fuse4/tcd0cfg verified
avrdude: reading input file 0xC9 for fuse5/syscfg0
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte fuse5/syscfg0 ...
avrdude: 1 byte of fuse5/syscfg0 written
avrdude: verifying fuse5/syscfg0 memory against 0xC9
avrdude: 1 byte of fuse5/syscfg0 verified
avrdude: reading input file 0x06 for fuse6/syscfg1
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte fuse6/syscfg1 ...
avrdude: 1 byte of fuse6/syscfg1 written
avrdude: verifying fuse6/syscfg1 memory against 0x06
avrdude: 1 byte of fuse6/syscfg1 verified
avrdude: reading input file 0x00 for fuse7/codesize
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte fuse7/codesize ...
avrdude: 1 byte of fuse7/codesize written
avrdude: verifying fuse7/codesize memory against 0x00
avrdude: 1 byte of fuse7/codesize verified
avrdude: reading input file 0x01 for fuse8/bootsize
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte fuse8/bootsize ...
avrdude: 1 byte of fuse8/bootsize written
avrdude: verifying fuse8/bootsize memory against 0x01
avrdude: 1 byte of fuse8/bootsize verified
avrdude: reading input file 0x5CC5C55C for lock
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lock ...
avrdude: 1 byte of lock written
avrdude: verifying lock memory against 0x5CC5C55C
avrdude: 1 byte of lock verified
avrdude: leaving NVM programming mode
avrdude done. Thank you.
Uploading bootloader
avrdude: Version 7.1-arduino.1
Copyright the AVRDUDE authors;
see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is C:\Users\Matou\.platformio\packages\tool-avrdude\avrdude.conf
Using Port : usb
Using Programmer : serialupdi
avrdude ser_open() error: cannot open port usb: Le fichier sp\xe9cifi\xe9 est introuvable.
avrdude main() error: unable to open programmer serialupdi on port usb
avrdude done. Thank you.
*** [bootloader] Error 1
========================================================================================== [FAILED] Took 1.89 seconds ==========================================================================================
Environment Status Duration
------------- -------- ------------
serial_updi FAILED 00:00:01.892
Then i can't chose if i want to upload using bootloader or without it ? When i hit "upload" with serialupdi it sends the program but not the fuses so the chip is stuck in a sort of bootloop and as i hit set fuses, it sends the fuses for the booloader .
Thanks for your time
Please check the Platformio documentation in the official DxCore repo. There's a section about how to select the bootloader.
The board_hardware.uart = ...
is where you tell if you are using Optiboot or not.
If you are uploading via UPDI, then you are not using Optiboot, so leave this line commented out.
This is the same as selecting the board AVR DA-series (no bootloader)
in the Arduino IDE Tools
->Board: ...
Note that in the Arduino IDE, the menus Tools
->Bootloader Serial Port
and Bootloader Entry Condition
are not present when this board is selected.
If you are uploading via serial (arduino), then tell which Serial Port you'll be using.
This is the same as selecting the board AVR DA-series (Optiboot)
in the Arduino IDE Tools
->Board: ...
In the Arduino IDE, you would normally select the bootloader in the menu Tools
->Bootloader Serial Port
and Bootloader Entry Condition
.
In PlatformIO, you specify the bootloader using board_hardware.uart = ...
(ex. ser1_8sec
).
Note that, in the Arduino IDE, the upload_port
is dependant on the selected board: Optiboot
or no bootloader
.
Optiboot
, the upload_port
is the equivalent of PlatformIO's arduino
.no bootloader
, the upload_port
is the protocol chosen in Tools
->Programmer: ...
.If you want to upload via serial
board_hardware.uart = ...
.pio run -t bootloader
.if you want to upload via UPDI
board_hardware.uart = ...
.pio run -t fuses
.Hi @brunob45, thanks for the PR. It seems the latest v1.5.6 follows a different bootloader file name pattern, e.g. optiboot_32dd14_ser0_alt3_poronly_8sec.hex
. Any thoughts?
oh shit this is why i didn't understand why i had to rename myself the files x) i updated the dxcore to the latest version manually before i tried this repo
@valeros I noticed that too. I thought about different solutions. Should it be backward compatible?
If the dxcore package is updated to 1.5.x, we could just update the bootloader file name pattern. I already fixed it in my branch dev/avrea2
https://github.com/brunob45/platform-atmelavrdx/tree/dev/avrea2
But this won't work for the DD series... Let me try something first
@valeros
I edited the bootloader.py
script to be able to specify the bootloader. For example, in platformio.ini
:
[env]
...
board_bootloader.class = optiboot_32dd14
board_bootloader.port = ser0_alt3 ; Serial Port used for upload
board_bootloader.entrycond = poronly_8sec ; Entry Condition to enable upload
...
The resulting bootloader file would be optiboot_32dd14_ser0_alt3_poronly_8sec.hex
.
In another PR, I would like to edit the .json
files for all DxCore boards, adding
{
...
"bootloader": {
"class": "optiboot_32dx"
},
...
}
so the default value for bootloader.class
is correct.
See:
What do you think about this solution?
@valeros Thank you for the comments, the issues have been fixed
@brunob45 Many thanks for the PR, merged.
pio run -t bootloader
commandMILLIS_USE_TIMER
variable:board_hardware.millistimer
(see description in SpenceKonde/DxCore#333)USING_OPTIBOOT
to all DxCore variants when a bootloader is specified (following SpenceKonde/DxCore#329)This PR may help closing issues #41 & #42.