Platformio

Development environment specific, Arduino, Eclipse, VS2013,Em::Blocks etc
madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Platformio

Post by madias » Sun Sep 11, 2016 9:56 pm

Ok, I got problems: For testing I used only a blank code (begin() and loop()) inserting a simple delay(100); or Serial.begin(9600); quits with:

Code: Select all

src\main.cpp: In function 'void setup()':
src\main.cpp:3:1: error: 'Serial' was not declared in this scope
Serial.begin(9600);
^
*** [.pioenvs\genericSTM32F103CB\src\main.o] Error 1
 [ERROR] Took 1.59 seconds

User avatar
Slammer
Posts: 241
Joined: Tue Mar 01, 2016 10:35 pm
Location: Athens, Greece

Re: Platformio

Post by Slammer » Sun Sep 11, 2016 10:03 pm

I think the idea is to change only the platform.ini file to define different options. Actually the PlatformIO is a console tool, the IDE is just to link atom with console tools.
You define a project by creating the platform.ini, for example it is possible to define an arduino/uno board build by these lines in platformio.ini:

Code: Select all

[env:uno]
platform = atmelavr
framework = arduino
board = uno

It is vary easy to add another target on the same sources by adding these lines on the same platformio.ini:

Code: Select all

[env:stm32]
platform = ststm32
framework = arduino
board = genericSTM32F103C8
Running build, will build both binaries.
Some other options for building can be assigned by adding lines in the form eg.:
build_flags = ...
upload_protocol = ...
upload_speed = ...
(see manual for full list of options)

Another example of platformio.ini is this:

Code: Select all

[env:nucleo_f401re]
platform = ststm32
framework = mbed
board = nucleo_f401re

[env:nucleo_l476rg]
platform = ststm32
framework = mbed
board = nucleo_l476rg

[env:nucleo_f103rb]
platform = ststm32
framework = mbed
board = nucleo_f103rb
I am using this for building the same mbed project for my 3 nucleo boards, in one step! Of course this can be done in different IDEs like Codeblocks or Eclipse, or even with makefiles without PlatformIO, but requires much more work and knowledge.

It would be very easy to support bootloader by adding something like 'upload_protocol = dfu'

@madias, add #include<Arduino.h> in the beginning of your source file.

ubis
Posts: 8
Joined: Tue Jun 07, 2016 12:16 pm

Re: Platformio

Post by ubis » Mon Sep 12, 2016 5:41 am

madias wrote:Ok, I read only in this thread:
Uploading is only possible at 0x08000000, so it will delete the bootloader (boards with bootloader starts at 0x08005000)
Uploading methods are:
dfu
serial
but not ST-Link (we use mostly ST-Link2.0 and not the new version ST-Link2.1 (as on nucleo boards))?

Boards:
Ok, you can use the generic ones, but the board we use mostly is the "maple mini" - this board is sadly missing (we use the maple mini as reference board for nearly everything - if it wont run on the maple mini, I will not run elsewhere). I tried to manually inserting a maple_mini.json into C:\Users\madias\.platformio\platforms\ststm32\boards but it won't shown up.

C:\Users\madias\.platformio\packages\framework-arduinoststm32\STM32F1\variants
Is this folder considered by platformIO?
Uploading is at 0x08000000 when you don't use upload_protocol option in platformio.ini or using it with serial. If it's dfu, address is changed(some boards 0x8002000, others - 0x8005000. As for ST-Link, I will add it, and all boards from stm32duino will be added. Just a little bit more patience ;)

User avatar
Kenjutsu
Posts: 127
Joined: Fri May 29, 2015 8:26 am

Re: Platformio

Post by Kenjutsu » Mon Sep 12, 2016 9:50 am

I followed your steps below, but when I try to compile for the BluePill, I get:

Code: Select all

[Mon Sep 12 11:47:16 2016] Processing bluepill_f103c8 (platform: ststm32, board: bluepill_f103c8, framework: mbed)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
Collected 7 compatible libraries
Looking for dependencies...
Project does not have dependencies
Compiling .pioenvs/bluepill_f103c8/src/main.o

src/main.cpp:16:21: fatal error: Arduino.h: No such file or directory
#include <Arduino.h>
^
compilation terminated.
*** [.pioenvs/bluepill_f103c8/src/main.o] Error 1
========================== [ERROR] Took 1.66 seconds ==========================
It also does not work for #include "Arduino.h"

It does work for pro16MHzatmega168
ubis wrote:Now PlatformIO supports STM32duino.
Currently, generic f103r* / f103c* and maple v3 boards are supported. More will be added soon.
Flashing is either serial or dfu(with stm32duino bootloader).

What you need to do is:

1) Install PlatformIO IDE http://platformio.org/platformio-ide
2) Launch terminal in PlatformIO IDE and write:

Code: Select all

platformio platform install https://github.com/platformio/platform-ststm32.git
3) Create a new project, choose board from generic category.

Post here if something doesn't work.
OSX: 10.12.5
Arduino IDE: 1.6.12
Blue pill STM32F103C8T6 Dev Board
Maple Mini Clones

ubis
Posts: 8
Joined: Tue Jun 07, 2016 12:16 pm

Re: Platformio

Post by ubis » Mon Sep 12, 2016 12:18 pm

Kenjutsu wrote:I followed your steps below, but when I try to compile for the BluePill, I get:

Code: Select all

