nrf52840 内部 flash 结构

个人博客

所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 nixgnauhcuy’s blog

如需转载,请标明出处!

前言

不同的 SDK 版本 flash 结构可能不同,以实际 SDK 版本提供的为准。

最近开发用的芯片正好是 Nodic 的 52840,学习过程中,正好对相关的知识做个总结,方便自己后面回顾。

先贴出一张 52840 和 52832 的 flash 结构图,这个是在网上翻阅资料找到的图片,当时保存到电脑里,正好拿出来用。

图片以 nRF52840 S140 v6 为例,52840 有 1MB 的 flash 和 256Kb RAM, 从上图可以看出 flash 最下边是 SoftDevice (蓝牙协议栈),中间是 Application (应用层), 再往上是 UserData 和 Bootloader。SoftDevice 下边还有 MBR (Master Boot Record, 主引导记录) 下边我们在详细分析它们。


52840 flash 结构解析

SoftDevice(蓝牙协议栈)

上边图中可以知道 SoftDevice 在 Flash 中的映射地址是 0x00000000-0x00026000,总共是 152Kb,但是其中要拆分成 4Kb 的 MBR 和 148Kb 的 Softdevice。

MBR (Master Boot Record, 主引导记录), The main functionality of the MBR is to provide an interface to allow in-system updates of the application, the SoftDevice, and bootloader firmware1,MBR 的主要功能是提供一个接口,以允许对应用程序,SoftDevice 和引导加载程序固件进行系统内更新。


Application

Application 存放了我们应用程序代码,在 Flash 中的映射地址是 0x00026000-0x000ED000,共 796Kb。


UserData

UserData 存放了配置信息,资料中是这样解释的:This 28KB section of flash memory is reserved for config settings. It uses an open source file system called Little File System, which is a part of ARM Mbed OpenSource to store bonding data. For example, when you bond the nRF52 with another Central device,用于存储绑定数据,它在 Flash 中的映射地址是 0x000ED000-0x000F4000,共 28Kb。


Bootloader

Bootloader,总共 48Kb,但是要拆分成三部分,分别是2

  • Bootloader (40Kb,引导程序,0x000F4000-0x000FE000)
  • Master Boot Record Params (4Kb,主引导记录参数,0x000FE000-0x000FF000)
  • Bootloader Settings (4Kb,引导程序设置,0x000FF000-0x00100000)

Bootloader3

A bootloader may be used to handle in-system update procedures.

The bootloader has full access to the SoftDevice Application Programming Interface (API) and can be implemented like any application that uses the SoftDevice. In particular, the bootloader can make use of the SoftDevice API for Bluetooth® Low Energy communication.

上边是官方文档的原文,bootloader 主要用于处理系统内更新程序,主要用途有:

  • booting into an application
  • activating new firmware
  • optionally, entering DFU mode where DFU transports are activated and new firmware can be delivered
  • feeding the watchdog timer

Master Boot Record Params

官方文档中没有找出相关的信息,但是应该和 MBR 相似,存放了程序引导信息。


Bootloader Settings4

Bootloader Settings 保存了 bootloader 和 DFU 信息,如:

  • current firmware - size, CRC-32,当前固件 - 大小,CRC-32。
  • pending firmware - size, CRC-32,待定的固件–大小,CRC-32。
  • progress of the firmware update,固件更新的进度。
  • progress of the firmware activation,激活固件的进度。
  • current firmware versions (application and bootloader),当前的固件版本(应用程序和引导程序)。
  • transport-specific data,传输特定数据。

其他

除了 flash 中的结构地址映射外,还需要关注 FICR (信息配置寄存器,0x10001000) 和 UICR (用户信息配置寄存器,0x10000000),

  • FICR, 存储了工厂信息配置,是在出厂时预先编程的,用户不能擦除。这些寄存器包含了芯片特有的信息和配置。
  • UICR, 可以用于配置用户特定设置的非易失性存储器 (NVM) 寄存器,用于管理 FLASH 区域 (0x0-0x80000) 中的 NVM 存储器存储,一般不建议在这里面存储信息,除非不使用 softdevice 则可以通过 fstorage 将数据写入 UICR (即只能在禁用 softdevice 时使用)。

52840 上电运行流程

上电后,系统先执行 softdevice,softdevice 通过读取 UICR 一个寄存器的值,来判断目前系统是否有 BootLoader ,如果没有 BootLoader ,系统直接跳到 application;如果有 BootLoader,系统先跳到 BootLoader,BootLoader 再根据目前的情况来决定是进入升级模式还是跳往 application。


结尾

本人水平有限,错误、疏漏之处在所难免,还请各位多多包涵,如有问题,欢迎评论指导我修正错误,也希望本文能给你带来一些对 52840 flash 映射理解上的帮助!

参考


  • 8
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值