Fail to upload Kendryte standalone Hello example on Maix Bit with Sipeed RV-Debugger Fai

Hi,
I am trying to upload and debug with a brand new Sipeed RV USB Debugger on a Maix Bit device. But its failing to upload on windows with Visual Studio Code. can someone please advise, thanks

I followed the instructions on using Zadig to get the device setup, and now it looks like this is DM

The error is

** Programming Started **
embedded:startup.tcl:476: Error: ** Programming Failed **
in procedure 'program' 
in procedure 'program_error' called at file "embedded:startup.tcl", line 532
at file "embedded:startup.tcl", line 476
*** [upload] Error 1
Processing sipeed-maix-bit (platform: kendryte210; board: sipeed-maix-bit; framework: kendryte-standalone-sdk)
------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/kendryte210/sipeed-maix-bit.html
PLATFORM: Kendryte K210 (1.2.4) > Sipeed MAIX BiT
HARDWARE: K210 400MHz, 6MB RAM, 16MB Flash
DEBUG: Current (iot-bus-jtag) External (iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, 
olimex-jtag-tiny, sipeed-rv-debugger, tumpa)
PACKAGES:
 - framework-kendryte-standalone-sdk 0.5.6
 - tool-kflash-kendryte210 0.9.1
 - tool-openocd-kendryte 1.203.1 (2.3)
 - toolchain-kendryte210 8.2.0
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\sipeed-maix-bit\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.5% (used 31432 bytes from 6291456 bytes)
Flash: [          ]   0.3% (used 57966 bytes from 16777216 bytes)
Configuring upload protocol...
AVAILABLE: iot-bus-jtag, jlink, kflash, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, sipeed-rv-debugger, tumpa
CURRENT: upload_protocol = sipeed-rv-debugger
Uploading .pio\build\sipeed-maix-bit\firmware.bin
 _  __              _            _     
| |/ /___ _ __   __| |_ __ _   _| |_ ___  
| ' // _ \ '_ \ / _` | '__| | | | __/ _ \
| . \  __/ | | | (_| | |  | |_| | ||  __/
|_|\_\___|_| |_|\__,_|_|   \__, |\__\___|
                           |___/
Kendryte Open On-Chip Debugger For RISC-V v0.2.3 (2019-02-21)
Licensed under GNU GPL v2
debug_level: 1
ftdi samples TDO on falling edge of TCK
adapter speed: 1000 kHz
riscv.cpu
Core [0] halted at 0x8000a96e due to debug interrupt
** Programming Started **
embedded:startup.tcl:476: Error: ** Programming Failed **
in procedure 'program' 
in procedure 'program_error' called at file "embedded:startup.tcl", line 532
at file "embedded:startup.tcl", line 476
*** [upload] Error 1
======================================================= [FAILED] Took 1.94 seconds =======================================================The terminal process "C:\Users\marcu\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload', '--environment', 'sipeed-maix-bit'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

My platformio.ini is

[env:sipeed-maix-bit]
platform = kendryte210
board = sipeed-maix-bit
framework = kendryte-standalone-sdk
monitor_speed = 115200
board_build.mcu = K210
; change MCU frequency
board_build.f_cpu = 400000000L
upload_protocol = sipeed-rv-debugger

Sadly that’s a known issue per Native "program" command does not work · Issue #11 · kendryte/openocd-kendryte · GitHub.

However it also says that a GDB load command works. This might mean that debugging works and for normal firmware uploading you should use the old upload method.

Try

[env:sipeed-maix-bit]
platform = kendryte210
board = sipeed-maix-bit
framework = kendryte-standalone-sdk
monitor_speed = 115200
board_build.mcu = K210
; change MCU frequency
board_build.f_cpu = 400000000L
; uplaod via OpenOCD does not work.
upload_protocol = kflash
; debug.. (which includes a firmware upload but through a different method) maybe.
debug_tool = sipeed-rv-debugger

Try going into the debugger sidebar and press the play button. (of course selecting the correct project env and debugger config corresponding to the project are prerequisites).

Hi,
Get a different error, looks like the upload fails still

CURRENT: upload_protocol = kflash
Looking for upload port…
Auto-detected: COM16
Uploading .pio\build\sipeed-maix-bit\firmware.bin
[INFO] COM Port Selected Manually: COM16
[INFO] Default baudrate is 115200 , later it may be changed to the value you set.
[INFO] Trying to Enter the ISP Mode…

Greeting fail, check serial port ([ERROR] No vaild Kendryte K210 found in Auto Detect, Check Your Connection or Specify One by-p COM3 )*** [upload] Error 1
====================================================== [FAILED] Took 14.48 seconds ======================================================
The terminal process “C:\Users\marcu.platformio\penv\Scripts\platformio.exe ‘run’, ‘–target’, ‘upload’, ‘–environment’, ‘sipeed-maix-bit’” terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Is that one correct? Maybe you have multiple ones through the debugger. Check the Windows device manager.

Hi,

Ok - so I rebooted, unplugged the rv debug completely. Now I can’t seem to even upload to the Maix Bit with just the standard USB connection from PC host to device. I have manually forced the COM port which is 20, must be driver related, it cant enter ISP mode. I also swapped the Maix Bit device for another one to make sure its not a broken device

[env:sipeed-maix-bit]
platform = kendryte210
board = sipeed-maix-bit
framework = kendryte-standalone-sdk
monitor_speed = 115200
board_build.mcu = K210
; change MCU frequency
board_build.f_cpu = 400000000L
upload_protocol = kflash
debug_tool = sipeed-rv-debugger
upload_port = COM20

So above is when there is only one USB cable from host to Maix Bit, no sipeed usb rv is plugged in.

The error is

Use manually specified: COM20
Uploading .pio\build\sipeed-maix-bit\firmware.bin
[INFO] COM Port Selected Manually: COM20
[INFO] Default baudrate is 115200 , later it may be changed to the value you set.
[INFO] Trying to Enter the ISP Mode…

Greeting fail, check serial port ([ERROR] No vaild Kendryte K210 found in Auto Detect, Check Your Connection or Specify One by-p COM3 )
*** [upload] Error 1
======================================================= [FAILED] Took 13.45 seconds =======================================================The terminal process “C:\Users\marcu.platformio\penv\Scripts\platformio.exe ‘run’, ‘–target’, ‘upload’, ‘–environment’, ‘sipeed-maix-bit’” terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

I can’t even upload in ArduinoIDE. So maybe I have messed up the driver by using Zadig ?

The uploader only needs the COM port, not the Sipeed-Debug device (which is the RV-Link I guess?).

COM3 is an unrelated COM port?

It might be possible that something has gone wrong when connecting the debugger to the module, hard to say.

The way I see it in the schematics, debugging involves these sections

grafik


The USB-Serial converter is connected to the USB-C port on one side. The chip’s (UART) TXD signal is the K210’s ISP_RX signal and is directly connected to the chip. Conversely RXD is the K210’s ISP_TX. To make the K210 enter bootloader mode, the USB-Serial converter’s RTS and DTR pins are used as basically GPIO pins, controlling the RST and BOOT lines of the K210 through transistors (Q1 and Q2). This is basically the same concept as with the ESP32’s auto-reset circuit.

Using the pin diagrams as shown here you should be able to use a multimeter and check whether all signals are still connected properly, that is, check continuity between TXD (of the CH340C) and the pin after TDO (as marked in the linked pin diagram), then RXD, DTR to the transistor, RTS to the transistor, transistor to RST, transistor to BOOT, etc.

The ISP RX and TX lines are right after the JTAG connections. You might have disconnected something when soldering the JTAG signals in, or accidentally shorted a signal with another one.

Again, you might not need ISP (UART) programming if you can connect to the chip via JTAG. Have you tried starting debugging with the Sipeed RV Debugger?

Oh, actually the VisualGDB link shows how to do it for a Maixduino board (schematics), which is not a Maix Bit.

The Maix-Bit is however extremely easy laid-out for JTAG debugging, since the needed JTAG signals are right on the big J1 header this time

Did you do any soldering modifications to the board?

Hi,

Thanks for helping with this. I haven’t changed the board at all, just got it OTB yesterday.

So I have restored all my drivers to their original state (back to FTDI), and am just using the Maix Bit Mic (this is a Mic variant I found out) with Arduino IDE and a single USB-C cable, and it works for uploading. So I am using COM5, with a simple setup() of serial.begin(115200); and in my loop just a Serial.println(“hello”);

It works uploading from ArduinoIDE, and enters ISP mode witrh [INFO] Automatically detected goE/kd233

INFO] ANSI colors not used 
[INFO] COM Port Selected Manually:  COM5 
[INFO] Default baudrate is 115200 , later it may be changed to the value you set. 
[INFO] Trying to Enter the ISP Mode... 
._
**[INFO] Automatically detected goE/kd233** 

[INFO] Greeting Message Detected, Start Downloading ISP 
[INFO] CH340 mode 
Downloading ISP: |=============================================| 100.0% 8kiB/s

[INFO] Booting From 0x80000000 
[INFO] Wait For 0.1 second for ISP to Boot 
[INFO] Boot to Flashmode Successfully 
[INFO] Selected Baudrate:  1500000 
[INFO] Baudrate changed, greeting with ISP again ...  
[INFO] Boot to Flashmode Successfully 
[INFO] Selected Flash:  On-Board 
[INFO] Initialization flash Successfully 
Programming BIN: |=============================================| 100.0% 52kiB/s

[INFO] Rebooting... 
-------------------------------------------

Then I take the same code and do an Arduino project in platformio, and use the same com port, and I get this verbose uploading, note that I can see the little LED Rx working on the board so it has comms, it just cant enter ISP

> Executing task in folder ard_hello_bit-mic: C:\Users\marcu\.platformio\penv\Scripts\platformio.exe run --verbose --target upload --environment sipeed-maix-bit-mic <

Processing sipeed-maix-bit-mic (platform: kendryte210; board: sipeed-maix-bit-mic; framework: arduino; upload_port: COM5; board_build.f_cpu: 400000000L)
------------------------------------------------------------------------------------------------------------------------------------------CONFIGURATION: https://docs.platformio.org/page/boards/kendryte210/sipeed-maix-bit-mic.html
PLATFORM: Kendryte K210 (1.2.4) > Sipeed MAIX BiT with Mic
HARDWARE: K210 400MHz, 6MB RAM, 16MB Flash
DEBUG: Current (iot-bus-jtag) External (iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, 
olimex-jtag-tiny, sipeed-rv-debugger, tumpa)
PACKAGES:
 - framework-maixduino 0.3.9
 - tool-kflash-kendryte210 0.9.1
 - tool-openocd-kendryte 1.203.1 (2.3)
 - toolchain-kendryte210 8.2.0
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 14 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
MethodWrapper(["checkprogsize"], [".pio\build\sipeed-maix-bit-mic\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.5% (used 33314 bytes from 6291456 bytes)
Flash: [          ]   0.7% (used 114327 bytes from 16777216 bytes)
text       data     bss     dec     hex filename

 109221    5106   28208  142535   22cc7 .pio\build\sipeed-maix-bit-mic\firmware.elf
<lambda>(["upload"], [".pio\build\sipeed-maix-bit-mic\firmware.bin"])
AVAILABLE: iot-bus-jtag, jlink, kflash, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, sipeed-rv-debugger, tumpa
CURRENT: upload_protocol = kflash
MethodWrapper(["upload"], [".pio\build\sipeed-maix-bit-mic\firmware.bin"])
Use manually specified: COM5
"c:\users\marcu\.platformio\penv\scripts\python.exe" "C:\Users\marcu\.platformio\packages\tool-kflash-kendryte210\kflash.py" -p COM5 -b 1500000 -B bit .pio\build\sipeed-maix-bit-mic\firmware.bin
[INFO] COM Port Selected Manually:  COM5 
[INFO] Default baudrate is 115200 , later it may be changed to the value you set.
[INFO] Trying to Enter the ISP Mode...
...............
Greeting fail, check serial port ([ERROR] No vaild Kendryte K210 found in Auto Detect, Check Your Connection or Specify One by`-p COM3`  )*** [upload] Error 1
====================================================== [FAILED] Took 13.95 seconds ======================================================
The terminal process "C:\Users\marcu\.platformio\penv\Scripts\platformio.exe 'run', '--verbose', '--target', 'upload', '--environment', 'sipeed-maix-bit-mic'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

My sipeed-maix-bit-mic.json contains this - maybe I changed something in here before and have forgotten about it ?

{
    "build": {
        "extra_flags": "",
        "f_cpu": "400000000L",
        "mcu": "K210",
        "hwids": [
            "0x0403",
            "0x6010"
        ],
        "variant": "sipeed_maix_bit",
        "board_def": "BOARD_SIPEED_MAIX_BIT"
    },
    "frameworks": [
        "kendryte-standalone-sdk",
        "kendryte-freertos-sdk",
        "arduino"
    ],
    "name": "Sipeed MAIX BiT with Mic",
    "upload": {
        "maximum_ram_size": 6291456,
        "maximum_size": 16777216,
        "burn_tool": "bit",
        "require_upload_port": true,
        "speed": 1500000
    },
    "url": "https://www.sipeed.com/",
    "vendor": "Sipeed"
}

And the on above pulls in this one sipeed-maix-bit.json - which uses a different burn tool ?

{
    "build": {
        "extra_flags": "",
        "f_cpu": "400000000L",
        "mcu": "K210",
        "hwids": [
            "0x1A86",
            "0x7523"
        ],
        "variant": "sipeed_maix_bit",
        "board_def": "BOARD_SIPEED_MAIX_BIT"
    },
    "frameworks": [
        "kendryte-standalone-sdk",
        "kendryte-freertos-sdk",
        "arduino"
    ],
    "name": "Sipeed MAIX BiT",
    "upload": {
        "maximum_ram_size": 6291456,
        "maximum_size": 16777216,
        "burn_tool": "dan",
        "require_upload_port": true,
        "speed": 2000000
    },
    "url": "https://www.sipeed.com/",
    "vendor": "Sipeed"
}

Looking at this page

qingpeng9802/build-maix-bit-k210-bare-metal-debug-dev-env: This tutorial is designed to help you build a bare metal debugging and development environment for Sipeed Maix Bit (Kendryte 210). (github.com)

which mentions using a VM, and then connecting the debugger to it, whilst leaving the serial port in the host to avoid any conflict. Sounds a bit weird…

" Notice that Maix Bit use CH552 chip to implement USB-Serial without JTAG. (K210 supports JTAG, but the CH552 on Maix Bit has no JTAG function)
CH552 contains FT2232c chip, which is the same as the debugger chip and causing conflict if they are used at same time.

ONLY connect the debugger to your VM to avoid conflict!

  1. Download Kendryte OpenOCD Relaese v0.2.3"

I got this working, I can now debug a Maix Bit with the Sipeed USB debugger, and therefore can now debug k210 - with RISC V !
But this is out of 5 Sipeed board types, Longan nano, Dock I (this worked for a bit with Jlink), Dock II, Maxduino (has no header for JTAG) and Bit. The Bit is the only one I can debug with. Now I can write some code. Thanks for all your help on here !

Hi,
Here is the author of the tutorial, and it sounds like my wording causes some confusion. Let me clarify it here for future reference :slight_smile:

Maix Bit uses the CH552 to emulate FT2232 chip to implement USB-Serial. However, the CH552 has no JTAG so we need an RV Debugger that has a real FT2332 for JTAG.

Then, the core of the conflict is that the debugger chip (FT2332) and the chip (CH552) used to implement the serial port function use the same FT2332 driver, but OpenOCD has no way to distinguish two chips (even with cfg, by my experience). Thus, we try not to use both chips at the same time in the same environment.

Last, since the debugger also has serial port, so there are two proposed solutions:

  1. Debugger → VM: serial port (UART) + OpenOCD
  2. Debugger → VM: OpenOCD, Maix Bit → Host: serial port (UART)

I can now also debug with the Sipeed RV Debugger with a Maix BIT in VS Code in Windows without a VM. I think I may have before just got confused with everything being new. Here are the steps to achieve debugging on the Maix Bit, I am sure all this is already listed in the instructions - but here is exactly wh t I did to get it working.

The debugger can not be used for uploading new firmware, so use a normal ftdi232 or whatever ( I use a $5 FT232RL FTDI Mini USB to TTL Serial Converter Adapter Module) for that , simply connect the device to your PC, have Rx to Tx, Tx to Rx make sure this is working before proceeding i.e. try it with any device that gives Serial output, also use the 3.3v/5v and Gnd to the Maix Bit to give it power. Then get the COM port its assigned to from the device manager- and save this for later.

Now set up the debugger

  1. Plug in the debugging device
  2. run Zadig to change the driver
  3. Change the Dual RS232 (interface 0) to use the WinUSB (v6.1…)
  4. Make sure in Windows device manager you can see Dual RS 232 listed under Universal Serial Bus
    devices, while in here make sure you can still see the FTDI232 USB to serial COM port - under the Ports (LPT & COM) section, eg USB Serial Port (Com X), use the X number as the Upload com port in the platformio.ini below
  5. In VSCode create a new platformio project to download the Maix Bit SDK - new project - board type : maix bit and framework : kendryte freertos or kendryte standalone SDK
  6. Now create an example project from platforio home, for example “kendryte-freertos-sdk_hello” - this will give you a main.c and all make files etc
  7. Change the platformio.ini - the following works with free rtos and standalone sdk - but change the framework field below for standalone - set the Upload port to the COM port number for your FTDI from the first step above

[env:sipeed-maix-bit-mic-freertos]
platform = kendryte210
board = sipeed-maix-bit-mic
board_build.mcu = K210
board_build.f_cpu = 400000000L
framework = kendryte-standalone-sdk
upload_protocol = kflash
upload_port=COM12
debug_tool = sipeed-rv-debugger
monitor_speed = 115200

  1. Connect the debugger to the Maix Bit, the pins are easy to match - Sipeed RV debugger needs the following connecting - tdi, rst, tms, tdo, tck these go to pins on the Maix Bit respectively Pin 1, RST, 2, 3, 0
  2. I also connect the 5v, 3v and Gnd from the debugger to the board (remove any other voltage supply to the maix bit for example from the the TDI232 - but keep the ground connected from the tdi232 to the board - you need this for uploading.
  3. So now you should have the tdi232 ground and rx and tx connected, and the RV debugger jtag pins, reset, ground, 5v and 3.3v connected
  4. Now build your project
  5. Upload it
  6. put a breakpoint in main
  7. run the platform io debugger option - it should work first time.

If you are just debugging and not using the upload feature you will need to just kick off the debugger from platfomio without uploading.

The 2 problems I had that stopped this working for me were

  1. Used this for the board type
    board = sipeed-maix-bit
    And I should have been using
    board = sipeed-maix-bit**-mic**

  2. Tried to upload the new firmware using the Sipeed RV debugger - cant do this as it doesnt work - you need to use a separate FTDI, USB to serial etc

Thanks.