AnsweredAssumed Answered

Over the Air Update BLE, STM32F2, CRC Always 0?

Question asked by blesener.daniel on Jun 5, 2018
Latest reply on Jun 14, 2018 by Clive Two.Zero

I would suggest opening the file attached in notepad++.

 

Generally speaking the code makes sense. I can get it working without the CRC, which apparently is supposed to equal 0.

 

Note the following section:

 

if(psFirmware->ulPage == (psFirmware->ulTotalPages - 1)){
sFirmware.ucRcvdImage = TRUE;
//verify FW
if(sFirmware.ucUpdateWhat == fwUPDATE_CONSOLE){
ulCRC_Calc = sFirmware.ulFirstWord;
sFirmware.ulAddress = UPDATE_IMAGE_ADDRESS+4;
size = ((psFirmware->ulTotalPages * 12) /4)-1;
}else{
ulCRC_Calc = 0;
sFirmware.ulAddress = UPDATE_RADIO_ADDRESS;
size = ((psFirmware->ulTotalPages * 12) /4);
}

for(i = 0x000 ; i < size ; i++){
ulMemoryRead = *(__IO uint32_t*)sFirmware.ulAddress;
sFirmware.ulAddress += 4;
ulCRC_Calc += ulMemoryRead; //ADD the bits to calculate the checksum
}
if(1){//ulCRC_Calc == 0){
//verify FW image here
if(sFirmware.ucUpdateWhat == fwUPDATE_CONSOLE){
FlashStatus = FLASH_ProgramWord(UPDATE_IMAGE_ADDRESS,sFirmware.ulFirstWord);
if(FlashStatus != FLASH_COMPLETE){
while(1);
}
firmwareUpdateProc(keyFW_RESET);
}else{
sFirmware.ulTotalBytes = (psFirmware->ulTotalPages * 12);
firmwareUpdateRadio();
}
}else{
firmwareEraseUpdateSectors();
NVIC_SystemReset();
}
}

 

The code above is saying (if I get rid of the if(1)) that the CRC of the first word, plus all of the words written to flash for the image of the app, should be 0.

 

I have no clue why this is the case. Is it just standard for the MCU to place a value in the application address that should work this way?

 

Thank you for your support,

 

Daniel

Attachments

Outcomes