ch32-rs / wchisp

WCH ISP Tool in Rust
https://ch32-rs.github.io/wchisp/
GNU General Public License v2.0
166 stars 28 forks source link

Add CH592 to Readme #47

Closed plops closed 6 months ago

plops commented 6 months ago

I used managed to program a board with CH592F using wchisp. I bought it from here: aliexpress.us/item/1005006117859297.html

cl-cpp-generator2/example/146_mch_mcu/source06/b $ ./wchisp flash risc_usb_test
19:48:49 [INFO] Chip: CH592[0x9222] (Code Flash: 448KiB, Data EEPROM: 32KiB)
19:48:49 [INFO] Chip UID: DF-36-4F-10-53-5C-81-A3
19:48:49 [INFO] BTVER(bootloader ver): 02.30
19:48:49 [INFO] Current config registers: ffffffffffffffff4d0fff4f00020300df364f10535c81a3
RESERVED: 0xFFFFFFFF
WPROTECT: 0xFFFFFFFF
  [0:0]   NO_KEY_SERIAL_DOWNLOAD 0x1 (0b1)
    `- Enable
  [1:1]   DOWNLOAD_CFG 0x1 (0b1)
    `- PB22(Default set)
USER_CFG: 0x4FFF0F4D
  [2:0]   RESERVED 0x5 (0b101)
    `- Default
  [3:3]   CFG_RESET_EN 0x1 (0b1)
    `- Enable
  [4:4]   CFG_DEBUG_EN 0x0 (0b0)
    `- Disable
  [5:5]   RESERVED 0x0 (0b0)
    `- Default
  [6:6]   CFG_BOOT_EN 0x1 (0b1)
    `- Enable
  [7:7]   CFG_ROM_READ 0x0 (0b0)
    `- Disable the programmer to read out, and keep the program secret
  [27:8]  RESERVED 0xFFF0F (0b11111111111100001111)
    `- Error
  [31:28] VALID_SIG 0x4 (0b100)
    `- Valid
19:48:49 [INFO] Read risc_usb_test as ELF format
19:48:49 [INFO] Found loadable segment, physical address: 0x00000000, virtual address: 0x00000000, flags: 0x5
19:48:49 [INFO] Section names: [".init"]
19:48:49 [INFO] Found loadable segment, physical address: 0x00000004, virtual address: 0x20000000, flags: 0x5
19:48:49 [INFO] Section names: [".highcode"]
19:48:49 [INFO] Found loadable segment, physical address: 0x00000240, virtual address: 0x00000240, flags: 0x5
19:48:49 [INFO] Section names: [".text"]
19:48:49 [INFO] Firmware size: 2048
19:48:49 [INFO] Erasing...
19:48:49 [WARN] erase_code: set min number of erased sectors to 8
19:48:49 [INFO] Erased 8 code flash sectors
19:48:50 [INFO] Erase done
19:48:50 [INFO] Writing to code flash...
█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 2048/204819:48:50 [INFO] Code flash 2048 bytes written
19:48:50 [INFO] Verifying...
█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 2048/204819:48:50 [INFO] Verify OK
19:48:50 [INFO] Now reset device and skip any communication errors
19:48:50 [INFO] Device reset

I have to press the BOOT button while plugging in the USB-C cable. Only then the USB device enumerates in Linux and wchisp can program. I believe if I don't program the device immediatly, then after 10 seconds I have to press BOOT again and plug USB again.

My code for the target is here: https://github.com/plops/cl-cpp-generator2/tree/master/example/146_mch_mcu/source06

andelf commented 6 months ago

Thanks for the info.