cmiot_fal.h 源码
2026/7/20大约 1 分钟附录源码附录OTAFAL
cmiot_fal.h — OTA Flash 抽象层接口头文件
路径: components/ota/cmiot/port/cmiot_fal.h
功能: OTA 远程升级组件的 Flash 抽象层(FAL)接口声明,将 OTA 需要的 Flash 分区操作(查找、读、写、擦除)映射到 OneOS FAL 框架。
引用章节: 7.8 OTA 远程升级组件 | 5.17 FAL Flash抽象层
完整源码
/**
***********************************************************************************************************************
* Copyright (c) 2021, China Mobile Communications Group Co.,Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* @file cmiot_fal.h
*
* @brief Interface related to OS.
*
* @revision
* Date Author Notes
* 2021-04-09 OneOS Team First version.
***********************************************************************************************************************/
#ifndef __CMIOT_FAL_H__
#define __CMIOT_FAL_H__
#include <stdint.h>
#include <stddef.h>
#include "cmiot_type.h"
#if defined(__cplusplus)
extern "C" {
#endif
void *cmiot_ota_fal_part_find(cmiot_char *name);
cmiot_int32 cmiot_ota_fal_part_read(void *part, cmiot_uint32 addr, cmiot_char *buf, cmiot_uint32 size);
cmiot_int32 cmiot_ota_fal_part_write(void *part, cmiot_uint32 addr, cmiot_char *buf, cmiot_uint32 size);
cmiot_int32 cmiot_ota_fal_part_erase(void *part, cmiot_uint32 addr, size_t size);
void *cmiot_hal_get_device(cmiot_uint8 type);
cmiot_uint32 cmiot_hal_get_true_blocksize(cmiot_uint8 type);
cmiot_uint32 cmiot_hal_get_true_pagesize(cmiot_uint8 type);
cmiot_uint32 cmiot_hal_get_download_size(void);
cmiot_uint32 cmiot_hal_get_delta_addr(void);
#if defined(__cplusplus)
}
#endif
#endif /* __CMIOT_FAL_H__ */关键说明
| 模块 | 说明 |
|---|---|
| 分区操作 | cmiot_ota_fal_part_* 系列函数封装 FAL 分区的查找、读、写、擦除操作 |
| 硬件抽象 | cmiot_hal_get_device 根据文件类型(补丁/补丁信息)获取对应 Flash 分区 |
| 块大小 | cmiot_hal_get_true_blocksize 获取实际 Flash 块大小(最小 1024 字节) |
| 页大小 | cmiot_hal_get_true_pagesize 获取 Flash 页大小,用于差分算法的最小写入单位 |
| 下载区域 | cmiot_hal_get_download_size / `cmiot_hal_get_d |