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


STM32H7 strcat bug

Hello.
I was wondering about a Hard Fault.
Stepping through I notice strcat() uses the string content as the address for the destination.
In the function there is an extra command
ldr r0, [[r3, #0]] (why?)
to load the content from the address, instead of using a simple
mov r0, r3

Bildschirmfoto 2018 02 11 Um 15.10.59

Thank you.

France

Hi,

There’s no bug in strcat; the line you don’t understand loads the first 4 bytes from PCC_VERSION (“2.08”) then stores them at the end of msgStr (r2 contains the length of msgStr, that is the number of bytes before the first zero-byte in msgStr).

Strcat is effectively a dangerous function for two reasons:

  1. You may overflow the destination buffer, as strcat can’t make any check
  2. If ever the destination string was not initialized, the initial strlen may yield a very big value and you will write somewhere where you don’t expect...


So I urge you to check your code, but I can ensure you the strcat code is correct...

Hope this helps,

Bernard (Ac6)

You are right. I read STR in the wrong way.
And I found the reason of the hard fault:
In MPU_Config there was a mistyped size of MPU_REGION_SIZE_512MB
instead of MPU_REGION_SIZE_512KB. The area where strcat() has to
copy the data to was protected.
I’m sorry for the inconvenience.


 

Newest Forum Posts

  1. reservation car service Seattle by Jamesprede, 2025-05-01 10:06
  2. Last day: drone bonus by Danielrug, 2025-04-19 16:55
  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. Insightful Perspectives on This Subject by davidsycle, 2025-03-04 05:45
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  10. Build a project in "release" mode by tang, 2025-02-20 10:36

Last-Modified Blogs