PlatformIO Community

Help getting Codrone to work with PlatformIO

It looks as if CoDrone is using a custom Arduino core. See package that’s downloaded as part of the Arduino board installation: http://www.robolink.com/wp-content/uploads/2016/07/RokitSmartInventor_1.0.3.zip

1 Like

Indeed, as @manuelbl and @pfeerick noted, a different Arduino core seems to be used, right? You also installed this Arduino core and selected the “SmartInventor” board for compilation?

Anyway, try the following:

  • Download the RokitSmartInventor ZIP file for above and extract it
  • Copy the “cores\atmega32” folder as “Rokit” into C:\Users\<user>\.platformio\packages\framework-arduinoavr\cores
  • copy all folders from “variants” into C:\Users\<user>\.platformio\packages\framework-arduinoavr\variants
  • use the following platformio.ini
[env:ATmega32]
board = ATmega32
platform = atmelavr
board_build.core = Rokit
board_build.variant = SmartInventor
framework = arduino
lib_deps =
  CoDrone
  • compile and observe
DATA:    [=====     ]  47.0% (used 963 bytes from 2048 bytes)
PROGRAM: [==        ]  24.4% (used 7868 bytes from 32256 bytes)

With that the new Arduino core is successfully hacked in PlatformIO’s framework-arduinoavr package, and we can also see that the compiled binary size has increased, though it’s still not at the level of the Arduino IDE. But now we are at least using the correct core and variant, which might help…

Edit: I also notice that SmartInventor-mega32_v2.build.f_cpu=7372800L line in the boards.txt, so if you are using that variant, you need to additionally add

board_build.f_cpu = 7372800L
1 Like

Hello, thank you very much for helping me get this working. I really appreciate it.

Here is my code:

//#include <Arduino.h>
#include <CoDrone.h>
//#include <EEPROM.h>

void setup() {

  CoDrone.begin(115200);
  CoDrone.pair(Nearest);  
  CoDrone.takeoff(); //goes up and hovers for 3 seconds
  CoDrone.hover(10); //hovers for an additional 2 seconds
  CoDrone.land(); //lands the CoDrone
}

void loop()
 {
 byte bt8 = digitalRead(18);
 byte bt4 = digitalRead( 14);
 byte bt1 = digitalRead(11);

 if(bt1 && bt4 &&!bt8)
  {
    CoDrone.emergencyStop();
  }
 }

Do I need to include the “Arduino.h”. I don’t think so.

Here is my compilation output:

Processing ATmega32 (platform: atmelavr; framework: arduino; board: ATmega32)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/ATmega32.html
PLATFORM: Atmel AVR 1.15.0 > ATmega32
HARDWARE: ATMEGA32 16MHz, 2KB RAM, 31.50KB Flash
PACKAGES: toolchain-atmelavr 1.50400.190710 (5.4.0), framework-arduinoavr 4.1.1
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <CoDrone> 2.1.1
Compiling .pio\build\ATmega32\src\main.cpp.o
Compiling .pio\build\ATmega32\lib871\CoDrone_ID909\CoDrone.cpp.o
Compiling .pio\build\ATmega32\lib871\CoDrone_ID909\CoDrone_led.cpp.o
Compiling .pio\build\ATmega32\lib871\CoDrone_ID909\CoDrone_request.cpp.o
In file included from src\main.cpp:2:0:
C:\Users\DDS\.platformio\lib\CoDrone_ID909/CoDrone.h:9:21: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://platformio.org/lib/search?query=header:Arduino.h
*
*****************************************************************

compilation terminated.
*** [.pio\build\ATmega32\src\main.cpp.o] Error 1
In file included from C:\Users\DDS\.platformio\lib\CoDrone_ID909\CoDrone.cpp:7:0:
C:\Users\DDS\.platformio\lib\CoDrone_ID909\CoDrone.h:9:21: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://platformio.org/lib/search?query=header:Arduino.h
*
*****************************************************************

compilation terminated.
*** [.pio\build\ATmega32\lib871\CoDrone_ID909\CoDrone.cpp.o] Error 1
In file included from C:\Users\DDS\.platformio\lib\CoDrone_ID909\CoDrone_request.cpp:1:0:
C:\Users\DDS\.platformio\lib\CoDrone_ID909\CoDrone.h:9:21: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://platformio.org/lib/search?query=header:Arduino.h
*
*****************************************************************

compilation terminated.
*** [.pio\build\ATmega32\lib871\CoDrone_ID909\CoDrone_request.cpp.o] Error 1
In file included from C:\Users\DDS\.platformio\lib\CoDrone_ID909\CoDrone_led.cpp:1:0:
C:\Users\DDS\.platformio\lib\CoDrone_ID909\CoDrone.h:9:21: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://platformio.org/lib/search?query=header:Arduino.h
*
*****************************************************************

compilation terminated.
*** [.pio\build\ATmega32\lib871\CoDrone_ID909\CoDrone_led.cpp.o] Error 1
========================================================================= [ERROR] Took 1.81 seconds =========================================================================
The terminal process terminated with exit code: 1

