在service_om_dfu.c文件中对服务名做如下修改: void service_om_dfu_init(void) { // static const uint8_t serv_dfu[16] = {0x41, 0x54, 0x4F, 0x2D, 0x4D, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xBF, 0x01, 0x00, 0x00}; // static const uint8_t char1[16] = {0x41, 0x54, 0x4F, 0x2D, 0x4D, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x5F, 0xBF, 0x01, 0x00, 0x00}; // static const uint8_t char2[16] = {0x41, 0x54, 0x4F, 0x2D, 0x4D, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x02, 0x5F, 0xBF, 0x01, 0x00, 0x00}; // static const uint8_t char3[16] = {0x41, 0x54, 0x4F, 0x2D, 0x4D, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x03, 0x5F, 0xBF, 0x01, 0x00, 0x00}; static const uint8_t serv_dfu[2] = {0x59, 0xFE}; static const uint8_t char1[16] = {0x50, 0xEA, 0xDA, 0x30, 0x88, 0x83, 0xB8, 0x9F, 0x60, 0x4F, 0x15, 0xF3, 0x01, 0x00, 0xC9, 0x8E}; static const uint8_t char2[16] = {0x50, 0xEA, 0xDA, 0x30, 0x88, 0x83, 0xB8, 0x9F, 0x60, 0x4F, 0x15, 0xF3, 0x02, 0x00, 0xC9, 0x8E}; static const uint8_t char3[2] = {0x03, 0x00}; static const ob_gatt_item_t atts_dfu[] = { { ob_att_char_def, OB_UUID_16BIT, OB_ATT_PROP_READ }, { char1, OB_UUID_128BIT, OB_ATT_PROP_NTF | OB_ATT_PROP_WRITE }, { ob_att_cccd_def, OB_UUID_16BIT, OB_ATT_PROP_READ | OB_ATT_PROP_WRITE }, { ob_att_char_def, OB_UUID_16BIT, OB_ATT_PROP_READ }, { char2, OB_UUID_128BIT, OB_ATT_PROP_WRITE_CMD }, { ob_att_char_def, OB_UUID_16BIT, OB_ATT_PROP_READ }, { char3, OB_UUID_16BIT, OB_ATT_PROP_READ | OB_ATT_PROP_WRITE | OB_ATT_PROP_NTF }, { ob_att_cccd_def, OB_UUID_16BIT, OB_ATT_PROP_READ | OB_ATT_PROP_WRITE }, }; static const ob_gatt_serv_t att_serv_dfu = { serv_dfu, OB_UUID_16BIT, sizeof(atts_dfu) / sizeof(atts_dfu[0]), atts_dfu }; ob_gatts_add_service(&att_serv_dfu, &m_start_handle); } 升级脚本的修改CreateFw_flash.bat脚本的修改在xx\projects\ble_app_simple目录下,我们能看到CreateFw_flash.bat脚本,修改如下 python ..\..\tools\imgutils\win\gen_mbr.py ..\..\tools\imgutils\win\CreateFwTool.exe pack ^ APP 0 .\mbr.bin MBR_USR1 @0x108 pause 上面主要修改的是加载bin路径的修改,当然咱们自己可以重新弄一个脚本,编译后把ble_app_simple.bin放在其他路径,同时,这里的路径也做对应的修改。 mbr_cfg.yaml修改在xx\projects\ble_app_simple目录下,有个tool文件夹,该文件夹下有mbr_cfg.yaml文件,修改如下: output_path: './mbr.bin' private_key: 0x0134893E # iflash config中任意一个为None,则代表不对flash进行配置 iflash_config: clk_div: 0x2 delay: 0 # when flash clock is high, just auto delay read_cmd: 'FLASH_FAST_READ_QIO' write_cmd: 'FLASH_PAGE_PROGRAM' spi_mode: 'SPI_MODE_0' encrypt_en: 0 # NOT USED manifest_config: img_ver: 0x00000001 img_vma: 0x00404000 img_lma: 0x00460000 主要修改点是img_path路径下的ble_app_simple.bin加载路径。 以上几个步骤操作完之后就可以用nrf connect软件进行测试。 注意: 我们想修改dfu的升级地址,这个时候可以修改om_dfu_config.h文件中的dfu_image_types数组中的如下位置 |