cmsis dap interface firmware

The source code of the mbed HDK (tools + libraries) is available in this repository:

What It Provides

The CMSIS-DAP Interface Firmware provides:

  • USB Mass Storage Device for drag and drop programming of the target chip
  • USB Communications Device Class for Serial Communication with the target chip
  • USB HID CMSIS-DAP for debugging
  • USB bootloader for updating the interface firmware itself

Hardware Interfaces

The following image shows how an Onboard Interface running the CMSIS-DAP Interface Firmware might be used to build an evaluation board:

When the Onboard Interface is plugged to an host PC it enumerates as a composite device with the following interfaces:

  • MSD, mass storage device class
  • CDC, communications device class
  • HID, human interface device class

It is connected to the following pins of the target microcontroller:

  • SWD + Reset
  • UART
  • Sleep and Wake (Not currently implemented, reserved for future use)

Shared Code

The Bootloader and CMSIS-DAP Interface Firmware for every target share common middleware and components in the folder shared:

  • shared\cmsis: The CMSIS-CORE software layer
  • shared\rtos: The RTX operating system
  • shared\USBStack: The USB Device middleware

Bootloader

The bootloader allows a firmware update of the interface chip.

Currently, this project support only the !LPC11U35, its project file is located in:bootloader\mdk\lpc11u35\lpc11u35_bootloader.uvproj

At startup it checks the state of a given pin, default high by pull-up resistor:

  • If the pin is high: it simply relocates the vector table to point to the interrupt handlers of the CMSIS-DAP Interface Firmware and then it jumps to its start address.
  • If the pin is low: it enumerates as a mass storage device, waiting for a new firmware image to be flashed using In Application Programming (IAP)

Porting to a New Chip

When you are porting to a new chip, you should first be sure to have the correspondent CMSIS-CORE files in the shared\cmsis folder.

To simplify the effort of porting this bootloader to a new target chip, we have kept together the majority of the target dependent code in the directory bootloader\hal:

  • flash.c: functions to provide In Application Programming (IAP)
  • gpio.c: functions to init the on board led/reset button interrupt
  • read_uid.c: Read of the chip unique ID
  • usbd_XXX.c: low-level driver for the USB device controller. This file contains all the low level functions used by the MDK USB device stack to access the USB controller
  • vector_table.c: Relocation of the interrupt vector table

The current implementations are:

  • LPC11U35bootloader\hal\TARGET_NXP\TARGET_LPC11U35

Flash Algorithms

The CMSIS-DAP Interface Firmware, to be able to flash a new image on the target microcontroller, needs to have a flash algorithm (a sequence of binary instructions) to be loaded on the RAM of the target itself.

The flash algorithm is developed as a small application compiled as *position independent* code and stored in the interface code as a "binary blob".

We provide two such MDK projects for generating the flash algorithms for two family of microcontrollers:

  • interface\flash_algo_mdk\LPC_IAP\LPC_IAP.uvproj: flash algorithm for NXP LPC family
  • interface\flash_algo_mdk\MKXXX\MKXX.uvproj: flash algorithm for Freescale MK family

These projects have multiple configurations for the different sizes of the flash memory within the supported family of microcontrollers.

Once you have generated the position independent flash algorithm, we provide scripts for generating the code to be included in the interface project for your target.

Copy the output elf binary ".axf" to tools\tmp\flash_algo.axf and run:

tools> python flash_algo_gen.py

This will generate a text file named tools\tmp\flash_algo.txt that will look like this:

const uint32_t flash_algo_blob[] = {
0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2, /*0x020*/ 0x28100b00, 0x210ed302, 0xd0eb01, 0x494f4770, 0x607af44f, 0x60084449, 0x2100484d, 0x21aa7001,
/*0x040*/ 0x21557301, 0x21017301, 0x1c40f800, 0x47702000, 0x47702000, 0x41f0e92d, 0x20324c46, 0x2500444c,
/*0x060*/ 0xe884261dL, 0xf1040061L, 0x4f430114, 0x46204688, 0x696047b8, 0x2034b960, 0x61e884, 0x4641483b,
/*0x080*/ 0x68004448, 0x462060e0, 0x696047b8, 0xd0002800L, 0xe8bd2001L, 0xe92d81f0L, 0xf7ff41f0L, 0x4d35ffc1,
/*0x0A0*/ 0x444d4604, 0xe9c52032L, 0xf1050400L, 0x4e320114, 0x4628460f, 0x47b060ac, 0xb9686968L, 0xe9c52034L,
/*0x0C0*/ 0x482a0400, 0x444860ac, 0x68004639, 0x462860e8, 0x696847b0, 0xd0dc2800L, 0xe7da2001L, 0x41f0e92d,
/*0x0E0*/ 0x64614, 0x4825d11d, 0x12fcf8d4, 0xd03a4281L, 0x42814823, 0x4823d037, 0xd0344281L, 0x4030ea4f,
/*0x100*/ 0xd0304281L, 0x100e9d4, 0xe9d44408L, 0x44111202, 0x69214408, 0x69614408, 0x69a14408, 0x42404408,
/*0x120*/ 0x463061e0, 0xff7cf7ffL, 0x21324d12, 0x4f12444d, 0x1000e9c5, 0x114f105, 0x468860a8, 0x47b84628,
/*0x140*/ 0xb9806968L, 0xe9c52033L, 0xf44f0600L, 0xe9c57000L, 0x48064002, 0x44484641, 0x61286800, 0x47b84628,
/*0x160*/ 0x28006968, 0x2001d095, 0xe793, 0x4, 0x400fc080, 0x8, 0x1fff1ff1, 0x4e697370,
/*0x180*/ 0x12345678, 0x87654321L, 0x0, 0x0,
}; static const TARGET_FLASH flash = {
0x1000002F, // Init
0x10000051, // UnInit
0x10000055, // EraseChip
0x10000097, // EraseSector
0x100000DD, // ProgramPage

Interface

Currently, two microcontrollers are supported:

  • LPC11U35interface\mdk\lpc11u35\lpc11u35_interface.uvproj
  • KL25Zinterface\mdk\kl25z\kl25z_interface.uvproj

Each of these projects provides multiple configurations, to:

  • Support different targets: providing a different flash algorithm and reset/unlock sequences
  • Standalone build at address 0x0 (useful during development for better debugging) / Bootloader build at address 0x5000 ready to be loaded by the bootloader.

Supporting a new target

We keep the target dependent code in two files:

  • target_flash.h: Implements an API to load a new binary into the flash of the target, largely generated from the above Flash Algorithm project
  • target_reset.c: provides function in order to unlock/set the target in a specific state

The current target implementations are:

  • LPC812interface\target\hal\DBG_NXP\DBG_LPC812
  • LPC1768interface\target\hal\DBG_NXP\DBG_LPC1768
  • KL25Zinterface\target\hal\DBG_Freescale\DBG_KL25Z
  • KL46Zinterface\target\hal\DBG_Freescale\DBG_KL46Z
  • KL05Zinterface\target\hal\DBG_Freescale\DBG_KL05Z

Porting to a New Interface Chip

When you are porting the CMSIS-DAP Interface Firmware to a new chip, you should first be sure to have the correspondent CMSIS-CORE files in the shared\cmsis folder.

To simplify the effort of porting the bootloader to a new interface chip, we have kept together the majority of the target dependent code in the directory interface\hal:

  • DAP_config.h: implements gpio driver to drive the SWD lines of the target chip.
  • gpio.c: functions to init the on board led/reset button interrupt.
  • read_uid.c: Read of the chip unique ID.
  • usbd_XXX.c: low-level driver for the USB device controller. This file contains all the low level functions used by the MDK USB device stack to access the USB controller.
  • uart.c: provides low level driver to access the uart for the usb <-> uart pipe.
  • usb_buf.h: declares the usb_buffer array. This is interface dependent because the developer may want to put this array into a specific location in memory.

The current implementations are:

  • LPC11U35interface\interface\hal\TARGET_NXP\TARGET_LPC11U35
  • MK20DXinterface\interface\hal\TARGET_Freescale\TARGET_MK20DX

Concatenated Production Image

The final production image will be a single binary containing the bootloader code at address 0x0 and the interface firmware at address0x5000. We do provide a simple script for concatenating these two images that is knowledgeable of the path conventions for the generate elf file of the different projects. It takes as input option the name of the interface and target microcontrollers. For example, for generating the image for an LPC11U35 interface targeting a LPC1768, you can use the following command line:

tools> python concat.py -i LPC11U35 -t LPC1768

This will generate the file: tools\tmp\if_lpc11u35_target_lpc1768.bin

cmsis dap interface firmware的更多相关文章

  1. STM32开发笔记之——CMSIS DAP

    都说开发stm32都是使用kail iar+jatg/swd的方式,然而arm公司已经开发出了CMSIS DAP的开源下载工具,全称是CoreSight Debug Access Port,网络上有大 ...

  2. STM32CubeIDE下载安装-GPIO基本配置操作-Debug调试(基于CMSIS DAP Debug)

    1.在ST官网下载STM32CubeIDE而不是STM32CubeMX,并且STM32CubeIDE是免费的.(STM32CubeIDE不支持中文路径,不然编译会出错) 2.如果你用的是keil开发环 ...

  3. PatentTips - Emulating a host architecture in guest firmware

    BACKGROUND The inventive subject matter relates generally to guest firmware systems, and more partic ...

  4. Booting dircetly into Redlink FW from flash

    Booting dircetly into Redlink FW from flash Hello, the usual way to use the Redlink FW is a two-step ...

  5. 沁恒CH32F103C8T6(三): PlatformIO DAPLink和WCHLink下载配置

    目录 沁恒CH32F103C8T6(一): Keil5环境配置,示例运行和烧录 沁恒CH32F103C8T6(二): Linux PlatformIO环境配置, 示例运行和烧录 沁恒CH32F103C ...

  6. CMSIS-DAP调试器

    http://www.keil.com/support/man/docs/dapdebug/dapdebug_introduction.htm CMSIS-DAP is the interface f ...

  7. Dapper Miser implementation of CMSIS-DAP, MC HCK as SWD Adapter

    Dapper Miser In late 2013, I created a functional implementation of CMSIS-DAP that runs in a low cos ...

  8. CMSIS-DAP仿真器_学习(转载)

    先给大家普及一下,哈哈.CMSIS-DAP仿真器,是ARM官方做的开源仿真器,没有版权,自由制作.官方给的源代码,使用的是NXP的单片机LPC4320做的.这个源代码,只要你安装了KEIL5,就可以找 ...

  9. SWD接口:探索&泄密&延伸

    http://bbs.21ic.com/icview-871133-1-1.html 文买了个JLINKV9,以为神器,拿到手发现根本不是,完全没必要替换V8,想自己做个另类的调试器,当然想只是想而已 ...

随机推荐

  1. shell 流程结构

    if 判断语句 if [ $a == $b ] then echo "等于" else echo "不等于" fi case分支选择 case $xs in ) ...

  2. C. NN and the Optical Illusion(几何)

    题目链接:http://codeforces.com/contest/1100/problem/C 题目大意:给你n和r,n指的是有n个圆围在里面的圆的外面,r指的是里面的圆的半径,然后让你求外面的圆 ...

  3. Linux 串口、usb转串口驱动分析(2-1) 【转】

    转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=26807463&id=4186851 Linux 串口.usb转 ...

  4. 关于Mysql5.6半同步主从复制的开启方法【转】

    介绍 先了解一下mysql的主从复制是什么回事,我们都知道,mysql主从复制是基于binlog的复制方式,而mysql默认的主从复制方式,其实是异步复制. 主库实际上并不关心从库是否把数据拉完没有, ...

  5. eclipse安装阿里巴巴java开发规范插件

    阿里巴巴java开发规范插件 作为JAVA开发人员,始终没有一个明确的规范,何为好代码,何为坏代码,造成不同人的代码风格不同,接手别人代码后改造起来相当困难.前不久,阿里巴巴发布了<阿里巴巴Ja ...

  6. poj2148

    题意:给出若干个没有公共面积的多边形,几个多边形可能属于同一个国家,要求给这个地图染色,同一个国家用相同的颜色,相邻国家不能用相同颜色.问最少需要多少种颜色. 分析:计算几何+搜索.先判断哪些多边形是 ...

  7. 【前端node开发】你需要的Express开发教程

    1.极简Node教程-七天从小白变大神(一:你需要Express) https://www.jianshu.com/p/b4701a6efc50

  8. Android安全系列之:如何在native层保存关键信息

    相信大家在日常开发中都要安全层面的需求,最典型的莫过于加密.而apk是脆弱的,反编译拿到你的源码轻而易举,这时候我们就需要更保险的手段来保存密钥之类的关键信息.本文就细致地讲解简单却实用的native ...

  9. 《高性能MySQL》学习笔记

    第1章 MySQL架构与历史 1.2 并发控制 MySQL在两个层面实现并发控制:服务器层与存储引擎层. 读锁和写锁: 在处理并发读或写时,可以通过实现一个由两种锁组成的系统来解决问题. 这两种锁通常 ...

  10. python的mock功能,感觉入门了~~~

    主要实现语法有patch, patch.object, Mock(). 下面的测试太赤裸裸了,只是为了熟悉语法. import unittest from unittest.mock import p ...