您尚未登录。

楼主 # 2022-04-21 10:06:27

jxlxh
会员
注册时间: 2022-03-27
已发帖子: 9
积分: 9

自制PCB/KEIL MDK/JLINK裸奔F1C100S,一步一步填坑

用自制PCB,用KEIL MDK和JLINK裸奔调试F1C100S
填坑开始

第一坑 JLINK连接
第一坑拜晕哥所赐
如下图
QQ20180418090915.jpg
QQ20180418090924.jpg

如果只连图上4根线,那么调试时会出来如下提示,然后退出调试
jlink%20lost.png

连上地和电源到JLINK后,就能正常调试了

离线

楼主 #1 2022-04-21 10:42:17

jxlxh
会员
注册时间: 2022-03-27
已发帖子: 9
积分: 9

Re: 自制PCB/KEIL MDK/JLINK裸奔F1C100S,一步一步填坑

第二坑 下载

由于以前一直用的是有内部FLASH的,所以调试的第一步自然是下载
对于F1C100S没有内部FLASH的,下载自然是有问题的,JLINK信息如下

Load "D:\\maojing\\hdy-radio\\1-templete\\mdk\\Objects\\templete.axf" 
ProjectFile = D:\maojing\hdy-radio\1-templete\mdk\JLinkArm_debug_in_dram.ini
Info: Device "ARM7" selected (0 KB flash, 0 KB RAM).
Device = TMPA900CMXBG
Info: Device "ARM7" selected (0 KB flash, 0 KB RAM).
VTarget = 3.261V
Info: TotalIRLen = 4, IRPrint = 0x01
***JLink Warning: Identified core does not match configuration. (Found: ARM9, Configured: ARM7)
Info: CP15.0.0: 0x41069265: ARM, Architecure 5TEJ
Info: CP15.0.1: 0x1D152192: ICache: 32kB (4*256*32), DCache: 16kB (4*128*32)
Info: Cache type: Separate, Write-back, Format C (WT supported)
Info: RTCK is not connected
Info: Auto JTAG speed: 8000 kHz
Info: J-Link: ARM9 CP15 Settings changed: 52078 from 78, MMU Off, ICache Off, DCache Off
***JLink Warning: RESET (pin 15) high, but should be low. Please check target hardware.
***JLink Warning: PC of target system has unexpected value of 0xFFFF00D8 after reset.
Info: CP15.0.0: 0x41069265: ARM, Architecure 5TEJ
Info: CP15.0.1: 0x1D152192: ICache: 32kB (4*256*32), DCache: 16kB (4*128*32)
Info: Cache type: Separate, Write-back, Format C (WT supported)
DLL version V4.50l, compiled Jul  9 2012 15:02:49
Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46
Hardware: V8.00
Hardware-Breakpoints: 2
Software-Breakpoints: 8192
Watchpoints:          0
Found 1 JTAG device, Total IRLen = 4:
 Id of device #0: 0x07926F0F
ARM9 identified.
JTAG speed: 1000 kHz
Info: RTCK is not connected
Info: Auto JTAG speed: 8000 kHz
***JLink Warning: RESET (pin 15) high, but should be low. Please check target hardware.
***JLink Warning: PC of target system has unexpected value of 0xFFFF018C after reset.
Info: CP15.0.0: 0x41069265: ARM, Architecure 5TEJ
Info: CP15.0.1: 0x1D152192: ICache: 32kB (4*256*32), DCache: 16kB (4*128*32)
Info: Cache type: Separate, Write-back, Format C (WT supported)
JTAG speed: 1000 kHz
No Algorithm found for: 00000000H - 00001357H
Erase skipped!
Error: Flash Download failed  -  ARM926EJ-S
Info: RTCK is not connected
Info: Auto JTAG speed: 8000 kHz
Flash Load finished at 10:13:14

