cancel
Showing results for 
Search instead for 
Did you mean: 

stm32F0 CDC out of work after vector-table relocation

LLiao.1
Associate II

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.  

 

5 REPLIES 5

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

Ozone
Lead II

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.

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 ...)

Yes, you are right, I tried it on NUCLEO-F072RB, it works fine after vector remap, Because I am using STM32F072C8U6, FLASH only 64K, Bootloader about 16K, my app in debug mode around 57K, in Release mode arount 29K. I can try to reduce the code and debug it. Thanks

LLiao.1
Associate II

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