sprintf hardfault while using format specifier.

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

sprintf hardfault while using format specifier.

跳至解决方案
3,064 次查看
athmesh_n
Contributor IV

Hi,

Am using LPC1756 for my project. I have been working on the code for sometime, but recently when I added a new code for sprintf the firmware version of the project, i am getting HARDFAULT-FORCED(30),

void func(void){
char Dummy[50];
uint8_t new_rev_vers;
sprintf(Dummy,"DOWNLOADING..%hu",new_rev_vers);
}



I tried understanding the disassembly and also tried adjusting heap and stack in mcuxpresso style, which did not even start the code.

I'll share the memory consumed by the code. and the fault details.

 

athmesh_n_0-1607500694928.png

memory consumption:

athmesh_n_1-1607500793438.png

MCU details

athmesh_n_2-1607500857389.png

 

标记 (3)
0 项奖励
回复
1 解答
3,028 次查看
athmesh_n
Contributor IV

Hi,

I solved the issue, as I was using FOTA and I accidently replaced the current program sector with the latest one. This caused hardfault.

在原帖中查看解决方案

0 项奖励
回复
4 回复数
3,029 次查看
athmesh_n
Contributor IV

Hi,

I solved the issue, as I was using FOTA and I accidently replaced the current program sector with the latest one. This caused hardfault.

0 项奖励
回复
3,036 次查看
athmesh_n
Contributor IV

Hi @Alice_Yang ,
Thanks for the reply, my IDE is MCUXpresso IDE v11.1.0 [Build 3209] [2019-12-12].


Hi @converse ,
Thanks for the reply, and yes I tried with %u for uint32_t for new_rev_vers, and am using redlib -semihost.

0 项奖励
回复
3,045 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello athmesh_n,

Which version of MCUXpresso IDE you used? You can share a simple project that can reproduce your issue, we can help to check.

 

Regards,

Alice

3,056 次查看
converse
Senior Contributor V

One obvious thing (but I doubt it is causing the problem) is that %hu expects a short (16 bit) but you have defined new_rev_vers at uint8_t which is a byte (8 bits).

But, more information required:

where is the PC - which module is it in?

which library are you using - newlib, newlib-nano, or redline?