Reflashing a bricked WCH-LinkE - Page 1
Forum section: electronics / general

author: MarkMLl
author_rank: Frequent Contributor
timestamp: March 19, 2023, 02:02:17 pm
content: Noting the earlier discussion athttps://www.eevblog.com/forum/microcontrollers/wch-$0-10-risc-v-mcu/msg4549094/#msg4549094QuoteI've started a separate thread since this could end up being an FAQ.I've got one of the WCH kits available via ALI which have a couple of evaluation boards, a WCH-LinkE programmer, and some additional chips, and have been carefully setting up MounRiver on Linux so that I understand its dependencies.Following Dave's lead, I compiled GPIO_Toggle without significant problems ** . However when I went to Flash->Download it MounRiver told me that I needed to "update" the WCH-LinkE firmware from 2.8 to 2.7, and wouldn't cooperate unless I did. However what it actually wrote was the newly-compiled .hex file, so the programmer is now a brick (flashing a pretty blue LED, but a brick nonetheless).How do I recover from this, and most importantly how do I prevent its happening to other people? Because right now I'm less than confident recommending this for a project I'm being asked about.MarkMLl** Noting Dave's problem with the GPIO bit connected to the LED, on these evaluation boards it looks as though the two LEDs are taken to header pins which need to be jumpered to suitable port pins.

author: Sacodepatatas
author_rank: Regular Contributor
timestamp: March 19, 2023, 04:37:53 pm
content: Take a look at the pages 13 and 14 of the WCH-Link(E) manual.

author: MarkMLl
author_rank: Frequent Contributor
timestamp: March 19, 2023, 05:35:25 pm
content: Thanks, I'll investigate. I might need to look very carefully at what version of MounRiver Studio I've got, in case the upgrade/downgrade/botch is something to do with that.Is the transparent case on the WCH-LinkE glued/welded? I'm trying to decide whether to pry harder or get the Dremel out to drill holes over the buttons.(Slightly later) So if I'm reading that correctly, "WCH-LinkUtility offline update (2-wire approach to offline update)" is applicable to a WCH-LinkE, i.e. I need a second programmer plus the WCH-Link software.MarkMLl

author: Sacodepatatas
author_rank: Regular Contributor
timestamp: March 19, 2023, 08:54:05 pm
content: Yes, it seems that the only way of updating the firmware is through SWD, then a second WCH-LINKE would be needed (unless the SWD propietary protocol would be released soon as stated by Patrick Yang), because the 1-wire protocol has been minimalistic ported to ESP32 and STM32F042, if I recall right). I guess the CH32V305 in TSSOP-20 that is on the PCB doesn't let access to boot0 or boot1 pins, so the bootloader for DFU or maybe UART cannot be started. That's why the need of another WCH dongle for unbricking this one.

author: GromBeestje
author_rank: Frequent Contributor
timestamp: March 20, 2023, 06:57:18 am
content: When I first got my WCH LinkE, it appeared to be bricked. It wouldn't enumerate on Linux.However, it would enumerate on Windows, and using the Windows updater I updated the WCH LinkE and then it would enumerate on Linux. I'm not sure what versions they were at though.

