platformio / platform-atmelavr

Atmel AVR: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelavr
Apache License 2.0
139 stars 105 forks source link

Support Move38's Blinks #294

Open TiiFuchs opened 1 year ago

TiiFuchs commented 1 year ago

I'd love to use platformio to develop applications for the blinks.

There is a board manager url for Arduino IDE: https://boardsmanager.com/package_move38.com-blinks_index.json

More information: https://move38.com/pages/game-makers

maxgerhardt commented 1 year ago

Which of the 4 boards referenced in the boards.txt do you have for testing and what programmer do you use? My understanding is that this needs an ISP programmer.

maxgerhardt commented 1 year ago

I've started a minimal project at https://github.com/maxgerhardt/pio-mov38-test that couples with repo that has the necessary platform-atmelavr modifications, it builds the firmware for a "Move38 -> Blink" board exactly like the Arduino IDE.

grafik

Uploading options not yet implemented, other boards not yet implemented.

TiiFuchs commented 1 year ago

I have a bunch of "Blinks" with a USBtinyISP programmer to test.

maxgerhardt commented 1 year ago

I've updated the test project above, can you check if it builds and uploads fine for you?

TiiFuchs commented 1 year ago

It uploads, but it doesn't work correctly afterwars. It just does nothing.

Processing move38_blink (platform: https://github.com/maxgerhardt/platform-atmelavr.git; board: move38_blink; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/move38_blink.html
PLATFORM: Atmel AVR (4.0.0+sha.fd5a81c) > Blink
HARDWARE: ATMEGA168PB 8MHz, 1KB RAM, 5.75KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES: 
 - framework-arduino-avr-blinklib @ 1.0.3+sha.121a398 
 - tool-avrdude @ 1.60300.200527 (6.3.0) 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio/build/move38_blink/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=======   ]  67.9% (used 695 bytes from 1024 bytes)
Flash: [===       ]  33.9% (used 1994 bytes from 5888 bytes)
Configuring upload protocol...
AVAILABLE: custom
CURRENT: upload_protocol = custom
Uploading .pio/build/move38_blink/firmware.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9415 (probably m168pb)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file ".pio/build/move38_blink/firmware.hex"
avrdude: writing flash (7888 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 7888 bytes of flash written
avrdude: verifying flash memory against .pio/build/move38_blink/firmware.hex:
avrdude: load data flash data from input file .pio/build/move38_blink/firmware.hex:
avrdude: input file .pio/build/move38_blink/firmware.hex contains 7888 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 7888 bytes of flash verified

avrdude: safemode: Fuses OK (E:F8, H:DF, L:62)

avrdude done.  Thank you.
maxgerhardt commented 1 year ago

avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed To disable this feature, specify the -D option.

Hm, it may have erased the bootloader file (but no problem, it can be reflashed with the programmer). Let me double check the exact upload flags in the Arduino IDE.

TiiFuchs commented 1 year ago

When I upload an example sketch via Arduino IDE it works again. Not sure if the bootloader gets changed simply by uploading. I assume one needs to burn it via the Tools menu in Arduino IDE...?

maxgerhardt commented 1 year ago

I assume one needs to burn it via the Tools menu in Arduino IDE...?

Nope, as I've just found out, the Arduino IDE flashes both bootloader and sketch in one go.

[..]avrdude -CC:\Users\Max\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -B 5 -v -patmega168pb -cusbtiny -Uflash:w:C:\Users\Max\AppData\Local\Temp\arduino_build_384396/sketch_oct31a.ino.hex:i -Uflash:w:C:\Users\Max\AppData\Local\Arduino15\packages\move38\hardware\avr\1.3.0/bootloaders/BlinkBIOS-168PB.hex:i -u

Let me adjust this do to the same in PlatformIO, right now it just does

avrdude -C C:\Users\Max.platformio\packages/tool-avrdude/avrdude.conf -p atmega168pb -c usbtiny -U flash:w:.pio\build\move38_blink\firmware.hex:i

maxgerhardt commented 1 year ago

Please git pull the reference project again and update the dev atmelavr platform again (easiest: Remove all atmelavr@.. folders in C:\Users\<user>\.platformio\platforms and build project again). Verbose upload output should look like

avrdude -C C:\Users\Max\.platformio\packages/tool-avrdude/avrdude.conf -p atmega168pb -c usbtiny -U flash:w:.pio\build\move38_blink\firmware.hex:i -Uflash:w:"C:\Users\Max\.platformio\packages\framework-arduino-avr-blinklib\bootloaders\BlinkBIOS-168PB.hex":i

now.

TiiFuchs commented 1 year ago

Works like a charm. :)

maxgerhardt commented 1 year ago

I've filed a pull-request per above.

I've updated the project as to remove the local board definitios (in board/), these are now in the platform-atmelavr folder.

Can you update in the same way as before and reupload the project to make sure it still works?

Do you happen to have the other 3 Blink board types (328, MAX, NFC)?

TiiFuchs commented 1 year ago

Yes, I removed the platform folder, cloned the repo from scratch (just to get rid of all the non-versioned files), and it still worked! 👍🏻

I have none of the other Blinks available, no.

According to this forum post, the Blink328 "behaves the same as all other Blinks, except instead of having an Atmega168pb microcontroller (MCU), it has an Atmega328pb." I assume a replacement for the 168pb due to supply shortages.

The BlinksMAX and NFC are not yet available as far as I am informed.

The BlinkNFC might be this one that is coming soon. The BlinkMAX I have no idea. Sounds like a version with more flash storage for more complex games, but I'm not aware that those are available to purchase yet.

TiiFuchs commented 1 year ago

Oh and thank you a lot! :)