PIO Arduino STM32F103CBT6 REMAP?

Before the update I used the following code to make remap:

afio_remap(AFIO_REMAP_USART1);
afio_cfg_debug_ports (AFIO_DEBUG_SW_ONLY);
afio_remap (AFIO_REMAP_SPI1);
gpio_set_mode (GPIOB, 3, GPIO_AF_OUTPUT_PP);
gpio_set_mode (GPIOB, 4, GPIO_INPUT_FLOATING);
gpio_set_mode (GPIOB, 5, GPIO_AF_OUTPUT_PP);

Now this code doesn’t work anymore, how can I make it work? Libmaple inclusions also do not work((

Make sure to use platform = https://github.com/platformio/platform-ststm32.git and apply the fix from genericSTM32F103C8: Undefined reference to 'end' symbol causes crash at malloc · Issue #208 · platformio/platform-ststm32 · GitHub.

I made a change to platformio.ini file:

18

I made a correction according to the instructions:

.bss :
  {
    . = ALIGN(8);
    __bss_start__ = .;
    *(.bss .bss.* .gnu.linkonce.b.*)
    *(COMMON)
    . = ALIGN (8);
    __bss_end__ = .;
    _end = __bss_end__;
   end = _end;
  } > REGION_BSS

But unfortunately it didn’t help, enabling libmaple is still not available(( I use QtCreator as IDE and fixed paths:

INCLUDEPATH += $${HOMEDIR}/.platformio/packages/framework-arduinoststm32-maple/STM32F1/cores/maple

INCLUDEPATH += $${HOMEDIR}/.platformio/packages/framework-arduinoststm32-maple/STM32F1/system/libmaple

INCLUDEPATH += $${HOMEDIR}/.platformio/packages/framework-arduinoststm32-maple/STM32F1/⁨system/⁨libmaple/⁨include/⁨libmaple

INCLUDEPATH += $${HOMEDIR}/.platformio/packages/framework-arduinoststm32-maple/STM32F1/system/libmaple/stm32f1/include

But I still can’t connect libmaple

#include <libmaple/adc.h>

#include <libmaple/iwdg.h>

#include <libmaple/gpio.h>

Try adding board_build.variant=custom to your build environment in platformio.ini file.

This is not the result I’m getting:

main.cpp

#include <Arduino.h>

#include <libmaple/adc.h>
#include <libmaple/iwdg.h>
#include <libmaple/gpio.h>

void setup()
{
	afio_remap(AFIO_REMAP_USART1);
	afio_cfg_debug_ports (AFIO_DEBUG_SW_ONLY);
	afio_remap (AFIO_REMAP_SPI1);
	gpio_set_mode (GPIOB, 3, GPIO_AF_OUTPUT_PP);
	gpio_set_mode (GPIOB, 4, GPIO_INPUT_FLOATING);
	gpio_set_mode (GPIOB, 5, GPIO_AF_OUTPUT_PP);
}
void loop()
{
}

and platformio.ini

[env:bp_debug]
platform = https://github.com/platformio/platform-ststm32.git
board = genericSTM32F103C8
framework = arduino
debug_tool = stlink
upload_protocol = stlink

Results in

arm-none-eabi-g++ -o .pioenvs\bp_debug\firmware.elf -T jtag_c8.ld -Os -mthumb -mcpu=cortex-m3 -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols .pioenvs\bp_debug\src\main.cpp.o -LC:\Users\Maxi\.platformio\platforms\ststm32\ldscripts -L.pioenvs\bp_debug -LC:\Users\Maxi\.platformio\packages\framework-arduinoststm32-maple\STM32F1\variants\generic_stm32f103c\ld -Wl,--start-group .pioenvs\bp_debug\libFrameworkArduinoVariant.a .pioenvs\bp_debug\libFrameworkArduino.a -lm -lgcc -Wl,--end-group
MethodWrapper(["checkprogsize"], [".pioenvs\bp_debug\firmware.elf"])
arm-none-eabi-objcopy -O binary .pioenvs\bp_debug\firmware.elf .pioenvs\bp_debug\firmware.bin
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [==        ]  15.3% (used 3136 bytes from 20480 bytes)
PROGRAM: [==        ]  22.8% (used 14952 bytes from 65536 bytes)
 [SUCCESS] Took 4.61 seconds 

Please show the full compiler error.

1 Like

Thank you very much for your answers! Yes, I just tried to re-build the project with your settings and it worked. The only thing I did not build QtCreator, but in Visual Studio code. My assumption is that the paths are incorrectly specified in QtCreator after executing the command: platformio init – IDE qtcreator --board genericSTM32F103CB

Oh then my example is kinda wrong, I’m using

So please double check that. But it still compiles for me when I change the board target.

Yes the project builds successfully, thank you very much!!! Is it possible to see the paths of the libraries used in Visual Studio Code so that you can manually add them to QtCreator?

After initializing the project with --ide=vscode, the file .vscode\c_cpp_properties.json contains your wanted paths. Although they should really be already there. Maybe try to re-init the project? Just pio init --ide=qtcreator again.

1 Like

No doubt you are my hero! Simple reinitialization of the project solved all the problems in QtCreator, I do not understand why I did not do it before(( thanks again!

1 Like