STM32 PlatformIO

Topic split from STM32 Development - #100 thread


The printf_float linker flag has also been added to platformio.ini and now works great to compile and upload dBC_txshield_demo using platformio. To get up and running from scratch on any machine (full tool-chain install), first install platformio then run:

$ git clone https://github.com/TrystanLea/STM32Dev/
$ cd dBC_txshield_demo
$ pio run -t upload
$ pio device monitor

Here is an extract from platformio.ini showing the build flags:

https://github.com/TrystanLea/STM32Dev/blob/master/dBC_txshield_demo/platformio.ini

Without anything connected I get;

$ pio device monitor 
--- Miniterm on /dev/ttyACM0  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
47.95, Irms: 2047.88, Papp: 3579591.25, Preal: 4146.25, PF: 0.001
1: Vrms: 1747.95, Irms: 2047.88, Papp: 3579591.25, Preal: 4146.25, PF: 0.001
2: Vrms: 1747.95, Irms: 2047.88, Papp: 3579591.25, Preal: 4146.25, PF: 0.001
3: Vrms: 1745.41, Irms: 2047.88, Papp: 3574399.50, Preal: 5312.25, PF: 0.001
0: Vrms: 1758.94, Irms: 2047.88, Papp: 3602099.25, Preal: 4159.00, PF: 0.001
1: Vrms: 1758.94, Irms: 2047.88, Papp: 3602099.25, Preal: 4159.00, PF: 0.001
2: Vrms: 1758.94, Irms: 2047.88, Papp: 3602099.25,
emonTxshield Demo 1.0
Patch PA0 through to PB14 for V!!!
3: Vrms: 1771.17, Irms: 2047.88, Papp: 3627147.75, Preal: 4435.75, PF: 0.001
0: Vrms: 1773.84, Irms: 2047.88, Papp: 3632621.00, Preal: 3751.50, PF: 0.001
1: Vrms: 1773.84, Irms: 2047.88, Papp: 3632621.00, Preal: 3751.50, PF: 0.001
2: Vrms: 1773.84, Irms: 2047.88, Papp: 3632621.00, Preal: 3751.50, PF: 0.001

Onwards and upwards! :smiley:

@glyn.hudson - you still need to gnu99 flag as well and even with your new settings there is still an issue on Pi. All the console output in this post is one session, I have chopped it up only for the purpose of adding notes and hopefully making it more digestible.

I last had this running last night (confirmed compile and flash using PIO) and I have not changed anything in the interim. First off, I did not expect it to need to re download the toolchain, what should have been a simple recompile of last nights code took ages.

pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ pio run -t upload          [Mon Mar 26 18:57:32 2018] Processing stm32f303 (platform: ststm32; board: nucleo_f303re; framework: stm32cube)
--------------------------------------------------------------------------------
PlatformManager: Installing ststm32
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
ststm32 @ 4.1.0 has been successfully installed!
The platform 'ststm32' has been successfully installed!
The rest of packages will be installed automatically depending on your build environment.
PackageManager: Installing tool-stm32duino @ ~1.0.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
PackageManager: Installing toolchain-gccarmnoneeabi @ >=1.60301.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
PackageManager: Installing tool-stlink @ ~1.10400.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
PackageManager: Installing tool-openocd @ ~1.1000.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
PackageManager: Installing framework-stm32cube @ ~1.1.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
CorePackageManager: Installing tool-scons @ ~2.20501.4
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
tool-scons @ 2.20501.4 has been successfully installed!
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST Nucleo F303RE
SYSTEM: STM32F303RET6 72MHz 64KB RAM (512KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(light)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
*** [.pioenvs/stm32f303/firmware.elf] /home/pi/redo/txshield_demo_3/emonTxshield/.pioenvs/stm32f303/firmware.elf: Permission denied
IOError: [Errno 13] Permission denied: '/home/pi/redo/txshield_demo_3/emonTxshield/.pioenvs/.sconsign.tmp':
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/Script/Main.py", line 1346:
_exec_main(parser, values)
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/Script/Main.py", line 1309:
_main(parser)
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/Script/Main.py", line 1091:
nodes = _build_targets(fs, options, targets, target_top)
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/Script/Main.py", line 1283:
jobs.run(postfunc = jobs_postfunc)
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/Job.py", line 113:
postfunc()
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/Script/Main.py", line 1280:
SCons.SConsign.write()
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/SConsign.py", line 109:
syncmethod()
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/dblite.py", line 118:
f = self._open(self._tmp_name, "wb", self._mode)
Exception IOError: (13, 'Permission denied', '/home/pi/redo/txshield_demo_3/emonTxshield/.pioenvs/.sconsign.tmp') in <bound method dblite.__del__ of <SCons.dblite.dblite object at 0x75a37b90>> ignored
========================= [ERROR] Took 449.62 seconds =========================

8 minutes is a long time, anyway, it failed to compile and I wasn’t sure why so I just ran it again (just “run” without “upload”) and this time it has given me a better description of the error and what to do about it.

pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ pio run
Please manually remove file `/home/pi/redo/txshield_demo_3/emonTxshield/.pioenvs/structure.hash`
Can not remove temporary directory `/home/pi/redo/txshield_demo_3/emonTxshield/.pioenvs`. Please remove it manually to avoid build issues
[Mon Mar 26 19:05:14 2018] Processing stm32f303-dev (platform: ststm32; board: nucleo_f303re; framework: stm32cube)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST Nucleo F303RE
SYSTEM: STM32F303RET6 72MHz 64KB RAM (512KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(light)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
*** [.pioenvs/stm32f303-dev] /home/pi/redo/txshield_demo_3/emonTxshield/.pioenvs/stm32f303-dev: Permission denied
IOError: [Errno 13] Permission denied: '/home/pi/redo/txshield_demo_3/emonTxshield/.pioenvs/.sconsign.tmp':
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/Script/Main.py", line 1346:
_exec_main(parser, values)
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/Script/Main.py", line 1309:
_main(parser)
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/Script/Main.py", line 1091:
nodes = _build_targets(fs, options, targets, target_top)
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/Script/Main.py", line 1283:
jobs.run(postfunc = jobs_postfunc)
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/Job.py", line 113:
postfunc()
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/Script/Main.py", line 1280:
SCons.SConsign.write()
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/SConsign.py", line 109:
syncmethod()
File "/home/pi/.platformio/packages/tool-scons/script/../engine/SCons/dblite.py", line 118:
f = self._open(self._tmp_name, "wb", self._mode)
Exception IOError: (13, 'Permission denied', '/home/pi/redo/txshield_demo_3/emonTxshield/.pioenvs/.sconsign.tmp') in <bound method dblite.__del__ of <SCons.dblite.dblite object at 0x7599e2d0>> ignored
========================== [ERROR] Took 8.58 seconds ==========================

It seems to have a problem deleting some temp files and it asks me to do it manually, which I do and then run “run” again.

pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ sudo rm -r /home/pi/redo/txshield_demo_3/emonTxshield/.pioenvs
pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ pio run
[Mon Mar 26 19:06:39 2018] Processing stm32f303-dev (platform: ststm32; board: nucleo_f303re; framework: stm32cube)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST Nucleo F303RE
SYSTEM: STM32F303RET6 72MHz 64KB RAM (512KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(light)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs/stm32f303-dev/src/adc.o
Compiling .pioenvs/stm32f303-dev/src/dma.o
Compiling .pioenvs/stm32f303-dev/src/gpio.o
Compiling .pioenvs/stm32f303-dev/src/main.o
Src/adc.c: In function 'ConvCpltEither':
Src/adc.c:641:5: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i=0; i<SEQS_PER_HALF; i++) {
^
Src/adc.c:641:5: note: use option -std=c99 or -std=gnu99 to compile your code
*** [.pioenvs/stm32f303-dev/src/adc.o] Error 1
========================== [ERROR] Took 10.86 seconds ==========================

This time it gets a bit further but I see the same error we were getting a couple of days ago telling us to use the gnu99 flag that dBC has included in the Makefile extension .mak file. So at this point I add build_flags = -std=gnu99 to the end of your platformio.ini and try again.

pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ nano platformio.ini
pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ pio run
[Mon Mar 26 19:07:37 2018] Processing stm32f303-dev (platform: ststm32; board: nucleo_f303re; framework: stm32cube)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST Nucleo F303RE
SYSTEM: STM32F303RET6 72MHz 64KB RAM (512KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(light)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs/stm32f303-dev/src/adc.o
Compiling .pioenvs/stm32f303-dev/src/dma.o
Compiling .pioenvs/stm32f303-dev/src/gpio.o
Compiling .pioenvs/stm32f303-dev/src/main.o
Compiling .pioenvs/stm32f303-dev/src/power.o
Compiling .pioenvs/stm32f303-dev/src/stm32f3xx_hal_msp.o
Compiling .pioenvs/stm32f303-dev/src/stm32f3xx_it.o
Compiling .pioenvs/stm32f303-dev/src/system_stm32f3xx.o
Compiling .pioenvs/stm32f303-dev/src/tim.o
Compiling .pioenvs/stm32f303-dev/src/usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_adc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_adc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_can.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_cec.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_comp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_cortex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_crc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_crc_ex.o
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c: In function 'CRC_Handle_8':
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:485:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
^
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:489:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
^
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c: In function 'CRC_Handle_16':
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:521:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = pBuffer[2*i];
^
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dac.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dac_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dma.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_flash.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_flash_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_gpio.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_hrtim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2c.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2c_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2s.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2s_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_irda.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_iwdg.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_nand.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_nor.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_opamp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_opamp_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pccard.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pcd.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pcd_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pwr.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pwr_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rcc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rcc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rtc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rtc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_sdadc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smartcard.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smartcard_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smbus.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_spi.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_spi_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_sram.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tim_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tsc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_uart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_uart_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_wwdg.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_adc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_comp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_crc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_dac.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_dma.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_exti.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_fmc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_gpio.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_hrtim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_i2c.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_opamp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_pwr.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_rcc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_rtc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_spi.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_tim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_utils.o
Compiling .pioenvs/stm32f303-dev/FrameworkCMSISDevice/gcc/startup_stm32f303xe.o
Compiling .pioenvs/stm32f303-dev/FrameworkCMSISDevice/system_stm32f3xx.o
Archiving .pioenvs/stm32f303-dev/libFrameworkCMSISDevice.a
Indexing .pioenvs/stm32f303-dev/libFrameworkCMSISDevice.a
Archiving .pioenvs/stm32f303-dev/libFrameworkHALDriver.a
Indexing .pioenvs/stm32f303-dev/libFrameworkHALDriver.a
Linking .pioenvs/stm32f303-dev/firmware.elf
Calculating size .pioenvs/stm32f303-dev/firmware.elf
text       data     bss     dec     hex filename
20636      1088    5904   27628    6bec .pioenvs/stm32f303-dev/firmware.elf
Building .pioenvs/stm32f303-dev/firmware.bin
========================= [SUCCESS] Took 41.07 seconds =========================

a couple of warnings but it compiles ok, To confirm my findings I re-edited the platformio.ini by commenting out the “gnu99” line and ran “run” again.

pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ nano platformio.ini
pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ pio run
[Mon Mar 26 19:10:53 2018] Processing stm32f303-dev (platform: ststm32; board: nucleo_f303re; framework: stm32cube)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST Nucleo F303RE
SYSTEM: STM32F303RET6 72MHz 64KB RAM (512KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(light)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs/stm32f303-dev/src/adc.o
Compiling .pioenvs/stm32f303-dev/src/dma.o
Compiling .pioenvs/stm32f303-dev/src/gpio.o
Compiling .pioenvs/stm32f303-dev/src/main.o
Src/adc.c: In function 'ConvCpltEither':
Src/adc.c:641:5: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i=0; i<SEQS_PER_HALF; i++) {
^
Src/adc.c:641:5: note: use option -std=c99 or -std=gnu99 to compile your code
*** [.pioenvs/stm32f303-dev/src/adc.o] Error 1
========================== [ERROR] Took 10.14 seconds ==========================

It failed with the same error again, I tried it again, this time with run and upload (shouldn’t be different I know, but you never know)

pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ pio run -t upload          [Mon Mar 26 19:11:49 2018] Processing stm32f303-dev (platform: ststm32; board: nucleo_f303re; framework: stm32cube)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST Nucleo F303RE
SYSTEM: STM32F303RET6 72MHz 64KB RAM (512KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(light)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs/stm32f303-dev/src/adc.o
Compiling .pioenvs/stm32f303-dev/src/power.o
Compiling .pioenvs/stm32f303-dev/src/stm32f3xx_hal_msp.o
Compiling .pioenvs/stm32f303-dev/src/stm32f3xx_it.o
Src/adc.c: In function 'ConvCpltEither':
Src/adc.c:641:5: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i=0; i<SEQS_PER_HALF; i++) {
^
Src/adc.c:641:5: note: use option -std=c99 or -std=gnu99 to compile your code
*** [.pioenvs/stm32f303-dev/src/adc.o] Error 1
Src/power.c: In function 'process_power_data':
Src/power.c:79:3: error: 'for' loop initial declarations are only allowed in C99 mode
for (int chan=0; chan<MAX_CHANNELS; chan++)
^
Src/power.c:79:3: note: use option -std=c99 or -std=gnu99 to compile your code
*** [.pioenvs/stm32f303-dev/src/power.o] Error 1
========================== [ERROR] Took 11.76 seconds ==========================

No change it failed again so I uncommented the gnu99 line and tried once more.

pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ nano platformio.ini
pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ pio run -t upload
[Mon Mar 26 19:12:28 2018] Processing stm32f303-dev (platform: ststm32; board: nucleo_f303re; framework: stm32cube)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST Nucleo F303RE
SYSTEM: STM32F303RET6 72MHz 64KB RAM (512KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(light)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs/stm32f303-dev/src/adc.o
Compiling .pioenvs/stm32f303-dev/src/dma.o
Compiling .pioenvs/stm32f303-dev/src/gpio.o
Compiling .pioenvs/stm32f303-dev/src/main.o
Compiling .pioenvs/stm32f303-dev/src/power.o
Compiling .pioenvs/stm32f303-dev/src/stm32f3xx_hal_msp.o
Compiling .pioenvs/stm32f303-dev/src/stm32f3xx_it.o
Compiling .pioenvs/stm32f303-dev/src/system_stm32f3xx.o
Compiling .pioenvs/stm32f303-dev/src/tim.o
Compiling .pioenvs/stm32f303-dev/src/usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_adc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_adc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_can.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_cec.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_comp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_cortex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_crc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_crc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dac.o
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c: In function 'CRC_Handle_8':
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:485:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
^
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:489:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
^
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c: In function 'CRC_Handle_16':
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:521:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = pBuffer[2*i];
^
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dac_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dma.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_flash.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_flash_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_gpio.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_hrtim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2c.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2c_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2s.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2s_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_irda.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_iwdg.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_nand.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_nor.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_opamp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_opamp_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pccard.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pcd.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pcd_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pwr.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pwr_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rcc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rcc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rtc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rtc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_sdadc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smartcard.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smartcard_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smbus.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_spi.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_spi_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_sram.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tim_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tsc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_uart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_uart_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_wwdg.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_adc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_comp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_crc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_dac.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_dma.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_exti.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_fmc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_gpio.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_hrtim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_i2c.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_opamp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_pwr.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_rcc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_rtc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_spi.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_tim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_utils.o
Compiling .pioenvs/stm32f303-dev/FrameworkCMSISDevice/gcc/startup_stm32f303xe.o
Compiling .pioenvs/stm32f303-dev/FrameworkCMSISDevice/system_stm32f3xx.o
Archiving .pioenvs/stm32f303-dev/libFrameworkCMSISDevice.a
Indexing .pioenvs/stm32f303-dev/libFrameworkCMSISDevice.a
Archiving .pioenvs/stm32f303-dev/libFrameworkHALDriver.a
Indexing .pioenvs/stm32f303-dev/libFrameworkHALDriver.a
Linking .pioenvs/stm32f303-dev/firmware.elf
Checking program size
text       data     bss     dec     hex filename
20636      1088    5904   27628    6bec .pioenvs/stm32f303-dev/firmware.elf
Building .pioenvs/stm32f303-dev/firmware.bin
Configuring upload protocol...
AVAILABLE: blackmagic, jlink, mbed, mbed, stlink
CURRENT: upload_protocol = mbed
Looking for upload disk...
Auto-detected: /media/pi/NODE_F303RE
Uploading .pioenvs/stm32f303-dev/firmware.bin
Firmware has been successfully uploaded.
(Some boards may require manual hard reset)
========================= [SUCCESS] Took 42.20 seconds =========================

a couple of warnings but it compiled ok, as the “upload” command was used this time it had installed to my stm32 but when I checked the serial output it is without data

pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ pio device monitor
--- Miniterm on /dev/ttyACM0  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
2: Vrms: , Irms: , Papp: , Preal: , PF:
3: Vrms: , Irms: , Papp: , Preal: , PF:
0: Vrms: , Irms: , Papp: , Preal: , PF:
1: Vrms: , Irms: , Papp: , Preal: , PF:
3: Vrms: , Irms: , Papp: , Preal: , PF:
0: Vrms: , Irms: , Papp: , Preal: , PF:
1: Vrms: , Irms: , Papp: , Preal: , PF:
2: Vrms: , Irms: , Papp: , Preal: , PF:
0: Vrms: , Irms: , Papp: , Preal: , PF:
1: Vrms: , Irms: , Papp: , Preal: , PF:
2: Vrms: , Irms: , Papp: , Preal: , PF:
3: Vrms: , Irms: , Papp: , Preal: , PF:
--- exit ---

my current platformio.ini file is

pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ cat platformio.ini
[platformio]
src_dir = Src
include_dir = Inc
env_default = stm32f303-dev

[common]
# Specify flags/variables commmon to all enviroments
# PlatfomIO common variables docs: http://docs.platformio.org/en/latest/projectconf/dynamic_variables.html
# PlatfomIO build_flags docs: http://docs.platformio.org/en/latest/projectconf/section_env_build.html
debug_flags = -D DEBUG=1
build_flags = -Wl,-u_printf_float
monitor_baud = 115200

# Dev build enviroment (default)
# $ pio run -t upload
[env:stm32f303-dev]
platform = ststm32
framework = stm32cube
board = nucleo_f303re
monitor_baud = ${common.monitor_baud}

build_flags = -std=gnu99

This isn’t a emonSD, it’s a Pi3 with the March 18 Raspbian Stretch and only the minicom and Arm toolchain packages installed plus PIO via the “quick install” method.

I might try v5 later tonight but I expect the same results, if you have any idea’s or further flags I should try, let me know, but it is unlikely I will re install PIO when I re-flash this sdcard to test installing the minimal arm toolchain plus minicom installation method from a fresh image.

Mmm strange, I’m unable to replicate. The code compiles fine for me without the std=gnu99 flag.

I was dev version of PlatformIO currently version 3.5.3a7, to test I reverted to the non dev version of platformio version 3.5.2 and still unable to replicate.

However I’ve added the build flag to platformio .ini (currently in PR to trystans repo). I didn’t seem to make any difference for me.

Build flag variables need to have -D in front of them e.g.

http://docs.platformio.org/en/latest/projectconf/section_env_build.html#id1

Please confirm if this fixes the issue for you. What version platformIO are your running $ pio --version?

For comparison here is my compilation output:

[Tue Mar 27 00:43:28 2018] Processing stm32f303-dev (platform: ststm32; board: nucleo_f303re; framework: stm32cube)
------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST Nucleo F303RE
SYSTEM: STM32F303RET6 72MHz 64KB RAM (512KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(light)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs/stm32f303-dev/src/adc.o
Compiling .pioenvs/stm32f303-dev/src/dma.o
Compiling .pioenvs/stm32f303-dev/src/gpio.o
Compiling .pioenvs/stm32f303-dev/src/main.o
Compiling .pioenvs/stm32f303-dev/src/power.o
Compiling .pioenvs/stm32f303-dev/src/stm32f3xx_hal_msp.o
Compiling .pioenvs/stm32f303-dev/src/stm32f3xx_it.o
Compiling .pioenvs/stm32f303-dev/src/system_stm32f3xx.o
Compiling .pioenvs/stm32f303-dev/src/tim.o
Compiling .pioenvs/stm32f303-dev/src/usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_adc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_adc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_can.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_cec.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_comp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_cortex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_crc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_crc_ex.o
/home/fig/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c: In function 'CRC_Handle_8':
/home/fig/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:485:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
^
/home/fig/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:489:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
^
/home/fig/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c: In function 'CRC_Handle_16':
/home/fig/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:521:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = pBuffer[2*i];
^
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dac.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dac_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dma.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_flash.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_flash_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_gpio.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_hrtim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2c.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2c_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2s.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2s_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_irda.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_iwdg.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_nand.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_nor.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_opamp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_opamp_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pccard.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pcd.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pcd_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pwr.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pwr_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rcc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rcc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rtc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rtc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_sdadc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smartcard.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smartcard_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smbus.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_spi.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_spi_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_sram.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tim_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tsc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_uart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_uart_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_wwdg.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_adc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_comp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_crc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_dac.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_dma.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_exti.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_fmc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_gpio.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_hrtim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_i2c.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_opamp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_pwr.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_rcc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_rtc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_spi.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_tim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_utils.o
Compiling .pioenvs/stm32f303-dev/FrameworkCMSISDevice/gcc/startup_stm32f303xe.o
Compiling .pioenvs/stm32f303-dev/FrameworkCMSISDevice/system_stm32f3xx.o
Archiving .pioenvs/stm32f303-dev/libFrameworkCMSISDevice.a
Indexing .pioenvs/stm32f303-dev/libFrameworkCMSISDevice.a
Archiving .pioenvs/stm32f303-dev/libFrameworkHALDriver.a
Indexing .pioenvs/stm32f303-dev/libFrameworkHALDriver.a
Linking .pioenvs/stm32f303-dev/firmware.elf
Calculating size .pioenvs/stm32f303-dev/firmware.elf
text       data     bss     dec     hex filename
27536      1460    5940   34936    8878 .pioenvs/stm32f303-dev/firmware.elf
Building .pioenvs/stm32f303-dev/firmware.bin
========================================== [SUCCESS] Took 6.07 seconds ==========================================

=================================================== [SUMMARY] ===================================================
Environment stm32f303-dev       [SUCCESS]
Environment stm32f303           [SKIP]
========================================== [SUCCESS] Took 6.07 seconds ==========================================

I expected that would be the case which is why I included all the info.

pi@raspberrypi:~/redo/txshield_demo_3/emonTxshield $ pio --version
PlatformIO, version 3.5.2

Ok, seems to work without it but I will try it with the -D tomorrow sometime.

indeed I shall :slight_smile:

For your information workIng OK on Windows 10.

I installed PlatformIO originally to be able to upload firmware to emonESP.

First time I tried STM32 using PIO it failed.
I reverted to emonESP to see if that still worked and if flagged the need to update Platform.
I did that, went back to STM32 and this time it worked perfectly including very similar results in the terminal.

Regards

Ian

1 Like

So starting with a fresh copy of dBC’s v5 tar (coned from GitHub - stm32oem/stm32tests) I just added your full platformio.ini content from your github link (STM32Dev/platformio.ini at master · glynhudson/STM32Dev · GitHub) as a new file in the root of the project folder and it failed to compile with the same “gnu99” errors.

pi@raspberrypi:~/v5/stm32tests/emonTxshield $ pio run -t upload
[Tue Mar 27 10:43:31 2018] Processing stm32f303-dev (platform: ststm32; board: nucleo_f303re; framework: stm32cube)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST Nucleo F303RE
SYSTEM: STM32F303RET6 72MHz 64KB RAM (512KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(light)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs/stm32f303-dev/src/adc.o
Compiling .pioenvs/stm32f303-dev/src/dma.o
Compiling .pioenvs/stm32f303-dev/src/gpio.o
Compiling .pioenvs/stm32f303-dev/src/main.o
Src/adc.c: In function 'ConvCpltEither':
Src/adc.c:643:5: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i=0; i<SEQS_PER_HALF; i++) {
^
Src/adc.c:643:5: note: use option -std=c99 or -std=gnu99 to compile your code
*** [.pioenvs/stm32f303-dev/src/adc.o] Error 1
========================== [ERROR] Took 8.29 seconds ==========================

================================== [SUMMARY] ==================================
Environment stm32f303-dev       [ERROR]
Environment stm32f303           [SKIP]
========================== [ERROR] Took 8.30 seconds ==========================

looking at the content of that ini file, it getting kinda busy in there an I’m not sure what is really necessary and whats not.

I can see you are putting the build flags in a variable in the [common] section and then using ${common.build_flags} in both the dev and non-dev environments. I decided to try what worked for me previously and just stuffed “build_flags = -std=gnu99” in there, since there was now 2 env sections I put it at the end of the [common] section like so

[platformio]
src_dir = Src
include_dir = Inc
env_default = stm32f303-dev

[common]
# Specify flags/variables commmon to all enviroments
# PlatfomIO common variables docs: http://docs.platformio.org/en/latest/project$
# PlatfomIO build_flags docs: http://docs.platformio.org/en/latest/projectconf/$
monitor_baud = 115200
debug_flags = -D DEBUG=1
build_flags =
  -Wl,-u_printf_float
  -D std=gnu99

build_flags = -std=gnu99

# Dev build enviroment (default)
# $ pio run -t upload
[env:stm32f303-dev]
platform = ststm32
framework = stm32cube
board = nucleo_f303re
monitor_baud = ${common.monitor_baud}
src_build_flags =
  ${common.build_flags}
  ${common.debug_flags}

# Non dev build enviroment, specify enviroment using:
# $ pio run -t upload -e stm32f303
[env:stm32f303]
platform = ststm32
framework = stm32cube
board = nucleo_f303re
monitor_baud = ${common.monitor_baud}
src_build_flags = ${common.build_flags}

That compiles and loads just fine

pi@raspberrypi:~/v5/stm32tests/emonTxshield $ nano platformio.ini
pi@raspberrypi:~/v5/stm32tests/emonTxshield $ pio run -t upload
[Tue Mar 27 10:55:20 2018] Processing stm32f303-dev (platform: ststm32; board: nucleo_f303re; framework: stm32cube)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST Nucleo F303RE
SYSTEM: STM32F303RET6 72MHz 64KB RAM (512KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(light)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs/stm32f303-dev/src/adc.o
Compiling .pioenvs/stm32f303-dev/src/dma.o
Compiling .pioenvs/stm32f303-dev/src/gpio.o
Compiling .pioenvs/stm32f303-dev/src/main.o
Compiling .pioenvs/stm32f303-dev/src/power.o
Compiling .pioenvs/stm32f303-dev/src/stm32f3xx_hal_msp.o
Compiling .pioenvs/stm32f303-dev/src/stm32f3xx_it.o
Compiling .pioenvs/stm32f303-dev/src/system_stm32f3xx.o
Compiling .pioenvs/stm32f303-dev/src/tim.o
Compiling .pioenvs/stm32f303-dev/src/usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_adc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_adc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_can.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_cec.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_comp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_cortex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_crc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_crc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dac.o
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c: In function 'CRC_Handle_8':
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:485:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
^
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:489:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
^
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c: In function 'CRC_Handle_16':
/home/pi/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:521:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = pBuffer[2*i];
^
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dac_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dma.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_flash.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_flash_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_gpio.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_hrtim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2c.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2c_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2s.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2s_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_irda.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_iwdg.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_nand.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_nor.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_opamp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_opamp_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pccard.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pcd.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pcd_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pwr.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pwr_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rcc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rcc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rtc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rtc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_sdadc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smartcard.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smartcard_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smbus.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_spi.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_spi_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_sram.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tim_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tsc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_uart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_uart_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_wwdg.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_adc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_comp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_crc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_dac.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_dma.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_exti.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_fmc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_gpio.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_hrtim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_i2c.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_opamp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_pwr.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_rcc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_rtc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_spi.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_tim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_utils.o
Compiling .pioenvs/stm32f303-dev/FrameworkCMSISDevice/gcc/startup_stm32f303xe.o
Compiling .pioenvs/stm32f303-dev/FrameworkCMSISDevice/system_stm32f3xx.o
Archiving .pioenvs/stm32f303-dev/libFrameworkCMSISDevice.a
Indexing .pioenvs/stm32f303-dev/libFrameworkCMSISDevice.a
Archiving .pioenvs/stm32f303-dev/libFrameworkHALDriver.a
Indexing .pioenvs/stm32f303-dev/libFrameworkHALDriver.a
Linking .pioenvs/stm32f303-dev/firmware.elf
Checking program size
text       data     bss     dec     hex filename
21400      1088    5908   28396    6eec .pioenvs/stm32f303-dev/firmware.elf
Building .pioenvs/stm32f303-dev/firmware.bin
Configuring upload protocol...
AVAILABLE: blackmagic, jlink, mbed, mbed, stlink
CURRENT: upload_protocol = mbed
Looking for upload disk...
Auto-detected: /media/pi/NODE_F303RE
Uploading .pioenvs/stm32f303-dev/firmware.bin
Firmware has been successfully uploaded.
(Some boards may require manual hard reset)
========================= [SUCCESS] Took 37.21 seconds =========================

================================== [SUMMARY] ==================================
Environment stm32f303-dev       [SUCCESS]
Environment stm32f303           [SKIP]
========================= [SUCCESS] Took 37.21 seconds =========================

and the resulting serial print still has no values either

pi@raspberrypi:~/v5/stm32tests/emonTxshield $ pio device monitor
--- Miniterm on /dev/ttyACM0  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
29C, Vdda: 3304mV
0: Vrms: , Irms: , Papp: , Preal: , PF:
1: Vrms: , Irms: , Papp: , Preal: , PF:
2: Vrms: , Irms: , Papp: , Preal: , PF:
3: Vrms: , Irms: , Papp: , Preal: , PF:
2: Vrms: , Irms: , Papp: , Preal: , PF:
3: Vrms: , Irms: , Papp: , Preal: , PF:
0: Vrms: , Irms: , Papp: , Preal: , PF:
1: Vrms: , Irms: , Papp: , Preal: , PF:
CPU temp: 29C, Vdda: 3306mV
0: Vrms: , Irms: , Papp: , PCPU temp: 29C, Vdda: 3306mV

--- exit ---

That’s good to know. Thanks for testing :+1:

I just tested compiling stm32tests/emonTxshield at master · stm32oem/stm32tests · GitHub using platformIO (copied over the same platformio.ini) and it worked for me. I’ve created a PR to add the platformio.ini

What version platformio are you using `$ pio --version"?

[Wed Mar 28 16:48:35 2018] Processing stm32f303-dev (platform: ststm32; board: nucleo_f303re; framework: stm32cube)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST Nucleo F303RE
SYSTEM: STM32F303RET6 72MHz 64KB RAM (512KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(light)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs/stm32f303-dev/src/adc.o
Compiling .pioenvs/stm32f303-dev/src/dma.o
Compiling .pioenvs/stm32f303-dev/src/gpio.o
Compiling .pioenvs/stm32f303-dev/src/main.o
Compiling .pioenvs/stm32f303-dev/src/power.o
Compiling .pioenvs/stm32f303-dev/src/stm32f3xx_hal_msp.o
Compiling .pioenvs/stm32f303-dev/src/stm32f3xx_it.o
Compiling .pioenvs/stm32f303-dev/src/system_stm32f3xx.o
Compiling .pioenvs/stm32f303-dev/src/tim.o
Compiling .pioenvs/stm32f303-dev/src/usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_adc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_adc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_can.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_cec.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_comp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_cortex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_crc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_crc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dac.o
/home/glyn/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c: In function 'CRC_Handle_8':
/home/glyn/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:485:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
^
/home/glyn/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:489:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
^
/home/glyn/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c: In function 'CRC_Handle_16':
/home/glyn/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:521:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = pBuffer[2*i];
^
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dac_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_dma.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_flash.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_flash_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_gpio.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_hrtim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2c.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2c_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2s.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_i2s_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_irda.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_iwdg.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_nand.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_nor.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_opamp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_opamp_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pccard.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pcd.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pcd_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pwr.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_pwr_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rcc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rcc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rtc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_rtc_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_sdadc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smartcard.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smartcard_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_smbus.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_spi.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_spi_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_sram.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tim_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_tsc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_uart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_uart_ex.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_hal_wwdg.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_adc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_comp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_crc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_dac.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_dma.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_exti.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_fmc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_gpio.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_hrtim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_i2c.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_opamp.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_pwr.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_rcc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_rtc.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_spi.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_tim.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_usart.o
Compiling .pioenvs/stm32f303-dev/FrameworkHALDriver/Src/stm32f3xx_ll_utils.o
Compiling .pioenvs/stm32f303-dev/FrameworkCMSISDevice/gcc/startup_stm32f303xe.o
Compiling .pioenvs/stm32f303-dev/FrameworkCMSISDevice/system_stm32f3xx.o
Archiving .pioenvs/stm32f303-dev/libFrameworkCMSISDevice.a
Indexing .pioenvs/stm32f303-dev/libFrameworkCMSISDevice.a
Archiving .pioenvs/stm32f303-dev/libFrameworkHALDriver.a
Indexing .pioenvs/stm32f303-dev/libFrameworkHALDriver.a
Linking .pioenvs/stm32f303-dev/firmware.elf
Building .pioenvs/stm32f303-dev/firmware.bin
Calculating size .pioenvs/stm32f303-dev/firmware.elf
text	   data	    bss	    dec	    hex	filename
28244	   1460	   5944	  35648	   8b40	.pioenvs/stm32f303-dev/firmware.elf
========================= [SUCCESS] Took 7.67 seconds =========================

================================== [SUMMARY] ==================================
Environment stm32f303-dev	[SUCCESS]
Environment stm32f303    	[SKIP]
========================= [SUCCESS] Took 7.67 seconds =========================

I’m still running…

only installed a few days ago specifically to try this out so it cannot be that far from the latest

That’s great, but what platform are you testing this on? Is it a PI?

Great! I was going to do it once I got it working, I have started a new branch “platformio” so that we can get this fixed and I’ll add some doc notes too.

The version you have submitted will simply not work for me, whilst I’m not overly concerned about that, I assume it is more to do with using a PI rather than specifically a problem unique to me personally, so if it’s in the repo IMO it needs to work for me too even if I’m not using it as I might end up supporting it.

Pi’s are not exactly uncommon around here :smile:

If I get time over the weekend, I will try again from scratch IF you are saying you have confirmed this as working on a RPi yourself.

Just installed Platformio on my Debian VM, cloned stm32oem (platformio branch) followed by sudo pio run -t upload and it successfully (and very smoothly!) compiled and uploaded the code to the STM32.

Running the pio monitor gave the error;
could not open port '/dev/ttyACM0': [Errno 13] could not open port /dev/ttyACM0:
…but running the command again as root - sudo pio device monitor ensured that Miniterm could access the port, and then all was well.

During the Platformio install process, I did get some warnings, but I assume that they can be disregarded.

/root/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c: In function 'CRC_Handle_8':
/root/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:485:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
^
/root/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:489:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = ((uint32_t)pBuffer[4*i]<<8) | (uint32_t)pBuffer[4*i+1];
^
/root/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c: In function 'CRC_Handle_16':
/root/.platformio/packages/framework-stm32cube/f3/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc.c:521:8: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*(uint16_t volatile*) (&hcrc->Instance->DR) = pBuffer[2*i];
^

That’s odd I don’t get that error. Does your user belong to the dialout groups? The pi user is in the dialout group by default in the Raspbian images

pi@raspberrypi:~ $ groups
pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi

Install or compile?

I get some warnings during compile too, I get some with the “make” routine and standard ARM toolchain too, but Ive never really studied the content, I did read it a couple of times when we started this but the info didn’t stick.

It could be because the usb device is mounted within a VM which isn’t quite the same as a physical machine.

Install. I don’t get any errors during compile.

Edit - in fact I do, the same errors occur during compile too, except the warnings are only visible if it’s run in verbose mode. - sudo pio run -t upload -v

Must admit, I was a sceptic about using Platformio, but having tried it I’m impressed.

I’m not sold on it, most of the negativity comes from having it thrust upon me at very regular intervals and having to explain why I’m not using it.

It is overkill for use on the Pi (and it currently doesn’t work which doesn’t help) the deb package and minicom works well and it’s maintained via apt-get, I have no need for more clutter. As I ve said before the serial monitor is nicer than minicom, but I wouldn’t install it just for a serial console.

Beware of using sudo with PIO. If you inadvertently use it for the compile command, it will write the temp files as root and not be able to delete them next time you compile as non-root. I have no doubt sudo make will probably do the same, but as I’m not using any sudo commands whilst compiling/flashing and viewing the serial output it’s a mistake less likely to happen for me.

Do you have to use sudo with minicom too?

1 Like

Well I never…

I just found Miniterm is installed as part of the standard Raspbian image. So there is no reason for me to install Minicom (which I dislike). I can just install the ARM toolchain alone and use Miniterm.

pi@raspberrypi:~ $ miniterm.py /dev/ttyACM0 115200
--- Miniterm on /dev/ttyACM0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
0: Vrms: 1133.46, Irms: 8.50, Papp: 9636.96, Preal: -28.42, PF: -0.003
1: Vrms: 1133.46, Irms: 87.93, Papp: 99662.74, Preal: 1469.25, PF: 0.015
2: Vrms: 1133.46, Irms: 87.93, Papp: 99662.74, Preal: 1469.25, PF: 0.015
3: Vrms: 1133.44, Irms: 87.93, Papp: 99660.94, Preal: 1316.91, PF: 0.013

--- exit ---
pi@raspberrypi:~ $

how great is that?

I can just set up an alias to include the settings and path like I have for Minicom and issue a single word command to open the Miniterm serial console at the right baud and path, Fantastic!

1 Like

Yes.

Well the compile command is run by root sudo pio run -t upload - see Trystan’s readme.md
…which results in the compiled data being;

paul@debian:~/STM32Cube/Repository/stm32tests/emonTxshield/.pioenvs$ ls -la stm32f303-dev
total 472
drwxr-xr-x 5 root root   4096 Mar 28 21:11 .
drwxr-xr-x 3 root root   4096 Mar 28 21:11 ..
-rwxr-xr-x 1 root root  29720 Mar 28 21:11 firmware.bin
-rwxr-xr-x 1 root root 155496 Mar 28 21:11 firmware.elf
drwxr-xr-x 3 root root   4096 Mar 28 21:11 FrameworkCMSISDevice
drwxr-xr-x 3 root root   4096 Mar 28 21:10 FrameworkHALDriver
-rw-r--r-- 1 root root   9816 Mar 28 21:11 libFrameworkCMSISDevice.a
-rw-r--r-- 1 root root 358016 Mar 28 21:11 libFrameworkHALDriver.a
drwxr-xr-x 2 root root   4096 Mar 28 21:10 src

Ohh! That’s not good! So make won’t work after using PIO either? Unless you use sudo too. That cannot be right, it installs it’s toolchain in the users home folder, not in the root filesystem, it shouldn’t then expect you to use sudo. Did you install with sudo or not?

[edit] Do you have a .platformio folder in your users home directory? Is there one at the root users home directory too?

[edit2] If you have more than one .platformio folder, can you tell which is being used? latest file times or rename one of them to see it is causes an issue.

[edit3] If you look at Glyns first post in this thread he doesn’t use sudo either (and his middle name is platformio), but I suppose he may be a root level user.

[edit4] In the PlatformIO: Compile & upload firmware. Blog post 1/3 thread, there is a variety of sudo and non-sudo commands but no explanation as to which or why. I think some clarification may be in order here.

Yes, I used the Platformio installation script (and yes sudo was required)

Yes, but it only contains a Platformio json config file - no other data

Yes, but that folder contains Platformio’s libraries, toolchains, etc.

Maybe. That’s one for Glyn to answer!

EDIT - there is a way to install Platformio local to a user, but pip is needed (the package management system for Python). I didn’t really want to install pip, as it’s yet more baggage I probably wouldn’t use again!!

I have both since I ran the compile with sudo by accident the other day and that’s how I came to learn about the issue with root owned temp files as I only made the error once and then couldn’t use non-sudo as I was used to.

pi@raspberrypi:~ $ ls -la .platformio
total 24
drwxr-xr-x  5 pi pi 4096 Mar 26 19:08 .
drwxr-xr-x 35 pi pi 4096 Mar 28 20:02 ..
-rw-r--r--  1 pi pi  186 Mar 26 19:08 appstate.json
drwxr-xr-x  2 pi pi 4096 Mar 23 17:00 lib
drwxr-xr-x  8 pi pi 4096 Mar 26 19:04 packages
drwxr-xr-x  3 pi pi 4096 Mar 26 18:57 platforms
pi@raspberrypi:~ $ sudo ls -la /root/.platformio
total 24
drwxr-xr-x 5 root root 4096 Mar 23 16:58 .
drwx------ 6 root root 4096 Mar 23 16:51 ..
-rw-r--r-- 1 root root  139 Mar 23 16:58 appstate.json
drwxr-xr-x 2 root root 4096 Mar 23 16:58 lib
drwxr-xr-x 8 root root 4096 Mar 23 16:57 packages
drwxr-xr-x 3 root root 4096 Mar 23 16:51 platforms

I too installed with sudo for the installer, I only asked to see if there was a difference.

If you delete the temp files in .pioenvs will it then compile without sudo?

sudo rm -r /home/pi/redo/txshield_demo_3/emonTxshield/.pioenvs

(edit to suit your user and path)

although it looks like all your files are root, you may need to chown the project folder instead.

PIP is also included as standard on the Raspbian image, but PIO installed it again, or so it told me, I don’t actually know if the message was accurate, but I recall I was annoyed whilst watching it apparently install PIP when I knew it was already there.

I use a lot of Python so PIP is generally something I use.

I think you have a non-sudo PIO, but once you use sudo you are stuck unless you remove or chown the files.

You souldn’t need sudo to flash the stm32 as it’s mounted to the users media folder so you shouldn’t need sudo at all for the run or upload commands.

For acces to the serial port to negate using sudo with miniterm try adding your user to the dialout group with

sudo usermod -a -G dialout $USER

you might need to log out and in, or start anew shell to get the new group permissions. Check it with groups .

My main project files are not root.
But, after deleting .pioenvs and running platformio without sudo, it again downloaded the toolchain, libraries and support files to my user root (so like you - I now have a set in root users home directory & a set in user home directory!!) it then went onto successfully flash the STM32.

However, the .pioenvs is now user owned;

user

I suppose the test now is to delete the library files (except the json config) from the root users home directory, but being a gentleman - you first!!

Paul

pi@raspberrypi:~ $ sudo mv /root/.platformio /root/X.platformio
pi@raspberrypi:~ $ cd ~/v5/stm32tests/emonTxshield
pi@raspberrypi:~/v5/stm32tests/emonTxshield $ pio run
[Wed Mar 28 21:21:33 2018] Processing stm32f303-dev (platform: ststm32; board: nucleo_f303re; framework: stm32cube)
----------------------------------------------------------------------------------------------------------------------------------------

...
...
...

Calculating size .pioenvs/stm32f303-dev/firmware.elf
text       data     bss     dec     hex filename
21408      1088    5908   28404    6ef4 .pioenvs/stm32f303-dev/firmware.elf
===================================================== [SUCCESS] Took 36.62 seconds =====================================================

============================================================== [SUMMARY] ==============================================================
Environment stm32f303-dev       [SUCCESS]
Environment stm32f303           [SKIP]
===================================================== [SUCCESS] Took 36.63 seconds =====================================================
pi@raspberrypi:~/v5/stm32tests/emonTxshield $

No problemo!

I just renamed the copy in the root folder so PIO couldn’t find them

1 Like