Platformio

Development environment specific, Arduino, Eclipse, VS2013,Em::Blocks etc
pirimmsr
Posts: 1
Joined: Sat Dec 03, 2016 12:03 am

Re: Platformio

Postby pirimmsr » Sat Dec 03, 2016 12:24 am

I got the blink.ino example working on the BluePill board under Win8 with the following platformio.ini settings:

Code: Select all

[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino
upload_port = COM10
upload_protocol = serial


Needed to change the LED from PB1 to PC13 as follows

Code: Select all

#define BOARD_LED PC13

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin PB1 as an output.
  pinMode(BOARD_LED, OUTPUT);
}


Kenjutsu helped me get going with his statement about 57600 baud. I had to change line 11 in C:\Users\{user}\.platformio\packages\tool-stm32duino\serial_upload.bat FROM:

Code: Select all

stm32flash -g 0x8000000 -b 230400 -w %str% %1


TO:

Code: Select all

stm32flash -g 0x8000000 -b 57600 -w %str% %1

michael_l
Posts: 219
Joined: Mon Aug 24, 2015 6:11 pm

Re: Platformio

Postby michael_l » Tue Dec 06, 2016 1:17 pm

If you want to use SPI, you'll have to add

Code: Select all

lib_deps=SPI

for platformio to find SPI libs.

Code: Select all

