lindahnu 发表于 2024-1-10 14:39:58

nuclei studio调试GD32VF103疑问

有人使用过芯来科技的IDE调试GD32VF103吗?nuclei studio其实就是eclipse。

目前刚接触,使用自带的工程模版时发现jlink debug配置startup里 “RAM application” 选项被勾选, 并且取消勾选“Initial Reset and Halt” 选项。


我理解 “RAM application” 选项是为了把代码放ram运行才勾选的,但nuclei studio提供的模版不明白为什么,链接ld文件是把代码放在flash里,不是矛盾吗?

/*
* Copyright (c) 2019 Nuclei Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/******************************************************************************
* @file   gcc_gd32vf103_flashxip.ld
* @brief    GNU Linker Script for gd32vf103 based device
* @versionV2.0.0
* @date   10. March 2022
******************************************************************************/

/*********** Use Configuration Wizard in Context Menu *************************/

OUTPUT_ARCH( "riscv" )
/********************* Flash Configuration ************************************
* <h> Flash Configuration
* <o0> Flash Base Address <0x0-0xFFFFFFFF:8>
* <o1> Flash Size (in Bytes) <0x0-0xFFFFFFFF:8>
* </h>
*/
__ROM_BASE = 0x08000000;
__ROM_SIZE = 0x00020000;

/*--------------------- Embedded RAM Configuration ---------------------------
* <h> RAM Configuration
* <o0> RAM Base Address    <0x0-0xFFFFFFFF:8>
* <o1> RAM Size (in Bytes) <0x0-0xFFFFFFFF:8>
* </h>
*/
__RAM_BASE = 0x20000000;
__RAM_SIZE = 0x00008000;

/**************************** end of configuration section ********************/

ENTRY(_start)

/* Define base address and length of flash and ram */
MEMORY
{
flash (rxa!w) : ORIGIN = __ROM_BASE, LENGTH = __ROM_SIZE
ram (wxa!r) : ORIGIN = __RAM_BASE, LENGTH = __RAM_SIZE
}

REGION_ALIAS("ROM", flash)
REGION_ALIAS("RAM", ram)

SECTIONS
{
/* To provide symbol __STACK_SIZE, __HEAP_SIZE */
PROVIDE(__STACK_SIZE = 2K);
PROVIDE(__HEAP_SIZE = 2K);
__TOT_STACK_SIZE = __STACK_SIZE;

.init         :
{
    /* vector table locate at ROM */
    *(.vtable)
    KEEP (*(SORT_NONE(.init)))
    . = ALIGN(4);
} >ROM AT>ROM

/* Code section located at ROM */
.text         :
{
    *(.text.unlikely .text.unlikely.*)
    *(.text.startup .text.startup.*)
    *(.text .text.*)
    *(.gnu.linkonce.t.*)
    /* readonly data placed in ROM */
    . = ALIGN(8);
    *(.srodata.cst16)
    *(.srodata.cst8)
    *(.srodata.cst4)
    *(.srodata.cst2)
    *(.srodata .srodata.*)
    *(.rdata)
    *(.rodata .rodata.*)
    *(.gnu.linkonce.r.*)
    /* below sections are used for rt-thread */
    . = ALIGN(4);
    __rt_init_start = .;
    KEEP(*(SORT(.rti_fn*)))
    __rt_init_end = .;
    . = ALIGN(4);
    __fsymtab_start = .;
    KEEP(*(FSymTab))
    __fsymtab_end = .;
    . = ALIGN(4);
    __vsymtab_start = .;
    KEEP(*(VSymTab))
    __vsymtab_end = .;
} >ROM AT>ROM

.fini         :
{
    KEEP (*(SORT_NONE(.fini)))
} >ROM AT>ROM

.preinit_array:
{
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array))
    PROVIDE_HIDDEN (__preinit_array_end = .);
} >ROM AT>ROM

