避免产品升级需要拆开重新下载程序,只需用手机或电脑连接上即可升级
芯片上电后首先运行 BIM。然后 BIM 判断芯片 Flash 中是否存在有效的 Image-B,如果有,跳转到 Image -B 开始运行。如果没有 Image-B,则再判断芯片 Flash 中是否存在Image-A,如果有跳转到 Image- A 处运行,如果没有,则进入 PM3 睡眠状态。
Projects\ble\util\BIM
BIM_CC254XF256.hex
BIM_CC254XF256.hex
下载到芯片Erase,program and verify
Project->Edit Configurations->New
Based on connfiguration
选择CC2541
修改C/C++ Compiler
配置的Preprocessor
选项
include directories
中添加$PROJ_DIR$\..\..\Profiles\OAD
Defind symbols
中添加
1
2
3
4
FEATURE_OAD_BIM
HAL_IMAGE_A
FEATURE_OAD
OAD_KEEP_NV_PAGES
post-build command line
中添加
1
"$PROJ_DIR$\..\..\common\cc2540\cc254x_ubl_pp.bat" "$PROJ_DIR$" "ProdUBL" "$TARGET_DIR$\$TARGET_BNAME$"
config
选项卡,在Linker configuration file
的填入
1
$PROJ_DIR$\..\..\common\CC2540\cc254x_f256_imgA.xcl
Output
选项卡,取消Override defaul
项Etra Output
选项卡,取消Override defaul
项,修改Output format
项改为simple-code
Etra Options
选项卡,增加Use command line ptions
,用来生成.hex
文件
1
-Ointel-extended,2=.hex
Texas Instruments
的Download
选项卡,取消Erase flash
profiles
找到oad.h
,oad_target.c
,oad_targe.h
三个文件options
Exclude from build
选项
simpleBlePerpheral.c
中包含头文件
1
2
3
4
#if defined FEATURE_OAD
#include "oad.h"
#include "oad_target.h"
#endif
SimpleBLEPeripheral_Init
函数中添加OAD服务
1
2
3
#if defined FEATURE_OAD
VOID OADTarget_AddService(); // OAD Profile
#endif
用软件SmartRF Flash Programmer通过CC Debugger把生成的imgae-A的.hex
下载到芯片
选择Append and verify
如果下载出现错误先重新下载BIM然后下载image-A,BIM选择 Erase,program and verify
,image-A选择Append and verify
Read flash into hex-file
flah image
自定义读出的文件名,以防混淆Perform actions
读出芯片内程序Erase,program and verify
下载到芯片内,运行结果和先下BIM再下image-A一样Project->Edit Configurations->New
Based on connfiguration
选择my-OAD-A
修改C/C++ Compiler
配置的Preprocessor
选项
Defind symbols
中把HAL_IMAGE_A
修改为HAL_IMAGE_B
1
2
3
4
FEATURE_OAD_BIM
HAL_IMAGE_B
FEATURE_OAD
OAD_KEEP_NV_PAGES
config
选项卡,修改Linker configuration file
内容把$PROJ_DIR$\..\..\common\CC2540\cc254x_f256_imgA.xcl
改为
1
$PROJ_DIR$\..\..\common\CC2540\cc254x_f256_imgB.xcl
Scan
Connect
或直接双击设备
Projects\ble\SimpleBLEPeripheral\CC2541DB\my-OAD-B\Exe
文件内
Projects\ble\SimpleBLEPeripheral\CC2541DB\my-OAD-A\Exe
文件内
.bin
文件,不可以是.hex
文件DOAD_IMAGE_VERSION
修改为0x0001
1
-DOAD_IMAGE_VERSION=0x0001