sprintf hardfault while using format specifier.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

sprintf hardfault while using format specifier.

Jump to solution
1,545 Views
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

 

0 Kudos
1 Solution
1,509 Views
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.

View solution in original post

0 Kudos
4 Replies
1,510 Views
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 Kudos
1,517 Views
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 Kudos
1,526 Views
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

1,537 Views
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?