瑞萨单片机学习:RA4M3单片机 BOOTloader升级 跳转到主程序 主程序无法执行问题

本文主要是介绍瑞萨单片机学习:RA4M3单片机 BOOTloader升级 跳转到主程序 主程序无法执行问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 背景:

使用瑞萨的RA4M3单片机编写BOOT引导程序进行测试,在BOOT程序跳转到主程序时,主程序无法执行。本文介绍了问题的定位和解决方法。

运行开发环境介绍

硬件环境

RA4M3 官方开发板

J-LINK  V11  开发板自带

软件开发环境

e2 studio

VSCODE 

软件支持包灵活配置软件包 FSP 安装

 一开始从BOOT更新了APP FLASH后,然后跳转主程序APP地址,发现程序无法执行,注释掉下面的代码就可以。

SystemInit()

但是这样系统时钟没有经过初始化,延时函数会出问题。

后来 经过挨着注释  最好发现注释掉函数里的下面这行就能跳转了。

    /* Call Post C runtime initialization hook. */// R_BSP_WarmStart(BSP_WARM_START_POST_C);

/*******************************************************************************************************************//*** Initialize the MCU and the runtime environment.**********************************************************************************************************************/
void SystemInit (void)
{
//    *__Vectors =  (uint32_t * )0x00038000;
#if __FPU_USED/* Enable the FPU only when it is used.* Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C) *//* Set bits 20-23 (CP10 and CP11) to enable FPU. */SCB->CPACR = (uint32_t) CP_MASK;
#endif#if BSP_TZ_SECURE_BUILD/* Seal the main stack for secure projects. Reference:* https://developer.arm.com/documentation/100720/0300* https://developer.arm.com/support/arm-security-updates/armv8-m-stack-sealing */uint32_t * p_main_stack_top = (uint32_t *) __Vectors[0];*p_main_stack_top = BSP_TZ_STACK_SEAL_VALUE;
#endif#if !BSP_TZ_NONSECURE_BUILD/* VTOR is in undefined state out of RESET:* https://developer.arm.com/documentation/100235/0004/the-cortex-m33-peripherals/system-control-block/system-control-block-registers-summary?lang=en.* Set the Secure/Non-Secure VTOR to the vector table address based on the build. This is skipped for non-secure* projects because SCB_NS->VTOR is set by the secure project before the non-secure project runs. */
//    SCB->VTOR = (uint32_t) &__Vectors;SCB->VTOR = (uint32_t)&__Vectors;
#endif#if !BSP_TZ_CFG_SKIP_INIT#if BSP_FEATURE_BSP_VBATT_HAS_VBTCR1_BPWSWSTP/* Unlock VBTCR1 register. */R_SYSTEM->PRCR = (uint16_t) BSP_PRV_PRCR_PRC1_UNLOCK;/* The VBTCR1.BPWSWSTP must be set after reset on MCUs that have VBTCR1.BPWSWSTP. Reference section 11.2.1* "VBATT Control Register 1 (VBTCR1)" and Figure 11.2 "Setting flow of the VBTCR1.BPWSWSTP bit" in the RA4M1 manual* R01UM0007EU0110. This must be done before bsp_clock_init because LOCOCR, LOCOUTCR, SOSCCR, and SOMCR cannot* be accessed until VBTSR.VBTRVLD is set. */R_SYSTEM->VBTCR1 = 1U;FSP_HARDWARE_REGISTER_WAIT(R_SYSTEM->VBTSR_b.VBTRVLD, 1U);/* Lock VBTCR1 register. */R_SYSTEM->PRCR = (uint16_t) BSP_PRV_PRCR_LOCK;#endif
#endif#if BSP_FEATURE_TFU_SUPPORTEDR_BSP_MODULE_START(FSP_IP_TFU, 0U);
#endif#if BSP_CFG_EARLY_INIT/* Initialize uninitialized BSP variables early for use in R_BSP_WarmStart. */bsp_init_uninitialized_vars();
#endif/* Call pre clock initialization hook. */R_BSP_WarmStart(BSP_WARM_START_RESET);#if BSP_TZ_CFG_SKIP_INIT/* Initialize clock variables to be used with R_BSP_SoftwareDelay. */bsp_clock_freq_var_init();
#else/* Configure system clocks. */bsp_clock_init();#if BSP_FEATURE_BSP_RESET_TRNG/* To prevent an undesired current draw, this MCU requires a reset* of the TRNG circuit after the clocks are initialized */bsp_reset_trng_circuit();#endif
#endif/* Call post clock initialization hook. */R_BSP_WarmStart(BSP_WARM_START_POST_CLOCK);#if BSP_FEATURE_BSP_HAS_SP_MON/* Disable MSP monitoring  */R_MPU_SPMON->SP[0].CTL = 0;/* Setup NMI interrupt  */R_MPU_SPMON->SP[0].OAD = BSP_STACK_POINTER_MONITOR_NMI_ON_DETECTION;/* Setup start address  */R_MPU_SPMON->SP[0].SA = BSP_PRV_STACK_LIMIT;/* Setup end address  */R_MPU_SPMON->SP[0].EA = BSP_PRV_STACK_TOP;/* Set SPEEN bit to enable NMI on stack monitor exception. NMIER bits cannot be cleared after reset, so no need* to read-modify-write. */R_ICU->NMIER = R_ICU_NMIER_SPEEN_Msk;/* Enable MSP monitoring  */R_MPU_SPMON->SP[0].CTL = 1U;
#endif#if BSP_FEATURE_TZ_HAS_TRUSTZONE/* Use CM33 stack monitor. */__set_MSPLIM(BSP_PRV_STACK_LIMIT);
//    __set_MSPLIM(0);
#endif#if BSP_CFG_C_RUNTIME_INIT/* Initialize C runtime environment. *//* Zero out BSS */#if defined(__ARMCC_VERSION)memset((uint8_t *) &Image$$BSS$$ZI$$Base, 0U, (uint32_t) &Image$$BSS$$ZI$$Length);#elif defined(__GNUC__)memset(&__bss_start__, 0U, ((uint32_t) &__bss_end__ - (uint32_t) &__bss_start__));#elif defined(__ICCARM__)memset((uint32_t *) __section_begin(".bss"), 0U, (uint32_t) __section_size(".bss"));#endif/* Copy initialized RAM data from ROM to RAM. */#if defined(__ARMCC_VERSION)memcpy((uint8_t *) &Image$$DATA$$Base, (uint8_t *) &Load$$DATA$$Base, (uint32_t) &Image$$DATA$$Length);#elif defined(__GNUC__)memcpy(&__data_start__, &__etext, ((uint32_t) &__data_end__ - (uint32_t) &__data_start__));#elif defined(__ICCARM__)memcpy((uint32_t *) __section_begin(".data"), (uint32_t *) __section_begin(".data_init"),(uint32_t) __section_size(".data"));/* Copy functions to be executed from RAM. */#pragma section=".code_in_ram"#pragma section=".code_in_ram_init"memcpy((uint32_t *) __section_begin(".code_in_ram"),(uint32_t *) __section_begin(".code_in_ram_init"),(uint32_t) __section_size(".code_in_ram"));/* Copy main thread TLS to RAM. */#pragma section="__DLIB_PERTHREAD_init"#pragma section="__DLIB_PERTHREAD"memcpy((uint32_t *) __section_begin("__DLIB_PERTHREAD"), (uint32_t *) __section_begin("__DLIB_PERTHREAD_init"),(uint32_t) __section_size("__DLIB_PERTHREAD_init"));#endif/* Initialize static constructors */#if defined(__ARMCC_VERSION)int32_t count = Image$$INIT_ARRAY$$Limit - Image$$INIT_ARRAY$$Base;for (int32_t i = 0; i < count; i++){void (* p_init_func)(void) =(void (*)(void))((uint32_t) &Image$$INIT_ARRAY$$Base + (uint32_t) Image$$INIT_ARRAY$$Base[i]);p_init_func();}#elif defined(__GNUC__)int32_t count = __init_array_end - __init_array_start;for (int32_t i = 0; i < count; i++){__init_array_start[i]();}#elif defined(__ICCARM__)void const * pibase = __section_begin("SHT$$PREINIT_ARRAY");void const * ilimit = __section_end("SHT$$INIT_ARRAY");__call_ctors(pibase, ilimit);#endif
#endif                                 // BSP_CFG_C_RUNTIME_INIT/* Initialize SystemCoreClock variable. */SystemCoreClockUpdate();#if !BSP_CFG_PFS_PROTECT#if BSP_TZ_SECURE_BUILDR_PMISC->PWPRS = 0;                              ///< Clear BOWI bit - writing to PFSWE bit enabledR_PMISC->PWPRS = 1U << BSP_IO_PWPR_PFSWE_OFFSET; ///< Set PFSWE bit - writing to PFS register enabled#elseR_PMISC->PWPR = 0;                               ///< Clear BOWI bit - writing to PFSWE bit enabledR_PMISC->PWPR = 1U << BSP_IO_PWPR_PFSWE_OFFSET;  ///< Set PFSWE bit - writing to PFS register enabled#endif
#endif#if FSP_PRIV_TZ_USE_SECURE_REGS/* Ensure that the PMSAR registers are reset (Soft reset does not reset PMSAR). */R_BSP_RegisterProtectDisable(BSP_REG_PROTECT_SAR);for (uint32_t i = 0; i < 9; i++){R_PMISC->PMSAR[i].PMSAR = UINT16_MAX;}R_BSP_RegisterProtectEnable(BSP_REG_PROTECT_SAR);
#endif#if BSP_TZ_SECURE_BUILD/* Initialize security features. */R_BSP_SecurityInit();
#endif/* Call Post C runtime initialization hook. */// R_BSP_WarmStart(BSP_WARM_START_POST_C);/* Initialize ELC events that will be used to trigger NVIC interrupts. */bsp_irq_cfg();/* Call any BSP specific code. No arguments are needed so NULL is sent. */bsp_init(NULL);
}

