Giter Club home page Giter Club logo

wchisp's Introduction

wchisp - WCH ISP Tool in Rust

crates.io

Command-line implementation of the WCHISPTool in Rust, by the ch32-rs team.

This tool is a work in progress.

  • NOTE: CH32V003 DOES NOT have a USB ISP interface, use WCH-Link to program
  • NOTE: This tool is for USB ISP, not using with WCH-Link

Installing

The prebuilt binaries are available on the Nightly release page.

For Windows users, you will need vc runtime to run the binary. You can download it from Microsoft.

Or else, you can install it from source.

# install libusb for your platform
# macOS
> brew install libusb
# Ubuntu
> sudo apt install libusb-1.0-0-dev

# install wchisp
> cargo install wchisp --git https://github.com/ch32-rs/wchisp
# or use
> cargo install wchisp --force

Prebuilt Binaries

Prebuilt binaries are available on the Github Actions Page. Click the newest runs at Github Actions Page and download the binary from "Artifacts" section.

Note for Windows

If you are using Windows, you need to install the WinUSB driver for your device. See Zadig.

NOTE: This is not compatible with the Official WCH driver you installed with IDE.

Note for Linux

If you are using Linux, you need to set the udev rules for your device.

# /etc/udev/rules.d/50-wchisp.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="4348", ATTRS{idProduct}=="55e0", MODE="0666"
# or replace MODE="0666" with GROUP="plugdev" or something else

Usage

> wchisp info
14:51:24 [INFO] Chip: CH32V307VCT6[0x7017] (Code Flash: 256KiB)
14:51:24 [INFO] Chip UID: 30-78-3e-26-3b-38-a9-d6
14:51:24 [INFO] BTVER(bootloader ver): 02.60
14:51:24 [INFO] Code Flash protected: false
RDPR_USER: 0x9F605AA5
  [7:0] RDPR 0b10100101 (0xA5)
    `- Unprotected
  [16:16] IWDG_SW 0b0 (0x0)
    `- IWDG enabled by the software
  [17:17] STOP_RST 0b0 (0x0)
    `- Enable
  [18:18] STANDBY_RST 0b0 (0x0)
    `- Enable
  [23:21] SRAM_CODE_MODE 0b11 (0x3)
    `- CODE-228KB + RAM-32KB
DATA: 0x00FF00FF
  [7:0] DATA0 0b11111111 (0xFF)
  [23:16] DATA1 0b11111111 (0xFF)
WRP: 0xFFFFFFFF
  `- Unprotected

> wchisp flash ./path/to/firmware.{bin,hex,elf}

> wchisp config info

> wchisp config reset

Tested On

This tool should work on most WCH MCU chips. But I haven't tested it on any other chips.

  • CH32V307
    • VCT6
    • RCT6 #8
  • CH32V103
  • CH32F103
  • CH552
    • Works but might be buggy #10 #14
  • CH582
    • CH58xM-EVT
  • CH573
  • CH579
    • BTVER: 02.90 #18
  • CH559
    • CH559TL_MINIEVT_V20 by wch.cn
  • CH32V203
  • ... (feel free to open an issue whether it works on your chip or not)

TODOs

  • chip detection, identification
    • wchisp probe
    • wchisp info
  • flash and verify code
    • ELF parsing
    • hex, bin, ihex support
    • skip erasing, verifying, resetting
  • chip config register dump
    • wchisp config
    • works for most chips, but not all. Issues and PRs are welcomed
  • write config registers
    • reset config registers to default
    • write config with friendly register names? like wchisp config set SRAM_CODE_MODE=1 ...
  • EEPROM dump
  • EEPROM erase
  • EEPROM write
  • select from multiple chips(using -d to select device index) wchisp -d 0 info
  • ISP via UART or Net

Related Works (Many Thanks!)

Contribution

This project is under active development. If you have any suggestions or bug reports, please open an issue.

If it works for your devices, please open a pull request to modify this README page.

It it doesn't, please open an issue. Better provide the following information:

  • chip type (with variant surfix)
  • debug print of usb packets
  • correct usb packets to negotiate with the chip (via USBPcap or other tools)

wchisp's People

Contributors

andelf avatar mini-ninja-64 avatar koendv avatar octopusz avatar rgoulter avatar martell avatar septs avatar

Stargazers

HaiND avatar

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.