2024-09-13 06:50 AM
Hello, everyone.
I have a problem on which I am seeking advice and opinions for a possible solution.
I am making an application with the STM32H7S78-dk board and TouchGFX. A very simple thing, imagine a page with a background image and a button, same for page 2. By pressing a button I move between pages.
What I want to do is read an image from the SD card (I have already managed to configure reading and writing a file correctly) and display it on the screen on one of the two pages, let's take page 2 as an example.
I have almost succeeded but with some basic problems.
My method was to have TouchGFX allocate an image of the size I wanted in the External Flash and through this code in the image.cpp file change its location.
LOCATION_PRAGMA(‘MyImage’) //RAM
KEEP extern unsigned char image_saname[] LOCATION_ATTRIBUTE(‘MyImage’) = { ...
Where this area called MyImage that has been allocated in the external RAM section in the LD file like this:
BufferSection(NOLOAD) :
{
*(TouchGFX_Framebuffer TouchGFX_Framebuffer.*)
*(.gnu.linkonce.r.*)
. = ALIGN(0x8);
*(Nemagfx_Stencil_Buffer Nemagfx_Stencil_Buffer.*)
*(.gnu.linkonce.r.*)
. = ALIGN(0x8);
*(MyImage MyImage.*)
*(.gnu.linkonce.r.*)
. = ALIGN(0x8);
} >EXTRAM
Having done this within the task that regulates the SD card, I went to read bit by bit of my 565 bitmap image on the SD card and overwritten the image created by TouchGFX.
This works because I can see this image on the page I'm interested in but after a bit of switching between pages by pressing the buttons I get a HardFault_Handler() back.
I can't figure out if there is a problem because TouchGFX doesn't know that that image is actually in the external RAM so that every time the page is reloaded it doesn't clean the memory correctly.
Or I can't tell if it's a task conflict problem
Thanks
2024-09-13 07:04 AM - edited 2024-09-13 07:05 AM
Hello,
@Leo99 wrote:
This works because I can see this image on the page I'm interested in but after a bit of switching between pages by pressing the buttons I get a HardFault_Handler() back.
For Hardfault debug, you need to refer to this article. Not obvious that someone here can tell you what is going on based on what you shared, as debugging "Hardfault" is a bit tricky and could be a symptom of many issues. So need a debug from your side.
2024-09-16 07:55 AM
Thanks for the advice.
I have carried out the steps set out in the link regarding debugging the HardFault and below I show the results obtained.
However, the guide is unclear in the step of obtaining the PC address from the SP address, as the address 0x2001ffcc appears in the photos and then in the memory view it disappears...
Leaving this aside, the result I find is the one shown in the results below where the entire .ld file is attached for greater clarity.
The error given seems to be related to ‘Attempt to execute a coprocessor instruction (NOCP)’ at an address where there should be nothing, i.e. 0x9BCA0170
If you have any further advice on how to get more information, I thank you.
2024-09-17 06:15 AM
Hello @Leo99 ,
Have you tried to debug it step by step, to figure out which function/line produce that Hardfault ? After how much calls do you have this hardfault or Is it random ?
I think it will give more information.
Best regards,
Louis B.
2024-09-17 06:45 AM
Hello,
Yeah, I tried the step by step debug and the last call before the hard fault is here in the line 7. Unfortunately it's quite random
void GPIO::set(GPIO_ID id)
{
switch (id)
{
case GPIO::VSYNC_FREQ:
#if defined(VSYNC_FREQ_GPIO_Port) && defined(VSYNC_FREQ_Pin)
HAL_GPIO_WritePin(VSYNC_FREQ_GPIO_Port, VSYNC_FREQ_Pin, GPIO_PIN_SET);
#endif
break;
case GPIO::RENDER_TIME:
#if defined(RENDER_TIME_GPIO_Port) && defined(RENDER_TIME_Pin)
HAL_GPIO_WritePin(RENDER_TIME_GPIO_Port, RENDER_TIME_Pin, GPIO_PIN_SET);
#endif
break;
case GPIO::FRAME_RATE:
#if defined(FRAME_RATE_GPIO_Port) && defined(FRAME_RATE_Pin)
HAL_GPIO_WritePin(FRAME_RATE_GPIO_Port, FRAME_RATE_Pin, GPIO_PIN_SET);
#endif
break;
case GPIO::MCU_ACTIVE:
#if defined(MCU_ACTIVE_GPIO_Port) && defined(MCU_ACTIVE_Pin)
HAL_GPIO_WritePin(MCU_ACTIVE_GPIO_Port, MCU_ACTIVE_Pin, GPIO_PIN_SET);
#endif
break;
}
}
2024-09-26 06:39 AM
Hello @Leo99 ,
You can try to check the memory state while debugging, to if it doesn't grows too much when you redraw it on the screen.