I've been working on a Rust bootloader for CH32 MCUs and ran into what seems like a metadata gap in ch32-data: some flash-related regions and address distinctions are difficult to represent cleanly with the current Memory model.
In particular, CH32 user flash has both:
- an execution view (CPU-visible alias, typically
0x0000_0000)
- a programming view (flash controller address, typically
0x0800_0000)
There are also other regions that would be useful to describe more explicitly in metadata, such as:
- system flash / bootloader region
- option bytes
- vendor bytes
Right now, downstream tools tend to reconstruct this with internal offsets, special cases, or incomplete target descriptions. That works, but it makes it harder to build consistent support across HALs, linker scripts, probe-rs flash algorithms, and bootloaders.
What I'm asking
I'd like to ask whether the community agrees that this is a real gap worth addressing in ch32-data, and if so, what the least invasive solution would be? I came up with a possible solution, but I feel it's too invasive, and there should be better solutions. Thus I'm asking the question here.
To get the discussion started, here is my invasive solution:
My Solution
One idea I explored was extending Memory so it can describe both execution and programming views more explicitly. For example:
- redefine
address as the programming address
- add optional fields such as
exec_address and exec_primary
That would allow concepts like:
address: real flash programming address
exec_address: execution alias
exec_primary: marks the main executable flash region
However, I don't want to over-prescribe this approach. It seems workable, but also fairly invasive, and it would likely require coordinated compatibility work in downstream code generation and tooling.
So I am treating this more as an example direction than a concrete proposal.
Questions
- does the community think
ch32-data should represent these distinctions more explicitly?
- if yes, what would be the simplest / cheapest way to do it? Another structure? Something completely different?
- is schema extension the right direction, or is there a less invasive approach?
I've already done a much deeper analysis of the downstream implications and possible migration strategies for this solution, and I'm happy to write that up if you guys are curious, but I have to warn you, it's not pretty...
Lastly, I'd be happy to help implement and maintain whichever approach the community prefers since I'm working on a few CH32 related open source projects.
I've been working on a Rust bootloader for CH32 MCUs and ran into what seems like a metadata gap in
ch32-data: some flash-related regions and address distinctions are difficult to represent cleanly with the currentMemorymodel.In particular, CH32 user flash has both:
0x0000_0000)0x0800_0000)There are also other regions that would be useful to describe more explicitly in metadata, such as:
Right now, downstream tools tend to reconstruct this with internal offsets, special cases, or incomplete target descriptions. That works, but it makes it harder to build consistent support across HALs, linker scripts, probe-rs flash algorithms, and bootloaders.
What I'm asking
I'd like to ask whether the community agrees that this is a real gap worth addressing in
ch32-data, and if so, what the least invasive solution would be? I came up with a possible solution, but I feel it's too invasive, and there should be better solutions. Thus I'm asking the question here.To get the discussion started, here is my invasive solution:
My Solution
One idea I explored was extending
Memoryso it can describe both execution and programming views more explicitly. For example:addressas the programming addressexec_addressandexec_primaryThat would allow concepts like:
address: real flash programming addressexec_address: execution aliasexec_primary: marks the main executable flash regionHowever, I don't want to over-prescribe this approach. It seems workable, but also fairly invasive, and it would likely require coordinated compatibility work in downstream code generation and tooling.
So I am treating this more as an example direction than a concrete proposal.
Questions
ch32-datashould represent these distinctions more explicitly?I've already done a much deeper analysis of the downstream implications and possible migration strategies for this solution, and I'm happy to write that up if you guys are curious, but I have to warn you, it's not pretty...
Lastly, I'd be happy to help implement and maintain whichever approach the community prefers since I'm working on a few CH32 related open source projects.