Skip to content

Reserve address 0 by shifting ITCM start#24

Merged
mciantyre merged 2 commits into
mainfrom
itcm-nonnull
Sep 16, 2025
Merged

Reserve address 0 by shifting ITCM start#24
mciantyre merged 2 commits into
mainfrom
itcm-nonnull

Conversation

@mciantyre

Copy link
Copy Markdown
Member

The runtime previously allowed function placement at address 0 in ITCM.
However, if you ever formed a pointer to the function placed there, it
would look like a null pointer. And you would never be able to call that
function if you relied on null pointer optimization. Also, most MCU
reference manuals (RM) recommend against this placement.

This reduces the total capacity of ITCM by 32 bytes, the smallest
possible size of a MPU region. Note that this is greater than the RM's
recommendation of a four byte reservation. It affects all supported
MCUs, except the 1180. If you're so inclined, your MPU could disallow
loads, stores, and execution from this reservation.

No changes here; we're testing an existing behavior. The next commit
changes how this math works.
The runtime previously allowed function placement at address 0 in ITCM.
However, if you ever formed a pointer to the function placed there, it
would look like a null pointer. And you would never be able to call that
function if you relied on null pointer optimization. Also, most MCU
reference manuals (RM) recommend against this placement.

This commit reduces the total capacity of ITCM by 32 bytes, the smallest
possible size of a MPU region. Note that this is greater than the RM's
recommendation of a four byte reservation. It affects all supported
MCUs, except the 1180. If you're so inclined, your MPU could disallow
loads, stores, and execution from this reservation.

Revised unit tests should cover this change. Additionally, you can
manually verify that the ITCM region lengths are reduced by 32 bytes by
opening the linker scripts generated by the ELF test suite.
@mciantyre
mciantyre merged commit ce97696 into main Sep 16, 2025
7 checks passed
@mciantyre
mciantyre deleted the itcm-nonnull branch September 16, 2025 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant