Community-PIO-CH32V / platform-ch32v

PlatformIO platform for CH32V RISC-V chips (CH32V003, CH32V103, CH32V20x, CH32V30x, CH32X035) and CH56x, CH57x, CH58x, CH59x
Apache License 2.0
203 stars 34 forks source link

Ch32V003: Please allow setting option byte register from within the IDE #68

Open FPGA-Computer opened 1 week ago

FPGA-Computer commented 1 week ago

CH32V003 Option Bytes Register (FLASH_OBR) uses the default setting whenever code is downloaded from the compiler/Debugger environment. There doesn't seem to be a way of changing the default values from within the IDE. External WCH utility could be used, BUT the debugger will rewrite it with the default values.

e.g. PD7 is default as NRST pin. This pin could also be used as a GPIO. However, there are no IDE options to tell the Debugger to use a different Option Byte value whenever it downloads a new firmware. The only alternative is the firmware programmatically reprogram the option byte register as part of the user firmware. However, I have not tested if the changes would affects the GPIO directly without a reset.

image

maxgerhardt commented 1 week ago

It shouldn't happen at all that a regular upload with OpenOCD or wlink or whatever touches the option bytes of the board. With what platformio.ini is it? How do you verify that the option bytes have changed?

FPGA-Computer commented 5 days ago

My picture is a composite of screen shots - left is from within debugger, top is user manual and bottom is drop down menu from WCH utility showing the various options available.

How do you verify that the option bytes have changed?

Left side of my picture shows the FLASH_OBR register viewed within the Debugger. It shows the bit fields for RST_MODE that is different than what I programmed in from WCH-Link Utility.

As I debug my code, the IDE downloads a new copy of the firmware. Since there are no settings available within the IDE, it picks whatever the default state is or whatever the erased state.

With what platformio.ini

Is there a setting in there I can change that the Option byte that tells the debugger to program it differently? This is what I am asking for. If there is a way of doing so, then please share the steps.

it shouldn't happen at al

Well, if it happens, then it becomes an issue for someone to fix.