Getting Started
Adafruit Playground is a wonderful and safe place to share your interests with Adafruit's vibrant community of makers and doers. Have a cool project you are working on? Have a bit of code that you think others will find useful? Want to show off your electronics workbench? You have come to the right place.
The goal of Adafruit Playground is to make it as simple as possible to share your work. On the Adafruit Playground users can create Notes. A note is a single-page space where you can document your topic using Adafruit's easy-to-use editor. Notes are like Guides on the Adafruit Learning System but guides are high-fidelity content curated and maintained by Adafuit. Notes are whatever you want them to be. Have fun and be kind.
Click here to learn more about Adafruit Playground and how to get started.
-
Using the Adafruit QT Py CH32V203 Dev Board with STEMMA QT
The
Adafruit QT Py CH32V203 Dev Board with STEMMA QT(Product ID:5996) is very similar to theLANA-TNY-01board (which will soon be for sale on Adafruit as well). Both have the exact same MCU: theCH32V203G6U6.Programming this chip is not easy. Most people get stuck with the vendor-provided Mounriver Studio IDE. However, you can also program it with Embeetle IDE. For the complete guide, check out this page:
https://embeetle.com/#supported-hardware/wch/boards/lana-tny-01
Below we'll go through the most basic steps.
STEP 1: Download Embeetle IDE
First download Embeetle:
https://embeetle.com/#embeetle-ide/downloadYou can download it for either Windows or Linux. We don't have MAC support yet.
STEP 2: Launch the ProjectLaunch Embeetle and click CREATE PROJECT:
Then selectWCHfor the vendor (that's the vendor of the microcontroller) and look for the projectlana-tny-01:Now click CREATE at the bottom. Embeetle IDE downloads the sample project and also all the required tools automatically. Then the project opens:
STEP 3: Plug in the boardFIRST press the
BOOTswitch, THEN plug your board into the computer with a USB-C cable (while keeping theBOOTswitch pressed):When the board is plugged in, you can release the
BOOTswitch. This procedure ensures that your board is now in "bootloader mode". That means the microcontroller is ready to receive a new firmware!STEP 4: Flash the firmware
Now click the
flashbutton at the top in Embeetle IDE. Embeetle will try to flash the firmware to the board. However, you might experience the following error now:Failed to open USB device: Bus 001 Device 008: ID 4348:55e0
Error: Failed to open USB device on Windows
On Linux you might experience another issue:Failed to open USB device: Bus 003 Device 010: ID 4348:55e0
Error: Failed to open USB device on Linux due to no enough permissionLet's fix this.
STEP 5a: Install Zadig (Windows only)
You must install Zadig and replace the driver for the USB device with the WinUSB driver. First, download Zadig:
Then, open Zadig and selectOptions -> List All Devices:Select
USB Modulefrom the list of devices and chooseWinUSBas the driver. Then clickReplace Driver:Maybe you didn't find
USB Modulein the list of devices? In that case, you might findUnknown Device #1instead. Take that one and chooseWinUSBas the driver. Then clickReplace Driver:Wait for the driver installation to complete:
Success:
Try again in Embeetle IDE. It should work now:
"C:/Users/krist/EMBEETLE IDE/embeetle/beetle_tools/windows/wchisp_0.2.2_64b/wchisp.exe" flash application.elf
14:57:06 [INFO] Chip: CH32V203G6U6[0x3619] (Code Flash: 32KiB)
14:57:06 [INFO] Chip UID: CD-AB-19-97-D0-BC-B6-FF
14:57:06 [INFO] BTVER(bootloader ver): 02.70
14:57:06 [INFO] Code Flash protected: false
14:57:06 [INFO] Current config registers: a55aff0000ff00ffffffffff00020700cdab1997d0bcb6ff
RDPR_USER: 0x00FF5AA5
[7:0] RDPR 0xA5 (0b10100101)
`- Unprotected
[16:16] IWDG_SW 0x1 (0b1)
`- IWDG enabled by the software, and disabled by hardware
[17:17] STOP_RST 0x1 (0b1)
`- Disable
[18:18] STANDBY_RST 0x1 (0b1)
`- Disable, entering standby-mode without RST
[23:22] SRAM_CODE_MODE 0x3 (0b11)
`- CODE-228KB + RAM-32KB / CODE-160KB + RAM-32KB depending on the chip
DATA: 0xFF00FF00
[7:0] DATA0 0x0 (0b0)
[23:16] DATA1 0x0 (0b0)
WRP: 0xFFFFFFFF
`- Unprotected
14:57:06 [INFO] Read application.elf as ELF format
14:57:06 [INFO] Found loadable segment, physical address: 0x00000000, virtual address: 0x00000000, flags: 0x5
14:57:06 [INFO] Section names: [".init", ".vector", ".text"]
14:57:06 [INFO] Found loadable segment, physical address: 0x00000dbc, virtual address: 0x20000000, flags: 0x6
14:57:06 [INFO] Section names: [".data"]
14:57:06 [INFO] Firmware size: 4096
14:57:06 [INFO] Erasing...
14:57:06 [WARN] erase_code: set min number of erased sectors to 8
14:57:06 [INFO] Erased 8 code flash sectors
14:57:07 [INFO] Erase done
14:57:07 [INFO] Writing to code flash...
██████████████████████████████████████ 4096/409614:57:07 [INFO] Code flash 4096 bytes written
14:57:08 [INFO] Verifying...
██████████████████████████████████████ 4096/409614:57:08 [INFO] Verify OK
14:57:08 [INFO] Now reset device and skip any communication errors
14:57:08 [INFO] Device resetIf it didn't work, pull out the LANA module and plug it back into your computer while pressing the
BOOTswitch (release the button a few seconds after you plugged it into the computer), to ensure it really is in "bootloader mode". If it still doesn't work, don't hesitate to contact us:
- Email: [email protected]
- Discord: @kristof-at-embeetleSTEP 5b: Add device to plugdev group (Linux only)
On Linux you'll have to add the device to the plugdev group. First check groups related to the current user:
$ groups `whoami`
kristof : kristof adm cdrom sudo dip plugdev lpadmin lxd sambashareIf
plugdevwould not be listed, add the current user to that group:$ sudo useradd -G plugdev `whoami`
Figure out your device's Vendor ID and Product ID through the
$ lsusbcommand:$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 046d:c548 Logitech, Inc. Logi Bolt Receiver
Bus 003 Device 003: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 003 Device 004: ID 04f2:b75c Chicony Electronics Co., Ltd FHD Webcam
Bus 003 Device 005: ID 1a2c:4324 China Resource Semico Co., Ltd USB Keyboard
Bus 003 Device 006: ID 048d:6005 Integrated Technology Express, Inc. ITE Device(8291)
Bus 003 Device 007: ID 1bcf:2701 Sunplus Innovation Technology Inc. HD 720P webcam
Bus 003 Device 008: ID 048d:ce00 Integrated Technology Express, Inc. ITE Device(8291)
Bus 003 Device 009: ID 8087:0026 Intel Corp. AX201 Bluetooth
Bus 003 Device 011: ID 4348:55e0 WinChipHead
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 004 Device 002: ID 0bda:0316 Realtek Semiconductor Corp. Card ReaderLook for the line with
WinChipHead(third to last). As you can see, the ID for my device consists of two 4-digit hex numbers:ID 4348:55e0. The first one is the Vendor ID, the second one the Product ID. Do not confuse them!In the console, navigate to
/etc/udev/rules.dand list the contents of the directory:$ cd /etc/udev/rules.d
$ ls
70-snap.core.rules
70-snap.firefox.rules
70-snap.snap-store.rulesNow create a new file, for example with the gedit editor:
$ sudo gedit 10-probe.rules
You can name this file whatever you want, so long as it ends in
.rules. Rules files by convention begin with a number. Linux parses rules files in lexical order, and the number makes it easy to see which files will be parsed first. Choosing a low number (like 10, as above) means that your file will be parsed before system rules files.Now you need to add a line in the file that represents your device. If the file already existed (from a previous device you added this way), you can leave all the content as-is and just add a line at the bottom. The line you need to add is:
ATTRS{idVendor}=="4348", ATTRS{idProduct}=="55e0", MODE="666", GROUP="plugdev"Note: In older Ubuntu/Linux installations, you might need to replace 'ATTRS' with 'SYSFS' in the line below.
Of course, fill in your own Vendor ID and Product ID! (although the ones above should be correct).
Save the file and close it. Now you need to tell Linux to reload the udev rules:$ sudo udevadm trigger
Any member of the plugdev group should now be able to run
wchispwithout using sudo.Try again to flash in Embeetle IDE.
If it doesn't work, pull out the LANA module and plug it back into your computer while pressing theBOOTswitch (release the button a few seconds after you plugged it into the computer), to ensure it really is in "bootloader mode". If it still doesn't work, don't hesitate to contact us:
- Email: [email protected]
- Discord: @kristof-at-embeetle