Closed MCUdude closed 4 years ago
@valeros any thoughts?
Hi @MCUdude ! I've pushed your development with slight modification, including fixes for the issues your specified above. It'd be great if you could test new functionality using the platform for dev branch. Thanks!
I'm not completely done testing, since there are some issues that are preventing me. First, I'm getting the incorrect device signature in Avrdude again. I've manually deleted the tool-avrdude-megaavr
package. Here's the output:
$ pio run -t fuses -e fuses_bootloader
Processing fuses_bootloader (platform: https://github.com/platformio/platform-atmelmegaavr.git#develop; board: ATmega3209)
--------------------------------------------------------------------------------------------------------------------------------------------------
Tool Manager: Installing platformio/tool-avrdude-megaavr @ ~1.60300.0
Tool Manager: tool-avrdude-megaavr @ 1.60300.191015 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/ATmega3209.html
PLATFORM: Atmel megaAVR (1.2.0+sha.daf7155) > ATmega3209
HARDWARE: ATMEGA3209 16MHz, 4KB RAM, 32KB Flash
PACKAGES:
- tool-avrdude-megaavr 1.60300.191015 (6.3.0)
- toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
TARGET CONFIGURATION:
------------------------
Target = atmega3209
Clock speed = 16000000L
Oscillator = internal
BOD level = 2.7v
Save EEPROM = yes
Reset pin mode = reset
------------------------
Selected fuses:
------------------------
[fuse0 / WDTCFG = 0x0]
[fuse1 / BODCFG = 0x0]
[fuse2 / OSCCFG = 0x1]
[fuse4 / TCD0CFG = 0x0]
[fuse5 / SYSCFG0 = 0xc9]
[fuse6 / SYSCFG1 = 0x6]
[fuse7 / APPEND = 0x0]
[fuse8 / BOOTEND = 0x2]
[lfuse / LOCKBIT = 0xc5]
------------------------
Setting fuses...
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.07s
avrdude: Device signature = 0x1e9531
avrdude: Expected signature for ATmega3209 is 1E 95 53
Double check chip, or use -F to override this check.
avrdude done. Thank you.
*** [fuses] Error 1
I'm not sure what's causing this. I was able to sneak in the -F flag to continue my testing.
Setting fuses works fine. However, bootloading not so much:
error: Couldn't find bootloader image bootloaders/bootloaders/optiboot/bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.hex
The corerct path is bootloaders/optiboot/bootloaders/mega0/115200/Optiboot_mega0_UART3_DEF_115200_A7.hex
I believe.
Another thing. I'm pretty sure all fuses are supposed to be in capital letters. At least, that's what Microchip uses in Atmel Studio and in their datasheets
About the 0x200 offset. I think we should use the upload_protocol
value as the indicator, not board_hardware.uart
. There's no real reason to specify what exact UART port on your target that's used for serial uploads.
[env:Upload_UART]
platform = https://github.com/platformio/platform-atmelmegaavr.git
framework = arduino
board = ATmega3209
board_build.f_cpu = 16000000L
board_hardware.bod = 4.3v
board_build.variant = 48pin-standard
upload_protocol = arduino
upload_port = /dev/cu.usbserial-1420
In this example, since upload_protocol = arduino
, it means that we're using a bootloader, and thus 0x200 is needed. It's also a benefit since upload_protocol
has to be defined anyways if you're using a bootloader for uploads.
Another 0x200 related bug; 0x200 is actually added when no bootloader is used, so it's the other way around. But again This is wrong. I got my platformio.ini settings wrong due to the upload_protocol
would be betterboard_hardware.uart
parameter confusion I've caused myself.
First, I'm getting the incorrect device signature in Avrdude again. I've manually deleted the tool-avrdude-megaavr package.
Thanks for testing! I see you didn't specified framework = arduino
in your configuration. That explains most of the issues. I suppose we should allow using your boards without any framework? In this case, where users should get bootloader binaries? Arduino packages are optional, if users don't run any example with Arduino framework, they won't be downloaded.
Another thing. I'm pretty sure all fuses are supposed to be in capital letters. At least, that's what Microchip uses in Atmel Studio and in their datasheets.
Thanks, now I see why you used %.2X
, should be fixed now.
About the 0x200 offset. I think we should use the upload_protocol value as the indicator, not board_hardware.uart.
Thanks, fixed as well.
I see you didn't specified framework = arduino in your configuration. That explains most of the issues.
🤦 Of course! I'm being sloppy, sorry! This fixed the issues I faced.
There's one tiny formatting thing I'd like to have fixed:
Selected fuses:
------------------------
[fuse0 / WDTCFG = 0x00]
[fuse1 / BODCFG = 0x00]
[fuse2 / OSCCFG = 0x01]
[fuse4 / TCD0CFG = 0x00]
[fuse5 / SYSCFG0 = 0xC9]
[fuse6 / SYSCFG1 = 0x06]
[fuse7 / APPEND = 0x00]
[fuse8 / BOOTEND = 0x02]
[lfuse / LOCKBIT = 0xc5]
------------------------
You can probably guess what it is? Add a space in front of the =
character to get everything aligned 👍
Another question @valeros. Is it possible to get access to a parameter defined in one environment in another environment? Take this example:
[env:environment1]
upload_protocol = xplainedmini_updi
[env:environment2]
upload_protocol = ${environment1.upload_protocol}
This would be very convenient in the platformio.ini template I'm creating for MegaCoreX
EDIT: I figured it out!
[env:environment1]
upload_protocol = xplainedmini_updi
[env:environment2]
upload_protocol = ${env:environment1.upload_protocol}
Thanks, the formatting should be fine now.
Awesome!
Here are the README and platformio.ini template I've created for MegaCoreX users:
https://github.com/MCUdude/MegaCoreX/blob/master/PlatformIO.md
Are we ready for a new atmelmegaavr release?
Here are the README and platformio.ini template I've created for MegaCoreX users:
Is there any chance you could port that page to PlatformIO docs? Something similar to the atmelavr
docs you added earlier.
Are we ready for a new atmelmegaavr release?
Once the issue #10 is resolved.
Once the issue #10 is resolved.
Sure! I do have an Uno Wifi Rev2, so iI can help out with the testing this evening.
@valeros are we ready for a new release? I don't think there will be any significant changes in this repo for a while since pretty much all MegaCoreX features are implemented, and the bugs regarding Uno Wifi Rev2/Nano Every (#10) are fixed.
Thanks, released.
Hi! After you @valeros released the latest
atmelmegaavr
package I started working on the fuses/bootloader script, and it wasn't that much work really. As mentioned earlier, I am NOT a (professional) Python programmer. The scrips work, but they are probably terrible because I'm happy as long as they just do what I want.First, here is the fuses script I've come up with:
Note that many of the functions are empty and only return a constant. This is on purpose so it's easier to extend the functionality later (other megaavr cores etc.).
Here is the bootloader script:
I removed the
board_bootloard.pins
parameter to make the setup procedure more similar to my other cores. You can instead useboard_hardware.uart = uart0 #or uart0_def or uart0_alt
There are some minor issues we need to work out though.
USE_EXTERNAL_OSCILLATOR
somewhere ifboard_hardware.oscillator = external
is present in platformio.ini. I know this could be added to the build flags, but it would be slightly more elegant if it could be hidden just like in the Arduino IDE. This will harmonize with the way my other cores work and behave.board_hardware.uart != no_bootloader
present in platformio.ini). If not, it won't be possible to use the bootloader to upload new programs.upload_protocol = arduino
, PlatformIO forces the USB flag and mutes the provided upload port. I think this can be fixed by addingarduino
as a programmer here: https://github.com/platformio/platform-atmelmegaavr/blob/3c2f7d8685791d8662b0286de60e5eeaccb0f68f/builder/main.py#L200 Howeverarduino
does not requireuse_1200bps_touch
orwait_for_upload_port
. Below is the error I'm getting with an umodified main.py file:However, Modifying the main.py file by replacing line 200 - 203 with the following code works:
Note that I've added the -D flag because this is required if you're using the
arduino
protocol. If not, you're getting an erase error.