| <html devsite><head> |
| <title>使用参考开发板</title> |
| <meta name="project_path" value="/_project.yaml"/> |
| <meta name="book_path" value="/_book.yaml"/> |
| </head> |
| <body> |
| <!-- |
| Copyright 2017 The Android Open Source Project |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <p>您可以使用 Android 开源项目 (AOSP) 细分版本和针对特定硬件的相关二进制文件来开发适用于 Nexus 设备的细分版本。要查看可用的 Android 细分版本和针对的设备,请参阅<a href="/setup/build-numbers.html#source-code-tags-and-builds">源代码、标记和细分版本</a>。</p> |
| |
| <p>您也可以开发适用于 <a href="https://android.googlesource.com/device/linaro/hikey/" class="external">HiKey</a> Android 参考开发板的细分版本,此类参考开发板旨在协助非 Nexus 组件供应商开发驱动程序并将其移植到各 Android 版本。使用参考开发板可以简化升级工作,缩短将新 Android 设备推向市场所需的时间,降低设备成本(因为使用参考开发板时,原始设计制造商 (ODM)/原始设备制造商 (OEM) 可以从更多兼容组件中进行选择),并加快组件供应商的创新速度。</p> |
| |
| <p>Google 支持使用经 <a href="#960hikey">HiKey960</a> 和 <a href="#620hikey">HiKey</a> 认证的 <a href="https://www.96boards.org/products/ce/" class="external">96Boards</a> 作为 Android 参考开发板。AOSP 可为 HiKey 提供内核源代码和开发板支持,这样开发者就能够以更低的原始设备制造商 (OEM) 费用轻松开发和调试新的及现有的外围设备驱动程序、进行内核开发,以及执行其他任务。要开发采用新传感器或 LED 的新 ContextHub 功能,您还可以使用连接到 HiKey 或 HiKey960 开发板的 <a href="#neonkey">Neonkey SensorHub</a>。</p> |
| |
| <h2 id="960hikey">HiKey960 开发板</h2> |
| |
| <p>HiKey960 开发板由 LeMaker(通过 <a href="https://www.amazon.com/dp/B071RD3V34" class="external">Amazon.com</a>)和 <a href="http://www.lenovator.com/product/80.html" class="external">Lenovator</a><a> 提供,采用 3GB RAM 配置。 |
| </a></p><a> |
| |
| <img src="images/hikey960.png" alt="HiKey960 开发板图片"/> |
| <figcaption><strong>图 1.</strong> Lenovator 提供的 HiKey960 开发板</figcaption> |
| |
| <p>其他资源:</p> |
| </a><ul><a> |
| </a><li><a> |
| </a><a href="https://github.com/96boards/documentation/blob/master/ConsumerEdition/HiKey960/HardwareDocs/HiKey960_Schematics.pdf" class="external">HiKey960 示意图</a></li> |
| <li> |
| <a href="http://www.96boards.org/documentation/ConsumerEdition/HiKey960/HardwareDocs/HardwareUserManual.md/" class="external">HiKey960 用户指南</a></li> |
| <li> |
| <a href="https://github.com/96boards/documentation/wiki/" class="external">96boards Wiki</a></li> |
| </ul> |
| |
| <p>您可以使用以下命令下载、编译 Android 并在 HiKey960 开发板上运行 Android。</p> |
| |
| <h3 id="960userspace">编译用户空间</h3> |
| <ol> |
| <li>下载 Android 源代码树: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">repo init -u <a href="https://android.googlesource.com/platform/manifest">https://android.googlesource.com/platform/manifest</a> -b master</code> |
| <code class="devsite-terminal">repo sync -j24</code> |
| </pre> |
| </li> |
| <li>下载二进制文件,并将其解压到 Android 源代码树中: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">wget https://dl.google.com/dl/android/aosp/arm-hikey960-OPR-cf4e0c80.tgz</code> |
| <code class="devsite-terminal">tar xzf arm-hikey960-OPR-cf4e0c80.tgz</code> |
| <code class="devsite-terimnal">./extract-arm-hikey960.sh</code> |
| </pre> |
| </li> |
| <li>编译: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">. ./build/envsetup.sh</code> |
| <code class="devsite-terminal">lunch hikey960-userdebug</code> |
| <code class="devsite-terminal">make -j32</code> |
| </pre> |
| </li> |
| </ol> |
| |
| <h3 id="960fastboot">安装初始映像</h3> |
| <ol> |
| <li>打开开关 1 和 3,从而选择 fastboot 模式(有关详情,请参阅 HiKey960 用户指南)。</li> |
| <li>为开发板接通电源。</li> |
| <li>将初始映像刷到设备上: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">cd device/linaro/hikey/installer/hikey960</code> |
| <code class="devsite-terminal">./flash-all.sh</code> |
| </pre> |
| </li> |
| <li>关闭开关 3,然后重启开发板。</li> |
| </ol> |
| |
| <h3 id="960images">将映像刷到设备上</h3> |
| <ol> |
| <li>打开开关 1 和 3,从而进入 fastboot 模式。</li> |
| <li>通过运行以下命令将映像刷到设备上: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">fastboot flash boot out/target/product/hikey960/boot.img</code> |
| <code class="devsite-terminal">fastboot flash dts out/target/product/hikey960/dt.img</code> |
| <code class="devsite-terminal">fastboot flash system out/target/product/hikey960/system.img</code> |
| <code class="devsite-terminal">fastboot flash cache out/target/product/hikey960/cache.img</code> |
| <code class="devsite-terminal">fastboot flash userdata out/target/product/hikey960/userdata.img</code> |
| </pre> |
| </li> |
| <li>关闭开关 3,然后重启开发板。</li> |
| </ol> |
| |
| <h3 id="960kernel">编译内核</h3> |
| <ol> |
| <li>运行以下命令: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">git clone <a href="https://android.googlesource.com/kernel/hikey-linaro">https://android.googlesource.com/kernel/hikey-linaro</a></code> |
| <code class="devsite-terminal">cd hikey-linaro</code> |
| <code class="devsite-terminal">git checkout -b android-hikey-linaro-4.9 origin/android-hikey-linaro-4.9</code> |
| <code class="devsite-terminal">make ARCH=arm64 hikey960_defconfig</code> |
| <code class="devsite-terminal">make ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- -j24</code> |
| </pre> |
| </li> |
| <li>更新启动映像中的内核。 |
| <ul> |
| <li>将 <code>hi3660-hikey960.dtb</code> (<code>arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dtb</code>) 复制到 <code>hikey-kernel</code> 目录,并将其重命名为 <code>hi3660-hikey960.dtb-4.9</code></li> |
| <li>将映像文件 <code>(arch/arm64/boot/Image.gz</code>) 复制到 <code>hikey-kernel</code> 目录,并将其重命名为 <code>Image.gz-hikey960-4.9</code></li> |
| </ul> |
| </li><li>制作启动映像: |
| <pre class="devsite-terminal devsite-click-to-copy"> |
| make bootimage -j24 |
| </pre> |
| </li> |
| </ol> |
| |
| <h3 id="960serial">设置序列号</h3> |
| <p>要设置随机序列号,请运行以下命令: |
| </p><pre class="devsite-terminal devsite-click-to-copy"> |
| fastboot getvar nve:SN@<var>16_DIGIT_NUMBER</var> |
| </pre> |
| <p>引导加载程序通过 <code>androidboot.serialno=</code> 将生成的序列号导出到内核。 |
| |
| </p><h3 id="960resolution">设置显示器分辨率</h3> |
| <p>修改 <code>device/linaro/hikey/hikey960/BoardConfig.mk</code> 参数 <code>BOARD_KERNEL_CMDLINE</code>,并配置 <code>video</code> 设置。 |
| 以下是针对 24 英寸显示器的示例设置:<code>video=HDMI-A-1:1280x800@60</code>。 |
| </p> |
| |
| <h2 id="620hikey">HiKey 开发板</h2> |
| |
| <p>HiKey 开发板(也称为 HiKey620)由 <a href="http://www.lenovator.com" class="external">Lenovator</a> 提供,有 <a href="http://www.lenovator.com/product/86.html" class="external">1GB RAM</a> 和 <a href="http://www.lenovator.com/product/90.html" class="external">2GB RAM</a> 配置可供选择: |
| </p> |
| |
| <img src="images/hikey620.png" alt="HiKey620 开发板图片"/> |
| <figcaption><strong>图 2.</strong> Lenovator 提供的 HiKey 开发板</figcaption> |
| |
| <p>其他资源:</p> |
| <ul> |
| <li> |
| <a href="https://github.com/96boards/documentation/blob/master/ConsumerEdition/HiKey/HardwareDocs/HiKey_schematics_LeMaker_version_Rev_A1.pdf" class="external">HiKey 示意图</a></li> |
| <li> |
| <a href="https://www.96boards.org/wp-content/uploads/2015/02/HiKey_User_Guide_Rev0.2.pdf" class="external">HiKey 用户指南</a></li> |
| <li><a href="https://github.com/96boards/documentation/wiki/" class="external">96boards Wiki</a></li> |
| </ul> |
| |
| <p>您可以使用以下命令下载、编译 Android 并在 HiKey 开发板上运行 Android。</p> |
| |
| <h3 id="620userspace">编译用户空间</h3> |
| <ol> |
| <li>下载 Android 源代码树: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">repo init -u <a href="https://android.googlesource.com/platform/manifest">https://android.googlesource.com/platform/manifest</a> -b master</code> |
| <code class="devsite-terminal">repo sync -j24</code> |
| </pre> |
| </li> |
| <li>下载 HDMI 二进制文件,并将其解压到 Android 源代码树中: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">wget <a href="https://dl.google.com/dl/android/aosp/linaro-hikey-20170523-4b9ebaff.tgz">https://dl.google.com/dl/android/aosp/linaro-hikey-20170523-4b9ebaff.tgz</a></code> |
| <code class="devsite-terminal">tar xzf linaro-hikey-20170523-4b9ebaff.tgz</code> |
| <code class="devsite-terminal">./extract-linaro-hikey.sh</code> |
| </pre> |
| </li> |
| <li>安装 mcopy 实用工具: |
| <pre class="devsite-terminal devsite-click-to-copy"> |
| apt-get install mtools |
| </pre> |
| </li> |
| <li>编译: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">. ./build/envsetup.sh</code> |
| <code class="devsite-terminal">lunch hikey-userdebug</code> |
| <code class="devsite-terminal">make -j32</code> |
| </pre> |
| </li> |
| </ol> |
| |
| <p class="note"><strong>注意</strong>:如果是 4GB eMMC,请不要使用 <code>$ make -j32</code>,而是要使用 <code>$ make -j32 TARGET_USERDATAIMAGE_4GB=true</code>。</p> |
| |
| <h3 id="620fastboot">安装初始 fastboot 和 ptable</h3> |
| <ol> |
| <li>连接 J15 1-2 和 3-4 引脚,从而选择特殊的引导加载程序模式(有关详情,请参阅 <a href="https://www.96boards.org/wp-content/uploads/2015/02/HiKey_User_Guide_Rev0.2.pdf" class="external">HiKey 用户指南</a>)。</li> |
| <li>将 USB 连接到 PC,以获取 ttyUSB 设备(例如:<code>/dev/ttyUSB1</code>)。</li> |
| <li>为开发板接通电源: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">cd device/linaro/hikey/installer/hikey</code> |
| <code class="devsite-terminal">./flash-all.sh /dev/ttyUSB1 [4g]</code> |
| </pre> |
| </li> |
| <li>取下跳线 3-4,并为开发板接通电源。</li> |
| </ol> |
| |
| <h3 id="620images">将映像刷到设备上</h3> |
| <ol> |
| <li>连接 J15 1-2 和 5-6 引脚,从而进入 fastboot 模式。</li> |
| <li>运行以下命令: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">fastboot flash boot out/target/product/hikey/boot.img</code> |
| <code class="devsite-terminal">fastboot flash -w system out/target/product/hikey/system.img</code> |
| </pre> |
| </li> |
| <li>取下跳线 5-6,并为开发板接通电源。</li> |
| </ol> |
| |
| <h3 id="620kernel">编译内核</h3> |
| <ol> |
| <li>运行以下命令: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">git clone <a href="https://android.googlesource.com/kernel/hikey-linaro">https://android.googlesource.com/kernel/hikey-linaro</a></code> |
| <code class="devsite-terminal">cd hikey-linaro</code> |
| <code class="devsite-terminal">git checkout -b android-hikey-linaro-4.9 origin/android-hikey-linaro-4.9</code> |
| <code class="devsite-terminal">make ARCH=arm64 hikey_defconfig</code> |
| <code class="devsite-terminal">make ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- -j24</code> |
| </pre> |
| </li> |
| <li>将输出复制到 HiKey 内核目录 (<code>/kernel/hikey-linaro</code>): |
| <ul> |
| <li>将 hi6220-hikey.dtb (<code>arch/arm64/boot/dts/hisilicon/hi6220-hikey.dtb</code>) 复制到 HiKey 内核目录,并将其重命名为 hi6220-hikey.dtb-4.9。</li> |
| <li>将映像文件 <code>(arch/arm64/boot/Image-dtb</code>) 复制到 HiKey 内核目录,并将其重命名为 Image-dtb-4.9。</li> |
| </ul> |
| </li><li>制作启动映像: |
| <pre class="devsite-terminal devsite-click-to-copy"> |
| make bootimage -j24 |
| </pre> |
| </li> |
| </ol> |
| |
| <h3 id="620resolution">设置显示器分辨率</h3> |
| <p>修改 <code>device/linaro/hikey/hikey/BoardConfig.mk</code> 参数 <code>BOARD_KERNEL_CMDLINE</code>,并配置 <code>video</code> 设置。 |
| 以下是 24 英寸显示器的示例设置:<code>video=HDMI-A-1:1280x800@60</code>。</p> |
| |
| <h3 id="620serial">配置内核串行输出 (uart3)</h3> |
| <p>将 J2 低速扩展连接器设为 1 - Gnd、11 - Rx、13 - Tx。有关详情,请参阅 <a href="https://www.96boards.org/wp-content/uploads/2015/02/HiKey_User_Guide_Rev0.2.pdf" class="external">HiKey 用户指南</a>。</p> |
| |
| <h2 id="neonkey">Neonkey SensorHub</h2> |
| <p>要开发采用新传感器或 LED 的新 ContextHub 功能,您可以使用连接到 HiKey 或 Hikey960 开发板的 <a href="http://www.96boards.org/product/neonkey/" class="external">Neonkey SensorHub</a>。</p> |
| |
| <img src="images/neonkey-sensorhub.png" alt="Neonkey Sensorhub 图片"/> |
| <figcaption><strong>图 3.</strong> Neonkey SensorHub</figcaption> |
| |
| <p>Neonkey 是 STM32F411CE 上经认证的 <a href="http://www.96boards.org/" class="external">96Boards</a> 夹层基础,具有以下组件:</p> |
| |
| <ul> |
| <li>压力传感器:BMP280</li> |
| <li>ALS/近程传感器:RPR-0521RS</li> |
| <li>ARM 霍尔效应传感器:MRMS501A</li> |
| <li>可支持 15 个 LED 的 LED 驱动程序:LP3943</li> |
| <li>加速度计/陀螺仪 + 地磁传感器:BMI160 + BMM150</li> |
| <li>温度/湿度传感器:SI7034-A10</li> |
| <li>4 个 GPIO 驱动的 LED、I2C 扩展、GPIO(2 条线)扩展、JTAG 连接器</li> |
| <li>NOR 闪存:512KB</li> |
| <li>SRAM:128 KB,96boards LS 扩展连接器</li> |
| </ul> |
| |
| <p>AOSP 可提供内核源代码和 ContextHub 开发板支持,以协助开发者以较低的 OEM 费用开发和调试新传感器、进行新的 HAL 和内核更改,等等。</p> |
| |
| <p>要编译、启用并上传 Neonkey,请执行以下操作:</p> |
| |
| <ol> |
| <li>提取 AOSP 源代码: |
| <pre class="devsite-terminal"> |
| repo init -u https://android.googlesource.com/platform/manifest -b master & repo sync -j24 |
| </pre> |
| </li> |
| <li>编译: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">. ./build/envsetup.sh</code> |
| <code class="devsite-terminal">lunch hikey-userdebug</code> |
| <code class="devsite-terminal">. device/google/contexthub/firmware/toolchain-setup.sh</code> |
| <code class="devsite-terminal">make -C device/google/contexthub/firmware/variant/neonkey</code> |
| <code class="devsite-terminal">adb push device/google/contexthub/firmware/out/nanohub/neonkey/full.bin /data/local/tmp</code> |
| </pre> |
| </li> |
| <li>要启用 Neonkey,请通过以下方法进入启动模式: |
| <ol> |
| <li>将 BOOT0 连接到 1V8(连接 JTAG P4 1-5 引脚)</li> |
| <li>按住 USR 按钮</li> |
| <li>按 RST 按钮</li> |
| </ol> |
| </li> |
| <li>要上传固件,请运行以下命令: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">adb root</code> |
| <code class="devsite-terminal">adb shell stm32_flash -u -d /dev/ttyAMA2 -e 0xffff -w /data/local/tmp/full.bin</code> |
| </pre> |
| </li> |
| <li>要编译用户空间 HAL,请运行以下命令: |
| <pre class="devsite-click-to-copy"> |
| <code class="devsite-terminal">make TARGET_SENSOR_MEZZANINE=neonkey -j24</code> |
| <code class="devsite-terminal">fastboot flashall</code> |
| </pre> |
| </li> |
| </ol> |
| |
| </body></html> |