Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of X_NUCLEO_IDB0XA1 by
Diff: source/bluenrg-hci/hci/controller/bluenrg_utils.c
- Revision:
- 245:6830f71c197c
- Parent:
- 132:51056160fa4a
- Child:
- 249:2e94d2835c45
--- a/source/bluenrg-hci/hci/controller/bluenrg_utils.c Mon Jun 20 17:20:23 2016 +0200
+++ b/source/bluenrg-hci/hci/controller/bluenrg_utils.c Mon Jun 20 17:53:36 2016 +0200
@@ -15,6 +15,7 @@
#define BASE_ADDRESS 0x10010000
#define FW_OFFSET (2*1024) // 2 KB
+#define FW_OFFSET_MS 0
#define FULL_STACK_SIZE (66*1024) // 66 KB
#define BOOTLOADER_SIZE (2*1024) // 2 kB
#define SECTOR_SIZE (2*1024) // 2 KB
@@ -92,6 +93,7 @@
uint8_t number_sectors, module;
uint32_t address, j;
uint32_t crc, crc2, crc_size;
+ uint32_t fw_offset = FW_OFFSET;
BlueNRG_HW_Bootloader();
HCI_Process(); // To receive the EVT_INITIALIZED
@@ -102,6 +104,14 @@
if(version < SUPPORTED_BOOTLOADER_VERSION_MIN || version > SUPPORTED_BOOTLOADER_VERSION_MAX)
return BLE_UTIL_UNSUPPORTED_VERSION;
+ if(aci_updater_hw_version(&version))
+ return BLE_UTIL_ACI_ERROR;
+
+ if(version==0x31){
+ // It does not contain bootloader inside first sector. It may contain code.
+ fw_offset = FW_OFFSET_MS;
+ }
+
if (fw_size != FULL_STACK_SIZE)
return BLE_UTIL_WRONG_IMAGE_SIZE;
@@ -121,11 +131,11 @@
/***********************************************************************
* Erase and Program sectors
************************************************************************/
- for(unsigned int i = FW_OFFSET; i < (number_sectors * SECTOR_SIZE); i += SECTOR_SIZE) {
+ for(int i = fw_offset; i < (number_sectors * SECTOR_SIZE); i += SECTOR_SIZE) {
num_erase_retries = 0;
while (num_erase_retries++ < MAX_ERASE_RETRIES) {
aci_updater_erase_sector(BASE_ADDRESS + i);
- if ((i/SECTOR_SIZE) < (unsigned int)(number_sectors-1))
+ if ((i/SECTOR_SIZE) < (number_sectors-1))
data_size = DATA_SIZE;
else
data_size = MIN_WRITE_BLOCK_SIZE;
@@ -146,7 +156,7 @@
************************************************************************/
module = fw_size % SECTOR_SIZE;
crc_size = SECTOR_SIZE;
- for(int i = SECTOR_SIZE; i < (number_sectors*SECTOR_SIZE); i += SECTOR_SIZE){
+ for(int i = fw_offset; i < (number_sectors*SECTOR_SIZE); i += SECTOR_SIZE){
address = BASE_ADDRESS + i;
if(aci_updater_calc_crc(address, 1, &crc))
return BLE_UTIL_ACI_ERROR;
@@ -214,8 +224,12 @@
int IFR_validate(IFR_config2_TypeDef *IFR_config)
{
- if(IFR_config->stack_mode < 1 || IFR_config->stack_mode > 3)
- return BLE_UTIL_PARSE_ERROR; // Unknown Stack Mode
+#if BLUENRG_MS
+ if(IFR_config->stack_mode < 1 || IFR_config->stack_mode > 4)
+#else
+ if(IFR_config->stack_mode < 1 || IFR_config->stack_mode > 3)
+#endif
+ return BLE_UTIL_PARSE_ERROR; // Unknown Stack Mode
if(IFR_config->master_sca > 7)
return BLE_UTIL_PARSE_ERROR; // Invalid Master SCA
if(IFR_config->month > 12 || IFR_config->month < 1)
@@ -360,9 +374,7 @@
*fwVersion |= ((lmp_pal_subversion >> 4) & 0xF) << 4; // Minor Version Number
*fwVersion |= lmp_pal_subversion & 0xF; // Patch Version Number
}
-
- HCI_Process(); // To receive the BlueNRG EVT
-
+
return status;
}
@@ -384,6 +396,21 @@
return BLE_STATUS_SUCCESS;
}
+uint8_t getBlueNRGUpdaterHWVersion(uint8_t *version)
+{
+
+ BlueNRG_HW_Bootloader();
+ HCI_Process(); // To receive the EVT_INITIALIZED
+
+ if(aci_updater_hw_version(version))
+ return BLE_UTIL_ACI_ERROR;
+
+ BlueNRG_RST();
+ HCI_Process(); // To receive the EVT_INITIALIZED
+
+ return BLE_STATUS_SUCCESS;
+}
+
uint8_t isHWBootloader_Patched(void)
{
uint8_t status, version;
