Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


Beginner questions about STM32 and System Workbench

I’ve just started working with the STM32 Cortex-M0+ MCUs and I want to understand a few things I’m seeing in the programming process. Any insight would be appreciated.

I have an STM32L051K8T6 connected with a genuine ST-LINK/V2 using SWD with nSRST connected. I’m running the simple LED blink program shown below to blink an LED connected a a transistor on pin 20 (i.e., GPIO PORTA10):

#include "stm32l0xx.h"
#include <stdint.h>

volatile uint32_t i;

int main(void)
{
	RCC->IOPENR |= RCC_IOPENR_GPIOAEN;

	GPIOA->MODER = GPIO_MODER_MODE10_0;

	while(1) {
		for (i = 0; i < 0x3FFF; i++);

		GPIOA->BSRR = GPIO_BSRR_BS_10;

		for (i = 0; i < 0x3FFF; i++);

		GPIOA->BSRR = GPIO_BSRR_BR_10;
	}
}


It seems to be working, other than occasionally having to try to program the device twice (the first time the programming fails). This is the .cfg file I’m using:

# This is an STM32L051K8T6 board with a single STM32L051K8Tx chip.
# Generated by System Workbench for STM32

source [find interface/stlink-v2.cfg]

set WORKAREASIZE 0x2000
transport select hla_swd
set CPUTAPID 0x0bc11477

source [find target/stm32lx_stlink.cfg]

# use hardware reset, connect under reset
reset_config srst_only srst_nogate


My main concern is that I’m seeing a number of errors during the programming process and I suspect that some of them could be related to the odd issues I’ve been seeing. Here are some examples:

** Programming Started **
auto erase enabled
Info : Device: STM32L0xx (Cat. 3)
Info : STM32L flash size is 64kb, base address is 0x8000000
Warn : couldn't use loader, falling back to page memory writes
wrote 4096 bytes from file Debug/STM32L0Test.elf in 2.251998s (1.776 KiB/s)
** Programming Finished **
** Verify Started **
Error: JTAG failure
Error: Error setting register
stm32l1.cpu: target state: halted
target halted due to breakpoint, current mode: Handler HardFault
xPSR: 0x61000003 pc: 0x2000002e msp: 0x20002000
Error: JTAG failure
Error: Error setting register
stm32l1.cpu: target state: halted
target halted due to breakpoint, current mode: Handler HardFault
xPSR: 0x61000003 pc: 0x2000002e msp: 0x20002000
verified 2372 bytes in 0.304996s (7.595 KiB/s)
** Verified OK **
** Resetting Target **
Info : Unable to match requested speed 300 kHz, using 240 kHz
Info : Unable to match requested speed 300 kHz, using 240 kHz
adapter speed: 240 kHz
in procedure 'program' 
in procedure 'reset' called at file "embedded:startup.tcl", line 507
in procedure 'ocd_bouncer'


In particular, I’m wondering:

1. Why is it warning that it can’t use the loader? Does that mean the boot loader? Would it even make sense to use the boot loader over SWD? I just don’t understand this message.

2. If I’m using SWD, why is it giving me a JTAG failure and how can I find out which register it is trying to set?

3. Is it normal for it to experience a HardFault during the programming process? I guess that is more of an ARM question than a System Workbench question, but it seems like a strange message to experience during device programming.

I’m coming from a background of AVR and PIC where the tools are mostly closed-source but well documented, and I really like having the fully open source System Workbench for STM32, but I know there can be some learning curve with open source systems. Any answers to these questions or general information about how to make development and testing run smoothly with this system would be appreciated.

 

Newest Forum Posts

  1. Монтаж камина с грилем в Москве - установка и барбекю by KpddomErorb, 2025-05-10 18:28
  2. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  9. Build a project in "release" mode by tang, 2025-02-20 10:36
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35

Last-Modified Blogs