2022-01-24 06:28 AM
My code throwing a hardfault error
in startup_stm32h743xx.s file
in
/* Call static constructors */
bl __libc_init_array
without going to
/* Call the application's entry point.*/
bl main
All constant strings are located in the .rodata segment because they are string constants.
They are located in FLASH at addresses 0x0805fd70 - 0x080603b0
If I make the number of rows smaller, say 5, then the hardfault doesn't happen.
MCU STM32H743BIT
Toolchaint gcc
GNUToolsARMEmbedded\8-2019-q3-update\bin\arm-none-eabi-gcc.exe
Platform windows-10 or linux ubuntu-20.04
Anyway.
The code:
static const char RES0[] = "РЕС0_________________________________";
static const char RES1[] = "РЕС1_________________________________";
static const char RES2[] = "РЕС2_________________________________";
static const char RES3[] = "РЕС3_________________________________";
static const char RES4[] = "РЕС4_________________________________";
static const char RES5[] = "РЕС5_________________________________";
static const char RES6[] = "РЕС6_________________________________";
static const char RES7[] = "РЕС7_________________________________";
static const char RES8[] = "РЕС8_________________________________";
static const char RES9[] = "РЕС9_________________________________";
static const char RES10[] = "РЕС10_________________________________";
static const char RES11[] = "РЕС11_________________________________";
static const char RES12[] = "РЕС12_________________________________";
static const char RES13[] = "РЕС13_________________________________";
static const char RES14[] = "РЕС14_________________________________";
static const char RES15[] = "РЕС15_________________________________";
static const char RES16[] = "РЕС16_________________________________";
static const char RES17[] = "РЕС17_________________________________";
static const char RES18[] = "РЕС18_________________________________";
static const char RES19[] = "РЕС19_________________________________";
static const char RES20[] = "РЕС20_________________________________";
static const char RES21[] = "РЕС21_________________________________";
static const char RES22[] = "РЕС22_________________________________";
static const char RES23[] = "РЕС23_________________________________";
static const char RES24[] = "РЕС24_________________________________";
static const char RES25[] = "РЕС25_________________________________";
static const char RES26[] = "РЕС26_________________________________";
static const char RES27[] = "РЕС27_________________________________";
static const char RES28[] = "РЕС28_________________________________";
static const char RES29[] = "РЕС29_________________________________";
static const char RES30[] = "РЕС30_________________________________";
static const char RES31[] = "РЕС31_________________________________";
static const char RES32[] = "РЕС32_________________________________";
static const char RES33[] = "РЕС33_________________________________";
static const char RES34[] = "РЕС34_________________________________";
static const char RES35[] = "РЕС35_________________________________";
static const char RES36[] = "РЕС36_________________________________";
static const char RES37[] = "РЕС37_________________________________";
static const char RES38[] = "РЕС38_________________________________";
static const char RES39[] = "РЕС39_________________________________";
static const char RES40[] = "РЕС40_________________________________";
char s[200];
void func(char* s, uint16_t code)
{
switch(code)
{
case 0:
strcpy(s, RES0);
break;
case 1:
strcpy(s, RES1);
break;
case 2:
strcpy(s, RES2);
break;
case 3:
strcpy(s, RES3);
break;
case 4:
strcpy(s, RES4);
break;
case 5:
strcpy(s, RES5);
break;
case 6:
strcpy(s, RES6);
break;
case 7:
strcpy(s, RES7);
break;
case 8:
strcpy(s, RES8);
break;
case 9:
strcpy(s, RES9);
break;
case 10:
strcpy(s, RES10);
break;
case 11:
strcpy(s, RES11);
break;
case 12:
strcpy(s, RES12);
break;
case 13:
strcpy(s, RES13);
break;
case 14:
strcpy(s, RES14);
break;
case 15:
strcpy(s, RES15);
break;
case 16:
strcpy(s, RES16);
break;
case 17:
strcpy(s, RES17);
break;
case 18:
strcpy(s, RES18);
break;
case 19:
strcpy(s, RES19);
break;
case 20:
strcpy(s, RES20);
break;
case 21:
strcpy(s, RES21);
break;
case 22:
strcpy(s, RES22);
break;
case 23:
strcpy(s, RES23);
break;
case 24:
strcpy(s, RES24);
break;
case 25:
strcpy(s, RES25);
break;
case 26:
strcpy(s, RES26);
break;
case 27:
strcpy(s, RES27);
break;
case 28:
strcpy(s, RES28);
break;
case 29:
strcpy(s, RES29);
break;
case 30:
strcpy(s, RES30);
break;
case 31:
strcpy(s, RES31);
break;
case 32:
strcpy(s, RES32);
break;
case 33:
strcpy(s, RES33);
break;
case 34:
strcpy(s, RES34);
break;
case 35:
strcpy(s, RES35);
break;
case 36:
strcpy(s, RES36);
break;
case 37:
strcpy(s, RES37);
break;
case 38:
strcpy(s, RES38);
break;
case 39:
strcpy(s, RES39);
break;
case 40:
strcpy(s, RES40);
break;
}
}
2022-01-24 09:39 AM
You can step through in disassembly to get more info or view SCB registers to find the reason for the fault.
Nothing you’ve shown seems problematic. The fact that it doesn’t fault with less data may not be relevant.
2022-01-24 11:09 AM
Using C++ ? Do you have constructors?
Is it binding the right library code? ie not binding 32-bit ARM code
Generate a disassembly listing file of what you're trying to run, or show code in debugger screen.
Look at .MAP file generated by the linker.
Comment out the call.
2022-01-28 11:38 AM
I use C++ a lot and (new() to SDRAM) (but never delete)
The project is 3 years old. So far there have been no problems with startup
You seem to think that ARM instructions are used at startup even though only Thumb is allowed.
Yes. I created *.map and *.list files
I'm Passed startup assembler code
So far without success.
In any case, thank you very much.
The problem is somewhere around.
And your answer is very helpful
2022-01-28 04:14 PM
> The project is 3 years old. So far there have been no problems with startup
Have you compared your current code against the old working version to find what changed?
2022-01-28 05:06 PM
Hard to guess from here without assembler code and registers to look at.
If its in the constructors, assume its probably a memory allocation thing or source/destination for the copy operation, or expectation in the constructors themselves.
Might need to step through the constructor calls, see if you can narrow it down a bit.
2022-02-04 11:19 AM
The source of the error has been found.
I used for programming and debugging openocd-0.10.0.13
and use stm32h7x.cfg
This script ignores the second bank of the MCU Flash memory.
Since the firmware has recently become more than 1024k, this script is unusable to load *.elf, *.bin and debug correctly.
Need use stm32h7x_dual_bank.cfg
Thus the problem is solved!