您尚未登录。

楼主 #1 2020-08-19 10:05:20

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

vscode的插件platformio,目录结构该如何规划?

去年买了sipeed的longan开发板,官方提供的badapple例程是基于platformio的工程。到时可以通过串口下载程序。

想试试rt-thread-nano,结果下载下来后,不知道该如何添加到platfromio工程里。
新建的platfromio工程有lib,src,include三个文件夹,还有个.ini配置文件。
而下载的rt-tread-nano文件夹下,是有bsp,components,include,libcpu,src这几个目录。

尝试将rtt源码全放进lib目录,然后将其中的bsp里的关于gd32的文件夹移出放置到工程根目录下的src目录下。
结果编译时报错,main.c里的两个头文件都找不到,手动输入路径后,又有其他的.c文件报错找不到.h。
完全不知道目录结构该如何设置。

最近编辑记录 Gentlepig (2020-08-19 10:24:34)

离线

楼主 #2 2020-08-19 10:22:45

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

比如 #include <rtconfig.h> ,我不名为这里为什么用的是<>而不是"",我网上搜到的信息是,#include< > 引用的是编译器的类库路径里面的头文件。
而这个rtconfig.h显然不是放在编译器的类库路径下吧。

离线

楼主 #3 2020-08-22 08:48:56

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

将git上rt-thread-nano工程文件里的bsp里的gd32xxx文件夹,复制到platformio的src目录下,然后将rt-thread-nano工程里除bsp外的其他文件,都复制到platformio工程目录下新建的rt-thread-nano目录下。
然后的.ini文件里设定build_flag = -Ixxx,xxx指的是编译时需要用到的头文件目录。
这样,一开始的几个找不到头文件的报错,没有了。但是最后还是编译失败了,找不到"entry" "rt_interrupt_enter" "rt_tick_increase" "rt_interrupt_leave"。

> Executing task: platformio run <

Processing sipeed-longan-nano-lite (platform: gd32v; board: sipeed-longan-nano-lite; framework: gd32vf103-sdk)
----------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/gd32v/sipeed-longan-nano-lite.html
PLATFORM: GigaDevice GD32V 1.1.2 #aa56577 > Sipeed Longan Nano Lite
HARDWARE: GD32VF103C8T6 108MHz, 20KB RAM, 64KB Flash
DEBUG: Current (altera-usb-blaster) External (altera-usb-blaster, gd-link, jlink, rv-link, sipeed-rv-debugger, um232h)
PACKAGES: 
 - framework-gd32vf103-sdk 1.0.0 
 - toolchain-gd32v 9.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
Linking .pio/build/sipeed-longan-nano-lite/firmware.elf
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/env_Eclipse/start.o: in function `.L0 ':
(.init+0x21c): undefined reference to `entry'
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: .pio/build/sipeed-longan-nano-lite/src/drivers/board.o: in function `eclic_mtip_handler':
board.c:(.text.eclic_mtip_handler+0x10): undefined reference to `rt_interrupt_enter'
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: board.c:(.text.eclic_mtip_handler+0x18): undefined reference to `rt_tick_increase'
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: board.c:(.text.eclic_mtip_handler+0x24): undefined reference to `rt_interrupt_leave'
collect2: error: ld returned 1 exit status
*** [.pio/build/sipeed-longan-nano-lite/firmware.elf] Error 1

最近编辑记录 Gentlepig (2020-08-22 08:53:07)

离线

楼主 #4 2020-08-24 10:32:31

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

经群里朋友指点,将rt-thread-nao从platformio工程目录移到了lib目录下,编译又进了一步,现在的报错是貌似找不到rt_hw_interrupt_enable()这个函数定义。

...略去一部分报错...
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: .pio/build/sipeed-longan-nano-lite/lib168/librt-thread-nano.a(timer.o): in function `rt_timer_stop':
timer.c:(.text.rt_timer_stop+0x12): undefined reference to `rt_hw_interrupt_disable'
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: timer.c:(.text.rt_timer_stop+0x22): undefined reference to `rt_hw_interrupt_enable'
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: .pio/build/sipeed-longan-nano-lite/lib168/librt-thread-nano.a(timer.o): in function `rt_timer_check':
timer.c:(.text.rt_timer_check+0x1c): undefined reference to `rt_hw_interrupt_disable'
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: timer.c:(.text.rt_timer_check+0x50): undefined reference to `rt_hw_interrupt_enable'
collect2: error: ld returned 1 exit status
*** [.pio/build/sipeed-longan-nano-lite/firmware.elf] Error 1
======================================== [FAILED] Took 0.85 seconds ========================================

我搜到了整个目录,只在两个地方找到了相关,分别是rthw.h和context_gcc.S。但是rthw.h里是声明,没有在.c文件里实现定义。
难道说context_gcc.S里的这几句汇编就是函数定义?

