Arduboy on PlatformIO [Stable Again]


(Boti Kis) #1

I’m totally new to Arduino development but i’ve noticed immediately that ppl prefer to use Atom with platformIO as IDE since it has CLANG support with that code completion and other nice things.

Sadly i was not able to run arduboy projects.
First i don’t know how to link the arduboy libs to it and second i don’t know if it’s enough to set the target to Arduino Leonardo.

Any help with this?


(Ross) #2

Have you tried @noopkat’s loader?

It uses Electron ( http://electron.atom.io/ ), and that is part of the Atom project.


(Boti Kis) #3

That’s just an UI to upload the software to arduboy as far i get it.
I look for a way to code in atom for arduboy.


(Ross) #4

So we have the hexloader, next we can look for a way to build the source into that hex file.

Have a look at this repository for a Makefile that will compile source for the Leonardo Arduino bootloader. https://github.com/sudar/Arduino-Makefile.

Could I ask what OS you use?


(Boti Kis) #5

Ph nice, i’ll take a look in that. I’m on OS X.


(Scott) #6

Something that may help:

The Arduino IDE has the ability to make it easier to use an external editor (such as Atom). Select this by using the Arduino IDE menus:
File > Preferences
In the Settings tab select the Use external editor checkbox and then click on the OK box at the bottom right.

With Use external editor selected, you will still be able to load sketches into the IDE, in the normal way, but the code will be grayed out and you won’t be able to edit it. From the IDE menus you can select:
Sketch > Show Sketch Folder (or press Ctrl+K)
to open the folder containing that sketch’s files.

You can edit these files with the editor of your choice. (With Ubuntu Linux’s Unity interface I can just right click on a file in the sketch’s folder and choose Open With > …)

When you save a file and then switch back to the Arduino IDE, the changes made to the file will automatically be loaded in for compiling and uploading.


(Scott) #7

Apparently, PlatformIO supports Arduino development. See the PlatformIO section of the Arduino from the Command Line document.

I don’t use PlatformIO so I haven’t looked into getting the Arduboy library into it but perhaps this will help.

And yes, selecting Arduino Leonardo as a target should work for the production Arduboy (but not the DevKit) if you can’t add the Arduboy board support to PlatformIO.


(Matthew Hungerford) #8

I use platformIO with the ArduBoy, just using the Leonardo support. Works great. I just copied the Arduboy library into the lib folder. Great IDE.


(Boti Kis) #9

Oh boy i feel so stupid. to copy the libs didn’t got in my mind…
Thanks man, works like a charm! far better than the arduino ide. :v:


(Ivan Kravets @ PlatformIO) #10

You need to install this library from PlatformIO Library Registry:

platformio lib install 192

Also, the developers of Arduboy can submit PR for board with own configuration based on leonardo. https://github.com/platformio/platform-atmelavr/tree/develop/boards


(Ivan Kravets @ PlatformIO) #11

We have added support for Arduboy today. Please read my answer here
http://community.arduboy.com/t/any-arduboy-developers-using-a-more-advanced-ide-than-arduino/1473/5?u=ivankravets


(Scott) #12

Since I don’t use PlatformIO, I don’t want to spend the time testing these, so I won’t create a PR, but they will probably work:


File arduboy.json

{
  "build": {
    "core": "arduino", 
    "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ARDUBOY -DARDUBOY_10", 
    "f_cpu": "16000000L", 
    "hwids": [
      [
        "0x2341", 
        "0x0036"
      ], 
      [
        "0x2341", 
        "0x8036"
      ] 
    ], 
    "mcu": "atmega32u4", 
    "usb_product": "Arduboy", 
    "variant": "leonardo"
  }, 
  "frameworks": [
    "arduino"
  ], 
  "name": "Arduboy", 
  "upload": {
    "disable_flushing": true, 
    "maximum_ram_size": 2560, 
    "maximum_size": 28672, 
    "protocol": "avr109", 
    "require_upload_port": true, 
    "speed": 57600, 
    "use_1200bps_touch": true, 
    "wait_for_upload_port": true
  }, 
  "url": "https://www.arduboy.com/", 
  "vendor": "Arduboy"
}

File arduboy_devkit.json

{
  "build": {
    "core": "arduino", 
    "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_ARDUBOY_DEVKIT -DAB_DEVKIT", 
    "f_cpu": "16000000L", 
    "hwids": [
      [
        "0x2341", 
        "0x0036"
      ], 
      [
        "0x2341", 
        "0x8036"
      ] 
    ], 
    "mcu": "atmega32u4", 
    "usb_product": "Arduboy DevKit", 
    "variant": "leonardo"
  }, 
  "frameworks": [
    "arduino"
  ], 
  "name": "Arduboy DevKit", 
  "upload": {
    "disable_flushing": true, 
    "maximum_ram_size": 2560, 
    "maximum_size": 28672, 
    "protocol": "avr109", 
    "require_upload_port": true, 
    "speed": 57600, 
    "use_1200bps_touch": true, 
    "wait_for_upload_port": true
  }, 
  "url": "https://www.arduboy.com/", 
  "vendor": "Arduboy"
}


(Ivan Kravets @ PlatformIO) #13
  1. Do you use these macros ARDUINO_AVR_ARDUBOY, ARDUBOY_10 and AB_DEVKIT?
  2. Should we have 2 different boards in supported list?
  3. See current configuration for PlatformIO 2.0 https://github.com/platformio/platformio/blob/develop/platformio/boards/misc.json#L743

(Scott) #14

I don’t think anyone is using ARDUINO_AVR_ARDUBOY (or ARDUINO_AVR_ARDUBOY_DEVKIT) for anything yet, but that’s what gets set using the board support file that we use for the Arduino IDE.

ARDUBOY_10 and AB_DEVKIT are used throughout the Arduboy library, and by other people such as Team A.R.G., to conditionally compile for either the production Arduboy or the DevKit. (If a board type other than Arduboy or Arduboy DevKit is selected, such as Arduino Leonardo, the library sets ARDUBOY_10 itself as a default. (See the logic at the top of core.h)

Sketches can also test ARDUBOY_10 and AB_DEVKIT to know whether certain features are available, and behave accordingly. For instance, the production Arduboy has an RGB LED, which can be varied in intensity using PWM, but the DevKit only has a single blue LED, which can only be on or off.

Here’s a typical line from the compile output when you select Arduboy as the board type using the Arduino IDE:


“/opt/arduino-1.6.9/hardware/tools/avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10609 -DARDUINO_AVR_ARDUBOY -DARDUINO_ARCH_AVR -DARDUBOY_10 -DUSB_VID=0x2341 -DUSB_PID=0x8036 ‘-DUSB_MANUFACTURER=“Unknown”’ ‘-DUSB_PRODUCT=“Arduboy”’ “-I/home/sa/.arduino15/packages/arduino/hardware/avr/1.6.11/cores/arduino” “-I/home/sa/.arduino15/packages/arduino/hardware/avr/1.6.11/variants/leonardo” “-I/home/sa/Arduino/libraries/Arduboy/src” “-I/home/sa/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/SPI/src” “-I/home/sa/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/EEPROM/src” “/home/sa/Arduino/libraries/Arduboy/src/core/core.cpp” -o “/dev/null”


And here’s the same line when Arduboy DevKit is selected as the board type:


“/opt/arduino-1.6.9/hardware/tools/avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10609 -DARDUINO_AVR_ARDUBOY_DEVKIT -DARDUINO_ARCH_AVR -DAB_DEVKIT -DUSB_VID=0x2341 -DUSB_PID=0x8036 ‘-DUSB_MANUFACTURER=“Unknown”’ ‘-DUSB_PRODUCT=“Arduboy DevKit”’ “-I/home/sa/.arduino15/packages/arduino/hardware/avr/1.6.11/cores/arduino” “-I/home/sa/.arduino15/packages/arduino/hardware/avr/1.6.11/variants/leonardo” “-I/home/sa/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/EEPROM/src” “-I/home/sa/Arduino/libraries/Arduboy/src” “-I/home/sa/.arduino15/packages/arduino/hardware/avr/1.6.11/libraries/SPI/src” “/home/sa/Arduino/libraries/Arduboy/src/core/core.cpp” -o “/dev/null”


That what we have for the Arduino IDE. You can select Arduboy or Arduboy DevKit.


(Ivan Kravets @ PlatformIO) #15

Thanks a lot! Done:

PlatformIO 2.0

PlatformIO 3.0


(Boti Kis) #16

Hey @ivankravets ,

PlatformIO seems to allow upload too large sketches to the arduboy without any warning which bricks them by doing something with the bootloader.
It happened already to 2 arduboys here and there is no easy way to flash it again.
-> this one and mine.
It would be great to have a security check for that so it won’t happen for others.


(Kevin) #17

CAUTION TO ARDUBOY USERS:

This platform is not directly supported and seems to have an issue with uploading too large files by accident. We will do a tutorial on how to bring your arduboy back to life, but you will require an external programmer!

USE EXTREME CAUTION WITH PLATFORMIO ON ARDUBOY!


(Ivan Kravets @ PlatformIO) #18

PlatformIO doesn’t check the firmware size. Please open an issue for that here https://github.com/platformio/platformio

The problem here is that board doesn’t react on SerialTouch 1200bps (software reset). Here are a few options to restore:

PlatformIO shows the final size of the firmware:

avr-size --mcu=atmega328p -C -d .pioenvs/uno/firmware.elf
AVR Memory Usage
----------------
Device: atmega328p

Program:    1034 bytes (3.2% Full)
(.text + .data + .bootloader)

Data:          9 bytes (0.4% Full)
(.data + .bss + .noinit)

P.S: This is the first case for the 2years :slight_smile: . I agree that need to check the size of firmware. I’ll implement it and release a new version as soon as possible.

Please sorry for the inconveniences.


#19

You can use an Arduino (no NOT an other arduboy) to re-flash your arduboy too, doesn’t have to be a programmer.
I have done this a hundred times with the DEV kit, because I somehow broke the USB connection … on multiple DEV kits.


(Michael Gollnick) #20

@ivankravets Thats fine for me. Looking forward to the update. I still like platformio. It works like charm and I can just program in my own environment without an IDE.