Giter VIP home page Giter VIP logo

rv-debugger-bl702's Introduction

Description

RV-Debugger-BL702 is an opensource project that implement a JTAG+UART debugger with BL702C-A0.

BL702 is highly integrated BLE and Zigbee combo chipset for IoT applications, contains 32-bit RISC-V CPU with FPU, frequency up to 144MHz, with 132KB RAM and 192 KB ROM, 1Kb eFuse, 512KB embedded Flash, USB2.0 FS device interface, and many other features.

The firmware implement is inspired by open-ec, implement by Sipeed teams and community developers.

The firmware emulate an FT2232D device, defaultly implement an JTAG+UART debugger, and can be implement as a Dual-Serial Port debugger, a bluetooth debugger, etc.

Community Forum: bbs.sipeed.com

Hardware

Offical Board

Sipeed RV-Debugger-Plus (BL702C-A0)

Purchase link: taobao.com/xxx

Schematic: BL702_USB2JTAG_3610_sch.pdf

Assembly: BL702_USB2JTAG_3610_asm.pdf

(LED0 is the led close to edge, indicate for RX)


Third-party Hardware

TODO

Firmware

Flash Tutorial

Press "boot" button then plug usb cable, and you will see "CDC Virtual ComPort" in device manager , remember the com number.

The flash tool is in tools/bflb_flash_tool directory, and input the command (replace port number and firmware name):

Windows:
.\bflb_mcu_tool.exe --chipname=bl702 --port=COM9 --xtal=32M --firmware="main.bin"
Linux:
./bflb_mcu_tool --chipname=bl702 --port=/dev/ttyACM0 --xtal=32M --firmware="main.bin"
tools\bflb_flash_tool> .\bflb_mcu_tool.exe --chipname=bl702 --port=COM9 --xtal=32M --firmware="main.bin"
[22:07:28.296] - ==================================================
[22:07:28.296] - Chip name is bl702
[22:07:28.297] - Serial port is COM9
[22:07:28.299] - Baudrate is 115200
[22:07:28.299] - Firmware is main.bin
[22:07:28.300] - Default flash clock is 72M
[22:07:28.300] - Default pll clock is 144M
[22:07:28.311] - ==================================================
[22:07:28.483] - Update flash cfg finished
[22:07:28.500] - EFUSE_CFG
[22:07:28.500] - BOOTHEADER_CFG
......
[22:07:31.274] - Load 53856/53856 {"progress":100}
[22:07:31.274] - Write check
[22:07:31.274] - Flash load time cost(ms): 267.942626953125
[22:07:31.275] - Finished
[22:07:31.276] - Sha caled by host: 825d198270c2cf509acda8f8e0830751c532da802060c324a4479e1fe599ae1f
[22:07:31.276] - xip mode Verify
[22:07:31.288] - Read Sha256/53856
[22:07:31.288] - Flash xip readsha time cost(ms): 12.508056640625
[22:07:31.288] - Finished
[22:07:31.288] - Sha caled by dev: 825d198270c2cf509acda8f8e0830751c532da802060c324a4479e1fe599ae1f
[22:07:31.288] - Verify success
[22:07:31.289] - Program Finished
[22:07:31.289] - All time cost(ms): 2220.2548828125
[22:07:31.390] - [All Success]

Another GUI flash tool is BouffaloLabDevCube:

usb2uartjtag (default)

Support JTAG+UART function

UART support baudrate below 2Mbps, and 3Mbps, and some experimental baudrate (stability is not guaranteed):

12M, 9.6M, 8M, 6.4M, 6M, 4.8M, 4M, 3.2M
we remap baudrate in 10000~12000 to (baud-10000)*10000
for example, 11200bps -> 12Mbps

LED0 for RX indication, LED1 for TX indication.

JTAG function is verified for :

  • RV32 Xuantie E906/E907
  • RV64 Xuantie C906
  • Gowin FPGA GW1N-1, GW1NS-4C. (need enable GOWIN_INT_FLASH_QUIRK)

usb2dualuart

TODO.

Project Structure

RV-Debugger-BL702
├── bsp
│   ├── board
│   │   └── bl702_debugger
│   └── bsp_common
│       └── platform
├── common
│   ├── device
│   ├── libc
│   ├── list
│   ├── memheap
│   ├── misc
│   ├── partition
│   ├── ring_buffer
│   └── soft_crc
├── components
│   ├── shell
│   └── usb_stack
├── drivers
│   └── bl702_driver
├── examples
│   └── usb
│       ├── usb2uartjtag
│       └── usb2dualuart
├── out
├── tools
│   ├── bflb_flash_tool
│   ├── cdk_flashloader
│   ├── cmake
│   └── openocd
└── hardware
    

BL SDK usage tutorial refer to http://bouffalolab.gitee.io/bl_mcu_sdk/

Develop Guide

Build

just "make"

Code Explanation

the main file is:

examples/usb/usb2uartjtag:
├── main.c
├── uart_interface.c
├── jtag_process.c
└── io_cfg.h         //main io cfg, another file is pinmux_config.h in bsp/board/bl702_debugger
components/usb_stack/class/vendor:
└── usbd_ftdi.c      //all FTDI vendor request process, like baudrate set, dtr/rts set, Latency_Timer

TODO

rv-debugger-bl702's People

Contributors

bitsk avatar taorye avatar zepan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rv-debugger-bl702's Issues

win7 上该设备不识别

调试器接到 win7 电脑上不能正常识别,且无虚拟串口,察看设备管理器接图如下:
Image 17.png

测试在 Fedora35 上可以正常识别。

USB enumeration issues

I'm experiencing USB enumeration issues on the Tang Nano 1K, 4K, and 9K boards. It seems that they use the same chip and presumably also the same firmware as this project so I'm reporting it here. Correct me if I'm wrong.

The problem is that when I try to connect the programmer to my computer over a USB hub, it fails to enumerate.

[29332.909014] usb 7-1.2: new full-speed USB device number 8 using xhci_hcd
[29338.196264] usb 7-1.2: device descriptor read/64, error -71
[29343.532540] usb 7-1.2: device descriptor read/64, error -71
[29343.722499] usb 7-1.2: new full-speed USB device number 9 using xhci_hcd
[29348.862626] usb 7-1.2: device descriptor read/64, error -71
[29354.196037] usb 7-1.2: device descriptor read/64, error -71
[29354.302915] usb 7-1-port2: attempt power cycle
[29354.916045] usb 7-1.2: new full-speed USB device number 10 using xhci_hcd
[29360.086242] xhci_hcd 0000:0a:00.3: Timeout while waiting for setup device command
[29365.419676] xhci_hcd 0000:0a:00.3: Timeout while waiting for setup device command
[29365.626240] usb 7-1.2: device not accepting address 10, error -62
[29365.709582] usb 7-1.2: new full-speed USB device number 11 using xhci_hcd
[29365.709791] usb 7-1.2: Device not responding to setup address.
[29365.916323] usb 7-1.2: Device not responding to setup address.
[29366.123016] usb 7-1.2: device not accepting address 11, error -71
[29366.123294] usb 7-1-port2: unable to enumerate USB device

This also happens on the front-panel USB hubs if there are other USB devices connected to the adjacent ports. However, if I unplug all other devices from the front panel it successfully enumerates again.

Enumeration works fine when directly connecting to USB ports in the motherboard.

I haven't experienced any enumeration issues with my other USB devices on these hubs so it seems like the issue related to the BL702 implementation.

usb2uartjtag固件,uart使用不了

调试板为 rv-debugger-plus,目标机器是sipeed nano,编译出来发现jtag能用,但是uart无通信。起初怀疑硬件的问题,但对比烧录sdk example下的usb2uart用例,uart通信正常,所以认定是固件bug,请排查一下。

No Setup/Hold time on TDI / TMS

With my purchased Sipeed RV Debugger Plus, which seems to use this firmware, I am not getting any successful JTAG connection using OpenOCD.

One issue is that the setup and hold times on TDI and TMS are near zero. This is wrong!