这篇关于瑞萨单片机学习:RA4M3单片机 BOOTloader升级 跳转到主程序 主程序无法执行问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/503912

相关文章

numpy求解线性代数相关问题

《numpy求解线性代数相关问题》本文主要介绍了numpy求解线性代数相关问题,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 在numpy中有numpy.array类型和numpy.mat类型,前者是数组类型,后者是矩阵类型。数组

解决systemctl reload nginx重启Nginx服务报错:Job for nginx.service invalid问题

《解决systemctlreloadnginx重启Nginx服务报错:Jobfornginx.serviceinvalid问题》文章描述了通过`systemctlstatusnginx.se... 目录systemctl reload nginx重启Nginx服务报错:Job for nginx.javas

怎么关闭Ubuntu无人值守升级? Ubuntu禁止自动更新的技巧

《怎么关闭Ubuntu无人值守升级?Ubuntu禁止自动更新的技巧》UbuntuLinux系统禁止自动更新的时候,提示“无人值守升级在关机期间,请不要关闭计算机进程”,该怎么解决这个问题?详细请看... 本教程教你如何处理无人值守的升级,即 Ubuntu linux 的自动系统更新。来源:https://

Redis缓存问题与缓存更新机制详解

《Redis缓存问题与缓存更新机制详解》本文主要介绍了缓存问题及其解决方案,包括缓存穿透、缓存击穿、缓存雪崩等问题的成因以及相应的预防和解决方法,同时,还详细探讨了缓存更新机制,包括不同情况下的缓存更... 目录一、缓存问题1.1 缓存穿透1.1.1 问题来源1.1.2 解决方案1.2 缓存击穿1.2.1

vue解决子组件样式覆盖问题scoped deep

《vue解决子组件样式覆盖问题scopeddeep》文章主要介绍了在Vue项目中处理全局样式和局部样式的方法,包括使用scoped属性和深度选择器(/deep/)来覆盖子组件的样式,作者建议所有组件... 目录前言scoped分析deep分析使用总结所有组件必须加scoped父组件覆盖子组件使用deep前言

解决Cron定时任务中Pytest脚本无法发送邮件的问题

《解决Cron定时任务中Pytest脚本无法发送邮件的问题》文章探讨解决在Cron定时任务中运行Pytest脚本时邮件发送失败的问题,先优化环境变量,再检查Pytest邮件配置,接着配置文件确保SMT... 目录引言1. 环境变量优化:确保Cron任务可以正确执行解决方案:1.1. 创建一个脚本1.2. 修

Python 标准库time时间的访问和转换问题小结

《Python标准库time时间的访问和转换问题小结》time模块为Python提供了处理时间和日期的多种功能,适用于多种与时间相关的场景,包括获取当前时间、格式化时间、暂停程序执行、计算程序运行时... 目录模块介绍使用场景主要类主要函数 - time()- sleep()- localtime()- g

SpringBoot项目删除Bean或者不加载Bean的问题解决

《SpringBoot项目删除Bean或者不加载Bean的问题解决》文章介绍了在SpringBoot项目中如何使用@ComponentScan注解和自定义过滤器实现不加载某些Bean的方法,本文通过实... 使用@ComponentScan注解中的@ComponentScan.Filter标记不加载。@C

VMWare报错“指定的文件不是虚拟磁盘“或“The file specified is not a virtual disk”问题

《VMWare报错“指定的文件不是虚拟磁盘“或“Thefilespecifiedisnotavirtualdisk”问题》文章描述了如何修复VMware虚拟机中出现的“指定的文件不是虚拟... 目录VMWare报错“指定的文件不是虚拟磁盘“或“The file specified is not a virt

Mybatis提示Tag name expected的问题及解决

《Mybatis提示Tagnameexpected的问题及解决》MyBatis是一个开源的Java持久层框架,用于将Java对象与数据库表进行映射,它提供了一种简单、灵活的方式来访问数据库,同时也... 目录概念说明MyBATis特点发现问题解决问题第一种方式第二种方式问题总结概念说明MyBatis(原名