author: MarkMLl
author_rank: Frequent Contributor
timestamp: March 20, 2023, 07:27:03 am
content: Quote from: GromBeestje on March 20, 2023, 06:57:18 amThanks, I'll check and report back. When you say "wouldn't enumerate on Linux", were you looking for the serial device (e.g. /dev/ttyACM0) or were you looking at lsusb output and checking the /dev/bus/usb tree?Slightly later: lsusb /does/ report a device, but the kernel doesn't know what to do with it.Code: (plain)Bus 002 Device 015: ID 4348:55e0 WinChipHeadDevice Descriptor:bLength 18bDescriptorType 1bcdUSB 1.10bDeviceClass 255 Vendor Specific Class[Mar20 07:34] usb 2-1.5: new full-speed USB device number 15 using ehci-pci[ +0.108750] usb 2-1.5: New USB device found, idVendor=4348, idProduct=55e0, bcdDevice= 1.00[ +0.000012] usb 2-1.5: New USB device strings: Mfr=0, Product=0, SerialNumber=0"Winchiphead CH341 DriverThis driver is for the Winchiphead CH341 USB-RS232 Converter. This chip also implementsan IEEE 1284 parallel port, I2C and SPI, but that is not supported by the driver. The protocolwas analyzed from the behaviour of the Windows driver, no datasheet is available at present."Unfortunately 4348:55e0 is not an ID that the Linux kernel knows about: the CH341 driver responds to 4348:5523. In the past I've tinkered a little with the CH341's I2C etc. capabilitieshttps://github.com/MarkMLl/i2c-ch341-usbbut I think that relies on the standard IDs.I note that the part-decoded WCH-Link protocol is described as I2C-like, and when I have time I'll take a closer look at that and see what ID it expects: it might be that in combination with the project above the programmer could be reflashed with no additional hardware.I've got a response from support@mounriver.com but so far they don't really seem to understand that their software can brick the programmer: they still think that the IDE should be able to upgrade the firmware, but while there's some slim possibility that libusb could do something with that device as it stands... without a module/driver that knows about that non-standard ID I don't think that will happen.In any event, this gives some indication of how Windows might be able to recover: but I bet that it relies on a driver having been installed.MarkMLl

author: MarkMLl
author_rank: Frequent Contributor
timestamp: March 20, 2023, 09:36:20 am
content: OK, sorted.The key is that when MounRiver Studio wrote the wrong firmware to the WCH-LinkE programmer, it changed the vid:pid identifier so my udev rules file- which was only looking for the operational ID 1a86:8010- was no longer prepared to put it into the plugdev group.If I use the slightly more complex fileCode: (shell)# Remember to udevadm control --reload after any changes.# Assume that the CDC serial device (typically /dev/ttyACM0) has already been# assigned to root:dialout on account of its class.# Operational WCH-LinkE:SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="8010", ATTRS{product}=="WCH-Link", GROUP="plugdev", MODE="0660"# This untested, and refers to the WCH-DAPLink## SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="8012", ATTRS{product}=="WCH-Link", GROUP="plugdev", MODE="0660"# WCH-LinkE recovery mode:SUBSYSTEMS=="usb", ATTRS{idVendor}=="4348", ATTRS{idProduct}=="55e0", ATTRS{bDeviceClass}=="ff", GROUP="plugdev", MODE="0660"the recovery/reflash identifier will still be in the plugdev group, and the IDE will be able to flash the firmware version that it believes is appropriate into the programmer.So provided that I have relaxed my security requirement slightly as above (or am prepared to throw caution to the wind and run MRS as root) their support desk's suggestion is appropriate:Quote...subject possibly to a bit of replugging. I am now able to write the .hex file to the target, without screing the programmer, and am pleased to confirm that GPIO_Pin_0 is actually PD0 :-)All above was with MounRiver Studio Community v1.30 on Debian Linux "Bookworm" x86_64. An update might have just been made available, but is not yet showing up on the main download page at least for Linux.MarkMLl

author: GromBeestje
author_rank: Frequent Contributor
timestamp: March 20, 2023, 07:05:45 pm
content: Quote from: MarkMLl on March 20, 2023, 07:27:03 amBy the dmesg output. The enumeration process failsCode:[ 5892.539593] usb 2-6.2: new full-speed USB device number 46 using xhci_hcd[ 5892.796254] usb 2-6.2: unable to read config index 0 descriptor/start: -32[ 5892.796263] usb 2-6.2: chopping to 0 config(s)[ 5892.796265] usb 2-6.2: can't read configurations, error -32[ 5892.802068] usb 2-6-port2: unable to enumerate USB device

author: MarkMLl
author_rank: Frequent Contributor
timestamp: March 21, 2023, 08:25:59 am
content: That reminds me of something. When I was looking at the original Tang Nano FPGA board I found that it was unreliable unless plugged directly into a USB v1 hub: and that similarly had an onboard WCH microcontroller, which in that case was actually programmed with FTDI IDs.So there's a possibility that some of these devices don't have very robust USB implementations, particularly when running in a fallback mode apparently implemented in the bootloader.I'm still a little confused as to what was really happening in the current case. The water's slightly muddied by the fact that what I'm actually doing is exploring putting untrusted development tools into Docker containers, and since Docker's hotplug ability is limited there is a possibility that that contributed to the confusion.And I don't know for certain whether MRS really had loaded the GPIO_Toggle demo code which was blinking the blue LED, or if it was running bootloader firmware: which their support said would turn on the blue LED with no mention of it flashing.So there's the nagging question of whether (some of) these devices have USB support hardware, or firmware in the bootloader, which can be enabled without the involvement of the normal application code. I would hope that they could be answered by detailed study of the reference material.MarkMLl

