Is newlib-nano thread safe?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Is newlib-nano thread safe?

跳至解决方案
584 次查看
fernando_dabadia
Contributor I

Hi,

I did a search but couldn't find reliable information.
Could someone confirm for me if the newlib-nano delivered in the MCUXpresso package is thread safe?

Sincerely,

Fernando

标签 (1)
0 项奖励
1 解答
542 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi @fernando_dabadia ,

Newlib and newlib-nano are part of the GNU ARM Embedded Toolchain distribution maintained by ARM. The IDE includes the package in unmodified binary form. Newlib requires FreeRTOS platform support to provide thread-safety. But we haven't such example.

https://community.nxp.com/t5/LPC-Microcontrollers/Newlib-none-C-exceptions-and-thread-safety/td-p/11...

https://nadler.com/embedded/NXP_newlibAndFreeRTOS.html

https://github.com/DRNadler/FreeRTOS_helpers

 

Regards,

Jing

在原帖中查看解决方案

0 项奖励
2 回复数
543 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi @fernando_dabadia ,

Newlib and newlib-nano are part of the GNU ARM Embedded Toolchain distribution maintained by ARM. The IDE includes the package in unmodified binary form. Newlib requires FreeRTOS platform support to provide thread-safety. But we haven't such example.

https://community.nxp.com/t5/LPC-Microcontrollers/Newlib-none-C-exceptions-and-thread-safety/td-p/11...

https://nadler.com/embedded/NXP_newlibAndFreeRTOS.html

https://github.com/DRNadler/FreeRTOS_helpers

 

Regards,

Jing

0 项奖励
514 次查看
fernando_dabadia
Contributor I

Hi @jing,

Thanks for the answer. I read the material recommended by you and several others that I found on the internet, in addition to performing some tests myself (which I had already done in the past). From what I could see, newlib-nano behaves the same way as newlib, when it comes to the thread-safe requirement. I had already implemented several hooks functions (even before this question) required by the newlib in addition to wrapping the malloc, malloc_r, free and free_r functions (I am using FreeRTOS and calling the pvPortMalloc and vPortFree functions in the wrap). From what I could see, the newlib's operations (printf, for example) are always using mutexes to protect events (using the hook functions I implemented).

However I still have some sporadics Hard Faults in my code, which is messing the process stack (where it points to). I'm still under investigation, in the past I had a similar problem when I was using the standard libraries without the necessary implementations for thread-safe (before I was using IAR and now GCC/MCUXpresso), that's why I posted this question, even having previously implemented what was demanded by newlib to make it thread-safe.

Thanks,

Fernando.

0 项奖励