Tuesday, April 24th 2018, 6:34pm UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

shal

Beginner

Date of registration: Mar 15th 2018

Posts: 7

1

Thursday, March 15th 2018, 4:36pm

HardFalt when rendering PNG (STM32F746g disco)

Hi !
A HardFalt error occurred while drawing PNG

Source code

1
2
 pData = _GetImageById(ID_IMAGE_0_IMAGE_0, &FileSize); 
 IMAGE_SetPNG(hItem, pData, FileSize);

What could be the problem?
The program code in the attachment

I use:
STM32F746g discovery
STemWin540_CM7_IAR.a
IAR C/C++ Compiler for ARM 7.50.2.10312 (7.50.2.10312)
png and zlib libraries

Regards,
shal
shal has attached the following image:
  • slide1.PNG
shal has attached the following file:
  • arch.zip (18.1 kB - 56 times downloaded - Last download: Today, 3:02am)

Mr. Spock

Beginner

Date of registration: May 19th 2009

Posts: 22

2

Sunday, March 18th 2018, 12:10pm

Stack ?

shal

Beginner

Date of registration: Mar 15th 2018

Posts: 7

3

Monday, March 19th 2018, 10:02am

The stack size in the project is 0x2000

The PNG picture is not drawn when using Windows Manager, but using GUI_PNG_Draw() - draws.

I need to draw using WM :)

This post has been edited 1 times, last edit by "shal" (Mar 19th 2018, 10:08am)


mrohit2011

Beginner

Date of registration: Jul 1st 2017

Posts: 25

4

Thursday, March 22nd 2018, 6:05am

Hi Shal,


You have allocated 128Kb of memory for EMWIN from microcontrollers ram. (GUIConfig.c file).

//
// Define the available number of bytes available for the GUI
//
#define GUI_NUMBYTES ( 128 * 1024) //4*1024

//
// 32 bit aligned memory area
//
static __no_init U32 g_emWinMemory[GUI_NUMBYTES / 4];// @ 0xC0400000;


Try allocating it into SDRAM Space, by modifying above code as follows.
static __no_init U32 g_emWinMemory[GUI_NUMBYTES / 4] @ 0xC0400000;

shal

Beginner

Date of registration: Mar 15th 2018

Posts: 7

5

Friday, March 23rd 2018, 10:56am

I tried to allocate memory to SDRAM, this does not help, the error continues to arise.
Suspicion on incorrect operation of Memory Devices

mrohit2011

Beginner

Date of registration: Jul 1st 2017

Posts: 25

Selso

Beginner

Date of registration: Jul 19th 2017

Posts: 22

7

Wednesday, April 4th 2018, 10:26am

From what I remembered the png lib need to allocate at least 1 MB of memory (emwin replaced malloc function by emwin_alloc in the pool).
I compiled the distributed lib by segger by my own with keil, in debug mode.
I remembered that when missing memory the lib clearly pointed it out.

Also it would be interesting to send us the call stack, or try using the fault analyzer in IAR (if there is one).

shal

Beginner

Date of registration: Mar 15th 2018

Posts: 7

8

Wednesday, April 11th 2018, 11:19am

Solved!

Hello!

Thank you for your answers.

Before initializing emWin, you need to configure the MPU with the following function:


C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
static void MPU_Config() 
{
	MPU_Region_InitTypeDef MPU_InitStruct;
	
	/* Disable the MPU */
	HAL_MPU_Disable();
	
	/* Configure the MPU attributes for SDRAM */
	MPU_InitStruct.Enable = MPU_REGION_ENABLE;
	MPU_InitStruct.BaseAddress = 0xC0000000;
	MPU_InitStruct.Size = MPU_REGION_SIZE_8MB;	//MPU_REGION_SIZE_4MB;
	MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
	MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
	MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
	MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
	MPU_InitStruct.Number = MPU_REGION_NUMBER0;
	MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
	MPU_InitStruct.SubRegionDisable = 0x00;
	MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
	
	HAL_MPU_ConfigRegion(&MPU_InitStruct);
	
	/* Enable the MPU */
	HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}