Embedded value riffraff: Freescale i.MX RTyyyy series MCU hardware those things (2.1) - Fun-board OpenSDA, Freelink debugger


  Hello everyone, I am a ruffian scale, is a decent engage in technology riffraff. Today riffraff balance to introduce the on-board debugger on Freescale i.MX RTyyyy series EVK usage .

  This article is i.MXRT hardware those things The second series, the first to give you the overall balance riffraff introduced i.MXRT official EVK, from the beginning of this article riffraff balance the small talk components on EVK, talk about today is a very classic and commonly used components - on-board debugger. Today's major semiconductor manufacturers introduced the basic EVK will configure your own design on-board debugger, user-friendly out of the box, do not need to prepare additional simulators. As we all know, the role of the debugger in embedded development there is very great, with a good debugger can do more with less. So which features NXP produced on-board debugger has it? Ruffian will balance your Secret:

I. Background Introduction

  Speaking i.MXRT series EVK background onboard debugger, it is really a long history. NXP acquired Freescale in 2015, the two leading semiconductor companies before that are designed their own on-board debugger, Freescale is OpenSDA debugger, mainly for Kinetis Series Tower / FRDM development board; Kindness Pu is the LPC-Link debugger, mainly for LPC series LPCXpresso development board. i.MXRT series after the two merged in the new MCU products, so in the end to adopt what kind of on-board debugger it? I.MXRT EVK design engineers have tangled before, this tangled eventually reflected on i.MXRT EVK.
  i.MXRT series was first released two chips are RT1050, RT1020, followed RT1060, RT1015, RT1010, RT1170 ... , let's open them separately EVK Schematic find one on-board debugger interface section as follows :

  Early i.MXRT chip (RT1050 / RT1020) is arranged on the EVK OpenSDA debugger, and thereafter starts from the chip RT1060, all onboard debugger replaced FreeLink (FreeLink fact that the LPC-Link EVK, in i.MXRT called on EVK LPC-Link sounds strange, it changed names), why change from OpenSDA debugger to Freelink debugger? Because i.MXRT chip is largely run by Freescale design team, so the on-board debugger first choice of course, is well placed to exploit OpenSDA, but Freelink master chip LPC4322 (dual-core CM4 + CM0, 204MHz) compared to OpenSDA master MK20DX128 (single-core CM4, 50MHz) are much stronger, use LPC4322 as a debugger master not only better performance, scalability and better future functionality (Do not you see SEGGER J-Link from V10 to start the master also chose LPC4300 series LPC4337) Therefore high-performance Freelink debugger is clearly more suitable i.MXRT EVK.
  Current i.MXRT EVK seems there are two different debugger interface, but only from a functional point, OpenSDA and Freelink there a difference? In fact there is no difference, NXP factory for these two different debuggers master burn the same firmware DAPLink, DAPLink is the ARM Cortex-M official open source project debugger, on DAPLink project home page, MK20 and LPC4322 are in the device support list, also made official and ARM-compatible I / O level is OpenSDA and LPC-Link circuit:

Second, the core function

  On one spoke either OpenSDA the interface or debugger Freelink interface, in fact, from the debugging point of view, they are essentially DAPLink debugger, its features are dependent on DAPLink firmware, continue to return to DAPLink project home page, you can see the following features:

  总体来说DAPLink固件主要有三大功能,第一是CMSIS-DAP协议的在线调试,知名IDE(Keil MDK、IAR EWARM)里都有CMSIS-DAP协议选项;第二是虚拟串口,嵌入式开发里,串口是常用的交互方式,DAPLink使用USB CDC虚拟了串口,为你省去了一个USB转串口的模块(如CH340T模块);第三是拖拽进U盘下载,DAPLink还额外做了一个U盘拖拽下载的功能,方便用户将应用程序下载到片内/片外Flash里。需要注意的是,虚拟串口与U盘下载功能都是板级相关的,跟I/O连接以及Flash型号绑定了。

三、使用示例

  讲完了DAPLink三大核心功能,下面痞子衡将结合恩智浦官方SDK里的示例工程为大家具体演示这三大功能。

