瑞萨单片机学习: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

相关文章

HarmonyOS学习(七)——UI(五)常用布局总结

自适应布局 1.1、线性布局(LinearLayout) 通过线性容器Row和Column实现线性布局。Column容器内的子组件按照垂直方向排列,Row组件中的子组件按照水平方向排列。 属性说明space通过space参数设置主轴上子组件的间距,达到各子组件在排列上的等间距效果alignItems设置子组件在交叉轴上的对齐方式,且在各类尺寸屏幕上表现一致,其中交叉轴为垂直时,取值为Vert

Ilya-AI分享的他在OpenAI学习到的15个提示工程技巧

Ilya(不是本人,claude AI)在社交媒体上分享了他在OpenAI学习到的15个Prompt撰写技巧。 以下是详细的内容: 提示精确化:在编写提示时,力求表达清晰准确。清楚地阐述任务需求和概念定义至关重要。例:不用"分析文本",而用"判断这段话的情感倾向:积极、消极还是中性"。 快速迭代:善于快速连续调整提示。熟练的提示工程师能够灵活地进行多轮优化。例:从"总结文章"到"用

【前端学习】AntV G6-08 深入图形与图形分组、自定义节点、节点动画(下)

【课程链接】 AntV G6:深入图形与图形分组、自定义节点、节点动画(下)_哔哩哔哩_bilibili 本章十吾老师讲解了一个复杂的自定义节点中,应该怎样去计算和绘制图形,如何给一个图形制作不间断的动画,以及在鼠标事件之后产生动画。(有点难,需要好好理解) <!DOCTYPE html><html><head><meta charset="UTF-8"><title>06

学习hash总结

2014/1/29/   最近刚开始学hash,名字很陌生,但是hash的思想却很熟悉,以前早就做过此类的题,但是不知道这就是hash思想而已,说白了hash就是一个映射,往往灵活利用数组的下标来实现算法,hash的作用:1、判重;2、统计次数;

好题——hdu2522(小数问题:求1/n的第一个循环节)

好喜欢这题,第一次做小数问题,一开始真心没思路,然后参考了网上的一些资料。 知识点***********************************无限不循环小数即无理数,不能写作两整数之比*****************************(一开始没想到,小学没学好) 此题1/n肯定是一个有限循环小数,了解这些后就能做此题了。 按照除法的机制,用一个函数表示出来就可以了,代码如下

hdu1043(八数码问题,广搜 + hash(实现状态压缩) )

利用康拓展开将一个排列映射成一个自然数,然后就变成了普通的广搜题。 #include<iostream>#include<algorithm>#include<string>#include<stack>#include<queue>#include<map>#include<stdio.h>#include<stdlib.h>#include<ctype.h>#inclu

三国地理揭秘:为何北伐之路如此艰难,为何诸葛亮无法攻克陇右小城?

俗话说:天时不如地利,不是随便说说,诸葛亮六出祁山,连关中陇右的几座小城都攻不下来,行军山高路险,无法携带和建造攻城器械,是最难的,所以在汉中,无论从哪一方进攻,防守方都是一夫当关,万夫莫开;再加上千里运粮,根本不需要打,司马懿只需要坚守城池拼消耗就能不战而屈人之兵。 另一边,洛阳的虎牢关,一旦突破,洛阳就无险可守,这样的进军路线,才是顺势而为的用兵之道。 读历史的时候我们常常看到某一方势

零基础学习Redis(10) -- zset类型命令使用

zset是有序集合,内部除了存储元素外,还会存储一个score,存储在zset中的元素会按照score的大小升序排列,不同元素的score可以重复,score相同的元素会按照元素的字典序排列。 1. zset常用命令 1.1 zadd  zadd key [NX | XX] [GT | LT]   [CH] [INCR] score member [score member ...]

购买磨轮平衡机时应该注意什么问题和技巧

在购买磨轮平衡机时,您应该注意以下几个关键点: 平衡精度 平衡精度是衡量平衡机性能的核心指标,直接影响到不平衡量的检测与校准的准确性,从而决定磨轮的振动和噪声水平。高精度的平衡机能显著减少振动和噪声,提高磨削加工的精度。 转速范围 宽广的转速范围意味着平衡机能够处理更多种类的磨轮,适应不同的工作条件和规格要求。 振动监测能力 振动监测能力是评估平衡机性能的重要因素。通过传感器实时监

【机器学习】高斯过程的基本概念和应用领域以及在python中的实例

引言 高斯过程(Gaussian Process,简称GP)是一种概率模型,用于描述一组随机变量的联合概率分布,其中任何一个有限维度的子集都具有高斯分布 文章目录 引言一、高斯过程1.1 基本定义1.1.1 随机过程1.1.2 高斯分布 1.2 高斯过程的特性1.2.1 联合高斯性1.2.2 均值函数1.2.3 协方差函数(或核函数) 1.3 核函数1.4 高斯过程回归(Gauss