Bluepil : compiles, uploads, but systick, sprintf, adc etc do not work

I created a project with bluepill. The programme complies and uploads. The OLED connected also works but does not display the adc values, the on board led set to toggle with each iterations also do not work.

On debugging, the program enters the main() and then to HAL_Init(). from there it goes back to the main() , not moving to systemclock_config().

[env:bluepill_f103c8]

platform = ststm32

board = bluepill_f103c8

framework =stm32cube

board_build.mcu = stm32f103c8t6

board_build.f_cpu=72000000L

upload_protocol = stlink

build_type = debug

debug_tool = stlink ; Must be “custom” when using debug_server

; Tell OpenOCD to accept any CPU ID (0 = disable check)

board_debug.openocd_extra_args = -c “set CPUTAPID 0”

build_flags = -Wl,–undefined,_printf_float

debug_init_break = break main

extra_scripts = hex_script.py (this is only to convert .elf to .hex file).

when stepped into the HAL_init() , it goes upto HAL_Mspinit() –> __HAL_AFIO_REMAP_SWJ_NOJTAG()–end of Systeminit()–> startup_stm32f103f1x.s -.

/* Copy the data segment initializers from flash to SRAM */

ldr r0, =_sdata

ldr r1, =_edata

ldr r2, =_sidata

movs r3, #0

b LoopCopyDataInit

CopyDataInit:

ldr r4, [r2, r3]

str r4, [r0, r3]

adds r3, r3, #4

LoopCopyDataInit:

adds r4, r0, r3

cmp r4, r1

bcc CopyDataInit

it loops through the above codes continuesly and if continue is pressed, goes back to start of main(). What could be the reason for this ?

Can you upload your project in full on e.g. Github?

Finally found that the chip on that board is spurious. Used another board. It works fine. Sprintf() was not working because of _printf float.

build_flags = -Wl,–undefined,_printf_float. This had solved that issue, but didn’t notice since I was concentrating on the debug being stuck issue.

What was confusing is the fact that the MCU and the uploaded program works , when uploaded using ST-Link utility.