2024-06-05 06:11 AM
I want to perform the bootloader on my stm32l072kzt 192kb microcontroller without the need to use serial interfaces, my idea is to download a new firmware from the cloud and then update the computer with this new firmware. However, it seems to me that he doesn't jump from bank 1 to bank 2, can you confirm and explain this to me? Furthermore, what are the ways to bootloader the stm32l072kzt 192kb microcontroller?
2024-06-13 09:16 AM - edited 2024-06-13 09:17 AM
>>I need it to work like this:
You need is for it to work properly, and in a way that's as bulletproof as possible, to any user interactions, power-loss, etc. There's a difference.
>>But I can't do anything manually.
You are in control of all the code running in the micro-controller, you can get to decide what it does. The more complex and convoluted you make it the more prone to bricking the devices you'll get and the likelihood it will need physical human interaction with the device.
You always want something on the device that is viable, and will run the most current software out of reset, and will recover/reinitiate in circumstance that one of the steps failed.
Reprogramming Option Bytes opens a number of windows for failure, ST also treats resets and power-cycling somewhat differently, as it's a potential attack vector for recovering protected firmware / readout-protection.
2024-06-14 07:43 AM
void SystemClock_Config(void);
void JumpToApplication(uint32_t address);
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_ADC_Init();
MX_IWDG_Init();
MX_LPUART1_UART_Init();
MX_RTC_Init();
MX_DAC_Init();
uint32_t address = 0x08018000;
JumpToApplication(address);
while (1)
{
}
}
void JumpToApplication(uint32_t address)
{
__disable_irq();
HAL_RCC_DeInit();
HAL_DeInit();
__set_MSP(*((volatile uint32_t*)address));
uint32_t resetHandlerAddress = *((volatile uint32_t*)(address + 4));
void (*resetHandler)(void) = (void (*)(void))resetHandlerAddress;
resetHandler();
}
However, the slow execution problem still occurs on bank2. My bank2 firmware runs at normal speed when it is on bank1, but when it is on bank2 with the same settings without changing absolutely anything, it runs slowly.
So me running firmware2 on bank1 works perfectly at its expected speed.
But I run the same firmware2 on bank2 its execution speed becomes slow.
I don't know if there might be something there, but I noticed these differences in bank1 and bank2. Since it is the same firmware for both.
BANK1
5000
5000
36
5001
uwTick normally varied e.g. 12361.
BANK2
TICK __weak void HAL_Delay(uint32_t Delay)
5000
5000
0 (different tickstart, always at 0)
5001
/**
* @brief Provides a tick value in millisecond.
* @note This function is declared as __weak to be overwritten in case of others
* implementations in user file.
* @retval tick value
*/
__weak uint32_t HAL_GetTick(void)
{
return uwTick;
}