问题已解决。修改原厂的FLM文件。
[C] 纯文本查看 复制代码 /*
* Change Mode & Clock for rewriting flash
* Parameter: clk: Input clock value (Hz)
* Return Value: 0 - OK, 1 - Failed
*/
static BYTE changeModeAndClock(DWORD *clk)
{
// Unprotect some registers
M16(MCU_PRCR_ADDR) = PRCR_KEY | PRCR_PRC0_ENABLE | PRCR_PRC1_ENABLE;
// If Sub Operating Power Control Mode = Subosc-speed, set to Other
if ((M8(MCU_SOPCCR_ADDR) & SOPCCR_SOPCM_MASK) == SOPCCR_SOPCM_SUBMODE)
{
M8(MCU_SOPCCR_ADDR) = SOPCCR_SOPCM_OTHMODE;
}
// Wait until it successfully sets
while ((M8(MCU_SOPCCR_ADDR) & SOPCCR_SOPCMTSF_MASK) != SOPCCR_SOPCMTSF_COMPL)
{
// Do nothing
;
}
// If OFS1 is in initial state, use MOCO
if ((M32(MCU_OFS1_ADDR) & OFS1_HOCOFRQ1_MASK) == OFS1_HOCOFRQ1_MASK)
{
TEST_LOG(0x50);
// Change clock source to MOCO
if (M8(MCU_SCKSCR_ADDR) != SCKSCR_CKSEL_MOCO)
{
// If MOCO is stoped, start it
if (M8(MCU_MOCOCR_ADDR) == MOCOCR_STOP)
{
M8(MCU_MOCOCR_ADDR) = MOCOCR_ON;
// Wait until MOCO is stable
Wait_us(15);
while ((M8(MCU_OSCSF_ADDR) & OSCSF_MOSCSF_MASK) != OSCSF_MOSCSF_STABLE)
{
// Do nothing
;
}
}
// Select clock as MOCO
M8(MCU_SCKSCR_ADDR) = SCKSCR_CKSEL_MOCO;
}
// Frequency is 8MHz
*clk = 8000000;
} else
{ // Otherwise, use HOCO
TEST_LOG(0x51);
// Change clock source to HOCO
if (M8(MCU_SCKSCR_ADDR) != SCKSCR_CKSEL_HOCO)
{
// If HOCO is stoped, start it
if (M8(MCU_HOCOCR_ADDR) == HOCOCR_STOP)
{
M8(MCU_HOCOCR_ADDR) = HOCOCR_ON;
// Wait until HOCO is stable
while ((M8(MCU_OSCSF_ADDR) & OSCSF_HOCOSF_MASK) != OSCSF_HOCOSF_STABLE)
{
// Do nothing
;
}
}
// Select clock as HOCO
M8(MCU_SCKSCR_ADDR) = SCKSCR_CKSEL_HOCO;
}
// Frequency is 24/32/48/64 MHz
M32(0x20002200) = M32(MCU_OFS1_ADDR);
switch (M32(MCU_OFS1_ADDR) & OFS1_HOCOFRQ1_MASK)
{
case OFS1_HOCOFRQ1_24MHZ:
*clk = 24000000;
TEST_LOG(0x52);
break;
case OFS1_HOCOFRQ1_32MHZ:
*clk = 32000000;
TEST_LOG(0x53);
break;
case OFS1_HOCOFRQ1_48MHZ:
*clk = 48000000;TEST_LOG(0x54);
break;
case OFS1_HOCOFRQ1_64MHZ:
*clk = 64000000;
TEST_LOG(0x55);
break;
default:
TEST_LOG(0x56);
break; // 安富莱add
return (RES_ERROR); // Finished with Errors
}
}
if (*clk != 64000000)
{
TEST_LOG(0x57);
// Change clock division to 1
M32(MCU_SCKDIVCR_ADDR) = SCKDIVCR_ICK_DIV1_MASK;
} else
{
TEST_LOG(0x58);
// Change clock division to 2
M32(MCU_SCKDIVCR_ADDR) = SCKDIVCR_ICK_DIV2_MASK;
*clk = 32000000;
}
return (RES_OK); // Finished without Errors
}
第89行,直接break,而不是return.下面是H7-TOOL烧录日志。 2.5秒烧录128KB。瑞萨的FLASH擦写速度还不错
[C] 纯文本查看 复制代码
开始烧录...
单路烧录
SWCLK时钟延迟: 0
core_id = 0x5BA02477
uid1 =
------------------------
FLM : 0:/H7-TOOL/Programmer/Device/Renesas/FLM/RA2L1_128K.FLM
Data: 128K_5A.bin
Addr: 0x00000000, cfg = 1
FLM memory Infomation :
algo file : 0:/H7-TOOL/Programmer/Device/Renesas/FLM/RA2L1_128K.FLM
AlgoRamAddr = 0x20000000
AlgoRamSize = 0x2000
----Device Info------------------------
Version & Architecture : 0x0101
Device Name : RA2L1 256KB Flash
Device Type : 1
Device Addr : 0x00000000
Device Size : 256KB (0x40000)
Page Size : 128B
Reserved : 0x00000000
Erased Content : 0xFF
Program Page TimeOut : 100
Erase Sector TimeOut : 3000
Erase Sector Size : 00000000, 2KB (0x800)
----Algo function offset ---------------
Load Offset : 0x00000034
Load Size : 0x00001084
FlashDevice : 0x000010B8
Init : 0x00000001
UnInit : 0x0000081D
BlankCheck : 0x00000EB5
EraseChip : 0x000008CD
EraseSector : 0x000009C9
ProgramPage : 0x00000AE9
Verify : 0x00000DC9
CaculCRC32 : 0x00000000
GetSN : 0x00000000
----Algo RAM Info---------------------------
algo ram address : 0x20000000
algo size : 0x000010A4
buffer address : 0x200010A4
buffer size : 0x00000080
breakpoint addres : 0x20000001
static base adress : 0x20001124
stack pointer : 0x20002000
Init : 0x20000021
UnInit : 0x2000083D
BlankCheck : 0x20000ED5
EraseChip : 0x200008ED
EraseSector : 0x200009E9
ProgramPage : 0x20000B09
Verify : 0x20000DE9
InitUnderReset()
OK
.NVIC_CPUID = 411CD200, Cortex-M23
正在检查空片
74ms, 0.00%
76ms, 100.00%
正在擦除整片...
78ms, 0.00%
81ms, 0.00%
103ms, 100.00%
正在编程...
104ms, 0.00%
.......
2207ms, 100.00%
正在校验...(Readback)
2255ms, 0.00%
.......
2500ms, 100.00%
编程成功
|