author: Kenjutsu
author_rank: Contributor
timestamp: May 18, 2023, 02:29:12 pm
content: I am in a similar position as the OP. The difference is that I am on aM1 Macand usedwchisp - WCH ISP Tool in Rustto mistakenly upload firmware for aCH32V003to myWeAct Studio WCHlink Debuggerwchisp infocan still see the WeAct board:Chip: CH549 (Code Flash: 60KiB, Data EEPROM: 1KiB)My question is where can I download the correct firmware to upload viawchispback on the WeAct board?Thank you!

author: MarkMLl
author_rank: Frequent Contributor
timestamp: May 20, 2023, 07:49:00 am
content: Quote from: Kenjutsu on May 18, 2023, 02:29:12 pmThe key phrase is "it will burn the WCH-LinkE firmware to the version built into MRS", i.e. there's a copy of the current firmware embedded in the MounRiver IDE with the capabilities expected by the IDE's loader, and the IDE can update the firmware provided that it sees (and recognises) the device.While I'm very much in favour of expanding the number of supported programming languages, I'd caution that this is a special operation and might be best left to WCH's own code.MarkMLl

author: HwAoRrDk
author_rank: Super Contributor
timestamp: May 20, 2023, 04:44:43 pm
content: Quote from: hamza.zahid on May 20, 2023, 09:47:18 amGee, thanks ChatGPT, that was most helpful. /s

author: MarkMLl
author_rank: Frequent Contributor
timestamp: May 20, 2023, 06:45:26 pm
content: Quote from: hamza.zahid on May 20, 2023, 09:47:18 amRead the thread: it is done automatically by the IDE.The thing that gave me problems initially was that I had not mapped all possible USB IDs through to Docker (and put them into Linux udev rules files etc.).MarkMLl

author: dquadros
author_rank: Newbie
timestamp: November 26, 2023, 07:58:16 pm
content: Just to document: the transparent case is not glued. You can pry it open with a screwdriver (and some care). Start at the connectors where there is a small space between the two parts.Not sure how I bricked mine. WCH tools were asking to update it all the time, sometimes saying the update was ok, sometimes saying something went wrong. At some point the WCH-LinkE just stopped communicating. Currently waiting for a new one to try to burn the firmware again.

author: dquadros
author_rank: Newbie
timestamp: November 27, 2023, 10:55:08 am
content: Really confused about the WCH-LinkE. I tried my "bricked" device on two computers (one running Windows and the other Linux) and there was not sign of USB communication. After opening the case, I connected it to the Windows machine with the APP button pressed and it was recognized. Running the WCH-LinkUtility, it once again asked permission to update; after the update (and removing and plugging it again), the WCH-LinkE is working fine.

author: MarkMLl
author_rank: Frequent Contributor
timestamp: November 30, 2023, 03:07:39 pm
content: Quote from: dquadros on November 27, 2023, 10:55:08 amOne thing that came out of my tinkering earlier in the year: ALWAYS look at the vid:pid pair that comes from the device, try to work out what it represents, and examine whether the udev rules can be improved.At about the same time I did quite a lot of work configuring Docker for different development environments (typically either Eclipse or Arduino) and programmers. In almost all cases I was able to map the programmer through the Docker sandbox (or whatever you want to call it), but that typically required more security features to be disabled than I was really happy with.MarkMLl

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 02, 2024, 06:52:22 pm
content: I'm having the same issue under Windows (7) - flashing blue LED after Mounriver attempts to update the WCH-link.In addition, Attempting to run WCHISPStudio from within Mounriver gives an error "The prcedure entry point CH375readEndP could not be located in the dynamic link library CH375DLL.DLL"Any clues..?Update - tried a WIN10 PC and still not able to run WCHISPStudio due to lack of CH375DLL.DLL

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 02, 2024, 08:12:31 pm
content: OK running setup.exe within the WCHISPTOOL folder has dealt with the CH375DLL issue.Running WCH-Linkutility ( in Extool\SWDtool ) seems to have updated it now, no longer getting flashing blue. Don't recall what I selected in this tool - I think it auto-detected.I don't have the hardware to hand now but Mounriver now seems to think the wch-link version is correct so looks like this solved the issue

