buildsystem.rst 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. .. _develop_buildsystem:
  2. Build System based on Makefile
  3. ==============================
  4. Nuclei SDK's build system is based on Makefile, user can build,
  5. run ordebug application in Windows and Linux.
  6. .. _develop_buildsystem_structure:
  7. Makefile Structure
  8. ------------------
  9. Nuclei SDK's Makefiles mainly placed in **<NUCLEI_SDK_ROOT>/Build** directory and
  10. an extra *Makefile* located in **<NUCLEI_SDK_ROOT>/Makefile**.
  11. This extra **<NUCLEI_SDK_ROOT>/Makefile** introduce a new Make variable called
  12. **PROGRAM** to provide the ability to build or run application in **<NUCLEI_SDK_ROOT>**.
  13. For example, if you want to *rebuild and upload* application **application/baremetal/timer_test**,
  14. you can run ``make PROGRAM=application/baremetal/timer_test clean upload`` to achieve it.
  15. The **<NUCLEI_SDK_ROOT>/Build** directory content list as below:
  16. .. code-block:: text
  17. gmsl/
  18. Makefile.base
  19. Makefile.conf
  20. Makefile.core
  21. Makefile.files
  22. Makefile.files.gd32vf103
  23. Makefile.files.hbird
  24. Makefile.global -> Created by user
  25. Makefile.misc
  26. Makefile.rtos
  27. Makefile.rtos.FreeRTOS
  28. Makefile.rtos.UCOSII
  29. Makefile.rtos.RTThread
  30. Makefile.rules
  31. Makefile.soc
  32. Makefile.soc.gd32vf103
  33. Makefile.soc.hbird
  34. The file or directory is used explained as below:
  35. .. _develop_buildsystem_makefile_base:
  36. Makefile.base
  37. ~~~~~~~~~~~~~
  38. This **Makefile.base** file is used as Nuclei SDK build system entry file,
  39. application's Makefile need to include this file to use all the features of
  40. Nuclei SDK build system.
  41. It will expose Make variables or options such as **BOARD** or **SOC** passed
  42. by ``make`` command, click :ref:`develop_buildsystem_exposed_make_vars`
  43. to learn more.
  44. This file will include optional :ref:`develop_buildsystem_makefile_global`
  45. and :ref:`develop_buildsystem_makefile_local` which allow user to set custom
  46. global Makefile configurations and local application Makefile configurations.
  47. This file will include the following makefiles:
  48. * :ref:`develop_buildsystem_gmsl`: additional library functions provided via gmsl
  49. * :ref:`develop_buildsystem_makefile_misc`: misc functions and OS check helpers
  50. * :ref:`develop_buildsystem_makefile_conf`: main Makefile configuration entry
  51. * :ref:`develop_buildsystem_makefile_rules`: make rules of this build system
  52. .. _develop_buildsystem_gmsl:
  53. gmsl
  54. ~~~~
  55. The **gmsl** directory consist of the `GNU Make Standard Library (GMSL)`_,
  56. which is an a library of functions to be used with GNU Make's $(call) that
  57. provides functionality not available in standard GNU Make.
  58. We use this **gmsl** tool to make sure we help us achieve some linux command
  59. which is only supported in Linux.
  60. .. _develop_buildsystem_makefile_misc:
  61. Makefile.misc
  62. ~~~~~~~~~~~~~
  63. This **Makefile.misc** file mainly provide these functions:
  64. * Define **get_csrcs**, **get_asmsrcs**, **get_cxxsrcs** and **check_item_exist** make functions
  65. - **get_csrcs**: Function to get ``*.c or *.C`` source files from a list of directories, no ability to
  66. do recursive match. e.g. ``$(call get_csrcs, csrc csrc/abc)`` will return c source files in
  67. ``csrc`` and ``csrc/abc`` directories.
  68. - **get_asmsrcs**: Function to get ``*.s or *.S`` source files from a list of directories, no ability to
  69. do recursive match. e.g. ``$(call get_asmsrcs, asmsrc asmsrc/abc)`` will return asm source files in
  70. ``asmsrc`` and ``asmsrc/abc`` directories.
  71. - **get_cxxsrcs**: Function to get ``*.cpp or *.CPP`` source files from a list of directories, no ability
  72. to do recursive match. e.g. ``$(call get_cxxsrcs, cppsrc cppsrc/abc)`` will return cpp source files in
  73. ``cppsrc`` and ``cppsrc/abc`` directories.
  74. - **check_item_exist**: Function to check if item existed in a set of items. e.g.
  75. ``$(call check_item_exist, flash, flash ilm flashxip)`` will check ``flash`` whether existed in
  76. ``flash ilm flashxip``, if existed, return ``flash``, otherwise return empty.
  77. * Check and define OS related functions, and also a set of trace print functions.
  78. .. _develop_buildsystem_makefile_conf:
  79. Makefile.conf
  80. ~~~~~~~~~~~~~
  81. This **Makefile.conf** file will define the following items:
  82. * Toolchain related variables used during compiling
  83. * Debug related variables
  84. * Include :ref:`develop_buildsystem_makefile_files` and :ref:`develop_buildsystem_makefile_rtos`
  85. * Collect all the C/C++/ASM compiling and link options
  86. .. _develop_buildsystem_makefile_rules:
  87. Makefile.rules
  88. ~~~~~~~~~~~~~~
  89. This **Makefile.rules** file will do the following things:
  90. * Collect all the sources during compiling
  91. * Define all the rules used for building, uploading and debugging
  92. * Print help message for build system
  93. .. _develop_buildsystem_makefile_files:
  94. Makefile.files
  95. ~~~~~~~~~~~~~~
  96. This **Makefile.files** file will do the following things:
  97. * Define common C/C++/ASM source and include directories
  98. * Define common C/C++/ASM macros
  99. * Include **Makefile.files.<SOC>** which will include all the source
  100. code related to the :ref:`develop_buildsystem_var_soc` and
  101. :ref:`develop_buildsystem_var_board`
  102. - **Makefile.files.gd32vf103**: Used to include source code for
  103. :ref:`design_soc_gd32vf103`
  104. - **Makefile.files.hbird**: Used to include source code for
  105. :ref:`design_soc_hbird`
  106. .. _develop_buildsystem_makefile_soc:
  107. Makefile.soc
  108. ~~~~~~~~~~~~
  109. This **Makefile.soc** will just include **Makefile.soc.<SOC>** according
  110. to the :ref:`develop_buildsystem_var_soc` makefile variable setting.
  111. It will define the following items:
  112. * **DOWNLOAD** and **CORE** variables
  113. - For :ref:`design_soc_hbird`, we can support all the modes defined in
  114. :ref:`develop_buildsystem_var_download`, and **CORE** list defined in
  115. :ref:`develop_buildsystem_makefile_core`
  116. - For :ref:`design_soc_gd32vf103`, The **CORE** is fixed to N205, since
  117. it is a real SoC chip, and only **FlashXIP** download mode is supported
  118. * Linker script used according to the **DOWNLOAD** mode settings
  119. * OpenOCD debug configuration file used for the SoC and Board
  120. * Some extra compiling or debugging options
  121. .. _develop_buildsystem_makefile_rtos:
  122. Makefile.rtos
  123. ~~~~~~~~~~~~~
  124. This **Makefile.rtos** will include **Makefile.rtos.<RTOS>** file
  125. according to our :ref:`develop_buildsystem_var_rtos` variable.
  126. If no :ref:`develop_buildsystem_var_rtos` is chosen, then RTOS
  127. code will not be included during compiling, user will develop
  128. baremetal application.
  129. If **FreeRTOS** or **UCOSII** RTOS is chosen, then FreeRTOS or UCOSII
  130. source code will be included during compiling, and user can develop
  131. RTOS application.
  132. * **Makefile.rtos.FreeRTOS**: Include FreeRTOS related source code and header
  133. directories
  134. * **Makefile.rtos.UCOSII**: Include UCOSII related source code and header
  135. directories
  136. .. _develop_buildsystem_makefile_core:
  137. Makefile.core
  138. ~~~~~~~~~~~~~
  139. This **Makefile.core** is used to define the RISC-V ARCH and ABI used during
  140. compiling of the CORE list supported.
  141. If you want to add a new **CORE**, you need to add a new line before **SUPPORTED_CORES**,
  142. and append the new **CORE** to **SUPPORTED_CORES**.
  143. For example, if you want to add a new **CORE** called **n308**, and the **n308**'s
  144. **ARCH** and **ABI** are ``rv32imafdc`` and ``ilp32d``, then you can add a new line
  145. like this ``N308_CORE_ARCH_ABI = rv32imafdc ilp32d``, and append **n308** to **SUPPORTED_CORES**
  146. like this ``SUPPORTED_CORES = n201 n201e n203 n203e n205 n205e n305 n307 n307fd n308 nx600``
  147. .. note::
  148. * The appended new **CORE** need to lower-case, e.g. *n308*
  149. * The new defined variable **N308_CORE_ARCH_ABI** need to be all upper-case.
  150. .. _develop_buildsystem_makefile_global:
  151. Makefile.global
  152. ~~~~~~~~~~~~~~~
  153. This **Makefile.global** file is an optional file, and will not be tracked by git,
  154. user can create own **Makefile.global** in **<NUCLEI_SDK_ROOT>/Build** directory.
  155. In this file, user can define custom **SOC**, **BOARD**, **DOWNLOAD** options to
  156. overwrite the default configuration.
  157. For example, if you will use only the :ref:`design_board_gd32vf103v_rvstar`, you can
  158. create the **<NUCLEI_SDK_ROOT>/Build/Makefile.global** as below:
  159. .. code-block:: Makefile
  160. SOC ?= gd32vf103
  161. BOARD ?= gd32vf103v_rvstar
  162. DOWNLOAD ?= flashxip
  163. .. note::
  164. * If you add above file, then you can build, run, debug application without passing
  165. **SOC**, **BOARD** and **DOWNLOAD** variables using make command for
  166. :ref:`design_board_gd32vf103v_rvstar` board, e.g.
  167. - Build and run application for :ref:`design_board_gd32vf103v_rvstar`: ``make run``
  168. - Debug application for :ref:`design_board_gd32vf103v_rvstar`: ``make debug``
  169. * The :ref:`design_board_gd32vf103v_rvstar` only support ``FlashXIP`` download mode.
  170. * If you create the **Makefile.global** like above sample code, you will also be able
  171. to use Nuclei SDK build system as usually, it will only change the default **SOC**,
  172. **BOARD** and **DOWNLOAD**, but you can still override the default variable using
  173. make command, such as ``make SOC=hbird BOARD=hbird_eval DOWNLOAD=ilm``
  174. .. _develop_buildsystem_makefile_local:
  175. Makefile.local
  176. ~~~~~~~~~~~~~~
  177. As the :ref:`develop_buildsystem_makefile_global` is used to override the default Makefile
  178. configurations, and the **Makefile.local** is used to override application level Makefile
  179. configurations, and also this file will not be tracked by git.
  180. User can create ``Makefile.local`` file in any of the application folder, placed together with
  181. the application Makefile, for example, you can create ``Makefile.local`` in ``application/baremetal/helloworld``
  182. to override default make configuration for this **helloworld** application.
  183. If you want to change the default board for **helloworld** to use :ref:`design_board_gd32vf103v_rvstar`,
  184. you can create ``application/baremetal/helloworld/Makefile.local`` as below:
  185. .. code-block:: Makefile
  186. SOC ?= gd32vf103
  187. BOARD ?= gd32vf103v_rvstar
  188. DOWNLOAD ?= flashxip
  189. .. note::
  190. * This local make configuration will override global and default make configuration.
  191. * If you just want to change only some applications' makefile configuration, you can
  192. add and update ``Makefile.local`` for those applications.
  193. .. _develop_buildsystem_make_targets:
  194. Makefile targets of make command
  195. --------------------------------
  196. Here is a list of the :ref:`table_dev_buildsystem_4`.
  197. .. _table_dev_buildsystem_4:
  198. .. list-table:: Make targets supported by Nuclei SDK Build System
  199. :widths: 20 80
  200. :header-rows: 1
  201. :align: center
  202. * - target
  203. - description
  204. * - help
  205. - display help message of Nuclei SDK build system
  206. * - info
  207. - display selected configuration information
  208. * - all
  209. - build application with selected configuration
  210. * - clean
  211. - clean application with selected configuration
  212. * - dasm
  213. - build and dissemble application with selected configuration
  214. * - bin
  215. - build and generate application binary with selected configuration
  216. * - upload
  217. - build and upload application with selected configuration
  218. * - run_openocd
  219. - run openocd server with selected configuration
  220. * - run_gdb
  221. - build and start gdb process with selected configuration
  222. * - debug
  223. - build and debug application with selected configuration
  224. .. note::
  225. * The selected configuration is controlled by
  226. :ref:`develop_buildsystem_exposed_make_vars`
  227. * For ``run_openocd`` and ``run_gdb`` target, if you want to
  228. change a new gdb port, you can pass the variable
  229. :ref:`develop_buildsystem_var_gdb_port`
  230. .. _develop_buildsystem_exposed_make_vars:
  231. Makefile variables passed by make command
  232. -----------------------------------------
  233. In Nuclei SDK build system, we exposed the following Makefile variables
  234. which can be passed via make command.
  235. * :ref:`develop_buildsystem_var_soc`
  236. * :ref:`develop_buildsystem_var_board`
  237. * :ref:`develop_buildsystem_var_download`
  238. * :ref:`develop_buildsystem_var_core`
  239. * :ref:`develop_buildsystem_var_simulation`
  240. * :ref:`develop_buildsystem_var_gdb_port`
  241. * :ref:`develop_buildsystem_var_v`
  242. * :ref:`develop_buildsystem_var_silent`
  243. .. note::
  244. * These variables can also be used and defined in application Makefile
  245. * If you just want to fix your running board of your application, you can
  246. just define these variables in application Makefile, if defined, then
  247. you can simply use ``make clean``, ``make upload`` or ``make debug``, etc.
  248. .. _develop_buildsystem_var_soc:
  249. SOC
  250. ~~~
  251. **SOC** variable is used to declare which SoC is used in application during compiling.
  252. You can easily find the supported SoCs in the **<NUCLEI_SDK_ROOT>/SoC** directory.
  253. Currently we support the following SoCs, see :ref:`table_dev_buildsystem_1`.
  254. .. _table_dev_buildsystem_1:
  255. .. list-table:: Supported SoCs
  256. :widths: 10, 60
  257. :header-rows: 1
  258. :align: center
  259. * - **SOC**
  260. - Reference
  261. * - gd32vf103
  262. - :ref:`design_soc_gd32vf103`
  263. * - hbird
  264. - :ref:`design_soc_hbird`
  265. .. _develop_buildsystem_var_board:
  266. BOARD
  267. ~~~~~
  268. **Board** variable is used to declare which Board is used in application during compiling.
  269. The **BOARD** variable should match the supported boards of chosen **SOC**.
  270. You can easily find the supported Boards in the **<NUCLEI_SDK_ROOT>/<SOC>/Board/** directory.
  271. * :ref:`table_dev_buildsystem_2`
  272. * :ref:`table_dev_buildsystem_3`
  273. Currently we support the following SoCs.
  274. .. _table_dev_buildsystem_2:
  275. .. list-table:: Supported Boards when SOC=gd32vf103
  276. :widths: 20, 60
  277. :header-rows: 1
  278. :align: center
  279. * - **BOARD**
  280. - Reference
  281. * - gd32vf103v_rvstar
  282. - :ref:`design_board_gd32vf103v_rvstar`
  283. * - gd32vf103v_eval
  284. - :ref:`design_board_gd32vf103v_eval`
  285. .. _table_dev_buildsystem_3:
  286. .. list-table:: Supported Boards when SOC=hbird
  287. :widths: 10 60
  288. :header-rows: 1
  289. :align: center
  290. * - **BOARD**
  291. - Reference
  292. * - hbird_eval
  293. - :ref:`design_board_hbird_eval`
  294. .. note::
  295. * If you only specify **SOC** variable in make command, it will use default **BOARD**
  296. and **CORE** option defined in Makefile.soc.<SOC>
  297. .. _develop_buildsystem_var_download:
  298. DOWNLOAD
  299. ~~~~~~~~
  300. **DOWNLOAD** variable is used to declare the download mode of the application,
  301. currently it has these modes supported as described in table
  302. :ref:`table_dev_buildsystem_5`
  303. .. _table_dev_buildsystem_5:
  304. .. list-table:: Supported download modes
  305. :widths: 10 70
  306. :header-rows: 1
  307. :align: center
  308. * - **DOWNLOAD**
  309. - Description
  310. * - ilm
  311. - | Program will be download into ilm/ram and
  312. | run directly in ilm/ram, program lost when poweroff
  313. * - flash
  314. - | Program will be download into flash, when running,
  315. | program will be copied to ilm/ram and run in ilm/ram
  316. * - flashxip
  317. - Program will to be download into flash and run directly in Flash
  318. .. note::
  319. * :ref:`design_soc_gd32vf103` only support **DOWNLOAD=flashxip**
  320. * :ref:`design_soc_hbird` support all the download modes.
  321. * **flashxip** mode in :ref:`design_soc_hbird` is very slow due to
  322. the CORE frequency is very slow, and Flash speed is slow
  323. .. _develop_buildsystem_var_core:
  324. CORE
  325. ~~~~
  326. **CORE** variable is used to declare the Nuclei processor core
  327. of the application.
  328. Currently it has these cores supported as described in table
  329. :ref:`table_dev_buildsystem_6`.
  330. .. _table_dev_buildsystem_6:
  331. .. table:: Supported Nuclei Processor cores
  332. :widths: 20 20 20
  333. :align: center
  334. ======== ========== =======
  335. **CORE** **ARCH** **ABI**
  336. n201 rv32iac ilp32
  337. n201e rv32eac ilp32e
  338. n203 rv32imac ilp32
  339. n203e rv32emac ilp32e
  340. n205 rv32imac ilp32
  341. n205e rv32emac ilp32e
  342. n305 rv32imac ilp32
  343. n307 rv32imafc ilp32f
  344. n307fd rv32imafdc ilp32d
  345. n600 rv32imac ilp32
  346. n600f rv32imafc ilp32f
  347. n600fd rv32imafdc ilp32d
  348. nx600 rv64imac lp64
  349. nx600f rv64imafc lp64f
  350. nx600fd rv64imafdc lp64d
  351. ux600 rv64imac lp64
  352. ux600f rv64imafc lp64f
  353. ux600fd rv64imafdc lp64d
  354. ======== ========== =======
  355. .. _develop_buildsystem_var_simulation:
  356. SIMULATION
  357. ~~~~~~~~~~
  358. If **SIMULATION=1**, it means the program is optimized for hardware simulation environment.
  359. Currently if **SIMULATION=1**, it will pass compile option **-DCFG_SIMULATION**,
  360. application can use this **CFG_SIMULATION** to optimize program for hardware
  361. simulation environment.
  362. .. note::
  363. * Currently the benchmark applications in **application/baremetal/benchmark** used this optimization
  364. .. _develop_buildsystem_var_gdb_port:
  365. GDB_PORT
  366. ~~~~~~~~
  367. .. note::
  368. * This new variable **GDB_PORT** is added in Nuclei SDK since version ``0.2.4``
  369. This variable is not used usually, by default the **GDB_PORT** variable is ``3333``.
  370. If you want to change a debug gdb port for openocd and gdb when run ``run_openocd`` and
  371. ``run_gdb`` target, you can pass a new port such as ``3344`` to this variable.
  372. For example, if you want to debug application using run_openocd and
  373. run_gdb and specify a different port other than ``3333``.
  374. You can do it like this, take ``hbird_eval`` board for example, such as port ``3344``:
  375. * Open openocd server: ``make SOC=hbird BOARD=hbird_eval CORE=n307 GDB_PORT=3344 run_openocd``
  376. * connect gdb with openocd server: ``make SOC=hbird BOARD=hbird_eval CORE=n307 GDB_PORT=3344 run_gdb``
  377. .. _develop_buildsystem_var_v:
  378. V
  379. ~
  380. If **V=1**, it will display compiling message in verbose including compiling options.
  381. By default, no compiling options will be displayed in make console message just to print
  382. less message and make the console message cleaner. If you want to see what compiling option
  383. is used, please pass **V=1** in your make command.
  384. .. _develop_buildsystem_var_silent:
  385. SILENT
  386. ~~~~~~
  387. If **SILENT=1**, it will not display any compiling messsage.
  388. If you don't want to see any compiling message, you can pass **SILENT=1** in your make command.
  389. .. _develop_buildsystem_app_make_vars:
  390. Makefile variables used only in Application Makefile
  391. ----------------------------------------------------
  392. The following variables should be used in application Makefile at your demand,
  393. e.g. ``application/baremetal/timer_test/Makefile``.
  394. * :ref:`develop_buildsystem_var_target`
  395. * :ref:`develop_buildsystem_var_nuclei_sdk_root`
  396. * :ref:`develop_buildsystem_var_rtos`
  397. * :ref:`develop_buildsystem_var_pfloat`
  398. * :ref:`develop_buildsystem_var_newlib`
  399. * :ref:`develop_buildsystem_var_nogc`
  400. .. _develop_buildsystem_var_target:
  401. TARGET
  402. ~~~~~~
  403. This is a necessary variable which must be defined in application Makefile.
  404. It is used to set the name of the application, it will affect the generated
  405. target filenames.
  406. .. warning::
  407. * Please don't put any spaces in TARGET variable
  408. * The variable shouldn't contain any space
  409. .. code-block:: Makefile
  410. # invalid case 1
  411. TARGET ?= hello world
  412. # invalid case 2
  413. TARGET ?= helloworld # before this # there is a extra space
  414. .. _develop_buildsystem_var_nuclei_sdk_root:
  415. NUCLEI_SDK_ROOT
  416. ~~~~~~~~~~~~~~~
  417. This is a necessary variable which must be defined in application Makefile.
  418. It is used to set the path of Nuclei SDK Root, usually it should be set as
  419. relative path, but you can also set absolute path to point to Nuclei SDK.
  420. .. _develop_buildsystem_var_rtos:
  421. RTOS
  422. ~~~~
  423. **RTOS** variable is used to choose which RTOS will be used in this application.
  424. You can easily find the supported RTOSes in the **<NUCLEI_SDK_ROOT>/OS** directory.
  425. * If **RTOS** is not defined, then baremetal service will be enabled with this application.
  426. See examples in ``application/baremetal``.
  427. * If **RTOS** is set the the following values, RTOS service will be enabled with this application.
  428. - ``FreeRTOS``: FreeRTOS service will be enabled, you can include FreeRTOS header files now, and
  429. use FreeRTOS API, for ``FreeRTOS`` application, you need to have an ``FreeRTOSConfig.h`` header file
  430. prepared in you application. See examples in ``application/freertos``.
  431. - ``UCOSII``: UCOSII service will be enabled, you can include UCOSII header files now, and
  432. use UCOSII API, for ``UCOSII`` application, you need to have ``app_cfg.h``, ``os_cfg.h``
  433. and ``app_hooks.c`` files prepared in you application. See examples in ``application/ucosii``.
  434. - ``RTThread``: RT-Thread service will be enabled, you can include RT-Thread header files now, and
  435. use RT-Thread API, for ``UCOSII`` application, you need to have an ``rtconfig.h`` header file
  436. prepared in you application. See examples in ``application/rtthread``.
  437. .. _develop_buildsystem_var_pfloat:
  438. PFLOAT
  439. ~~~~~~
  440. **PFLOAT** variable is used to enable floating point value print when using the newlib nano(**NEWLIB=nano**).
  441. If you don't use newlib nano, this variable will have no affect.
  442. .. _develop_buildsystem_var_newlib:
  443. NEWLIB
  444. ~~~~~~
  445. **NEWLIB** variable is used to select which newlib version will be chosen.
  446. If **NEWLIB=nano**, then newlib nano will be selected. About newlib, please
  447. visit https://sourceware.org/newlib/README.
  448. If **NEWLIB=**, then normal newlib will be used.
  449. .. _develop_buildsystem_var_nogc:
  450. NOGC
  451. ~~~~
  452. **NOGC** variable is used to control whether to enable gc sections to reduce program
  453. code size or not, by default GC is enabled to reduce code size.
  454. When GC is enabled, these options will be added:
  455. * Adding to compiler options: ``-ffunction-sections -fdata-sections``
  456. * Adding to linker options: ``-Wl,--gc-sections -Wl,--check-sections``
  457. If you don't want disable this GC feature, you can set **NOGC=1**, GC feature will
  458. remove sections for you, but sometimes it might remove sections that are useful,
  459. e.g. For Nuclei SDK test cases, we use ctest framework, and we need to set **NOGC=1**
  460. to disable GC feature.
  461. .. _develop_buildsystem_app_build_vars:
  462. Build Related Makefile variables used only in Application Makefile
  463. ------------------------------------------------------------------
  464. If you want to specify additional compiler flags, please follow this guidance
  465. to modify your application Makefile.
  466. Nuclei SDK build system defined the following variables to control the
  467. build options or flags.
  468. * :ref:`develop_buildsystem_var_incdirs`
  469. * :ref:`develop_buildsystem_var_c_incdirs`
  470. * :ref:`develop_buildsystem_var_cxx_incdirs`
  471. * :ref:`develop_buildsystem_var_asm_incdirs`
  472. * :ref:`develop_buildsystem_var_srcdirs`
  473. * :ref:`develop_buildsystem_var_c_srcdirs`
  474. * :ref:`develop_buildsystem_var_cxx_srcdirs`
  475. * :ref:`develop_buildsystem_var_asm_srcdirs`
  476. * :ref:`develop_buildsystem_var_c_srcs`
  477. * :ref:`develop_buildsystem_var_cxx_srcs`
  478. * :ref:`develop_buildsystem_var_asm_srcs`
  479. * :ref:`develop_buildsystem_var_common_flags`
  480. * :ref:`develop_buildsystem_var_cflags`
  481. * :ref:`develop_buildsystem_var_cxxflags`
  482. * :ref:`develop_buildsystem_var_asmflags`
  483. * :ref:`develop_buildsystem_var_ldflags`
  484. * :ref:`develop_buildsystem_var_ldlibs`
  485. * :ref:`develop_buildsystem_var_libdirs`
  486. * :ref:`develop_buildsystem_var_linker_script`
  487. .. _develop_buildsystem_var_incdirs:
  488. INCDIRS
  489. ~~~~~~~
  490. This **INCDIRS** is used to pass C/CPP/ASM include directories.
  491. e.g. To include current directory ``.`` and ``inc`` for C/CPP/ASM
  492. .. code-block:: makefile
  493. INCDIRS = . inc
  494. .. _develop_buildsystem_var_c_incdirs:
  495. C_INCDIRS
  496. ~~~~~~~~~
  497. This **C_INCDIRS** is used to pass C only include directories.
  498. e.g. To include current directory ``.`` and ``cinc`` for C only
  499. .. code-block:: makefile
  500. C_INCDIRS = . cinc
  501. .. _develop_buildsystem_var_cxx_incdirs:
  502. CXX_INCDIRS
  503. ~~~~~~~~~~~
  504. This **CXX_INCDIRS** is used to pass CPP only include directories.
  505. e.g. To include current directory ``.`` and ``cppinc`` for CPP only
  506. .. code-block:: makefile
  507. CXX_INCDIRS = . cppinc
  508. .. _develop_buildsystem_var_asm_incdirs:
  509. ASM_INCDIRS
  510. ~~~~~~~~~~~
  511. This **ASM_INCDIRS** is used to pass ASM only include directories.
  512. e.g. To include current directory ``.`` and ``asminc`` for ASM only
  513. .. code-block:: makefile
  514. ASM_INCDIRS = . asminc
  515. .. _develop_buildsystem_var_srcdirs:
  516. SRCDIRS
  517. ~~~~~~~
  518. This **SRCDIRS** is used to set the source directories used to search
  519. the C/CPP/ASM source code files, it will not do recursively.
  520. e.g. To search C/CPP/ASM source files in directory ``.`` and ``src``
  521. .. code-block:: makefile
  522. SRCDIRS = . src
  523. .. _develop_buildsystem_var_c_srcdirs:
  524. C_SRCDIRS
  525. ~~~~~~~~~
  526. This **C_SRCDIRS** is used to set the source directories used to search
  527. the C only source code files(*.c, *.C), it will not do recursively.
  528. e.g. To search C only source files in directory ``.`` and ``csrc``
  529. .. code-block:: makefile
  530. C_SRCDIRS = . csrc
  531. .. _develop_buildsystem_var_cxx_srcdirs:
  532. CXX_SRCDIRS
  533. ~~~~~~~~~~~
  534. This **CXX_SRCDIRS** is used to set the source directories used to search
  535. the CPP only source code files(*.cpp, *.CPP), it will not do recursively.
  536. e.g. To search CPP only source files in directory ``.`` and ``cppsrc``
  537. .. code-block:: makefile
  538. CXX_SRCDIRS = . cppsrc
  539. .. _develop_buildsystem_var_asm_srcdirs:
  540. ASM_SRCDIRS
  541. ~~~~~~~~~~~
  542. This **ASM_SRCDIRS** is used to set the source directories used to search
  543. the ASM only source code files(*.s, *.S), it will not do recursively.
  544. e.g. To search ASM only source files in directory ``.`` and ``asmsrc``
  545. .. code-block:: makefile
  546. ASM_SRCDIRS = . asmsrc
  547. .. _develop_buildsystem_var_c_srcs:
  548. C_SRCS
  549. ~~~~~~
  550. If you just want to include a few of C source files in directories, you can use this
  551. **C_SRCS** variable.
  552. e.g. To include ``main.c`` and ``src/hello.c``
  553. .. code-block:: makefile
  554. C_SRCS = main.c src/hello.c
  555. .. _develop_buildsystem_var_cxx_srcs:
  556. CXX_SRCS
  557. ~~~~~~~~
  558. If you just want to include a few of CPP source files in directories, you can use this
  559. **CXX_SRCS** variable.
  560. e.g. To include ``main.cpp`` and ``src/hello.cpp``
  561. .. code-block:: makefile
  562. CXX_SRCS = main.cpp src/hello.cpp
  563. .. _develop_buildsystem_var_asm_srcs:
  564. ASM_SRCS
  565. ~~~~~~~~
  566. If you just want to include a few of ASM source files in directories, you can use this
  567. **ASM_SRCS** variable.
  568. e.g. To include ``asm.s`` and ``src/test.s``
  569. .. code-block:: makefile
  570. ASM_SRCS = asm.s src/test.s
  571. .. _develop_buildsystem_var_common_flags:
  572. COMMON_FLAGS
  573. ~~~~~~~~~~~~
  574. This **COMMON_FLAGS** variable is used to define common compiler flags to all c/asm/cpp compiler.
  575. For example, you can add a newline ``COMMON_FLAGS += -O3 -funroll-loops -fpeel-loops``
  576. in your application Makefile and these options will be passed to C/ASM/CPP compiler.
  577. .. _develop_buildsystem_var_cflags:
  578. CFLAGS
  579. ~~~~~~
  580. Different to **COMMON_FLAGS**, this **CFLAGS** variable is used to define common compiler flags to C compiler only.
  581. For example, you can add a newline ``CFLAGS += -O3 -funroll-loops -fpeel-loops``
  582. in your application Makefile and these options will be passed to C compiler.
  583. .. _develop_buildsystem_var_cxxflags:
  584. CXXFLAGS
  585. ~~~~~~~~
  586. Different to **COMMON_FLAGS**, this **CXXFLAGS** variable is used to define common compiler flags to cpp compiler only.
  587. For example, you can add a newline ``CXXFLAGS += -O3 -funroll-loops -fpeel-loops``
  588. in your application Makefile and these options will be passed to cpp compiler.
  589. .. _develop_buildsystem_var_asmflags:
  590. ASMFLAGS
  591. ~~~~~~~~
  592. Different to **COMMON_FLAGS**, this **ASMFLAGS** variable is used to define common compiler flags to asm compiler only.
  593. For example, you can add a newline ``ASMFLAGS += -O3 -funroll-loops -fpeel-loops``
  594. in your application Makefile and these options will be passed to asm compiler.
  595. .. _develop_buildsystem_var_ldflags:
  596. LDFLAGS
  597. ~~~~~~~
  598. This **LDFLAGS** is used to pass extra linker flags, for example,
  599. if you want to link extra math library, you can add a newline
  600. ``LDFLAGS += -lm`` in you application Makefile.
  601. Libraries (-lfoo) could also be added to the LDLIBS variable instead.
  602. .. _develop_buildsystem_var_ldlibs:
  603. LDLIBS
  604. ~~~~~~
  605. This **LDLIBS** variable is library flags or names given to compilers
  606. when they are supposed to invoke the linker.
  607. Non-library linker flags, such as -L, should go in the **LDFLAGS** variable.
  608. .. _develop_buildsystem_var_libdirs:
  609. LIBDIRS
  610. ~~~~~~~
  611. This **LIBDIRS** variable is used to store the library directories, which could
  612. be used together with **LDLIBS**.
  613. For example, if you have a library located in **$(NUCLEI_SDK_ROOT)/Library/DSP/libnmsis_dsp_rv32imac.a**,
  614. and you want to link it, then you can define these lines:
  615. .. code-block:: makefile
  616. LDLIBS = -lnmsis_dsp_rv32imac
  617. LIBDIRS = $(NUCLEI_SDK_ROOT)/Library/DSP
  618. .. _develop_buildsystem_var_linker_script:
  619. LINKER_SCRIPT
  620. ~~~~~~~~~~~~~
  621. This **LINKER_SCRIPT** variable could be used to set the link script of the application.
  622. By default, there is no need to set this variable, since the build system will define
  623. a default linker script for application according to the build configuration. If you want
  624. to define your own linker script, you can set this variable.
  625. For example, ``LINKER_SCRIPT := gcc.ld``.
  626. .. _GNU Make Standard Library (GMSL): http://sourceforge.net/projects/gmsl/