Menu

#398 Status of STM fork and adding support for new STM32 silicon

0.11.0
new
nobody
None
2023-07-24
2023-05-31
Jan Henke
No

Hi,

I have purchased a STM32WBA52CG nucelo board and noticed OpenOCD does not yet has support for these newer chips STM released in the last months (they released several new series).

I stumbled across a fork of OpenOCD created by STM: https://github.com/STMicroelectronics/OpenOCD
They have added support for the STM32WBA family to that fork's flash driver along with some other of the new chips (but unfortunately no target config file yet).

So I have two questions:

  1. What is the status of that fork? Was there any discussion between STM32 and the OpenOCD project in that regard? With OpenOCD being GPL-2 licenced I would assume it is no problem to just cherry picks the relevant commits from that fork back to main OpenOCD?
  2. I am struggling with creating a working target config file for the STM32WBA chip. The support was added to the STM32L4x flash driver (which already supports several STM32 families). Is it enough to copy the existing STM32l4x target config and updating the JTAG and SWD values with the correct ones from the STM32WBA reference manual?

Best regards
Jan Henke

Discussion

1 2 > >> (Page 1 of 2)
  • Tommy Murphy

    Tommy Murphy - 2023-05-31
    1. What is the status of that fork?

    You probably need to ask STM that question?

    1. I am struggling with creating a working target config file for the STM32WBA chip.

    What's wrong with the target script that's in the mainline OpenOCD?

     

    Last edit: Tommy Murphy 2023-05-31
    • Jan Henke

      Jan Henke - 2023-05-31

      The current script does not work, for starters the STM32WBA has different JTAG/SWD IDs. But also the chip architecture is different. STM32WBx is a dual core chip with one M4 and one M+, the new STM32WBA is a single core M33 chip. So there is definitely some difference that needs to be accounted for.

       
  • Tarek BOCHKATI

    Tarek BOCHKATI - 2023-05-31

    I will push a gerrit change in a few minutes with the needed cfg file

     
  • Tarek BOCHKATI

    Tarek BOCHKATI - 2023-05-31

    please test using this patch
    https://review.openocd.org/c/openocd/+/7694

     
    • Jan Henke

      Jan Henke - 2023-05-31

      Thank you for your work, unfortunately it runs into an error:

      /usr/bin/openocd -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -s /usr/share/openocd/scripts -f /home/jan/Projekte/Experimente/Elektronik/stm32wba52cg-test/openocd.cfg -c "program /home/jan/Projekte/Experimente/Elektronik/stm32wba52cg-test/cmake-build-debug/stm32wba52cg-test.elf" -c "init;reset init;" -c "echo (((READY)))"
      Open On-Chip Debugger 0.12.0
      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
      Error: hla_target: invalid parameter -ap-num (> 0)
      /usr/share/openocd/scripts/target/stm32wbax.cfg:45: Error: 
      in procedure 'script' 
      at file "embedded:startup.tcl", line 28
      at file "/home/jan/Projekte/Experimente/Elektronik/stm32wba52cg-test/openocd.cfg", line 11
      at file "/usr/share/openocd/scripts/target/stm32wbax.cfg", line 45
      GDB Server stopped, exit code 1
      

      Using this config file:

      #
      # Configuration for STM32WBA52 Nucleo board (STM32WBA52CG)
      #
      
      source [find interface/stlink.cfg]
      
      transport select hla_swd
      
      source [find target/stm32wbax.cfg]
      
      reset_config srst_only
      
       
    • Jan Henke

      Jan Henke - 2023-05-31

      Changing the ap-num in the cfg file manually to 0 yields another error:

      /usr/bin/openocd -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -s /usr/share/openocd/scripts -f /home/jan/Projekte/Experimente/Elektronik/stm32wba52cg-test/openocd.cfg -c "init;reset init;" -c "echo (((READY)))"
      Open On-Chip Debugger 0.12.0
      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
      srst_only separate srst_nogate srst_open_drain connect_deassert_srst
      
      Info : clock speed 500 kHz
      Info : STLINK V3J11M3B5S1 (API v3) VID:PID 0483:374F
      Info : Target voltage: 3.312922
      Warn : UNEXPECTED idcode: 0x0be12477
      Error: expected 1 of 1: 0x6ba02477
      
      
      GDB Server stopped, exit code 1
      
      Process finished with exit code 0
      
       
  • Tarek BOCHKATI

    Tarek BOCHKATI - 2023-05-31

    I see that you are using "interface/stlink.cfg"
    we recommend using "interface/stlink-dap.cfg" to work with cortex-M33 on Access Port != 0

     
    • Jan Henke

      Jan Henke - 2023-05-31

      I did not know that, switching to dap interface got more output, but still an error:

      /usr/bin/openocd -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -s /usr/share/openocd/scripts -f /home/jan/Projekte/Experimente/Elektronik/stm32wba52cg-test/openocd.cfg -c "init;reset init;" -c "echo (((READY)))"
      Open On-Chip Debugger 0.12.0
      Licensed under GNU GPL v2
      For bug reports, read
          http://openocd.org/doc/doxygen/bugs.html
      srst_only separate srst_nogate srst_open_drain connect_deassert_srst
      
      Info : STLINK V3J11M3B5S1 (API v3) VID:PID 0483:374F
      Info : Target voltage: 3.273161
      Info : Unable to match requested speed 500 kHz, using 200 kHz
      Info : Unable to match requested speed 500 kHz, using 200 kHz
      Info : clock speed 200 kHz
      Info : stlink_dap_op_connect(connect)
      Info : SWD DPIDR 0x0be12477
      Error: [stm32wbax.cpu] Cortex-M PARTNO 0x0 is unrecognized
      Warn : target stm32wbax.cpu examination failed
      Info : starting gdb server for stm32wbax.cpu on 3333
      Info : Listening on port 3333 for gdb connections
      Error: [stm32wbax.cpu] Cortex-M PARTNO 0x0 is unrecognized
      Error: [stm32wbax.cpu] Cortex-M PARTNO 0x0 is unrecognized
      Error: [stm32wbax.cpu] Cortex-M PARTNO 0x0 is unrecognized
      TARGET: stm32wbax.cpu - Not examined
      GDB Server stopped, exit code 1
      
       
      • Jan Henke

        Jan Henke - 2023-05-31

        Sorry my bad, I still had the cfg file edited, with ap_num 1 we get further, still not entirely happy:

        /usr/bin/openocd -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -s /usr/share/openocd/scripts -f /home/jan/Projekte/Experimente/Elektronik/stm32wba52cg-test/openocd.cfg -c "init;reset init;" -c "echo (((READY)))"
        Open On-Chip Debugger 0.12.0
        Licensed under GNU GPL v2
        For bug reports, read
            http://openocd.org/doc/doxygen/bugs.html
        srst_only separate srst_nogate srst_open_drain connect_deassert_srst
        
        Info : STLINK V3J11M3B5S1 (API v3) VID:PID 0483:374F
        Info : Target voltage: 3.244533
        Info : Unable to match requested speed 500 kHz, using 200 kHz
        Info : Unable to match requested speed 500 kHz, using 200 kHz
        Info : clock speed 200 kHz
        Info : stlink_dap_op_connect(connect)
        Info : SWD DPIDR 0x0be12477
        Info : [stm32wbax.cpu] Cortex-M33 r0p4 processor detected
        Info : [stm32wbax.cpu] target has 8 breakpoints, 4 watchpoints
        Info : starting gdb server for stm32wbax.cpu on 3333
        Info : Listening on port 3333 for gdb connections
        [stm32wbax.cpu] halted due to debug-request, current mode: Thread 
        xPSR: 0xf9000000 pc: 0x08029ff8 msp: 0x20001000
        (((READY)))
        Info : tcl server disabled
        Info : Listening on port 4444 for telnet connections
        Info : accepting 'gdb' connection on tcp/3333
        Error: Failed to read memory at 0x40015800
        Info : device idcode = 0x10006492 (STM32WBA5x - Rev A : 0x1000)
        Info : TZEN = 0 : TrustZone disabled by option bytes
        Info : RDP level 0 (0xAA)
        Info : flash size = 1024 KiB
        Info : flash mode : single-bank
        Error: Failed to read memory at 0x40015800
        Info : device idcode = 0x10006492 (STM32WBA5x - Rev A : 0x1000)
        Info : TZEN = 0 : TrustZone disabled by option bytes
        Info : RDP level 0 (0xAA)
        Error: invalid bank base address
        Error: auto_probe failed
        Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
        Error: attempted 'gdb' connection rejected
        com.jetbrains.cidr.execution.debugger.backend.gdb.GDBDriver$GDBCommandException: Remote connection closed
        Debugger disconnected
        
        Process finished with exit code 0
        GDB Server stopped, exit code 137
        
         
  • Jan Henke

    Jan Henke - 2023-06-04

    To verbalize the last post: With the change I was able to flash my MCU, but I cannot attach a debugger. Can you look into why the debugging does not work?

     
    • Tommy Murphy

      Tommy Murphy - 2023-06-04

      You should post (attach) a verbose OpenOCD log for the failed attempt to debug to assist with investigation. Use openocd -d3 ... to get the verbose log.

       
  • Jan Henke

    Jan Henke - 2023-06-04

    Attached is the debug log. Thank you for looking into it.

     
    • Tommy Murphy

      Tommy Murphy - 2023-06-08

      Thanks - these seem to be the key errors in the verbose log file:

      Line 357: Error: 308 224554 arm_adi_v5.c:570 mem_ap_read(): Failed to read memory at 0x40015800
      Line 370: Error: 321 224559 arm_adi_v5.c:570 mem_ap_read(): Failed to read memory at 0x40015800
      Line 377: Error: 328 224560 stm32l4x.c:1851 stm32l4_probe(): invalid bank base address
      Line 378: Error: 329 224560 core.c:291 get_flash_bank_by_num(): auto_probe failed
      Line 379: Error: 330 224560 gdb_server.c:1061 gdb_new_connection(): Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
      Line 380: Error: 331 224560 server.c:94 add_connection(): attempted 'gdb' connection rejected
      

      So it would make sense to drill into these in more detail first.

       

      Last edit: Tommy Murphy 2023-06-08
      • Jan Henke

        Jan Henke - 2023-06-23

        Hi,

        were you able to make some progress on this issue?

        Best regards,
        Jan Henke

         
  • Jan Henke

    Jan Henke - 2023-07-23

    Would it be possible to get the changes merged? Being able to upload is better then nothing, even if debugging is still broken.

     
    • Tommy Murphy

      Tommy Murphy - 2023-07-23

      OpenOCD is open-source so anybody is free to submit changes for consideration and inclusion. Including any changes in the STM fork - or any other fork. Of course, it would be nice if STM would do this themselves (and maybe they do from time to time?) but it's open to anybody else, in particular stakeholders in the STM mods, to do this unilaterally. Why not contact STM ask them if/when they might upstream the changes in their fork?

      Edit: I just noticed this:

      STMicroelectronics is actively working at merging these modifications in the official OpenOCD. In the mean time, these modifications are available in this repository.

      And I see that you did contact them here but got no response so far:

       

      Last edit: Tommy Murphy 2023-07-23
      • Jan Henke

        Jan Henke - 2023-07-23

        I already did contact them (https://github.com/STMicroelectronics/OpenOCD/issues/20), but there is zero activity from STM to this issue.
        I am also referring to an open change set here: https://review.openocd.org/c/openocd/+/7694
        I tested it and it allows flashing the device. Attaching a debugger unfortunately does not work (see debug logs above). Therefore I was hoping the patch's original author could look into why debugging does not work. But alas since there is no activity at all, I would prefer to add at least the flashing ability.

         
  • Tommy Murphy

    Tommy Murphy - 2023-07-23

    I am also referring to an open change set here: https://review.openocd.org/c/openocd/+/7694

    Maybe if you post review feedback on that change set it might help?
    As far as I can see nobody has reviewed it so that may be one reason why it's lying dormant.

     
    • Jan Henke

      Jan Henke - 2023-07-23

      I am simply not familiar enough with the codebase to give a meaningful review. So far I have been a user only.

       
  • Tomas Vanek

    Tomas Vanek - 2023-07-23

    Tarek wrote 2 moths ago:

    please test using this patch
    https://review.openocd.org/c/openocd/+/7694

    But I see in all logs:
    Open On-Chip Debugger 0.12.0

    instead of
    Open On-Chip Debugger 0.12.0+dev-00xxx-gd3949b4af339

    Jan,
    testing a patched config file with an unpatched release OpenOCD binary has no value for us
    and the reported error likely originates here.

    Please recompile OpenOCD from source
    git fetch https://review.openocd.org/openocd refs/changes/94/7694/2 && git checkout FETCH_HEAD
    and retry.

     
    • Jan Henke

      Jan Henke - 2023-07-24

      Hi,
      I am using Gentoo, so everything is compiled from source. I have added the patch from https://review.openocd.org/c/openocd/+/7694 to my user patches and reemerged (recompiled) the package. So the changes are included, even if the version does not change it.

       
    • Jan Henke

      Jan Henke - 2023-07-24

      For the sake of the argument I recompiled from Git master + the patch from https://review.openocd.org/c/openocd/+/7694.

      Attached you find the debug log with the same problem

       
  • Tomas Vanek

    Tomas Vanek - 2023-07-24

    There seems to be a mismatch in OTP bank address.
    Could you try comment out OTP definition in tcl/target/stm32wbax.cfg
    # flash bank $_CHIPNAME.otp stm32l4x 0x1fff7000 0 0 0 $_TARGETNAME

    It should allow gdb attach.

     
    • Jan Henke

      Jan Henke - 2023-07-24

      Thanks, that worked indeed. Is that line necessary for anything?

      It would be great to get this patch into the next release, as it seems to be working with that line commented out.

       
1 2 > >> (Page 1 of 2)

Log in to post a comment.

MongoDB Logo MongoDB