1 Star 0 Fork 24

汇顶科技 / device_soc_goodix

forked from OpenHarmony / device_soc_goodix 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

device_soc_goodix

[TOC]

简介

基于Goodix开发的BLE应用soc部分,主要存放GR551x系列芯片的sdk和适配,以及后续其他系列芯片的适配。

以下内容步骤参考quickstart-lite-env-setup-linux

系统要求:Ubuntu16.04 或 Ubuntu18.04 64位系统版本。

编译构建

工具安装

安装repo

  1. 创建repo安装目录:命令行输入mkdir ~/bin
  2. 下载repo:命令行输入wget https://storage.googleapis.com/git-repo-downloads/repo -P ~/bin/
  3. 改变执行权限:命令行输入chmod a+x ~/bin/repo
  4. 设置环境变量:在~/.bashrc文件的最后输入export PATH=~/bin:$PATHexport REPO_URL=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/
  5. 重启shell

安装必要的库和工具

  • 通常系统默认安装samba、vim等常用软件,需要做适当适配以支持Linux服务器与Windows工作台之间的文件共享。
  • 使用如下apt-get命令安装编译所需的必要的库和工具:
sudo apt-get install build-essential gcc g++ make zlib* libffi-dev e2fsprogs pkg-config flex bison perl bc openssl libssl-dev libelf-dev libc6-dev-amd64 binutils binutils-dev libdwarf-dev u-boot-tools mtd-utils gcc-arm-linux-gnueabi

安装Python3

  1. 打开Linux编译服务器终端。

  2. 输入如下命令,查看python版本号:

    python3 --version

    如果低于python3.7版本,不建议直接升级,请按照如下步骤重新安装。以python3.8为例,按照以下步骤安装python。

    1. 运行如下命令,查看Ubuntu版本:
    cat /etc/issue
    1. 根据Ubuntu不同版本,安装python。
      • 如果Ubuntu 版本为18+,运行如下命令。

        sudo apt-get install python3.8
      • 如果Ubuntu版本为16。

        a. 安装依赖包

        sudo apt update && sudo apt install software-properties-common

        b. 添加deadsnakes PPA 源,然后按回车键确认安装。

        sudo add-apt-repository ppa:deadsnakes/ppa

        c. 安装python3.8

        sudo apt upgrade && sudo apt install python3.8
  3. 设置python和python3软链接为python3.8。

    sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
  4. 安装并升级Python包管理工具(pip3),任选如下一种方式。

    • 命令行方式:

      sudo apt-get install python3-setuptools python3-pip -y
      sudo pip3 install --upgrade pip
    • 安装包方式:

      curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
      python get-pip.py

安装hb

前提条件

请先安装Python 3.7.4及以上版本,请见安装Python3

安装方法
  1. 运行如下命令安装hb

    python3 -m pip install --user ohos-build
  2. 设置环境变量

    vim ~/.bashrc

    将以下命令拷贝到.bashrc文件的最后一行,保存并退出。

    export PATH=~/.local/bin:$PATH

    执行如下命令更新环境变量。

    source ~/.bashrc
  3. 执行"hb -h",有打印以下信息即表示安装成功:

    usage: hb
    
    OHOS build system
    
    positional arguments:
      {build,set,env,clean}
        build               Build source code
        set                 OHOS build settings
        env                 Show OHOS build env
        clean               Clean output
    
    optional arguments:
      -h, --help            show this help message and exit

安装编译工具链

  1. 编译链工具推荐使用gcc-arm-none-eabi-10-2020-q4-major。(下载网站:https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads )。
  2. 执行vim ~/.bashrc
  3. 将工具链的路径加入环境变量, 如:export PATH=/home/tools/ARM/gcc-arm-none-eabi-10-2020-q4-major/bin:$PATH
  4. 保存后执行source ~/.bashrc使环境变量生效。

获取代码流程

  1. 新建代码存放目录(用户可以自行指定为其他目录),并进入:
mkdir ~/openharmony
cd ~/openharmony
  1. 打包下载所有文件,此时默认的Harmony版本为Master:
repo init -u https://gitee.com/openharmony/manifest --no-repo-verify
  1. 下载好仓库后,输入:repo sync -c,也就是下载当前分支的代码。
  2. 下载好代码后,输入:repo forall -c 'git lfs pull',下载部分大容量二进制文件。

确认目录结构

在device文件夹下,确保device/soc目录结构如下

user:~/openharmony/device/soc$ tree -L 3
.
└── goodix
    ├── BUILD.gn                                  # GN构建脚本
    ├── gr551x                                    # gr551x soc适配目录
    │   ├── adapter                               # 外设驱动、BLE、文件系统适配
    │   ├── BUILD.gn                              # GN构建脚本
    │   ├── components                            # 组件
    │   ├── hcs                                   # 设备描述文件
    │   ├── Kconfig.liteos_m.defconfig.gr551x     # gr551x Kconfig默认配置
    │   ├── Kconfig.liteos_m.defconfig.series     # series Kconfig默认配置
    │   ├── Kconfig.liteos_m.series               # series Kconfig配置项
    │   ├── Kconfig.liteos_m.soc                  # soc Kconfig配置项
    │   ├── sdk_liteos                            # Liteos GR551x SDK适配
    │   └── tools                                 # 固件生成工具
    ├── Kconfig.liteos_m.defconfig                # liteos_m Kconfig默认配置
    ├── Kconfig.liteos_m.series                   # liteos_m series配置项
    └── Kconfig.liteos_m.soc                      # liteos_m soc配置项

在device文件夹下,确保device/board目录结构如下

user:~/openharmony/device/board$ tree -L 3
.
└── goodix
    ├── BUILD.gn                                  # GN构建脚本
    ├── drivers                                   # 板级驱动存放目录
    │   └── BUILD.gn                              # GN构建脚本
    ├── gr5515_sk                                 # GR5515 Starter Kit开发板配置目录
    │   ├── BUILD.gn                              # GN构建脚本
    │   ├── gr5515_sk_defconfig                   # GR5515 Starter Kit Kconfig默认配置
    │   ├── Kconfig.liteos_m.board                # Board liteos_m Kconfig配置项
    │   ├── Kconfig.liteos_m.defconfig.board      # Board liteos_m Kconfig默认配置
    │   └── liteos_m                              # 构建脚本目录
    ├── hcs                                       # hcs硬件描述配置目录
    │   ├── BUILD.gn                              # GN构建脚本
    │   └── gr5515_sk.hcs                         # GR5515 Starter Kit hcs硬件描述脚本
    ├── Kconfig.liteos_m.boards                   # Board liteos_m Kconfig配置项
    └── Kconfig.liteos_m.defconfig.boards         # Board liteos_m Kconfig默认配置

在vendor文件夹下,确保vendor文件夹目录结构如下

user:~/openharmony/vendor$ tree -L 3
.
└── goodix
    ├── gr5515_sk_iotlink_demo                    # BLE应用示例工程
    │   ├── ble_template                          # BLE示例代码
    │   ├── BUILD.gn                              # GN构建脚本
    │   ├── config.json                           # 子系统裁配置裁剪脚本
    │   ├── hals                                  # 产品参数配置
    │   ├── hdf_config                            # HDF硬件描述配置
    │   └── kernel_configs                        # Kconfig配置输出
    └── gr5515_sk_xts_demo                        # XTS测试示例工程
        ├── BUILD.gn                              # GN构建脚本
        ├── config.json                           # 子系统裁配置裁剪脚本
        ├── tests                                 # 测试用例
        ├── hals                                  # 产品参数配置
        ├── hdf_config                            # HDF硬件描述配置
        └── kernel_configs                        # Kconfig配置输出

编译工程

进入源码根目录编译工程

hb set -root . 选择当前路径为工程根目录

hb set -p 选择工程

goodix
    >gr5515_sk_iotlink_demo
     gr5515_sk_xts_demo

hb build -f 开始编译,后续修改了文件只需要执行hb build -f即可,不需要重复以上步骤。

如果hb set命令提示报错,请先执行一次python3 -m pip install build/lite

使用方法

生成的固件位于out/{board_name}/{product_name}/bin/application_fw.bin

Windows下固件烧录

软件安装

GProgrammer仅支持在Windows平台下安装使用,其可执行安装程序为GProgrammer Setup Version.exe。点击下载GProgrammer

用户可按照以下步骤安装GProgrammer:

  1. 双击GProgrammer的可执行安装程序GProgrammer Setup Version.exe,进入GProgrammer安装界面,然后按照安装向导提示逐步完成安装操作。

GProgrammer安装界面

  1. GProgrammer安装完成后,将提示用户继续安装JLink驱动,如下图所示。

安装JLink提示

  1. JLink安装完成后,用户可通过桌面或开始菜单的快捷方式启动GProgrammer软件。

硬件连接

GProgrammer既支持JLink SWD方式烧录,也支持串口方式烧录,这里推荐使用SWD连接方式。

选择SWD连接方式时,用户需使用J-Link仿真器来连接PC和目标板。使用USB线将仿真器的一端与PC相连,使用杜邦线将仿真器的另一端与目标板上的芯片管脚相连。

GProgrammer安装界面

J-Link仿真器与芯片管脚的连接对应关系如下:

J-Link仿真器管脚 GR551x芯片管脚
VCC VCC
GND GND
SWDIO GPIO_1
SWCLK GPIO_0

提示: 如过用户使用的是Goodix的GR5515 Starter Kit开发板,开发板已经集成J-Link OB芯片,用户只需使用一根Micro USB 2.0线连接开发板和PC,Mirco USB用于供电以及通过J-Link进行固件烧录。

芯片选型

启动GProgrammer后,默认进入芯片选型页面,如下图所示,根据自己产品或者开发板使用的芯片型号选择对应的芯片型号。

GProgrammer启动界面

选择芯片型号后,进入主界面:

GProgrammer主界面

软件界面的左侧为功能导航栏(具体描述见下表),右侧为功能操作区域。

图标 功能名称 描述
Firmware Firmware 点击该图标,进入固件操作页面
Flash Flash 点击该图标,进入Flash操作页面
Encrypt Encrypt & Sign 点击该图标,进入加密加签操作页面
eFuse Layout eFuse Layout 点击该图标,进入eFuse展示操作页面
Chip config Chip Configuration 点击该图标,进入芯片配置操作页面
Device Log Device Log 点击该图标,进入设备日志操作页面
Help Help 点击该图标,进入帮助操作页面

连接设备

用户可管理控制目标板与主机之间的连接。

点击软件界面右上角的打开连接面板_灰 ,可展开连接管理面板;再次点击隐藏连接面板_灰 ,可收起并隐藏该面板。

GProgrammer支持SWD和串口两种连接方式。

  • SWD连接

在SWD连接方式下,用户只需配置传输速率Speed,即可点击Connect按钮连接目标板。

SWD连接
  • 串口(UART)连接 在串口(UART)连接方式下,用户可根据实际情况配置串口号Port(需点击Refresh按钮获取串口号列表,再选择正确的串口号)和波特率,其他参数默认配置不可修改。
串口连接

参数配置完成后,点击Connect按钮连接目标板。

目标板连接成功后,连接管理面板将自动收起并隐藏。同时,按钮打开连接面板_灰将变成打开连接面板_彩,表示当前的连接状态为“已连接”。

如需断开连接,再次点击打开连接面板_彩,打开连接管理面板,然后点击Disconnect按钮即可。

断开连接

固件下载

GProgrammer以图形化方式展示Flash Firmware Layout(如图下图所示),可帮助用户直观了解Flash中固件区域的占用情况。

FW Flash布局

浅灰色(浅灰色):可下载的Flash空间。

深蓝色(深蓝色):软件默认配置的NVDS区域。固件不能下载至该区域。

深灰色(深灰色):待删除的固件,如ble_app_ancs。

浅绿色(浅绿色):待下载的固件,如ble_app_hrs。

深绿色(深绿色):已存在于Flash中的固件,如ble_app_bps。

红色(红色):两个固件的占用空间的重叠区域,如ble_app_T3u和ble_app_hts。

用户下载固件时,请按以下步骤操作:

  1. 点击Add按钮,从本地添加需下载的固件文件。固件文件添加后,可查看到该固件的详细信息,例如固件文件路径、固件Image Info信息。

  2. 在图形化展示的Flash Firmware Layout区域中,选中要启动的固件,点击Startup按钮,此时该选中的固件会出现一个小火箭,表示下载成功后立即启动该固件。

  3. 点击Commit按钮,将固件文件下载到Flash。

下载完成后,若Layout示意图中的固件由浅绿色变为深绿色,则表示固件下载成功。

提示: 更详细的GProgrammer使用指导,参考GProgrammer用户手册

Linux下固件烧录

1. GProgrammer获取:

git clone https://gitee.com/sink-top/gprogrammer-linux.git

2. 解压:

cd gprogrammer-linux/
tar -xjvf GProgrammer-1.2.15.tar.bz2

3. 安装J-Link软件:

cd GProgrammer-1.2.15/
sudo dpkg -i JLink_Linux_V618c_x86_64.deb

4. 固件下载

参考上面"编译工程"章节,选中gr5515_sk_xts_demo工程编译后,生成的固件存放在"~/openharmony/out/gr551x/gr5515_sk_xts_demo/bin/application_fw.bin"。

1. 硬件连接

J-Link仿真器与开发板或者产品正确连接,且J-Link仿真器的USB与Ubuntu连接,确保Ubuntu USB列表能找到J-Link设备。

2. 固件下载

在GProgrammer-1.2.15目录下:

  1. 先擦除Flash上已经存在的固件
  • 全部擦除,包括文件系统、NVDS区域保存的用户信息,如果用户不关心这些信息,执行此命令:
./GR551x_console eraseall
  • 擦除部分区域,保留文件系统、NVDS区域保存的用户信息:
 ./GR551x_console erase 0x1000000 0x10c3000 y

上面两种擦除方式,二选一执行。

  1. 烧录固件:
 ./GR551x_console program ~/openharmony/out/gr551x/gr5515_sk_xts_demo/bin/application_fw.bin y

提示: 更多GProgrammer命令的使用,请参考GProgrammer命令行

相关仓库

vendor_goodix

device_board_goodix

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS

简介

基于Goodix开发的BLE应用soc部分,主要存放GR551x系列芯片的sdk和适配,以及后续其他系列芯片的适配 展开 收起
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/sink-top/device_soc_goodix.git
git@gitee.com:sink-top/device_soc_goodix.git
sink-top
device_soc_goodix
device_soc_goodix
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891