sprintf hardfault while using format specifier.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

sprintf hardfault while using format specifier.

ソリューションへジャンプ
2,099件の閲覧回数
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 解決策
2,063件の閲覧回数
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 返答(返信)
2,064件の閲覧回数
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 件の賞賛
返信
2,071件の閲覧回数
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 件の賞賛
返信
2,080件の閲覧回数
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

2,091件の閲覧回数
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?