author: MarkMLl
author_rank: Frequent Contributor
timestamp: January 03, 2024, 11:48:19 am
content: Glad you've got that sorted. The one thing I would add is that I found their support approachable and competent when I had the problem described in OP: they appear to "have the right attitude" when it comes to breaking into the market.MarkMLl

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: February 21, 2024, 01:56:46 pm
content: Does any one know what CH217K part do? my guess is that they are Power switches? Does anyone have their datasheet?

author: eutectique
author_rank: Frequent Contributor
timestamp: February 21, 2024, 04:55:26 pm
content: Quote from: ali_asadzadeh on February 21, 2024, 01:56:46 pmThe topmost link suggested by google leads here:https://nl.aliexpress.com/i/1005005392218373.htmlScroll a bit down to see the pictures of the datasheet.

author: MarkMLl
author_rank: Frequent Contributor
timestamp: February 22, 2024, 09:58:27 am
content: Quote from: eutectique on February 21, 2024, 04:55:26 pm"USB port power switch with adjustable current limiting theshold [...] alarm open-drain output active-low".Note two different pinnings with K and X suffix.MarkMLl

author: HwAoRrDk
author_rank: Super Contributor
timestamp: February 22, 2024, 11:26:48 am
content: The resistor values they're using (150k and 300k) give a current limit of 400mA for 5V and 200mA for 3.3V.On the older version 1.2 of the LinkE, they used to have 150k Rsetresistors for both, but I guess they figured that was stupid because the SOT23 voltage regulator they're using for the 3.3V won't be rated for that anyway.

author: wilhe_jo
author_rank: Regular Contributor
timestamp: June 18, 2024, 07:26:46 pm
content: Could someone explain how one is supposed to update a wch-link?I got some problems with upload with the newest mounriver studio... I found some information, that my old firmware on the ch32v307 dev-board is too old for the new openocd.So I followed the instructions, got a win10 virtual machine running, got the wch-link-tool and that asked me if it should update.Now I'm left with a blnking blue LED...Any idea how I could get it working again?Tried everything above, but nothing seems to work.I have a spare dev board at hand... but I can't use it with the newer MRS... and - at least for me - the MRS would not update the programmer.Going another round with virtualbox seems too risky for now.Regards

author: Postal2
author_rank: Frequent Contributor
timestamp: June 18, 2024, 08:19:35 pm
content: Quote from: wilhe_jo on June 18, 2024, 07:26:46 pmAssume you want to upload CH32V307 devboard. You can set jumpers "boot0" to vcc, "boot1" to gnd, next you can connect directly via CH32V307 usb-HS-port (marked on devboard). WCHISPTool will recognize chip and work with it.

author: wilhe_jo
author_rank: Regular Contributor
timestamp: June 19, 2024, 11:59:26 am
content: Quote from: Postal2 on June 18, 2024, 08:19:35 pmNo, this is not what I want!I want to use the wlink integrated in the dev board to flash & debug.The problem is, I had to update the firmware on the CH549 for the new MRS. This failed in the Windows 10 virtual machine.Now I'm left with a bricked wlink!I found the isp55e0 tool that actually can flash the CH549.However, all firmware files i found so far did not restore my wlink.My thinking was, that one of the firmware files supplied with the MRS would fix this.. so I tried flashing WCH-Link_APP_IAP_RV.bin, FIRMWARE_CH549.bin, WCH-Link_APP_IAP_ARM.bin and FIRMWARE_DAP_CH549.bin.... but none of them worked.Interestingly, I cannot get the ISP-bootloader of the CH549 to show up under virtualbox...seems some USB-IO-problem that prevents this .... I found comments, that the bootloader is a little picky, so I guess it's a firmware problem.Any idea how to bring the device back to life??Regards