3.1 准备工作

  • 准备一块IMXRT1050-EVKB(Rev.A)或者MIMXRT1060-EVK(Rev.A1),假设板载调试器里的DAPLink固件是完好的。
  • 准备一台PC,最好是Win10系统,如果是Win10以下系统需要手动安装好 serial port driver,注意要连接EVK上安装驱动,详见 安装注意事项
  • 准备一根Micro USB连接线,一端接上EVK的J14口,另一端连PC,EVK供电方式选择DAPLink(将J1的Pin5和Pin6连接)。
  • 在PC上安装至少一个IDE(MCUXpresso/MDK/IAR),痞子衡安装的是IAR EWARM v8.32.2。
  • 进入 MCUXpresso SDK Builder主页 下载最新的RT1050或RT1060 SDK开发包,Toolchain全部勾选上。

  一切准备工作就绪,你应该可以看到EVK上电源灯D3显示黄色,这表明DAPLink供电正常,再打开设备管理器,可以看到如下三处设备,表明DAPLink驱动也在正常工作。

3.2 演示一:在线调试

  首先演示的是在线调试,其实更准确的说是在内部SRAM中调试,即利用板载DAPLink调试器直接将应用程序下载进i.MXRT内部SRAM中,并跳转到应用程序中单步执行。当然有朋友会疑问,除了在内部SRAM调试,还有在外部SDRAM调试和在外部SPI NOR Flash调试,后两种不是本小节讨论的内容,痞子衡会在后续的文章中再细聊。
  以RT1050-EVKB为例,使用IAR打开SDK里的 \boards\evkbimxrt1050\demo_apps\hello_world\iar 工程,hello_world是SDK里最典型的例程,该例程一共包含6个Project build(不算xx_debug/xx_release区别),其中debug或ram_0x1400_debug是链接到SRAM中的工程(.text段在ITCM里,.data段在DTCM里),这两个build即可用作在SRAM调试,选中debug工程,确认工程Options里的Debugger选的是CMSIS-DAP,然后点击IAR菜单栏上的“Download and Debug (Ctrl+D)”按钮,便能进入单步调试。

3.3 演示二:虚拟串口

  继续演示虚拟串口,RT1050/RT1060 SDK里hello_world例程使能的是UART1(GPIO_AD_B0_12/13),OpenSDA/Freelink主控芯片与i.MXRT芯片的UART连接正是这个,因此DAPLink虚拟出来的串口可直接用于hello_world例程。
  进入hello_world工程单步调试以后,随便打开一个串口调试助手,COM口设为39(与3.1节里设备管理器里设备号一致),然后直接按F5运行,可以在串口调试助手接收区里看到"hello world."打印出来。如果没有看到打印信息,请检查J30/J31(RT1050-EVKB)或J45/J46(RT1060-EVK)是否已连接。

3.4 演示三:U盘拖拽下载

  最后演示U盘拖拽下载,前面讲的在线调试是把应用程序直接下载到i.MXRT内部SRAM中,断电重启后应用程序就丢失了,而U盘拖拽下载是将应用程序下载到外部SPI NOR Flash中,断电重启后ROM会负责启动SPI NOR Flash中的程序,因此可以实现离线运行。如果你看过痞子衡 《i.MXRT启动那些事》 系列文章,你应该知道所有类型的应用程序都可以存储在SPI NOR Flash中,无论是在Flash中XIP执行,还是在SRAM/SDRAM中执行,但是这些需要离线运行的应用程序必须要加上必要的i.MXRT启动头(FDCB,IVT, BootData)形成Bootable image才可以存储在SPI NOR Flash中,而U盘拖拽下载仅适用Bootable image。
  仍以RT1050-EVKB为例,前面说过hello_world一共包含6个Project build,其中flexspi_nor_debug和flexspi_nor_sdram_debug工程可以直接生成Bootable image,因为这两个Build使能了XIP_BOOT_HEADER_ENABLE,这个宏决定了evkbimxrt1050_flexspi_nor_config.c中的hyperflash_config结构体常量和fsl_flexspi_nor_boot.c中的image_vector_table、boot_data结构体常量是否会被链接进最终的可执行文件。

  痞子衡讲过,U盘拖拽下载是跟Flash类型相关的,咱们再打开RT1050-EVKB原理图,找到其中NOR Flash部分,从原理图上来看,RT1050-EVKB有两种类型NOR Flash可选,分别是八线HyperFlash(S26KS512SDPBHI02)和四线QSPI Flash(IS25WP064AJBLE),而默认连接的是八线HyperFlash,SDK例程里的flexspi_nor_xx build使能的启动头(FDCB)也正是对应HyperFlash(即evkbimxrt1050_flexspi_nor_config.c文件里的hyperflash_config)。

  在进行U盘拖拽之前,首先需要设置RT1050-EVKB的拨码开关SW7,从原理图上看,SW7的3、4位对应Boot Mode,我们需要将Boot Mode设为2'b01,即设置i.MXRT芯片进入Serial Downloader模式,然后重新上电,再进行U盘拖拽下载。为什么需要这么做?这是因为如果i.MXRT芯片处于非Serial Downloader模式(比如Internal Boot),板子上电,ROM会尝试初始化FlexSPI模块去访问外部Flash,如果FlexSPI模块被初始化过一次,这可能会导致DAPLink中的FlexSPI驱动不能正常工作。
  现在让我们选中flexspi_nor_debug工程,确认工程Options里Output Converter中Output format选择的是"Raw binary",编译工程生成可执行文件hello_world.bin,然后将这个bin文件拖拽进名为 "RT1050-EVK" 的虚拟U盘里:

  U盘拖拽下载已成功,现在让我们检验一下应用程序是否能够离线运行,首先需要将Boot Mode设为2'b10,即设置i.MXRT芯片进入Internal Boot模式,然后还需要设置i.MXRT从外部SPI NOR Flash启动,从原理图上看,SW7的1、2位对应BOOT_CFG[9]、BOOT_CFG[6],我们需要将BOOT_CFG[6]设成1'b0,即从FlexSPI1 NOR启动,然后再将BOOT_CFG[9]设成1'b1,即FLASH_TYPE选择010 - HyperFlash 1V8,与EVK上连接的Flash类型保持一致。此时断电重启,你应该可以看到hello world离线运行了。

  至于RT1060-EVK的U盘拖拽下载,其实与RT1050-EVKB差不多,只是需要注意的是RT1060-EVK上默认连接的Flash是四线QSPI Flash,SDK例程里的flexspi_nor_xx build使能的启动头(FDCB)也对应的是QSPI Flash(即evkimxrt1060_flexspi_nor_config.c文件里的qspiflash_config)。U盘下载成后BOOT_CFG[9]需设成1'b0,即FLASH_TYPE选择000 - Device supports 3B read by default。

