1、多核概念说明
AMP:异构多工程,即一个workspace对应一个Core,此方式可以为异构多核(Cortex-M4+Cortex-M7等),也可以是同构多核(比如FC7300 Cortex-M7 * 3)
SMP:多个Core使用同一套Workspace的代码,具体哪个Core运行哪一段代码,由Core Id来区分。
2、JLink Script文件基础
JLink Script这一套东西整体上由五大部分组成:基本语法、全局DLL变量、全局DLL常量、系统API接口、用户自定义动作集。
2.1 脚本基础语法
JLink Script并不是一个通用的脚本语言,因此其并不像你熟知的那些Python之类的脚本语言那样语法完善,它仅是为了配合JLink完成一些必要操作。JLink Script语法跟C语言类似,支持C语言中允许的大多数语句(if else,while,变量声明,…),但不是所有的语句。
此外,还有一些语句是特定于JLink Script的,JLink Script已经尽可能允许最大的灵活性,因此几乎任何必要的目标初始化操作都可以得到支持。
2.2 全局DLL常/变量
JLink Script在被解释执行时,其实是和JLink DLL(即\SEGGER\JLink_Vxxx\JLinkARM.dll)联动的,DLL里存放了JLink各种底层功能集合,同时也默认预定义一些全局变量,这些变量用于DLL配置,需要在JLink Script中被赋值。比如最基础的变量CPU,用于指示连接的目标内核类型,而支持的全部CPU类型都定义在全局常量里。
2.3 系统内置的API接口
JLink DLL中实现了很多基础操作功能,这些功能通过API函数接口形式开放给JLink Script来调用,这些API全部以JLINK_为前缀。举一个比较常用的API函数JLINK_TARGET_Halt(),这个函数功能就是挂起目标内核。
2.4 用户可自定义动作集
终于要讲到JLink Script最关键的部分了,前面都是基础,而JLink Script最核心的功能其实在用户自定义动作集合里,这些动作由JLink预先定义,但是内部具体操作可由用户来编写。在IDE在线下载调试过程中按规定触发条件来调用执行这些动作,下表列出了全部动作,其中蓝框标出的四个动作最常用。
InitTarget():替换J-Link DLL的目标CPU自动查找过程。对于默认情况下不可访问且需要执行一些特殊步骤才能成功执行常规调试连接过程的目标CPU非常有用。
SetupTarget():在InitTarget()以及JLink常规调试连接序列之后被调用,通常用于更高级别的CPU调试设置,如写入某些内存位置、初始化PLL以加快下载速度等。
ResetTarget():替换DLL的复位策略。无论在DLL中选择了什么复位类型,如果存在此函数,将调用它而不是DLL内部复位。
AfterResetTarget():在ResetTarget()之后调用。复位结束后,用于初始化一些必要外设(比如看门狗)。除此之外,对于某些内核类型有必要在复位后执行一些特殊操作,以保证复位后的设备功能正常。
3、keil
3.1、对于多核工程的支持
Keil不支持SMP模式调试多核,因此只能进行AMP调试。
3.2、FC7300 多核调试的基本原理
由于jlink默认只能认到core0,并且core1和core2的启动均由core0来控制,因此首先是通过core0对core1/core2进行初始化,然后再通过AP的选择来控制core1/core2。
3.3、FC7300 Core1和Core2在keil中无法debug的原因
此段内存只有core0有,而keil默认会去该内存上读取相关数据,因此需要在jlink脚本中将该段内存屏蔽,不让keil去访问。

屏蔽方法:
int ConfigTargetSettings(void)
{
JLINK_ExecCommand("map exclude 0xE0040000-0xE0040FFF");
return 0;
}
4、dmac脚本基础
由于网上公开资料比较少,可以先参考痞子衡的blog《痞子衡嵌入式:IAR内部C-SPY调试组件配套宏文件(.mac)用法介绍 - 痞子衡 - 博客园》,
然后在查阅这两篇文档《EWARM_DebuggingGuide.ENU.pdf》、《IARDebugProbe.ENU.pdf》,实际操作时还是需要参考其他现有厂商的脚本。
4.1、I-Jet调试器位置:
__probeCmd调试工具:C:\Program Files (x86)\IAR Systems\Embedded Workbench 9.0\arm\bin\jet
4.2、需要添加文件的相关位置
config/debugger:调试脚本目录
config/devices:芯片类型所在目录
config/flashloader:下载算法所在目录
config/linker:主要包含icf文件,为参考链接文件
5、IAR dmac多核调试实例
Core0_Enable()
{
/* Assert the reset pin */
__probeCmd("dap.RDPw 8 0x0F000000");
__probeCmd("dap.APw 4 0x00004000");
__probeCmd("dap.RDPw 8 0x00000000");
__probeCmd("dap.w 0xE000ED08 0x21010000");
__probeCmd("dap.w 0x21010000 0x21010000");
__probeCmd("dap.w 0x21010004 0x21010401");
__probeCmd("dap.w 0x21010008 0x21010402");
__probeCmd("dap.w 0x2101000C 0x21010402");
__probeCmd("dap.w 0x21010010 0x21010402");
__probeCmd("dap.w 0x21010014 0x21010402");
__probeCmd("dap.w 0x21010400 0xE7FEE7FE");
__probeCmd("dap.RDPw 8 0x0F000000");
__probeCmd("dap.APw 4 0x00000000");
__probeCmd("dap.RDPw 8 0x00000000");
__probeCmd("dap.w 0x40022000 0x2920");
__probeCmd("dap.w 0x40022008 0xf000");
}
Core1_Enable()
{
/* Enable Core 1 */
__probeCmd("dap.p 0");
__probeCmd("dap.w 0x40072034 0x02100100");
__probeCmd("dap.w 0x21001000 0x200017f8");
__probeCmd("dap.w 0x21001004 0x210015a5");
__probeCmd("dap.w 0x210015a4 0xbf00e7fe");
__probeCmd("dap.w 0x40072040 0x00060004");
__probeCmd("dap.w 0x4004620c 0x00000001");
__probeCmd("dap.w 0x40433000 0x2920");
__probeCmd("dap.w 0x40433008 0xf000");
__probeCmd("dap.p 1");
__message "----- CoreId: ", __probeCmd("dap.r 0xE0080004"):%x, " -----";
}
Core2_Enable()
{
/* Enable Core 2 */
__probeCmd("dap.p 0");
__probeCmd("dap.w 0x4007203C 0x02100200");
__probeCmd("dap.w 0x21002000 0x200027f8");
__probeCmd("dap.w 0x21002004 0x210025a5");
__probeCmd("dap.w 0x210025a4 0xbf00e7fe");
__probeCmd("dap.w 0x40072040 0x00060002");
__probeCmd("dap.w 0x4004630c 0x00000001");
__probeCmd("dap.w 0x40434000 0x2920");
__probeCmd("dap.w 0x40434008 0xf000");
__probeCmd("dap.p 2");
__message "----- CoreId: ", __probeCmd("dap.r 0xE0080004"):%x, " -----";
}
execUserCoreConnect()
{
__var processor_id;
__var core_num;
__var debugger_version;
if (!(__driverType("ijet") || __driverType("cmsisdap")))
{
return; // Only supported drivers.
}
debugger_version = __targetDebuggerVersion();
if (__strFind(debugger_version, "8.", 0) == 0)
{
__message "---------------------SMP Debug With 8.x execUserCoreConnect ---------------------";
Core0_Enable();
Core1_Enable();
Core2_Enable();
}
else
{
core_num = __getNumberOfCores();
/* SMP Project debug */
if (core_num == 3)
{
__message "---------------------SMP Debug With 9.x execUserCoreConnect ---------------------";
Core0_Enable();
Core1_Enable();
Core2_Enable();
}
else
{
/* AMP Project debug */
processor_id = __probeCmd("emu BoardDID");
if (__strFind(processor_id,"CM7_0",0) >= 0)
{
__message "---------------------Core0 execUserCoreConnect ---------------------";
Core0_Enable();
}
else if (__strFind(processor_id,"CM7_1",0) >= 0)
{
__message "---------------------Core1 execUserCoreConnect ---------------------";
Core1_Enable();
}
else if (__strFind(processor_id,"CM7_2",0) >= 0)
{
__message "---------------------Core2 execUserCoreConnect ---------------------";
Core2_Enable();
}
}
}
}
execUserSetup()
{
__var processor_id;
__var core_num;
__var debugger_version;
if (!(__driverType("ijet") || __driverType("cmsisdap")))
{
return; // Only supported drivers.
}
/* Hold cpu after debugger access */
__probeCmd("dap.p 0");
debugger_version = __targetDebuggerVersion();
if (__strFind(debugger_version, "8.", 0) == 0)
{
__message "---------------------SMP Debug With 8.x execUserSetup ---------------------";
__probeCmd("dap.w 0x40046204 0x00000001");
__probeCmd("dap.w 0x40046304 0x00000001");
}
else
{
core_num = __getNumberOfCores();
if (core_num == 3)
{
__message "---------------------SMP Debug With 9.x execUserSetup ---------------------";
__probeCmd("dap.w 0x40046204 0x00000001");
__probeCmd("dap.w 0x40046304 0x00000001");
}
else
{
processor_id = __probeCmd("emu BoardDID");
if (__strFind(processor_id,"CM7_0",0) >= 0)
{
__message "---------------------Core0 execUserSetup ---------------------";
}
else if (__strFind(processor_id,"CM7_1",0) >= 0)
{
__message "---------------------Core1 execUserSetup ---------------------";
__probeCmd("dap.w 0x40046204 0x00000001");
}
else if (__strFind(processor_id,"CM7_2",0) >= 0)
{
__message "---------------------Core2 execUserSetup ---------------------";
__probeCmd("dap.w 0x40046304 0x00000001");
}
}
}
}
6、IAR IDE给dmac文件传入参数的方法

注意:当IAR中添加了参数传入,在dmac脚本中能获取到的值为传入值;若IAR中未添加参数传入,在dmac脚本中该变量值为0。

1461

被折叠的 条评论
为什么被折叠?