[Mon Sep 12 11:47:16 2016] Processing bluepill_f103c8 (platform: ststm32, board: bluepill_f103c8, framework: mbed)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
Collected 7 compatible libraries
Looking for dependencies...
Project does not have dependencies
Compiling .pioenvs/bluepill_f103c8/src/main.o

src/main.cpp:16:21: fatal error: Arduino.h: No such file or directory
#include <Arduino.h>
^
compilation terminated.
*** [.pioenvs/bluepill_f103c8/src/main.o] Error 1
========================== [ERROR] Took 1.66 seconds ==========================
It also does not work for #include "Arduino.h"

It does work for pro16MHzatmega168
ubis wrote:Now PlatformIO supports STM32duino.
Currently, generic f103r* / f103c* and maple v3 boards are supported. More will be added soon.
Flashing is either serial or dfu(with stm32duino bootloader).

What you need to do is:

1) Install PlatformIO IDE http://platformio.org/platformio-ide
2) Launch terminal in PlatformIO IDE and write:

Code: Select all

platformio platform install https://github.com/platformio/platform-ststm32.git
3) Create a new project, choose board from generic category.

Post here if something doesn't work.
bluepill_f103c8 board doesn't support arduino framework yet. We are already working with it. In the meantime, you could try to use generic boards, genericSTM32F103C8, since both mcu's are equal.

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Platformio

Post by madias » Mon Sep 12, 2016 2:04 pm

ubis wrote:
Don't forget to add upload_procotol = serial or dfu in platformio.ini to enable automatic flashing ;)
Ok, I'm on OSX at the moment and compiling runs ok (the post before I forgot the #include "Arduino.h" ... sorry, but this is everything new to me).

But in platformio.ini

Neither

Code: Select all

upload_procotol = dfu
or

Code: Select all

upload_procotol = serial
works.
Error message (both):

Code: Select all

Warning! Ignore unknown `upload_procotol` option from `[env:]` section
Full example:

Code: Select all

[env:genericSTM32F103CB]
platform = ststm32
framework = arduino
board = genericSTM32F103CB
upload_procotol = serial
So what is the correct syntax using "upload_procotol"?

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Platformio

Post by madias » Mon Sep 12, 2016 2:27 pm

Ok, found the right syntax ("UPLOAD_PROTOCOL" - why upper case!?!??!) in "arduino.py" in /Users/madias/.platformio/platforms/ststm32/builder/frameworks
So I tried for my maple mini

Code: Select all

[env:genericSTM32F103CB]
platform = ststm32
framework = arduino
board = genericSTM32F103CB
upload_port = /dev/cu.usbmodem411
UPLOAD_PROTOCOL =  dfu
dfu upload was done (only via perpetual bootloader mode), but code (just print out some values via serial) didn't work and the /dev/cu.usbmodem411 disappeared - so the might be a problem with USB-serial? A simple blink sketch (instead of "33" we must take PB1) works.

ubis
Posts: 8
Joined: Tue Jun 07, 2016 12:16 pm

Re: Platformio

Post by ubis » Mon Sep 12, 2016 3:26 pm

madias wrote:Ok, found the right syntax ("UPLOAD_PROTOCOL" - why upper case!?!??!) in "arduino.py" in /Users/madias/.platformio/platforms/ststm32/builder/frameworks
So I tried for my maple mini

Code: Select all

[env:genericSTM32F103CB]
platform = ststm32
framework = arduino
board = genericSTM32F103CB
upload_port = /dev/cu.usbmodem411
UPLOAD_PROTOCOL =  dfu
dfu upload was done (only via perpetual bootloader mode), but code (just print out some values via serial) didn't work and the /dev/cu.usbmodem411 disappeared - so the might be a problem with USB-serial? A simple blink sketch (instead of "33" we must take PB1) works.
It shouldn't be upper case, this might be OS-related bug, I will notify PlatformIO devs about this.
And, it should automatically find upload port, there is no need to specify it in platformio.ini.
We might use different approach to handle boards from stm32duino in PlatformIO, so that all of boards and upload modes will work.

Thanks for testing, I don't have any Maple boards, so I can't test it. There is a huge possibility that I missed some of flags, I will recheck everything.

User avatar
Slammer
Posts: 241
Joined: Tue Mar 01, 2016 10:35 pm
Location: Athens, Greece

Re: Platformio

Post by Slammer » Mon Sep 12, 2016 8:54 pm

ubis, I am sure that some glitches will be fixed. Overall the first commit of stm32duino is very promising. I think that it is more useful for everyone to make a fork of stm32 platform https://github.com/platformio/platform-ststm32 (every platform is on separate repository) and to submit the patches for various boards directly to platformIO developers.

User avatar
Kenjutsu
Posts: 127
Joined: Fri May 29, 2015 8:26 am

Re: Platformio

Post by Kenjutsu » Wed Sep 28, 2016 11:41 am

I got it working under OSX using a BluePill board with the following platformio.ini setting:

[env:genericSTM32F103CB]
platform = ststm32
framework = arduino
board = genericSTM32F103CB
UPLOAD_PROTOCOL = serial

I can also confirm that UPLOAD_PROTOCOL must be all upper case. Also, I had to change the serial_upload file to:
$(dirname $0)/stm32flash/stm32flash -g 0x8000000 -b 57600 -w "$4" "$1"

The baud rate of 230400 simply did not want to work, and the extra /dev/ infront of "$1" cause a port name of "/dev//dev/"
OSX: 10.12.5
Arduino IDE: 1.6.12
Blue pill STM32F103C8T6 Dev Board
Maple Mini Clones

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest