xtaens 发表于 2015-8-26 14:16:50

【IAP】LPC1788 IAP后读写、校验都正确后在跳转时跳不过去,...

我用IAR,lpc1788上做好了iap,在跳转到app时却一直跳不过去,跳完后还是在Bootloader中,且从Bootloader的开始处执行了,似乎把Bootloader程序复位了一样。

哪位遇到过这个问题呢?怎么解决?

谢谢

下面是我的跳转代码:

void _Boot(uint32_t address)
{
asm("ldr SP, ");    //Load new stack pointer address
asm("ldr PC, ");//Load new program counter address
}
uint8_t ExceuteApplication(void)
{
uint8_t tmp;

/* Disable all interrupts */
NVIC->ICER = 0xFFFFFFFF;
NVIC->ICER = 0x00000001;
/* Clear all pending interrupts */
NVIC->ICPR = 0xFFFFFFFF;
NVIC->ICPR = 0x00000001;

/* Clear all interrupt priority */
for (tmp = 0; tmp < 32; tmp++)
{
    NVIC->IP = 0x00;
}

SCB->ICSR = 0x0A000000;
SCB->VTOR = 0x00000000;
SCB->AIRCR = 0x05FA0000;
SCB->SCR = 0x00000000;
SCB->CCR = 0x00000000;

for (tmp = 0; tmp < 32; tmp++)
{
    SCB->SHP = 0x00;
}

SCB->SHCSR = 0x00000000;
SCB->CFSR = 0xFFFFFFFF;
SCB->HFSR = 0xFFFFFFFF;
SCB->DFSR = 0xFFFFFFFF;

//开始跳转
SCB->VTOR= ApplicationAddress;
_Boot(ApplicationAddress);
}

xtaens 发表于 2015-8-26 22:05:39

我来顶顶,不要沉下去啊

xtaens 发表于 2015-8-27 08:51:25

{:cry:}{:cry:}{:cry:}{:cry:}{:cry:}{:cry:}

难道没有人遇到过这个问题??

xtaens 发表于 2015-8-27 16:58:52

原因已经找到啦:是IAR ARM编译器编译的bin有问题。即只要设置了中断向量偏移地址,不管是生成的hex还是bin文件都有问题,前面一段全是0,用jlink直接下载bin或hex,程序无法运行。但是用仿真的方式下载,不管是否有偏移,程序都运行良好。


这个现象有人遇到过吗?

下面的是有偏移和无偏移bin文件比较。有偏移的文件无法运行。

xtaens 发表于 2015-8-27 17:03:58

附上我的icf文件:

我的iar 是6.4版本,用该版本编译stm32,设置或不设置偏移编译的bin,hex都没有问题,直接下载后就可以运行。

如此看软件是没有问题,很有可能是icf不对?

/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__   = 0x0007FFFB;
define symbol __ICFEDIT_region_RAM_start__ = 0x10000000;
define symbol __ICFEDIT_region_RAM_end__   = 0x1000FFDF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x2000;
define symbol __ICFEDIT_size_heap__   = 0x500;
/**** End of ICF editor section. ###ICF###*/

define symbol __CRP_start__   = 0x000002FC;
define symbol __CRP_end__   = 0x000002FF;

define symbol __RAM1_start__= 0x20000000;
define symbol __RAM1_end__    = 0x20007FFF;

define memory mem with size = 4G;
define region ROM_region   = mem: -mem:;
define region RAM_region   = mem:;
define region CRP_region   = mem:;
define region RAM1_region= mem:;

define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__   { };

initialize by copy { readwrite };
do not initialize{ section .noinit };

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region   { readonly };
place in RAM_region   { readwrite,
                        block CSTACK, block HEAP };
place in CRP_region        { section .crp };
place in RAM1_region        { section .sram };

xtaens 发表于 2015-8-28 09:09:31

没有新的发现,谁遇到过这个现象吗{:sad:}

LeiR 发表于 2015-9-7 10:06:56

本帖最后由 LeiR 于 2015-9-7 10:10 编辑

代码自己做Bootloader+Application两个工程:

1)、Bootloader:跳转到Application前,先关中断,再跳转;这样可以避免跳转前产生中断,而中断向量表还在使用Bootloader;
2)、Application:主要有二个工作:1、设置VTOR(可以设置在RAM中,也可以设置flash,这里假定在FLASH中);2、在分散加载文件中,设置Flash的起始地址。注意:这两个flash的超始地址必须一致。

xtaens 发表于 2015-10-10 11:00:47

LeiR 发表于 2015-9-7 10:06
代码自己做Bootloader+Application两个工程:

1)、Bootloader:跳转到Application前,先关中断,再跳转; ...

嗯,谢谢

问题已经解决,是我把app的地址和写的程序地址没有弄一致,运行app后就直接复位了{:sweat:}

LeiR 发表于 2015-10-16 00:02:17

xtaens 发表于 2015-10-10 11:00
嗯,谢谢

问题已经解决,是我把app的地址和写的程序地址没有弄一致,运行app后就直接复位了...

解决了就好
页: [1]
查看完整版本: 【IAP】LPC1788 IAP后读写、校验都正确后在跳转时跳不过去,...