Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Fix: hardcode GD32VW553 memory map#2199

Open
ALTracer wants to merge 1 commit intoblackmagic-debug:mainfrom
ALTracer:fix/gd32vw553-map
Open

Fix: hardcode GD32VW553 memory map#2199
ALTracer wants to merge 1 commit intoblackmagic-debug:mainfrom
ALTracer:fix/gd32vw553-map

Conversation

@ALTracer
Copy link
Contributor

@ALTracer ALTracer commented Mar 5, 2026

Detailed description

  • No new features.
  • The existing problem is incorrect memory map introduced by me in Feature: detect GD32VW553 #2186.
  • This PR solves it by hardcoding fixed sizes of SRAM and Flash for GD32VW553. No flash driver yet.

Tested on "LCSC-boards LCKFB-GD32VW553-HMQ6", now that it arrived, via blackpill-f411ce.

Apparently 0x1ffff7e0 reads as 0xFF, so normal autodetection code gets 65536 KiB for each, this is wrong.
User Manual and Datasheet state that there are either 4 MiB or 2 MiB of SiP flash in these parts, and 320 KiB of SRAM (last 32 KiB are "shared" mysteriously, with Wi-Fi or BLE maybe). Let's just go by that. Flash is readable.

Before:

ID code 0x10307a6d: Nuclei Systems RISC-V DTM.
ID code 0x790007a3: Gigadevice BSD.
RISC-V debug v0.13/v1.0 DMI
RISC-V debug v0.13 DM
Hart has 4 data registers and 2 progbuf registers
...
Attempting 32-bit read on misa
Hart 0: 32-bit RISC-V (arch = 00000307), rv32igcbp ISA (exts = 0010912f), vendor = a36, impl = 30700
Hart has 8 trigger slots available
-> riscv32_probe
Stub for detection of GD32VW553. DBG_ID=0x418, RAM=65535, flash=65535
***  1   GD32VW5 rv32igcbp
RAM   Start: 0x20000000 length = 0x3fffc00
RAM   Start: 0x08000000 length = 0x3fffc00

After:

ID code 0x10307a6d: Nuclei Systems RISC-V DTM.
ID code 0x790007a3: Gigadevice BSD.
RISC-V debug v0.13/v1.0 DMI
RISC-V debug v0.13 DM
Hart has 4 data registers and 2 progbuf registers
...
Attempting 32-bit read on misa
Hart 0: 32-bit RISC-V (arch = 00000307), rv32igcbp ISA (exts = 0010912f), vendor = a36, impl = 30700
Hart has 8 trigger slots available
-> riscv32_probe
Stub for detection of GD32VW553. DBG_ID=0x418, RAM=320, flash=4096
***  1   GD32VW5 rv32igcbp
RAM   Start: 0x20000000 length = 0x50000
RAM   Start: 0x08000000 length = 0x400000

Your checklist for this pull request

Closing issues

@dragonmux dragonmux added this to the v2.1 release milestone Mar 6, 2026
@dragonmux dragonmux added Enhancement General project improvement Bug Confirmed bug labels Mar 6, 2026
Copy link
Member

@dragonmux dragonmux left a comment

Choose a reason for hiding this comment

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

Paired with what you've shared on Discord this seems reasonable - just needs a small clean-up and then we'll be happy to merge it. Shame that using the FLASHSIZE register won't work! But such are the realities of parts not setting things up right and such..

With the small tweak made, we'll be happy to merge this.

const uint16_t flash_size = 4096U;
/* SRAM0/1/2 each 64 KiB, SRAM3 128 KiB (96+32 shared) */
const uint16_t ram_size = 320U;
DEBUG_WARN("Stub for detection of GD32VW553. DBG_ID=0x%x, RAM=%u, flash=%u\n", device_id, ram_size, flash_size);
Copy link
Member

Choose a reason for hiding this comment

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

Please drop this warning if you're hard-coding these bits - the line no longer serves a purpose.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Bug Confirmed bug Enhancement General project improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants