-
Notifications
You must be signed in to change notification settings - Fork 131
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
minichlink resetting option bytes on flash operations #232
Comments
The InternalUnlockFlash is not used for V307 because for WCH-LinkE it uses a custom implementation of WriteBinaryBlob. We aim to make a low-level implementation of the protocol, so the registers can be set directly. Have you tried out if similar alternatives like the Rust-based wlink mess with the option bytes as well? |
wlink doesn't work properly with my WCH-LinkE:
After that error, the microcontroller isn't printing to serial and wlink just prints error messages for any command:
But if I power cycle the board, the debugger comes back and it looks like wlink isn't resetting the option bytes. |
Ok, looking at the official programmer, it sets the user option bytes along with readout protection with:
The surrounding context is:
So since this is in between two 81:06:01:01's, I tried modifying pgm-wch-linke.c with:
that gives me 64K ram, but it isn't especially elegant. Any ideas on how to handle this better? |
Here's an attempt (attached) to utilize the above bit patterns , to partition the CH307 Ram on flashing. Btw: I'm a git novice , don't send a pull request. I "cheated" , and used two Global variables .. Dunno' if minichlink Author will kill me .... |
I'm using the ch32v307, and it has a register to determine the ram/flash split. I'm guessing it's doing a shadow copy of the flash contents into ram. This is the option byte at 0x1ffff802, which is copied to the register OBR in the flash controller at startup.
I can set the option byte to use a 192KB flash/128KB sram split just fine with:
The board picks up my change through a reset, by pushing the reset button or using
minichlink -a -b
orNVIC_SystemReset();
Reading back the option bytes:
I get the expected value:
And the flash OBR register has the split I want:
But when I flash a new image with
minichlink -a -w build/example.bin 0x08000000 -b
, something is resetting my user option bytes back to 0xff:Which resets back to the 288K/32K memory split:
I experimented with commenting out OBKEYR unlocking in
InternalUnlockFlash
, but that didn't change this behavior.Any ideas on what to try next?
The text was updated successfully, but these errors were encountered: