ch32-rs / ch32v00x-hal

HAL for the CH32V003 family of microcontrollers
29 stars 11 forks source link

Can I enable sdi print on probe-rs? #7

Closed Dicklessgreat closed 3 months ago

Dicklessgreat commented 5 months ago

I tried debug example on VSCode using probe-rs. I found it result in infinite loop at first println! call stack:

read_volatile<u32> #[inline] (...rustlib\src\rust\library\core\src\ptr\mod.rs:1580)
is_busy #[inline] (...\ch32v00x-hal-d817920771731cf2\cdd79fc\src\debug.rs:23)
write_str (...\ch32v00x-hal-d817920771731cf2\cdd79fc\src\debug.rs:38)
write (...\rustlib\src\rust\library\core\src\fmt\mod.rs:1144)
unwrap<(), core::fmt::Error> #[inline] (...\rustlib\src\rust\library\core\src\result.rs:1071)
__risc_v_rt__main (...\ch32v00x-hal-d817920771731cf2\cdd79fc\src\debug.rs:57)
<unknown function @ 0x20000018> (Unknown Source:0)

seems like DEBUG_DATA would not flush 0 and SDIPrint is always busy.

I tried the same program with wlink -v flash path/to/debug_program --enable-sdi-print --watch-serial and it works fine. So I think probe-rs's setting is something wrong. My current launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "preLaunchTask": "rust: cargo build",
            "type": "probe-rs-debug",
            "request": "launch",
            "name": "my_program",
            "cwd": "${workspaceFolder}",
            "chip": "ch32v003",
            "connectUnderReset": false,
            "speed": 4000,
            "flashingConfig": {
                "flashingEnabled": true,
                "resetAfterFlashing": true,
                "haltAfterReset": true,
            },
            "coreConfigs": [
                {
                    "programBinary": "path/to/debug_program",
                    "chip": "ch32v003",
                    "rttEnabled": true,
                    "options": {
                        "env": {
                            "DEFMT_LOG": "debug"
                        }
                    },
                }
            ],
            "consoleLogLevel": "Info", //Error, Warn, Info, Debug, Trace
            "wireProtocol": "Jtag"
        }
    ]
}
andelf commented 3 months ago

SDI print is not the same as probe-rs's rtt. wlink has a support for SDI print.