author: Postal2
author_rank: Frequent Contributor
timestamp: June 19, 2024, 01:07:15 pm
content: Quote from: wilhe_jo on June 19, 2024, 11:59:26 amBuy very cheap wch-link on aliexpress and resolder CH549 to your board.https://aliexpress.com/item/1005003346413532.html

author: wilhe_jo
author_rank: Regular Contributor
timestamp: June 19, 2024, 01:30:41 pm
content: Quote from: Postal2 on June 19, 2024, 01:07:15 pmwell, I would do that if I had time and I was sure that the one is flashed with a recent firmware!But I finally (after a good day of hating WCH!), I got it to work.The tool, that helped me is the CH552tool (https://github.com/MarsTechHAN/ch552tool/tree/master).I first erased everything as suggested by the WCH-LinkUserManual (that pdf linked at the beginnin of this thread).this can be done withCode:$ python3 ch55xtool.py -e -cnow flash the firmware and let it reset (I guess, the "-R" is optional if you power-cycle afterwards).Code:$ python3 ch55xtool.py -f /opt/wch/mounriver-studio-community/update/Firmware_Link/WCH-Link_APP_IAP_RV.bin -rif you have the "-r" option, it would fail since the programmer resets after programming. Not nice, but it now shows up as a WLink instead of the bootloader.Without "-r" it would finish correctly and you have to power-cycle manually.Hope that helps some people out there!I tried a good bunch of other programming tools and it seems none of them allow you to erase the flash/data memories...I also tried basically every programming tool from the WCH website... non of them recognized the ISP bootloader (or I was simply too stupid getting them to work).Virtualbox also "crashed"/has frozen several times when connecting/disconnection/reconnecting the programmer.This may result from some bugs in the bootloader, that are mentioned somewhere on the web.My best guess is, that these made the update fail in the VM...However, my programmer now worksRegards

author: Postal2
author_rank: Frequent Contributor
timestamp: June 19, 2024, 02:04:27 pm
content: Quote from: wilhe_jo on June 19, 2024, 01:30:41 pmMounriver under Windows 10 like it.Quote from: wilhe_jo on June 19, 2024, 01:30:41 pmWCHISPTool I showed above is much more reliable.Quote from: wilhe_jo on June 19, 2024, 01:30:41 pmI guarantee WCHISPTool I showed above can do that work perfectly, it's tested with CH549. CH549 has 64kB flash I need for tables, therefore I bought some wch-links because it's cheaper than naked chip.

author: wilhe_jo
author_rank: Regular Contributor
timestamp: June 19, 2024, 02:41:14 pm
content: Quote from: Postal2 on June 19, 2024, 02:04:27 pmWell not for me...I had absolutely no luck with Win10 in a VM.The tool does net even recognize the device even though it is present!However, now I have the next problem... I get LibUSB timeouts .... AHHHH.... why is there no reliable programmer!!Segger has its on problems, but their programmers/debuggers just always work.73

author: Postal2
author_rank: Frequent Contributor
timestamp: June 19, 2024, 03:47:21 pm
content: Quote from: wilhe_jo on June 19, 2024, 02:41:14 pmAs you can see on my screenshot above, WCHISPTool nicely working on Windows XP.

author: MarkMLl
author_rank: Frequent Contributor
timestamp: July 05, 2024, 08:43:31 am
content: Quote from: wilhe_jo on June 18, 2024, 07:26:46 pmI refuse to get drawn into a discussion of Windows and Windows-related VMs, but from earlier messages in the thread you will see that my problems were, by and large, related to the fact that when the role of the chip changed so did its vid:pid doublet.Over the last year or so I've "played around" quite a lot with containerised microcontroller and FPGA development tools, and hardware access problems almost always boiled down to allowing the "guest" software, which should be running with limited access to "host" facilities, sufficient permissions to access arbitrary (USB etc.) devices and possibly to force re-enumeration of the (USB etc.) busses.Simply moving from closed- to open-source tools won't fix this since it's the change-of-role that is significant. At the very least, you would need one set of tools to talk /through/ the programming device and another to talk /to/ it when it wanted its own firmware updated.MarkMLl