TDI and TCK toggle AT THE SAME TIME. Even more so, TDI / TMS also change on the falling edge of TCK. I did not expect this, and it is highly suspicious.

Please fix, as this adapter is totally unusable with a timing like this.

Can't program GW1NZ-LV1 FPGA with published code.

Hi. I'm struggling to fix an issue I'm having with the published usb2uartjtag code.

I have a Tang Nano 1k, with a BL702 on board. I desoldered both the Bl702 and the GW1NZ FPGA, and transfered them to my own PCB, that replicates the TANG NANO schematich, but with severl BL and GW1NZ pins exposed via pin headers, as well as some additional stuff.

I can program the FPGA with the current BL702 firmware. Both the BL and the FPGA behave as expected, same as when they were on the Tang Nano PCB. However, after building the USB2UARTJTAG firmware for the Bl702, it fails to program the FPGA.

With this firmware, the Bl702 is properly detected as a FTDI device. And the gowin programmer works. However, it ends up with an error code, and the FPGA won't wake up. This firmware can program the SRAM properly though, but it fails to program the flash.

Reverting to the original firmware allows me to reprogram the FPGA, with no issues.

In order to discard any issues while soldering, I build 3 boards, from 3 Tang Nano. Same behaviour in the 3 of them. So I'm pretty sure my issue is caused by some firmware error I'm failing to detect.

I've capture the full JTAG operation with a logic analizer. Both captures are pretty much identical, except on two points.

After erasing the Emb.Flash, on the original firmware the status is 0x39020, but with the github code, I get 0x19020. This is bit 17 being changed, however, bit 17 does not show in the gowin documentation!

Also, at the end of the programming cycle, instead of 0x39020, I get 0x11426 or 0x15422.

Everything else is the same in the JTAG conversation.

Another difference is the time it take to complete the programing. On the original firmware a bit below 5 seconds. With the compiled code from github, it goes up to 7-8 seconds. I'm guessing the issue is cause by some timing issue, but I'm still not able to pinpoint it.

If needed, I can provide the full JTAG capture, my pcb schematichs, anything you may need if you're able to look into this.

Many thanks.

reent.h: No such file or directory

我们依照这个方法在LicheePi4A的板子上面进行编译的

apt install git make cmake binutils-riscv64-unknown-elf gcc-riscv64-unknown-elf picolibc-riscv64-unknown-elf
git clone https://github.com/sipeed/RV-Debugger-BL702
git submodule update --init
cd RV-Debugger-BL702/firmware/bl_mcu_sdk
echo "add_compile_options(-specs=picolibc.specs)" >> tools/cmake/compiler_flags.cmake
echo "add_link_options(-specs=picolibc.specs)" >> tools/cmake/compiler_flags.cmake
make

结果报错了
[ 97%] Building C object samples/usb2uartjtag/CMakeFiles/usb2uartjtag_bl702.elf.dir/home/debian/RV-Debugger-BL702/firmware/bl_mcu_sdk/bsp/bsp_common/platform/syscalls.c.obj
/home/debian/RV-Debugger-BL702/firmware/bl_mcu_sdk/bsp/bsp_common/platform/syscalls.c:1:10: fatal error: reent.h: No such file or directory
1 | #include <reent.h>
| ^~~~~~~~~
compilation terminated.
make[3]: *** [samples/usb2uartjtag/CMakeFiles/usb2uartjtag_bl702.elf.dir/build.make:174: samples/usb2uartjtag/CMakeFiles/usb2uartjtag_bl702.elf.dir/home/debian/RV-Debugger-BL702/firmware/bl_mcu_sdk/bsp/bsp_common/platform/syscalls.c.obj] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory '/home/debian/RV-Debugger-BL702/firmware/bl_mcu_sdk/build'
make[2]: *** [CMakeFiles/Makefile2:153: samples/usb2uartjtag/CMakeFiles/usb2uartjtag_bl702.elf.dir/all] Error 2
make[2]: Leaving directory '/home/debian/RV-Debugger-BL702/firmware/bl_mcu_sdk/build'
make[1]: *** [Makefile:91: all] Error 2
make[1]: Leaving directory '/home/debian/RV-Debugger-BL702/firmware/bl_mcu_sdk/build'
make: *** [Makefile:52: build] Error 2

