Guten Tag!
Ich will aus meinem Programm nach empfangen eines Zeichens über UART in
den Bootloader springen. Ich benutze freeRTOS auf einem STM32L476 µC.
Dazu habe ich eine Funktion erstellt, die auch funktioniert, solange ich
sie vor dem Starten des schedulers ausführe, also ganz am Anfang im
main() Programm. Rufe ich die Funktion innerhalb eines Tasks auf, so
komme ich in den hard_fault handler. Ich habe alle interrupts
deaktiviert und weiß wirklich nicht woran es liegen kann. ...
mein Code der bootloaderstart Funktion:
void (*SysMemBootJump)(void);
volatile uint32_t addr = 0x1FFF0000;
if(BootLoaderStatus == 1)
{
//Shutdown any tasks running
//vTaskResumeAll();
/*
HAL_UART_DeInit(&huart1);
HAL_UART_DeInit(&huart2);
HAL_GPIO_DeInit(GPIOA,GPIO_PIN_6);
HAL_GPIO_DeInit(GPIOD,GPIO_PIN_5);
HAL_GPIO_DeInit(GPIOD,GPIO_PIN_4);
*/
HAL_RCC_DeInit();
//Reset the systick timer
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
//Disable Interrupts
//__set_PRIMASK(1);// oder
__disable_irq();
portDISABLE_INTERRUPTS();
vTaskSuspendAll();
portNVIC_SYSTICK_CTRL_REG &= ~portNVIC_SYSTICK_ENABLE_BIT;
//Remap system memory
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
HAL_DeInit();
//suspend all tasks from freeRTOS
vTaskSuspendAll();
//vTaskEndScheduler ();
//Set jump memory location for system memory (bootloader)
//Addres + 4 bytes offset which specifies jump location where
programm starts
SysMemBootJump = (void(*)(void)) (*((uint32_t *)(addr + 4)));
//Set the main stack pointer to its default value
__set_MSP(*(uint32_t *)addr);
//__set_MSP(0x20001000);
//Call the function to jump to the set location
//This will start system memory execution
SysMemBootJump();
while(1);
}
für hilfe wäre ich dankbar, lg benjamin.
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.