/*
 * rt_base_t rt_hw_interrupt_disable(void);
 */
    .globl rt_hw_interrupt_disable
rt_hw_interrupt_disable:
    csrrci a0, mstatus, 8
    ret

/*
 * void rt_hw_interrupt_enable(rt_base_t level);
 */
    .globl rt_hw_interrupt_enable
rt_hw_interrupt_enable:
    csrw mstatus, a0
    ret

最近编辑记录 Gentlepig (2020-08-24 10:36:27)

离线

楼主 #6 2020-08-24 10:55:19

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

想试试rt-thread-nano,这个好像不能用scons来生成工程。

在context_gcc.S里有rt_hw_interrupt_enable相关定义。
我将context_gcc.S从lib的下级目录移到src的下级目录,和start.S和entry.S两个汇编放到一块。编译不报那个错误了。

但又找不到rt_hw_context_swith_interrupt和rt_hw_statck_init这两个函数定义,但我搜了下,在context_gcc.S和cpuport.c两个文件里,都有相关函数定义。

Building in release mode
Linking .pio/build/sipeed-longan-nano-lite/firmware.elf
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: .pio/build/sipeed-longan-nano-lite/lib168/librt-thread-nano.a(scheduler.o): in function `rt_schedule':
scheduler.c:(.text.rt_schedule+0x6e): undefined reference to `rt_hw_context_switch_interrupt'
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: .pio/build/sipeed-longan-nano-lite/lib168/librt-thread-nano.a(thread.o): in function `rt_thread_init':
thread.c:(.text.rt_thread_init+0x5c): undefined reference to `rt_hw_stack_init'
collect2: error: ld returned 1 exit status
*** [.pio/build/sipeed-longan-nano-lite/firmware.elf] Error 1

-------------------------------
又查了下,这个函数定义是有条件的:RT_USING_SMP

最近编辑记录 Gentlepig (2020-08-24 11:23:30)

离线

楼主 #7 2020-08-24 14:31:57

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

查了下这个SMP,说是对称多核用的...可我这是个单核单片机啊...

随便找了个地方使能了RT_USING_SMP。
再次编译还有个函数未定义的错误,查了下这个函数在libcpu/risc-v/comon/cpuport.c里,将这个.c文件移动到src目录下,编译通过了。

感觉像是src目录下的.c和.S文件都会被编译。
而lib目录下的,则是有条件的编译,但是不清楚是什么条件。

离线

楼主 #8 2020-08-24 15:13:42

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

main函数里实现了点灯功能:

#include "gd32vf103v_eval.h"
#include <rtthread.h>

int main(void)
{
    gd_eval_led_init(LED1);

    while (1)
    {
        gd_eval_led_on(LED1);
        rt_thread_mdelay(500);
        gd_eval_led_off(LED1);
        rt_thread_mdelay(500);
    }
}

我修改了LED1的定义,改成longan板上三色灯中的一个PA1:

#define LEDn                             4U

#define LED1_PIN                         GPIO_PIN_1
#define LED1_GPIO_PORT                   GPIOA
#define LED1_GPIO_CLK                    RCU_GPIOA

编译后下载到板子上,结果,等没反应...

离线

楼主 #10 2020-08-25 08:35:41

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

aozima 说:

灯没反应是否是心跳没起来?

我这里应该不应该定义RT_USING_SMP这个宏定义呢?

SMP(对称多核处理器),这是我网上搜到的,但我这里肯定是个单核的单片机啊。

最近编辑记录 Gentlepig (2020-08-25 08:36:52)

离线

楼主 #11 2020-08-25 09:31:59

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

gd32vf103v_eval.c有个delay_1ms()函数,原来设参数1000,打算延时1秒让灯亮灭。
昨天观察到的现象是灯常亮,实际上是灯闪频率极高。现在调成1000000000,然后又用个for循环将这个延时函数调用100次,现在大概是1秒-2秒的周期闪灯。

--------------------------------

修改了下start.S,将call entry改回call main,这样应该就不是rtt了吧,再次编译下载,灯可以按预设的频率闪烁。

---------------------------------

貌似是delay_1ms()函数的参数不起作用了,无论设成多少,该函数都实现了固定时间的延迟,我上一步实现的灯闪,实际上是拷外层for循环调用delay_1ms实现的。

好奇为何这个函数的参数失效了?

/*!
    \brief      delay a time in milliseconds
    \param[in]  count: count in milliseconds
    \param[out] none
    \retval     none
*/
void delay_1ms(uint32_t count)
{
	uint64_t start_mtime, delta_mtime;

	// Don't start measuruing until we see an mtime tick
	uint64_t tmp = get_timer_value();
	do {
	start_mtime = get_timer_value();
	} while (start_mtime == tmp);

	do {
	delta_mtime = get_timer_value() - start_mtime;
	}while(delta_mtime <(SystemCoreClock/4000.0 *count ));
}

---------------------------------------

直接调用rt_thread_mdelay()函数,结果灯连亮都不亮,感觉应该是卡到这里了。

最近编辑记录 Gentlepig (2020-08-25 10:36:43)

离线

楼主 #12 2020-08-26 09:36:42

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

换下头脑。
之前移植是用的串口下载,每次都要按键boot重启。
买这个longan-nano时也买了个sipeed的usb转jtag/ttl。之前试过配置platformio的.ini文件,下载协议设置为jlink。
可下载总是失败:

jtag
Warn : Transport "jtag" was already selected
jtag
adapter speed: 1000 kHz

Error: No J-Link device found.

今天又试了试,发现还可以选sipeed-rv-debugger,结果下载后也提示失败,在github上看到也有人遇到这个问题。

> Executing task in folder gd32v_lcd: platformio run --target upload <

Processing sipeed-longan-nano (platform: gd32v; board: sipeed-longan-nano-lite; framework: gd32vf103-sdk)
----------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/gd32v/sipeed-longan-nano-lite.html
PLATFORM: GigaDevice GD32V 1.2.0 #e53fe77 > Sipeed Longan Nano Lite
HARDWARE: GD32VF103C8T6 108MHz, 20KB RAM, 64KB Flash
DEBUG: Current (sipeed-rv-debugger) External (altera-usb-blaster, gd-link, jlink, rv-link, sipeed-rv-debugger, um232h)
PACKAGES: 
 - framework-gd32vf103-sdk 1.0.0 
 - tool-dfuutil 1.9.200310 
 - tool-gd32vflash 0.1.0 
 - tool-openocd-gd32v 0.1.1 
 - toolchain-gd32v 9.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
Compiling .pio/build/sipeed-longan-nano/src/fatfs/ff.o
Compiling .pio/build/sipeed-longan-nano/src/fatfs/ffsystem.o
Compiling .pio/build/sipeed-longan-nano/src/fatfs/ffunicode.o
Compiling .pio/build/sipeed-longan-nano/src/fatfs/tf_card.o
Compiling .pio/build/sipeed-longan-nano/src/lcd/lcd.o
src/fatfs/tf_card.c:278:6: warning: 'tfcard_timer_irq' defined but not used [-Wunused-function]
  278 | void tfcard_timer_irq (void)
      |      ^~~~~~~~~~~~~~~~
Compiling .pio/build/sipeed-longan-nano/src/main.o
src/main.c: In function 'main':
src/main.c:41:10: warning: unused variable 'br' [-Wunused-variable]
   41 |     UINT br;
      |          ^~
src/main.c:40:13: warning: unused variable 'fr' [-Wunused-variable]
   40 |     FRESULT fr;     /* FatFs return code */
      |             ^~
src/main.c:39:9: warning: unused variable 'fil' [-Wunused-variable]
   39 |     FIL fil;
      |         ^~~
src/main.c:38:9: warning: unused variable 'offset' [-Wunused-variable]
   38 |     int offset = 0;
      |         ^~~~~~
src/main.c:37:13: warning: unused variable 'mount_is_ok' [-Wunused-variable]
   37 |     uint8_t mount_is_ok = 1; /* 0: mount successful ; 1: mount failed */
      |             ^~~~~~~~~~~
Compiling .pio/build/sipeed-longan-nano/src/systick.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_adc.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_bkp.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_can.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_crc.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_dac.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_dbg.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_dma.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_eclic.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_exmc.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_exti.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_fmc.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_fwdgt.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_gpio.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_i2c.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_pmu.o
/home/any/.platformio/packages/framework-gd32vf103-sdk/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.c: In function 'i2c_flag_clear':
/home/any/.platformio/packages/framework-gd32vf103-sdk/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.c:610:14: warning: variable 'temp' set but not used [-Wunused-but-set-variable]
  610 |     uint32_t temp;
      |              ^~~~
/home/any/.platformio/packages/framework-gd32vf103-sdk/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.c: In function 'i2c_interrupt_flag_clear':
/home/any/.platformio/packages/framework-gd32vf103-sdk/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.c:718:14: warning: variable 'temp' set but not used [-Wunused-but-set-variable]
  718 |     uint32_t temp;
      |              ^~~~
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_rcu.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_rtc.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_spi.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_timer.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_usart.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/Source/gd32vf103_wwdgt.o
Compiling .pio/build/sipeed-longan-nano/standard_peripheral/system_gd32vf103.o
Compiling .pio/build/sipeed-longan-nano/RISCV/drivers/n200_func.o
Compiling .pio/build/sipeed-longan-nano/RISCV/env_Eclipse/entry.o
Compiling .pio/build/sipeed-longan-nano/RISCV/env_Eclipse/handlers.o
Compiling .pio/build/sipeed-longan-nano/RISCV/env_Eclipse/init.o
Compiling .pio/build/sipeed-longan-nano/RISCV/env_Eclipse/start.o
Compiling .pio/build/sipeed-longan-nano/RISCV/env_Eclipse/your_printf.o
Compiling .pio/build/sipeed-longan-nano/RISCV/stubs/_exit.o
Compiling .pio/build/sipeed-longan-nano/RISCV/stubs/close.o
/home/any/.platformio/packages/framework-gd32vf103-sdk/RISCV/env_Eclipse/your_printf.c: In function '__wrap_printf':
/home/any/.platformio/packages/framework-gd32vf103-sdk/RISCV/env_Eclipse/your_printf.c:4:1: warning: control reaches end of non-void function [-Wreturn-type]
    4 | }
      | ^
Compiling .pio/build/sipeed-longan-nano/RISCV/stubs/fstat.o
Compiling .pio/build/sipeed-longan-nano/RISCV/stubs/isatty.o
Compiling .pio/build/sipeed-longan-nano/RISCV/stubs/lseek.o
Compiling .pio/build/sipeed-longan-nano/RISCV/stubs/read.o
Compiling .pio/build/sipeed-longan-nano/RISCV/stubs/sbrk.o
Archiving .pio/build/sipeed-longan-nano/libstandard_peripheral.a
Compiling .pio/build/sipeed-longan-nano/RISCV/stubs/write.o
Indexing .pio/build/sipeed-longan-nano/libstandard_peripheral.a
Compiling .pio/build/sipeed-longan-nano/RISCV/stubs/write_hex.o
Archiving .pio/build/sipeed-longan-nano/libRISCV.a
Indexing .pio/build/sipeed-longan-nano/libRISCV.a
Linking .pio/build/sipeed-longan-nano/firmware.elf
Checking size .pio/build/sipeed-longan-nano/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  11.3% (used 2314 bytes from 20480 bytes)
Flash: [=         ]  12.9% (used 8426 bytes from 65536 bytes)
Configuring upload protocol...
AVAILABLE: altera-usb-blaster, gd-link, jlink, rv-link, serial, sipeed-rv-debugger, um232h
CURRENT: upload_protocol = sipeed-rv-debugger
Uploading .pio/build/sipeed-longan-nano/firmware.elf
Open On-Chip Debugger 0.10.0+dev-00911-gcfbca74bd (2019-09-12-09:31)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Warn : Transport "jtag" was already selected
jtag
adapter speed: 1000 kHz

Info : clock speed 1000 kHz
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Warn : JTAG tap: riscv.cpu       UNEXPECTED: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Error: JTAG tap: riscv.cpu  expected 1 of 1: 0x1e200a6d (mfg: 0x536 (Nuclei System Technology Co.,Ltd.), part: 0xe200, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Error: Trying to use configured scan chain anyway...
Warn : AUTO auto0.tap - use "jtag newtap auto0 tap -irlen 5 -expected-id 0x790007a3"
Warn : Bypassing JTAG setup events due to errors
Info : datacount=4 progbufsize=2
Info : Exposing additional CSR 3040
Info : Exposing additional CSR 3041
Info : Exposing additional CSR 3042
Info : Exposing additional CSR 3043
Info : Exposing additional CSR 3044
Info : Exposing additional CSR 3045
Info : Exposing additional CSR 3046
Info : Exposing additional CSR 3047
Info : Exposing additional CSR 3048
Info : Exposing additional CSR 3049
Info : Exposing additional CSR 3050
Info : Exposing additional CSR 3051
Info : Exposing additional CSR 3052
Info : Exposing additional CSR 3053
Info : Exposing additional CSR 3054
Info : Exposing additional CSR 3055
Info : Exposing additional CSR 3056
Info : Exposing additional CSR 3057
Info : Exposing additional CSR 3058
Info : Exposing additional CSR 3059
Info : Exposing additional CSR 3060
Info : Exposing additional CSR 3061
Info : Exposing additional CSR 3062
Info : Exposing additional CSR 3063
Info : Exposing additional CSR 3064
Info : Exposing additional CSR 3065
Info : Exposing additional CSR 3066
Info : Exposing additional CSR 3067
Info : Exposing additional CSR 3068
Info : Exposing additional CSR 3069
Info : Exposing additional CSR 3070
Info : Exposing additional CSR 3071
Info : Examined RISC-V core; found 1 harts
Info :  hart 0: XLEN=32, misa=0x40901105
Info : Listening on port 3333 for gdb connections
Info : device id = 0x19060410
Info : flash_size_in_kb = 0x00000040
Info : flash size = 64kbytes
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Warn : JTAG tap: riscv.cpu       UNEXPECTED: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Error: JTAG tap: riscv.cpu  expected 1 of 1: 0x1e200a6d (mfg: 0x536 (Nuclei System Technology Co.,Ltd.), part: 0xe200, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Error: Trying to use configured scan chain anyway...
Warn : Bypassing JTAG setup events due to errors
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
Info : Hart 0 unexpectedly reset!

*** [upload] Error 1

离线

楼主 #13 2020-08-26 11:06:44

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

https://github.com/sipeed/platform-gd32v/issues/12
看这个问题说,下载芯来的最新版的openocd,就可以下载了。
可我下载后解压得到了个文件夹,不知道该怎么用,里面的bin目录下倒是有个可执行文件openocd。
我在platformio的.ini文件里,将debug_tool修改为custom,debug_server改为刚下的openocd地址,结果执行下载还是包一样的错误。

离线

楼主 #15 2020-08-26 11:46:44

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

aozima 说:

libraries\n22\env_Eclipse\init.c 里面有个 init 函数 ,你在 board.c 中手动调用一下看看。
感觉是心跳没起来

我用的是bsp里的gd32vf103_eval那个工程文件,init.c的路径是libraries/RISCV/env_Eclipse,里面有个_init()函数。我在board.c里的rt_hw_board_init()里开始的地方手动调用了_init()函数,结果现象依旧。
并且,rt_hw_board_init()里有个risc_clock_init()函数,里面实现的,基本和_init()函数一致。

最近编辑记录 Gentlepig (2020-08-26 11:47:40)

离线

楼主 #16 2020-08-26 16:13:47

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

把工程删了。又重新走了一遍:
1将rtthread-nano源码放到lib目录下;
2将rtthread-nano源码下的bsp下的gd32vf103-blink目录下的文件,全部放到src目录下;
3将rtthread-nano源码里的libcpu目录下的,arm目录删了,risc目录下,除bomblebee和common两个目录外的其他文件夹删了。其实也可以不删,估计不影响;
4然后将bomblebee和common目录下的cpuport.c,context_gcc.S,entry.S放到platformio工程目录下的src目录下或src下的任意目录下。如果放在原lib目录的下级目录下,总是编译不了,会提示找不到其中的各种函数定义。
5.ini文件里设置编译时报错找不到的各种头文件路径,我这里是这样的:
build_flags =
    -Isrc/drivers
    -Isrc
    -Ilib/rt-thread-nano/include
    -Ilib/rt-thread-nano/src
    -Ilib/rt-thread-nano/libcpu/risc-v/common

最近编辑记录 Gentlepig (2020-08-26 17:18:04)

离线

楼主 #17 2020-08-27 09:11:45

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

上传下自己的工程,现在开机启动后,不知为何打印了两遍rtt图标。
rt-thread-nano.zip

Welcome to minicom 2.7.1

OPTIONS: I18n                                                                
Compiled on Aug 13 2017, 15:25:34.                                           
Port /dev/ttyUSB2, 09:06:32                                                  
                                                                             
Press CTRL-A Z for help on special keys                                      
                                                                             
                                                                            
 \ | /                                                                       
- RT -     Thread Operating System                                           
 / | \     3.1.3 build Aug 26 2020                                           
 2006 - 2019 Copyright by rt-thre                                            
 \ | /                                  
- RT -     Thread Operating System      
 / | \     3.1.3 build Aug 26 2020      
 2006 - 2019 Copyright by rt-thread team
hahaha                                  
hahaha  

剩下的问题还有用jtag/sipeed-rv-debugger不能下载。在github的longan仓库上看到有人提到过这个问题。说是用芯来的最新的openocd可以下载。但是我不知道如何将下载下来的Openocd加入到platformio工程中去。

最近编辑记录 Gentlepig (2020-08-27 09:16:53)

离线

楼主 #18 2020-08-27 11:06:01

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

发现运行rtt程序后,串口显示两次版本信息。经群里朋友指点,应该是复位不稳定的原因。longan开发板复位引脚是个10k电阻和0.1uF电容实现的阻容复位,可能电容太小了。
在rtthread_startup()函数前加了个延时,暂时躲过了这一现象。

又发现,其实是可以用sipeed-rv-debugger下载的,是有报错,但是重启后发现程序已下载进去可以运行。
这是报错信息:

> Executing task in folder rt-thread-nano: platformio run --target upload <

Processing sipeed-longan-nano-lite (platform: gd32v; board: sipeed-longan-nano-lite; framework: gd32vf103-sdk)
----------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/gd32v/sipeed-longan-nano-lite.html
PLATFORM: GigaDevice GD32V 1.2.0 #e53fe77 > Sipeed Longan Nano Lite
HARDWARE: GD32VF103C8T6 108MHz, 20KB RAM, 64KB Flash
DEBUG: Current (altera-usb-blaster) External (altera-usb-blaster, gd-link, jlink, rv-link, sipeed-rv-debugger, um232h)
PACKAGES: 
 - framework-gd32vf103-sdk 1.0.0 
 - tool-dfuutil 1.9.200310 
 - tool-gd32vflash 0.1.0 
 - tool-openocd-gd32v 0.1.1 
 - toolchain-gd32v 9.2.0
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <rt-thread-nano>
Building in release mode
Compiling .pio/build/sipeed-longan-nano-lite/src/applications/main.o
Compiling .pio/build/sipeed-longan-nano-lite/src/drivers/board.o
Compiling .pio/build/sipeed-longan-nano-lite/src/drivers/cpuport.o
Compiling .pio/build/sipeed-longan-nano-lite/src/drivers/gd32vf103v_eval.o
src/applications/main.c: In function 'main':
src/applications/main.c:16:5: warning: 'return' with no value, in function returning non-void [-Wreturn-type]
   16 |     return;
      |     ^~~~~~
src/applications/main.c:14:5: note: declared here
   14 | int main(void)
      |     ^~~~
src/drivers/gd32vf103v_eval.c: In function 'rt_hw_console_output':
src/drivers/gd32vf103v_eval.c:253:12: warning: implicit declaration of function 'rt_strlen' [-Wimplicit-function-declaration]
  253 |     size = rt_strlen(str);
      |            ^~~~~~~~~
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_adc.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_bkp.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_can.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_crc.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_dac.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_dbg.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_dma.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_eclic.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_exmc.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_exti.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_fmc.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_fwdgt.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_gpio.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_pmu.o
src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.c: In function 'i2c_flag_clear':
src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.c:610:14: warning: variable 'temp' set but not used [-Wunused-but-set-variable]
  610 |     uint32_t temp;
      |              ^~~~
src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.c: In function 'i2c_interrupt_flag_clear':
src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.c:718:14: warning: variable 'temp' set but not used [-Wunused-but-set-variable]
  718 |     uint32_t temp;
      |              ^~~~
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_rcu.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_rtc.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_spi.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_timer.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_usart.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/Source/gd32vf103_wwdgt.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/GD32VF103_standard_peripheral/system_gd32vf103.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/drivers/n200_func.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/env_Eclipse/context_gcc.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/env_Eclipse/entry.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/env_Eclipse/handlers.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/env_Eclipse/init.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/env_Eclipse/interrupt_gcc.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/env_Eclipse/start.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/env_Eclipse/your_printf.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/stubs/_exit.o
src/libraries/RISCV/env_Eclipse/your_printf.c: In function '__wrap_printf':
src/libraries/RISCV/env_Eclipse/your_printf.c:4:1: warning: control reaches end of non-void function [-Wreturn-type]
    4 | }
      | ^
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/stubs/close.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/stubs/fstat.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/stubs/isatty.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/stubs/lseek.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/stubs/read.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/stubs/sbrk.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/stubs/write.o
Compiling .pio/build/sipeed-longan-nano-lite/src/libraries/RISCV/stubs/write_hex.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/clock.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/components.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/cpu.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/idle.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/ipc.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/irq.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/kservice.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/mem.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/memheap.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/mempool.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/object.o
lib/rt-thread-nano/src/object.c: In function 'rt_object_init':
lib/rt-thread-nano/src/object.c:262:27: warning: variable 'obj' set but not used [-Wunused-but-set-variable]
  262 |         struct rt_object *obj;
      |                           ^~~
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/scheduler.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/slab.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/thread.o
Compiling .pio/build/sipeed-longan-nano-lite/lib168/rt-thread-nano/timer.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_adc.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_bkp.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_can.o
Archiving .pio/build/sipeed-longan-nano-lite/lib168/librt-thread-nano.a
Indexing .pio/build/sipeed-longan-nano-lite/lib168/librt-thread-nano.a
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_crc.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_dac.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_dbg.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_dma.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_eclic.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_exmc.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_exti.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_fmc.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_fwdgt.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_gpio.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_i2c.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_pmu.o
/home/any/.platformio/packages/framework-gd32vf103-sdk/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.c: In function 'i2c_flag_clear':
/home/any/.platformio/packages/framework-gd32vf103-sdk/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.c:610:14: warning: variable 'temp' set but not used [-Wunused-but-set-variable]
  610 |     uint32_t temp;
      |              ^~~~
/home/any/.platformio/packages/framework-gd32vf103-sdk/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.c: In function 'i2c_interrupt_flag_clear':
/home/any/.platformio/packages/framework-gd32vf103-sdk/GD32VF103_standard_peripheral/Source/gd32vf103_i2c.c:718:14: warning: variable 'temp' set but not used [-Wunused-but-set-variable]
  718 |     uint32_t temp;
      |              ^~~~
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_rcu.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_rtc.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_spi.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_timer.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_usart.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/Source/gd32vf103_wwdgt.o
Compiling .pio/build/sipeed-longan-nano-lite/standard_peripheral/system_gd32vf103.o
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/drivers/n200_func.o
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/env_Eclipse/entry.o
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/env_Eclipse/handlers.o
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/env_Eclipse/init.o
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/env_Eclipse/start.o
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/env_Eclipse/your_printf.o
/home/any/.platformio/packages/framework-gd32vf103-sdk/RISCV/env_Eclipse/your_printf.c: In function '__wrap_printf':
/home/any/.platformio/packages/framework-gd32vf103-sdk/RISCV/env_Eclipse/your_printf.c:4:1: warning: control reaches end of non-void function [-Wreturn-type]
    4 | }
      | ^
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/stubs/_exit.o
Archiving .pio/build/sipeed-longan-nano-lite/libstandard_peripheral.a
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/stubs/close.o
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/stubs/fstat.o
Indexing .pio/build/sipeed-longan-nano-lite/libstandard_peripheral.a
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/stubs/isatty.o
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/stubs/lseek.o
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/stubs/read.o
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/stubs/sbrk.o
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/stubs/write.o
Compiling .pio/build/sipeed-longan-nano-lite/RISCV/stubs/write_hex.o
Archiving .pio/build/sipeed-longan-nano-lite/libRISCV.a
Indexing .pio/build/sipeed-longan-nano-lite/libRISCV.a
Linking .pio/build/sipeed-longan-nano-lite/firmware.elf
Checking size .pio/build/sipeed-longan-nano-lite/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  15.8% (used 3232 bytes from 20480 bytes)
Flash: [=         ]  14.3% (used 9362 bytes from 65536 bytes)
Configuring upload protocol...
AVAILABLE: altera-usb-blaster, gd-link, jlink, rv-link, serial, sipeed-rv-debugger, um232h
CURRENT: upload_protocol = sipeed-rv-debugger
Uploading .pio/build/sipeed-longan-nano-lite/firmware.elf
Open On-Chip Debugger 0.10.0+dev-00911-gcfbca74bd (2019-09-12-09:31)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Warn : Transport "jtag" was already selected
jtag
adapter speed: 1000 kHz

