contribute.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. .. _contribute:
  2. Contributing
  3. ============
  4. Contributing to Nuclei N100 SDK project is always welcome.
  5. You can always do a lot of things to help Nuclei N100 SDK project
  6. improve and grow stronger.
  7. * :ref:`contribute_portsoc`
  8. * :ref:`contribute_submit_issue`
  9. * :ref:`contribute_submit_pr`
  10. .. _contribute_portsoc:
  11. Port your Nuclei SoC into Nuclei N100 SDK
  12. -----------------------------------------
  13. .. note::
  14. If you just want to do quick porting based on evalsoc implementation of Nuclei SDK
  15. to get quick ramp up, you can refer to `Quick Porting to you SoC based on Evalsoc in Nuclei N100 SDK`_
  16. If you want to port you Nuclei Processor Core based Board to Nuclei N100 SDK,
  17. you need to follow these steps:
  18. And the best example is our evalsoc support, although it may contains many unused features you may
  19. not want to use, but it is our evaluation SoC and will supply to provide best support for Nuclei RISC-V
  20. CPU features, if you are already using it, please keep in update of the evalsoc support changes in each
  21. release, you can track it by diff each release changes, and please also remember Nuclei N100 SDK release may
  22. also bump with NMSIS release.
  23. Assume your SoC name is ``ncstar``, based on Nuclei core **n100**, and **RISCV_ARCH**
  24. is ``rv32imc``, **RISCV_ABI** is ``ilp32``, and you made a new board called ``ncstar_eval``,
  25. and this SoC only support **FlashXIP** download mode.
  26. Make sure the SoC name and Board name used in this Nuclei N100 SDK is all in lowercase.
  27. 1. Create a folder named ``ncstar`` under **SoC** directory.
  28. * Create folder named ``Board`` and ``Common`` under ``ncstar``
  29. * Create directory structure under ``ncstar/Common`` like below:
  30. .. code-block:: text
  31. <ncstar/Common>
  32. ├── Include
  33. │   ├── peripheral_or_device_headers.h
  34. │   ├── ......
  35. │   ├── ncstar.h
  36. │   ├── nuclei_sdk_soc.h
  37. │   └── system_ncstar.h
  38. └── Source
  39. ├── Drivers
  40. │   ├── peripheral_or_device_sources.c
  41. │   └── ......
  42. ├── GCC
  43. │   ├── intexc_ncstar.S
  44. │   └── startup_ncstar.S
  45. ├── Stubs
  46. │   ├── newlib
  47. │   └── libncrt
  48. ├── ncstar_soc.c
  49. └── system_ncstar.c
  50. .. note::
  51. * The directory structure is based on the NMSIS device template, please refer
  52. to https://doc.nucleisys.com/nmsis/core/core_templates.html
  53. * The folder names must be exactly the same as the directory structure showed
  54. * **peripheral_or_device_sources.c** means the SoC peripheral driver source code files,
  55. such as uart, gpio, i2c, spi driver sources, usually get from the SoC firmware library,
  56. it should be placed in **Drivers** folder.
  57. * **peripheral_or_device_headers.h** means the SoC peripheral driver header files,
  58. such as uart, gpio, i2c, spi driver headers, usually get from the SoC firmware library,
  59. it should be placed in **Include** folder.
  60. * The **Stubs** folder contains the stub code files for newlib c library and nuclei c runtime
  61. library porting code, take ``SoC/evalsoc/Common/Stubs`` as reference.
  62. * The **GCC** folder contains *startup* and *exeception/interrupt* assemble code,
  63. if your board share the same linker script files, you can also put link script files here,
  64. the linker script files name rules can refer to previously supported *evalsoc* SoC.
  65. * If you want to do IAR compiler support, you also need to implement IAR related stuff,
  66. which is located in folder called IAR.
  67. * The **nuclei_sdk_soc.h** file is very important, it is a Nuclei SoC Header file used
  68. by common application which can run accoss different SoC, it should include the SoC device
  69. header file ``ncstar.h``
  70. * Create directory structure under ``ncstar/Board`` like below:
  71. .. code-block:: text
  72. <ncstar/Board>
  73. └── ncstar_eval
  74.    ├── Include
  75.    │   ├── ncstar_eval.h
  76.    │   └── nuclei_sdk_hal.h
  77.    ├── openocd_ncstar.cfg
  78.    └── Source
  79.    ├── GCC
  80.    │   └── gcc_ncstar_flashxip.ld
  81.    └── ncstar_eval.c
  82. .. note::
  83. * The **ncstar_eval** is the board folder name, if you have a new board,
  84. you can create a new folder in the same level
  85. * **Include** folder contains the board related header files
  86. * **Source** folder contains the board related source files
  87. * **GCC** folder is optional, if your linker script for the board is different
  88. to the SoC, you need to put your linker script here
  89. * **openocd_ncstar.cfg** file is the board related openocd debug configuration file
  90. * **ncstar_eval.h** file contains board related definition or APIs and also include
  91. the **SoC** header file, you can refer to previously supported board such as ``nuclei_fpga_eval``
  92. * **nuclei_sdk_hal.h** is very important, it includes the **ncstar_eval.h** header file.
  93. This file is used in application as entry header file to access board and SoC resources.
  94. 2. Create Makefile related to ``ncstar`` in :ref:`Nuclei N100 SDK build system <develop_buildsystem>`
  95. * Create **SoC/ncstar/build.mk**, the file content should be like this:
  96. .. code-block:: Makefile
  97. ##### Put your SoC build configurations below #####
  98. BOARD ?= ncstar_eval
  99. # override DOWNLOAD and CORE variable for NCSTAR SoC
  100. # even though it was set with a command argument
  101. override CORE := n100
  102. override DOWNLOAD := flashxip
  103. NUCLEI_SDK_SOC_BOARD := $(NUCLEI_SDK_SOC)/Board/$(BOARD)
  104. NUCLEI_SDK_SOC_COMMON := $(NUCLEI_SDK_SOC)/Common
  105. #no ilm on NCSTAR SoC
  106. LINKER_SCRIPT ?= $(NUCLEI_SDK_SOC_BOARD)/Source/GCC/gcc_ncstar_flashxip.ld
  107. OPENOCD_CFG ?= $(NUCLEI_SDK_SOC_BOARD)/openocd_ncstar.cfg
  108. RISCV_ARCH ?= rv32imc
  109. RISCV_ABI ?= ilp32
  110. ##### Put your Source code Management configurations below #####
  111. INCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Include
  112. C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source \
  113. $(NUCLEI_SDK_SOC_COMMON)/Source/Drivers
  114. ifneq ($(findstring libncrt,$(STDCLIB)),)
  115. C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source/Stubs/libncrt
  116. else ifneq ($(findstring newlib,$(STDCLIB)),)
  117. C_SRCDIRS += $(NUCLEI_SDK_SOC_COMMON)/Source/Stubs/newlib
  118. else
  119. # no stubs will be used
  120. endif
  121. ASM_SRCS += $(NUCLEI_SDK_SOC_COMMON)/Source/GCC/startup_ncstar.S \
  122. $(NUCLEI_SDK_SOC_COMMON)/Source/GCC/intexc_ncstar.S
  123. # Add extra board related source files and header files
  124. VALID_NUCLEI_SDK_SOC_BOARD := $(wildcard $(NUCLEI_SDK_SOC_BOARD))
  125. ifneq ($(VALID_NUCLEI_SDK_SOC_BOARD),)
  126. INCDIRS += $(VALID_NUCLEI_SDK_SOC_BOARD)/Include
  127. C_SRCDIRS += $(VALID_NUCLEI_SDK_SOC_BOARD)/Source
  128. endif
  129. 3. If you have setup the source code and build system correctly, then you can test
  130. your SoC using the common applications, e.g.
  131. .. code-block:: shell
  132. # Test helloworld application for ncstar_eval board
  133. ## cd to helloworld application directory
  134. cd application/baremetal/helloworld
  135. ## clean and build helloworld application for ncstar_eval board
  136. make SOC=ncstar BOARD=ncstar_eval clean all
  137. ## connect your board to PC and install jtag driver, open UART terminal
  138. ## set baudrate to 115200bps and then upload the built application
  139. ## to the ncstar_eval board using openocd, and you can check the
  140. ## run messsage in UART terminal
  141. make SOC=ncstar BOARD=ncstar_eval upload
  142. .. note::
  143. * You can always refer to previously supported SoCs for reference,
  144. such as the ``evalsoc`` SoC, we suggest you follow
  145. the ``evalsoc`` implementation, since it is well maintained to support
  146. latest nuclei riscv cpu feature.
  147. * The ``evalsoc`` SoC is a FPGA based evaluation platform, it have
  148. ``ilm`` and ``dlm``, so it support many
  149. :ref:`download modes <develop_buildsystem_var_download>`
  150. * The **nuclei_sdk_soc.h** must be created in SoC include directory, it must
  151. include the device header file <device>.h and SoC firmware library header files.
  152. * The **nuclei_sdk_hal.h** must be created in Board include directory, it must
  153. include **nuclei_sdk_soc.h** and board related header files.
  154. .. _contribute_submit_issue:
  155. Submit your issue
  156. -----------------
  157. If you find any issue related to Nuclei N100 SDK project,
  158. you can open an issue in https://github.com/Nuclei-Software/nuclei-sdk/issues
  159. .. _contribute_submit_pr:
  160. Submit your pull request
  161. ------------------------
  162. If you want to contribute your code to Nuclei N100 SDK project,
  163. you can open an pull request in https://github.com/Nuclei-Software/nuclei-sdk/pulls
  164. Regarding to code style, please refer to :ref:`develop_codestyle`.
  165. .. _contribute_git_guide:
  166. Git commit guide
  167. ----------------
  168. If you want to contribute your code, make sure you follow the guidance
  169. of git commit, see here https://chris.beams.io/posts/git-commit/ for details
  170. * Use the present tense ("Add feature" not "Added feature")
  171. * Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
  172. * Limit the first line to 80 characters or less
  173. * Refer github issues and pull requests liberally using ``#``
  174. * Write the commit message with an category name and colon:
  175. - soc: changes related to soc
  176. - board: changes related to board support packages
  177. - nmsis: changes related to NMSIS
  178. - build: changes releated to build system
  179. - library: changes related to libraries
  180. - rtos: changes related to rtoses
  181. - test: changes related to test cases
  182. - doc: changes related to documentation
  183. - ci: changes related to ci environment
  184. - application: changes related to applications
  185. - misc: changes not categorized
  186. - env: changes related to environment
  187. .. _Quick Porting to you SoC based on Evalsoc in Nuclei N100 SDK: https://doc.nucleisys.com/nuclei_studio_supply/28-quick_porting_from_evalsoc_to_customsoc_based_on_Nuclei_SDK/