Debug Sipeed Longan invalid board option

Hi,

I am trying to use one Sipeed Longan nano to debug another one. When I click on Start Debugging I get this

Verbose mode can be enabled via -v, --verbose option
KeyError: “Invalid board option ‘build.ldscript’”:
File “U:\LonganIDE.platformio\penv\Lib\site-packages\platformio\builder\main.py”, line 175:
env.SConscript(item, exports=“env”)
File “U:\LonganIDE.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Script\SConscript.py”, line 591:
return _SConscript(self.fs, *files, **subst_kw)
File “U:\LonganIDE.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Script\SConscript.py”, line 280:
exec(compile(scriptdata, scriptname, ‘exec’), call_stack[-1].globals)
File “X:\Firmware\RV-link_longan\proj\build.py”, line 65:
LDSCRIPT_PATH = join(PROJ_DIR, “src”, “link”, “gd32vf103c-start”, “RISCV”, “gcc”, board.get(“build.ldscript”))
File “u:\longanide.platformio\penv\lib\site-packages\platformio\platform\board.py”, line 59:
raise KeyError(“Invalid board option ‘%s’” % path)

This is my platformio.ini
[env:sipeed-longan-nano]
platform = gd32v
framework = gd32vf103-sdk
board = sipeed-longan-nano
monitor_speed = 115200
debug_tool = sipeed-rv-debugger

I have uploaded the RV Link debug project from this sipeed page
Using RV-LINK · Longan DOC (sipeed.com)

This is the platformioi rv-link project I downloaded
http://dl.sipeed.com/LONGAN/Nano/Tools/RV-LINK-pio-src-v0.1.zip

I changed the upload from dfu to serial, as I cant get dfu work to at all.

I used a FTDI 232 to program the nano over serial, using this platformio.ini

Blockquote; PlatformIO Project Configuration File
;
; Build options: build flags, source filter, extra scripting
; Upload options: custom port, speed and extra flags
; Library options: dependencies, extra library storages
;
; Please visit documentation for the other options and examples
; Redirecting...

[env:sipeed-longan-nano-rv]
platform = gd32v
;framework = gd32vf103-sdk
board = sipeed-longan-nano
monitor_speed = 115200
upload_protocol = serial
debug_tool = sipeed-rv-debugger
build_flags =
-DGD32VF103C_START
-DUSE_STDPERIPH_DRIVER
-DUSE_USB_FS
-DLINK_LONGAN_NANO
-DTARGET_GD32VF103

-DAPP_GDB_SERVER
-DRVL_ASSERT_EN
-MMD

extra_scripts =
pre:build.py
src_filter =
+<*>-<.git/>-<.svn/>----
-<app/riscv-prober>
-<app/test-usb-serial/>
-<link/gd32vf103c-start/rvl-link.c>
-<link/gd32vf103c-start/rvl-button.c>
-<link/gd32vf103c-start/rvl-led.c>
-<link/gd32vf103c-start/rvl-jtag.c>
-<link/gd32vf103c-start/gd32vf103c_start.c>
-<link/gd32vf103c-start/rvl-jtag-inline.h>
-<link/rvl-link-stub.c>
-<link/gd32vf103c-start/RISCV/gcc/>
+<link/gd32vf103c-start/RISCV/gcc/init.c>
+<link/gd32vf103c-start/RISCV/gcc/handlers.c>
+<link/gd32vf103c-start/RISCV/gcc/entry.S>
+<link/gd32vf103c-start/RISCV/gcc/start.S>
-<link/gd32vf103c-start/RISCV/stubs>
+<link/gd32vf103c-start/RISCV/stubs/sbrk.c>
-<link/gd32vf103c-start/GD32VF103_standard_peripheral/>
+<link/gd32vf103c-start/GD32VF103_standard_peripheral/system_gd32vf103.c>
+<link/gd32vf103c-start/GD32VF103_standard_peripheral/Source/gd32vf103_gpio.c>
+<link/gd32vf103c-start/GD32VF103_standard_peripheral/Source/gd32vf103_rcu.c>
+<link/gd32vf103c-start/GD32VF103_standard_peripheral/Source/gd32vf103_timer.c>
+<link/gd32vf103c-start/GD32VF103_standard_peripheral/Source/gd32vf103_eclic.c>
+<link/gd32vf103c-start/GD32VF103_standard_peripheral/Source/gd32vf103_exti.c>
+<link/gd32vf103c-start/GD32VF103_standard_peripheral/Source/gd32vf103_pmu.c>

Blockquote

It looks like it worked, I have a green LED flashing.

Then the second nano I want to debug, so I connected them all like this

FT232 Nano Debugger RV-Link Program to debug Nano
Rx Tx
Tx Rx
VCC 3.3V
GND GND
TDO TDO
TDI TDI
TCK TCK
TMS TMS
Any ideas ?

Thanks
Marcus

This code is problematic if the board definition does not have this meta info. I’m not sure if one is supposed to use the linked project there because it looks really odd to me how it’s a baremetal project (framework = .. line is commented out!) and so they have to do a custom builder script to build the SDK. But then in that script they assume the board file has some attribute which is not there, breaking compilation.

My guess is that this is some old project where they didn’t have a builder script yet and it is superseeded by the examples in the current repository.

You should base your project off of platform-gd32v/examples/longan-nano-blink at master · sipeed/platform-gd32v · GitHub and then just add debug_tool = sipeed-rv-debugger.

Alternatively you can try and use the original project and add

board_build.ldscript = GD32VF103xB.lds

in an attempt to fix the builder script.

Manyh thanks, you were right adding the linker script name in the file directly works.
I can now upload files to the Longan, still can’t debug it though using another nano or jlink.