Info : clock speed 1000 kHz
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Warn : JTAG tap: riscv.cpu       UNEXPECTED: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Error: JTAG tap: riscv.cpu  expected 1 of 1: 0x1e200a6d (mfg: 0x536 (Nuclei System Technology Co.,Ltd.), part: 0xe200, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Error: Trying to use configured scan chain anyway...
Warn : AUTO auto0.tap - use "jtag newtap auto0 tap -irlen 5 -expected-id 0x790007a3"
Warn : Bypassing JTAG setup events due to errors
Info : datacount=4 progbufsize=2
Info : Exposing additional CSR 3040
Info : Exposing additional CSR 3041
Info : Exposing additional CSR 3042
Info : Exposing additional CSR 3043
Info : Exposing additional CSR 3044
Info : Exposing additional CSR 3045
Info : Exposing additional CSR 3046
Info : Exposing additional CSR 3047
Info : Exposing additional CSR 3048
Info : Exposing additional CSR 3049
Info : Exposing additional CSR 3050
Info : Exposing additional CSR 3051
Info : Exposing additional CSR 3052
Info : Exposing additional CSR 3053
Info : Exposing additional CSR 3054
Info : Exposing additional CSR 3055
Info : Exposing additional CSR 3056
Info : Exposing additional CSR 3057
Info : Exposing additional CSR 3058
Info : Exposing additional CSR 3059
Info : Exposing additional CSR 3060
Info : Exposing additional CSR 3061
Info : Exposing additional CSR 3062
Info : Exposing additional CSR 3063
Info : Exposing additional CSR 3064
Info : Exposing additional CSR 3065
Info : Exposing additional CSR 3066
Info : Exposing additional CSR 3067
Info : Exposing additional CSR 3068
Info : Exposing additional CSR 3069
Info : Exposing additional CSR 3070
Info : Exposing additional CSR 3071
Info : Examined RISC-V core; found 1 harts
Info :  hart 0: XLEN=32, misa=0x40901105
Info : Listening on port 3333 for gdb connections
Info : device id = 0x19060410
Info : flash_size_in_kb = 0x00000040
Info : flash size = 64kbytes
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Warn : JTAG tap: riscv.cpu       UNEXPECTED: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Error: JTAG tap: riscv.cpu  expected 1 of 1: 0x1e200a6d (mfg: 0x536 (Nuclei System Technology Co.,Ltd.), part: 0xe200, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Error: Trying to use configured scan chain anyway...
Warn : Bypassing JTAG setup events due to errors
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
Info : Hart 0 unexpectedly reset!

*** [upload] Error 1
========================================== [FAILED] Took 6.78 seconds ==========================================
终端进程“platformio 'run', '--target', 'upload'”已终止,退出代码: 1。

.ini里upload_protocol选的是sipeed-rv-debugger,选jlink不行。但sipeed-rv-debugger写的是usb转jtag。
jlink难道用的不是jtag协议吗?

------------------------------------------------

用sipeed-rv-debugger也可以调试。
vscode左边栏里有个“运行”图标是个向右的三角加上一个虫子,打开这个侧边栏后,最上方有个“开始调试”框,选pio debug,就可以了。
感觉这样的话,可以替代mdk了。

最近编辑记录 Gentlepig (2020-08-27 11:32:51)

离线

楼主 #19 2020-09-02 09:36:01

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

发现msh功能打不开。工程目录里已包含msh相关文件,rtconfig.h里也使能了RTE_USING_FINSH。main函数的while循环里也有rt_msdelay()。但是打开串口后,只看到打印的rtt图标,以及main线程里定时打印的一句字符串。

难道c8t6的20k ram太小了?

离线

楼主 #20 2020-09-02 17:13:02

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

shell.c里有int finsh_system_init(void)函数,会创建finsh线程,而这个函数是通过INIT_APP_EXPORT(finsh_system_init)来实现自动启动的。

我在int finsh_system_init(void)函数里加断点,结果运行仿真后,发现无法在这里停下。

--------------------------------------------

断点是不是只能加在main函数以后呢?

------------------------------------------

在main函数前可以加断点,刚才是操作不对。

--------------------------------------------------

又考虑是不是component/finsh文件夹在platformio的lib目录下,.c文件没有被编译进去?
明天再试试将文件移到src目录下试试。

最近编辑记录 Gentlepig (2020-09-02 17:51:28)

离线

楼主 #21 2020-09-03 10:02:47

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

将所有rtthread文件夹都放到了platformio的src目录下,结果仍然是无法使能msh。

离线

楼主 #22 2020-09-08 17:18:42

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

QQ图片20200908171754.jpg
找不到__fsymtabl_start, __fsmtab_end等。

离线

楼主 #23 2020-09-09 16:08:47

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

尝试编译Lvgl,报错:

Compiling .pio/build/sipeed-longan-nano-lite/RISCV/stubs/write_hex.o
Archiving .pio/build/sipeed-longan-nano-lite/libRISCV.a
Indexing .pio/build/sipeed-longan-nano-lite/libRISCV.a
Linking .pio/build/sipeed-longan-nano-lite/firmware.elf
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: .pio/build/sipeed-longan-nano-lite/firmware.elf section `.bss' will not fit in region `ram'
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: section .stack VMA [0000000020004800,0000000020004fff] overlaps section .bss VMA [0000000020000100,0000000020008687]
/home/any/.platformio/packages/toolchain-gd32v/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: region `ram' overflowed by 0 bytes
collect2: error: ld returned 1 exit status
*** [.pio/build/sipeed-longan-nano-lite/firmware.elf] Error 1
========================================== [FAILED] Took 10.38 seconds ==========================================
终端进程“platformio 'run'”已终止,退出代码: 1。

----------------------------------------

经群里朋友指点,.bss已经34k多了。
可我看Lvgl介绍说16k ram需求就够了啊。

------------------------------------------------

我试着改了下lv_conf.h的分辨率,改大改小,最后编译报错时.bss占用ram大小都是那么大...

最近编辑记录 Gentlepig (2020-09-09 17:29:06)

离线

楼主 #24 2020-09-10 16:03:38

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,363
积分: 1323.5

Re: vscode的插件platformio,目录结构该如何规划?

再回到rtthread-nano的msh功能。

之前编译后发现finsh_system_init()函数没有执行,于是手动调用这个函数,结果报__fsymtabl_start, __fsmtab_end等找不到的错误。去rtthread论坛搜,都提到了链接文件。当时没明白该去哪里找链接文件。在vsc工程目录里搜相关词也搜不到。
今天发现GD32VF103XX.lds就是链接文件,其中cbxx.lds里有相关定义,其他的没有,而我的板子正好是c8t6。把相关部分复制过来后,编译还是不行。想了想,platfromio用的是自带的lds,然后去.platformio目录下找到了相关的,把这部分复制过去。可以编译通过了,串口上也能显示msh>提示符了。不过输入没反应,可能是我串口输入部分写的有问题。

-----------------------------------------------

可以输入了,哈。

 \ | /                                                      
- RT -     Thread Operating System                          
 / | \     3.1.3 build Sep 10 2020                          
 2006 - 2019 Copyright by rt-thread team                    
msh >hahaha                                                 
RT-Thread shell commands:                                   
list_timer list_mailbox list_sem list_thread version ps hel 
msh >

-------------------------------------------

上传一下目前的工程当个备份用。
需要注意的地方就是修改/home/any/.platformio/packages/framework-gd32vf103-sdk/RISCV/env_Eclipse下的.lds后缀的链接文件里的内容。也许platformio能指定用bsp里的lds,但我不知道怎么设置。并且,rtthread给的bsp里的,只有cbxx.lds里有__fsymtab_start相关部分,如果用的是c8t6的话,需要将c8xx.lds里的复制那部分进去。
rt-thread-nano-allinsrc.zip

最近编辑记录 Gentlepig (2020-09-10 16:14:18)

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn