Skip to content

MPU API Increases Code Size and Cannot be Completely Removed #9007

Closed
@mattbrown015

Description

@mattbrown015

Description

Memory protection is enabled by default by MPU API #8335.

This change increased my code size by 824 bytes. The target is an STM32L442 and this is using the develop profile.

I tried to disable the MPU API but found it still added 406 bytes.

Here's a bit more detail...

| Module                                                 |        .text |    .data |      .bss |
|--------------------------------------------------------|--------------|----------|-----------|
...
| mbed-os\hal\mpu\mbed_mpu_v7m.o                         |    315(+315) |    0(+0) |     0(+0) |
...
| mbed-os\platform\mbed_mpu_mgmt.o                       |    446(+446) |    0(+0) |     4(+4) |
| Subtotals                                              | 215926(+824) | 3296(+0) | 28488(+0) |
...
Total Static RAM memory (data + bss): 31784(+0) bytes
Total Flash memory (text + data): 219222(+824) bytes

I can reduce the code size by defining MBED_MPU_CUSTOM and removing the MPU device from my custom target:

| Module                                                 |        .text |    .data |      .bss |
|--------------------------------------------------------|--------------|----------|-----------|
...
| mbed-os\hal\mpu\mbed_mpu_v7m.o                         |      0(-315) |    0(+0) |     0(+0) |    ...
...
| mbed-os\platform\mbed_mpu_mgmt.o                       |     406(-40) |    0(+0) |     4(+0) |
...
| Subtotals                                              | 215590(-336) | 3296(+0) | 28488(+0) |
Total Static RAM memory (data + bss): 31784(+0) bytes
Total Flash memory (text + data): 218886(-336) bytes

Memory protection is important but it probably should be possible to disable it and it have zero impact(?).

My original comment is here: #8335 (comment)

Issue request type

[ ] Question
[ ] Enhancement
[X] Bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions