TI中文支持网
TI专业的中文技术问题搜集分享网站

AM335x裸机开发:如何在程序代码中实现软件复位?

开发硬件:BBB外接SPI FLASH;

开发软件: CCS; AM335X_StarterWare;

参考AM335X_StarterWare,建立CCS裸机工程:

工程1:RBL工程:BOOT上电启动(从SPI FLASH里加载代码到内部RAM运行); 内部RAM空间;

工程2:APP工程:RBL工程代码实现从SPI FLASH里加载APP并跳转运行; 外部DDR空间;

APP工程是应用工程,相比RBL工程,使能了MMU和CACHE等;

在APP代码中,实现软件复位:

(*(void (*)(void))(0x40020000);//参考TRM. Memory Map: Boot ROM 开始地址;

正常应该会复位重启,但实际没有;

请问如何才能在应用程序中实现软件复位?谢谢!

附:

工程1:RBL主函数为:

intmain(void)

{

BlPlatformConfig(); // Configures PLL and DDR controller

    ImageCopy();  // Copies application from spi flash to DDR

   UARTPuts("Jumping to StarterWare Application…\r\n\n", -1);

    /* Giving control to the application */

    appEntry = (void (*)(void)) entryPoint;

    (*appEntry)( );

   return 0;

}

工程2:APP复位函数为:

intSoftReset(void)

{

       CacheDisable(CACHE_ALL); // 调试测试,关闭CACHE;

        IntMasterIRQDisable();//调试测试,关闭总中断;

        IntAINTCInit();//调试测试,初始化中断;

       

///   WdtSoftReset(); // 用看门狗可以复位;

 

// 跳转到复位

    // (*(void (*)(void))(0x40000000))();

    //  (*(void (*)(void))(0x402F0400))();

   //  (*(void (*)(void))(0x40020000))();

    //  (*(void (*)(void))(0x402F0400))();

// ((void(*)(void))0x40020000)();

 

 (*(void (*)(void))(0x40020000))();

   for(;;);

   return 0;

}

Shine:

请问PC指针跳转到0x40020000 ROM地址执行RBL了吗?

user4467014:

回复 Shine:

感谢回复!  跳转RBL地址也没有用,现象一样,并没有复位重新运行。谢谢!

Shine:

回复 user4467014:

您的意思是PC指针跳转到0x40020000执行RBL没有去重新搬移代码?

user4467014:

回复 Shine:

感谢回复!应该是没有重新搬移代码,因为没有看到RBL工程的打印信息.

user4467014:

回复 user4467014:

另外,我在复位或者跳转前,参考UBOOT跳转前,调用了禁用CACHE等操作(如下),还是不能正常跳转.

void cleanup_before_jump(void)
{/** Turn off I-cache and invalidate it*/CacheDisable(CACHE_ICACHE); ///icache_disable();CacheInstInvalidateAll(); /// invalidate_icache_all();
/** turn off D-cache* dcache_disable() in turn flushes the d-cache and disables MMU*/CacheDisable(CACHE_DCACHE); /// dcache_disable();///MMUDisable();CacheDataCleanAll();///v7_outer_cache_disable();CacheDataInvalidateAll();///invalidate_dcache_all();
/** After D-cache is flushed and before it is disabled there may* be some new valid entries brought into the cache. We are sure* that these lines are not dirty and will not affect our execution.* (because unwinding the call-stack and setting a bit in CP15 SCTRL* is all we did during this. We have not pushed anything on to the* stack. Neither have we affected any static data)* So just invalidate the entire d-cache again to avoid coherency* problems for kernel*/CacheDataInvalidateAll();///invalidate_dcache_all();
/** Some CPU need more cache attention before starting the kernel.*////cpu_cache_initialization();
}

Shine:

回复 user4467014:

请看一下Global Cold Software Reset (GLOBAL_COLD_SW_RST) 位?

另外,我们一般是用watchdog来复位CPU的,请参考pdk_am335x_1_0_xx\packages\ti\starterware\examples\wdt\cpu_reset。

user4467014:

回复 Shine:

感谢回复!我问题里有描述: ///WdtSoftReset(); // 用看门狗可以复位;
其实本意是想软件跳转到另外一个app工程,为了咨询问题简单化,我就询问如果能软件跳转复位(因为我发现APP里软件跳转复位都不行.);
谢谢!

Shine:

回复 user4467014:

Global Cold Software Reset (GLOBAL_COLD_SW_RST)这个位有查看过吗?

user4467014:

回复 Shine:

感谢回复! 看门狗可以实现复位, 而我是想软件指令跳转复位;因为我本意是要跳转到另外一个app工程(DDR单独分配了一个区间). 我发现跳转不了时,我就尝试APP软件跳转复位,发现也不行, 就咨询如何能软件跳转复位地址; 如果能实现,那我也就可以跳转到另外一个APP工程了.
谢谢!

赞(0)
未经允许不得转载:TI中文支持网 » AM335x裸机开发:如何在程序代码中实现软件复位?
分享到: 更多 (0)