2021-02-17 08:32 AM
Hello,
I'm using STM32Wb CubeMX HAL FW 1.10.1 and a PNUCLEO-WB55
I'd like to get the wireless coprocessor stack version at runtime. I didn't find a HAL API to do this, so I went about it manually using AN5185 as a guide. According to AN5185, the device information table contains (among other things) the wireless stack version. This table is in SRAM2a and should be accessible by both cores. Using the flowchart on page 16, I'm trying to read the magic number stored at the top of this table, but I'm always getting back 0x00000000. Here's my code:
void print_device_info(void)
{
// Get IPCCDBA
FLASH_OBProgramInitTypeDef pOBInit;
HAL_FLASHEx_OBGetConfig(&pOBInit);
volatile uint32_t *ipccdba = (uint32_t *)(pOBInit.IPCCdataBufAddr);
// Get offset of device info table
uint8_t device_info_table_offset = (uint8_t)*ipccdba;
printf("Device info table magic number = %08lX\r\n", *(ipccdba + device_info_table_offset));
__BKPT(0);
}
If I point the debugger at that memory address, it indeed reads 0.
Code is called after all MX init functions
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
printf("System init complete!\r\n");
printf("MCU:%ld,%ld\tHAL version:%ld\r\n", HAL_GetDEVID(), HAL_GetREVID() ,HAL_GetHalVersion());
printf("Initializing peripherals...\r\n");
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
MX_CRC_Init();
MX_I2C1_Init();
MX_RF_Init();
MX_RTC_Init();
/* USER CODE BEGIN 2 */
printf("Initializng sensor...\r\n");
sensor_init();
printf("Initializing WPAN...\r\n");
/* USER CODE END 2 */
/* Init code for STM32_WPAN */
APPE_Init();
/* Infinite loop */
/* USER CODE BEGIN WHILE */
print_device_info();
printf("Initializing complete!\r\n");
while (1)
{
HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_Delay(1000);
}
/* USER CODE END 3 */
}
Wireless coprocessor has latest firmware image from 1.10.1 Cube FW and CubeProg showed a successful upgrade of that image
c:\ST\STM32Cube\STM32CubeProgrammer\bin>STM32_Programmer_CLI.exe -c port=usb1 -fwupgrade .\stm32wb5x_BLE_Stack_full_fw.bin 0x080CB000 firstinstall=0
-------------------------------------------------------------------
STM32CubeProgrammer v2.6.0
-------------------------------------------------------------------
USB speed : Full Speed (12MBit/s)
Manuf. ID : STMicroelectronics
Product ID : DFU in FS Mode
SN : 208138753036
FW version : 0x011a
Device ID : 0x0495
Device name : STM32WBxx
Flash size : 1 MBytes
Device type : MCU
Device CPU : Cortex-M4
FUS state is FUS_SERVICE_ONGOING
FUS status is FUS_IMAGE_NOT_FOUND
FUS state is FUS_IDLE
FUS status is FUS_NO_ERROR
Old wireless stack delete ...
Deleting firmware ...
Firmware delete finished
FUS state is FUS_SERVICE_ONGOING
FUS status is FUS_IMAGE_NOT_FOUND
FUS state is FUS_IDLE
FUS status is FUS_NO_ERROR
Download firmware image at address 0x80cb000 ...
Memory Programming ...
Opening and parsing file: stm32wb5x_BLE_Stack_full_fw.bin
File : stm32wb5x_BLE_Stack_full_fw.bin
Size : 165456 Bytes
Address : 0x080CB000
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [203 243]
erasing sector 0203 @: 0x080cb000 done
erasing sector 0204 @: 0x080cc000 done
erasing sector 0205 @: 0x080cd000 done
erasing sector 0206 @: 0x080ce000 done
erasing sector 0207 @: 0x080cf000 done
erasing sector 0208 @: 0x080d0000 done
erasing sector 0209 @: 0x080d1000 done
erasing sector 0210 @: 0x080d2000 done
erasing sector 0211 @: 0x080d3000 done
erasing sector 0212 @: 0x080d4000 done
erasing sector 0213 @: 0x080d5000 done
erasing sector 0214 @: 0x080d6000 done
erasing sector 0215 @: 0x080d7000 done
erasing sector 0216 @: 0x080d8000 done
erasing sector 0217 @: 0x080d9000 done
erasing sector 0218 @: 0x080da000 done
erasing sector 0219 @: 0x080db000 done
erasing sector 0220 @: 0x080dc000 done
erasing sector 0221 @: 0x080dd000 done
erasing sector 0222 @: 0x080de000 done
erasing sector 0223 @: 0x080df000 done
erasing sector 0224 @: 0x080e0000 done
erasing sector 0225 @: 0x080e1000 done
erasing sector 0226 @: 0x080e2000 done
erasing sector 0227 @: 0x080e3000 done
erasing sector 0228 @: 0x080e4000 done
erasing sector 0229 @: 0x080e5000 done
erasing sector 0230 @: 0x080e6000 done
erasing sector 0231 @: 0x080e7000 done
erasing sector 0232 @: 0x080e8000 done
erasing sector 0233 @: 0x080e9000 done
erasing sector 0234 @: 0x080ea000 done
erasing sector 0235 @: 0x080eb000 done
erasing sector 0236 @: 0x080ec000 done
erasing sector 0237 @: 0x080ed000 done
erasing sector 0238 @: 0x080ee000 done
erasing sector 0239 @: 0x080ef000 done
erasing sector 0240 @: 0x080f0000 done
erasing sector 0241 @: 0x080f1000 done
erasing sector 0242 @: 0x080f2000 done
erasing sector 0243 @: 0x080f3000 done
Download in Progress:
██████████████████████████████████████████████████ 100%
File download complete
Time elapsed during download operation: 00:00:06.714
FUS state is FUS_IDLE
FUS status is FUS_NO_ERROR
Firmware Upgrade process started ...
Updating firmware ...
Waiting for firmware upgrade end
FUS state is WIRELESS_STACK_UPGRADE_ONGOING
FUS status is FUS_NO_ERROR
FUS state is WIRELESS_STACK_UPGRADE_ONGOING
FUS status is FUS_NO_ERROR
FUS state is FUS_ERROR
FUS status is FUS_NOT_RUNNING
Firmware Upgrade Success
Looks like everything is ok:
c:\ST\STM32Cube\STM32CubeProgrammer\bin>STM32_Programmer_CLI.exe -c port=usb1 -fusgetstate
-------------------------------------------------------------------
STM32CubeProgrammer v2.6.0
-------------------------------------------------------------------
USB speed : Full Speed (12MBit/s)
Manuf. ID : STMicroelectronics
Product ID : DFU in FS Mode
SN : 208138753036
FW version : 0x011a
Device ID : 0x0495
Device name : STM32WBxx
Flash size : 1 MBytes
Device type : MCU
Device CPU : Cortex-M4
FUS state is FUS_IDLE
FUS status is FUS_NO_ERROR
getFUSstate command execution finished
I must be missing something basic. Can wireless copro version be read at runtime? If so, how?
Thanks,
Andy