Bootloader and distance reprogramming
Hello,
I program on the NUCLEO-144 STM32F767ZI board and I have been facing a problem for over a week.
In FLASH memory, I have 3 programs located at specific addresses:
- A bootloader which allows to start on the main programmer or reprogramming program.
- A main program that has several functions like http server, tcp server, usart ...
- A reprogramming program that distance reprograms the stm32 card. The operation is basic, I send a binary file to an http server, then I put at the place of the main program.
When I reprogram with a basic program (for example: to light an LED) everything works. on the other side when I reprogram with a big program (for example: my actual main program) it does not work. The stm32 seems to hang somewhere and I do not know where. I have already tried to remove all the interruptions before jump, it does not change anything.
On the front line of all my programs, I have the "SCB-> VTOR" which points to current address.
Here my bootloader code :
#include "stm32f7xx_hal.h"
#define REPROGRAMMATION_ADDRESS 0x08020000
#define FLASH_MEM1_FIRST_ADDRESS 0x08040000
void JumpInProgram(uint32_t address);
typedef void (*pFunction)(void);
pFunction Jump_To_Application;
int main(void)
{
SCB->VTOR = 0x8000000;
if((*(uint32_t*)0x80C0000 == 1) JumpInProgram(REPROGRAMMATION_ADDRESS); // if variable locaded "0x80C0000" is equal to 1 go to reprogrammation program
else JumpInProgram(FLASH_MEM1_FIRST_ADDRESS); // else principal program
}
void JumpInProgram(uint32_t address)
{
uint32_t JumpAddress = *(__IO uint32_t*)(address + 4);
pFunction Jump = (pFunction)JumpAddress;
__set_MSP(*(__IO uint32_t*)address);
Jump();
}Here my main fonction in principal program for example :
int main(void)
{
SCB->VTOR = 0x8040000;
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_TIM4_Init();
MX_USART1_UART_Init();
MX_USART2_UART_Init();
MX_USART3_UART_Init();
HAL_TIM_Base_Start_IT(&htim4);
HAL_UART_Receive_IT(&huart3, donneetic, 1);
HAL_UART_Receive_IT(&huart1, donneerf, 1);
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
osKernelStart();
}Hoping you can help me, thank you
