2019-04-09 01:26 AM
Hi,
I'm writing a custom bootloader that reads a *.dfu file from an USB memory stick and programs the internal/external flash accordingly.
So far, everything is working fine... I've tested it on an Nucleo STM32F767 and on a STM32F746G-DISCO and I can successfully update my applications just by putting the new *.dfu on a USB MSC.
The only problem I'm facing is with the FMC controller...if it's not used/initialized in the bootloader, jumping to applications works fine... if the bootloader initialize the FMC, then jumping to the application at the end of the boot process fails...
The question is: how am I supposed to de-initialize the FMC ? as I'm using the external SDRAM of the STM32F746G-DISCO, calling HAL_SDRAM_DeInit() is enough ?
Reported below is my jump-code...
any ideas ?
thanks a lot,
Giampaolo
void executeApplicationCode(void)
{
uint32_t appStack;
pFunction appEntry;
#if 0
// SysTick is not used so far...
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
#endif
HAL_RCC_DeInit();
HAL_DeInit();
// FPU settings
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); // set CP10 and CP11 Full Access
#endif
// Reset the RCC clock configuration to the default reset state
RCC->CR |= (uint32_t)0x00000001; // Set HSION bit
RCC->CFGR = 0x00000000; // Reset CFGR register
RCC->CR &= (uint32_t)0xFEF6FFFF; // Reset HSEON, CSSON and PLLON bits
RCC->PLLCFGR = 0x24003010; // Reset PLLCFGR register
RCC->CR &= (uint32_t)0xFFFBFFFF; // Reset HSEBYP bit
RCC->CIR = 0x00000000; // Disable all interrupts
#if 0
__disable_irq();
#endif
// get the application stack pointer
appStack = (uint32_t) * ((__IO uint32_t*)APPLICATION_ADDRESS);
// get the application entry point
appEntry = (pFunction) * (__IO uint32_t*) (APPLICATION_ADDRESS + 4);
// reconfigure vector table offset
SCB->VTOR = APPLICATION_ADDRESS;
// initialize user application's Stack Pointer
__set_MSP(appStack);
// jump to application address
appEntry();
}
and here is my de-initialization function (invoked before jumping to the app):
void peripheralsDeinitialize(void)
{
HAL_DisableFMCMemorySwapping();
// HAL_DisableMemorySwappingBank();
SCB_DisableICache();
SCB_DisableDCache();
// MX_USB_HOST_Init();
USBH_DeInit(&hUsbHostFS);
// MX_FATFS_Init();
// MX_USART6_UART_Init();
HAL_UART_DeInit(&huart6);
// tengo la seriale 1 attiva per il debug
// MX_USART1_UART_Init();
// HAL_UART_DeInit(&huart1);
// MX_TIM8_Init();
HAL_TIM_Base_DeInit(&htim8);
// MX_TIM5_Init();
HAL_TIM_Base_DeInit(&htim5);
// MX_TIM3_Init();
HAL_TIM_Base_DeInit(&htim3);
// MX_TIM2_Init();
HAL_TIM_Base_DeInit(&htim2);
// MX_TIM1_Init();
HAL_TIM_Base_DeInit(&htim1);
// MX_QUADSPI_Init();
HAL_QSPI_DeInit(&hqspi);
// MX_LTDC_Init();
HAL_LTDC_DeInit(&hltdc);
// MX_GFXSIMULATOR_Init();
// MX_FMC_Init(); // WARNING! se e' presente, il bootloader non e' in grado di lanciare correttamente il testTouchGFX_03 HAL_SDRAM_DeInit()
HAL_SDRAM_DeInit(&hsdram1); // non avendo inizializzato l'FMC, non lo deinizializzo neppure...
// MX_DMA2D_Init();
HAL_DMA2D_DeInit(&hdma2d);
// MX_DCMI_Init();
HAL_DCMI_DeInit(&hdcmi);
// MX_ADC3_Init();
HAL_ADC_DeInit(&hadc3);
// MX_GPIO_Init();
#if 0
__HAL_RCC_GPIOA_CLK_DISABLE();
__HAL_RCC_GPIOB_CLK_DISABLE();
__HAL_RCC_GPIOC_CLK_DISABLE();
__HAL_RCC_GPIOD_CLK_DISABLE();
__HAL_RCC_GPIOG_CLK_DISABLE();
__HAL_RCC_GPIOH_CLK_DISABLE();
__HAL_RCC_USART3_CLK_DISABLE();
#endif
}
2019-04-09 03:01 AM
Is space of your bootloader-program enough?
2019-04-09 03:12 AM
Hi slh,
yes... I'm using 60% of the bootloader-reserved space...
tnx,
Giampaolo
2019-04-09 03:34 AM
So I think maybe you have conflict with pins configuration... for example PB5 is USB OTG and FMC_CLK_Enable.
2019-04-09 08:54 AM
Hi slh...
... I've been looking for conflicts the whole afternoon but so far... it seems to me that is something related to the application and not to the bootloader...
I can see that the app is starting and passing all its initialization phases... but there is something wrong in touchGFX somehow.
Giampaolo
2019-04-10 02:14 AM
Hi all,
when launched from my bootloader, touchGFX-based applications hangs right after calling touchgfx::HAL::getInstance()->taskEntry() while non-touchGFX applications are fine.
Calling touchgfx::HAL::getInstance()->taskEntry() seems to block even High-priority tasks (if defined)... and no hw fault is reported...
Anyone else has incountered such problem ?
tnx,
Giampaolo
2019-04-10 03:07 AM
got it!
it seems that I'm falling into an LTDC_ER_IRQHandler
Giampaolo