[SOLVED] STM32F103C Blue Pill – can compile and upload only once.

kd5byb
Sun Jan 07, 2018 3:41 pm
Good morning all,

SOLUTION: Reinstalled Arduino IDE from scratch and now everything works fine. :)

Having a bit of an issue using STM32duino and the Arduino GUI (v 1.8.5) to upload to a generic STM32F103C blue pill.

Some background – about six months ago, I bought some blue pills, flashed them with the ST GUI flash tool using generic_boot20_pc13.bin. I played around with them a bit, mostly doing nothing more than flashing the PC13 LED at various rates, then got sidetracked with other projects. I do not recall having any issues at all with compiling or uploading via the miniUSB port on the blue pill.

Today, I decided to get started on a new project using the blue pill. I decided that I should make sure my setup was working properly, so I opened up the example LED flashing code and set about to change the flash rate just to make sure I could upload code without error. After remembering that I’ve got to hit the reset button right after it finishes compiling, I had no problem uploading code the first time. However, when I change my code and try to compile and upload again, I get an error. This seems very strange!

I looked through the message boards trying to find someone who had this previous…but had no luck. So…I figured I’d ask and see if someone can please point me in the right direction.

First…here is the output from the compiler when everything works. I’ve deleted out the majority of the compiling core messages, else this post would be way too long!

D:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware D:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Benjamin\AppData\Local\Arduino15\packages -hardware D:\My Documents\Arduino\hardware -tools D:\Program Files (x86)\Arduino\tools-builder -tools D:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Benjamin\AppData\Local\Arduino15\packages -built-in-libraries D:\Program Files (x86)\Arduino\libraries -libraries D:\My Documents\Arduino\libraries -fqbn=Arduino_STM32-master:STM32F1:genericSTM32F103C:device_variant=STM32F103C8,upload_method=DFUUploadMethod,cpu_speed=speed_72mhz,opt=osstd -ide-version=10805 -build-path C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703 -warnings=none -build-cache C:\Users\Benjamin\AppData\Local\Temp\arduino_cache_693657 -prefs=build.warn_data_percentage=75 -verbose D:\My Documents\Arduino\stm32_blink_test\stm32_blink_test.ino
D:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware D:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Benjamin\AppData\Local\Arduino15\packages -hardware D:\My Documents\Arduino\hardware -tools D:\Program Files (x86)\Arduino\tools-builder -tools D:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Benjamin\AppData\Local\Arduino15\packages -built-in-libraries D:\Program Files (x86)\Arduino\libraries -libraries D:\My Documents\Arduino\libraries -fqbn=Arduino_STM32-master:STM32F1:genericSTM32F103C:device_variant=STM32F103C8,upload_method=DFUUploadMethod,cpu_speed=speed_72mhz,opt=osstd -ide-version=10805 -build-path C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703 -warnings=none -build-cache C:\Users\Benjamin\AppData\Local\Temp\arduino_cache_693657 -prefs=build.warn_data_percentage=75 -verbose D:\My Documents\Arduino\stm32_blink_test\stm32_blink_test.ino
Using board 'genericSTM32F103C' from platform in folder: D:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1
Using core 'maple' from platform in folder: D:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1
Detecting libraries used...
"C:\Users\Benjamin\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8002000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10805 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/include" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/stm32f1/include" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/usb/stm32f1" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/usb/usb_lib" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\variants\generic_stm32f103c" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\sketch\stm32_blink_test.ino.cpp" -o "nul"
Generating function prototypes...
"C:\Users\Benjamin\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8002000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10805 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/include" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/stm32f1/include" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/usb/stm32f1" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/usb/usb_lib" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\variants\generic_stm32f103c" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\sketch\stm32_blink_test.ino.cpp" -o "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\preproc\ctags_target_for_gcc_minus_e.cpp"
"D:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Users\Benjamin\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11 -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8002000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10805 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/include" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/stm32f1/include" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/usb/stm32f1" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/usb/usb_lib" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\variants\generic_stm32f103c" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\sketch\stm32_blink_test.ino.cpp" -o "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\sketch\stm32_blink_test.ino.cpp.o"
Compiling libraries...
Compiling core...
"C:\Users\Benjamin\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-gcc" -c -g -x assembler-with-cpp -MMD -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10805 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/include" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/stm32f1/include" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/usb/stm32f1" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/usb/usb_lib" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\variants\generic_stm32f103c" "D:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\variants\generic_stm32f103c\wirish\start.S" -o "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\core\wirish\start.S.o"
"C:\Users\Benjamin\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-gcc" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu11 -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8002000 -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10805 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/include" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/stm32f1/include" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/usb/stm32f1" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/usb/usb_lib" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple" "-ID:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\variants\generic_stm32f103c" "D:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\variants\generic_stm32f103c\wirish\start_c.c" -o "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\core\wirish\start_c.c.o"
<NOTE: many more of these messages edited to save space.>
"C:\Users\Benjamin\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-ar" rcs "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\core\core.a" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\core\libmaple\exc.S.o"
"C:\Users\Benjamin\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-ar" rcs "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\core\core.a" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\core\libmaple\stm32f1\performance\isrs.S.o"
<NOTE: many more of these messages edited to save space.>
Archiving built core (caching) in: C:\Users\Benjamin\AppData\Local\Temp\arduino_cache_693657\core\core_Arduino_STM32-master_STM32F1_genericSTM32F103C_device_variant_STM32F103C8,upload_method_DFUUploadMethod,cpu_speed_speed_72mhz,opt_osstd_7ddba73ee2fe122909a5bdb2c1fa5896.a
Linking everything together...
"C:\Users\Benjamin\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -Os -Wl,--gc-sections -mcpu=cortex-m3 "-TD:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\variants\generic_stm32f103c/ld/bootloader_20.ld" "-Wl,-Map,C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703/stm32_blink_test.ino.map" "-LD:\My Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\variants\generic_stm32f103c/ld" -o "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703/stm32_blink_test.ino.elf" "-LC:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703" -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\Benjamin\AppData\Local\Temp\arduino_build_167703\sketch\stm32_blink_test.ino.cpp.o" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\core\wirish\start.S.o" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\core\wirish\start_c.c.o" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\core\wirish\syscalls.c.o" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\core\board.cpp.o" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\core\wirish\boards.cpp.o" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703\core\wirish\boards_setup.cpp.o" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703/core\core.a" -Wl,--end-group
"C:\Users\Benjamin\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-objcopy" -O binary "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703/stm32_blink_test.ino.elf" "C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703/stm32_blink_test.ino.bin"
Sketch uses 13044 bytes (19%) of program storage space. Maximum is 65536 bytes.
Global variables use 2816 bytes (13%) of dynamic memory, leaving 17664 bytes for local variables. Maximum is 20480 bytes.
D:\My Documents\Arduino\hardware\Arduino_STM32-master/tools/win/maple_upload.bat COM31 2 1EAF:0003 C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703/stm32_blink_test.ino.bin
maple_loader v0.1
Resetting to bootloader via DTR pulse
Reset via USB Serial Failed! Did you select the right serial port?
Searching for DFU device [1EAF:0003]...
Assuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...

