Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT __main
IMPORT SystemInit
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
运行到“BX R0”这里就不执行了。
原因找到了,特发此转过来~
因printf()之类的函数,使用了半主机模式。使用微库的话,不会使用半主机模式,所以就没有问题。
添加下面代码,就可以使用标准库了:
#pragma import(__use_no_semihosting)
_sys_exit(int x)
{
x = x;
}
struct __FILE
{
int handle;
/* Whatever you require here. If the only file you are using is */
/* standard output using printf() for debugging, no file handling */
/* is required. */
};
/* FILE is typedef’ d in stdio.h. */
FILE __stdout;
这个问题可以在"RealView? 编译工具库和浮点支持指南"书中找到。。
EXPORT Reset_Handler [WEAK]
IMPORT __main
IMPORT SystemInit
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
运行到“BX R0”这里就不执行了。
原因找到了,特发此转过来~
因printf()之类的函数,使用了半主机模式。使用微库的话,不会使用半主机模式,所以就没有问题。
添加下面代码,就可以使用标准库了:
#pragma import(__use_no_semihosting)
_sys_exit(int x)
{
x = x;
}
struct __FILE
{
int handle;
/* Whatever you require here. If the only file you are using is */
/* standard output using printf() for debugging, no file handling */
/* is required. */
};
/* FILE is typedef’ d in stdio.h. */
FILE __stdout;
这个问题可以在"RealView? 编译工具库和浮点支持指南"书中找到。。
本文介绍了在STM32开发中遇到的一个问题,即程序在执行到`BX R0`指令后停止运行。原因在于使用了半主机模式的printf等函数,而微库不支持半主机模式。通过添加`#pragma import(__use_no_semihosting)`并定义 `_sys_exit` 和 `__stdout`,可以解决标准库使用的问题,从而让程序正常运行。
2万+





