实例介绍
【实例简介】nordic的蓝牙芯片的BootLoader例程和相关说明
说明:
nRF51822之BootLoader
一)nRF51822程序加载顺序
1)SoftDevice加载;
2)SoftDevice初始化蓝牙协议栈;
3)SoftDevice检查0x10001014处是否保存有有效的BootLoader地址, 如果不是跳转到0x14000处的APP执行,流程结束.
4)SoftDevice跳转到BootLoader
5)BootLoader进行他的业务处理工作;
6)BootLoader跳转到0x14000处的APP执行,流程结束.
二)实现步骤
1)修改SoftDivice.hex
看NRF_UICR_Type结构,有一个BOOTLOADERADDR字段, 这个就是指向的BootLoader地址
typedef struct {/*!< UICR Structure*/
__IO uint32_t CLENR0; /*!< Length of code region 0.*/
__IO uint32_t RBPCONF; /*!< Readback protection configuration.*/
__IO uint32_t XTALFREQ; /*!< Reset value for CLOCK XTALFREQ register.*/
__I uint32_t RESERVED0;
__I uint32_t FWID; /*!< Firmware ID.*/
__IO uint32_t BOOTLOADERADDR;/*!< Bootloader start address.*/
} NRF_UICR_Type;
默认情况下,SoftDivice.hex没有指定BootLoader地址;
我们需要在SoftDivice.hex中插入一行
:0410140000300100A7
参考HEX文件说明
这里修改0x10001014地址的数据为"00300100"就是0x13000, 这个地址根据BootLoader的实际位置修改.
2)编写BootLoader
BootLoader本身是一个普通的程序,只是在跳转到APP执行时需要特殊处理
static void interrupts_disable(void) {
uint32_t interrupt_setting_mask = NVIC->ISER[0];
for (uint8_t irq=0; irq < 32; irq ) {
if (interrupt_setting_mask & (1 << irq)) {
NVIC_DisableIRQ((IRQn_Type) irq);
}
}
}
__asm void StartApplication(uint32_t start_addr){
LDR R2, [R0] ; Get App MSP.
MSR MSP, R2 ; Set the main stack pointer to the applications MSP.
LDR R3, [R0, #0x00000004] ; Get application reset vector address.
BX R3 ; No return - stack code is now activated only through SVC and plain interrupts.
ALIGN
}
/**
* 跳转到APP执行
*/
static void bootloader_app_start(uint32_t app_addr) {
sd_softdevice_disable();
interrupts_disable();
sd_softdevice_forward_to_application();
StartApplication(app_addr);
}
把BootLoader写入我们上面定义的地址 0x13000
3)编写APP
APP跟没有BootLoader时是一样的,依然放在 0x14000 处
【实例截图】
【核心代码】
.
├── bootloader
│ ├── arm
│ │ ├── JLinkSettings.ini
│ │ ├── bootloader.uvopt
│ │ └── bootloader.uvproj
│ ├── arm_startup_nrf51.s
│ ├── bootloader.c
│ ├── bootloader_util_arm.c
│ ├── dfu_dual_bank.c
│ ├── dfu_single_bank.c
│ ├── dfu_transport_ble.c
│ ├── dfu_transport_serial.c
│ ├── hci_transport_config.h
│ ├── include
│ │ ├── bootloader.h
│ │ ├── bootloader_types.h
│ │ ├── bootloader_util.h
│ │ ├── dfu.h
│ │ ├── dfu_transport.h
│ │ └── dfu_types.h
│ └── main.c
└── 好例子网_nrf51822-bootloader.zip
3 directories, 19 files
标签: Bootloader BootLoad boot DER NRF
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论