In directory I have:

C:\Users\DDS\.platformio\packages\framework-arduinoavr\cores\Rokit
atmega16
atmega32
atmega128
In directory I have:
C:\Users\DDS\.platformio\packages\framework-arduinoavr\variants
SmartInventor
Ardu-X100
Ardu-X200

Hopefully this can help use find what we are missing.

How do I “add” board_build.f_cpu _ 7372800L line?

Thank you very much.
Joe

Here is my platformio.ini file:

[env:ATmega32]
board = ATmega32
platform = atmelavr
board_build.core = Rokit
board_build.variant = SmartInventor
framework = arduino
lib_deps =
   CoDrone

Literally just add

board_build.f_cpu = 7372800L

to your platformio.ini … just like the core and variant parameters.

1 Like

Yes… as soon as you use setup() and loop() (among other things) you need to #include <Arduino.h> I’m not sure why it’s not being found when CoDrone.h etc. try to include it as well though.

No, your Arduino core is not installed properly, you must not have the three atmegaX folders there, but the contents of atmega32 must be inside the cores\Rokit folder, as I have written above. It can’t find the Arduino.h (and the entire core) this way.

1 Like

Hello, thanks to everyone helping me get this working.

How does this look?

[env:ATmega32]
board = ATmega32
platform = atmelavr
board_build.core = Rokit
board_build.variant = SmartInventor
framework = arduino
lib_deps =
   CoDrone
board_build.f_cpu = 7372800L

Will give it a try.

Joe

Processing ATmega32 (framework: arduino; board: ATmega32; platform: atmelavr)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/ATmega32.html
PLATFORM: Atmel AVR 1.15.0 > ATmega32
HARDWARE: ATMEGA32 16MHz, 2KB RAM, 31.50KB Flash
PACKAGES: toolchain-atmelavr 1.50400.190710 (5.4.0), framework-arduinoavr 4.1.1
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Looking for board_build.f_cpu  library in registry
Warning! Library `{'requirements': None, 'name': 'board_build.f_cpu '}` has not been found in PlatformIO Registry.
You can ignore this message, if `{'requirements': None, 'name': 'board_build.f_cpu '}` is a built-in library (included in framework, SDK). E.g., SPI, Wire, etc.
Found 1 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <CoDrone> 2.1.1
Compiling .pio\build\ATmega32\src\main.cpp.o
Compiling .pio\build\ATmega32\lib871\CoDrone_ID909\CoDrone.cpp.o
Compiling .pio\build\ATmega32\lib871\CoDrone_ID909\CoDrone_led.cpp.o
Compiling .pio\build\ATmega32\lib871\CoDrone_ID909\CoDrone_request.cpp.o
In file included from C:\Users\DDS\.platformio\lib\CoDrone_ID909\CoDrone.cpp:7:0:
C:\Users\DDS\.platformio\lib\CoDrone_ID909\CoDrone.h:9:21: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://platformio.org/lib/search?query=header:Arduino.h
*
*****************************************************************

compilation terminated.
src\main.cpp:1:21: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://platformio.org/lib/search?query=header:Arduino.h
*
*****************************************************************

compilation terminated.
*** [.pio\build\ATmega32\src\main.cpp.o] Error 1
In file included from C:\Users\DDS\.platformio\lib\CoDrone_ID909\CoDrone_led.cpp:1:0:
C:\Users\DDS\.platformio\lib\CoDrone_ID909\CoDrone.h:9:21: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://platformio.org/lib/search?query=header:Arduino.h
*
*****************************************************************

compilation terminated.
*** [.pio\build\ATmega32\lib871\CoDrone_ID909\CoDrone_led.cpp.o] Error 1
*** [.pio\build\ATmega32\lib871\CoDrone_ID909\CoDrone.cpp.o] Error 1
In file included from C:\Users\DDS\.platformio\lib\CoDrone_ID909\CoDrone_request.cpp:1:0:
C:\Users\DDS\.platformio\lib\CoDrone_ID909\CoDrone.h:9:21: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://platformio.org/lib/search?query=header:Arduino.h
*
*****************************************************************

compilation terminated.
*** [.pio\build\ATmega32\lib871\CoDrone_ID909\CoDrone_request.cpp.o] Error 1
========================================================================= [ERROR] Took 1.74 seconds =========================================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

Hello, I’ve made the suggested changes and unable to get a good path to the header files. Any ideas?
I’ll keep trying.
Thank you very much.

Not sure how to update include path but will work on it. Thank you

I updated the ini file to be:

[env:ATmega32]
board = ATmega32
platform = atmelavr
board_build.core = Rokit
board_build.variant = SmartInventor
board_build.f_cpu = 7372800L
framework = arduino
lib_deps =
   CoDrone

Still wrong layout. The contents of the atmega32 folder has to be inside cores\Rokit..

It works!!!

Thank you everyone!

Thank you for not giving up on me and letting me squander in my mess.

Thank for the terrific technical support.

Joe

1 Like