cancel
Showing results for 
Search instead for 
Did you mean: 

BlueNRG2 OTA Flash verify failure

TGats.2
Associate II

Hello

I'm trying to implement the OTA feature in my project. We use the BlueNRG-2 Chip.

I'm followed the BLE_Chat example and the explanaition in the The BlueNRG-LP (over-the-air) firmware upgrade document to inlcude all the ota related code parts.

When I now try to load a new firmware to the device through the Android application ST BLE Mesh, I see, that on the BLE device some Gatt Attribute modified events are triggered. But right after that, the error Flash verify failure occurs from the OTA_Write_Data function.

I did not adjust the BlueNRG2.Id file, do I have to change something in that file? Or can someone give me a hint, what otherwise I could/should adjust?

Many thanks.

Tobias

I just append a part of the BlueNRG2.Id file. The rest have also all the default values.

/*******************************************************************************
* Memory Definitions
*******************************************************************************/
/*
BlueNRG-2 memory map
+-----------------------+ 0x20005FFF
|  RAM (24K)            |
+-----------------------+ 0x20000000
|                       |
|                       |
+-----------------------+ 0x1007FFFF
|                       |
|  FLASH (256K)         |
+-----------------------+ 0x10040000
|                       |
+-----------------------| 0x100007FF
|   ROM (2K)            |
+-----------------------+ 0x10000000
*/
 
 
_MEMORY_RAM_BEGIN_   =  0x20000000; 
_MEMORY_RAM_SIZE_    =  0x6000;           /* 24KB  */
_MEMORY_RAM_END_     =  0x20005FFF; 
 
_MEMORY_FLASH_BEGIN_ = 0x10040000;  
_MEMORY_FLASH_SIZE_  = 0x40000;          /* 256KB */ 
_MEMORY_FLASH_END_   = 0x1007FFFF;  
 
_MEMORY_ROM_BEGIN_   = 0x10000000;    
_MEMORY_ROM_SIZE_    = 0x800;             /* 2KB */ 
_MEMORY_ROM_END_     = 0x100007FF;  
 
 
/* Reserved for BTLE stack non volatile memory */
FLASH_NVM_DATASIZE   = (4*1024);
 
 
  /* This configuration is intended for application not supporting OTA firmware upgrade */
  /*
  BlueNRG-2 standard application memory map
  +-----------------------+ 0x20005FFF
  |  RAM (24K)            |
  +-----------------------+ 0x20000000
  |                       |
  |                       |
  +-----------------------+ 0x10068000
  |                       |
  |  NVM(4K)              |
  +-----------------------+ 0x1007F000
  |                       |
  |  User app (252K)      |
  +-----------------------+ 0x10040000
  |                       |
  +-----------------------| 0x100007FF
  |   ROM (2K)            |
  +-----------------------+ 0x10000000
*/
 
MEMORY_FLASH_APP_OFFSET = DEFINED(MEMORY_FLASH_APP_OFFSET) ? (MEMORY_FLASH_APP_OFFSET) : (0) ;
MEMORY_FLASH_APP_SIZE = DEFINED(MEMORY_FLASH_APP_SIZE) ? (MEMORY_FLASH_APP_SIZE) : ( _MEMORY_FLASH_SIZE_ - FLASH_NVM_DATASIZE - MEMORY_FLASH_APP_OFFSET);
MEMORY_RAM_APP_OFFSET = DEFINED(MEMORY_RAM_APP_OFFSET) ? (MEMORY_RAM_APP_OFFSET) : (0x2CC) ;
 
RESET_MANAGER_SIZE = DEFINED(RESET_MANAGER_SIZE) ? RESET_MANAGER_SIZE : 0x800 ;
 
 
/* 
   *****************************
   * ST_OTA_HIGHER_APPLICATION *
   *****************************
*/
   /* This configuration is intended for application supporting OTA firmware upgrade with 2-app scheme (app in the upper part of memory map) */
  /*
     BlueNRG-2 OTA firmware upgrade support for higher application memory map
     +-----------------------+ 0x20005FFF
     |  RAM (24K-4)          |
     +-----------------------+ 0x20000004
     |                       |
     |                       |
     +-----------------------+ 0x10080000
     |                       |
     |  NVM(4K)              |
     +-----------------------+ 0x1007E800
     |                       |
     |  Higher app (124K)    |
     +-----------------------+ 0x1005F800
     |                       |
     |  Lower app (124K)     |
     +-----------------------| 0x10040800
     |   Reset Manager (2K)  |
     +-----------------------+ 0x10040000
     |                       |
     +-----------------------| 0x100007FF
     |   ROM (2K)            |
     +-----------------------+ 0x10000000
  */
 
 
MEMORY_FLASH_APP_SIZE = DEFINED(ST_OTA_HIGHER_APPLICATION) ? (((_MEMORY_FLASH_SIZE_ - RESET_MANAGER_SIZE - FLASH_NVM_DATASIZE) / 2) / 2048) * 2048 : MEMORY_FLASH_APP_SIZE ;
MEMORY_FLASH_APP_OFFSET = DEFINED(ST_OTA_HIGHER_APPLICATION) ? (RESET_MANAGER_SIZE + MEMORY_FLASH_APP_SIZE) : MEMORY_FLASH_APP_OFFSET ;
 
 
/* 
   *****************************
   * ST_OTA_LOWER_APPLICATION *
   *****************************
*/
  /* This configuration is intended for application supporting OTA firmware upgrade with 2-app scheme (app in the lower part of memory map) */
  /*
     BlueNRG-2 OTA firmware upgrade support for lower application memory map
     +-----------------------+ 0x20005FFF
     |  RAM (24K-4)          |
     +-----------------------+ 0x20000004
     |                       |
     |                       |
     +-----------------------+ 0x10080000
     |                       |
     |  NVM(4K)              |
     +-----------------------+ 0x1007E800
     |                       |
     |  Higher app (124K)    |
     +-----------------------+ 0x10053800
     |                       |
     |  Lower app (124K)     |
     +-----------------------| 0x10040800
     |   Reset Manager (2K)  |
     +-----------------------+ 0x10040000
     |                       |
     +-----------------------| 0x100007FF
     |   ROM (2K)            |
     +-----------------------+ 0x10000000
  */
 
MEMORY_FLASH_APP_SIZE = DEFINED(ST_OTA_LOWER_APPLICATION) ? (((_MEMORY_FLASH_SIZE_ - RESET_MANAGER_SIZE - FLASH_NVM_DATASIZE) / 2) / 2048) * 2048 : MEMORY_FLASH_APP_SIZE ;
MEMORY_FLASH_APP_OFFSET = DEFINED(ST_OTA_LOWER_APPLICATION) ? (RESET_MANAGER_SIZE) : MEMORY_FLASH_APP_OFFSET ;
 
 
/* 
   ******************************************
   * ST_USE_OTA_SERVICE_MANAGER_APPLICATION *
   ******************************************
*/
  /* This configuration is intended for application supporting OTA firmware upgrade with independent OTA firmware upgrade service manager
  (app in the upper part of memory map) */
  /*
     BlueNRG-2 OTA firmware upgrade support for service manager application memory map
     +-----------------------+ 0x20005FFF
     |  RAM (24K-4)          |
     +-----------------------+ 0x20000004
     |                       |
     |                       |
     +-----------------------+ 0x10080000
     |                       |
     |  NVM(4K)              |
     +-----------------------+ 0x1007F000
     |                       |
     |  User app (182K)      |
     +-----------------------+ 0x10051800
     | OTA Service           |
     | Manager (70K)         |
     +-----------------------+ 0x10040000
     |                       |
     +-----------------------| 0x100007FF
     |   ROM (2K)            |
     +-----------------------+ 0x10000000
  */
 
SERVICE_MANAGER_SIZE = 0x11800;
MEMORY_FLASH_APP_SIZE = DEFINED(ST_USE_OTA_SERVICE_MANAGER_APPLICATION) ? (_MEMORY_FLASH_SIZE_ - SERVICE_MANAGER_SIZE - FLASH_NVM_DATASIZE) : MEMORY_FLASH_APP_SIZE ;
MEMORY_FLASH_APP_OFFSET = DEFINED(ST_USE_OTA_SERVICE_MANAGER_APPLICATION) ? (SERVICE_MANAGER_SIZE) : MEMORY_FLASH_APP_OFFSET ;
 
/* Entry Point */
ENTRY(RESET_HANDLER)
 
 
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x0;      /* required amount of heap  */
_Min_Stack_Size = 0xC00; /* required amount of stack */
 
/* Specify the memory areas */

1 ACCEPTED SOLUTION

Accepted Solutions
AndyR1
Senior

No need to add flash erase, there is already one at the beginning of OTA Service manager project

/* Erase the storage area from start page to end page */
OTA_Erase_Flash(APP_WITH_OTA_SERVICE_PAGE_NUMBER_START,APP_WITH_OTA_SERVICE_PAGE_NUMBER_END);

I'm working on my projects, I will tell you if I have the same issue or not.

View solution in original post

5 REPLIES 5
AndyR1
Senior

Hello Tobias,

I'm working on custom OTA service manager on Bluenrg-m2, i have some issue with OTA upgrade too, hope we will help each other 🙂

In OTA project, you have to check/set the OTA size, the default value would be great for small application : OTA_btl.h -> #define SERVICE_MANAGER_SIZE = 0x11800, for 70kB.

For application project, don't modify the BlueNRG2.icf file, like described in the OTA document : Project -> Options -> Linker -> Config, add in Configurations file symbol definitions :

ST_USE_OTA_SERVICE_MANAGER_APPLICATION=1

SERVICE_MANAGER_SIZE=0x19000

I set SERVICE_MANAGER_SIZE to 0x19000 (102400) which is 100kB, because in OTA project, I set SERVICE_MANAGER_SIZE to PAGE_SIZE_ROUND(100 * 1024)

Add ST_USE_OTA_SERVICE_MANAGER_APPLICATION=1 in C/C++ Compiler -> Preprocessor -> Defined symbols.

Can't help you with the Android part, i use BlueNRG GUI with STEVAL-IDB00xv1M board.

Andy.

TGats.2
Associate II

Hi Andy

Thanks for your answer.

I don't think that it is a problem with the Service Manager in my project. All seems to be working until it will write the received data to the flash. There it is failing.

Is you project failing at the same stage or somewhere else?

Should I first erase the flash before I can write something to it?

Best Regards,

Tobias

AndyR1
Senior

No need to add flash erase, there is already one at the beginning of OTA Service manager project

/* Erase the storage area from start page to end page */
OTA_Erase_Flash(APP_WITH_OTA_SERVICE_PAGE_NUMBER_START,APP_WITH_OTA_SERVICE_PAGE_NUMBER_END);

I'm working on my projects, I will tell you if I have the same issue or not.

AndyR1
Senior

You can try to modify parameters at the end of OTA_btl.c in the hci_le_data_length_change_event function:

/* Increase connection interval for handling BUF_SIZE Flash write operations when no radio activity */
aci_l2cap_connection_parameter_update_req(Connection_Handle, /*(uint16_t)OTA_EXT_LE_L2CAP_CONN_INTERVAL(ota_att_mtu_size)*/0x50,/*(uint16_t)OTA_EXT_LE_L2CAP_CONN_INTERVAL(ota_att_mtu_size)*/0x50, 0, 0xC80);

TGats.2
Associate II

Many thanks for your answers. To erase the flash solved the issue. I had a little missunderstanding regarding the OTA service manager. But this is now clear for me.

But the next issue is, that the service manager is no jumping to the user application. But I will open a new question for that.

Thanks!