boards/lm3s6965-ek: Make the protected configuration fit the part. - #19837
Open
casaroli wants to merge 2 commits into
Open
boards/lm3s6965-ek: Make the protected configuration fit the part.#19837casaroli wants to merge 2 commits into
casaroli wants to merge 2 commits into
Conversation
The protected build gives the kernel the first 128 KiB of flash and the user image the second. Both halves were full. The kernel image was 132456 bytes and the user image 130668, which is 1308 bytes more than the 256 KiB the LM3S6965 has. The two images overlapped. Remove from the configuration what QEMU cannot use, and what other configurations of this board already cover: MMC/SD over SPI with SSI0, because the QEMU model has no SSI; semihosting hostfs; the GPIO interrupt ports, which no driver in this configuration uses; and the wget example with its web client. The kernel image is now 124580 bytes and the user image 125500. Each half has more than 5 KiB free. Assisted-by: Claude Code:claude-opus-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
In a protected build the kernel must stay in the flash half that memory.ld gives it. ARCHSCRIPT selected ld.script, which declares the whole 256 KiB of flash as one region, so nothing held the kernel to its half. The kernel image grew past the boundary unseen: its .data initialiser ran 1384 bytes into 0x00020000, where the user image is programmed. Select memory.ld and kernel-space.ld when CONFIG_BUILD_PROTECTED is set. The link now fails when the kernel does not fit. Assisted-by: Claude Code:claude-opus-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
casaroli
requested review from
acassis,
anchao,
masayuki2009,
xiaoxiang781216 and
yamt
as code owners
August 13, 2026 16:58
acassis
approved these changes
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lm3s6965-ek:qemu-protecteddoes not fit the part any more. The kernel image is 132456 bytes and the user image is 130668 bytes, which is 1308 bytes more than the 256 KiB of flash on the LM3S6965, so the kernel.datainitialiser runs 1384 bytes into 0x00020000, where the user image is programmed.Nothing reported this.
memory.ldsplits the flash in two halves and bounds the user link, butARCHSCRIPTselectedld.script, which declares the whole flash as one region, so nothing held the kernel to its half.This PR makes the configuration fit and makes the boundary enforceable. It removes what QEMU cannot use, and what other configurations of this board already cover: MMC/SD over SPI with SSI0, because the QEMU model has no SSI; semihosting hostfs; the GPIO interrupt ports, which no driver here uses; and the wget example with its web client. It then links the protected kernel against
kflash, so a kernel that does not fit is a link error.The result, measured with arm-none-eabi-gcc 14.2.rel1: kernel 132456 -> 124580 bytes, user image 130668 -> 125500 bytes. Each 128 KiB half now has more than 5 KiB free.
The split itself stays at 128 KiB / 128 KiB. The ARMv7-M MPU maps the user flash as one power-of-two region with eight sub-regions, and
mpu_subregion_ls()rounds the offset down to the sub-region grid, so a boundary off that grid would give user code read and execute access to the end of the kernel flash.apache/nuttx-apps#3685 needs this room: it builds
testing/ostest/vfork.cwhereverARCH_HAVE_VFORKis set, and that is 328 bytes the user half does not have today.Impact
Board
lm3s6965-ekonly.qemu-protectedloses the MMC/SD driver, hostfs andwget; thensh,discoverandqemu-flatconfigurations of the same board still build the MMC/SD driver.qemu-kostest, the other protected configuration of this board, is unchanged. Flat configurations still link againstld.script.Testing
Host: macOS 15.5 on Apple Silicon, arm-none-eabi-gcc 14.2.rel1.
Built
lm3s6965-ek:qemu-protected,lm3s6965-ek:qemu-kostestandlm3s6965-ek:qemu-flat, each frommake distclean.Sizes of
qemu-protectedbefore and after, fromreadelf -lW:With this branch,
qemu-protectedalso builds against apache/nuttx-apps#3685, which fails against master withregion uflash overflowed by 128 bytes.To show that the new kernel bound works, a build with
kflashset to 120 KiB reports the overflow instead of silently crossing the boundary: