quickstart.rst 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. .. _quickstart:
  2. Quick Startup
  3. =============
  4. .. _quickstart_using_nside:
  5. Use Nuclei SDK in Nuclei Studio
  6. -------------------------------
  7. .. caution::
  8. - If you are looking for Nuclei 100 series support, please read :ref:`N100 support status <n100_support_limitation>`
  9. - If you are evaluating Nuclei CPU, in future released **nuclei_gen**, you will be able
  10. to use the generated Nuclei SDK, please see :ref:`design_soc_evalsoc_usage`.
  11. - For **Nuclei SDK 0.6.0** version and later ones, please use `Nuclei Studio 2024.06`_ or
  12. Nuclei RISC-V Toolchain/OpenOCD/QEMU 2024.06.
  13. - For **Nuclei SDK 0.8.0** version and later ones, please use `Nuclei Studio 2025.02`_ or
  14. Nuclei RISC-V Toolchain/OpenOCD/QEMU/CPUModel 2025.02.
  15. - For **Nuclei SDK 0.9.0** version and later ones, please use `Nuclei Studio 2025.10`_ or
  16. Nuclei RISC-V Toolchain/OpenOCD/QEMU/CPUModel 2025.10.
  17. From `Nuclei Toolchain 2023.10`_, both gnu and llvm toolchain are provided, and toolchain
  18. prefix changed from ``riscv-nuclei-elf-`` to ``riscv64-unknown-elf-``, and 0.5.0 SDK release
  19. will only support this ``2023.10`` or later toolchain.
  20. If you want to learn about how to use Nuclei Tools(IDE,Toolchain,Qemu,OpenOCD,XlModel),
  21. please checkout https://doc.nucleisys.com/nuclei_tools.
  22. If you want to report issues and see application note when using Nuclei Tools or Nuclei Studio,
  23. please checkout https://github.com/Nuclei-Software/nuclei-studio.
  24. Now the nuclei-sdk **released** versions are deeply integrated with Nuclei Studio IDE via menu
  25. **RV-Tools -> NPK Package Management**, and you can directly create nuclei-sdk project in Nuclei Studio IDE
  26. Menu **File -> New Nuclei RISC-V C/C++ Project**.
  27. You can download **Nuclei Studio IDE** from |nuclei_download_center|, and follow
  28. `Nuclei Studio and Nuclei Tools User Guide`_ to learn how to use it.
  29. But if you want to use latest source code of Nuclei SDK, please follow the rest
  30. part of this guide to build and run using Nuclei SDK Build System in Makefile.
  31. .. _quickstart_setup_tools_env:
  32. Setup Tools and Environment
  33. ---------------------------
  34. To start to use Nuclei SDK, you need to install the following tools:
  35. From **2020.10** release version of Nuclei Studio, you can directly use the prebuilt tools
  36. provided in Nuclei Studio(**strongly suggested**), please following :ref:`quickstart_setup_tools_env_nside`.
  37. .. _quickstart_setup_tools_env_nside:
  38. Use Prebuilt Tools in Nuclei Studio
  39. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  40. Since **2020.10** release version of Nuclei Studio, you just need to download the
  41. **Nuclei Studio IDE** from |nuclei_download_center| for your development OS, and
  42. no need to do the following steps below, the prebuilt tools are already included.
  43. For example:
  44. * In Windows, if you have extracted the Nuclei Studio IDE to ``D:\Software\NucleiStudio_IDE_202510``,
  45. then you can find the prebuilt tools in ``D:\Software\NucleiStudio_IDE_202510\NucleiStudio\toolchain``.
  46. * In Linux, if you have extracted the Nuclei Studio IDE to ``/home/labdev/NucleiStudio_IDE_202510``,
  47. then you can find the prebuilt tools in ``/home/labdev/NucleiStudio_IDE_202510/NucleiStudio/toolchain``.
  48. You can also update tools located in the Nuclei Studio prebuilt tools ``toolchain`` by downloading newer version
  49. from `Nuclei Tools`_ and replace it.
  50. .. _quickstart_get_set_nuclei_sdk:
  51. Get and Setup Nuclei SDK
  52. ------------------------
  53. The source code of Nuclei SDK is maintained in |github| and |gitee|.
  54. * We mainly maintained github version, and gitee version is mirrored, just for fast access in China.
  55. * Check source code in |github_nuclei_sdk| or |gitee_nuclei_sdk| according to your network status.
  56. * Stable version of Nuclei SDK is maintained in **master** version, if you want release version of **Nuclei SDK**,
  57. please check in |github_nuclei_sdk_release|.
  58. **Here are the steps to clone the latest source code from Github:**
  59. * Make sure you have installed Git tool, see https://git-scm.com/download/
  60. * Then open your terminal, and make sure git command can be accessed
  61. * Run ``git clone https://github.com/Nuclei-Software/nuclei-sdk nuclei-sdk`` to clone source code
  62. into ``nuclei-sdk`` folder
  63. .. note::
  64. - If you have no access to github.com, you can also use command
  65. ``git clone https://gitee.com/Nuclei-Software/nuclei-sdk nuclei-sdk`` to clone from gitee.
  66. - If you have no internet access, you can also use pre-downloaded ``nuclei-sdk`` code,
  67. and use it.
  68. - If the backup repo is not up to date, you can import github repo in gitee by yourself, see
  69. https://gitee.com/projects/import/url
  70. * Create tool environment config file for Nuclei SDK
  71. .. note::
  72. If you want to use **Terapines ZCC** toolchain, you can download latest version from https://www.terapines.com/, or use
  73. **Nuclei Studio >= 2024.06**, a **Terapines ZCC Community** version is integrated in **<NucleiStudio>/toolchain/zcc** folder,
  74. and you also need to add extra **PATH** into your environment, like this:
  75. - **Windows**: execute ``set PATH=\path\to\zcc\bin;%PATH%`` in windows cmd terminal before run Nuclei SDK
  76. - **Linux**: execute ``set PATH=/path/to/zcc/bin:$PATH`` in linux shell terminal before build Nuclei SDK
  77. - **Windows**
  78. If you want to use Nuclei SDK in **Windows Command Prompt** terminal, you need to
  79. create ``setup_config.bat`` in ``nuclei-sdk`` folder, and open this file
  80. your editor, and paste the following content, assuming you followed
  81. :ref:`quickstart_setup_tools_env`, and prebuilt tools located in
  82. ``D:\Software\NucleiStudio_IDE_202510\NucleiStudio\toolchain``,
  83. otherwise please use your correct tool root path.
  84. .. code-block:: bat
  85. set NUCLEI_TOOL_ROOT=D:\Software\NucleiStudio_IDE_202510\NucleiStudio\toolchain
  86. If you want to use Nuclei SDK in **Windows PowerShell** terminal, you need to create
  87. a ``setup_config.ps1`` in ``nuclei-sdk`` folder, and edit this file with content below
  88. if your prebuilt tools are located in ``D:\Software\NucleiStudio_IDE_202510\NucleiStudio\toolchain``:
  89. .. code-block:: ps1
  90. $NUCLEI_TOOL_ROOT="D:\Software\NucleiStudio_IDE_202510\NucleiStudio\toolchain"
  91. - **Linux**
  92. Create ``setup_config.sh`` in ``nuclei-sdk`` folder, and open this file
  93. your editor, and paste the following content, assuming you followed
  94. :ref:`quickstart_setup_tools_env` and prebuilt tools located in
  95. ``/home/labdev/NucleiStudio_IDE_202510/NucleiStudio/toolchain``,
  96. otherwise please use your correct tool root path.
  97. .. code-block:: shell
  98. NUCLEI_TOOL_ROOT=/home/labdev/NucleiStudio_IDE_202510/NucleiStudio/toolchain
  99. .. _quickstart_buildrundebug_app:
  100. Build, Run and Debug Sample Application
  101. ---------------------------------------
  102. Assume you have followed steps in :ref:`quickstart_get_set_nuclei_sdk` to clone
  103. source code and create files below:
  104. * ``setup_config.bat`` for run in **Windows Command Prompt** terminal
  105. * ``setup_config.ps1`` for run in **Windows PowerShell** terminal
  106. * ``setup_config.sh`` for run in **Linux Bash** terminal
  107. To build, run and debug application, you need to open command terminal in ``nuclei-sdk``
  108. folder.
  109. * For **Windows** users, you can open **Windows Command Prompt** terminal and cd to ``nuclei-sdk`` folder,
  110. then run the following commands to setup build environment for Nuclei SDK, the output will
  111. be similar as this screenshot :ref:`figure_quickstart_6`:
  112. .. code-block:: bat
  113. :linenos:
  114. setup.bat
  115. echo %PATH%
  116. where riscv64-unknown-elf-gcc openocd make rm
  117. make help
  118. .. _figure_quickstart_6:
  119. .. figure:: /asserts/images/nuclei_sdk_open_cmd.png
  120. :width: 80 %
  121. :align: center
  122. :alt: Setup Build Environment for Nuclei SDK in Windows Command Prompt
  123. Setup Build Environment for Nuclei SDK in Windows Command Prompt
  124. * For **Linux** users, you can open **Linux Bash** terminal and cd to ``nuclei-sdk`` folder,
  125. then run the following commands to setup build environment for Nuclei SDK, the output will
  126. be similar as this screenshot :ref:`figure_quickstart_7`:
  127. .. code-block:: shell
  128. :linenos:
  129. source setup.sh
  130. echo $PATH
  131. which riscv64-unknown-elf-gcc openocd make rm
  132. make help
  133. .. _figure_quickstart_7:
  134. .. figure:: /asserts/images/nuclei_sdk_open_shell.png
  135. :width: 80 %
  136. :align: center
  137. :alt: Setup Build Environment for Nuclei SDK in Linux Bash
  138. Setup Build Environment for Nuclei SDK in Linux Bash
  139. .. note::
  140. * Only first line ``setup.bat`` or ``source setup.sh`` are required before build, run or debug application.
  141. The ``setup.bat`` and ``setup.sh`` are just used to append Nuclei RISC-V GCC Toolchain, OpenOCD and Build-Tools
  142. binary paths into environment variable **PATH**
  143. * line 2-4 are just used to check whether build environment is setup correctly, especially the **PATH** of
  144. Nuclei Tools are setup correctly, so we can use the ``riscv64-unknown-elf-xxx``, ``openocd``, ``make`` and ``rm``
  145. tools
  146. * If you know how to append Nuclei RISC-V GCC Toolchain, OpenOCD and Build-Tools binary paths to **PATH** variable
  147. in your OS environment, you can also put the downloaded Nuclei Tools as you like, and no need to run ``setup.bat``
  148. or ``source setup.sh``
  149. * If you want to run in **Windows PowerShell**, please run ``. .\setup.ps1`` instead of ``setup.bat``, and
  150. ``setup_config.ps1`` must be created as described in :ref:`quickstart_get_set_nuclei_sdk`.
  151. Here for a quick startup, this guide will take board :ref:`design_board_gd32vf103v_rvstar`
  152. for example to demostrate how to setup hardware, build run and debug application in Windows.
  153. The demo application, we will take ``application/baremetal/helloworld`` for example.
  154. First of all, please reuse previously build environment command terminal.
  155. Run ``cd application/baremetal/helloworld`` to cd the ``helloworld`` example folder.
  156. Hardware Preparation
  157. ~~~~~~~~~~~~~~~~~~~~
  158. Please check :ref:`design_board` and find your board's page, and follow **Setup** section
  159. to setup your hardware, mainly **JTAG debugger driver setup and on-board connection setup**.
  160. * Power on the :ref:`design_board_gd32vf103v_rvstar` board, and use USB Type-C data cable to connect the board and your PC,
  161. make sure you have setup the JTAG driver correctly, and you can see JTAG port and serial port.
  162. * Open a UART terminal tool such as |teraterm| or |minicom|, and minitor the serial port of the Board,
  163. the UART baudrate is *115200 bps*
  164. * If you are building example for your own SoC and Board, please pass correct :ref:`develop_buildsystem_var_soc` and
  165. :ref:`develop_buildsystem_var_board` make variable. eg. If you SoC is ``evalsoc`` and Board is ``nuclei_fpga_eval``,
  166. just pass ``SOC=evalsoc BOARD=nuclei_fpga_eval`` to make instead of the one mentioned below. If your default board
  167. for this ``evalsoc`` is ``nuclei_fpga_eval``, then you don't need to pass ``BOARD=nuclei_fpga_eval``.
  168. * If you don't pass any SOC or BOARD via make, ``evalsoc`` and ``nuclei_fpga_eval`` are default SoC and Board.
  169. If you just want to try on **Nuclei Evaluation SoC**, no need to pass **SOC** or **BOARD**, the default value is that,
  170. you just need to pass correct :ref:`develop_buildsystem_var_core`, :ref:`develop_buildsystem_var_archext` and :ref:`develop_buildsystem_var_download`
  171. Build Application
  172. ~~~~~~~~~~~~~~~~~
  173. We need to build application for this board :ref:`design_board_gd32vf103v_rvstar` using this command line:
  174. .. note::
  175. * If you want to run on Nuclei Evaluation SoC, see :ref:`design_soc_evalsoc`, recommend to run :ref:`design_app_cpuinfo`
  176. * Since below steps are taking gd32vf103 SoC based board **gd32vf103v_rvstar** to do demostration,
  177. and when you pass ``SOC=gd32vf103``, the default BOARD will be ``gd32vf103v_rvstar``, so
  178. do you don't need to pass ``BOARD=gd32vf103v_rvstar``
  179. * You can check default SOC/BOARD/CORE information passed by using make target ``info``, eg.
  180. ``make SOC=gd32vf103 info``, for more information, please check :ref:`develop_buildsystem_make_targets`.
  181. .. code-block:: shell
  182. # clean application if build in other application before or build for other board
  183. make SOC=gd32vf103 BOARD=gd32vf103v_rvstar clean
  184. # first build choice: using full command line
  185. make SOC=gd32vf103 BOARD=gd32vf103v_rvstar all
  186. # second build choice: using simple command line, since when SOC=gd32vf103, default BOARD is gd32vf103v_rvstar
  187. make SOC=gd32vf103 all
  188. Here is the sample output of this command:
  189. .. code-block::
  190. # NOTICE: You can check this configuration whether it matched your desired configuration
  191. Current Configuration: RISCV_ARCH=rv32imac RISCV_ABI=ilp32 SOC=gd32vf103 BOARD=gd32vf103v_rvstar CORE=n205 DOWNLOAD=flashxip
  192. "Assembling : " ../../../SoC/gd32vf103/Common/Source/GCC/intexc_gd32vf103.S
  193. "Assembling : " ../../../SoC/gd32vf103/Common/Source/GCC/startup_gd32vf103.S
  194. "Compiling : " ../../../SoC/gd32vf103/Board/gd32vf103v_rvstar/Source/gd32vf103v_rvstar.c
  195. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_adc.c
  196. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_bkp.c
  197. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_can.c
  198. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_crc.c
  199. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_dac.c
  200. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_dbg.c
  201. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_dma.c
  202. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_exmc.c
  203. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_exti.c
  204. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_fmc.c
  205. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_fwdgt.c
  206. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_gpio.c
  207. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_i2c.c
  208. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_pmu.c
  209. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_rcu.c
  210. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_rtc.c
  211. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_spi.c
  212. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_timer.c
  213. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_usart.c
  214. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Drivers/gd32vf103_wwdgt.c
  215. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Stubs/close.c
  216. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Stubs/fstat.c
  217. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Stubs/gettimeofday.c
  218. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Stubs/isatty.c
  219. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Stubs/lseek.c
  220. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Stubs/read.c
  221. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Stubs/sbrk.c
  222. "Compiling : " ../../../SoC/gd32vf103/Common/Source/Stubs/write.c
  223. "Compiling : " ../../../SoC/gd32vf103/Common/Source/gd32vf103_soc.c
  224. "Compiling : " ../../../SoC/gd32vf103/Common/Source/system_gd32vf103.c
  225. "Compiling : " hello_world.c
  226. "Linking : " hello_world.elf
  227. text data bss dec hex filename
  228. 13022 112 2290 15424 3c40 hello_world.elf
  229. As you can see, that when the application is built successfully, the elf will be generated
  230. and will also print the size information of the ``hello_world.elf``.
  231. .. note::
  232. * In order to make sure that there is no application build before, you can run
  233. ``make SOC=gd32vf103 BOARD=gd32vf103v_rvstar clean`` to clean previously built
  234. objects and build dependency files.
  235. * About the make variable or option(**SOC**, **BOARD**) passed to make command, please refer
  236. to :ref:`develop_buildsystem`.
  237. Run Application
  238. ~~~~~~~~~~~~~~~
  239. If the application is built successfully for this board :ref:`design_board_gd32vf103v_rvstar`,
  240. then you can run it using this command line:
  241. .. code-block:: shell
  242. make SOC=gd32vf103 BOARD=gd32vf103v_rvstar upload
  243. Here is the sample output of this command:
  244. .. code-block::
  245. "Download and run hello_world.elf"
  246. riscv64-unknown-elf-gdb hello_world.elf -ex "set remotetimeout 240" \
  247. -ex "target remote | openocd -c \"gdb_port pipe; log_output openocd.log\" -f ../../../SoC/gd32vf103/Board/gd32vf103v_rvstar/openocd_gd32vf103.cfg" \
  248. --batch -ex "monitor halt" -ex "monitor halt" -ex "monitor flash protect 0 0 last off" -ex "load" -ex "monitor resume" -ex "monitor shutdown" -ex "quit"
  249. D:\Software\Nuclei\gcc\bin\riscv64-unknown-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
  250. Nuclei OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev-00014-g0eae03214 (2019-12-12-07:43)
  251. Licensed under GNU GPL v2
  252. For bug reports, read
  253. http://openocd.org/doc/doxygen/bugs.html
  254. _start0800 () at ../../../SoC/gd32vf103/Common/Source/GCC/startup_gd32vf103.S:359
  255. 359 j 1b
  256. cleared protection for sectors 0 through 127 on flash bank 0
  257. Loading section .init, size 0x266 lma 0x8000000
  258. Loading section .text, size 0x2e9c lma 0x8000280
  259. Loading section .rodata, size 0x1f0 lma 0x8003120
  260. Loading section .data, size 0x70 lma 0x8003310
  261. Start address 0x800015c, load size 13154
  262. Transfer rate: 7 KB/sec, 3288 bytes/write.
  263. shutdown command invoked
  264. A debugging session is active.
  265. Inferior 1 [Remote target] will be detached.
  266. Quit anyway? (y or n) [answered Y; input not from terminal]
  267. [Inferior 1 (Remote target) detached]
  268. As you can see the application is uploaded successfully using ``openocd`` and ``gdb``,
  269. then you can check the output in your UART terminal, see :ref:`figure_quickstart_8`.
  270. .. _figure_quickstart_8:
  271. .. figure:: /asserts/images/nuclei_app_helloworld_uart.png
  272. :width: 80 %
  273. :align: center
  274. :alt: Nuclei SDK Hello World Application UART Output
  275. Nuclei SDK Hello World Application UART Output
  276. Debug Application
  277. ~~~~~~~~~~~~~~~~~
  278. If the application is built successfully for this board :ref:`design_board_gd32vf103v_rvstar`,
  279. then you can debug it using this command line:
  280. .. code-block:: shell
  281. make SOC=gd32vf103 BOARD=gd32vf103v_rvstar debug
  282. 1. The program is not loaded automatically when you enter to debug state, just in case you want to
  283. debug the program running on the board.
  284. .. code-block::
  285. "Download and debug hello_world.elf"
  286. riscv64-unknown-elf-gdb hello_world.elf -ex "set remotetimeout 240" \
  287. -ex "target remote | openocd -c \"gdb_port pipe; log_output openocd.log\" -f ../../../SoC/gd32vf103/Board/gd32vf103v_rvstar/openocd_gd32vf103.cfg"
  288. D:\Software\Nuclei\gcc\bin\riscv64-unknown-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
  289. GNU gdb (GDB) 8.3.0.20190516-git
  290. Copyright (C) 2019 Free Software Foundation, Inc.
  291. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  292. This is free software: you are free to change and redistribute it.
  293. There is NO WARRANTY, to the extent permitted by law.
  294. Type "show copying" and "show warranty" for details.
  295. This GDB was configured as "--host=i686-w64-mingw32 --target=riscv64-unknown-elf".
  296. Type "show configuration" for configuration details.
  297. For bug reporting instructions, please see:
  298. <http://www.gnu.org/software/gdb/bugs/>.
  299. Find the GDB manual and other documentation resources online at:
  300. <http://www.gnu.org/software/gdb/documentation/>.
  301. --Type <RET> for more, q to quit, c to continue without paging--
  302. For help, type "help".
  303. Type "apropos word" to search for commands related to "word"...
  304. Reading symbols from hello_world.elf...
  305. Remote debugging using | openocd -c \"gdb_port pipe; log_output openocd.log\" -f ../../../SoC/gd32vf103/Board/gd32vf103v_rvstar/openocd_gd32vf103.cfg
  306. Nuclei OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev-00014-g0eae03214 (2019-12-12-07:43)
  307. Licensed under GNU GPL v2
  308. For bug reports, read
  309. http://openocd.org/doc/doxygen/bugs.html
  310. _start0800 () at ../../../SoC/gd32vf103/Common/Source/GCC/startup_gd32vf103.S:359
  311. 359 j 1b
  312. 2. If you want to load the built application, you can type ``load`` to load the application.
  313. .. code-block::
  314. (gdb) load
  315. Loading section .init, size 0x266 lma 0x8000000
  316. Loading section .text, size 0x2e9c lma 0x8000280
  317. Loading section .rodata, size 0x1f0 lma 0x8003120
  318. Loading section .data, size 0x70 lma 0x8003310
  319. Start address 0x800015c, load size 13154
  320. Transfer rate: 7 KB/sec, 3288 bytes/write.
  321. 3. If you want to set a breakpoint at *main*, then you can type ``b main`` to set a breakpoint.
  322. .. code-block::
  323. (gdb) b main
  324. Breakpoint 1 at 0x8001b04: file hello_world.c, line 85.
  325. 4. If you want to set more breakpoints, you can do as you like.
  326. 5. Then you can type ``c``, then the program will stop at **main**
  327. .. code-block::
  328. (gdb) c
  329. Continuing.
  330. Note: automatically using hardware breakpoints for read-only addresses.
  331. Breakpoint 1, main () at hello_world.c:85
  332. 85 srand(__get_rv_cycle() | __get_rv_instret() | __RV_CSR_READ(CSR_MCYCLE));
  333. 6. Then you can step it using ``n`` (short of next) or ``s`` (short of step)
  334. .. code-block::
  335. (gdb) n
  336. 86 uint32_t rval = rand();
  337. (gdb) n
  338. 87 rv_csr_t misa = __RV_CSR_READ(CSR_MISA);
  339. (gdb) s
  340. 89 printf("MISA: 0x%lx\r\n", misa);
  341. (gdb) n
  342. 90 print_misa();
  343. (gdb) n
  344. 92 printf("Hello World!\r\n");
  345. (gdb) n
  346. 93 printf("Hello World!\r\n");
  347. 7. If you want to quit debugging, then you can press ``CTRL - c``, and type ``q`` to quit debugging.
  348. .. code-block::
  349. (gdb) Quit
  350. (gdb) q
  351. A debugging session is active.
  352. Inferior 1 [Remote target] will be detached.
  353. Quit anyway? (y or n) y
  354. Detaching from program: D:\workspace\Sourcecode\nuclei-sdk\application\baremetal\helloworld\hello_world.elf, Remote target
  355. Ending remote debugging.
  356. [Inferior 1 (Remote target) detached]
  357. .. note::
  358. * More about how to debug using gdb, you can refer to the `GDB User Manual`_.
  359. * If you want to debug using Nuclei Studio, you can open Nuclei Studio, and create a debug configuration,
  360. and choose the application elf, and download and debug in IDE.
  361. Create helloworld Application
  362. -----------------------------
  363. If you want to create your own ``helloworld`` application, it is also very easy.
  364. There are several ways to achieve it, see as below:
  365. * **Method 1:** You can find a most similar sample application folder and copy it, such as
  366. ``application/baremetal/helloworld``, you can copy and rename it as ``application/baremetal/hello``
  367. - Open the ``Makefile`` in ``application/baremetal/hello``
  368. 1. Change ``TARGET = hello_world`` to ``TARGET = hello``
  369. - Open the ``hello_world.c`` in ``application/baremetal/hello``, and replace the content using code below:
  370. .. code-block:: c
  371. :linenos:
  372. // See LICENSE for license details.
  373. #include <stdio.h>
  374. #include <time.h>
  375. #include <stdlib.h>
  376. #include "nuclei_sdk_soc.h"
  377. int main(void)
  378. {
  379. printf("Hello World from Nuclei RISC-V Processor!\r\n");
  380. return 0;
  381. }
  382. - Save all the changes, and then you can follow the steps described
  383. in :ref:`quickstart_buildrundebug_app` to run or debug this new application.
  384. * **Method 2:** You can also do it from scratch, with just create simple ``Makefile`` and ``main.c``
  385. - Create new folder named ``hello`` in ``application/baremetal``
  386. - Create two files named ``Makefile`` and ``main.c``
  387. - Open ``Makefile`` and edit the content as below:
  388. .. code-block:: makefile
  389. :linenos:
  390. TARGET = hello
  391. NUCLEI_SDK_ROOT = ../../..
  392. SRCDIRS = .
  393. INCDIRS = .
  394. include $(NUCLEI_SDK_ROOT)/Build/Makefile.base
  395. - Open ``main.c`` and edit the content as below:
  396. .. code-block:: c
  397. :linenos:
  398. // See LICENSE for license details.
  399. #include <stdio.h>
  400. #include <time.h>
  401. #include <stdlib.h>
  402. #include "nuclei_sdk_soc.h"
  403. int main(void)
  404. {
  405. printf("Hello World from Nuclei RISC-V Processor!\r\n");
  406. return 0;
  407. }
  408. - Save all the changes, and then you can follow the steps described
  409. in :ref:`quickstart_buildrundebug_app` to run or debug this new application.
  410. .. note::
  411. * If your are looking for how to run for other boards, please ref to :ref:`design_board`.
  412. * Please refer to :ref:`develop_appdev` and :ref:`develop_buildsystem` for more information.
  413. * If you want to access SoC related APIs, please use ``nuclei_sdk_soc.h`` header file.
  414. * If you want to access SoC and board related APIs, please use ``nuclei_sdk_hal.h`` header file.
  415. * For simplified application development, you can use ``nuclei_sdk_hal.h`` directly.
  416. .. _quickstart_advanced_usage:
  417. Advanced Usage
  418. --------------
  419. For more advanced usage, please follow the items as below:
  420. * Click :ref:`design` to learn about Nuclei SDK Design and Architecture, Board and SoC support documentation.
  421. * Click :ref:`develop` to learn about Nuclei SDK Build System and Application Development.
  422. * Click :ref:`design_app` to learn about each application usage and expected output.
  423. .. note::
  424. * If you met some issues in using this guide, please check :ref:`faq`,
  425. if still not solved, please :ref:`contribute_submit_issue`.
  426. * If you are trying to **develop Nuclei SDK application in IDE**, now you have three choices:
  427. 1. **Recommended**: Since Nuclei Studio 2020.08, Nuclei SDK will be deeply integrated with
  428. Nuclei Studio IDE, you can easily create a Nuclei SDK Project in Nuclei Studio through IDE
  429. Project Wizard, and easily configure selected Nuclei SDK project using SDK Configuration Tool,
  430. for more details, please click `Nuclei Tools`_ to download Nuclei Studio IDE, and refer to
  431. the `Nuclei Studio and Nuclei Tools User Guide`_ for how to use it.
  432. 2. Now **Terapines ZCC Community** is deeply integrated in **Nuclei Studio >= 2024.06**, so you just need to
  433. follow :ref:`quickstart_get_set_nuclei_sdk` to setup PATH for Terapines ZCC, and in Nuclei SDK,
  434. you can just pass **TOOCHAIN=terapines** during make to take a try with Terapines ZCC, please use
  435. latest Terapines ZCC from its website https://www.terapines.com/.
  436. From 0.7.0 release, you can create project in Nuclei Studio >= 2024.06 using Terapines ZCC, see
  437. `Using Terapines ZCC Toolchain in Nuclei Studio`_.
  438. 3. You can take a try using IAR workbench, we provided prebuilt projects directly in Nuclei SDK,
  439. just check the `ideprojects/iar/README.md`_ to learn about it.
  440. 4. You can take a try using Segger embedded studio, we provided prebuilt projects using Nuclei
  441. SDK release version, click `Segger embedded studio projects for Nuclei SDK`_ to learn about it
  442. 5. You can also take a try with the Cross-platform PlatformIO IDE, we provided our Nuclei platform
  443. and Nuclei SDK release version in PlatformIO, click `Platform Nuclei in PlatformIO`_ to learn
  444. more about it, or you can visit `Light on onboard LED of RVSTAR board using PlatformIO(Chinese)`_
  445. to play with PlatformIO for Nuclei.
  446. 6. You can also use source code in Nuclei SDK as base, and easily integrate with other IDE tools,
  447. such as `ZStudio IDE`_, `Compiler IDE`_ and others.
  448. 7. If you want to evaluate RT-Thread instead of RT-Thread Nano, please check https://github.com/riscv-mcu/rt-thread/issues/1, SMP version also supported
  449. 8. If you want to evalute OpenHarmony LiteOS-M, please check https://github.com/riscv-mcu/kernel_liteos_m/tree/nuclei/OpenHarmony-3.0-LTS/targets/riscv_nuclei_evalsoc_gcc
  450. 9. If you want to evaluate Nuttx based RTOS such as Xiaomi Openvela, LiAuto HaloOS, please check https://github.com/riscv-mcu/nuttx/tree/nuclei_trunk/Documentation/platforms/risc-v/nuclei-evalsoc/boards/nuclei-fpga-eval
  451. 10. If you want to evaluate Zephyr RTOS, please check https://github.com/riscv-mcu/zephyr/blob/nuclei/4.1-branch/boards/nuclei/fpga_eval/doc/index.rst, SMP version also supported
  452. .. _GDB User Manual: https://www.gnu.org/software/gdb/documentation/
  453. .. _Nuclei Tools: https://nucleisys.com/download.php
  454. .. _Segger embedded studio projects for Nuclei SDK: https://github.com/riscv-mcu/ses_nuclei_sdk_projects
  455. .. _Platform Nuclei in PlatformIO: https://github.com/Nuclei-Software/platform-nuclei
  456. .. _Nuclei Studio and Nuclei Tools User Guide: https://doc.nucleisys.com/nuclei_tools/
  457. .. _Light on onboard LED of RVSTAR board using PlatformIO(Chinese): https://www.rvmcu.com/community-topic-id-310.html
  458. .. _Nuclei Toolchain 2023.10: https://github.com/riscv-mcu/riscv-gnu-toolchain/releases/tag/nuclei-2023.10
  459. .. _ideprojects/iar/README.md: https://github.com/Nuclei-Software/nuclei-sdk/blob/master/ideprojects/iar/README.md
  460. .. _Nuclei Studio 2024.06: https://github.com/Nuclei-Software/nuclei-studio/releases/tag/2024.06
  461. .. _Nuclei Studio 2025.02: https://github.com/Nuclei-Software/nuclei-studio/releases/tag/2025.02
  462. .. _Nuclei Studio 2025.10: https://github.com/Nuclei-Software/nuclei-studio/releases/tag/2025.10
  463. .. _Using Terapines ZCC Toolchain in Nuclei Studio: https://1nfinite.ai/t/nuclei-studio-2024-06-ide-terapines-zcc/113
  464. .. _ZStudio IDE: https://1nfinite.ai/t/zstudio-ide-risc-v/71
  465. .. _Compiler IDE: https://www.compiler-dev.com/