Found it!

Opening USB Device 0x1eaf:0x0003...
Found Runtime: [0x1eaf:0x0003] devnum=1, cfg=0, intf=0, alt=2, name="STM32duino bootloader v1.0 Upload to Flash 0x8002000"
Setting Configuration 1...
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
bytes_per_hash=260
Starting download: [##################################################] finished!
error resetting after download: usb_reset: could not reset device, win error: The device is not connected.

state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
timeout waiting for COM31 serial


kd5byb
Sun Jan 07, 2018 4:42 pm
Good morning all,

So…I decided to simply uninstall the Arduino IDE and start over. That has fixed the problem! I can now compile as many times as I like.

How do I mark the thread as solved?

thanks much,
ben


zmemw16
Sun Jan 07, 2018 5:36 pm
edit the title of your first post of this thread
add in text at the top of the body to summarise the fix
srp

kd5byb
Sun Jan 07, 2018 5:57 pm
Excellent, thanks much! Marked as solved and added in text describing the fix.

mrburnette
Sun Jan 07, 2018 7:50 pm
[kd5byb – Sun Jan 07, 2018 4:42 pm] –
Good morning all,

So…I decided to simply uninstall the Arduino IDE and start over. That has fixed the problem! I can now compile as many times as I like.

How do I mark the thread as solved?

thanks much,
ben

Almost always this is due to the ArduinoIDE cache files not being properly managed in the /tmp folder. If you were able to solve by an uninstall/install then it was likely a permissions issue.

Ray


kd5byb
Sun Jan 07, 2018 9:10 pm
[mrburnette – Sun Jan 07, 2018 7:50 pm] –
Almost always this is due to the ArduinoIDE cache files not being properly managed in the /tmp folder. If you were able to solve by an uninstall/install then it was likely a permissions issue.

Hi Ray,

Thanks much for the reply. That was my first thought. This is a Win7 box and I’m running as admin (probably not a great idea, security-wise, I know) and didn’t think I should have any permissions issues? Anyways…it’s now all sorted out and I’m happily programming away on the Blue Pill board. :) Got the neopixels working and just figured out how to talk out of all three Serial Ports so I’m quite happy.

thanks much,
ben


fpiSTM
Mon Jan 08, 2018 9:18 am
FYI
This issue is known.
This is due to the path length of the core.a file when using aggressively cache compiled core feature.
Issue I’ve opened in Arduino github:
https://github.com/arduino/Arduino/issues/6757

The path is 263 in your case that’s why it’s failed.
C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703/..\arduino_cache_693657\core\core_Arduino_STM32-master_STM32F1_genericSTM32F103C_device_variant_STM32F103C8,upload_method_DFUUploadMethod,cpu_speed_speed_72mhz,opt_osstd_7ddba73ee2fe122909a5bdb2c1fa5896.a


RogerClark
Tue Jan 23, 2018 8:44 pm
Frederic

Do you know if this fix causes slower build times ?


fpiSTM
Tue Jan 23, 2018 9:40 pm
I didn’t see build time change. it’s just another variable which go directly in the right path instead of going too deep and rewind :lol:
Instead of
C:\Users\Benjamin\AppData\Local\Temp\arduino_build_167703/..\arduino_cache_693657\core\...

RogerClark
Tue Jan 23, 2018 10:09 pm
OK

Path shortening is great ;-)

I was just concerned as it the changed seem to imply it had something to do with changing the way the IDE caches its precompiled object or core library


fpiSTM
Tue Jan 23, 2018 10:12 pm
Right, if you disable the aggressively cached core option in the preference dialog box you will not have the issue.
Note that this is Martino facchin from Arduino who gave me this hint.
I’ve also shorten several option as all build options are used in the cache core name.
See: https://github.com/stm32duino/Arduino_C … 2/pull/109
With those change I’ve decreased around 70 the pathname ;)

RogerClark
Wed Jan 24, 2018 5:35 am
[fpiSTM – Tue Jan 23, 2018 10:12 pm] –

With those change I’ve decreased around 70 the pathname ;)

Wow…

Thanks

I’ll try it when I get some free time. (Loads of PR’s still to process)


Leave a Reply

Your email address will not be published. Required fields are marked *