Skip to content

Commit 99860e7

Browse files
jsbatchcfriedt
authored andcommitted
soc: infineon: cyw20829: Adding MPU memory permission to userspace app
Adds additional MPU memory permissions to userspace applications by default. This change addresses an MPU fault encountered when running tests/kernel/common and tests/drivers/adc/adc_api. This approach opens additional memory locations up to user space access. This assumes that end users of applications will tune the MPU regions for the needs of that application. Signed-off-by: John Batch <[email protected]>
1 parent a39285b commit 99860e7

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

dts/arm/infineon/cat1b/cyw20829/cyw20829.dtsi

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545
reg = <0x20000000 SRAM0_SIZE>;
4646

4747
/* SRAM aliased address path */
48-
sram_sahb: sram_bus_alias@20000000 {
48+
sram_sahb: sram_sahb@20000000 {
4949
reg = <0x20000000 SRAM0_SIZE>; /* SAHB address */
5050
};
5151

52-
sram_cbus: sram_bus_alias@4000000 {
52+
sram_cbus: sram_cbus@4000000 {
5353
reg = <0x04000000 SRAM0_SIZE>; /* CBUS address */
5454
};
5555
};
@@ -59,9 +59,20 @@
5959
* (e.g. 0x20000000 + 0x40000 - 12K (0x3000) = 0x2003D000)
6060
*/
6161
sram_bootstrap: memory@2003D000 {
62+
#address-cells = <1>;
63+
#size-cells = <1>;
6264
compatible = "zephyr,memory-region", "mmio-sram";
6365
zephyr,memory-region = "BOOTSTRAP_RAM";
6466
reg = <0x2003D000 BOOTSTRAP_SIZE>;
67+
68+
/* SRAM aliased address path */
69+
sram_bootstrap_sahb: sram_bootstrap_sahb@2003D000 {
70+
reg = <0x2003D000 BOOTSTRAP_SIZE>; /* SAHB address */
71+
};
72+
73+
sram_bootstrap_cbus: sram_bootstrap_cbus@403D000 {
74+
reg = <0x0403D000 BOOTSTRAP_SIZE>; /* CBUS address */
75+
};
6576
};
6677

6778
qspi_flash: qspi_flash@40890000 {

soc/infineon/cat1b/cyw20829/mpu_regions.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
#include <zephyr/devicetree.h>
88
#include <zephyr/arch/arm/cortex_m/arm_mpu_mem_cfg.h>
99

10-
#define BOOTSTRAP_RAM_BASE_ADDRESS DT_REG_ADDR(DT_NODELABEL(sram_bootstrap))
11-
#define BOOTSTRAP_RAM_SIZE DT_REG_SIZE(DT_NODELABEL(sram_bootstrap))
10+
#define BOOTSTRAP_SAHB_RAM_BASE_ADDRESS DT_REG_ADDR(DT_NODELABEL(sram_bootstrap_sahb))
11+
#define BOOTSTRAP_CBUS_RAM_BASE_ADDRESS DT_REG_ADDR(DT_NODELABEL(sram_bootstrap_cbus))
12+
#define BOOTSTRAP_RAM_SIZE DT_REG_SIZE(DT_NODELABEL(sram_bootstrap))
1213

1314
#define REGION_BOOTSTRAP_RAM_ATTR(base, size) \
1415
{ \
@@ -24,8 +25,13 @@ static const struct arm_mpu_region mpu_regions[] = {
2425
MPU_REGION_ENTRY("SRAM", CONFIG_SRAM_BASE_ADDRESS,
2526
REGION_RAM_ATTR(CONFIG_SRAM_BASE_ADDRESS, CONFIG_SRAM_SIZE * 1024)),
2627

27-
MPU_REGION_ENTRY("BOOTSTRAP_RAM", BOOTSTRAP_RAM_BASE_ADDRESS,
28-
REGION_BOOTSTRAP_RAM_ATTR(BOOTSTRAP_RAM_BASE_ADDRESS, BOOTSTRAP_RAM_SIZE)),
28+
MPU_REGION_ENTRY(
29+
"BOOTSTRAP_SAHB_RAM", BOOTSTRAP_SAHB_RAM_BASE_ADDRESS,
30+
REGION_BOOTSTRAP_RAM_ATTR(BOOTSTRAP_SAHB_RAM_BASE_ADDRESS, BOOTSTRAP_RAM_SIZE)),
31+
32+
MPU_REGION_ENTRY(
33+
"BOOTSTRAP_CBUS_RAM", BOOTSTRAP_CBUS_RAM_BASE_ADDRESS,
34+
REGION_BOOTSTRAP_RAM_ATTR(BOOTSTRAP_CBUS_RAM_BASE_ADDRESS, BOOTSTRAP_RAM_SIZE)),
2935
};
3036

3137
const struct arm_mpu_config mpu_config = {

0 commit comments

Comments
 (0)