Skip to content

how to build flash and use examples on windows

Benjamin Vernoux edited this page Nov 1, 2023 · 28 revisions

How to build flash and use examples on Windows with MSY2/MINGW64 shell

Build the firmware source code for HydraUSB3(CH569W MCU) with MSY2/MINGW64 shell

How to build the firmware source code for HydraUSB3(CH569 MCU) with MSY2/MINGW64 shell

Prerequisites

Clone the hydrausb3_fw repository with git

  • Start mingw64
cd ~
git clone --recursive https://github.com/hydrausb3/hydrausb3_fw.git

Windows 10 x64 + open source GCC RISC-V v12.2.0 with MSYS2/MINGW64

  • Start mingw64
  • Add the path to "GCC RISC-V v12.2.0" (example with nomultilib version xpack-riscv-none-elf-gcc-12.2.0-1-win32-x64.zip extracted in c: and renamed xpack-riscv-none-elf-gcc-12.2.0-1-win32-x64_wch_nomultilib) bin directory
    • PATH="/c/xpack-riscv-none-elf-gcc-12.2.0-1-win32-x64_wch_nomultilib/bin/":$PATH
  • Change current directory to firmware example (here HydraUSB3_Blink_ULED)
    • cd ~/hydrausb3_fw/HydraUSB3_Blink_ULED
  • Clean and build the firmware example
    • make clean all
  • The flashable firmware with wch-ch56x-isp (*.bin) is available in ~/hydrausb3_fw/HydraUSB3_Blink_ULED/build/HydraUSB3_Blink_ULED.bin

Windows 10 x64 + MounRiver Studio Community Win V130 with MSYS2/MINGW64

  • Start mingw64
  • Add the path to "RISC-V Embedded GCC" bin directory
    • For MounRiver Studio Community Win V130(or more)
      • PATH="/c/MounRiver/MRS_Community/toolchain/RISC-V Embedded GCC/bin/":$PATH
  • Change current directory to firmware example (here HydraUSB3_Blink_ULED)
    • cd ~/hydrausb3_fw/HydraUSB3_Blink_ULED
  • Clean and build the firmware example
    • make clean all
  • The flashable firmware with wch-ch56x-isp (*.bin) is available in ~/hydrausb3_fw/HydraUSB3_Blink_ULED/build/HydraUSB3_Blink_ULED.bin

Flash and use hydrausb3_fw example(s)

Prerequisites

  • Start mingw64
  • Install pkg-config and libusb-1.0-0-dev
    • pacman -S mingw-w64-x86_64-pkgconf mingw-w64-x86_64-libusb

Clone & build wch-ch56x-isp

  • Start mingw64
cd ~
git clone --recursive https://github.com/hydrausb3/wch-ch56x-isp.git
cd wch-ch56x-isp
make clean all

Flash and use hydrausb3_fw example

  1. On HydraUSB3 (disconnect any cable/power supply) and add a Jumper on Flash Mode P3
  2. Connect “USB A Male to USB A male cable” to HydraUSB3 then the other side to PC(USB2 or USB3 port)
  3. The PC shall detect the WCH CH569W Bootloader (enumeration as USB2 Full-Speed)
    • Download & Execute Zadig 2.7
      • Install driver "WinUSB" with Zadig for the USB ID 4348 55E0
        • Note after 10s of inactivity the bootloader exit and run the program
          • You can just reset the board to re-enter in bootloader by pressing(1s) & releasing 3V3 DISABLE button(at left of USB3 connector)
          • During Install with Zadig it is advised to reboot the bootloader (by pressing(1s) & releasing 3V3 DISABLE button at left of USB3 connector) each 5s until the Zadig driver install is done else it will fail if it does not detect the board in bootloader mode
    • You can check it is well recognized with windows PowerShell with command:
      • Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB\\VID_4348' } | Format-List
      • Which shall find :
      • ...
      • HardwareID : {USB\VID_4348&PID_55E0&REV_2700, USB\VID_4348&PID_55E0}
      • Manufacturer : WinChipHead
      • PNPClass : USBDevice
      • Present : True
      • Service : WinUSB
      • ...
    • Note after 10s of inactivity the bootloader exit and run the program
      • You can just reset the board to re-enter in bootloader by pressing(1s) & releasing 3V3 DISABLE button(at left of USB3 connector)
  4. Launch(quickly to avoid 10s timeout) wch-ch56x-isp to flash(and verify) the hydrausb3_fw example (here HydraUSB3_Blink_ULED)
    • ./wch-ch56x-isp -v -f=~/hydrausb3_fw/HydraUSB3_Blink_ULED/obj/HydraUSB3_Blink_ULED.bin
  5. On HydraUSB3 Remove the Jumper on Flash Mode P3
  6. On HydraUSB3 Press(1s) & Release the 3V3 DISABLE button(at left of USB3 connector) to reset the board
  • The HydraUSB3 board shall execute the HydraUSB3_Blink_ULED firmware example by blinking the ULED
    • Note: If you press UBTN the ULED blink very fast