如果不使用微库,使用C标准库的话,RTX5会在堆栈初始化阶段就开启了
通过C库的API也会使用互斥信号量等:
// C/C++ Standard Library Multithreading Interface
// ===============================================
#if ( !defined(RTX_NO_MULTITHREAD_CLIB) && \
( defined(__CC_ARM) || \
(defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))) && \
!defined(__MICROLIB))
#define LIBSPACE_SIZE 96
//lint -esym(714,__user_perthread_libspace,_mutex_*) "Referenced by C library"
//lint -esym(765,__user_perthread_libspace,_mutex_*) "Global scope"
//lint -esym(9003, os_libspace*) "variables 'os_libspace*' defined at module scope"
// Memory for libspace
static uint32_t os_libspace \
__attribute__((section(".bss.os.libspace")));
// Thread IDs for libspace
static osThreadId_t os_libspace_id \
__attribute__((section(".bss.os.libspace")));
// Check if Kernel has been started
static uint32_t os_kernel_is_active (void) {
static uint8_t os_kernel_active = 0U;
if (os_kernel_active == 0U) {
if (osKernelGetState() > osKernelReady) {
os_kernel_active = 1U;
}
}
return (uint32_t)os_kernel_active;
}
// Provide libspace for current thread
void *__user_perthread_libspace (void);
void *__user_perthread_libspace (void) {
osThreadId_t id;
uint32_t n;
if (os_kernel_is_active() != 0U) {
id = osThreadGetId();
for (n = 0U; n < (uint32_t)OS_THREAD_LIBSPACE_NUM; n++) {
if (os_libspace_id == NULL) {
os_libspace_id = id;
}
if (os_libspace_id == id) {
break;
}
}
if (n == (uint32_t)OS_THREAD_LIBSPACE_NUM) {
(void)osRtxErrorNotify(osRtxErrorClibSpace, id);
}
} else {
n = OS_THREAD_LIBSPACE_NUM;
}
//lint -e{9087} "cast between pointers to different object types"
return (void *)&os_libspace;
}
// Mutex identifier
typedef void *mutex;
//lint -save "Function prototypes defined in C library"
//lint -e970 "Use of 'int' outside of a typedef"
//lint -e818 "Pointer 'm' could be declared as pointing to const"
// Initialize mutex
__USED
int _mutex_initialize(mutex *m);
int _mutex_initialize(mutex *m) {
int result;
*m = osMutexNew(NULL);
if (*m != NULL) {
result = 1;
} else {
result = 0;
(void)osRtxErrorNotify(osRtxErrorClibMutex, m);
}
return result;
}
// Acquire mutex
__USED
void _mutex_acquire(mutex *m);
void _mutex_acquire(mutex *m) {
if (os_kernel_is_active() != 0U) {
(void)osMutexAcquire(*m, osWaitForever);
}
}
// Release mutex
__USED
void _mutex_release(mutex *m);
void _mutex_release(mutex *m) {
if (os_kernel_is_active() != 0U) {
(void)osMutexRelease(*m);
}
}
// Free mutex
__USED
void _mutex_free(mutex *m);
void _mutex_free(mutex *m) {
(void)osMutexDelete(*m);
}
//lint -restore
#endif
硬汉大哥, 不使用微库,实用标准库,对RTX5来说有什么影响没有 ?
morning_enr6U 发表于 2019-8-17 11:23
硬汉大哥, 不使用微库,实用标准库,对RTX5来说有什么影响没有 ?
对RTX5没有影响。那个FlasFS要用C标准库 感谢,硬汉的解答,谢谢!:P 跑rtos2 的 CMSIS_5-5.9.0\CMSIS\RTOS2\RTX\Examples\Blinky
1. 用c库,调试可以跑起来;直接下到板子上,就卡死了
2. 用microlib,调试和下到板子都正常
不知道是怎么回事? cdmar79 发表于 2023-10-15 21:46
跑rtos2 的 CMSIS_5-5.9.0\CMSIS\RTOS2\RTX\Examples\Blinky
1. 用c库,调试可以跑起来;直接下到板子上, ...
发现是c库模式,下到板子后,printf函数失效,没打印东西,以为卡死了
但是很奇怪,单步调试可以打印的 cdmar79 发表于 2023-10-15 21:46
跑rtos2 的 CMSIS_5-5.9.0\CMSIS\RTOS2\RTX\Examples\Blinky
1. 用c库,调试可以跑起来;直接下到板子上, ...
此贴方法解决即可。
使用MDK RTE可以方便的随意切换微库和C标准库
https://www.armbbs.cn/forum.php?mod=viewthread&tid=100641&fromuid=58
(出处: 硬汉嵌入式论坛)
eric2013 发表于 2023-10-16 07:35
此贴方法解决即可。
使用MDK RTE可以方便的随意切换微库和C标准库
可以解决:victory:
另有一问,是否有运行时计算当前程序体(flash)文件大小的办法(也就是静态的bin文件大小,怎么在运行时可以算出/获取到) cdmar79 发表于 2023-10-16 12:15
可以解决
另有一问,是否有运行时计算当前程序体(flash)文件大小的办法(也就是静态的bin ...
MDK编程完成后,批处理自动计算是否满足需求。
页:
[1]