openwch / openocd_wch Goto Github PK
View Code? Open in Web Editor NEWOpenOCD for WCH CH32
OpenOCD for WCH CH32
MRS_Community_V160
OpenOCD 0.11.0+dev-02415-gfad123a16-dirty (2023-09-22-10:36)
WCH-LinkE-R0-1v3 (firmware v2.11)
Chip CH32V307VCT6
Problem: during step-by-step debugging, register a0 is overwritten with the value 0xE0000000, if debugging view "registers" is open, and registers ft0... are visible.
The debugger probably uses dscratch interface to read ft0..ftN (after next step, dscratch0/1 has same value, 0xE0000000), and does not restore contents of the a0 register.
This problem exists while mstatus is zero. At the end of startup code, value 0x6088 is written to the mstatus, and debugger starts working correctly.
Could you please write more build instructions under Build section?
My firmware stores user-data to flash memory at address 0x08030000. But this memory is erased after starting hardware debugging. I see 0xE339E339... instead my data. Probably at the beginning of debugging the mass-erase command is executed.
I found sources of OpenOCD_wch, and I see this code:
static int ch32vx_erase(struct flash_bank* bank, int first, int last)
{
if (pageerase)
return ERROR_OK;
if ((riscvchip == 5) || (riscvchip == 6) || (riscvchip == 9)|| (riscvchip == 0x0c)||(riscvchip==0x0e))
{
int retval = wlnik_protect_check();
if (retval == 4)
{
LOG_ERROR("Read-Protect Status Currently Enabled");
return ERROR_FAIL;
}
}
if (noloadflag)
return ERROR_OK;
int ret = wlink_erase();
target_halt(bank->target);
if (ret)
return ERROR_OK;
else
return ERROR_FAIL;
return ERROR_OK;
}
Parameters first and last store the beginning and end of the memory to be erased. But they are not used!!!
The debugger passes the memory address to erase to function ch32vx_erase, but every time all memory is erased (used mass erase).
Please implement the ch32vx_erase function completely, as done in stm32x_erase, for example.
Used tools:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.