README.txt 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  1. tools/README.txt
  2. ================
  3. This README file addresses the contents of the NuttX tools/ directory.
  4. The tools/ directory contains miscellaneous scripts and host C programs
  5. that are necessary parts of the NuttX build system. These files
  6. include:
  7. cmpconfig.c
  8. -----------
  9. This C file can be used to build a utility for comparing two NuttX
  10. configuration files.
  11. Config.mk
  12. ---------
  13. Config.mk contains common definitions used by many configuration files.
  14. This file (along with <nuttx>/.config) must be included at the top of
  15. each configuration-specific Make.defs file like:
  16. include $(TOPDIR)/.config
  17. include $(TOPDIR)/tools/Config.mk
  18. Subsequent logic within the configuration-specific Make.defs file may then
  19. override these default definitions as necessary.
  20. checkpatch.sh
  21. -------------
  22. checkpatch.sh is a bash script that make use of nxstyle and codespell tools
  23. to format patches and files conform to NuttX coding standard. For example,
  24. it has been used in NuttX github action PR check build.
  25. $ tools/checkpatch.sh -h
  26. USAGE: ./tools/checkpatch.sh [options] [list|-]
  27. Options:
  28. -h
  29. -c spell check with codespell(install with: pip install codespell)
  30. -r range check only (coupled with -p or -g)
  31. -p <patch list> (default)
  32. -g <commit list>
  33. -f <file list>
  34. - read standard input mainly used by git pre-commit hook as below:
  35. git diff --cached | ./tools/checkpatch.sh -
  36. Where a <commit list> is any syntax supported by git for specifying git revision, see GITREVISIONS(7)
  37. Where a <patch file names> is a space separated list of patch file names or wildcard. or *.patch
  38. configure.sh
  39. configure.bat
  40. configure.c, cfgparser.c, and cfgparser.h
  41. ------------
  42. configure.sh is a bash script that is used to configure NuttX for a given
  43. target board in a environment that supports POSIX paths (Linux, Cygwin,
  44. macOS, or similar). See boards/README.txt or Documentation/NuttXPortingGuide.html
  45. for a description of how to configure NuttX with this script.
  46. configure.c, cfgparser.c, and cfgparser.h can be used to build a work-alike
  47. program as a replacement for configure.sh. This work-alike program would be
  48. used in environments that do not support Bash scripting (such as the Windows
  49. native environment).
  50. configure.bat is a small Windows batch file that can be used as a replacement
  51. for configure.sh in a Windows native environment. configure.bat is actually
  52. just a thin layer that executes configure.exe if it is available. If
  53. configure.exe is not available, then configure.bat will attempt to build it
  54. first.
  55. In order to build configure.exe from configure.c in the Windows native
  56. environment, two assumptions are made:
  57. 1) You have installed the MinGW GCC toolchain. This toolchain can be
  58. downloaded from http://www.mingw.org/. It is recommended that you not
  59. install the optional MSYS components as there may be conflicts.
  60. 2) That path to the bin/ directory containing mingw-gcc.exe must be
  61. included in the PATH variable.
  62. convert-comments.c
  63. ------------------
  64. Convert C++-style comments to C89 C-style comments. Usage:
  65. convert-comments <source-file> <out-file>
  66. detab.c
  67. -------
  68. Convert tabs to spaces in a file. Usage:
  69. detab [-4] <source-file> <out-file>
  70. Default <source-file> tab size is 8 spaces; -4 selects 4 space tab size.
  71. discover.py
  72. -----------
  73. Example script for discovering devices in the local network.
  74. It is the counter part to apps/netutils/discover
  75. gencromfs.c
  76. -----------
  77. This is a C program that is used to generate CROMFS file system images.
  78. Usage is simple:
  79. gencromfs <dir-path> <out-file>
  80. Where:
  81. <dir-path> is the path to the directory will be at the root of the
  82. new CROMFS file system image.
  83. <out-file> the name of the generated, output C file. This file must
  84. be compiled in order to generate the binary CROMFS file system
  85. image.
  86. initialconfig.c
  87. ---------------
  88. This is a C file that can be used to create an initial configuration.
  89. This permits creating a new configuration from scratch, without
  90. relying on any existing board configuration in place. This utility
  91. will create a barebones .config file sufficient only for
  92. instantiating the symbolic links necessary to do a real configuration.
  93. kconfig2html.c
  94. --------------
  95. This is a C file that can be used to build a utility for converting the
  96. NuttX configuration in the Kconfig files to an HTML document. This
  97. auto-generated documentation will, eventually, replace the manually
  98. updated configuration documentation that is falling woefully behind.
  99. $ tools/kconfig2html.exe -h
  100. USAGE: tools/kconfig2html [-d] [-a <apps directory>] {-o <out file>] [<Kconfig root>]
  101. tools/kconfig2html [-h]
  102. Where:
  103. -a : Select relative path to the apps/ directory. This path is relative
  104. to the <Kconfig directory>. Default: ../apps
  105. -o : Send output to <out file>. Default: Output goes to stdout
  106. -d : Enable debug output
  107. -h : Prints this message and exits
  108. <Kconfig root> is the directory containing the root Kconfig file.
  109. Default <Kconfig directory>: .
  110. NOTE: In order to use this tool, some configuration must be in-place with
  111. all necessary symbolic links. You can establish the configured symbolic
  112. links with:
  113. make context
  114. or more quickly with:
  115. make dirlinks
  116. Libraries.mk, FlatLibs.mk, ProtectedLibs.mk, and KernelLib.mk
  117. -------------------------------------------------------------
  118. Libraries.mk has the build rules for all NuttX libraries.
  119. FlatLibs.mk, ProtectedLibs.mk, and KernelLib.mk: These control the
  120. selection of libraries to be built, depending on the selected build mode.
  121. lowhex.c
  122. --------
  123. Convert hexadecimal representation in a file from upper- to lower-case.
  124. Usage:
  125. lowhex <source-file> <out-file>
  126. Makefile.[unix|win]
  127. -----------------
  128. Makefile.unix is the Makefile used when building NuttX in Unix-like
  129. systems. It is selected from the top-level Makefile.
  130. Makefile.win is the Makefile used when building natively under
  131. Windows. It is selected from the top-level Makefile.
  132. mkconfig.c, cfgdefine.c, and cfgdefine.h
  133. ----------------------------------------
  134. These are C files that are used to build mkconfig program. The mkconfig
  135. program is used during the initial NuttX build.
  136. When you configure NuttX, you will copy a configuration file called .config
  137. in the top level NuttX directory (See boards/README.txt or
  138. Documentation/NuttXPortingGuide.html). The first time you make NuttX,
  139. the top-level makefile will build the mkconfig executable from mkconfig.c
  140. (using Makefile.host). The top-level Makefile will then execute the
  141. mkconfig program to convert the .config file in the top level directory
  142. into include/nuttx/config.h. config.h is a another version of the
  143. NuttX configuration that can be included by C files.
  144. mkconfigvars.sh
  145. ---------------
  146. The HTML documentation expects to have a copy of the auto-generated
  147. configuration variable documentation Documentation/NuttXConfigVariables.html.
  148. The script mkconfigvars.sh is a simple script that can be used to
  149. re-generated that file as needed.
  150. $ tools/mkconfigvars.sh -h
  151. tools/mkconfigvars.sh is a tool for generation of configuration variable documentation
  152. USAGE: tools/mkconfigvars.sh [-d|h] [-v <major.minor.patch>]
  153. Where:
  154. -v <major.minor.patch>
  155. The NuttX version number expressed as a major, minor and patch number separated
  156. by a period
  157. -d
  158. Enable script debug
  159. -h
  160. show this help message and exit
  161. mkexport.sh and Makefile.export
  162. -------------------------------
  163. These implement part of the top-level Makefile's 'export' target. That
  164. target will bundle up all of the NuttX libraries, header files, and the
  165. startup object into an export-able, binary NuttX distribution. The
  166. Makefile.export is used only by the mkexport.sh script to parse out
  167. options from the top-level Make.defs file.
  168. USAGE: tools/mkexport.sh [-d] [-z] [-u] -t <top-dir> [-x <lib-ext>] -l "lib1 [lib2 [lib3 ...]]"
  169. This script also depends on the environment variable MAKE which is set
  170. in the top-level Makefile before starting mkexport.sh. If MAKE is not
  171. defined, the script will set it to `which make`.
  172. mkfsdata.pl
  173. -----------
  174. This perl script is used to build the "fake" file system and CGI support
  175. as needed for the apps/netutils/webserver. It is currently used only
  176. by the Makefile at apps/examples/uip. That example serves as an example
  177. of how to configure the uIP webserver "fake" file system.
  178. NOTE: This perl script comes from uIP and was (probably) written
  179. by Adam Dunkels. uIP has a license that is compatible with NuttX.
  180. mkversion.c, cfgdefine.c, and cfgdefine.h
  181. -----------------------------------------
  182. This is C file that is used to build mkversion program. The mkversion
  183. program is used during the initial NuttX build.
  184. When you build NuttX there should be a version file called .version in
  185. the top level NuttX directory (See Documentation/NuttXPortingGuide.html).
  186. The first time you make NuttX, the top-level makefile will build the
  187. mkversion executable from mkversion.c (using Makefile.host). The top-
  188. level Makefile will then execute the mkversion program to convert the
  189. .version file in the top level directory into include/nuttx/version.h.
  190. version.h provides version information that can be included by C files.
  191. mksyscall.c, cvsparser.c, and cvsparser.h
  192. -----------------------------------------
  193. This is a C file that is used to build mksyscall program. The mksyscall
  194. program is used during the initial NuttX build by the logic in the top-
  195. level syscall/ directory.
  196. If you build NuttX as a separately compiled, monolithic kernel and separate
  197. applications, then there is a syscall layer that is used to get from the
  198. user application space to the NuttX kernel space. In the user application
  199. "proxies" for each of the kernel functions are provided. The proxies have
  200. the same function signature as the kernel function, but only execute a
  201. system call.
  202. Within the kernel, there are "stubs" for each of the system calls. The
  203. stubs receive the marshalled system call data, and perform the actually
  204. kernel function call (in kernel-mode) on behalf of the proxy function.
  205. Information about the stubs and proxies is maintained in a comma separated
  206. value (CSV) file in the syscall/ directory. The mksyscall program will
  207. accept this CVS file as input and generate all of the required proxy or
  208. stub files as output. See syscall/README.txt for additional information.
  209. mksymtab.c, cvsparser.c, and cvsparser.h
  210. ----------------------------------------
  211. This is a C file that is used to build symbol tables from comma separated
  212. value (CSV) files. This tool is not used during the NuttX build, but
  213. can be used as needed to generate files.
  214. USAGE: ./mksymtab [-d] <cvs-file> <symtab-file> [<symtab-name> [<nsymbols-name>]]
  215. Where:
  216. <cvs-file> : The path to the input CSV file (required)
  217. <symtab-file> : The path to the output symbol table file (required)
  218. <symtab-name> : Optional name for the symbol table variable
  219. Default: "g_symtab"
  220. <nsymbols-name> : Optional name for the symbol table variable
  221. Default: "g_nsymbols"
  222. -d : Enable debug output
  223. Example:
  224. cd nuttx/tools
  225. cat ../syscall/syscall.csv ../lib/libc.csv | sort >tmp.csv
  226. ./mksymtab.exe tmp.csv tmp.c
  227. mkctags.sh
  228. ----------
  229. A script for creating ctags from Ken Pettit. See http://en.wikipedia.org/wiki/Ctags
  230. and http://ctags.sourceforge.net/
  231. nxstyle.c
  232. ---------
  233. I am embarrassed that this is here. This program is a complete hack
  234. but, unfortunately, it has become so useful to me that I need to keep
  235. it here.
  236. A little background: I have tinkered with pretty printers for some
  237. time and have not been happy with the results. An alternative that
  238. occurred to me would be just a standard checker that examines a C
  239. file that gives warnings for violations of the coding standard.
  240. This turns out to be more difficult that you might think. A pretty
  241. printer understands C syntax: They break the file up into its C
  242. components then reassembles the output in the format. But parsing the
  243. C loses the original file layout and so it not useful in this case.
  244. This program instead, uses a collection of heuristics (i.e., hacks and
  245. bandaids) to examine the C file for obvious violations of the coding
  246. standard. This program is completely ignorant of C syntax; it simply
  247. performs crude pattern matching to check the file.
  248. Prints formatted messages that are classified as info, warn, error,
  249. fatal. In a parsable format that can be used by editors and IDEs.
  250. Usage: nxstyle [-m <excess>] [-v <level>] [-r <start,count>] <filename>
  251. nxstyle -h this help
  252. nxstyle -v <level> where level is
  253. 0 - no output
  254. 1 - PASS/FAIL
  255. 2 - output each line (default)
  256. See also indent.sh and uncrustify.cfg
  257. pic32mx
  258. -------
  259. This directory contains build tools used only for PIC32MX/Z platforms
  260. bdf-convert.c
  261. -------------
  262. This C file is used to build the bdf-converter program. The bdf-converter
  263. program can be used to convert fonts in Bitmap Distribution Format (BDF)
  264. into fonts that can be used in the NX graphics system.
  265. Below are general instructions for creating and installing a new font
  266. in the NX graphic system:
  267. 1. Locate a font in BDF format,
  268. 2. Use the bdf-converter program to convert the BDF font to the NuttX
  269. font format. This will result in a C header file containing
  270. definitions. That header file should be installed at, for example,
  271. libnx/nxfonts/nxfonts_myfont.h.
  272. Create a new NuttX configuration variable. For example, suppose
  273. you define the following variable: CONFIG_NXFONT_MYFONT. Then
  274. you would need to:
  275. 3. Define CONFIG_NXFONT_MYFONT=y in your NuttX configuration file.
  276. A font ID number has to be assigned for each new font. The font ID
  277. is defined in the file include/nuttx/nx/nxfonts.h. Those definitions
  278. have to be extended to support your new font. Look at how the font ID
  279. enabled by CONFIG_NXFONT_SANS23X27 is defined and add an ID for your
  280. new font in a similar fashion:
  281. 4. include/nuttx/nx/nxfonts.h. Add your new font as a possible system
  282. default font:
  283. #if defined(CONFIG_NXFONT_SANS23X27)
  284. # define NXFONT_DEFAULT FONTID_SANS23X27
  285. #elif defined(CONFIG_NXFONT_MYFONT)
  286. # define NXFONT_DEFAULT FONTID_MYFONT
  287. #endif
  288. Then define the actual font ID. Make sure that the font ID value
  289. is unique:
  290. enum nx_fontid_e
  291. {
  292. FONTID_DEFAULT = 0 /* The default font */
  293. #ifdef CONFIG_NXFONT_SANS23X27
  294. , FONTID_SANS23X27 = 1 /* The 23x27 sans serif font */
  295. #endif
  296. #ifdef CONFIG_NXFONT_MYFONT
  297. , FONTID_MYFONT = 2 /* My shiny, new font */
  298. #endif
  299. ...
  300. Now add the font to the NX build system. There are several files that
  301. you have to modify to do this. Look how the build system uses the
  302. font CONFIG_NXFONT_SANS23X27 for examples:
  303. 5. nuttx/graphics/Makefile. This file needs logic to auto-generate
  304. a C source file from the header file that you generated with the
  305. the bdf-converter program. Notice NXFONTS_FONTID=2; this must be
  306. set to the same font ID value that you defined in the
  307. include/nuttx/nx/nxfonts.h file.
  308. genfontsources:
  309. ifeq ($(CONFIG_NXFONT_SANS23X27),y)
  310. @$(MAKE) -C nxfonts -f Makefile.sources NXFONTS_FONTID=1 EXTRAFLAGS=$(EXTRAFLAGS)
  311. endif
  312. ifeq ($(CONFIG_NXFONT_MYFONT),y)
  313. @$(MAKE) -C nxfonts -f Makefile.sources NXFONTS_FONTID=2 EXTRAFLAGS=$(EXTRAFLAGS)
  314. endif
  315. 6. nuttx/libnx/nxfonts/Make.defs. Set the make variable NXFSET_CSRCS.
  316. NXFSET_CSRCS determines the name of the font C file to build when
  317. NXFONTS_FONTID=2:
  318. ifeq ($(CONFIG_NXFONT_SANS23X27),y)
  319. NXFSET_CSRCS += nxfonts_bitmaps_sans23x27.c
  320. endif
  321. ifeq ($(CONFIG_NXFONT_MYFONT),y)
  322. NXFSET_CSRCS += nxfonts_bitmaps_myfont.c
  323. endif
  324. 7. nuttx/libnx/nxfonts/Makefile.sources. This is the Makefile used
  325. in step 5 that will actually generate the font C file. So, given
  326. your NXFONTS_FONTID=2, it needs to determine a prefix to use for
  327. auto-generated variable and function names and (again) the name of
  328. the auto-generated file to create (this must be the same name that
  329. was used in nuttx/libnx/nxfonts/Make.defs):
  330. ifeq ($(NXFONTS_FONTID),1)
  331. NXFONTS_PREFIX := g_sans23x27_
  332. GEN_CSRC = nxfonts_bitmaps_sans23x27.c
  333. endif
  334. ifeq ($(NXFONTS_FONTID),2)
  335. NXFONTS_PREFIX := g_myfont_
  336. GEN_CSRC = nxfonts_bitmaps_myfont.c
  337. endif
  338. 8. graphics/libnx/nxfonts_bitmaps.c. This is the file that contains
  339. the generic font structures. It is used as a "template" file by
  340. nuttx/libnx/nxfonts/Makefile.sources to create your customized
  341. font data set.
  342. #if NXFONTS_FONTID == 1
  343. # include "nxfonts_sans23x27.h"
  344. #elif NXFONTS_FONTID == 2
  345. # include "nxfonts_myfont.h"
  346. #else
  347. # error "No font ID specified"
  348. #endif
  349. Where nxfonts_myfont.h is the NuttX font file that we generated in
  350. step 2 using the bdf-converter tool.
  351. 9. libnx/nxfonts/nxfonts_getfont.c. Finally, we need to extend the
  352. logic that does the run-time font lookups so that can find our new
  353. font. The lookup function is NXHANDLE nxf_getfonthandle(enum nx_fontid_e fontid).
  354. The new font information needs to be added to data structures used by
  355. that function:
  356. #ifdef CONFIG_NXFONT_SANS23X27
  357. extern const struct nx_fontpackage_s g_sans23x27_package;
  358. #endif
  359. #ifdef CONFIG_NXFONT_MYFONT
  360. extern const struct nx_fontpackage_s g_myfont_package;
  361. #endif
  362. static FAR const struct nx_fontpackage_s *g_fontpackages[] =
  363. {
  364. #ifdef CONFIG_NXFONT_SANS23X27
  365. &g_sans23x27_package,
  366. #endif
  367. #ifdef CONFIG_NXFONT_MYFONT
  368. &g_myfont_package,
  369. #endif
  370. NULL
  371. };
  372. define.sh and define.bat
  373. ------------------------
  374. Different compilers have different conventions for specifying pre-
  375. processor definitions on the compiler command line. This bash
  376. script allows the build system to create command line definitions
  377. without concern for the particular compiler in use.
  378. The define.bat script is a counterpart for use in the native Windows
  379. build.
  380. flash_writer.py
  381. ---------------
  382. This flash writer is using the xmodem for firmware transfer on
  383. boards based on cxd56 chip (Ex. Spresense). This tool depends on
  384. the xmodem package (https://pypi.org/project/xmodem/).
  385. for flashing the .spk image to the board please use:
  386. tools/flash_writer.py -s -c /dev/ttyUSB0 -d -b 115200 -n nuttx.spk
  387. ide_exporter.py
  388. ---------------
  389. This Python script will help to create NuttX project in the IAR and
  390. uVision IDEs. These are few simple the steps to export the IDE
  391. workspaces.
  392. 1) Start the NuttX build from the Cygwin command line before trying to
  393. create your project by running:
  394. make V=1 |& tee build_log
  395. This is necessary to certain auto-generated files and directories that
  396. will be needed. This will provide the build log to construct the IDE
  397. project also.
  398. 2) Export the IDE project base on that make log. The script usage:
  399. usage: ide_exporter.py [-h] [-v] [-o OUT_DIR] [-d] build_log {iar,uvision_armcc,uvision_gcc} template_dir
  400. positional arguments:
  401. build_log Log file from make V=1
  402. {iar,uvision_armcc,uvision_gcc}
  403. The target IDE: iar, uvision_gcc, (uvision_armcc is experimental)
  404. template_dir Directory that contains IDEs template projects
  405. optional arguments:
  406. -h, --help show this help message and exit
  407. -v, --version show program's version number and exit
  408. -o OUT_DIR, --output OUT_DIR
  409. Output directory
  410. -d, --dump Dump project structure tree
  411. Example:
  412. cd nuttx
  413. make V=1 |& tee build_log
  414. ./tools/ide_exporter.py makelog_f2nsh_c iar ./boards/<arch>/<chip>/<board>/ide/template/iar -o ./boards/<arch>/<chip>/<board>/ide/nsh/iar
  415. or
  416. ./tools/ide_exporter.py makelog_f2nsh_c uvision_gcc ./boards/<arch>/<chip>/<board>/ide/template/uvision_gcc/ -o ./boards/<arch>/<chip>/<board>/ide/nsh/uvision
  417. 3) Limitations:
  418. - IAR supports C only. Iar C++ does not compatible with g++ so disable
  419. C++ if you want to use IAR.
  420. - uvision_armcc : nuttx asm (inline and .asm) can't be compiled with
  421. armcc so do not use this option.
  422. - uvision_gcc : uvision project that uses gcc. Need to specify path to
  423. gnu toolchain.
  424. In uVison menu, select:
  425. Project/Manage/Project Items.../FolderExtension/Use GCC compiler/ PreFix, Folder
  426. 4) Template projects' constrains:
  427. - mcu, core, link script shall be configured in template project
  428. - Templates' name are fixed:
  429. - template_nuttx.eww : IAR nuttx workspace template
  430. - template_nuttx_lib.ewp : IAR nuttx library project template
  431. - template_nuttx_main.ewp : IAR nuttx main project template
  432. - template_nuttx.uvmpw : uVision workspace
  433. - template_nuttx_lib.uvproj : uVision library project
  434. - template_nuttx_main.uvproj : uVision main project
  435. - iar:
  436. - Library option shall be set to 'None' so that IAR could use nuttx
  437. libc
  438. - __ASSEMBLY__ symbol shall be defined in assembler
  439. - uVision_gcc:
  440. - There should be one fake .S file in projects that has been defined
  441. __ASSEMBLY__ in assembler.
  442. - In Option/CC tab : disable warning
  443. - In Option/CC tab : select Compile thump code (or Misc control =
  444. -mthumb)
  445. - template_nuttx_lib.uvproj shall add 'Post build action' to copy .a
  446. file to .\lib
  447. - template_nuttx_main.uvproj Linker:
  448. - Select 'Do not use Standard System Startup Files' and 'Do not
  449. use Standard System Libraries'
  450. - Do not select 'Use Math libraries'
  451. - Misc control = --entry=__start
  452. 5) How to create template for other configurations:
  453. 1) uVision with gcc toolchain:
  454. - Copy 3 uVision project files
  455. - Select the MCU for main and lib project
  456. - Correct the path to ld script if needed
  457. 2) iar:
  458. - Check if the arch supports IAR (only armv7-m is support IAR
  459. now)
  460. - Select the MCU for main and lib project
  461. - Add new ld script file for IAR
  462. NOTE: Due to bit rot, the template files for the stm3220g-eval and for
  463. the stm32f429-disco have been removed from the NuttX repository. For
  464. reference, they can be found in the Obsoleted repository at
  465. Obsoleted/stm32f429i_disco/ltcd/template and at
  466. Obsoleted/stm3220g-eval/template.
  467. incdir.sh, incdir.bat, and incdir.c
  468. -----------------------------------
  469. Different compilers have different conventions for specifying lists
  470. of include file paths on the compiler command line. This incdir.sh
  471. bash script allows the build system to create include file paths without
  472. concern for the particular compiler in use.
  473. The incdir.bat script is a counterpart for use in the native Windows
  474. build. However, there is currently only one compiler supported in
  475. that context: MinGW-GCC.
  476. incdir.c is a higher performance version of incdir.sh, converted to C.
  477. indent.sh
  478. ---------
  479. This script can be used to indent .c and .h files in a manner similar
  480. to the NuttX coding style. It doesn't do a really good job, however
  481. (see below and the comments at the top of the indent.sh file).
  482. USAGE:
  483. tools/indent.sh [-d] [-p] -o <out-file> <in-file>
  484. tools/indent.sh [-d] [-p] <in-file-list>
  485. tools/indent.sh [-d] -h
  486. Where:
  487. -<in-file>
  488. A single, unformatted input file
  489. -<in-file-list>
  490. A list of unformatted input files that will be reformatted in place.
  491. -o <out-file>
  492. Write the single, reformatted <in-file> to <out-file>. <in-file>
  493. will not be modified.
  494. -d
  495. Enable script debug
  496. -p
  497. Comments are pre-formatted. Do not reformat.
  498. -h
  499. Show this help message and exit
  500. The conversions make by the indent.sh script differs from the NuttX coding
  501. style in that:
  502. 1. The coding standard requires that the trailing */ of a multi-line
  503. comment be on a separate line. By default, indent.sh will put the
  504. final */ on the same line as the last comment text. If your C file
  505. already has properly formatted comments then using the -p option will
  506. eliminate that bad behavior
  507. 2. If your source file has highly formatted comments containing things
  508. such as tables or lists, then use the -p option to preserve those
  509. pre-formatted comments.
  510. 3. I usually align things vertically (like '=' in assignments),
  511. 4. indent.sh puts a bogus blank line at the top of the file,
  512. 5. I don't like the way it handles nested conditional compilation
  513. intermixed with code. I prefer the preprocessor conditional tests
  514. be all right justified in that case.
  515. 6. I also indent brackets differently on structures than does this script.
  516. 7. I normally use no spaces in casts. indent.sh adds spaces in casts like
  517. "(FAR void *)&foo" becomes "(FAR void *) & foo".
  518. 8. When used with header files, the initial idempotence conditional test
  519. causes all preprocessor directives to be indented in the file. So for
  520. header files, you will need to substitute "^# " with "#" in the
  521. converted header file.
  522. You will manually need to check for the issues listed above after
  523. performing the conversions. nxstyle.c provides a good test that will
  524. catch most of the indent.sh screw-ups. Together, they do a pretty good
  525. job of formatting.
  526. See also nxstyle.c and uncrustify.cfg
  527. kconfig.bat
  528. -----------
  529. Recent versions of NuttX support building NuttX from a native Windows
  530. CMD.exe shell. But kconfig-frontends is a Linux tool and is not yet
  531. available in the pure CMD.exe environment. At this point, there are
  532. only a few options for the Windows user (see the top-level README.txt
  533. file).
  534. You can, with some effort, run the Cygwin kconfig-mconf tool directly
  535. in the CMD.exe shell. In this case, you do not have to modify the
  536. .config file, but there are other complexities: You need to
  537. temporarily set the Cygwin directories in the PATH variable and
  538. then run kconfig-mconf outside of the Make system.
  539. kconfig.bat is a Windows batch file at tools/kconfig.bat that automates
  540. these steps. It is used from the top-level NuttX directory like:
  541. tools/kconfig menuconfig
  542. NOTE: There is currently an issue with accessing DOS environment
  543. variables from the Cygwin kconfig-mconf running in the CMD.exe shell.
  544. The following change to the top-level Kconfig file seems to work around
  545. these problems:
  546. config APPSDIR
  547. string
  548. - option env="APPSDIR"
  549. + default "../apps"
  550. link.sh, link.bat, copydir.sh, copydir.bat, unlink.sh, and unlink.bat
  551. ---------------------------------------------------------------------
  552. Different file systems have different capabilities for symbolic links.
  553. Some Windows file systems have no native support for symbolic links.
  554. Cygwin running under Windows has special links built in that work with
  555. all cygwin tools. However, they do not work when Windows native tools
  556. are used with cygwin. In that case something different must be done.
  557. If you are building under Linux or under cygwin with a cygwin tool
  558. chain, then your Make.defs file may have definitions like the
  559. following:
  560. DIRLINK = $(TOPDIR)/tools/link.sh
  561. DIRUNLINK = (TOPDIR)/tools/unlink.sh
  562. The first definition is not always present because link.sh is the
  563. default. link.sh is a bash script that performs a normal, Linux-style
  564. symbolic link; unlink.sh is a do-it-all unlinking script.
  565. But if you are building under cygwin using a Windows native toolchain
  566. within a POSIX framework (such as Cygwin), then you will need something
  567. like the following in you Make.defs file:
  568. DIRLINK = $(TOPDIR)/tools/copydir.sh
  569. DIRUNLINK = (TOPDIR)/tools/unlink.sh
  570. copydir.sh will copy the whole directory instead of linking it.
  571. Finally, if you are running in a pure native Windows environment with
  572. a CMD.exe shell, then you will need something like this:
  573. DIRLINK = $(TOPDIR)/tools/copydir.bat
  574. DIRUNLINK = (TOPDIR)/tools/unlink.bat
  575. Note that this will copy directories. link.bat might also be used in
  576. this case. link.bat will attempt to create a symbolic link using the
  577. NTFS mklink.exe command instead of copying files. That logic, however,
  578. has not been verified as of this writing.
  579. Makefile.host
  580. -------------
  581. This is the makefile that is used to make the mkconfig program from
  582. the mkconfig.c C file, the cmpconfig program from cmpconfig.c C file,
  583. the mkversion program from the mkconfig.c C file, or the mksyscall
  584. program from the mksyscall.c file. Usage:
  585. cd tools/
  586. make -f Makefile.host <program>
  587. mkromfsimg.sh
  588. -------------
  589. This script may be used to automate the generation of a ROMFS file system
  590. image. It accepts an rcS script "template" and generates an image that
  591. may be mounted under /etc in the NuttX pseudo file system.
  592. TIP: Edit the resulting header file and mark the generated data values
  593. as 'const' so that they will be stored in FLASH.
  594. mkdeps.c, cnvwindeps.c, mkwindeps.sh, and mknulldeps.sh
  595. -------------------------------------------------------
  596. NuttX uses the GCC compiler's capabilities to create Makefile dependencies.
  597. The program mkdeps is used to run GCC in order to create the dependencies.
  598. If a NuttX configuration uses the GCC toolchain, its Make.defs file (see
  599. boards/README.txt) will include a line like:
  600. MKDEP = $(TOPDIR)/tools/mkdeps[.exe] (See NOTE below)
  601. If the NuttX configuration does not use a GCC compatible toolchain, then
  602. it cannot use the dependencies and instead it uses mknulldeps.sh:
  603. MKDEP = $(TOPDIR)/tools/mknulldeps.sh
  604. The mknulldeps.sh is a stub script that does essentially nothing.
  605. mkwindeps.sh is a version that creates dependencies using the Windows
  606. native toolchain. That generates Windows native paths in the dependency
  607. file. But the mkwindeps.sh uses cnvwindeps.c to convert the Windows
  608. paths to POSIX paths. This adds some time to the Windows dependency
  609. generation but is generally the best option available for that mixed
  610. environment of Cygwin with a native Windows GCC toolchain.
  611. mkdeps.c generates mkdeps (on Linux) or mkdeps.exe (on Windows).
  612. However, this version is still under-development. It works well in
  613. the all POSIX environment or in the all Windows environment but also
  614. does not work well in mixed POSIX environment with a Windows toolchain.
  615. In that case, there are still issues with the conversion of things like
  616. 'c:\Program Files' to 'c:program files' by bash. Those issues may,
  617. eventually be solvable but for now continue to use mkwindeps.sh in
  618. that mixed environment.
  619. netusb.sh
  620. ---------
  621. Helper script used to set up the CDC ECM Ethernet Over USB driver,
  622. host routes, and IP Tables rules to support networking with a NuttX
  623. system that has a CDC ECM Ethernet Over USB driver configured. Only
  624. supported on Linux.
  625. General usage:
  626. $ ./tools/netusb.sh
  627. Usage: tools/netusb.sh <main-interface> <usb-net-interface> <on|off>
  628. This has been tested on the SAMA5D3-Xplained board; see
  629. `boards/arm/sama5/sama5d3-xplained/README.txt` for more information on how
  630. to configure the CDC ECM driver for that board.
  631. README.txt
  632. ----------
  633. This file!
  634. refresh.sh
  635. ----------
  636. [NOTE: This script with --silent is really obsolete. refresh with the
  637. silent option really adds default values. However, as of 217-07-09,
  638. defconfig files are retained in a compressed format, i.e., with default
  639. values removed. So the --silent option will accomplish nothing.
  640. Without --silent, you will have the opportunity over override the default
  641. value from the command line and, in that case, the script may still have
  642. some minimal value.]
  643. This is a bash script that automatics refreshing of board default
  644. configuration (defconfig) files. It does not do anything special
  645. that you cannot do manually, but is useful for me when I have to
  646. update dozens of configuration files.
  647. Configuration files have to be updated because over time, the
  648. configuration settings change: New configurations are added and
  649. new dependencies are added. So an old configuration file may
  650. not be usable anymore until it is refreshed.
  651. Help is also available:
  652. $ tools/refresh.sh --help
  653. tools/refresh.sh is a tool for refreshing board configurations
  654. USAGE: ./refresh.sh [options] <board>/<config>+
  655. Where [options] include:
  656. --debug
  657. Enable script debug
  658. --silent
  659. Update board configuration without interaction
  660. --defaults
  661. Do not prompt for new default selections; accept all recommended default values
  662. --help
  663. Show this help message and exit
  664. <board>
  665. The board directory under nuttx/boards
  666. <config>
  667. The board configuration directory under nuttx/boards/<arch>/<chip>/<board>
  668. The steps to refresh the file taken by refresh.sh are:
  669. 1. Make tools/cmpconfig if it is not already built.
  670. 2. Copy the defconfig file to the top-level NuttX
  671. directory as .config (being careful to save any previous
  672. .config file that you might want to keep!).
  673. 3. Execute 'make oldconfig' to update the configuration.
  674. 'make oldconfig' will prompt you for each change in the
  675. configuration that requires that you make some decision.
  676. With the --silent option, the script will use 'make
  677. oldefconfig' instead and you won't have to answer any
  678. questions; the refresh will simply accept the default
  679. value for any new configuration settings.
  680. 4. Then it runs tools/cmpconfig to show the real differences
  681. between the configuration files. Configuration files are
  682. complex and things can move around so a simple 'diff' between
  683. two configuration files is often not useful. But tools/cmpconfig
  684. will show only the meaningful differences between the two
  685. configuration files.
  686. 4. It will edit the .config file to comment out the setting
  687. of the CONFIG_APPS_DIR= setting. This setting should not
  688. be in checked-in defconfig files because the actually must
  689. be determined at the next time that the configuration is
  690. installed.
  691. 5. Finally, the refreshed defconfig file is copied back in
  692. place where it can be committed with the next set of
  693. difference to the command line. If you select the --silent
  694. option, this file copy will occur automatically. Otherwise,
  695. refresh.sh will prompt you first to avoid overwriting the
  696. defconfig file with changes that you may not want.
  697. rmcr.c
  698. ------
  699. Removes all white space from the end of lines. Whitespace here
  700. includes space characters, TAB characters, horizontal and vertical
  701. TABs, and carriage returns. Lines will be terminated with the
  702. newline character only.
  703. sethost.sh
  704. ----------
  705. Saved configurations may run on Linux, Cygwin (32- or 64-bit), or other
  706. platforms. The platform characteristics can be changed use 'make
  707. menuconfig'. Sometimes this can be confusing due to the differences
  708. between the platforms. Enter sethost.sh
  709. sethost.sh is a simple script that changes a configuration to your
  710. host platform. This can greatly simplify life if you use many different
  711. configurations. For example, if you are running on Linux and you
  712. configure like this:
  713. $ tools/configure.sh board:configuration
  714. The you can use the following command to both (1) make sure that the
  715. configuration is up to date, AND (2) the configuration is set up
  716. correctly for Linux:
  717. $ tools/sethost.sh -l
  718. Or, if you are on a Windows/Cygwin 64-bit platform:
  719. $ tools/sethost.sh -c
  720. Other options are available:
  721. $ ./sethost.sh -h
  722. USAGE: ./sethost.sh [-l|m|c|g|n] [make-opts]
  723. ./sethost.sh -h
  724. Where:
  725. -l|m|c|g|n selects Linux (l), macOS (m), Cygwin (c),
  726. MSYS/MSYS2 (g) or Windows native (n). Default Linux
  727. make-opts directly pass to make
  728. -h will show this help test and terminate
  729. simhostroute.sh
  730. ---------------
  731. Helper script used to set up the tap driver, host routes,
  732. and IP Tables rules to support networking with the
  733. simulator under Linux. General usage:
  734. $ tools/simhostroute.sh
  735. Usage: tools/simhostroute.sh <interface> <on|off>
  736. See boards/sim/sim/sim/NETWORK-LINUX.txt for further information
  737. simbridge.sh
  738. ------------
  739. Helper script used to set up a bridge to support networking with the
  740. simulator under Linux. General usage:
  741. $ tools/simbridge.sh
  742. Usage: tools/simbridge.sh <interface> <on|off>
  743. See boards/sim/sim/sim/NETWORK-LINUX.txt for further information
  744. showsize.sh
  745. -----------
  746. Show the top 10 biggest memory hogs in code and data spaces. This
  747. must be executed from the top-level NuttX directory like:
  748. $ tools/showsize.sh
  749. TOP 10 BIG DATA
  750. ...
  751. TOP 10 BIG CODE
  752. ...
  753. testbuild.sh
  754. ------------
  755. This script automates building of a set of configurations. The intent is
  756. simply to assure that the set of configurations build correctly. The -h
  757. option shows the usage:
  758. $ ./testbuild.sh -h
  759. USAGE: ./testbuild.sh [-l|m|c|g|n] [-d] [-x] [-j <ncpus>] [-a <appsdir>] [-t <topdir>] [-p] [-G] <testlist-file>
  760. ./testbuild.sh -h
  761. Where:
  762. -l|m|c|g|n selects Linux (l), macOS (m), Cygwin (c),
  763. MSYS/MSYS2 (g) or Windows native (n). Default Linux
  764. -d enables script debug output
  765. -x exit on build failures
  766. -j <ncpus> passed on to make. Default: No -j make option.
  767. -a <appsdir> provides the relative path to the apps/ directory. Default ../apps
  768. -t <topdir> provides the absolute path to top nuttx/ directory.
  769. Default $WD/../nuttx, where $WD is the parent directory of
  770. the directory where this script is.
  771. -p only print the list of configs without running any builds
  772. -C Skip tree cleanness check.
  773. -G Use "git clean -xfdq" instead of "make distclean" to clean the tree.
  774. This option may speed up the builds. However, note that:
  775. * This assumes that your trees are git based.
  776. * This assumes that only nuttx and apps repos need to be cleaned.
  777. * If the tree has files not managed by git, they will be removed
  778. as well.
  779. -h will show this help test and terminate
  780. <testlist-file> selects the list of configurations to test. No default
  781. Your PATH variable must include the path to both the build tools and the
  782. kconfig-frontends tools
  783. These script needs two pieces of information.
  784. a. A description of the platform that you are testing on. This description
  785. is provided by the optional -l, -m, -c, -g and -n options.
  786. b. A list of configurations to build. That list is provided by a test
  787. list file. The final, non-optional parameter, <testlist-file>,
  788. provides the path to that file.
  789. The test list file is a sequence of build descriptions, one per line. One
  790. build descriptions consists of two comma separated values. For example:
  791. stm32f429i-disco:nsh,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL
  792. arduino-due:nsh,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL
  793. /arm,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL
  794. /risc-v,CONFIG_RV32IM_TOOLCHAIN_GNU_RVGL
  795. The first value is the usual configuration description of the form
  796. <board-name>:<configuration-name> or /<folder-name> and must correspond to a
  797. configuration or folder in the nuttx/boards directory.
  798. The second value is valid name for a toolchain configuration to use
  799. when building the configuration. The set of valid toolchain
  800. configuration names depends on the underlying architecture of the
  801. configured board.
  802. The prefix '-' can be used to skip a configuration:
  803. -stm32f429i-disco/nsh
  804. or skip a configuration on a specific host(e.g. Darwin):
  805. -Darwin,sim:rpserver
  806. uncrustify.cfg
  807. --------------
  808. This is a configuration script for the uncrustify code beautifier.
  809. Uncrustify does well with forcing braces into "if" statements and
  810. indenting per the NuttX C coding standard. It correctly does things
  811. like placing all braces on separate lines at the proper indentation
  812. level. It cannot handle certain requirements of the coding standard
  813. such as
  814. - FAR attributes in pointer declarations.
  815. - The NuttX standard function header block comments.
  816. - Naming violations such as use of CamelCase variable names,
  817. lower case pre-processor definitions, etc.
  818. Comment blocks, function headers, files headers, etc. must be formatted
  819. manually.
  820. Its handling of block comments is fragile. If the comment is perfect,
  821. it leaves it alone, but if the block comment is deemed to need a fix
  822. it starts erroneously indenting the continuation lines of the comment.
  823. - uncrustify.cfg messed up the indent of most block comments.
  824. cmt_sp_before_star_cont is applied inconsistently. I added
  825. cmt_indent_multi = false # disable all multi-line comment changes
  826. to the .cfg file to limit its damage to block comments.
  827. - It is very strict at wrapping lines at column 78. Even when column 79
  828. just contained the '/' of a closing "*/". That created many
  829. bad continuation lines.
  830. - It moved '{' that opened a struct to the line defining the struct.
  831. nl_struct_brace = add (or force) seemed to be ignored.
  832. - It also aligned variable names in declarations and '=' signs in
  833. assignment statements in a seemingly arbitrary manner. Making changes
  834. that were not necessary.
  835. NOTE: uncrustify.cfg should *ONLY* be used with new files that have an
  836. inconsistent coding style. uncrustify.cfg should get you in the ballpark,
  837. but you should expect to review and hand-edit the files to assume 100%
  838. compliance.
  839. WARNING: *NEVER* use uncrustify.cfg for modifications to existing NuttX
  840. files. It will probably corrupt the style in subtle ways!
  841. This was last verified against uncrustify 0.66.1 by Bob Feretich.
  842. About uncrustify: Uncrustify is a highly configurable, easily modifiable
  843. source code beautifier. To learn more about uncrustify:
  844. http://uncrustify.sourceforge.net/
  845. Source code is available on GitHub:
  846. https://github.com/uncrustify/uncrustify
  847. Binary packages are available for Linux via command line installers.
  848. Binaries for both Windows and Linux are available at:
  849. https://sourceforge.net/projects/uncrustify/files/
  850. See also indent.sh and nxstyle.c
  851. zds
  852. ---
  853. This directory contains build tools used only with the ZDS-II
  854. platforms (z8, ez80, zNeo).
  855. zipme.sh
  856. --------
  857. I use this script to create the nuttx-xx.yy.tar.gz tarballs for
  858. release. It is handy because it also does the kind of clean up
  859. that you need to do to make a clean code release.
  860. It can also PGP sign the final tarballs and create their SHA512 hash.
  861. Any VCS files or directories are excluded from the final tarballs.
  862. $ ./tools/zipme.sh -h
  863. USAGE="USAGE: ./tools/zipme.sh [-d|h|v|s] [-b <build]> [-e <exclude>] [-k <key-id>] [<major.minor.patch>]"
  864. Examples:
  865. ./tools/zipme.sh -s 9.0.0
  866. Create version 9.0.0 tarballs and sign them.
  867. ./tools/zipme.sh -s -k XXXXXX 9.0.0
  868. Same as above but use the key-id XXXXXX to sign the tarballs
  869. ./tools/zipme.sh -e "*.swp tmp" 9.0.0
  870. Create the tarballs but exclude any .swp file and the "tmp" directory.