GithubHelp home page GithubHelp logo

openocd_wch's People

Contributors

tianpeilee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

openocd_wch's Issues

Corruption of register a0 during step-by-step debugging

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.

изображение
изображение

Incorrect memory erase

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:

  • MounRiver_Studio_Community_Win_V160
  • WCH-LinkE-R0-1v3
  • OpenOCD_wch (from toolchain MounRiver_Studio_Community_Win_V160).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.