cancel
Showing results for 
Search instead for 
Did you mean: 

Memory malloc fails after upgrading of new firmware.

Nikunj Patel
Associate III

Hello @Martin KJELDSEN​ @All ALL​ ,

Facing issue in up-gradation of new firmware in following scenarios.

  1. I am using "STM32F412CGU6" microcontroller with MPU protection.
  2. My application stores the new firmware in an external SPI flash. Firmware data received using wirelessly.
  3. Firmware Integrity has been check successfully after receiving firmware wirelessly.
  4. Firmware activation command has sent to the device.
  5. The device is reboot using "HAL_NVIC_SystemReset".
  6. The device entered into Bootloader and where the bootloader verifies the valid flag and valid size of new firmware.
  7. If the bootloader satisfied the valid flag and firmware size it will read the new firmware data from the external flash and write it into internal flash.
  8. Once, internal flash is written successfully, Bootloader again verifies the Firmware Integrity using CRC check validation.
  9. Once CRC verification has done successfully, the Device jumps to the application location.
  10. The device starts running from its application location and fails during malloc operation. when it fails during malloc my application explicitly reboots the device.

The device works properly in the up-gradation of new firmware in the following scenarios.

  1. I am using "STM32F412CGU6" microcontroller with MPU protection.
  2. My application stores the new firmware in an external SPI flash. Firmware data received using wirelessly.
  3. Firmware Integrity has been check successfully after receiving firmware wirelessly.
  4. BEFORE SENDING FIRMWARE ACTIVATION COMMAND, PERFORMED HARD REBOOT MANUALLY.
  5. Firmware activation command has sent to the device.
  6. The device is reboot using "HAL_NVIC_SystemReset".
  7. The device entered into Bootloader and where the bootloader verifies the valid flag and valid size of new firmware.
  8. If the bootloader satisfied the valid flag and firmware size it will read the new firmware data from the external flash and write it into internal flash.
  9. Once, internal flash is written successfully, Bootloader again verifies the Firmware Integrity using CRC check validation.
  10. Once CRC verification has done successfully, the Device jumps to the application location.
  11. The device starts running from its application location without any issue.

In working cases, we performed only HARD REBOOT and the device works as per expectation.

Can you please suggest the solution if any?

Regards,

Nikunj Patel

1 REPLY 1
Martin KJELDSEN
Chief III

Hi Nikunj,

Thanks for the details. I don't feel i have much to go on here. To get you right: If you DON'T hard reboot before firmware activation the program will fail malloc and reboot. What is this Firmware activation command ? Can you check that when you try to malloc that the memory malloc is trying to access is available? Maybe the activation command is doing something to mess something up.

/Martin