我知道需要下到SRAM或DRAM,但怎么下进去就不知道了
在参考了网友的例程,和网友晕哥和aozima的帮忙下,总算清楚了这个过程,填坑如下
1)在编译通过后,不需要download,直接开始debug就可以
2)如果要在SRAM中运行,那么project options需要设置如下
   A)Linker tab中的Scatter file和Misc controls分别设置如下
link_scatter.png
run_in_sram.sct文件代码如下

LR_IROM1 0x00000000  {    ; load region size_region
    ER_IROM1 0x00000000 {  ; load address = execution address
        *.o (F1C100S_INIT, +First)
        *(InRoot$$Sections)
        .ANY (+RO)
    }
    RW_RAM1 +0  {  ; RW_RAM1 start address is after ER_ROM1
        .ANY (+RW +ZI)
    }
}

  B)Debug tab中的Initialization File中设置如下
debug_init.png
run_in_sram.ini代码如下

FUNC void SET_PC_SRAM(void)
{
	PC = 0x00000000;
}

SET_PC_SRAM();

  C)Utilities tab设置如下
util_configure.png

如果要运行在DRAM中,那么设置如下:
   A)Linker tab中的Scatter file和Misc controls分别设置如下
link_scatter_dram.png
run_in_dram.sct文件代码如下

LR_IROM1 0x80000000  {    ; load region size_region
    ER_IROM1 0x80000000 {  ; load address = execution address
        *.o (F1C100S_INIT, +First)
        *(InRoot$$Sections)
        .ANY (+RO)
    }
    RW_RAM1 +0  {  ; RW_RAM1 start address is after ER_ROM1
        .ANY (+RW +ZI)
    }
}

  B)Debug tab中的Initialization File中设置如下
debug_init_dram.png
run_in_sram.ini代码如下

FUNC void INIT_CLOCK(void)
{
	int val;
	
	//先把CPU时钟源设置为24Mhz晶振
	val = _RDWORD(0x01c20050);
	val &= ~(3 << 16);
	val |= (1 << 16);
	_WDWORD(0x01c20050, val);
	
	//设置PLL_PERIPH(N=25,M=1) to 600Mhz
	_WDWORD(0x01c20028, 0x80041800);

	//设置AHB/APB/HCLKC的工作频率 200MHz/100MHz
	_WDWORD(0x01c20054, 0x00003180);

	//开启DRAM的front-end和back-end的DCLK门
	_WDWORD(0x01c20100, 0x05000000);	

	//配置PLL_CPU的值408MHz
	_WDWORD(0x01c20000, 0x80001000);

	//把CPU时钟源设置为PLL_CPU
	val = _RDWORD(0x01c20050);
	val &= ~(3 << 16);
	val |= (2 << 16);
	_WDWORD(0x01c20050, val);	
}

FUNC void INIT_DRAM(void)
{
	int val;
	
	//初始化DRAM
	val = _RDWORD(0x01c20824);
	val |= (7 << 12);
	_WDWORD(0x01c20824, val);

	//设置DRAM时钟 156MHz
	_WDWORD(0x01c20020, 0x80100c00);

	//开启DRAM时钟
	val = _RDWORD(0x01c20060);
	val |= (1 << 14);
	_WDWORD(0x01c20060, val);	

	//DRAM软件复位失效
	val = _RDWORD(0x01c202c0);
	val |= (1 << 14);
	_WDWORD(0x01c202c0, val);				

	//设置DRAM参数
	_WDWORD(0x01c01000, 0x0001318a);	//f1c100s设置
	//_WDWORD(0x01c01000, 0x0001338a);	//f1c200s设置

	val = _RDWORD(0x01c0100c);
	val &= ~(7 << 6);
	val |= ((4 << 6) | (1 << 0));
	_WDWORD(0x01c0100c, val);			
}

FUNC void SET_PC_DRAM(void)
{
	PC = 0x80000000;
}

INIT_CLOCK();
INIT_DRAM();
SET_PC_DRAM();

现在能正常在SRAM和DRAM中调试了

在此感谢@晕哥和@aozima的帮助

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn