浅析NRF51822合并文件之app_valid_setting_apply
【原创出品§转载请注明出处】
出处:http://www.cnblogs.com/libra13179/p/5787084.html
我们打开app_valid_setting_apply.hex如下
:0003F7
:FC000100000000000000FE000000FFFFFFFFF9
:FF
分析如下
对数据帧结构
|
补充
数据类型
'00' Data Rrecord:用来记录数据,HEX文件的大部分记录都是数据记录
'01' End of File Record:用来标识文件结束,放在文件的最后,标识HEX文件的结尾
'02' Extended Segment Address Record:用来标识扩展段地址的记录
'03' Start Segment Address Record:开始段地址记录
'04' Extended Linear Address Record:用来标识扩展线性地址的记录
'05' Start Linear Address Record:开始线性地址记录
好了现在正式开始
:02000004F7
:10FC00000100000000000000FE000000FFFFFFFFF9
:00000001FF :020000040008F2
: FF00A0E314209FE5001092E5011092E5 A3
:00000001FF
对上面的HEX文件进行分析:
第1条记录的长度为,LOAD OFFSET为,RECTYPE为,说明该记录为扩展段地址记录。数据为0003,校验和为F7。
从这个记录的长度和数据,我们可以计算出一个基地址,这个地址为(0x0003 << )。后面的数据记录都以这个地址为基地址。
第2条记录的长度为(),LOAD OFFSET为FC00,RECTYPE为,说明该记录为数据记录。数据为0100000000000000FE000000FFFFFFFF,共16个BYTE。这个记录的校验和为F9。
此时的基地址为0X30000,加上OFFSET,这个记录里的16BYTE的数据的起始地址就是0x30000 + 0xFC00 = 0x3FC00.
第3条记录的长度为00,LOAD OFFSET为0000,TYPE= ,校验和为FF。说明这个是一个END OF FILE RECORD,标识文件的结尾。
问题来了这个0x3FC00是什么鬼??
在dfu_types.H文件中
#ifdef NRF51
#ifdef SIGNING
#define BOOTLOADER_REGION_START 0x00039C00 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
#define BOOTLOADER_SETTINGS_ADDRESS 0x0003D800 /**< The field specifies the page location of the bootloader settings address. */
#else
#define BOOTLOADER_REGION_START 0x0003C000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
#define BOOTLOADER_SETTINGS_ADDRESS 0x0003FC00 /**< The field specifies the page location of the bootloader settings address. */
#endif #define CODE_PAGE_SIZE 0x0400 /**< Size of a flash codepage. Used for size of the reserved flash space in the bootloader region. Will be runtime checked against NRF_UICR->CODEPAGESIZE to ensure the region is correct. */
#elif NRF52
#define BOOTLOADER_REGION_START 0x0007B000 /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
#define BOOTLOADER_SETTINGS_ADDRESS 0x0007F000 /**< The field specifies the page location of the bootloader settings address. */
#define CODE_PAGE_SIZE 0x1000 /**< Size of a flash codepage. Used for size of the reserved flash space in the bootloader region. Will be runtime checked against NRF_UICR->CODEPAGESIZE to ensure the region is correct. */
#else
#error No target defined
#endif
我们继续跟踪
#if defined ( __CC_ARM )
uint8_t m_boot_settings[CODE_PAGE_SIZE] __attribute__((at(BOOTLOADER_SETTINGS_ADDRESS))) __attribute__((used)); /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
uint32_t m_uicr_bootloader_start_address __attribute__((at(NRF_UICR_BOOT_START_ADDRESS))) = BOOTLOADER_REGION_START; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
#elif defined ( __GNUC__ )
__attribute__ ((section(".bootloaderSettings"))) uint8_t m_boot_settings[CODE_PAGE_SIZE]; /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
__attribute__ ((section(".uicrBootStartAddress"))) volatile uint32_t m_uicr_bootloader_start_address = BOOTLOADER_REGION_START; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
#elif defined ( __ICCARM__ )
__no_init uint8_t m_boot_settings[CODE_PAGE_SIZE] @ 0x0003FC00; /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
__root const uint32_t m_uicr_bootloader_start_address @ 0x10001014 = BOOTLOADER_REGION_START; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
#endif
我们看到这个
void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_settings)
{
// Read only pointer to bootloader settings in flash.
bootloader_settings_t const * const p_bootloader_settings =
(bootloader_settings_t *)&m_boot_settings[]; *pp_bootloader_settings = p_bootloader_settings;
}
看到这个我们将0100000000000000FE000000FFFFFFFF的具体含义了
/**@brief Structure holding bootloader settings for application and bank data.
*/
typedef struct
{
bootloader_bank_code_t bank_0; /**< Variable to store if bank 0 contains a valid application. */
uint16_t bank_0_crc; /**< If bank is valid, this field will contain a valid CRC of the total image. */
bootloader_bank_code_t bank_1; /**< Variable to store if bank 1 has been erased/prepared for new image. Bank 1 is only used in Banked Update scenario. */
uint32_t bank_0_size; /**< Size of active image in bank0 if present, otherwise 0. */
uint32_t sd_image_size; /**< Size of SoftDevice image in bank0 if bank_0 code is BANK_VALID_SD. */
uint32_t bl_image_size; /**< Size of Bootloader image in bank0 if bank_0 code is BANK_VALID_SD. */
uint32_t app_image_size; /**< Size of Application image in bank0 if bank_0 code is BANK_VALID_SD. */
uint32_t sd_image_start; /**< Location in flash where SoftDevice image is stored for SoftDevice update. */
} bootloader_settings_t;
浅析NRF51822合并文件之app_valid_setting_apply的更多相关文章
- RandomAccessFile拆分合并文件
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java. ...
- PDF 补丁丁 0.4.2.905 测试版发布:智能合并功能减小合并文件的大小
之前的测试版在合并文件功能处添加两个相同的PDF文件,程序会重复写入该文件的内容,导致文件体积膨胀,浪费存储空间. 例如:使用者需要在原 PDF 文件(设文件为1.pdf)第2和第3页中间插入几张图片 ...
- stream流批量读取并合并文件
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.F ...
- IO流--切割 合并文件
import java.io.*; import java.util.*; public class io { public static void main(String[] args)throws ...
- PDF 补丁丁 0.4.1.804 测试版发布:合并文件夹的图片和PDF文件,自由生成多层次书签
新的测试版增强了合并文件的功能,可以合并文件夹内的图片和PDF文件,还可以在合并文件列表上直接指定与合并文件对应的PDF书签标题.通过拖放文件项目生成多层次的PDF书签.如下图所示: 另外,新的测试版 ...
- Linux合并文件、去除重复行的命令
Linux合并文件命令: awk '{printf("%s\n",$0)}' YQ-*101?.txt > 123.txt linux去除重复行命令:cat YQ-10 ...
- bash shell 合并文件
# 按列合并文件 paste file1 file2 file3 > file4 # 要先 sort, 再 file1 file2 paste格式为: paste -d -s -file1 fi ...
- requirejs实验002. r.js合并文件. 初体验.
requirejs的官网上有介绍如何使用r.js合并,压缩文件的.http://requirejs.org/docs/optimization.html https://github.com/jrbu ...
- 02-IOSCore - NSFileHandle、合并文件、文件指针、文件查看器
[day0201_NSFileHandle]:文件句柄 1 NSFileHandle 文件对接器.文件句柄 常用API: - (NSData *)readDataToEndOfFile;读取数据到最后 ...
随机推荐
- TFS下的源代码控制
以下主要描述了: TFS源代码控制系统的基本场景 如何把一个项目添加到源代码管理中 如何与服务器同步 如何做Check-In 如何做分支与合并 什么是上架与下架 我们知道工作项是项目管理的基本元素,但 ...
- Memcached 数据缓存系统
Memcached 数据缓存系统 常用命令及使用:http://www.cnblogs.com/wayne173/p/5652034.html Memcached是一个自由开源的,高性能,分布式内存对 ...
- kali-dmitry 域名信息收集
DMirty:用来收集以下信息: 1. 端口扫描 2. whois主机IP和域名信息 3. 从Netcraft.com获取主机信息 4. 子域名 5. 域名中包含的邮件地址 1.使用方法: Deepm ...
- FormatFloat 格式化浮点数
#和0的区别: #是对应位有值显示,无值不显示 0是对应位有值显示,无值显示0 分号后的字符串是对负值的格式化特殊定义: s := FormatFloat(.); .); .); .); ...
- AWS CloudFormation Template
{ "AWSTemplateFormatVersion" : "2010-09-09", "Parameters" : { "Ba ...
- LINUX 下Open cv练习使用小记(1)
首先肯定离不开选一张自己喜欢的图像来显示 #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp ...
- ORA-01747: user.table.column, table.column 或列说明无效
Oracle.DataAccess.Client.OracleException ORA-01747: user.table.column, table.column 或列说明无效 原因1: 查了一下 ...
- fontcreator制作iconfont(包含两个教程)
第一步 在AI中画好矢量图,或者是在PS中将纯色的图片存成PNG格式,最好是放大很多倍的纯色图片.因为导入到fontcreator中会显得很小,如果不是矢量,图片拉大后就会有锯齿状. 第二步 选中AI ...
- maven scope含义的说明
依赖范围控制哪些依赖在哪些classpath 中可用,哪些依赖包含在一个应用中.让我们详细看一下每一种范围: compile (编译范围) compile是默认的范围:如果没有提供一个范围,那该依赖的 ...
- 使用Ninject进行DI(依赖注入)
Ninject是一个快如闪电.超轻量级的基于.Net平台的依赖注入框架.它能够帮助你把应用程序分离成一个个松耦合.高内聚的模块,然后用一种灵活的方式组装起来.通过使用Ninject配套你的软件架构,那 ...