targets.json的风格
<p><code>targets.json</code>风格检查脚本在<code>tools/targets/lint.py</code>.它可以排除一般的错误。它基于以下规则显示风格错误</p>
<h4><code>Inheritance rules</code></h4>
<p>目标继承必须是其一:</p>
<pre><code>MCU -> Board
MCU -> Module -> Board
Family -> MCU -> Board
Family -> MCU -> Module -> Board
Family -> Subfamily -> MCU -> Board
Family -> Subfamily -> MCU -> Module -> Board</code></pre>
<p>An MCU, Family or Subfamily must have at least one Board or Module above it in any hierarchy.</p>
<h4>Role rules</h4>
<h5>Families, MCUs and Subfamilies may contain the following keys:</h5>
<ul>
<li>core.</li>
<li>extra_labels.</li>
<li>features.</li>
<li>bootloader_supported.</li>
<li>device_name.</li>
<li>post_binary_hook.</li>
<li>default_tool chain.</li>
<li>config.</li>
<li>target_overrides.</li>
</ul>
<h5>MCUs are required to have, and Families and Subfamilies may have:</h5>
<ul>
<li>release_versions.</li>
<li>supported_toolchains.</li>
<li>default_lib.</li>
<li>public.</li>
<li>device_has.</li>
</ul>
<h5>Modules and Boards may have the following keys:</h5>
<ul>
<li>supported_form_factors.</li>
<li>is_disk_virtual.</li>
<li>detect_code.</li>
<li>extra_labels.</li>
<li>public.</li>
<li>config.</li>
<li>overrides.</li>
<li>forced_reset_timeout.</li>
</ul>
<h5><code>macros</code> are not used. 这是有意的:它们不提供任何好处且难以使用。实践中它很难复写<code>macros</code>的值。</h5>
<h5><code>extra_labels</code> 不能包含任何目标名</h5>
<h5><code>device_has</code>只能包含下面列表的值:</h5>
<ul>
<li>ANALOGIN.</li>
<li>ANALOGOUT.</li>
<li>CAN.</li>
<li>ETHERNET.</li>
<li>EMAC.</li>
<li>FLASH.</li>
<li>I2C.</li>
<li>I2CSLAVE.</li>
<li>I2C_ASYNCH.</li>
<li>INTERRUPTIN.</li>
<li>LPTICKER.</li>
<li>PORTIN.</li>
<li>PORTINOUT.</li>
<li>PORTOUT.</li>
<li>PWMOUT.</li>
<li>RTC.</li>
<li>TRNG.</li>
<li>SERIAL.</li>
<li>SERIAL_ASYNCH.</li>
<li>SERIAL_FC.</li>
<li>SLEEP.</li>
<li>SPI.</li>
<li>SPI_ASYNCH.</li>
<li>SPISLAVE.</li>
<li>SYSTICK_CLK_OFF_DURING_SLEEP.
<h5>If release_versions contains 5, then supported_toolchains must contain all of GCC_ARM, ARM and IAR</h5>
<h5>MCUs, Families and SubFamilies must set public to false</h5></li>
</ul>
<h2>Sample output</h2>
<p>lint脚本接收三个子命令<code>targets, all-targets and orphans</code></p>
<h4>targets and all-targets commands</h4>
<p><code>targets</code>和<code>all-targets</code>命令都显示公共继承层次错误,如:
<code>python tools/targets/lint.py targets EFM32GG_STK3700 EFM32WG_STK3800 LPC11U24_301</code>
可能的输出:</p>
<pre><code>hierarchy: Family (EFM32) -> MCU (EFM32GG990F1024) -> Board (EFM32GG_STK3700)
target errors:
EFM32:
- EFM32 is not allowed in extra_labels
EFM32GG990F1024:
- macros found, and is not allowed
- default_lib not found, and is required
- device_has not found, and is required
EFM32GG_STK3700:
- progen found, and is not allowed
- device_has found, and is not allowed
---
hierarchy: Family (EFM32) -> MCU (EFM32WG990F256) -> Board (EFM32WG_STK3800)
target errors:
EFM32:
- EFM32 is not allowed in extra_labels
EFM32WG990F256:
- macros found, and is not allowed
- default_lib not found, and is required
- device_has not found, and is required
EFM32WG_STK3800:
- progen found, and is not allowed
- device_has found, and is not allowed
---
hierarchy: Family (LPCTarget) -> MCU (LPC11U24_301) -> ???
hierarchy errors:
- no boards found in hierarchy
target errors:
LPC11U24_301:
- release_versions not found, and is required
- default_lib not found, and is required
- public not found, and is required</code></pre>
<h4>orphans command</h4>
<p><code>orphans</code>显示所有不能从公共目标到达的目标
<code>python tools/targets/lint.py orphans</code></p>
<pre><code>- CM4_UARM
- CM4_ARM
- CM4F_UARM
- CM4F_ARM
- LPC1800
- EFR32MG1P132F256GM48
- EFR32MG1_BRD4150</code></pre>