Maix Bit load failed from gdb - setup_write_memory() Unsupported size : 8


I am trying to use gdb from the command line to debug a Maix Bit, the k210 chip, using Windows 10 , with a Sipeed-USB-JTAG-TTL-RISC-V-Debugger and when I follow these instructions…

Tutorial of Building Bare Metal Debugging & Development Environment for Maix Bit (K210)

everything works, until I try to load my hello_world example in gdb and then I get this

(gdb) load
Loading section .text, size 0xb0ed8 lma 0x80000000
Load failed

Any idea on what I am doing wrong ?

Openocd server is running in verbose mode (openocd -f k210.cfg -d) and I can see this error

Debug: 4377 8039800 gdb_server.c:3358 gdb_input_inner(): received packet: ‘X80000000,3e20:!\xa8\xef\xbe\xad\xde\x01\x00\x01\x00\x00’…
Debug: 4378 8039805 gdb_server.c:1410 gdb_error(): Reporting -4 to GDB as generic error
Debug: 4379 8039810 gdb_server.c:402 gdb_put_packet_inner(): sending packet ‘$E0E#ba’
Debug: 4380 8039814 gdb_server.c:1591 gdb_write_memory_binary_packet(): addr: 0x80000000, len: 0x00003e20
Debug: 4381 8039820 target.c:2236 target_write_buffer(): writing buffer of 15904 byte at 0x80000000
Debug: 4382 8039824 riscv-011.c:751 cache_set32(): cache[0x0] = 0x40503c23: DASM(0x40503c23) (hit)
Debug: 4383 8039829 riscv-011.c:751 cache_set32(): cache[0x1] = 0x41003283: DASM(0x41003283) (hit)
Debug: 4384 8039833 riscv-011.c:751 cache_set32(): cache[0x2] = 0x3fc0006f: DASM(0x3fc0006f) (hit)
Debug: 4385 8039838 riscv-011.c:754 cache_set32(): cache[0x4] = 0x80000000: DASM(0x80000000)
Debug: 4386 8039841 riscv-011.c:751 cache_set32(): cache[0x5] = 0x00000000: DASM(0x0) (hit)
Debug: 4387 8039845 riscv-011.c:843 cache_write(): enter
Debug: 4388 8039848 riscv-011.c:410 scan(): 41b w ih:80000000 04 -> + .h:40503c23 00
Debug: 4389 8039852 riscv-011.c:410 scan(): 41b r .h:00000000 05 -> + .h:80000000 04
Debug: 4390 8039857 riscv-011.c:410 scan(): 41b r .h:00000000 05 -> + .h:00000000 05
Debug: 4391 8039861 riscv-011.c:963 cache_write(): exit
Debug: 4392 8039864 riscv-011.c:410 scan(): 41b r …:00000000 06 -> + .h:00000000 05
Debug: 4393 8039868 riscv-011.c:410 scan(): 41b r …:00000000 06 -> + .h:80000000 06
Debug: 4394 8039872 riscv-011.c:410 scan(): 41b r …:00000000 07 -> + .h:80000000 06
Debug: 4395 8039876 riscv-011.c:410 scan(): 41b r …:00000000 07 -> + .h:00000000 07
Debug: 4396 8039879 riscv-011.c:2154 write_memory(): t0 is 0x80000000
Error: 4397 8039883 riscv-011.c:2129 setup_write_memory(): Unsupported size: 8

I have done the following

  1. Downloaded and installed the kendryte standalone SDK, kendryte toolchain, openocd, drivers (zadig)
  2. Setup the usb jtag risc v dongle
  3. Build the hello_world example

My openocd k210.cfg and a corresponding ft2232c.cfg were taken a website (but I cant put anymore than 21 links in my post ?)


debug adapter

source [find ft2232c.cfg]

transport select jtag
adapter_khz 10000

server port

gdb_port 3333
telnet_port 4444

add cpu target

set _CHIPNAME riscv

jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x04e4796b

target create $_TARGETNAME riscv -chain-position $_TARGETNAME




interface ftdi
ftdi_vid_pid 0x0403 0x6010

ftdi_layout_init 0xfff8 0xfffb
ftdi_layout_signal nTRST -data 0x0100 -oe 0x0100
ftdi_layout_signal nSRST -data 0x0200 -oe 0x0200

Building hello_world
I am building the hello_world different to the above mentioned bare metal instructions, as they dont work. I am doing this

set PATH=X:\ToolChains\riscv\toolchain\bin:%PATH%
cd src\hello_world
mkdir build
cd build
cmake -G “MinGW Makefiles” …/…/…

Then to run gdb I do
cd X:\ToolChains\riscv\sdk\src\hello_world\build
…\toolchain\bin\riscv64-unknown-elf-gdb.exe hello_world

Then to run the binary I do
set print pretty on
target remote localhost:3333
monitor reset halt