概述
实验环境
1.软件:
协议栈版本:BLE-STACK SDK ble_sdk_2_02_01_18
烧录软件版本:Smart Flash Programmer 2
IAR开发环境版本:IAR for Arm 7.80.4
示例测试Demo工程:自己的项目工程
2.硬件:
CC2640开发板
3、OAD升级方式
这个已经有非常多的资料了,请自行Google,此次移植过程中主要参考到以下博文,非常感谢各位博主的帮忙
http://www.leconiot.com/download/cc2640r2f/oad/oad_concept/oad_concept.html
https://blog.csdn.net/zzfenglin/article/details/72835965
http://dev.ti.com/tirex/content/simplelink_cc2640r2_sdk_1_35_00_33/docs/blestack/ble_sw_dev_guide/html/oad/oad.html
《CC2640 BLE OAD User’s Guide.pdf》
4、OAD升级步骤
4.1、编译BIM
1)配置Flash管脚
打开"C:tisimplelinkble_sdk_2_02_01_18srcexamplesutilbim_extflashcc2640boardcc2650lpbsp.h"修改SPI Flash管脚配置,使用自己产品或开发板的配置管脚
2)配置Flash info
根据自己的Flash厂商、存储空间、deviceId配置Flash Info
3)编译BIM
用IAR打开"C:tisimplelinkble_sdk_2_02_01_18examplesutilbim_extflashcc2640iarbim_extflash.eww"进行编译。
4.2编译Stack
打开自己的项目工程,切换到cc2650lp_stack进行编译,stack基本不变,直接编译就好
4.3编译App,这个是重中之重,需要变更的地方挺多的,完全结合自己的工程来的
1)Select Project→Options→C/C++ Compiler→Preprocessor and add the following new definitions
to Defined symbols:
FEATURE_OAD
HAL_IMAGE_E
Add the following lines to Additional include directories:
[外链图片转存失败(img-OOsA5rL5-1568194573495)(C:UsersAdministratorAppDataRoamingTyporatypora-user-images1568194526198.png)]
2)Select Project→Options→Linker→Config→Linker configuration file and paste the following line:
S
R
C
E
X
SRC_EX
SRCEX/common/cc26xx/iar/cc26xx_app_oad.icf
And add the following symbols to Configurable file symbol definitions:
APP_IMAGE_START=0x1000
Append the following in Build Actions under Pre-build command line:
–cfgArgs NO_ROM=1,OAD_IMG_E=1
3)Exclude the forder of Middleware.
Add oad.c , oad.h , oad_reset_service.h in Profiles in “C:tisimplelinkble_sdk_2_02_01_18srcprofilesoadcc26xx”.
Exclude ccfg_app_ble.c and ccfg_app_ble_rcosc.c in the forder StartUp.
Under Tools, include cc26xx_app_oad.icf and exclude cc26xx_app.icf.
4)在自己工程下的config文件夹下修改文件app_ble.cfg
添加var Event = xdc.useModule('ti.sysbios.knl.Event');
5)修改文件oad_target.h
将OAD需要的oad_target.h替换原工程的oad_target.h
将原工程的oad_target.h中有,而OAD的oad_target.h没有的内容进行添加,添加内容如下:
void HwFlashErase(uint32_t page);
void HwFlashWrite(uint32_t page, uint8_t *pBuf, uint16_t len);
void HwFlashRead(uint32_t page, uint8_t *pBuf, uint16_t len);
void HwFlashErase_All(void);
6)修改文件oad_target_external_flash.c
①将OAD需要的oad_target.h替换原工程的oad_target.h
②将原工程的oad_target.h中有,而OAD的oad_target.h没有的内容进行添加,添加内容如下:
③将OAD的#include "oad_target.h"换成原工程的#include “oad_target.h”(变更路径)
④将OAD的#include "ext_flash_layout.h"换成原工程的#include “ext_flash_layout.h”(变更路径)
⑤由于原工程与OAD工程都有OADTarget_readFlash()
将原工程的所有函数OADTarget_readFlash()换成OADTarget_readFlash_neck()
⑥由于原工程与OAD工程都有OADTarget_writeFlash()
将原工程的所有函数OADTarget_writeFlash()换成OADTarget_writeFlash_neck()
⑦由于原工程与OAD工程都有OADTarget_eraseFlash()
将原工程的所有函数OADTarget_eraseFlash()换成OADTarget_eraseFlash_neck()
⑧在OAD工程中追加
void HwFlashErase(uint32_t page)
void HwFlashWrite(uint32_t page, uint8_t *pBuf, uint16_t len)
void HwFlashRead(uint32_t page, uint8_t *pBuf, uint16_t len)
7)修改文件oad.c
①更换文件#include "oad_target.h"的路径
②变更函数OAD_getNextBlockReq
追加以下赋值,始终搞不明白为什么oadImgBlockConfig->connHandle一直是0xFFFF,oadImgBlockConfig->value一直未0x00,期望大神看到后能给些指导
oadImgBlockConfig->connHandle = 0x0000;
oadImgBlockConfig->value = 0x01;
static void OAD_getNextBlockReq(uint16_t connHandle, uint16_t blkNum)
{
oadImgBlockConfig->connHandle = 0x0000;
oadImgBlockConfig->value = 0x01;
uint16_t value = GATTServApp_ReadCharCfg(connHandle, oadImgBlockConfig);
// If notifications enabled
if (value & GATT_CLIENT_CFG_NOTIFY)
{
attHandleValueNoti_t noti;
noti.pValue = GATT_bm_alloc(connHandle, ATT_HANDLE_VALUE_NOTI, 2, NULL);
if (noti.pValue != NULL)
{
gattAttribute_t *pAttr;
pAttr= GATTServApp_FindAttr(oadAttrTbl, GATT_NUM_ATTRS(oadAttrTbl),
oadCharVals+OAD_IDX_IMG_BLOCK);
noti.handle = pAttr->handle;
noti.len = 2;
noti.pValue[0] = LO_UINT16(blkNum);
noti.pValue[1] = HI_UINT16(blkNum);
if (GATT_Notification(connHandle, ¬i, FALSE) != SUCCESS)
{
GATT_bm_free((gattMsg_t *)¬i, ATT_HANDLE_VALUE_NOTI);
}
}
}
}
8)修改文件oad_reset_service.c
①更换文件#include "oad_target.h"的路径
9)编译App
5、烧录BIM,Stack,App
6、结束
最后
以上就是传统黄蜂为你收集整理的CC2640之在已有工程中添加OAD(外置Flash)的全部内容,希望文章能够帮你解决CC2640之在已有工程中添加OAD(外置Flash)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复