能看下是什么原因么?

Missing image firmware

it looks like the repository is incomplete. I can't find for example the main.bin file

[Instruction] How to build on Debian Buster and Bullseye

How to build on Debian Buster

To build RV-Debugger-BL702 you need a compiler. which is available in the following 3 packages.

binutils-riscv64-unknown-elf
gcc-riscv64-unknown-elf
picolibc-riscv64-unknown-elf

Current stable, Buster, does not have these packages. So we'll have to borrow them from current testing, Bullseye.

Specifically you'll need the following 3 package files. ( at the time of writing )

pool/main/b/binutils-riscv64-unknown-elf/binutils-riscv64-unknown-elf_2.32.2020.04+dfsg-2_amd64.deb
pool/main/g/gcc-riscv64-unknown-elf/gcc-riscv64-unknown-elf_8.3.0.2019.08+dfsg-1_amd64.deb
pool/main/p/picolibc/picolibc-riscv64-unknown-elf_1.5.1-2_all.deb

Which can be found at the following locations respectively.

https://ftp.debian.org/debian/pool/main/b/binutils-riscv64-unknown-elf/
https://ftp.debian.org/debian/pool/main/g/gcc-riscv64-unknown-elf/
https://ftp.debian.org/debian/pool/main/p/picolibc/

Install those 3 packages using dpkg command.

> dpkg -i binutils-riscv64-unknown-elf_2.32.2020.04+dfsg-2_amd64.deb
> dpkg -i gcc-riscv64-unknown-elf_8.3.0.2019.08+dfsg-1_amd64.deb
> dpkg -i picolibc-riscv64-unknown-elf_1.5.1-2_all.deb

note: you need root privilege

clone this repo and do a small patching.

> git clone https://github.com/sipeed/RV-Debugger-BL702
> cd RV-Debugger-BL702
> echo "add_compile_options(-specs=picolibc.specs)" >> tools/cmake/compiler_flags.cmake
> echo "add_link_options(-specs=picolibc.specs)" >> tools/cmake/compiler_flags.cmake

then edit CMakeList.txt .

@@ -1,1 +1,1 @@
- cmake_minimum_required(VERSION 3.15)
+ cmake_minimum_required(VERSION 3.13)

finally fire up the make command.

> make

and binary firmware file will be created at out/usb/usb2uartjtag/main.bin .

of course you need make and cmake. so do install them if you haven't yet.

> apt install make cmake

note: you need root privilege

OpenOCD: No progress with mpsse_flush( )

The mpsse implementation seems to be buggy. I cannot get this adapter to reliably work with OpenOCD. At times OpenOCD just hangs with the message "Haven't made progress in mpsse_flush()..."

This seems to happen more with OpenOCD 0.11.0-4, but I have also seen it happen with 0.10.0, which comes with Ubuntu (18.04 LTS).

如何调试bl602呢

使用RV-Debugger-BL702对bl602进行调试,但是在打开OpenOCD时得到了IR capture error at bit 5, saw 0x01 not 0x...3的错误

Open On-Chip Debugger 0.10.0+dev (SiFive OpenOCD 0.10.0-2019.08.2)
Licensed under GNU GPL v2
For bug reports:
        https://github.com/sifive/freedom-tools/issues
adapter speed: 2000 kHz
Ready for Remote Connections
Info : clock speed 2000 kHz
Info : JTAG tap: riscv.cpu tap/device found: 0x20000c05 (mfg: 0x602 (<unknown>), part: 0x0000, ver: 0x2)
Error: IR capture error at bit 5, saw 0x01 not 0x...3
Warn : Bypassing JTAG setup events due to errors
Error: failed write at 0x10, status=1
Error: failed write at 0x10, status=1
Error: failed write at 0x10, status=1
Error: failed read at 0x10, status=1
Info : Listening on port 3333 for gdb connections
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections

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.