Some time ago I’ve moved from arduino ide to Eclipse (on linux). My project (small game for my nephew) used ST SPL for “blue pill”, u8g library (graphics primitives, screen buffer handling), Nokia 5110 LCD with my own drivers and rotary encoder (handled by my code) – nothing special.
In fact I’ve used eclipse for code navigation and as good source browser for ST and u8g staff. Build process was driven by my own self-made makefile and the only linked in things were SPL distribution rooted startup files (no libgcc nor libc nor libstdc++).
I’ve used Chinese st-link clone for uploads with st-flash utility (exec bundled with Arduino IDE for Linux). Everything worked fine and development was very smooth – every code change was recompiled and re-linked by makefile and finally uploaded to stm32 board with reset and program started.
For next project i’d like to give the chance to other tools – Arduino API (stm32duino) built via PlatformIO IDE (VSCode on linux). In terms of usability this is way better than Arduino IDE – VSCode is decent IDE with powerful Sublime like editor, code completion and navigation. Unfortunately, on first sketch (LED blink) problems appeared. Build process is smooth but firmware upload is very unstable:
First upload (board had my game fw) was smooth:
st-flash write .pioenvs/genericSTM32F103CB/firmware.bin 0x08000000
2018-01-20T15:56:03 INFO src/usb.c: -- exit_dfu_mode
2018-01-20T15:56:03 INFO src/common.c: Loading device parameters....
2018-01-20T15:56:03 INFO src/common.c: Device connected is: F1 Medium-density device, id 0x20036410
2018-01-20T15:56:03 INFO src/common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 1024 bytes
2018-01-20T15:56:03 INFO src/common.c: Attempting to write 8436 (0x20f4) bytes to stm32 address: 134217728 (0x8000000)
...
2018-01-20T15:56:04 INFO src/common.c: Starting verification of write complete
2018-01-20T15:56:04 INFO src/common.c: Flash written and verified! jolly good!
8/8 pages written
Search for debug pins, or jtag or something in those lines.
stephen
[mkr – Sat Jan 20, 2018 6:30 pm] –
Yeah…that’s the simplest explanation…but for me was quite clear that such a mature soft as duino is, should not do such a things... Thought that my config is quite common and someone would notice such a thing… But, alright I’ll try to investigate that.
… a misconception.
The “core” has nothing to do with uploading. Uploading is done via 3rd party tools under ArduinoIDE. Outside the ArduinoIDE, we have no responsibility for failures; that is, you have a clone board, a clone ST_Link, and are using a make file to compile (or other environment.) The forum’s baseline environment is Windows or Linux running a recent version of the ArduinoIDE and the Maple Mini with bootloader (2K or 4K.)
I do appreciate your situation, but the “duino” in STM32duino is a reference to the ArduinoIDE. We have many members using other tools for code development and broadly two classes of users: those that use Roger’s github_hosted bootloaders and those that use no bootloaders. When outside the IDE, you are welcome to post and ask for assistance but just remember you are ultimately in self-supported territory.
Even using the ArduinoIDE, uploading can be very problematic, rarely 100% success.
Ray
Adding
void setup() {
// AFIO_BASE - expansion from SPL
uint32_t *AFIO = ((uint32_t *)((((uint32_t)0x40000000) + 0x10000) + 0x0000));
// AFIO_MAPR->SWJ_CFG = 0x0 // no remap, both JTAG and SWD active
AFIO[1] &= ~(0x07000000);
pinMode(LED, OUTPUT);
}
[mrburnette – Sat Jan 20, 2018 7:07 pm] –
The “core” has nothing to do with uploading. Uploading is done via 3rd party tools under ArduinoIDE. Outside the ArduinoIDE, we have no responsibility for failures; that is, you have a clone board, a clone ST_Link, and are using a make file to compile (or other environment.) The forum’s baseline environment is Windows or Linux running a recent version of the ArduinoIDE and the Maple Mini with bootloader (2K or 4K.)I do appreciate your situation, but the “duino” in STM32duino is a reference to the ArduinoIDE. We have many members using other tools for code development and broadly two classes of users: those that use Roger’s github_hosted bootloaders and those that use no bootloaders. When outside the IDE, you are welcome to post and ask for assistance but just remember you are ultimately in self-supported territory.
Even using the ArduinoIDE, uploading can be very problematic, rarely 100% success.
But the “core” setups microcontroller and st-link is officially supported way of uploading (appears in AIDE menu). And st-link is most probably blocked by this initialization… This seems to be AIDE problem. Preventing of SWD remapping should address most of AIDE issues with uploading via st-link… Most probably OCD is also disabled by “duino” which is rather bad news.
[mkr – Sat Jan 20, 2018 7:33 pm] –
<…>
But the “core” setups microcontroller and st-link is officially supported way of uploading (appears in AIDE menu). And st-link is most probably blocked by this initialization… This seems to be AIDE problem. Preventing of SWD remapping should address most of AIDE issues with uploading via st-link… Most probably OCD is also disabled by “duino” which is rather bad news.
There are two (2) cores both unfortunately called STM32duino:
https://github.com/rogerclarkmelbourne/Arduino_STM32
and
https://github.com/stm32duino/Arduino_C … sed-boards
Both cores are intended to be used with the ArduinoIDE, in a base_line configuration. If you deviate the IDE or build process, you put a strain on “duino” resources. Do what you want but be prepared to take the risks.
Only the last link above is considered “supported” and to what level beyond “best effort” only fpiSTM can advise. Questions are answered in this section of the forum…
http://stm32duino.com/viewforum.php?f=48
As this specific section of STM32DUINO has no “official” support, technically nothing is Officially supported. Even the core files are marked”Experimental”…
Notice
This software is experimental and a work in progress. Under no circumstances should these files be used in relation to any critical system(s). Use of these files is at your own risk.
But, if you drop over to the ST core section for Nucleo boards, then there is some support.
https://github.com/stm32duino For core and other efforts.
And
https://github.com/stm32duino/Arduino_C … sed-boards
Boards available
Current release
STM32F0
Nucleo F030R8
Nucleo F091RC
STM32F1
Nucleo F103RB
STM32VLDISCOVERY
STM32F2
Nucleo F207ZG
STM32F3
Nucleo F302R8
Nucleo F303K8
Nucleo F303RE
STM32F4
Nucleo F401RE
Nucleo F411RE
Nucleo F429ZI
Nucleo F446RE
STM32F407G-DISC1
STM32F7
STM32F746G-DISCOVERY
STM32L0
Nucleo L031K6
Nucleo L053R8
B-L072Z-LRWAN1
STM32L1
Nucleo L152RE
STM32L4
Nucleo L432KC
Nucleo L476RG
B-L475E-IOT01A
Next release
STM32F1
BluePill F103C8 (on going)
MapleMini F103CB (on going)
[mkr – Sat Jan 20, 2018 7:16 pm] –
Maybe this should be default config for duino, what you think.
Assuming you are using the libmaple core and the stlink upload option it is
[mkr – Sat Jan 20, 2018 7:16 pm] –
Bingo!
<…>
Maybe this should be default config for duino, what you think.
mkr:
This is the kind of knowledge that the user community wants to capture. It would make an excellent WiKi topic after some discussion with other advanced members who use ST_Link… hopefully they will chime in and continue this discussion.
Ray
As a newbie had no idea … Always used Roger’s duino and its repo pointed to this forum. Of course I thought about “support” not in commercial mean but on open source projects style terms. But if Roger’s core is installed within the IDE then st-link is one of the upload possibilities, so should be “supported” somehow… My problem seems to be problem of this “duino” and I’d like to discuss if the remapping/switching off the JTAG/SWD was intentional and is a good thing. In fact I’m not dsure if this is done only for blue pill, or whether the pins are remapped or freed by switching SWD off… if is it just side-effect or intention. For me it was big surprise and I’d like to know what other users think about it.
We came later with our generic boards and desire to use a debugger.
Now in the Arduino ide, if you select stlink upload the proper define is added to the compile. If you select bootloader it isn’t and the swd will be disabled.
[Rick Kimball – Sat Jan 20, 2018 11:27 pm] –
The original maple boards use a bootloader exclusively. The maple people intentionally made it hard to use the SWD/JTAG pins and made them normal gpio pins. Go look at the pinouts for the maple mini.We came later with our generic boards and desire to use a debugger.
Now in the Arduino ide, if you select stlink upload the proper define is added to the compile. If you select bootloader it isn’t and the swd will be disabled.
That means everything seems to be under control… Unfortunately had no idea about this logic, and using it outside AIDE had poor chance to have it working. From my point of view would be better not to free all the pins for GPIO on generic boards – they usually have dedicated pins for JTAG/SWD – but all that logic is quite reasonable.
Thanks.