四、更新固件

  讲完了DAPLink调试器的功能与使用,最后再介绍一下更新DAPLink固件的方法。那么我们为什么需要更新DAPLink固件?我们知道ARM官方一直在维护DAPLink项目,代码也在不断地更新,或修复bug或新增功能,使用最新的DAPLink固件总不是坏事。有人可能会说,只要旧的DAPLink固件功能足够我使用,我就没有必要更新,确实有一定道理,但出现如下两种情况,你就不得不更新DAPLink固件:

  • 你为i.MXRT-EVK更换了Flash连接(比如从HyperFlash换到了QSPI Flash),而且你还想继续使用DAPLink的U盘拖拽下载
  • i.MXRT官方SDK的重大升级,并且DAPLink固件与SDK存在某种联系。据痞子衡所知,SDK 2.3.x的时候,DAPLink是可以自动为拖拽进U盘的裸image加启动头的,而到了SDK 2.6.x的时候,DAPLink就是直接下载Bootable image。

  现在让我们试一下更换DAPLink固件,其实操作很简单,你还记得DAPLink调试器的U盘拖拽下载吗?其实DAPLink固件的更新也是用U盘拖拽下载的方式,因为DAPLink项目本身包含DAPLink Bootloader和DAPLink固件,下载用户应用程序我们借助的是DAPLink固件,而更新DAPLink固件,我们则需要借助DAPLink Bootloader。
  首先让我们准备一个DAPLink固件,我们不需要去DAPLink项目主页自己去编固件,直接进到恩智浦 OpenSDA主页 ,还是以RT1050-EVKB为例吧,默认DAPLink固件是支持onboard hyper-flash的,我们现在将其换为支持onboard spi-flash的固件,点击DAPLink v0244 - Supports onboard spi-flash下面的Download Binary即可下载到k20dx_mimxrt1050_evk_qspi_if_crc_20180419.zip包,将包解压后里面即是我们要的固件(.bin格式)。

  有了新固件,这时候需要让DAPLink进入Bootloader模式,确认J27(RT1050-EVKB)/J43(RT1060-EVK)连接的是Pin1-2,然后按住SW4(RT1050-EVKB)/SW9(RT1060-EVK)按钮,断电重启,如果出现名为 "MAINTENANCE" 的虚拟U盘,即表明进入DAPLink Bootloader模式成功,这时候将新固件拖拽进去即大功告成。

  至此,飞思卡尔i.MX RTyyyy系列EVK上板载调试器的用法痞子衡便介绍完毕了,掌声在哪里~~~

Guess you like

Origin www.cnblogs.com/henjay724/p/11671536.html