Skip to main content
Visitor II
March 4, 2021
Question

stm32F0 CDC out of work after vector-table relocation

  • March 4, 2021
  • 3 replies
  • 978 views

Hi,

I have an application running on the stm32F072C8U6.

It has a 'bootloader' application at 0x08000000, which successfully jumps to the 'real' application, at 0x08004000.

after vector remap, GPIO USB Keypad works fine, but when PC send a message by USB CDC.

it caused the MCU out of work.

Thanks.

int main(void)
{
 /* USER CODE BEGIN 1 */
 
 /* USER CODE END 1 */
 
 /* MCU Configuration--------------------------------------------------------*/
 
 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();
 
 /* USER CODE BEGIN Init */
 Remap_Table();
 /* USER CODE END Init */
 
 /* Configure the system clock */
 SystemClock_Config();
 
}
 
void Remap_Table(void)
{
 // Copy interrupt vector table to the RAM.
 volatile uint32_t *VectorTable = (volatile uint32_t *)0x20000000;
 uint32_t ui32_VectorIndex = 0;
 
 for(ui32_VectorIndex = 0; ui32_VectorIndex < 48; ui32_VectorIndex++)
 {
 VectorTable[ui32_VectorIndex] = *(__IO uint32_t*)((uint32_t)0x08004000 + (ui32_VectorIndex << 2));
 }
 
 __HAL_RCC_AHB_FORCE_RESET();
 
 // Enable SYSCFG peripheral clock
 __HAL_RCC_SYSCFG_CLK_ENABLE();
 
 __HAL_RCC_AHB_RELEASE_RESET();
 
 // Remap RAM into 0x0000 0000
 __HAL_SYSCFG_REMAPMEMORY_SRAM();
}
  1.  

 

    This topic has been closed for replies.

    3 replies

    Super User
    March 4, 2021

    I don't think the problem is the vector table relocation.

    > it caused the MCU out of work.

    Try to be more specific. What are exactly the symptoms? Try to debug it as usually.

    JW

    LLiao.1Author
    Visitor II
    March 4, 2021

    it caused the MCU out of work. => I mean when STM32F072 get CDC message from PC USB, it will cause the MCU out of work. if there is no CDC message from PC USB, everything work well( GPIO, USB Keypad ...)

    Explorer
    March 4, 2021

    Applications with fixed preceeding bootloader are usually tricky to debug.

    You might need to play with your debug settings (like attach to a running application), or use instrumentation.

    LLiao.1Author
    Visitor II
    March 5, 2021

    Solved ! It's cause by compiler Option, Optimize for size work abnormal, finally I chose Optimize most (-O3),