Skip to main content
Explorer II
April 2, 2025
Solved

STM32F767Z: MPU Configurations for Custom Bootloader

  • April 2, 2025
  • 1 reply
  • 431 views

Hi,  I am triyng to develop custom bootloader. My application address is 0x08180000 and bootloader address is 0x08000000. I can start with the bootloader and jump to the application successfully. 

 while (1)
 {
 /* USER CODE END WHILE */

 /* USER CODE BEGIN 3 */
	 HAL_UART_Transmit(&huart1, (uint8_t *)"HELLO", strlen("HELLO"), HAL_MAX_DELAY);
	 HAL_Delay(1000);
 }

The application send "HELLO" message over UART. but when I set MPU configurations I cant see the message coming from application. Here is my MPU configuration.

void MPU_Config(void)
{
 MPU_Region_InitTypeDef MPU_InitStruct = {0};

 /* Disables the MPU */
 HAL_MPU_Disable();

 /** Initializes and configures the Region and the memory to be protected
 */
 MPU_InitStruct.Enable = MPU_REGION_ENABLE;
 MPU_InitStruct.Number = MPU_REGION_NUMBER0;
 MPU_InitStruct.BaseAddress = 0x08000000;
 MPU_InitStruct.Size = MPU_REGION_SIZE_1MB;
 MPU_InitStruct.SubRegionDisable = 0x0;
 MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
 MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
 MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
 MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
 MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
 MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;

 HAL_MPU_ConfigRegion(&MPU_InitStruct);

 /** Initializes and configures the Region and the memory to be protected
 */
 MPU_InitStruct.Number = MPU_REGION_NUMBER1;
 MPU_InitStruct.BaseAddress = 0x08180000;
 MPU_InitStruct.Size = MPU_REGION_SIZE_512KB;
 MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
 MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

 HAL_MPU_ConfigRegion(&MPU_InitStruct);

 /** Initializes and configures the Region and the memory to be protected
 */
 MPU_InitStruct.Number = MPU_REGION_NUMBER2;
 MPU_InitStruct.BaseAddress = 0x20000000;
 MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
 MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;

 HAL_MPU_ConfigRegion(&MPU_InitStruct);
 /* Enables the MPU */
 HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);

}


Why I get failure when I try to jump application? What must the MPU configuration be?

This is my application flash.ld file

/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */

_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */

/* Memories definition */
MEMORY
{
 RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K
 FLASH (rx) : ORIGIN = 0x08180000, LENGTH = 512K
}

This is my bootloader flash.ld file
 

/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */

_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */

/* Memories definition */
MEMORY
{
 RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K
 FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1536K
}

 

Can you help me to configure MPU? The reason I am setting MPU is I need to use ethernet in bootloader. I need to use MPU configurations If I want to use ethernet in stm32f767zi. And I must use it. Can you help me?  @mƎALLEm  @Andrew Neil  @TDK can you help me, guys?

    This topic has been closed for replies.
    Best answer by emirhan37

    Sorry guys, it is not about MPU configuration; I got the failure because of the system PLLQ clock mismatch between bootloader and application. You should be careful about MPU region and clock if you are facing a problem like me.

    1 reply

    emirhan37AuthorAnswer
    Explorer II
    April 3, 2025

    Sorry guys, it is not about MPU configuration; I got the failure because of the system PLLQ clock mismatch between bootloader and application. You should be careful about MPU region and clock if you are facing a problem like me.