项目实战:基于瑞萨RA6M5构建多节点OTA升级-创建工程MCUBoot<二>

项目系统架构搭好了,咱们就开始动手实践吧!

实现固件升级需要用到UBoot引导加载程序,因此,首先我们先创建一个项目实现UBoot功能。

目录

一、新建项目配置

二、新增MCUBoot

三、配置MCUBoot属性

四、配置项目属性

五、编写启动函数

六、编译工程

七、编译问题解决

八、工程源码


一、新建项目配置

项目在e2 studio创建,创建过程不再详述啦!FSP版本不必纠结,基本上大同小异变化不是太大,推荐使用近期发行的版本。项目配置信息如下:

二、新增MCUBoot

添加模块:

三、配置MCUBoot属性

Downgrade Prevention(Overwrite Only):设置为Disabled,关闭是为了日后异常可以灵活处理,回退版本。

Signing and Encryption Options选项下的内容没有启用,固件需要加密打包的,就没有必要使用签名加密了。

配置g_flash0属性:

关闭掉Data Flash Programming Enable可以减少固件尺寸,在项目中也用不到data flash。

配置完成,点击生成项目内容:

四、配置项目属性

配置完成后,点击应用关闭。

五、编写启动函数

在hal_entry.c中编写函数mcuboot_quick_setup

cpp 复制代码
void mcuboot_quick_setup()
{
#ifdef MCUBOOT_USE_MBED_TLS

    /* Initialize mbedtls. */
    mbedtls_platform_context ctx = {0};
    assert(0 == mbedtls_platform_setup(&ctx));
#elif (defined(MCUBOOT_USE_TINYCRYPT) && defined(RM_MCUBOOT_PORT_USE_TINYCRYPT_ACCELERATION))

    /* Initialize TinyCrypt port. */
    assert(FSP_SUCCESS == RM_TINCYRYPT_PORT_Init());
#elif (defined(MCUBOOT_USE_USER_DEFINED_CRYPTO_STACK))

/* Initialize Custom Crypto (Protected Mode) driver. */
    assert(FSP_SUCCESS == R_SCE_Open(&sce_ctrl, &sce_cfg));
#endif

    /* (Optional, not required if --pad is used during signing) To check for updates, call boot_set_pending. */
    bool update = 0;
    if (update)
    {
        boot_set_pending(0);
    }

    /* Verify the boot image and get its location. */
    struct boot_rsp rsp;
    assert(0 == boot_go(&rsp));

    /* Enter the application. */
    RM_MCUBOOT_PORT_BootApp(&rsp);
}
/*******************************************************************************************************************//**
 * main() is generated by the RA Configuration editor and is used to generate threads if an RTOS is used.  This function
 * is called by main() when no RTOS is used.
 **********************************************************************************************************************/
void hal_entry(void)
{
    /* TODO: add your own code here */
    mcuboot_quick_setup();
#if BSP_TZ_SECURE_BUILD
    /* Enter non-secure code */
    R_BSP_NonSecureEnter();
#endif
}

六、编译工程

编译输出结果:

七、编译问题解决

使用FSP5.1编译会出现找不到头文件rm_tinycrypt_port_cfg.h,用来做加密配置的,咱也没用到,注释掉就行啦!

八、工程源码

RA6M5_MCUBoot工程源代码https://download.csdn.net/download/xtudj/90492983

相关推荐
光芒Shine1 小时前
【STM32-代码】
stm32·单片机·嵌入式硬件
无垠的广袤1 小时前
【树莓派 PICO 2 测评】采集 DS18B20 数据及 OLED 显示
单片机·嵌入式硬件·物联网
冻结的鱼1 小时前
两个 STM32G0 I2C 通信异常的案例分析
stm32·单片机·嵌入式硬件
总结所学2 小时前
arm_math.h、arm_const_structs.h 和 arm_common_tables.h
arm开发·单片机·嵌入式硬件
Wythzhfrey3 小时前
单片机Day05---静态数码管
c语言·单片机·嵌入式硬件·学习·c#·51单片机
KaiGer6663 小时前
AUTOSAR图解==>AUTOSAR_SWS_GPTDriver
单片机·汽车·嵌入式·autosar
厉昱辰4 小时前
STM32F103C8T6 单片机入门基础知识及点亮第一个 LED 灯
stm32·单片机·嵌入式硬件
夜月yeyue4 小时前
STM32启动流程详解
linux·c++·stm32·单片机·嵌入式硬件·c#
夜月yeyue4 小时前
VScode+OpenOCD+HTOS栈回溯在国产mcu芯片上完全调试
c语言·ide·vscode·单片机·嵌入式硬件·编辑器
Yesheldon4 小时前
高速电路中的电感、磁珠的选型及应用
单片机·嵌入式硬件·硬件架构·硬件工程·智能硬件