CmdLineBuild.txt 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021
  1. /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
  2. /**
  3. \page CmdLineBuild Command Line Build
  4. The following bash scripts and command line tools can be used for managing the build of CMSIS Projects from the command line.
  5. These scripts can be easily adopted to specific environments and are intended as a minimal reference.
  6. CMSIS-Build tools are available for download as an asset of the respective
  7. <a href="https://github.com/ARM-software/CMSIS_5/releases/" target="_blank"><b>CMSIS Release Version</b></a>
  8. (starting 5.7.0 e/o April 2020).
  9. For command line build with software packs, the following tools and utilities are provided.
  10. | Tool / Script | Description |
  11. |:--------------------------------------------|:----------------------------------------------------------------------------|
  12. | \subpage cbuild_install "cbuild_install.sh" | Setup of the CMSIS command line build environment |
  13. | \subpage cbuild "cbuild.sh" | Start the overall command line build process |
  14. | \subpage cp_init "cp_init.sh" | Create an empty directory for storing software packs in CMSIS-Pack format |
  15. | \subpage cbuildgen "cbuildgen" | Create Make files and manage software layers |
  16. | \subpage Make "make" | GNU Make utility to generate binary images and update configuration files |
  17. | \subpage cp_install "cp_install.sh" | Download and install software packs |
  18. | \subpage ccmerge "ccmerge" | Merge project specific setup to a new version of a configuration file |
  19. | \subpage cbuild_uv "cbuild_uv.sh" | Export MDK project targets and run a command line build process |
  20. \note
  21. For the above command line build tools and scripts a <a href="https://en.wikipedia.org/wiki/Bash_(Unix_shell)" target="_blank"><b>Bash</b></a> environment is required. For Windows, install for example
  22. <a href="https://gitforwindows.org/" target="_blank"><b>git for Windows</b></a> which includes <b>Git Bash</b>.
  23. The following usage example assumes that the \ref cbuild_install is already completed.
  24. Usage Example
  25. -------------
  26. Open a Bash console and choose a the directory that contains a project and setup the command line build environment:
  27. \code
  28. $ source /c/cbuild/setup
  29. \endcode
  30. Create an empty directory for storing software packs (this not required when existing pack directory is re-used):
  31. \code
  32. $ cp_init.sh
  33. \endcode
  34. Start the build process for a existing project file:
  35. \code
  36. $ cbuild.sh MyProject.cprj
  37. \endcode
  38. Below is the output that shows a successful build:
  39. \verbatim
  40. (cbuild.sh): Build Invocation 0.9.0 (C) 2020 ARM
  41. MyProject.cprj validates
  42. (cbuildgen): Build Process Manager 0.9.0 (C) 2020
  43. M654: URL 'https://www.keil.com/pack/ARM.CMSIS.5.6.0.pack' was added to the list of missing packages.
  44. M650: Command completed successfully.
  45. (cp_install.sh): Install Packs 0.9.0 (C) 2020 ARM
  46. info: reading file: MyProject.cp_install
  47. dos2unix: converting file MyProject.cp_install to Unix format...
  48. https://www.keil.com/pack/ARM.CMSIS.5.6.0.pack
  49. ######################################################################## 100.0%
  50. info: ARM.CMSIS.5.6.0.pack installing into /c/Projects/Packs/ARM/CMSIS/5.6.0
  51. pack installation completed successfully
  52. (cbuildgen): Build Process Manager 0.9.0 (C) 2020 ARM
  53. M653: Local config file RTE/Device/ARMCM0/ARMCM0_ac6.sct was not found. Copying default file from package.
  54. M653: Local config file RTE/Device/ARMCM0/startup_ARMCM0.c was not found. Copying default file from package.
  55. M653: Local config file RTE/Device/ARMCM0/system_ARMCM0.c was not found. Copying default file from package.
  56. M651: Generated makefile for merging config files: 'MyProject_cfg.mak'
  57. M652: Generated makefile for project building:'MyProject.mak'
  58. mkdir -p "/c/Projects/MyProject/Objects/RTE/Device/Startup/C Startup"
  59. mkdir -p "/c/Projects/MyProject/Objects/Source"
  60. "/C/Keil_v5/ARM/ARMCLANG/bin/armclang" @"/c/Projects/MyProject/Objects/Source/MyMain.o._cc"
  61. "/C/Keil_v5/ARM/ARMCLANG/bin/armclang" @"/c/Projects/MyProject/Objects/RTE/Device/Startup/C Startup/startup_ARMCM0.o._cc"
  62. "/C/Keil_v5/ARM/ARMCLANG/bin/armclang" @"/c/Projects/MyProject/Objects/RTE/Device/Startup/C Startup/system_ARMCM0.o._cc"
  63. "/C/Keil_v5/ARM/ARMCLANG/bin/armlink" --via="/c/Projects/MyProject/Objects/MyBinary.axf._ld"
  64. cbuild.sh finished successfully!
  65. \endverbatim
  66. */
  67. /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
  68. /**
  69. \page cbuild_install Setup Build Environment
  70. The command line build environment for projects that are based on the CMSIS-Pack standard requires:
  71. - Required: <a href="https://en.wikipedia.org/wiki/Bash_(Unix_shell)" target="_blank"><b>Bash</b></a> for script execution.
  72. - Optional: \ref libxml "xmllint" for XML schema verification.
  73. With most Linux distributions these tools are already available. The installation for Windows is explained below.
  74. <b>Required for Windows: Bash</b>
  75. - <a href="https://gitforwindows.org/" target="_blank"><b>git for Windows</b></a> includes <b>Git Bash</b> which is easy to download and install.
  76. \section cbuild_install2 cbuild_install.sh: Install Build Tools
  77. CMSIS-Build tools are available for download as an asset of the respective
  78. <a href="https://github.com/ARM-software/CMSIS_5/releases/" target="_blank"><b>CMSIS Release Version</b></a>
  79. (starting 5.7.0 e/o April 2020).
  80. To install the command line build environment start from the Bash prompt:
  81. \code
  82. $ ./cbuild_install.sh
  83. \endcode
  84. This install script queries for:
  85. - Directory for the installation of the CMSIS command line build tools (default ./cbuild).
  86. - When Keil MDK is installed, enter the base directory of the MDK installation (default /c/Keil_v5).
  87. - Directory to store the content of the software packs in CMSIS-Pack format.
  88. \section cbuild_envsetup Environment Variables
  89. The file <b>./cbuild/etc/setup</b> configures the CMSIS command line build environment.
  90. It contains the following section that should reflect the actual installation.
  91. <b>File: ./cbuild/etc/setup</b>
  92. \code
  93. ############### EDIT BELOW ###############
  94. export CMSIS_PACK_ROOT=/C/Users/myname/AppData/Local/Arm/Packs
  95. export CMSIS_COMPILER_ROOT=/C/myname/cbuild
  96. export MDK_ROOT=/C/Keil_v5
  97. \endcode
  98. The file <b>./cbuild/etc/setup</b> is used to setup environment variables in Bash using the <b>source</b> command:
  99. \code
  100. $ source ./cbuild/etc/setup
  101. \endcode
  102. | Variable | Description |
  103. |:------------------------|:-----------------------------------------------------------------|
  104. |\c $CMSIS_PACK_ROOT | Directory that contains the software packs in CMSIS-Pack format. |
  105. |\c $CMSIS_COMPILER_ROOT | Directory that contains the \ref cbuild_compiler_config. |
  106. |\c $CMSIS_BUILD_ROOT | Base directory of the CMSIS command line build tools. |
  107. |\c $MDK_ROOT | Base directory of the MDK installation (optional). |
  108. \section cbuild_compiler_config Compiler Configuration
  109. The CMSIS \ref cbuildgen uses toolchain specific <b>.mak files</b> that map the CMSIS project
  110. settings to the toolchain. For each supported toolchain a <b>.mak files</b> is provided in
  111. the directory <b>./cbuild/etc</b> and specifies the base directory of the toolchain installation (TOOLCHAIN_ROOT).
  112. In addition other toolchain specific environment variables may be setup here (e.g. license file and
  113. product variant).
  114. The user is required to update the these settings after installation to reflect the actual installation.
  115. <b>Example file: ./cbuild/etc/ARMCC.6.13.1.mak</b>
  116. \code
  117. # Version: 1.0.0
  118. # Date: 2020-02-11
  119. # This file maps the CMSIS project options to toolchain settings.
  120. #
  121. # - Applies to toolchain: ARMCC 6.13.1
  122. #
  123. ############### EDIT BELOW ###############
  124. # Set base directory of toolchain
  125. TOOLCHAIN_ROOT:=/C/Keil_v5/ARM/ARMCLANG
  126. # Licensing
  127. #export ARMLMD_LICENSE_FILE=todo
  128. #export ARM_PRODUCT_DEF=$(TOOLCHAIN_ROOT)/../../mappings/gold.elmap
  129. ############ DO NOT EDIT BELOW ###########
  130. \endcode
  131. The toolchain for compilation is defined in project file <b>*.cprj</b> and used by \ref cbuildgen.
  132. The \ref cbuildgen first searches for the toolchain specific <b>.mak file</b> in the project directory.
  133. If the toolchain specific <b>.mak file</b> is not present there, it uses the directory that is specified
  134. by the \b $CMSIS_BUILD_ROOT environment variable.
  135. \section libxml libxml (optional for Windows)
  136. For Windows the <a href="https://www.zlatkovic.com/pub/libxml/" target="_blank"><b>libxml</b></a> provides an XML processor that provides
  137. the functionality of <b>xmllint</b>.
  138. \note The installation is optional and not required to run the command line build tools.
  139. Download the following ZIP files:
  140. - <b>iconv-1.9.2.win32.zip</b>
  141. - <b>libxml2-2.7.8.win32.zip</b>
  142. - <b>libxmlsec-1.2.18.win32.zip</b>
  143. - <b>zlib-1.2.5.win32.zip</b>
  144. Extract the \b /bin directory of each ZIP file to a directory, for example \b C:\\xmllint and add this directory to the Windows
  145. <a href="https://answers.microsoft.com/en-us/windows/forum/windows_10-other_settings/adding-path-variable/97300613-20cb-4d85-8d0e-cc9d3549ba23" target="_blank"><b>PATH</b></a> environment variable.
  146. \note Restart the <b>Git Bash</b> after changing the <b>PATH</b> environment variable.
  147. \note When <b>xmllint</b> is not installed, the XML schema verification is skipped by the \ref cbuild "cbuild.sh" script.
  148. xmllint is also provided by the xsltproc package that can be installed via <a href="https://chocolatey.org/packages/xsltproc" target="_blank"><b>Chocolatey</b></a>:
  149. \code
  150. > choco install xsltproc
  151. \endcode
  152. */
  153. /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
  154. /**
  155. \page cp_init cp_init.sh: Setup Pack Directory
  156. The \ref cp_init "cp_init.sh" script is used to setup a build environment from scratch. It is called from the \b Bash command line with the following syntax:
  157. \code
  158. cp_init.sh [<pack-directory>]
  159. \endcode
  160. \b Where:
  161. \c cp_init.sh is the name of the script.
  162. <\c pack-directory> specifies the directory where software packs should be stored. If not specified, the $CMSIS_PACK_ROOT directory is used.
  163. The \b cp_init.sp script downloads the public CMSIS-Pack index file from https://www.keil.com/pack/index/pidx
  164. and stores this catalog file in pack directory under ./Web. This file is used by \ref cbuildgen to find the latest version of the public software packs.
  165. \section cp_init_example Usage Example
  166. \verbatim
  167. $ cp_init.sh ./packrepo
  168. (cp_init.sh): Setup Pack Directory 0.9.0 (C) 2020 ARM
  169. info: reading directory: ./packrepo
  170. downloading package index file from
  171. ######################################################################## 100.0%
  172. pack repository created successfully
  173. Please setup environment variable CMSIS_PACK_ROOT to:
  174. /c/cbuild/packrepo
  175. \endverbatim
  176. \section cp_init_errors Error Messages
  177. <table class="cmtable" summary="cp_init messages">
  178. <tr>
  179. <th>Type</th>
  180. <th>Message</th>
  181. <th>Action</th>
  182. </tr>
  183. <tr>
  184. <td>ERROR</td>
  185. <td>error: no argument passed and CMSIS_PACK_ROOT environment variable not set</td>
  186. <td>See usage and correct the argument.</td>
  187. </tr>
  188. <tr>
  189. <td>ERROR</td>
  190. <td>error: more than one command line argument passed</td>
  191. <td>See usage and correct the argument.</td>
  192. </tr>
  193. <tr>
  194. <td>ERROR</td>
  195. <td>error: directory already exists. Cannot create new pack repository</td>
  196. <td>See usage and correct the argument.</td>
  197. </tr>
  198. <tr>
  199. <td>ERROR</td>
  200. <td>error: index.pidx download failed</td>
  201. <td>Check internet connection and server availability.</td>
  202. </tr>
  203. <tr>
  204. <td>ERROR</td>
  205. <td>error: downloaded file is not an xml file</td>
  206. <td>Check downloaded file.</td>
  207. </tr>
  208. <tr>
  209. <td>INFO</td>
  210. <td>info: no argument passed - using CMSIS_PACK_ROOT environment variable</td>
  211. <td>For information only.</td>
  212. </tr>
  213. <tr>
  214. <td>INFO</td>
  215. <td>pack repository created successfully</td>
  216. <td>For information only.</td>
  217. </tr>
  218. </table>
  219. */
  220. /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
  221. /**
  222. \page cbuild cbuild.sh: Build Invocation
  223. The \ref cbuild "cbuild.sh" script starts the build process. It is called from the \b Bash command line with the following syntax:
  224. \code
  225. $ cbuild.sh <ProjectFile>.cprj [--toolchain=<Toolchain> --output=<OutputPath> <MakefileTarget>]
  226. \endcode
  227. \b Where:
  228. \c cbuild.sh is the name of the script.
  229. <\c ProjectFile> specifies the project file in CMSIS project format.
  230. Optional:
  231. <\c Toolchain> specifies the selected toolchain for projects that support multiple compilers.
  232. <\c OutputPath> specifies the output directory.
  233. <\c MakefileTarget> specifies the <\c target> option for \ref Make "make".
  234. The \ref cbuild script implements the build flow by chaining the utilities \ref cbuildgen "cbuildgen", \ref ccmerge "ccmerge", and <b>Make</b>.
  235. It replicates the build steps of CMSIS-Pack aware IDEs and also updates configuration files if necessary.
  236. The script can be adopted to project specific requirements.
  237. The build flow of the \ref cbuild script is:
  238. 1. Call \ref cbuildgen with command \b packlist to list the URLs of missing software packs.
  239. 2. Call \ref cp_install to download and install missing software packs.
  240. 3. Call \ref cbuildgen with command \b make to generate Make files.
  241. 4. Call \ref Make to update configuration files using \ref ccmerge.
  242. 5. Call \ref Make to compile the project source code into the binary image.
  243. \section cbuild_example Usage Example
  244. \verbatim
  245. $ cbuild.sh Simulation.cprj
  246. (cbuild.sh): Build Invocation 0.9.0 (C) 2020 ARM
  247. Simulation.cprj validates
  248. (cbuildgen): Build Process Manager 0.9.0 (C) 2020 ARM
  249. M650: Config command completed successfully.
  250. (cbuildgen): Build Process Manager 0.9.0 (C) 2020 ARM
  251. M651: Generated makefile for merging config files: 'Simulation_cfg.mak'
  252. M652: Generated makefile for project build:'Simulation.mak'
  253. mkdir -p "/c/Examples/Blinky/Objects/RTE/CMSIS/RTOS2/Keil RTX5/Library"
  254. mkdir -p "/c/Examples/Blinky/Objects/RTE/Compiler/IO/STDOUT/ITM"
  255. mkdir -p "/c/Examples/Blinky/Objects/RTE/Device/Startup/C Startup"
  256. mkdir -p "/c/Examples/Blinky/Objects/Source Files"
  257. "/C/Keil_v5/ARM/ARMCLANG/bin/armclang" @"/c/Examples/Blinky/Objects/RTE/CMSIS/RTOS2/Keil RTX5/Library/RTX_Config.o._cc"
  258. "/C/Keil_v5/ARM/ARMCLANG/bin/armclang" @"/c/Examples/Blinky/Objects/RTE/CMSIS/RTOS2/Keil RTX5/Library/rtx_lib.o._cc"
  259. "/C/Keil_v5/ARM/ARMCLANG/bin/armclang" @"/c/Examples/Blinky/Objects/RTE/Compiler/IO/STDOUT/ITM/retarget_io.o._cc"
  260. "/C/Keil_v5/ARM/ARMCLANG/bin/armclang" @"/c/Examples/Blinky/Objects/RTE/Device/Startup/C Startup/startup_ARMCM3.o._cc"
  261. "/C/Keil_v5/ARM/ARMCLANG/bin/armclang" @"/c/Examples/Blinky/Objects/RTE/Device/Startup/C Startup/system_ARMCM3.o._cc"
  262. "/C/Keil_v5/ARM/ARMCLANG/bin/armclang" @"/c/Examples/Blinky/Objects/Source Files/Blinky.o._cc"
  263. "/C/Keil_v5/ARM/ARMCLANG/bin/armlink" --via="/c/Examples/Blinky/Objects/Blinky.axf._ld"
  264. Program Size: Code=7516 RO-data=1264 RW-data=168 ZI-data=9084
  265. cbuild.sh finished successfully!
  266. \endverbatim
  267. \section cbuild_errors Error Messages
  268. <table class="cmtable" summary="cbuild messages">
  269. <tr>
  270. <th>Type</th>
  271. <th>Message</th>
  272. <th>Action</th>
  273. </tr>
  274. <tr>
  275. <td>ERROR</td>
  276. <td>error: missing required argument <\c project>.cprj</td>
  277. <td>See usage and correct the argument.</td>
  278. </tr>
  279. <tr>
  280. <td>ERROR</td>
  281. <td>error: CMSIS_BUILD_ROOT environment variable not set</td>
  282. <td>Set \ref cbuild_envsetup.</td>
  283. </tr>
  284. <tr>
  285. <td>ERROR</td>
  286. <td>make ${output}${project}_cfg.mak failed!</td>
  287. <td>Check make error messages.</td>
  288. </tr>
  289. <tr>
  290. <td>ERROR</td>
  291. <td>make ${output}${project}.mak failed!</td>
  292. <td>Check make error messages.</td>
  293. </tr>
  294. <tr>
  295. <td>INFO</td>
  296. <td>cbuild.sh finished successfully!</td>
  297. <td>For information only.</td>
  298. </tr>
  299. </table>
  300. */
  301. /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
  302. /**
  303. \page cbuildgen cbuildgen: Build Process Manager
  304. The \ref cbuildgen "cbuildgen" is the core tool for the build process. It is called from the \b Bash command line with the following syntax:
  305. \code
  306. cbuildgen <command> <ProjectFile>.cprj [options]
  307. \endcode
  308. <b>Where:</b>
  309. \c cbuildgen is the name of tool.
  310. <\c command> specifies the operation of \c cbuildgen (see table below). Only one command is permitted per invocation.
  311. <\c ProjectFile> is the name of the project file. The file extension (.cprj) is mandatory.
  312. [\c options] are additional parameters that control the operation (see table below).
  313. Note: available options are specific for each command.
  314. \b Commands
  315. <table class="cmtable" summary="cbuildgen commands">
  316. <tr>
  317. <th style="min-width:100px">&lt;command></th>
  318. <th style="min-width:185px">Description</th>
  319. <th style="min-width:175px">Details</th>
  320. </tr>
  321. <tr>
  322. <td>packlist</td>
  323. <td nowrap>List missing packs</td>
  324. <td>Check the current list of installed packs in the directory \c $CMSIS_PACK_ROOT. The URLs of missing packs are written to &lt;ProjectFile\>.cp_install file.</td>
  325. </tr>
  326. <tr>
  327. <td>make</td>
  328. <td nowrap>Generate makefile(s)</td>
  329. <td>Generates &lt;ProjectFile\>.mak for \ref Make "Make" required to build the project.
  330. When used with option --merge it generates also &lt;ProjectFile>_cfg.mak for \ref Make "Make" to update configuration files.
  331. This command also generates a ASCII log file &lt;ProjectFile\>.clog recording location and version of the selected toolchain,
  332. packs, components and config files.
  333. The option --output specifies the destination folder of the generated files. The location of the &lt;ProjectFile\>.cprj is
  334. used if --output is not specified.
  335. </td>
  336. </tr>
  337. <tr>
  338. <td>extract</td>
  339. <td nowrap>Extract layer from project</td>
  340. <td>Creates a sub directory named \c ./Layer/\<layername>/ for each layer described in &lt;ProjectFile\>.cprj. These folders
  341. contain a layer description file \<layername>.clayer and the project and configuration files belonging to the layer.
  342. The option --layer=\<layname> selects a specific layer by name. This option can be specified multiple times to select multiple layers.
  343. </td>
  344. </tr>
  345. <tr>
  346. <td>remove</td>
  347. <td nowrap>Remove layer from project</td>
  348. <td>Updates the &lt;ProjectFile\>.cprj removing the layer description as well as all associated files and components for the
  349. layers specified at the command line. The command deletes the associated files from the respecctive project directory.
  350. The option --layer=\<layname> selects a specific layer by name and is mandatory. This option can be specified multiple
  351. times to remove multiple layers.
  352. </td>
  353. </tr>
  354. <tr>
  355. <td>compose</td>
  356. <td nowrap>Create new project</td>
  357. <td>Create new &lt;ProjectFile\>.cprj from layer files ([...]\<layername>.clayer) as well as copying associated files.
  358. One or more clayer files are required.
  359. </td>
  360. </tr>
  361. <tr>
  362. <td>add</td>
  363. <td nowrap>Add layer to project</td>
  364. <td>Updates the &lt;ProjectFile\>.cprj adding the layer description as well as all associated files and components for the
  365. clayer files specified at the command line. The command copies the associated files from the layer directory into the project
  366. directory. One or more clayer files are required.
  367. </td>
  368. </tr>
  369. </table>
  370. \b Options
  371. <table class="cmtable" summary="cbuildgen options">
  372. <tr>
  373. <th style="min-width:100px">[option]</th>
  374. <th style="min-width:175px">Description</th>
  375. <th style="min-width:175px">Details</th>
  376. </tr>
  377. <tr>
  378. <td>\--merge</td>
  379. <td nowrap>Update configuration files</td>
  380. <td>When used with the command \c make, it generates also &lt;ProjectFile>_cfg.mak for \ref Make "Make" to update configuration
  381. files using \ref ccmerge (used by command: make).
  382. </td>
  383. </tr>
  384. <tr>
  385. <td>\--toolchain=&lt;compiler></td>
  386. <td nowrap>Specify toolchain</td>
  387. <td>For projects that can be build with multiple toolchains, it defines the toolchain for the build (used by command: make).</td>
  388. </tr>
  389. <tr>
  390. <td>\--output=&lt;directory></td>
  391. <td nowrap>Specify output directory</td>
  392. <td>Specifies the directory for the generated files <b>*.mak</b> files and the base directory for intermediate output from build.
  393. (used by command: make).</td>
  394. </tr>
  395. <tr>
  396. <td>\--layer=\<layername>
  397. <td nowrap>Specify layer name</td>
  398. <td>Specifies the name of the layer (used by commands: remove and extract).</td>
  399. </tr>
  400. <tr>
  401. <td>\<directory>/\<layername>.clayer</td>
  402. <td nowrap>Specify layer file</td>
  403. <td>Specifies the directory and filename of the project layer (used by commands: add and compose).</td>
  404. </table>
  405. The \ref cbuildgen uses information from the CMSIS project file *.cprj, software packs, and environment variables.
  406. - The *.cprj file lists all software packs (optionally with version), configuration files, and user files along with toolchain specific options.
  407. - The software packs are used to get source and include files of software components. The location of software packs is defined with the environment variable $CMSIS_PACK_ROOT.
  408. - The version of configuration files is specified in project file *.cprj and related software packs are used to update it.
  409. - Device information is read from the device family pack (DFP) that defines the device.
  410. - Command line options for a toolchain is used from the <b>\<name>.\<version>.mak</b> file, if not present in the project file directory, the $CMSIS_COMPILER_ROOT is used.
  411. The \<ProjectFile>.mak file includes two additional makefiles:
  412. - include ${CMSIS_BUILD_ROOT}/etc/Whitespace.mak for handling of white space characters in filenames.
  413. - include ${CMSIS_COMPILER_ROOT}/\<name>.\<version>.mak that specifies default options for the toolchain.
  414. Note: cbuildgen does not update the *.cprj for commands packlist, make and extract. The merge tool updates the outdated configuration files with new merged data, keeping a copy
  415. of the original file.
  416. \section cbuild_example Usage Example
  417. \verbatim
  418. $ cbuildgen packlist Simulation.cprj
  419. (cbuildgen): Build Process Manager 0.9.0 (C) 2020 ARM
  420. M654: URL 'http://www.keil.com/pack/ARM.CMSIS.5.6.0.pack' was added to the list of missing packages.
  421. M654: URL 'http://www.keil.com/pack/Keil.ARM_Compiler.1.6.1.pack' was added to the list of missing packages.
  422. M650: Command completed successfully.
  423. $ cbuildgen make Simulation.cprj
  424. (cbuildgen): Build Process Manager 0.9.0 (C) 2020 ARM
  425. M651: Generated makefile for merging config files: 'Simulation_cfg.mak'
  426. M652: Generated makefile for project build:'Simulation.mak'
  427. \endverbatim
  428. \section cbuildgen_errors Error Messages
  429. <table class="cmtable" summary="cbuildgen invocation messages">
  430. <tr>
  431. <th>Message Number</th>
  432. <th>Type</th>
  433. <th>Description</th>
  434. <th>Action</th>
  435. </tr>
  436. <tr><td>M200</td> <td>ERROR</td> <td>Invalid arguments!</td>
  437. <td>At least one argument is wrong. See usage and correct the argument.</td>
  438. </tr>
  439. <tr><td>M201</td> <td>ERROR</td> <td>Too many arguments!</td>
  440. <td>There is more arguments passed than allowed. See usage and correct the command line.</td>
  441. <tr><td>M202</td> <td>ERROR</td> <td>No CPRJ input file was specified</td>
  442. <td>A *.cprj file is not provided as an argument. </td>
  443. </tr>
  444. <tr><td>M203</td> <td>ERROR</td> <td>Error reading file(s) ...!</td>
  445. <td>The listed file could not be read. Check file content.</td>
  446. </tr>
  447. <tr><td>M204</td> <td>ERROR</td> <td>File not found: ...!</td>
  448. <td>The listed file was not found.</td>
  449. </tr>
  450. <tr><td>M205</td> <td>ERROR</td> <td>$CMSIS_PACK_ROOT environment variable is not defined!</td>
  451. <td>The tool requires the environment variable $CMSIS_PACK_ROOT to locate the CMSIS Packs.</td>
  452. </tr>
  453. <tr><td>M206</td> <td>ERROR</td> <td>No command was specified!</td>
  454. <td>The tool requires a command. See usage information for available commands (e.g. config, make)</td>
  455. </tr>
  456. <tr><td>M207</td> <td>ERROR</td> <td>Multiple commands were specified!</td>
  457. <td>More than one command was provided in arguments. A single command is required.</td>
  458. </tr>
  459. <tr><td>M208</td> <td>ERROR</td> <td>Error copying file ...!</td>
  460. <td>The specified file could not be copied and will be missing during build.</td>
  461. </tr>
  462. <tr><td>M500</td> <td>ERROR</td> <td>RTE Model reports: <i>MSG</i></td>
  463. <td>Error while preparing data. See message for more details.</td>
  464. </tr>
  465. <tr><td>M502</td> <td>ERROR</td> <td>RTE Model reports: <i>\#error NUM: NAME : MSG</i></td>
  466. <td>Additional software components required.</td>
  467. </tr>
  468. <tr><td>M504</td> <td>ERROR</td> <td>RTE Model reports: MISSING: – <i>SPACE NAME</i></td>
  469. <td>Add the missing component.</td>
  470. </tr>
  471. <tr><td>M600</td> <td>ERROR</td> <td>Package index was not found in 'PATH/.Web</td>
  472. <td>Check the package repository.</td>
  473. </tr>
  474. <tr><td>M601</td> <td>ERROR</td> <td>Package 'VENDOR.NAME' was not found in package index!</td>
  475. <td>Check the package repository.</td>
  476. </tr>
  477. <tr><td>M602</td> <td>ERROR</td> <td>Package 'VENDOR.NAME.VER' was not found!</td>
  478. <td>Check the package repository.</td>
  479. </tr>
  480. <tr><td>M603</td> <td>ERROR</td> <td>No version of package 'VENDOR.NAME' was found!</td>
  481. <td>Check the package repository.</td>
  482. </tr>
  483. <tr><td>M604</td> <td>ERROR</td> <td>Unresolved package component: 'CMP'</td>
  484. <td>Check project description file.</td>
  485. </tr>
  486. <tr><td>M605</td> <td>ERROR</td> <td>Wrong CPRJ specification!</td>
  487. <td>Check project description file.</td>
  488. </tr>
  489. <tr><td>M606</td> <td>ERROR</td> <td>Device 'DEV (VENDOR)' was not found!</td>
  490. <td>Check project description file.</td>
  491. </tr>
  492. <tr><td>M607</td> <td>ERROR</td> <td>RTE Model construction failed!</td>
  493. <td>The CMSIS-Pack engine reports an error message.</td>
  494. </tr>
  495. <tr><td>M608</td> <td>ERROR</td> <td>No toolchain configuration file for 'NAME' version 'VER" was found!</td>
  496. <td>Check CMSIS_COMPILER_ROOT or add the required toolchain configuration file to the project directory.</td>
  497. </tr>
  498. <tr><td>M609</td> <td>ERROR</td> <td>Missing 'NAME' element in CPRJ file!</td>
  499. <td>Check project description file.</td>
  500. </tr>
  501. <tr><td>M610</td> <td>ERROR</td> <td>Project supports multiple toolchains. Select one with the option --toolchain</td>
  502. <td>See usage and correct the argument.</td>
  503. </tr>
  504. <tr><td>M611</td> <td>ERROR</td> <td>Selected toolchain is not supported by the project</td>
  505. <td>Check project description file or command line arguments.</td>
  506. </tr>
  507. <tr><td>M630</td> <td>WARNING</td> <td>Device ... is substituted by device variant ... .</td>
  508. <td>Instead of the device specified by the project a variant found for this device is used.</td>
  509. </tr>
  510. <tr><td>M650</td> <td>INFO</td> <td>Setup run successfully</td>
  511. <td>For information only./td>
  512. </tr>
  513. <tr><td>M651</td> <td>INFO</td> <td>Generated makefile for merging config files: ... </td>
  514. <td>For information only.</td>
  515. </tr>
  516. <tr><td>M652</td> <td>INFO</td> <td>Generated makefile for project build:'%NAME%.mak'</td>
  517. <td>For information only.</td>
  518. </tr>
  519. <tr><td>M653</td> <td>INFO</td> <td>Local config file ... was not found. Copying default file from package.</td>
  520. <td>Please validate whether the config file is intentionally missing. The default config file may be missing project specific settings.</td>
  521. </tr>
  522. <tr><td>M654</td> <td>INFO</td> <td>URL ... was added to the list of missing packages.</td>
  523. <td>For information only.</td>
  524. </tr>
  525. <tr><td>M655</td> <td>INFO</td> <td>CMSIS_COMPILER_ROOT environment variable was not set!</td>
  526. <td>For information only.</td>
  527. </tr>
  528. <tr><td>M656</td> <td>INFO</td> <td>Package 'VENDOR.NAME.VER' was found in local repository 'PATH'!</td>
  529. <td>For information only.</td>
  530. </tr>
  531. </table>
  532. */
  533. /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
  534. /**
  535. \page ccmerge ccmerge: Config File Updater
  536. The \ref ccmerge "ccmerge" tool supports the update process for configuration files that use
  537. <a href="../../Pack/html/configWizard.html"><b>Configuration Wizard Annotations</b></a>.
  538. The tool takes the configuration file located in the CMSIS Pack (pfile) and merges the configuration information extracted
  539. from the configuration file located in the current project (cfile). If the merge succeeds the result is written to 'cfile'
  540. after a copy of 'cfile' has been stored as 'cfile.nnnn'.
  541. It is called from the \b Bash command line with the following syntax:
  542. \b ccmerge has the following command invocation:
  543. \code
  544. ccmerge -pfile <name_of_pack_cfgfile> -cfile <name_of_current_cfgfile> [-merge] [-details]
  545. \endcode
  546. \ref ccmerge "ccmerge" helps to update the setup of software components as it merges options from a previous configuration file version to a new version.
  547. <table class="cmtable" summary="ccmerge Arguments">
  548. <tr>
  549. <th style="min-width:210px">Option</th>
  550. <th>Description</th>
  551. </tr>
  552. <tr>
  553. <td>-pfile &lt;name_of_pack_cfgfile></td>
  554. <td>File path of the configuration file from a pack</td>
  555. </tr>
  556. <tr>
  557. <td>-cfile &lt;name_of_current_cfgfile></td>
  558. <td>File path of the current config file in a project</td>
  559. </tr>
  560. <tr>
  561. <td>-merge</td>
  562. <td>Execute merge: the current 'cfile' will be saved as 'cfile.nnnn' then 'cfile' will be updated and overwritten.</td>
  563. </tr>
  564. <tr>
  565. <td>-details</td>
  566. <td>Create a log file: the name will be that of 'cfile' with an extension '.mlog' added to 'cfile'. The log file will contain info about merged items and their location or warning and error messages when processing fails.</td>
  567. </tr>
  568. </table>
  569. When -details is specified without -merge, then a .mlog file will be created that shows the differences of the config values but no actual merge takes place.
  570. When \ref ccmerge "ccmerge" detects that 'cfile' and 'pfile' are incompatible then an error message is shown and the merge is not executed.
  571. \note
  572. A filepath name can be specified without surrounding " characters as long as it does not contain any space or other special characters. It must be enclosed by " characters when the filepath name contains one or more spaces or other special characters.
  573. \section ccmerge_examples Usage Example
  574. \code
  575. ccmerge -pfile $CMSIS_PACK_ROOT/ARM/CMSIS/5.6.0/CMSIS/RTOS2/RTX/Config/RTX_Config.h -cfile RTE/CMSIS/RTX_Config.h -merge
  576. \endcode
  577. \section ccmerge_errors Error Messages
  578. <table class="cmtable" summary="ccmerge messages">
  579. <tr>
  580. <th>Type</th>
  581. <th>Message</th>
  582. <th>Action</th>
  583. </tr>
  584. <tr>
  585. <td>ERROR</td>
  586. <td>-cfile - missing filename</td>
  587. <td>See usage and correct the argument.</td>
  588. </tr>
  589. <tr>
  590. <td>ERROR</td>
  591. <td>-cfile: duplicate specification</td>
  592. <td>See usage and correct the argument.</td>
  593. </tr>
  594. <tr>
  595. <td>ERROR</td>
  596. <td>-pfile - missing filename</td>
  597. <td>See usage and correct the argument.</td>
  598. </tr>
  599. <tr>
  600. <td>ERROR</td>
  601. <td>-pfile: duplicate specification</td>
  602. <td>See usage and correct the argument.</td>
  603. </tr>
  604. <tr>
  605. <td>ERROR</td>
  606. <td>unknown command option</td>
  607. <td>See usage and correct the argument.</td>
  608. </tr>
  609. <tr>
  610. <td>ERROR</td>
  611. <td>Error - cannot open %s file</td>
  612. <td>Check input files.</td>
  613. </tr>
  614. <tr>
  615. <td>ERROR</td>
  616. <td>Error - different types of configuration options</td>
  617. <td>Check input files.</td>
  618. </tr>
  619. <tr>
  620. <td>ERROR</td>
  621. <td>Error: vector.AddCitem() failed - out of memory.</td>
  622. <td>Ensure you have enough memory available.</td>
  623. </tr>
  624. <tr>
  625. <td>ERROR</td>
  626. <td>FATAL-ERROR: Out of Memory</td>
  627. <td>Ensure you have enough memory available.</td>
  628. </tr>
  629. <tr>
  630. <td>ERROR</td>
  631. <td>ccmerge failed, %d Error(s) found.</td>
  632. <td>Check log file.</td>
  633. </tr>
  634. <tr>
  635. <td>WARNING</td>
  636. <td>ccmerge command line warning: duplicate '-%s' ignored</td>
  637. <td>See usage and correct the argument.</td>
  638. </tr>
  639. <tr>
  640. <td>INFO</td>
  641. <td>Note: '-merge' not specified, checking files only.</td>
  642. <td>For information only.</td>
  643. </tr>
  644. <tr>
  645. <td>INFO</td>
  646. <td>Note: no config annotations in pfile</td>
  647. <td>For information only.</td>
  648. </tr>
  649. <tr>
  650. <td>INFO</td>
  651. <td>Note: no config annotations in cfile</td>
  652. <td>For information only.</td>
  653. </tr>
  654. <tr>
  655. <td>INFO</td>
  656. <td>ccmerge completed, 0 Error(s), 0 Warning(s), 'cfile' left unchanged.</td>
  657. <td>For information only.</td>
  658. </tr>
  659. <tr>
  660. <td>INFO</td>
  661. <td>ccmerge completed, %d Error(s), %d Warning(s), %d items merged.</td>
  662. <td>For information only.</td>
  663. </tr>
  664. </table>
  665. */
  666. /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
  667. /**
  668. \page cp_install cp_install.sh: Install Packs
  669. The \c cp_install "cp_install.sh" script gets a list of URLs that refer to software packs in CMSIS-Pack format that should
  670. be downloaded and installed. It is called from the \b Bash command line with the following syntax:
  671. \code
  672. cp_install.sh <pack-list-file>
  673. \endcode
  674. <b>Where:</b>
  675. \c cp_install is the name of the script.
  676. <\c pack-list-file> is a text file that contains a URL list.
  677. The \c cp_install script reads a text file that contains a URL list of software packs in CMSIS-Pack format. The URL list has the following format:
  678. \c \<url>/\<vendor>.\<packname>.\<version>.pack. Below is an example:
  679. \code
  680. https://www.keil.com/pack/ARM.CMSIS.5.6.0.pack
  681. https://www.keil.com/pack/ARM.CMSIS-Driver.2.5.0.pack
  682. \endcode
  683. For each URL in this list the following operations are performed:
  684. 1. Download the related software pack from the URL.
  685. 2. Extract the content of the software pack.
  686. The following directories are used to store software pack. The naming conventions for directories is based on the CMSIS-Pack specification.
  687. | Directory | Description |
  688. |:------------------------------------------------------------------|:----------------------------------------------------------------------------------|
  689. | <b>${CMSIS_PACK_ROOT}/.Download</b> | Stores the downloaded software pack |
  690. | <b>${CMSIS_PACK_ROOT}/&lt;vendor>/&lt;packname>/&lt;version></b> | Extracted content of the software pack (naming accoring CMSIS-Pack specification) |
  691. \note The environment variable \c $CMSIS_PACK_ROOT must reference an existing directory with at least the file ./Web/index.pidx. The directory structure can be created with \ref cp_init
  692. \section cp_install_example Usage Example
  693. \verbatim$
  694. cp_install.sh Simulation.cpinstall
  695. (cp_install.sh): Install Packs 0.9.0 (C) 2020 ARM
  696. info: reading file: Simulation.cpinstall
  697. dos2unix: converting file Simulation.cpinstall to Unix format...
  698. http://www.keil.com/pack/ARM.CMSIS.5.6.0.pack
  699. ######################################################################## 100.0%#=#=#
  700. ######################################################################## 100.0%
  701. info: ARM.CMSIS.5.6.0.pack installing into /c/arm/cbuild/packs/ARM/CMSIS/5.6.0
  702. http://www.keil.com/pack/Keil.ARM_Compiler.1.6.1.pack
  703. ######################################################################## 100.0%#=#=#
  704. ######################################################################## 100.0%
  705. info: Keil.ARM_Compiler.1.6.1.pack installing into /c/arm/cbuild/packs/Keil/ARM_Compiler/1.6.1
  706. pack installation completed successfully
  707. \endverbatim
  708. \section cp_install_errors Error Messages
  709. <table class="cmtable" summary="cp_install messages">
  710. <tr>
  711. <th>Type</th>
  712. <th>Message</th>
  713. <th>Action</th>
  714. </tr>
  715. <tr>
  716. <td>ERROR</td>
  717. <td>error: missing command line argument</td>
  718. <td>See usage and corret argument.</td>
  719. </tr>
  720. <tr>
  721. <td>ERROR</td>
  722. <td>error: too many command line arguments</td>
  723. <td>See usage and corret argument.</td>
  724. </tr>
  725. <tr>
  726. <td>ERROR</td>
  727. <td>error: $filename does not exist</td>
  728. <td>See usage and corret argument.</td>
  729. </tr>
  730. <tr>
  731. <td>ERROR</td>
  732. <td>error: CMSIS_PACK_ROOT environment variable not set</td>
  733. <td>Set \ref cbuild_envsetup.</td>
  734. </tr>
  735. <tr>
  736. <td>ERROR</td>
  737. <td>error: CMSIS_PACK_ROOT: folder does not contain package index file .Web/index.pidx</td>
  738. <td>Check pack repository.</td>
  739. </tr>
  740. <tr>
  741. <td>ERROR</td>
  742. <td>error: pack download failed for $pack_url</td>
  743. <td>Check internet connection and server availability.</td>
  744. </tr>
  745. <tr>
  746. <td>ERROR</td>
  747. <td>error: downloaded file $packfile is not a zip/pack file</td>
  748. <td>Check list of missing packages in cpinstall file.</td>
  749. </tr>
  750. <tr>
  751. <td>ERROR</td>
  752. <td>error: unzip failed for $packfile</td>
  753. <td>Check downloaded package.</td>
  754. </tr>
  755. <tr>
  756. <td>INFO</td>
  757. <td>info: pack $packfile is already downloaded</td>
  758. <td>For information only.</td>
  759. </tr>
  760. <tr>
  761. <td>INFO</td>
  762. <td>info: $packfile is already installed</td>
  763. <td>For information only.</td>
  764. </tr>
  765. <tr>
  766. <td>INFO</td>
  767. <td>pack installation completed successfully</td>
  768. <td>For information only.</td>
  769. </tr>
  770. </table>
  771. */
  772. /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
  773. /**
  774. \page Make make: GNU Make
  775. The \ref Make "make" utility automatically determines which pieces of a large program need to be recompiled, and issues commands to
  776. recompile them. For Windows, the \ref cp_install installs GNU Make version 4.2 compiled for Win32. For
  777. full documentation visit: https://www.gnu.org/software/make/manual/make.html#Options-Summary.
  778. \ref Make "make" is called from the \b Bash command line with the following syntax:
  779. \code
  780. make [<options>] [<target>] ...
  781. \endcode
  782. The \ref cbuild "cbuild.sh" script uses only the following subset of the \ref Make "make" options.
  783. <br>
  784. <table class="cmtable" summary="make options">
  785. <tr>
  786. <th>\[\<options>]</th>
  787. <th>Short Name</th>
  788. <th>Description</th>
  789. </tr>
  790. <tr>
  791. <td>-f FILE</td>
  792. <td>Specify makefile</td>
  793. <td>Run make for the makefile specified by FILE</td>
  794. </tr>
  795. <tr>
  796. <td>-j [N]</td>
  797. <td>Run parallel jobs.</td>
  798. <td>Speed up builds by allowing N jobs at once; infinite jobs with no arg.</td>
  799. </tr>
  800. <tr>
  801. <td>-r</td>
  802. <td>Run make without built-in rules</td>
  803. <td>Disable the implicit rules built into make.</td>
  804. </tr>
  805. <tr>
  806. <td>-s</td>
  807. <td>Run make in silent mode</td>
  808. <td>Don't echo recipes.</td
  809. </tr>
  810. <tr>
  811. <th>[\<target>]</th>
  812. <th>Short Name</th>
  813. <th>Description</th>
  814. </tr>
  815. <tr>
  816. <td>clean</td>
  817. <td nowrap>Cleanup build</td>
  818. <td>Requests to remove intermediate build output files</td>
  819. </tr>
  820. </table>
  821. \section Make_example Usage Example
  822. Build a project:
  823. \code
  824. $ make -j -f MyProject.mak
  825. \endcode
  826. Cleanup the project build directories:
  827. \code
  828. $ make -f MyProject.mak clean
  829. \endcode
  830. */
  831. /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
  832. /**
  833. \page cbuild_uv cbuild_uv.sh: Build MDK project
  834. The \c cp_install "cbuild_uv.sh" script calls uVision and exports all targets for a Keil MDK project in the CMSIS project
  835. format (*.cprj files). The script then invokes the \ref cbuild "cbuild.sh" script for each exported project target. It is
  836. called from the \b Bash command line with the following syntax:
  837. \code
  838. cbuild_uv.sh <project-file>.uvprojx
  839. \endcode
  840. <b>Where:</b>
  841. \c cbuild_uv.sh is the name of the script.
  842. <\c project-file> is the filename of a uVision project.
  843. \note
  844. The environment variable \c $MDK_ROOT must refer to the base directory of the Keil MDK installation.
  845. \note
  846. Some MDK features are not converted as not all build features of µVision are available in command line build process. For example:
  847. - User commands pre and post build
  848. - \c fcarm code generator
  849. - Linker script generation. Instead the linker script generated by MDK is used by cmsis build.
  850. \section cbuild_uv_example Usage Example
  851. \verbatim
  852. $ cbuild_uv.sh FTP_Server.uvprojx
  853. (cbuild_uv.sh): Build MDK Project 0.9.0 (C) 2020 ARM
  854. uVision has created CPRJ files for the following targets:
  855. FTP_Server.Debug.cprj
  856. FTP_Server.Release.cprj
  857. --------------------------------------------------------------------
  858. calling cbuild.sh for FTP_Server.Debug.cprj
  859. --------------------------------------------------------------------
  860. ...
  861. --------------------------------------------------------------------
  862. calling cbuild.sh for FTP_Server.Release.cprj
  863. --------------------------------------------------------------------
  864. ...
  865. builds completed for:
  866. FTP_Server.Debug.cprj
  867. FTP_Server.Release.cprj
  868. total: 2 failed: 0
  869. \endverbatim
  870. */