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


STM32L476G-EVAL and ST-LINK/V2 Connection Problem

Hello,

I am wanting to debug on a STM32L476G-EVAL board using an external ST-LINK/V2 programmer.

Using the ST-LINK utility, I can connect to the board, view memory, etc.

Once in the Workbench environment, I error out when trying to connect to the board.

I have tried using both the default script and well as providing a Manual spec:

Debug device: ST-LinkV2
Debug interface: SWD

The OCD output from this setup is:

Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Warn : use ‘stm32l4.cpu’ as target identifier, not ‘0’
adapter_nsrst_delay: 100
srst_only separate srst_nogate srst_open_drain connect_assert_srst
adapter speed: 1800 kHz
srst_only separate srst_nogate srst_open_drain connect_assert_srst
Info : clock speed 1800 kHz
Error: libusb_open() failed with LIBUSB_ERROR_ACCESS
Error: open failed
in procedure ‘init’
in procedure ‘ocd_bouncer’

And the error message I get in Workbench is:

Error in final launch sequence
Failed to execute MI command:
-target-select remote localhost:3333

Error message from debugger back end:
localhost:3333: The system tried to join a drive to a directory on a joined drive.
localhost:3333: The system tried to join a drive to a directory on a joined drive.


Can someone guide me on how I might fix this problem?

Thank you.

Hello,

For info, the default config for L476 Eval internal STLink is STLink V2-1, not Stlink V2.

For external STlink, it is STLink V2 (STLink V1 not supported by SW4STM32).

Also, you must not connect several Stlink to the PC.
It can be the case if the Eval board STLink usb connector is connected to the PC (for supply), In that case, you would have the internal STLink V2-1 of the eval board and the external STLink V2 connected to the PC.

It can be this issue when you get the libusb error access msg.

Regards,
Laurent

Thanks Laurent. I have perhaps made some progress on the topic.

At least I am getting a different error now:

Error in final launch sequence
Failed to execute MI command:
load E:\project\AMBERSTONE\Software\evaluationboard\SW4STM32\evaluationboard\Debug\evaluationboard.elf

Error message from debugger back end:
Error erasing flash with vFlashErase packet
Error erasing flash with vFlashErase packet

I am running the low power series processor on this board.

I have attached my debug settings in Workbench.


Hello,

I can’t see anything on your pdf screenshot (too small) but anyway, check the board configuration script cfg produced, it should have:

  1. This is an L476_test board with a single STM32L476ZGTx chip.
  2. Generated by System Workbench for STM32


source find interface/stlink-v2.cfg

set WORKAREASIZE 0x18000
transport select “hla_swd”


source find target/stm32l4.cfg

  1. use hardware reset, connect under reset

reset_config srst_only srst_nogate


Then, maybe the jumpers on the eval board are at the wrong place.
Check that pwr_ext jumper is on.
That the jumper is on PSU for power supply and that the board has the external 5V supplied connected.
Check that no debug session are still running or openocd.exe task running.
And quit the stlink utility (or at least disconnect the session).

If this is still not working, what you can try also is to right click on the project name and do a Target->Erase chip before debug.


And why don’t you use the STLink V2-1 on the eval board to debug ?

Rgds,
Laurent


Hello Laurent:

Attached is a copy of the custom cfg file contents:

  1. This is an .custom board with a single STM32L476ZGTx chip.
  2. Generated by System Workbench for STM32


source find interface/stlink-v2.cfg

set WORKAREASIZE 0x18000
transport select “hla_swd”


source find target/stm32l4.cfg

  1. use hardware reset, connect under reset

reset_config srst_only srst_nogate

I am running from the external +5V and I believe the hardware (eval board and external ST-LINK) should be fine as I can query and erase memory from the U-LINK application.

I am wanting to use an external ST-LINK/V2 because I have a custom board coming and will need to debug from this device. I won’t have an on-board ST-LINK hardware.

I tried performing the Target->Erase Chip and get the following error:
Open On-Chip Debugger 0.10.0-dev-00267-g884c33c (2016-03-16-12:22)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Warn : use ‘STM32L476.cpu’ as target identifier, not ‘0’
adapter_nsrst_delay: 100
srst_only separate srst_nogate srst_open_drain connect_assert_srst
adapter speed: 1800 kHz
Info : clock speed 1800 kHz
Error: open failed
in procedure ‘init’
in procedure ‘ocd_bouncer

Sorry for all the problems, but your help is much appreciated.

Loren


Laurent,

It is interesting that the OCD console says I have breakpoints set, but none actually show up in the Workbench environment. See that attached console output below:

Info : STLINK v2 JTAG v25 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.256693
Info : stm32l4.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting ‘gdb’ connection on tcp/3333
adapter speed: 240 kHz
stm32l4.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
adapter speed: 4000 kHz
Info : Device id = 0x10076415
Info : STM32L4xx flash size is 1024kb, base address is 0x8000000
Error: address + size wrapped(0xfffffffe, 0x00000004)
adapter speed: 240 kHz
stm32l4.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
adapter speed: 240 kHz
stm32l4.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
adapter speed: 4000 kHz

Thanks,

Loren


The cfg file is ok.

Then, i just got the error you have because i forgot to put the jumper on PSU (it was on STLINK as i use the internal STLink normally).
So, check again the jumpers on Eval board: PSU ON, PWR_EXT ON
And no USB cable on STLink v2-1 USB port of course.

Then, it was not so simple to remove the error, i had to quit and restart and replug the board supply.

I retried, reproducing the error with the jumper.
To recover, i had to put back jumper on PSU, unplug power AND STlink v2 usb.
No need to restart SW4STM32.
Replug Power and STlink v2.
Then i could debug again.

Also don’t forget to remove all terminated launches or restart SW4STM32 to be sure.


For the Breakpoints, OpenOcd only says you can set 6 hardware breakpoints on this target.
It doesn’t say you have set them.

Rgds,
Laurent


Laurent,

Some good news. I found another evaluation board, connected it to the debugging hardware and software, and everything works (on the 2nd evaluation board). Upon further inspection, I find that my processor is in Level 1 read out protection. I can’t seem to get it out of this mode using the ST-LINK utility.

What is the process for getting it back to Level 0?

Thanks for all the help.

Loren


Hello,

You should be able to reprogram option bytes to ReaD Protection level 0.
In STLink Utility, go to Target - Option Bytes window and change the RDP to level 0 and reprogram.

Laurent


Laurent,

I have tried this with no success. I get the error:

Could not set Option bytes!
Please reset the target and retry.

No luck beyond that. I wonder if I could have damaged my part?

Loren


Hi,

I don’t know, maybe use the internal STlink v2-1 for this.
Also, can you try to change the switch of Boot0 pin to 1 and reset.


Another idea, maybe the PCrop R/W protection is set too ?

Check that you have the “connect under reset” and “debug in low power modes” options activated.
Reset mode should be “Hardware Reset”.
And i have SWD at 1.8MHz.

Can you upgrade the STLink firmware ?

Laurent