浅析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;读取数据到最后 ...
随机推荐
- 第二节:模型(Models)和管理后台(Admin site)
本节内容我们将配置数据库,创建第一个model并且快速了解Django自动生成的管理后台(admin site) 目录 数据库配置 创建模型 激活模型 使用Django API 介绍Django管理后 ...
- Oracle虚拟索引,大表或生产环境下预估索引效果的好东西
在数据库优化过程中,索引的重要性是不言而喻的,但是在我们进行性能调整过程中, 一个索引是否能够被使用到,在索引创建之前是存在不确定性的. 而创建索引又是一个代价很高的操作,尤其是数据量很大的情况下,在 ...
- 【java】jackson 中JsonFormat date类型字段的使用
为了便于date类型字段的序列化和反序列化,需要在数据结构的date类型的字段上用JsonFormat注解进行注解具体格式如下 @JsonFormat(pattern = "yyyy-MM- ...
- Oracle用法集锦
查询第一条数据 修改表名 ALTER TABLE tablename RENAME TO newtablename 修改列名: ALTER TABLE BD_PRI RENAME COLUMN EU_ ...
- [综] Sparse Representation 稀疏表示 压缩感知
稀疏表示 分为 2个过程:1. 获得字典(训练优化字典:直接给出字典),其中字典学习又分为2个步骤:Sparse Coding和Dictionary Update:2. 用得到超完备字典后,对测试数据 ...
- PHP简介
PHP PHP是运行在服务器端的脚本,可以运行在UNIX.LINUX.WINDOWS.Mac OS下.PHP的特性包括:1. PHP 独特的语法混合了 C.Java.Perl 以及 PHP 自创新的语 ...
- navicat连接My SQL时忘记root密码处理方法
前端时间安装完My SQL5.6以后很长时间没用过,用navicat连接时有错误提示 应该是密码错误了,但是忘记了root的密码. 在网上找了很久,终于找到修改root密码的方法并修改成功. 1. 关 ...
- 用Python向MySQL数据库插入数据
最近一直在学习MySQL数据库,很感兴趣.这次我做了一个简单的尝试,使用Python3.4与MySQL数据库进行交互,将一份从雪球网上下载的某股票数据上传至MySQL数据库.仅为初学者提供参考,高手请 ...
- MVC中关于Membership类跟数据库的问题
Membership它们用的是ASPNETDB这个数据库,但我们可以使用我们自定义的数据库,然而除非我们自定义的数据库有着跟这个ASPNETDB一样的模式,否则ASP.NET提供的默认的SqlMemb ...
- linux中mysql如何设置为开机启动
开机启动命令 chkconfig mysqld on 查询是否设置为开机启动命令 chkconfig --list mysqld 结果为 mysqld 0:关闭 1:关闭 2:启动 3:启动 4:启动 ...