Giter VIP home page Giter VIP logo

nuclei-software / nuclei-sdk Goto Github PK

View Code? Open in Web Editor NEW
109.0 9.0 46.0 138.77 MB

Nuclei RISC-V Software Development Kit

Home Page: https://doc.nucleisys.com/nuclei_sdk

License: Apache License 2.0

Shell 0.60% C 91.87% Assembly 1.89% C++ 0.62% Makefile 0.66% HTML 0.49% Batchfile 0.01% Python 3.83% PowerShell 0.01% Tcl 0.02%
riscv risc-v embedded-hal iot-platform nuclei freertos rtos makefile fpga-evaluation-board rt-thread

nuclei-sdk's Introduction

Nuclei Software Development Kit

Build Documentation Build SDK

Since 0.5.0 release, Nuclei Studio >= 2023.10 and Nuclei RISC-V Toolchain/Qemu/OpenOCD >= 2023.10 are required to build and run.

Nuclei Software Development Kit(Nuclei SDK) is developed for developing and evaluating software using our FPGA evaluation board.

Nuclei SDK Diagram

This Nuclei SDK is built based on the NMSIS framework, user can access all the APIs provided by NMSIS and also the APIs that provided by Nuclei SDK which mainly for on-board peripherals access such as GPIO, UART, SPI and I2C etc.

We also intergated three RTOSes into Nuclei SDK, which are FreeRTOS, UCOSII and RTThread, you can easily find it in the OS folder.

Quick Startup

Wanner to a try with Nuclei SDK, click Quick Start with Nuclei SDK to start up.

Requirements

  • Ubuntu Linux >=16.04 LTS or Windows >=7
  • Nuclei Studio >= 2023.10
    • Nuclei Studio can support import Nuclei SDK NPK package to provide IDE project wizard create/build/debug.
    • Nuclei Studio also contains same release of Nuclei Toolchain/QEMU/OpenOCD, so just download IDE is enough.

Directory Structure

Here is the directory structure for this Nuclei SDK.

$NUCLEI_SDK_ROOT
├── application
│   ├── baremetal
│   ├── freertos
│   ├── ucosii
│   └── rtthread
├── Build
│   ├── gmsl
│   ├── toolchain
│   ├── Makefile.base
│   ├── Makefile.conf
│   ├── Makefile.core
│   ├── Makefile.components
│   ├── Makefile.files
│   ├── Makefile.global
│   ├── Makefile.misc
│   ├── Makefile.rtos
│   ├── Makefile.rules
│   └── Makefile.soc
├── doc
│   ├── build
│   ├── source
│   ├── Makefile
│   └── requirements.txt
├── NMSIS
│   ├── Core
│   ├── DSP
│   ├── NN
│   └── Library
├── OS
│   ├── FreeRTOS
│   ├── UCOSII
│   └── RTThread
├── SoC
│   ├── gd32vf103
│   └── evalsoc
├── test
│   ├── core
│   ├── ctest.h
│   ├── LICENSE
│   └── README.md
├── LICENSE
├── Makefile
├── NMSIS_VERSION
├── package.json
├── SConscript
├── README.md
├── setup.bat
└── setup.sh
  • application

    This directory contains all the application softwares for this Nuclei SDK.

    The application code can be divided into mainly 4 parts, which are:

    • Baremetal applications, which will provide baremetal applications without any OS usage, these applications will be placed in application/baremetal/ folder.
    • FreeRTOS applications, which will provide FreeRTOS applications using FreeRTOS RTOS, placed in application/freertos/ folder.
    • UCOSII applications, which will provide UCOSII applications using UCOSII RTOS, placed in application/ucosii/ folder.
    • RTThread applications, which will provide RT-Thread applications using RT-Thread RTOS, placed in application/rtthread/ folder.
  • SoC

    This directory contains all the supported SoCs for this Nuclei SDK, the directory name for SoC and its boards should always in lower case.

    Here we mainly support Nuclei processor cores running on Nuclei FPGA evaluation board(MCU200T/DDR200T), the support package placed in SoC/evalsoc/.

    In each SoC's include directory, nuclei_sdk_soc.h must be provided, and include the soc header file, for example, SoC/evalsoc/Common/Include/nuclei_sdk_soc.h.

    In each SoC Board's include directory, nuclei_sdk_hal.h must be provided, and include the board header file, for example, SoC/evalsoc/Board/nuclei_fpga_eval/Include/nuclei_sdk_hal.h.

  • Build

    This directory contains the key part of the build system based on Makefile for Nuclei SDK.

  • NMSIS

    This directory contains the NMSIS header files, which is widely used in this Nuclei SDK, you can check the NMSIS_VERSION file to know the current NMSIS version used in Nuclei-SDK.

    We will also sync the changes in NMSIS project when it provided a new release.

  • OS

    This directory provided three RTOS package we suppported which are FreeRTOS, UCOSII and RT-Thread.

  • LICENSE

    Nuclei SDK license file.

  • NMSIS_VERSION

    NMSIS Version file. It will show current NMSIS version used in Nuclei SDK.

  • package.json

    PlatformIO package json file for Nuclei SDK, used in Nuclei Plaform for PlatformIO

  • SConscript

    RT-Thread package scons build script, used in RT-Thread package development.

  • Makefile

    An external Makefile just for build, run, debug application without cd to any coresponding application directory, such as application/baremetal/helloworld/.

  • setup.sh

    Nuclei SDK environment setup script for Linux. You need to create your own setup_config.sh.

    # This can be path to Nuclei Studio's toolchain folder
    NUCLEI_TOOL_ROOT=/path/to/your_tool_root

    In the $NUCLEI_TOOL_ROOT for Linux, you need to have Nuclei RISC-V toolchain and OpenOCD installed as below.

    ${NUCLEI_TOOL_ROOT}
    ├── gcc
    │   ├── bin
    │   ├── include
    │   ├── lib
    │   ├── libexec
    │   ├── riscv64-unknown-elf
    │   └── share
    └── openocd
        ├── bin
        ├── contrib
        ├── distro-info
        ├── OpenULINK
        ├── scripts
        └── share
    
  • setup.bat

    Nuclei SDK environment setup bat script for Windows. You need to create your own setup_config.bat.

    set NUCLEI_TOOL_ROOT=\path\to\your_tool_root

    In the %NUCLEI_TOOL_ROOT% for Windows, you need to have Nuclei RISC-V toolchain, necessary Windows build tools and OpenOCD installed as below.

    %NUCLEI_TOOL_ROOT%
    ├── build-tools
    │   ├── bin
    │   ├── gnu-mcu-eclipse
    │   └── licenses
    ├── gcc
    │   ├── bin
    │   ├── include
    │   ├── lib
    │   ├── libexec
    │   ├── riscv64-unknown-elf
    │   └── share
    └── openocd
        ├── bin
        ├── contrib
        ├── distro-info
        ├── OpenULINK
        ├── scripts
        └── share

How to use

  1. Create and modify your own setup config
    • For Linux, create setup_config.sh in $NUCLEI_SDK_ROOT.
    • For Windows, create setup_config.bat in %NUCLEI_SDK_ROOT%.
  2. Source the environment script right in NUCLEI_SDK_ROOT
    • For Linux: source setup.sh
    • For Windows: setup.bat
  3. Build and run application.
    • Note: By default, the SoC and Board is set to evalsoc and nuclei_fpga_eval, if you don't pass any SOC and BOARD variable in Make command, it will use the default SoC and Board.
    • Assume that you will run this application -> application/baremetal/helloworld/.
    • cd application/baremetal/helloworld/
    • you can run make help to show help message.
    • We provided different Nuclei Core configurations(CORE=<your_core>) we supported, see Build/Makefile.core.
      • such as CORE=n305
    • We support several download modes(DOWNLOAD=) for different applications.
      • flashxip: Program will to be download into flash and run directly in Flash
      • flash: Program will be download into flash, when running, program will be copied to ilm/ram and run in ilm/ram
      • ilm: Program will be download into ilm/ram and run directly in ilm/ram, program lost when poweroff
    • For example, if you want to build your application for CORE=n305 DOWNLOAD=ilm, you can easily run this command:
      make CORE=n305 DOWNLOAD=ilm all
    • If you want to upload your application for CORE=n305 DOWNLOAD=ilm, you can easily run this command:
      make CORE=n305 DOWNLOAD=ilm upload
    • (Option 1)If you want to debug your application for CORE=n305 DOWNLOAD=ilm:
      • First open a new terminal in the same application folder and run: make CORE=n305 DOWNLOAD=ilm run_openocd
      • Then run this command make CORE=n305 DOWNLOAD=ilm run_gdb in the existing terminal, then you can debug it using gdb, if you want to load your program, you need to type load to achieve it.
      • Notice: Since version 0.2.4, you can also pass extra GDB_PORT=<portno>, to change to use new gdb port other than default 3333, for example, make CORE=n305 DOWNLOAD=ilm GDB_PORT=3344 run_openocd and make CORE=n305 DOWNLOAD=ilm GDB_PORT=3344 run_gdb
    • (Option 2)If you want to debug your application for CORE=n305 DOWNLOAD=ilm:
      make CORE=n305 DOWNLOAD=ilm debug
    • If you want to use UART terminal tool to view the UART message, you can choose screen or minicom in Linux, teraterm in Windows, the default UART baudrate we use is 115200.

Knowledge book

  • Since 0.5.0 release, Nuclei SDK only support Nuclei RISC-V Toolchain >= 2023.10, and toolchain prefix changed from riscv-nuclei-elf- to riscv64-unknown-elf-.

  • If you want to learn more about Nuclei SDK documentation, please click Nuclei SDK documentation

  • If you need to build a new application, or change CORE or DOWNLOAD option, please make sure that you have clean the project by make clean

  • If you want to specify additional compiler flags, please follow this guidance in your application Makefile.

    • Pass common compiler flags to all c/asm/cpp compiler, you can use COMMON_FLAGS in Makefile, such as COMMON_FLAGS := -O3 -funroll-loops -fpeel-loops
    • Pass C compiler only flags to c compiler, you can use CFLAGS in Makefile, such as CFLAGS := -O3 -funroll-loops -fpeel-loops
    • For ASM compiler only flags, you can use ASMFLAGS, for CPP compiler only flags, you can use CXXFLAGS.
  • If you want to pass additional linker flags, you can use LDFLAGS, and if you have additional library directories, you can use LIBDIRS to specify library directories.

  • The preprovided applications and its makefile is the best startup examples about how to use Nuclei SDK.

  • Pass extra V=1 to your make command, it will show verbose compiling information, otherwise it will only show basic information. Sample output with extra V=1

    $ make V=1 all
    Current Configuration: TOOLCHAIN=nuclei_gnu RISCV_ARCH=rv32imafdc RISCV_ABI=ilp32d RISCV_TUNE=nuclei-300-series RISCV_CMODEL=medlow SOC=evalsoc BOARD=nuclei_fpga_eval CORE=n307fd ARCH_EXT= DOWNLOAD=ilm STDCLIB=newlib_nano SMP= BOOT_HARTID=0
    Assembling :  ../../../SoC/evalsoc/Common/Source/GCC/intexc_evalsoc.S
    riscv64-unknown-elf-gcc -x assembler-with-cpp -O2 -DBOOT_HARTID=0 -march=rv32imafdc -mabi=ilp32d -mcmodel=medlow -mtune=nuclei-300-series -g -fno-common  -ffunction-sections -fdata-sections -DDOWNLOAD_MODE=DOWNLOAD_MODE_ILM -DDOWNLOAD_MODE_STRING=\"ILM\" -DCPU_SERIES=300  -I. -I../../../NMSIS/Core/Include -I../../../SoC/evalsoc/Board/nuclei_fpga_eval/Include -I../../../SoC/evalsoc/Common/Include -Iinc -MMD -MT ../../../SoC/evalsoc/Common/Source/GCC/intexc_evalsoc.S.o -MF
    ../../../SoC/evalsoc/Common/Source/GCC/intexc_evalsoc.S.o.d -c -o ../../../SoC/evalsoc/Common/Source/GCC/intexc_evalsoc.S.o ../../../SoC/evalsoc/Common/Source/GCC/intexc_evalsoc.S
    Assembling :  ../../../SoC/evalsoc/Common/Source/GCC/intexc_evalsoc_s.S
    riscv64-unknown-elf-gcc -x assembler-with-cpp -O2 -DBOOT_HARTID=0 -march=rv32imafdc -mabi=ilp32d -mcmodel=medlow -mtune=nuclei-300-series -g -fno-common  -ffunction-sections -fdata-sections -DDOWNLOAD_MODE=DOWNLOAD_MODE_ILM -DDOWNLOAD_MODE_STRING=\"ILM\" -DCPU_SERIES=300  -I. -I../../../NMSIS/Core/Include -I../../../SoC/evalsoc/Board/nuclei_fpga_eval/Include -I../../../SoC/evalsoc/Common/Include -Iinc -MMD -MT ../../../SoC/evalsoc/Common/Source/GCC/intexc_evalsoc_s.S.o -MF
    ../../../SoC/evalsoc/Common/Source/GCC/intexc_evalsoc_s.S.o.d -c -o ../../../SoC/evalsoc/Common/Source/GCC/intexc_evalsoc_s.S.o ../../../SoC/evalsoc/Common/Source/GCC/intexc_evalsoc_s.S
    Assembling :  ../../../SoC/evalsoc/Common/Source/GCC/startup_evalsoc.S

nuclei-sdk's People

Contributors

bigmagic123 avatar fanghuaqi avatar gsauthof avatar ivankravets avatar karlk90 avatar michahoiting avatar romanbuchert avatar tuupola 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

nuclei-sdk's Issues

VSCode Plugin for Nuclei SDK

Maybe we can have a VSCode plugin for nuclei sdk in future, which provide the following features:

  • Automatically download or use existing Nuclei SDK source code base
  • Create or use existing nuclei-sdk project as templates
  • Create project wizard support choosen of SoC, Board, Core, Download
  • Support build and debug application directly in VSCode using Makefile build system

Currently we have platformio-nuclei which also provide Nuclei SDK intergation in VSCode, but maybe there will be a good try to have a native plugin to directly use Nuclei SDK build system.

Sipeed-RV-debugger-lite supported?

I followed nuclei_sdk Manual on Linux with longan nano GD3VF103CBT6.

Building example ./application/baremetal/helloworld according to the manual is OK. Then I uploaded with sipeed-rv-debugger-lite by make SOC=gd32vf103 BOARD=gd32vf103c_longan_nano upload:

Download and run helloworld.elf
riscv-nuclei-elf-gdb helloworld.elf -ex "set remotetimeout 240" \
-ex "target remote | openocd  -c \"; gdb_port pipe; log_output openocd.log\" -f ../../../SoC/gd32vf103/Board/gd32vf103c_longan_nano/openocd_gd32vf103.cfg" \
--batch -ex "thread apply all monitor reset halt" -ex "thread apply all set \$pc=_start" -ex "thread 1" -ex "load" -ex "monitor resume" -ex "quit"
Open On-Chip Debugger 0.11.0+dev-01897-gc8fc2a168 (2022-04-01-08:40)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
_start0800 () at ../../../SoC/gd32vf103/Common/Source/GCC/startup_gd32vf103.S:372
372         j 1b

Thread 1 (Remote target):
JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice Semiconductor (Beijing) Inc), part: 0x9000, ver: 0x7)

Thread 1 (Remote target):
[Switching to thread 1 (Remote target)]
#0  _start () at ../../../SoC/gd32vf103/Common/Source/GCC/startup_gd32vf103.S:214
214         csrc CSR_MSTATUS, MSTATUS_MIE
Loading section .init, size 0x2f4 lma 0x8000000
Loading section .text, size 0x254c lma 0x8000300
Loading section .rodata, size 0x490 lma 0x800284c
Loading section .data, size 0x6c lma 0x8002cdc
Start address 0x08000180, load size 11580
Transfer rate: 2 KB/sec, 2895 bytes/write.
A debugging session is active.

        Inferior 1 [Remote target] will be detached.

Quit anyway? (y or n) [answered Y; input not from terminal]
[Inferior 1 (Remote target) detached]

However, the serial output is wired (115200 8N1):

Nu, *
lmY'R &22	3'&4S
DloXjdY'21S
A
CAU2q]Yk148MS J5
*t bMI 00N1j
Sj RIMP
! lol2o[rcRRcYK
CHYWK  eZ%Sooj
!&HY Kd2mrlYZ%SCKocY!CC lorl2o[rc RRVcYrHCH ol2o[rcRRooj
HYWK  ei%SCKooj
!HY Kd2mrlYZ%MCKocYrH
7'BlWKd m leZ%MCKcYK
C!HeWK  eZ%Sooj
 HYWK mrclY%SCKoorH
1HeWKd  eZ%Sooj
 lorl2mrc RRVcYrHCH(:BlrFN], j5VocY!CC:Blll2o[rc j5V %ceK
C: lorl2o[rc RRVcYrHCH(:BlrFN], j5VocY!CC:Blll2o[rclY%Sooj
: lorl2o[rcRRVcYrHCH1 HY Kd2mrlYZ%SCKocY!CC:Blll2o[rclY%Sooj

I tried different baudrate(9600...) but none of it was right.

Besides, multiple reset will get different results.

Register keyword removal

I noticed that some headers use the register keyword, e.g.:

__STATIC_FORCEINLINE uint32_t __CAS_W(volatile uint32_t *addr, uint32_t oldval, uint32_t newval)
{
register uint32_t result;
register uint32_t rc;
__ASM volatile ( \
"0: lr.w %0, %2 \n" \
" bne %0, %z3, 1f \n" \
" sc.w %1, %z4, %2 \n" \
" bnez %1, 0b \n" \
"1:\n" \
: "=&r"(result), "=&r"(rc), "+A"(*addr) \
: "r"(oldval), "r"(newval) \
: "memory");
return result;
}

AFAICS, those register keywords are superfluous because the following inline assembler directives specify the register-constraint for those variables.

However, OTOH, the asm register constraint can't be left out because the C register keyword is just a hint (in contrast to the GCC local register variable extension which is only supposed to be used if constraints aren't sufficient).

So I suggest to simply remove those register keywords.


Background: The register keyword was deprecated in C++ 17 and hence GCC warns about this when compiling with C++17 features enabled, even when wrapping the gd32vf103 headers in extern "C" { }.

As a workaround I #define register before including and gd32vf103 headers and so far I don't see any issues.

At least for now, one can also compile with -Wno-register.

How to evaluate gcc13 for nuclei sdk

If you want to take a try with gcc13 for nuclei sdk, you need to download our prebuilt still in development gcc13/clang17 toolchain from https://drive.weixin.qq.com/s?k=ABcAKgdSAFcdQ1noOT, and use a develop branch of nuclei sdk https://github.com/Nuclei-Software/nuclei-sdk/tree/develop.

From 2023.10.9, now develop branch is changing to use gcc13, and merged all the changes from feature/llvm branch, please switch to use develop branch.

Latest qemu for this branch can be found here: https://drive.weixin.qq.com/s?k=ABcAKgdSAFcWD95meC

About how to use this toolchain, please click(In Chinese) https://doc.weixin.qq.com/doc/w3_ASUAMQZqALwUNtgZUvFTH2hR2F7KD?scode=ABcAKgdSAFc1u2vvWl

Download the toolchain, and export it to system PATH, and just try it.

If you want to try nuclei llvm toolchain, just pass TOOLCHAIN=nuclei_llvm when run make command.

$ riscv64-unknown-elf-gcc --version
riscv64-unknown-elf-gcc (gfc04c1213) 13.1.1 20230713
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cd application/baremetal/benchmark/coremark
$ make TOOLCHAIN=nuclei_llvm clean all
Clean all build objects
Current Configuration: TOOLCHAIN=nuclei_llvm RISCV_ARCH=rv32imafdc RISCV_ABI=ilp32d RISCV_TUNE=nuclei-300-series RISCV_CMODEL=medlow SOC=evalsoc BOARD=nuclei_fpga_eval CORE=n307fd ARCH_EXT= DOWNLOAD=ilm STDCLIB=newlib_small SMP= BOOT_HARTID=0
Compiling  :  ../../../../SoC/evalsoc/Common/Source/evalsoc_common.c
Compiling  :  ../../../../SoC/evalsoc/Common/Source/system_evalsoc.c
... ...
Compiling  :  core_list_join.c
Compiling  :  core_main.c
Compiling  :  core_matrix.c
Compiling  :  core_portme.c
Compiling  :  core_state.c
Compiling  :  core_util.c
Linking    :  coremark.elf
   text    data     bss     dec     hex filename
  22836    4072    4812   31720    7be8 coremark.elf

If you want to test gnu toolchain support Zc and Xxlcz, you can try it like this:

nuclei llvm not yet support Zc

cd application/baremetal/benchmark/coremark
# default TOOLCHAIN is nuclei_gnu, no need to pass TOOLCHAIN=nuclei_gnu
## Test cpu arch rv32imafc, which means n300 with single float point, and C extension
make CORE=n300f ARCH_EXT=_zca_zcb_zcf_zcmp_zcmt clean
make CORE=n300f ARCH_EXT=_zca_zcb_zcf_zcmp_zcmt all

## Test cpu arch rv32imaf_zca_zcb_zcf_zcmp_zcmt, which means n300 with single float point, and Zc extension
make CORE=n300f ARCH_EXT=_zca_zcb_zcf_zcmp_zcmt clean
make CORE=n300f ARCH_EXT=_zca_zcb_zcf_zcmp_zcmt all

## Test cpu arch rv32imaf_zca_zcb_zcf_zcmp_zcmt_xxlcz, which means n300 with single float point, and Zc extension, and Xxlcz extension
make CORE=n300f ARCH_EXT=_zca_zcb_zcf_zcmp_zcmt_xxlcz clean
make CORE=n300f ARCH_EXT=_zca_zcb_zcf_zcmp_zcmt_xxlcz all

You can also switch different c library by using https://doc.nucleisys.com/nuclei_sdk/develop/buildsystem.html#develop-buildsystem-var-stdclib

[Feature]Add CI support for Nuclei SDK

Feature: Add CI support for Nuclei SDK

  • Add CI support for build Nuclei SDK in windows and Linux
  • Tasks need to do:
    • CI choice: https://circleci.com/, github actions, or travis ci and appveyor
    • Build application in Windows and Linux
    • Build application for hbird and gd32vf103 soc and its board

[Document] Add documentation for Nuclei SDK

Feature: Add documentation for Nuclei SDK

Tasks need to be done:

  • Add documentation structure using Sphinx and reStructuredText
  • Document about Nuclei SDK source code structure and NMSIS
  • Document about Build system of Nuclei SDK
  • Document about Nuclei SDK supported Board
    - Must describe the board's necessary information, so software developer can easily use this board without looking into the hardware manual too much
    - Must contain nessary steps about how to use Nuclei SDK on this board
  • Document about the applications and how to run
  • Document about how to add a new application
  • Document about how to add new BSP support in Nuclei SDK
  • Document about contributing guide

RCCV vs. adding clock pulses

The GD32CVF103 User Manual (1.3) specifies the RTC clock calibration value (RCCV) as:

RTC clock calibration value The value indicates how many clock pulses are ignored or added every 2^20 RTC clock pulses.

(Section 4.4.2, page 59, emphasis mine)

After implementing a calibration procedure I don't think that the second (emphasized) part is true. That means it looks like the RCCV can only be used to ignore clock pulses.

(In which case, when having a clock that is too slow, one would need to decrement the prescaler and calibrate from a (then) too fast clock.)

My tests show that RCCV isn't interpreted as signed (two's complement) value.

And I can't find any other field that would work as a sign bit, either. I mean, e.g. in contrast to the GD32F1x0 where the RTC_HRFC register contains the CMSK (Calibration mask number) and FREQI fields.

Can you clarify this point?

Batch execution raised an error

setup.bat

**** ПРЕВЫШЕНИЕ РАЗМЕРОВ СТЕКА ****
**** ПРИ ВЫПОЛНЕНИИ РЕКУРСИИ В ПАКЕТНОМ РЕЖИМЕ ****
Глубина рекурсии=317, Использование стека=90 проц.
**** ПАКЕТНАЯ ОБРАБОТКА ПРЕРВАНА ****

Issue translated using google:

setup.bat

**** OVERSTACK SIZES ****
**** WHEN PERFORMING RECURSION IN BATCH MODE ****
Recursion depth = 317, Stack usage = 90 percent.
**** BATCH PROCESSING INTERRUPTED ****

semihost is not working in Nuclei SDK 0.4.1

When working with Nuclei SDK 0.4.1, build and compile with semihosting library, the semihosting feature is not working as expect.

make STDCLIB=newlib_nano CORE=n300fd SEMIHOST=1 clean all

The program stop at early_exc_entry and no output in openocd console, which is not as expected.

Can board name prefix be removed from common functions?

Currently some of the common function names are prefixed with the board name.

void gd_eval_led_init(led_typedef_enum lednum);
void gd_eval_led_on(led_typedef_enum lednum);
void gd_eval_led_off(led_typedef_enum lednum);
void gd_eval_led_toggle(led_typedef_enum lednum);
void gd_eval_key_init(key_typedef_enum keynum, keymode_typedef_enum key_mode);
uint8_t gd_eval_key_state_get(key_typedef_enum key);
void gd_rvstar_led_init(led_typedef_enum lednum);
void gd_rvstar_led_on(led_typedef_enum lednum);
void gd_rvstar_led_off(led_typedef_enum lednum);
void gd_rvstar_led_toggle(led_typedef_enum lednum);
void gd_rvstar_key_init(key_typedef_enum keynum, keymode_typedef_enum keymode);
uint8_t gd_rvstar_key_state_get(key_typedef_enum keynum);

Looking at the source I could not find any technical reason for this. Function signatures and behaviour are the same. Could the function names be unified to be the following?

void gd_led_init(led_typedef_enum lednum);
void gd_led_on(led_typedef_enum lednum);
void gd_led_off(led_typedef_enum lednum);
void gd_led_toggle(led_typedef_enum lednum);
void gd_key_init(key_typedef_enum keynum, keymode_typedef_enum keymode);
uint8_t gd_key_state_get(key_typedef_enum keynum);

This way you could use the same code for different dev boards.

undefined reference to `_sp'

in portasm.s of freertos file ,there are a undefined reference to `_sp'.
where to define the "_sp" in la to _sp?
how to solve this problem?

Prebuilt libraries disk usage

When cloning the repository over a slow connection I noticed that it contains a bunch of prebuilt libraries:

$ du -chs NMSIS/Library/
117M	NMSIS/Library/
117M	total

I'm kind of afraid that those prebuilt libraries will bloat this repository in the future even more, when each change to them basically adds another 100 MBs or so to the git index.

Is it really necessary to include those artifacts?

Perhaps there are alternatives such as using Git Large File Storage or building them from source like the rest?

openocd reg command

Hi
openocd reg command can't display all values of all registers. So i have to invoke command "reg a0", "reg a1" and so on, which is very slow. Any workaround?
thanks
Peter

GD32VF103: Update driver?

Currently, SDK is still using the driver which is 2 years old. Driver from gigadevice has updated a lot since then, so better update to newer version.

SMP demo fail, what can i do?

I create a smp demo by "SMP Helloworld in baremetal environment @app-nsdk_smphello" on NucleiDemo.
But it can't run into main() when i debug it with qemu, does i need to do any other configuration?
I also build it from nuclei-sdk/application/baremetal/smphello by hand. Only one cpu run.
LOGS:

Nuclei SDK Build Time: Jun 15 2022, 18:01:00
Download Mode: ILM
CPU Frequency 46858 Hz
Hello world from hart 0
Some harts boot failed, only 1/2 booted!

I think nuclei-n307fd which demo use by default does not support smp?

I test by below:

qemu-system-riscv32.exe  -machine nuclei_n -cpu nuclei-n307fd -smp 2 -serial stdio -nodefaults -S -s
qemu-system-riscv32.exe: Invalid SMP CPUs 2. The max CPUs supported by machine 'nuclei_n' is 1

[GD32VF103] Jump to embedded bootloader from user code

I'm wondering if it is possible to jump to the embedded bootloader that is present at 0x1FFFB000 in the devices ROM without a reset and externally pulling Boot0 high?

So far I have tried to jump to 0x1FFFB000 immediately after the device has been reset in the startup code. Observing the execution path with a debugger I can confirm that this indeed produced a valid jump, but the bootloader code is not executed successfully e.g. with a USB connection it doesn't show up as a USB-DFU device.

I know that this is possible with STM32F103 and GD32F103, so there is a chance that this possible as well?

How to handle different variations of Longan Nano?

Currently there is two known versions of Longan Nano. The official version has GD32VF103CBT6 which has 128K flash and 32K sram. Apparently some Aliexpress sellers also make version with GD32VF103C8T6 which has 64K flash and 20K sram. This is also sometimes referred as the Longan Nano Lite.

Currently the Nuclei SDK linker script for Longan Nano assumes the Lite version. This causes the linking to fail with memory heavy applications.

Linking    :  firmware.elf
/opt/nuclei/gcc/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: firmware.elf section `.bss' will not fit in region `ram'
/opt/nuclei/gcc/bin/../lib/gcc/riscv-nuclei-elf/9.2.0/../../../../riscv-nuclei-elf/bin/ld: section .stack VMA [0000000020004800,0000000020004fff] overlaps section .bss VMA [0000000020000268,0000000020006a23]
/opt/nuclei/gcc/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
../nuclei-sdk-roman/Build/Makefile.rules:71: recipe for target 'firmware.elf' failed
make: *** [firmware.elf] Error 1

When changing the linker script to support 32kB sram linking succeeds.

Linking    :  firmware.elf
   text	   data	    bss	    dec	    hex	filename
  72022	    612	  28604	 101238	  18b76	firmware.elf

This issue is to start discussion how to support the different variations of the Longan Nano board. Separate linker scripts chosen with a Makefile variable is one possibility.

Build system already supports LINKER_SCRIPT variable. Can this be used or should a new variable be introduced?

Is a bug in CTEST?

test/core/test_compiler.c:

now:

{
    uint32_t __ALIGNED(2) data_aligned1;
    uint32_t __ALIGNED(16) data[4];
    uint32_t __ALIGNED(64) data2[4];
    unsigned long p_data = (unsigned long)(&data_aligned1);
    CTEST_LOG("Aligned 2 Byte Data address 0x%x", p_data);
    ASSERT_EQUAL(p_data & (1 - 1), 0);
    p_data = (unsigned long)(&data[0]);
    CTEST_LOG("Aligned 16 Byte Data address 0x%x", p_data);
    ASSERT_EQUAL(p_data & (16 - 1), 0);
    p_data = (unsigned long)(&data2[0]);
    CTEST_LOG("Aligned 64 Byte Data address 0x%x", p_data);
    ASSERT_EQUAL(p_data & (64 - 1), 0);
}

data_aligned1 is __ALIGNED(2), but ASSERT_EQUAL(p_data & (1 - 1), 0), shoule ASSERT_EQUAL(p_data & (2 - 1), 0)?

arithmetic on `void*`

In NMSIS/Core/Include/core_feature_timer.h, there are codes like:

addr = (void *)(&(SysTimer->MTIMER));
high0 = __LW(addr + 4);

which will cause many compiling warnings in g++.

When doing arithmetic operations, void * will be treated as char * in GCC, but it is not defined in the C standard,
I guess it will be better to replace them by something like

addr = (void *)(&(SysTimer->MTIMER));
high0 = __LW((int *) addr + 1);

or

addr = (void *)(&(SysTimer->MTIMER));
high0 = __LW((char *) addr + 4);

intexc_gd32vf103.S uses unsupported extension zicsr on architecture rv32imac

When I build the example application with upstream RISC-V toolchain (12.2.0) for Longan Nano equipped with GD32VF103C8T6, it will show the error:

Assembling :  ../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S: Assembler messages:
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:162: Error: unrecognized opcode `csrrwi x0,0x7EE,11', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:162: Error: unrecognized opcode `csrrwi x0,0x7EF,12', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:162: Error: unrecognized opcode `csrrwi x0,0x7EB,13', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:169: Error: unrecognized opcode `csrr a0,mcause', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:179: Error: unrecognized opcode `csrw 0x7C4,x5', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:179: Error: unrecognized opcode `csrw 0x341,x5', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:179: Error: unrecognized opcode `csrw 0x342,x5', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:206: Error: unrecognized opcode `csrrwi x0,0x7EE,11', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:206: Error: unrecognized opcode `csrrwi x0,0x7EF,12', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:206: Error: unrecognized opcode `csrrwi x0,0x7EB,13', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:213: Error: unrecognized opcode `csrrw ra,0x7ED,ra', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:216: Error: unrecognized opcode `csrc 0x300,0x00000008', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:219: Error: unrecognized opcode `csrw 0x7C4,x5', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:219: Error: unrecognized opcode `csrw 0x341,x5', extension `zicsr' required
../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S:219: Error: unrecognized opcode `csrw 0x342,x5', extension `zicsr' required
make: *** [../../../Build/Makefile.rules:100: ../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S.o] Error 1

Headers use features from other headers without including them.

For instance, core_feature_eclic.h uses the rv_csr_t type which is defined in core_feature_base.h, but it does not #include it. This means that the header does not work if it is included on its own, and even if you include both headers, the order in which you do so matters.

Headers should #include whatever other headers they need.

Error in __set_exc_entry

The comments for __set_exc_entry says that address should be aligned to 4 bytes, but the code itself forces alignment to 64 bytes:

https://github.com/Nuclei-Software/nuclei-sdk/blob/master/NMSIS/Core/Include/core_feature_eclic.h#L757

This looks like a mistake copied from the earlier n200_func.c file, which also incorrectly aligned the address to 64 bytes. The address should be masked by ~3, not ~0x3f.

This code probably works by accident since a lot of startup code seems to place the interrupt table at the start of Flash memory, so it is accidentally aligned.

EDIT: It seems that the address written to mtvec does have to be aligned to 64 bytes, or else the hardware refuses to work. So the actual bug here is that this requirement is not correctly documented for this function.

https://github.com/Nuclei-Software/nuclei-sdk/blob/master/NMSIS/Core/Include/core_feature_eclic.h#L751

This comment says the address has to be aligned to 4 bytes, but it should be aligned to 64 bytes.

Is a bug in CTEST?

in test_csr.c:

CTEST(core, icache)
{
    EnableICache();
    ASSERT_NOT_EQUAL(__RV_CSR_READ(CSR_MCACHE_CTL) & CSR_MCACHE_CTL_IE, 0);
    DisableICache();
    ASSERT_EQUAL(__RV_CSR_READ(CSR_MCACHE_CTL) & CSR_MCACHE_CTL_IE, 0);
}

should do

__RWMB();
__FENCE_I();

before EnableICache();andEnableICache();?
Now,If my compilation option is -02,CPU may be abnormal。

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.