Skip to content

STM32WLE5JC: Add board configuration#129

Open
tyler-potyondy wants to merge 2 commits into
tock:masterfrom
tyler-potyondy:ents-board-config
Open

STM32WLE5JC: Add board configuration#129
tyler-potyondy wants to merge 2 commits into
tock:masterfrom
tyler-potyondy:ents-board-config

Conversation

@tyler-potyondy

Copy link
Copy Markdown
Contributor

Overview

This PR adds support for the STM32WLE5JC SoC (found on the Seeed Studio LoRa E5 dev board) via an STLink. This accompanies tock/tock#4695.

OpenOCD Changes

When initially adding this board, tockloader caused a number of bus faults that arose from attempting to read/write past the end of flash. I am not entirely sure why this has not come up before. My guess is that this has something to do with the lack of an OpenOCD board specific configuration for the stm32wle5jc. OpenOCD only has a target config (different than board config) for the stm32wle5xx (which can be a few different lengths for flash).

Quickly looking, it appears the other boards using OpenOCD have an OpenOCD board specific config (not just a target). Long story short, I bubbled up errors when attempting to r/w past the end of flash and added some exception handling to gracefully handle when this happens. Someone with a better understanding of OpenOCD/tockloader should sanity check this to make sure these changes are in fact necessary as this impacts all OpenOCD functionality, albeit minor.

@bradjc

bradjc commented Jan 29, 2026

Copy link
Copy Markdown
Contributor

I'm guessing it's a combination of we never actually try to read/write past the end of flash and openocd generally handles the issue rather than causing errors.

I think it is valid for tockloader to not try to write apps beyond the end of flash.

I'm less sure about what should happen to writes and reads beyond flash; I think it's probably fine to handle those the same we do today and make it a board/openocd/user problem.

Can we make this PR just the second commit, and work on the end of flash issue separately? I think if tockloader is to check that apps are going to far it needs to know where the end should be, and that should be set in tockloader.py. I'm happy to work on this.

@tyler-potyondy
tyler-potyondy force-pushed the ents-board-config branch 2 times, most recently from 42d301b to 291f8e5 Compare January 31, 2026 00:55
@tyler-potyondy

Copy link
Copy Markdown
Contributor Author

Sounds good, I just dropped the other commit.

Looks like black is failing for some reason. I couldn't recreate this locally until updating black to 26.1.0. The failure is in tab.py which I'm not modifying.

It looks like Leon's PR also picked up this formatting issue but he checked in the tab.py formatting fix. Let me know if I should open a separate PR for that fix.

@lschuermann

lschuermann commented Jan 31, 2026

Copy link
Copy Markdown
Member

It looks like Leon's PR also picked up this formatting issue but he checked in the tab.py formatting fix. Let me know if I should open a separate PR for that fix.

So, I just squashed the formatting fixes into my commit, and I didn't realize those were also touching code that I didn't change. I'll merge this in with another PR and then we can both rebase. :)

Edit: @tyler-potyondy if you rebase on master, the CI should turn green now!

This adds the stm32wle5jc chip used in the seeed_studio_lora-E5-HF dev
board to tockloader's known board list. Communication intended to occur
using stlink over openocd.
@tyler-potyondy

Copy link
Copy Markdown
Contributor Author

Sorry for the delay circling back to this! Just rebased on master and CI is good now.

@alevy
alevy force-pushed the ents-board-config branch from e3491c3 to b992d90 Compare July 8, 2026 19:19
@alevy
alevy force-pushed the ents-board-config branch from b992d90 to 1fe0156 Compare July 8, 2026 19:37
@tyler-potyondy

Copy link
Copy Markdown
Contributor Author

Talking more with @ppannuto and @jmadden173 about this, it seems we should use the attribute table feature in the kernel for the app flash start.

We have been optimizing the kernel size to fit on the somewhat small stm32wle5jc boards, which in turn has resulted in the app start changing and breaking this branch's tockloader functionality.

All this is to say, let's block merging this until we update to pickup the attribute table.

@alevy

alevy commented Jul 17, 2026

Copy link
Copy Markdown
Member

And what @tyler-potyondy ?

@ppannuto

ppannuto commented Jul 17, 2026

Copy link
Copy Markdown
Member

Minor miscommunication in that comment / from my memory in the meeting earlier today before looking at code.

The question was “why do we need this https://github.com/tock/tockloader/pull/129/changes#diff-4d77c2acd86ba2a9e6df5dd3155d1aa499b1c872312cbd5bea86b2ddb749aa8fR157” ( start_address in tockloader.py), and the short answer is because tockloader doesn’t assume anything about a target board, so it doesn’t know what memory address range flash is in, so it doesn’t know where to read to look for the attributes that are included in the kernel image

We could include something like kernel_address that specifies where the kernel image starts for a board as a static property of board configuration, but that leaves open the question of how long the kernel is (and how long flash is), i.e., how much memory should tockloader read?

We could just specify the board’s memory map as part of its config (i.e. start/end of flash [and maybe RAM too]) but that’s annoying to add for all the boards, and it really feels like there should be some way to get jlink/openocd/etc to just report that for an attached target [quick search confirms that’s in principle possible]; with that we could just dump all of flash and then scan for the kernel attribute table

tl;dr—I think there’s better solutions, but updating start_address is sufficiently not-annoying that implementing anything fancier isn’t worth the effort; during development you can just use the -a, --app-address flag when invoking tockloader to override the default.

I think we should just merge this as-is.


FWIW, tockloader does read the kernel attributes already — indeed, it uses start_address to know where to look for them

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.

5 participants