Daplink简介
Daplink是arm开源的一款烧写器,硬件电路与stlink可以兼容,可以用于cortex系列的单片机调试与程序烧写。V2版本增加串口支持。
由于arm开源了整个项目,所以任何人使用daplink,都不存在版权的问题。
参考资源
daplink源码:https://github.com/ARMmbed/DAPLink
参考电路图:https://github.com/JassyL/DAP-Link-TypeC
v0257版本在keil中无法识别的接法方案:https://community.arm.com/support-forums/f/keil-forum/52868/keil-cannot-find-daplink-with-new-version-firmware
stlink与daplink电路图上的区别:https://stm32world.com/wiki/STM32_USB_Device_Renumeration
keil编译环境的搭建
英文资料可参考github:https://github.com/ARMmbed/DAPLink/blob/main/docs/DEVELOPERS-GUIDE.md
下面是部分翻译:
设置
DAPLink源文件由 progen
(from project-generator) 生成。progen
可以运行于Linux,MacOS和Windows。
安装下面的必要工具。 如果已经安装,可以跳过这些步骤。
- 安装 Python 3 . 添加到PATH中。
- 安装 Git . 添加到PATH中。
- 安装一个编译器:
-
Keil MDK 或 Arm Compiler 5. 这个编译器将被识别为
armcc
. 只支持Linux和Windows。
-
Keil MDK 或 Arm Compiler 5. 这个编译器将被识别为
- 安装
make
(用 GNU Make测试). CMake 也可以和不同的make
实现以及ninja一起使用。 - 在你的Python环境中安装:
pip install virtualenv
.
第一步. 初始化配置.
获取源代码并创建一个虚拟环境
$ git clone https://github.com/mbedmicro/DAPLink
$ cd DAPLink
$ pip install virtualenv
$ virtualenv venv
激活虚拟环境
第二步. 激活虚拟环境并更新需求。这在你打开一个新的shell时是必要的。 你每次从git上获取新的变化时都应进行
$ venv/Scripts/activate (For Linux)
$ venv/Scripts/activate.bat (For Windows)
(venv) $ pip install -r requirements.txt
构建
你每次从git上获取新的变化时都应进行
有两种方法来构建DAPLink。你可以使用project-generator中的progen
命令行工具或tools/progen_compile.py
包装工具。
方法1. 使用 progen_compile.py
(venv) $ python tools/progen_compile.py [-t <tool>] [--clean] [-v] [--parallel] [<project> [<project> ...]]
-
-t <tool>
: 选择要构建的工具链。默认是make_gcc_arm
. 其他测试过的选项是make_gcc_arm
,make_armclang
,make_armcc
,cmake_gcc_arm
,cmake_armclang
,cmake_armcc
. -
--clean
: 将清除现有的编译产物并强制重新编译所有文件。 -
-v
: 将使编译过程更加冗长(通常列出所有命令及其参数) -
--parallel
: 在一个项目中启用并行编译(项目是按顺序编译的)。 -
<project>
: 要编译的目标项目 (例如stm32f103xb_bl
,lpc11u35_if
),如果没有指定,所有(140到150)项目都将被编译。
方法2. 使用progen进行MDK编译。
该命令在projectfiles/uvision
目录下生成MDK项目文件。
$ progen generate -t uvision
要只生成一个特定的项目,使用这样的命令。
progen generate -f projects.yaml -p stm32f103xb_stm32f746zg_if -t uvision
progen
的参数选项。
-
-f
用于输入项目文件 -
-p
表示项目名称 -
-t
指定IDE的名称
Contribute
We would love to have your changes! Pull requests should be made once a changeset is rebased onto main. See the contributing guide for detailed requirements and guidelines for contributions.
Port
There are three defined ways in which DAPLink can be extended. These are adding target support, adding board support and adding HIC support. Details on porting each of these can be found below.
Test
DAPLink has an extensive set of automated tests written in Python. They are used for regression testing, but you can use them to validate your DAPLink port. Details are here
An option to search for the daplink firmware build in uvision and mbedcli build folders. python test/run_test.py --project-tool make_gcc_arm ...
or python test/run_test.py --project-tool uvision ...
.
Release
Release using progen_compile.py
- Create a tag with the correct release version and push it to github
- Clean the repo you will be building from by running 'git clean -xdf' followed by 'git reset --hard'
- Run the
progen_compile.py
command with the following parameters (see above for the-t
flag):
(venv) $ python tools/progen_compile.py [-t <tool>] --clean -v --parallel --release
- All release deliverables will be created and stored in
firmware_<version>
(where<version>
is the DAPLink version). Save this wherever your builds are stored.
Release using uvision
DAPLink contains scripts to automate most of the steps of building a release. In addition to building the release, these scripts also save relevant build information such as git SHA and python tool versions so the same build can be reproduced. The recommended steps for creating a release are below.
- Create a tag with the correct release version and push it to github
- Clean the repo you will be building from by running 'git clean -xdf' followed by 'git reset --hard'
- Run the script
build_release_uvision.bat
to create all builds. - All release deliverables will be created and stored in 'uvision_release'. Save this wherever your builds are stored.
Note: A previous build can be reproduced by using the build_requirements.txt
of that build. To do this add the additional argument build_requirements.txt
when calling build_release_uvision.bat
in step 2. This will install and build with the exact version of the python packages used to create that build.
MDK
If you want to use the MDK (uVision) IDE to work with the DAPLink code, you must launch it in the right environment. The project will fail to build otherwise. To launch uVision properly, use tools/launch_uvision.bat
This script can take arguments to override default virtual environment and python packages to be installed. For example tools\launch_uvision.bat other_env other_requirements.txt