[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino
[color=#BF0000]lib_deps = SPI[/color]

[platformio]
src_dir=.


michael_l
Posts: 219
Joined: Mon Aug 24, 2015 6:11 pm

Re: Platformio

Postby michael_l » Tue Mar 28, 2017 5:01 pm

Has anybody got UPLOAD_MODE=dfu working with platformio so that the actual code and USB works ?

I can build and upload (dfu) with platformio but after flashing there's no COM port.

Compiling with Arduino IDE is quite time-consuming especially with old laptops so it would be so great to get platformio working.

Any hints where to start looking ?

User avatar
martinayotte
Posts: 1150
Joined: Mon Apr 27, 2015 1:45 pm

Re: Platformio

Postby martinayotte » Tue Mar 28, 2017 5:26 pm

but after flashing there's no COM port

In your compile flags, do you have the "-DSERIAL_USB" defined ?

michael_l
Posts: 219
Joined: Mon Aug 24, 2015 6:11 pm

Re: Platformio (solved)

Postby michael_l » Tue Mar 28, 2017 6:29 pm

martinayotte wrote:
but after flashing there's no COM port

In your compile flags, do you have the "-DSERIAL_USB" defined ?


I'm actually flashing to BluePill but using genericSTM32F103CB because it has 128kB defined in platformio config. Is this a problem ?

according to build log
log.zip
(4.63 KiB) Not downloaded yet
there is -DSERIAL_USB

here's one row from build process:

Code: Select all

arm-none-eabi-g++ -o .pioenvs\genericSTM32F103CB\lib\SdFat\FatLib\FatFilePrint.o -c -fno-rtti -fno-exceptions -g -Os -ff
unction-sections -fdata-sections -Wall -mthumb -nostdlib -mcpu=cortex-m3 --param max-inline-insns-single=500 -march=armv
7-m -DF_CPU=72000000L -DGENERIC_STM32F103C -DPLATFORMIO=30300 -DARDUINO_GENERIC_STM32F103C -DMCU_STM32F103CB -DARDUINO=1
0610 -DBOARD_generic_stm32f103c -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -DDEBUG_LEVEL=DEBUG_NONE -D__STM32F1__ -DARDUIN
O_ARCH_STM32F1 -DVECT_TAB_ADDR=134225920 -DSERIAL_USB -DGENERIC_BOOTLOADER -IC:\Users\michael\.platformio\packages\framewor
k-arduinoststm32\STM32F1\cores\maple -IC:\Users\michael\.platformio\packages\framework-arduinoststm32\STM32F1\system\libmap
le -IC:\Users\michael\.platformio\packages\framework-arduinoststm32\STM32F1\system\libmaple\include -IC:\Users\michael\.platfo
rmio\packages\framework-arduinoststm32\STM32F1\system\libmaple\usb\stm32f1 -IC:\Users\michael\.platformio\packages\framewor
k-arduinoststm32\STM32F1\system\libmaple\usb\usb_lib -IC:\Users\michael\.platformio\packages\framework-arduinoststm32\STM32
F1\variants\generic_stm32f103c -IC:\Users\michael\.platformio\packages\framework-arduinoststm32\STM32F1\libraries\SPI\src -
IC:\Users\michael\.platformio\packages\framework-arduinoststm32\STM32F1\libraries\SdFat\src C:\Users\michael\.platformio\packa
ges\framework-arduinoststm32\STM32F1\libraries\SdFat\src\FatLib\FatFilePrint.cpp



One difference I found is that Arduino build uses -Og and platformio uses -Os flag for optimization


EDIT:

Further studying.. there seems to be more difference in linking phase:

This is from platformio:

Code: Select all

arm-none-eabi-g++ -o .pioenvs\genericSTM32F103CB\firmware.elf -Os -Wl,--gc-sections,--relax -mthumb -mcpu=cortex-m3 -Wl,-T"jtag.ld" .pioenvs\genericSTM32F103CB\src\BPCB.ino.o -LC:\Users\michael\.platformio\platforms\ststm32\ldscripts -LC:\Users\michael\.platformio\packages\framework-arduinoststm32\STM32F1\variants\generic_stm32f103c\ld -L.pioenvs\genericSTM32F103CB -Wl,--start-group .pioenvs\genericSTM32F103CB\libFrameworkArduinoVariant.a .pioenvs\genericSTM32F103CB\libFrameworkArduino.a -lc -lgcc -lm -lstdc++ -lnosys -lc .pioenvs\genericSTM32F103CB\lib\libFreeRTOS821.a .pioenvs\genericSTM32F103CB\lib\libSPI.a .pioenvs\genericSTM32F103CB\lib\libArduinoJson_ID64.a .pioenvs\genericSTM32F103CB\lib\libSdFat.a -Wl,--end-group



This is from Arduino IDE:

Code: Select all

"C:\Users\michael\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -Og -Wl,--gc-sections -mcpu=cortex-m3 "-TC:\Users\michael\Documents\Arduino\hardware\Arduino_STM32\STM32F1\variants\generic_stm32f103c/ld/bootloader_20.ld" "-Wl,-Map,C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp/BPCB.ino.map" "-LC:\Users\michael\Documents\Arduino\hardware\Arduino_STM32\STM32F1\variants\generic_stm32f103c/ld" -o "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp/BPCB.ino.elf" "-LC:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\sketch\BPCB.ino.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\FreeRTOS821\MapleFreeRTOS821.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\FreeRTOS821\utility\croutine.c.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\FreeRTOS821\utility\event_groups.c.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\FreeRTOS821\utility\heap_1.c.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\FreeRTOS821\utility\list.c.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\FreeRTOS821\utility\port.c.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\FreeRTOS821\utility\queue.c.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\FreeRTOS821\utility\tasks.c.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\FreeRTOS821\utility\timers.c.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SPI\SPI.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\MinimumSerial.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\SdFatUtil.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\FatLib\FatFile.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\FatLib\FatFileLFN.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\FatLib\FatFilePrint.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\FatLib\FatFileSFN.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\FatLib\FatVolume.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\FatLib\FmtNumber.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\FatLib\StdioStream.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\FatLib\fstream.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\FatLib\istream.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\FatLib\ostream.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\SdCard\SdSpiCard.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\SdCard\SdSpiCardEX.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\SdCard\SdioCardEX.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\SdCard\SdioTeensy.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\SpiDriver\SdSpiESP8266.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\SpiDriver\SdSpiSAM3X.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\SpiDriver\SdSpiSTM32F1.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\libraries\SdFat\SpiDriver\SdSpiTeensy3.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\core\wirish\start.S.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\core\wirish\start_c.c.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\core\wirish\syscalls.c.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\core\board.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\core\wirish\boards.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp\core\wirish\boards_setup.cpp.o" "C:\Users\michael\AppData\Local\Temp\buildd7c89daa834f4d59c2e0edd41c4c10b1.tmp/core\core.a" -Wl,--end-group


platformio is not linking many files that arduino build does

EDIT2:

Arduino is linking with this parameter

"-TC:\Users\michael\Documents\Arduino\hardware\Arduino_STM32\STM32F1\variants\generic_stm32f103c/ld/bootloader_20.ld"

Platformio does:

-T"jtag.ld"

hmm.. is that correct ?


EDIT3:

Yes, seems that wrong linker script was the problem. I think I solved it:

I added bolded rows to arduino.py

if "stm32f103r" in board.get("build.mcu", ""):
env.Replace(LDSCRIPT_PATH="bootloader.ld")
elif "stm32f103c" in board.get("build.mcu", ""):
env.Replace(LDSCRIPT_PATH="bootloader_20.ld")

elif board.get("upload.boot_version", 0) == 2:
env.Replace(LDSCRIPT_PATH="bootloader_20.ld")


.. and it works again

michael_l
Posts: 219
Joined: Mon Aug 24, 2015 6:11 pm

Re: Platformio

Postby michael_l » Wed Mar 29, 2017 7:15 am

Another issue with platformio build is that it seems to create much larger flash file than Arduino IDE.

EDIT:

Added bolded rows to arduino.py and the size is approximately the same than with Arduino build.

env.Append(
CCFLAGS=[
"--param", "max-inline-insns-single=500",
"-march=armv7-m",
"-fno-exceptions",
"-fno-rtti",
"-fno-threadsafe-statics",

],


Return to “IDE's”

Who is online

Users browsing this forum: No registered users and 1 guest