32f103cbt6
固件编译为例。https://github.com/ARMmbed/DAPLink
https://gitee.com/openLuat/daplink/tree/main
,但是需要注意,适配的是216MHz主频。🧨现成的固件下载地址:https://gitee.com/openLuat/luatos-soc-air32f103/tree/master/AIR_Jlink_Keil
- 🔖使用合宙提供的源码工程,还需要拷贝DAPLink源码工程中的
version_git.h
文件,或者修改对应的宏,否则会报错,找不到头文件。
python.exe -m pip install --upgrade pip --升级pip命令
pip install virtualenv 安装虚拟环境
virtualenv venv --创建虚拟环境
cd D:\STM32\DAPLink-main\venv -- 进入虚拟环境文件夹
venv/Scripts/activate.bat -- 执行激活虚拟环境
cd D:\STM32\DAPLink-main\ -- 返回主目录
pip install -r requirements.txt -- 安装所需组件
progen generate -t uvision -- 生成Keil工程列表
venv/Scripts/deactivate.bat -- 退出虚拟环境
- 📍Python下载地址:
https://www.python.org/getit/
🌿Windows环境下,Python
虚拟环境的搭建::pip install virtualenv
安装虚拟环境
🌿在cmd命令提示符窗口内,通过cd命令进入到所下载下来的并解压的DAPLink源码文件夹内:cd D:\STM32\DAPLink-main
🌿在.\DAPLink-main
源码所在文件夹内,创建虚拟环境:virtualenv venv
,会随之创建一个名为venv
文件夹。
venv
文件夹内:.\Scripts\activate.bat
命令.激活虚拟环境?上面2个步骤可以合并,直接在
DAPLink-main
源码所在文件位置,执行.venv\Scripts\activate.bat
cd D:\STM32\DAPLink-main\
;执行:pip install -r requirements.txt
,安装所需组件。DAPLink-main
目录下,执行progen generate -t uvision
;生成Keil
工程列表
- ?在
DAPLink-main\projectfiles\uvision
路径下的得到下面的工程列表,我们只需要保留其中的2个工程:
stm32f103xb_bl:Bootload固件,支持拖拽升级
stm32f103xb_stm32f103rb_if:实际实现dap功能的工程
- 📢烧录完成stm32f103xb_bl.Hex固件后,通过USB(P11,PA12)连接电脑,会出现一个64M的U盘,让后将
stm32f103xb_stm32f103rb_if
工程生成的Hex文件拷贝到U盘中完成DAPLINK功能升级。
DAPLink-main
目录全部拷贝)options for Target
选项- User
IO_Config.h
文件中:
/**
* @file IO_Config.h
* @brief
*
* DAPLink Interface Firmware
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*/
#ifndef __IO_CONFIG_H__
#define __IO_CONFIG_H__
#include "stm32f1xx.h"
#include "compiler.h"
#include "daplink.h"
COMPILER_ASSERT(DAPLINK_HIC_ID == DAPLINK_HIC_ID_STM32F103XB);
//USB control pin
#define USB_CONNECT_PORT_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define USB_CONNECT_PORT_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define USB_CONNECT_PORT GPIOA
#define USB_CONNECT_PIN GPIO_PIN_15
#define USB_CONNECT_ON() (USB_CONNECT_PORT->BSRR = USB_CONNECT_PIN)
#define USB_CONNECT_OFF() (USB_CONNECT_PORT->BRR = USB_CONNECT_PIN)
//Connected LED
#define CONNECTED_LED_PORT GPIOB
#define CONNECTED_LED_PIN GPIO_PIN_11
#define CONNECTED_LED_PIN_Bit 11
//When bootloader, disable the target port(not used)
#define POWER_EN_PIN_PORT GPIOB
#define POWER_EN_PIN GPIO_PIN_15
#define POWER_EN_Bit 15
// nRESET OUT Pin
#define nRESET_PIN_PORT GPIOB
#define nRESET_PIN GPIO_PIN_0
#define nRESET_PIN_Bit 0
//SWD
#define SWCLK_TCK_PIN_PORT GPIOB
#define SWCLK_TCK_PIN GPIO_PIN_13
#define SWCLK_TCK_PIN_Bit 13
#define SWDIO_OUT_PIN_PORT GPIOB
#define SWDIO_OUT_PIN GPIO_PIN_14
#define SWDIO_OUT_PIN_Bit 14
#define SWDIO_IN_PIN_PORT GPIOB
#define SWDIO_IN_PIN GPIO_PIN_12
#define SWDIO_IN_PIN_Bit 12
//JTAG
#define TDO_PIN_PORT GPIOA
#define TDO_PIN GPIO_PIN_10
#define TDO_PIN_Bit 10
#define TDI_PIN_PORT GPIOA
#define TDI_PIN GPIO_PIN_9
#define TDI_PIN_Bit 9
//LEDs
//USB status LED
#define RUNNING_LED_PORT GPIOA
#define RUNNING_LED_PIN GPIO_PIN_2
#define RUNNING_LED_Bit 2
#define PIN_HID_LED_PORT GPIOA
#define PIN_HID_LED GPIO_PIN_6
#define PIN_HID_LED_Bit 6
#define PIN_CDC_LED_PORT GPIOA
#define PIN_CDC_LED GPIO_PIN_10
#define PIN_CDC_LED_Bit 10
#define PIN_MSC_LED_PORT GPIOA
#define PIN_MSC_LED GPIO_PIN_0
#define PIN_MSC_LED_Bit 0
#endif
- 🏷由于源工程630M太多不方便分享。进提供相关固件。
STM32 ST-LINK Utility
或者STM32CubeProgrammer
软件烧录stm32f103xb_bl.Hex,Bootload程序。之后,就不需要以上工具了,再通过USB(PA11,PA12)连接电脑,将出现一个64M的U盘,将stm32f103xb_stm32f103rb_if.Hex文件拷贝到U盘中进行升级成DAPLINK。链接:https://pan.baidu.com/s/1NDvg_HMIuZ8lElKROrOsEg
提取码:gqq2
USB D+
需要上拉一个1.5K的电阻,否则识别不到USB接口,STM32其他较新出的芯片,不需要此上拉电阻,这一点需要注意。