Skip to content

Commit d1ff4f6

Browse files
committed
[bsp][stm32] Add mprotect static region for F407ZGT6
Add a reference implementation of the static MPU region for the STM32F407ZGT6 BSP, guarded by RT_USING_MEM_PROTECTION so it is not enabled by default. - board.h: include rtthread.h and define NUM_STATIC_REGIONS. - board.c: define static_regions[] marking the Flash region read-only.
1 parent 67adfc9 commit d1ff4f6

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

bsp/stm32/stm32f407-fk407m2-zgt6/board/board.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111
#include <board.h>
1212
#include <drv_common.h>
1313

14+
#ifdef RT_USING_MEM_PROTECTION
15+
#include "mprotect.h"
16+
17+
rt_mem_region_t static_regions[NUM_STATIC_REGIONS] = {
18+
/* Flash region, read only */
19+
{
20+
.start = (void *)STM32_FLASH_START_ADRESS,
21+
.size = (rt_size_t)STM32_FLASH_SIZE,
22+
.attr = RT_MEM_REGION_P_RX_U_RX,
23+
},
24+
};
25+
#endif
26+
1427
void SystemClock_Config(void)
1528
{
1629
RCC_OscInitTypeDef RCC_OscInitStruct = {0};

bsp/stm32/stm32f407-fk407m2-zgt6/board/board.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#ifndef __BOARD_H__
1212
#define __BOARD_H__
1313

14+
#include <rtthread.h>
1415
#include <stm32f4xx.h>
1516

1617
#ifdef __cplusplus
@@ -37,6 +38,10 @@ extern int __bss_end;
3738

3839
#define HEAP_END STM32_SRAM_END
3940

41+
#ifdef RT_USING_MEM_PROTECTION
42+
#define NUM_STATIC_REGIONS 1
43+
#endif
44+
4045
void SystemClock_Config(void);
4146

4247
#ifdef __cplusplus

0 commit comments

Comments
 (0)