基于rtthread studio的STM32F407OTA升级(ymodem篇)
0、部分电路图
1、在线生成Bootloader
提示:
1M = 1024kB = 8 * 128 kB
128kB = 0x20000
此处,我将ROM按以下分区,大家可根据实际情况自行划分
按照上面分析,分区表配置为
2、烧录BootLoader
2.1、擦除芯片
2.2、烧录boot
2.3、烧录结束串口打印
3、配置工程
3.1、创建工程
3.2、配置cubemx
3.3、添加组件包
3.4、修改board.h
3.5、配置FAL文件
3.5.1、初始化Fal
3.5.2、新增/修改fal_cfg.h文件
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-11-05 YPD the first version
*/
#ifndef PACKAGES_FAL_V0_5_0_INC_FAL_CFG_H_
#define PACKAGES_FAL_V0_5_0_INC_FAL_CFG_H_
#include <rtthread.h>
#include "board.h"
#define FLASH_SIZE_GRANULARITY_16K (4 * 16 * 1024)
#define FLASH_SIZE_GRANULARITY_64K (64 * 1024)
#define FLASH_SIZE_GRANULARITY_128K (7 * 128 * 1024)
#define STM32_FLASH_START_ADRESS_16K STM32_FLASH_START_ADRESS
#define STM32_FLASH_START_ADRESS_64K (STM32_FLASH_START_ADRESS_16K + FLASH_SIZE_GRANULARITY_16K)
#define STM32_FLASH_START_ADRESS_128K (STM32_FLASH_START_ADRESS_64K + FLASH_SIZE_GRANULARITY_64K)
extern const struct fal_flash_dev stm32_onchip_flash_16k;
extern const struct fal_flash_dev stm32_onchip_flash_64k;
extern const struct fal_flash_dev stm32_onchip_flash_128k;
/* flash device table */
#define FAL_FLASH_DEV_TABLE \
{ \
&stm32_onchip_flash_128k, \
}
/* ====================== Partition Configuration ========================== */
#ifdef FAL_PART_HAS_TABLE_CFG
/* partition table */
#define FAL_PART_TABLE \
{ \
{FAL_PART_MAGIC_WROD, "app", "onchip_flash_128k", 0 , (3*128*1024), 0}, \
{FAL_PART_MAGIC_WROD, "download","onchip_flash_128k", (3*128*1024), (4*128*1024), 0}, \
}
#endif /* FAL_PART_HAS_TABLE_CFG */
#endif /* PACKAGES_FAL_V0_5_0_INC_FAL_CFG_H_ */
3.6、修改 app 固件配置
3.6.1、修改中断向量表的跳转基地址为 0x8020000。
#define RT_APP_PART_ADDR 0x8020000
static int ota_app_vtor_reconfig(void)
{
#define NVIC_VTOR_MASK 0x3FFFFF80
/* Set the Vector Table base location by user application firmware definition */
SCB->VTOR = RT_APP_PART_ADDR & NVIC_VTOR_MASK;
return 0;
}
INIT_BOARD_EXPORT(ota_app_vtor_reconfig);
3.6.2、修改app固件连接地址
3.7、编译下载
3.8、编译新固件
3.9、打包.rbl文件
4、通过ymodem进行升级
此处使用的是secureCRT工具