Skip to content

dts: wch: Enable using whole flash with CH32V208 #87345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025

Conversation

VynDragon
Copy link
Collaborator

@VynDragon VynDragon commented Mar 19, 2025

Enables using the whole flash on CH32V208
This needs #87141 This fixes it differently.
and #85395

fkokosinski
fkokosinski previously approved these changes Mar 21, 2025
@fabiobaltieri
Copy link
Member

cc @kholia (need to open a issue to add you to the collaborators)

@VynDragon VynDragon force-pushed the ch32v208_fix_flash_addr branch from 145559b to f6d4d2e Compare May 5, 2025 15:08
j __start
.rept CONFIG_VECTOR_TABLE_SIZE
.word _isr_wrapper
.endr

SECTION_FUNC(vectors, __start)
li a0, 3
li a0, 0xf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first, I wanted to ask what this change is about but I now have some idea:
You need this because lui and jr from above are now at 0x0 and then the table starts at 0x8, right?
I think this warrants a comment in code for the next person that tries to understand this line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 first bits are settings, 2 after that are 0xC start of the table (0x4+0x4+0x4 3 32-bits instructions)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, my bad.
But then vector table is one entry to small (check VECTOR_TABLE_SIZE and Table 9-2 in RM).
Could also verify using DMA2_CH11 interrupt

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, the number should be 104, I'll make a PR for fixing this later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have applied it there since I had to spend another hour updating this PR again since other things were merged before it was.

Copy link
Collaborator Author

@VynDragon VynDragon May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have applied it there since I had to spend another hour updating this PR again since other things were merged before it was.

Feel free to mark other PRs as DNM if there are dependencies or preferences w.r.t merge order

Not only do i expect people to be pissed if I do that, but I also expected y'all take the normal time to merge that PR, eg 2 to 3 months counted in buisness days so i could have the time to actually take a look at it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only do i expect people to be pissed if I do that, but I also expected y'all take the normal time to merge that PR, eg 2 to 3 months counted in buisness days so i could have the time to actually take a look at it.

I don't know what this is supposed to mean. PRs get merged when they're... mergeable?

Copy link
Collaborator Author

@VynDragon VynDragon May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What it means is being unpredictable is worse than being slow, you cant just have trivial PRs taking months to merge because no one bothers taking a look or assigned person disappeared, while having big PRs being reviewed very partially (100 % certain nordicjm's review was only relevant to the board part, dont know about yours but i'm also sure there wasnt a overall architectural review because it didn't match the current architecture of the wch soc folders that my PRs had to match being merged) and merged near-instantly.

Copy link
Collaborator Author

@VynDragon VynDragon May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like ffs we still cant use west flash on ch32v208 because we have to make sure <random person 458485> is ok with fixing a obvious bug but apparently breaking other PRs and making 4 contributors wait for months on end because no one can be bothered to actually review something agreed upon by 3/4th of the contributors of a platform is perfectly ok.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to apologize to you two, it's really not your fault, it's only the normal, insanely frustrating (especially in areas of low mainstream interest), process...

Enables using the whole flash on CH32V208
This also involves limiting frequency of the CPU to 120Mhz
from 144Mhz to meet recommendations.

Signed-off-by: Camille BAUD <mail@massdriver.space>
Copy link
Collaborator

@nzmichaelh nzmichaelh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, the ch32v00x series (like the ch32v006) is different from the ch32v003 - including having a different microarchitecture (v2c) and different pinmux.

Happy to discuss.

@@ -90,7 +90,7 @@ static void clock_control_wch_rcc_setup_flash(void)
} else {
latency = FLASH_ACTLR_LATENCY_1;
}
#elif defined(CONFIG_SOC_SERIES_CH32V00X)
#elif defined(CONFIG_SOC_SERIES_QINGKE_V2A)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original is correct.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add detail: the flash latency is a SOC feature, not a core feature, and it's different on the CH32V003 to the others in the CH32V00x series.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this is the correct filter right? This will be CONFIG_SOC_SERIES_QINGKE_V2 soon.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -6,3 +6,4 @@ config SOC_SERIES_QINGKE_V2A
select RISCV_ISA_EXT_ZICSR
select RISCV_ISA_EXT_ZIFENCEI
select RISCV_ISA_EXT_C
select RISCV_ISA_EXT_ZMMUL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The V2A does not have ZMMUL

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

# SPDX-License-Identifier: Apache-2.0

if SOC_SERIES_QINGKE_V2A

config SYS_CLOCK_HW_CYCLES_PER_SEC
default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)

config MAIN_STACK_SIZE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are needed on the CH32V003, which is the only SOC using the V2A.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look at the new version while i run functionaility tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -1,12 +1,12 @@
# Copyright (c) 2025 Michael Hope <michaelh@juju.nz>
# SPDX-License-Identifier: Apache-2.0

if SOC_SERIES_CH32V00X
if SOC_CH32V006

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! No action requested.

@@ -3,7 +3,7 @@

config SOC_CH32V006
bool
select SOC_SERIES_CH32V00X
select SOC_SERIES_QINGKE_V2A
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original is correct. Also, the CH32V00x series is a QINGKE_V2C.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -10,7 +10,7 @@
/**
* @brief Type to hold a pin's pinctrl configuration.
*/
struct ch32v00x_pinctrl_soc_pin {
struct qingke_v4_pinctrl_soc_pin {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this file moved?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deduplication.

@@ -7,9 +7,7 @@ family:
- name: qingke-v2a
socs:
- name: ch32v003
- name: ch32v00x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ch32v006 is not a qingke-v2a but a v2c

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not clear i'm quite a bit annoyed CH32V006 was merged, because it messes up this PR and means it requires ANOTHER round of reviews and hours of update for me, and obviously I have made errors on adding ch32v006 to it, but I'm really not inclined in spending more time on it while everyone has been dragging their feets about this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you know, the fact that it's probably going to need another round of reorganization as discussed there #87345 (comment) and so it's basically doubly wasted time.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hear you, and I'm sorry for your wasted time. When I reviewed it, this PR breaks both the ch32v003 and ch32v00x, so I can't LGTM it as is.

Could I suggest breaking this up into separate PRs covering separate concerns? For example, the CH32V208 PLL, flash, and startup changes are independent of the rename.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am working on fixing it so it doesnt break them and they are organized as they are supposed to be in this version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be good now.

@nzmichaelh
Copy link
Collaborator

re: naming in general, is #87345 (comment) the plan of record? I used that for the ch32v00x structure, but this PR reverses much of that.

@VynDragon VynDragon force-pushed the ch32v208_fix_flash_addr branch 3 times, most recently from bdc2db6 to 8ae6dfa Compare May 10, 2025 16:19
@VynDragon VynDragon changed the title dts: wch: Enable using whole flash with CH32V208 And reorganize soc folder for future deduplication dts: wch: Enable using whole flash with CH32V208 May 10, 2025
@VynDragon
Copy link
Collaborator Author

VynDragon commented May 10, 2025

Someone else can take care of the reorganization reviewers have asked for: #87125 (comment)
patch.txt

@VynDragon VynDragon requested a review from nzmichaelh May 10, 2025 16:25
Copy link

Copy link
Collaborator

@nzmichaelh nzmichaelh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kartben kartben merged commit bab50a5 into zephyrproject-rtos:main May 12, 2025
29 checks passed
@VynDragon VynDragon deleted the ch32v208_fix_flash_addr branch May 14, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.