.init_array   :
{
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
    KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
    PROVIDE_HIDDEN (__init_array_end = .);
} >ROM AT>ROM

.fini_array   :
{
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
    KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
    PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM AT>ROM

.ctors          :
{
    /* gcc uses crtbegin.o to find the start of
   * the constructors, so we make sure it is
   * first.Because this is a wildcard, it
   * doesn't matter if the user does not
   * actually link against crtbegin.o; the
   * linker won't look for a file to match a
   * wildcard.The wildcard also means that it
   * doesn't matter which directory crtbegin.o
   * is in.
   */
    KEEP (*crtbegin.o(.ctors))
    KEEP (*crtbegin?.o(.ctors))
    /* We don't want to include the .ctor section from
   * the crtend.o file until after the sorted ctors.
   * The .ctor section from the crtend file contains the
   * end of ctors marker and it must be last
   */
    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
    KEEP (*(SORT(.ctors.*)))
    KEEP (*(.ctors))
} >ROM AT>ROM

.dtors          :
{
    KEEP (*crtbegin.o(.dtors))
    KEEP (*crtbegin?.o(.dtors))
    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
    KEEP (*(SORT(.dtors.*)))
    KEEP (*(.dtors))
} >ROM AT>ROM

PROVIDE( _ilm_lma = LOADADDR(.text) );
PROVIDE( _ilm = ADDR(.text) );
PROVIDE( _eilm = . );
PROVIDE( _text_lma = LOADADDR(.text) );
PROVIDE( _text = ADDR(.text) );
PROVIDE (_etext = .);
PROVIDE (__etext = .);
PROVIDE (etext = .);

.data            : ALIGN(8)
{
    KEEP(*(.data.ctest*))
    *(.data .data.*)
    *(.gnu.linkonce.d.*)
    . = ALIGN(8);
    PROVIDE( __global_pointer$ = . + 0x800 );
    *(.sdata .sdata.* .sdata*)
    *(.gnu.linkonce.s.*)
    . = ALIGN(8);
} >RAM AT>ROM

.tdata         : ALIGN(8)
{
    PROVIDE( __tls_base = . );
    *(.tdata .tdata.* .gnu.linkonce.td.*)
} >RAM AT>ROM

PROVIDE( _data_lma = LOADADDR(.data) );
PROVIDE( _data = ADDR(.data) );
PROVIDE( _edata = . );
PROVIDE( edata = . );

PROVIDE( _fbss = . );
PROVIDE( __bss_start = . );

.tbss (NOLOAD)   : ALIGN(8)
{
    *(.tbss .tbss.* .gnu.linkonce.tb.*)
    *(.tcommon)
    PROVIDE( __tls_end = . );
} >RAM AT>RAM

.tbss_space (NOLOAD) : ALIGN(8)
{
    . = . + SIZEOF(.tbss);
} >RAM AT>RAM

.bss (NOLOAD)   : ALIGN(8)
{
    *(.sbss*)
    *(.gnu.linkonce.sb.*)
    *(.bss .bss.*)
    *(.gnu.linkonce.b.*)
    *(COMMON)
    . = ALIGN(4);
} >RAM AT>RAM

PROVIDE( _end = . );
PROVIDE( end = . );

/* Nuclei C Runtime Library requirements:
   * 1. heap need to be align at 16 bytes
   * 2. __heap_start and __heap_end symbol need to be defined
   * 3. reserved at least __HEAP_SIZE space for heap
   */
.heap (NOLOAD)   : ALIGN(16)
{
    . = ALIGN(16);
    PROVIDE( __heap_start = . );
    . += __HEAP_SIZE;
    . = ALIGN(16);
    PROVIDE( __heap_limit = . );
} >RAM AT>RAM

.stack ORIGIN(RAM) + LENGTH(RAM) - __TOT_STACK_SIZE (NOLOAD) :
{
    . = ALIGN(16);
    PROVIDE( _heap_end = . );
    PROVIDE( __heap_end = . );
    PROVIDE( __StackLimit = . );
    PROVIDE( __StackBottom = . );
    . += __TOT_STACK_SIZE;
    . = ALIGN(16);
    PROVIDE( __StackTop = . );
    PROVIDE( _sp = . );
} >RAM AT>RAM
}



zcsexp 发表于 2024-1-10 15:05:02

我们用芯来的 IP 自己做的芯片,也是用 NucleiStudio 开发。说一下我们理解,仅供参考:
1. 程序实际下载到 RAM 还是 FLASH 取决于你的调试器的配置文件(确切说是 .ld 文件),和这个选项无关。这个选项就是为了告诉 Eclipse 会每次调试都需要重新下载程序
2. 至于取消 Initial Reset and Halt 是因为,芯片启动过程时有可能会用到 RAM,如果你烧写到 RAM 后,让芯片重新运行了,那之前烧写的程序就可能不对了

emwin 发表于 2024-1-11 10:19:54

用另一家的RISC-V核的MCU开发过1个项目,你理解是对的,这个链接配置是放在ROM区。

lindahnu 发表于 2024-1-12 15:01:24

zcsexp 发表于 2024-1-10 15:05
我们用芯来的 IP 自己做的芯片,也是用 NucleiStudio 开发。说一下我们理解,仅供参考:
1. 程序实际下载 ...

感谢解答,那请教一下你们怎么做的flash烧录算法文件来下载程序调试?就类似MDK的flash烧录FLM文件。

zcsexp 发表于 2024-1-13 19:18:01

lindahnu 发表于 2024-1-12 15:01
感谢解答,那请教一下你们怎么做的flash烧录算法文件来下载程序调试?就类似MDK的flash烧录FLM文件。

自己移植并编译的 OpenOCD,在自己的 SDK 中提供自己的 OpenOCD。

lindahnu 发表于 2024-1-16 12:01:54

zcsexp 发表于 2024-1-13 19:18
自己移植并编译的 OpenOCD,在自己的 SDK 中提供自己的 OpenOCD。

请教一下在什么环境下编译的openocd?
百度到一个帖子在windows下编译的(https://blog.csdn.net/ic2121/article/details/129332671)但最后结果就是缺少了一些文件,也不知道为什么。

pacman -S libtool
autoconf
automake
texinfo
pkg-config
make
autogen
git
unzip
bzip2
base-devel
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-libusb
mingw-w64-x86_64-libusb-compat-git
mingw-w64-x86_64-hidapi
mingw-w64-x86_64-libftdi
mingw-w64-x86_64-arm-none-eabi-gcc
mingw-w64-x86_64-capstone
mingw-w64-x86_64-libjaylink


make install完成后:
bin文件夹缺少了libgcc_s_sjlj-1.dll;
lib文件夹缺少capstone.lib,libhidapi.la,libusb-1.0.la;
doc文件夹下缺少hidapi;



这是我少装了哪些依赖库吗?


zcsexp 发表于 2024-1-16 13:48:20

lindahnu 发表于 2024-1-16 12:01
请教一下在什么环境下编译的openocd?
百度到一个帖子在windows下编译的(https://blog.csdn.net/ic2121 ...

1. 我都是在 Ubuntu 下进行交叉编译 linux 版本和 Windows 版本。直接在 Windows 下编译,官方说支持 MSYS2 环境,但是我没试过
2.libgcc_s_sjlj-1.dll、libwinpthread-1.dll 是需要手动拷贝的吧,我看官方说需要自己复制
3. 其他我没编译,具体不清楚

lindahnu 发表于 2024-1-16 14:18:38

zcsexp 发表于 2024-1-16 13:48
1. 我都是在 Ubuntu 下进行交叉编译 linux 版本和 Windows 版本。直接在 Windows 下编译,官方说支持 MSY ...

好的,谢谢。
页: [1]
查看完整版本: nuclei studio调试GD32VF103疑问