项目实战:基于瑞萨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

相关推荐
csdn_aspnet35 分钟前
嵌入式赋能生活的各个领域
嵌入式·生活
yuan1999740 分钟前
AD7689 12位串行ADC驱动与应用
单片机·嵌入式硬件
磨十三1 小时前
MCU 时钟系统全解析:主时钟、PLL、分频与外设时钟门控
arm开发·单片机·嵌入式硬件
DIY机器人工房2 小时前
嵌入式面试题:电容滤波,低频高频谁来滤?放置顺序怎么定?
stm32·单片机·嵌入式硬件·diy机器人工房
学习路上_write2 小时前
嵌入式系统bringup指南:软硬件调试
c语言·单片机·嵌入式硬件
磨十三4 小时前
ARM Cortex-M 系列 MCU:内核、指令、异常与中断解析
arm开发·单片机·嵌入式硬件
罗汉松(山水白河)5 小时前
关于串口与UDP通讯的实验
单片机·嵌入式硬件·网络协议·udp·tcp·串口、
d111111111d6 小时前
STM32外设--SPI读取W25Q64(学习笔记)硬件SPI
笔记·stm32·单片机·嵌入式硬件·学习
steins_甲乙8 小时前
stm32入门篇(6)
stm32·单片机·嵌入式硬件
刻BITTER18 小时前
用EXCEL 将单色屏幕的Bitmap 字模数据还原回图形
单片机·嵌入式硬件·excel·arduino