Thursday, April 26th 2018, 9:47am 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

Friday, April 6th 2018, 2:10pm

The example from Segger does not work

Hello!
I'm studying the example MOTION_SmartFoneMenu.

This is from the package: SeggerEval_WIN32_MSVC_MinGW_GUI_V546 \ Sample \ Tutorial \ MOTION_SmartFoneMenu

After the firmware, the following error occurs in the microcontroller

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



Regards,
shal
shal has attached the following image:
  • err_MotionMenu.png

SEGGER - Martin

Super Moderator

Date of registration: Jul 1st 2014

Posts: 35

2

Friday, April 6th 2018, 6:06pm

Dear shal,

It seems the hardfault was caused by an unaligned memory access.
Does your application use the STM32F7's external SDRAM?
If so, the hardfault is probably related to the hardware's memory specifications.

This is for the reason that the STM32F7's SDRAM is mapped to 0xC0000000 - 0xC03FFFFF.
That area, however, is specified as device memory type according to the ARMv7-M architecture.
This means that all accesses to this area must be naturally aligned, whereas any unaligned access will cause a hardfault.

In case this is what causes the observed issue, there's several ways to avoid this:
- Using the STM32F7's MPU to re-configure the respective area to normal memory type instead of device memory type.
- Remapping the SDRAM to a different address.
- Preventing the compiler from generating any unaligned accesses.

Best regards,
Martin

shal

Beginner

Date of registration: Mar 15th 2018

Posts: 7

3

Wednesday, April 11th 2018, 10:41am

Solved!

Hello!

Thank you for your reply! :)

The solution is as follows:

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);
}

This post has been edited 1 times, last edit by "shal" (Apr 11th 2018, 10:47am)