cancel
Showing results for 
Search instead for 
Did you mean: 

Problem after jump from bootloader to RTOS application (Freertos) with call osKernelStart();

LROUS.14
Associate

Hello,

I have problem after jump from bootloader to FreeRTOS application

I use STM32F09 (HAL) chip.

Jump from bootloader to Freertos application => OK

But when I call "osKernelStart()" board crashed

In debug I crashed in function

xPortStartScheduler()

---------------------

This is my code to jump to FreertosApplication

__entry_point = 0x0801A191

void startFirmwareApplication(void)
{
 
    /// BOOT START APPLICATION (i.e execute  SP310 FIRMWARE entry point)
    MSG(" mainTask ***   BOOT  START APPLICATION \n");
 
    vTaskSuspendAll();
    taskDISABLE_INTERRUPTS();
 
     __disable_irq();
 
    __HAL_RCC_GPIOE_CLK_ENABLE();
 
    //__HAL_RCC_GPIOB_CLK_ENABLE(); //@TODO
 
 
    GPIO_InitTypeDef GPIO_InitStruct;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 
    GPIO_InitStruct.Pin = GPIO_PIN_7;
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
    GPIO_InitStruct.Pin = GPIO_PIN_0;
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
    GPIO_InitStruct.Pin = GPIO_PIN_8;
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
 
    //    GPIO_InitStruct.Pin = GPIO_PIN_1; //@TODO
    //    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
    //    GPIO_InitStruct.Pin = GPIO_PIN_2;
    //    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
    //    GPIO_InitStruct.Pin = GPIO_PIN_10;
    //    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 
    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_7, GPIO_PIN_SET);
    //    HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET); //@TODO
 
    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_0, GPIO_PIN_SET);
    //    HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_RESET); //@TODO
 
    HAL_GPIO_WritePin(GPIOE, GPIO_PIN_8, GPIO_PIN_SET);
    //    HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET); //@TODO
 
 
    SysTick->CTRL = 0;
    SysTick->LOAD = 0;
    SysTick->VAL = 0;
 
    HAL_RCC_DeInit();
 
    /* Disable all interrupts */
    NVIC->ICER[0] = 0xFFFFFFFF;
    /* Clear all pending interrupts */
    NVIC->ICPR[0] = 0xFFFFFFFF;
 
    /* Clear all interrupt priority */
    for (int tmp = 0; tmp < 7; tmp++) {
        NVIC->IP[tmp] = 0x00;
    }
 
 
    auto address = reinterpret_cast<uint32_t>(__entry_point);
 
    /* change control register */
    __set_CONTROL(0);
 
    __set_MSP(address);
 
 
    __entry_point();
 
    }

This is my code in Freertos appliction to remap vector table

#define FIRMWARE_START_ADDR 0x0801A191
 
volatile uint32_t VectorTable[48] __attribute__((section(".RAMVectorTable")));
 
void Remap_Table(void)
{
    uint32_t i = 0;
 
    for(i = 0; i < 48; i++)
    {
        VectorTable[i] = *(__IO uint32_t*)(FIRMWARE_START_ADDR + (i<<2));
    }
 
    __HAL_SYSCFG_REMAPMEMORY_SRAM();
 
    // Enable the SYSCFG peripheral clock
    __HAL_RCC_SYSCFG_CLK_ENABLE();
    // Remap SRAM at 0x00000000
 
    MX_GPIO_Init();
 
    HAL_GPIO_WritePin(LED_BLUE_GPIO_Port,LED_RED_Pin,GPIO_PIN_RESET);
    HAL_GPIO_WritePin(LED_BLUE_GPIO_Port,LED_BLUE_Pin,GPIO_PIN_SET);
}
 
 
 
int main(void)
{
  /* USER CODE BEGIN 1 */
 
  /* USER CODE END 1 */
	Remap_Table();
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  HAL_GPIO_WritePin(LED_BLUE_GPIO_Port,LED_RED_Pin,GPIO_PIN_SET);
  HAL_GPIO_WritePin(LED_BLUE_GPIO_Port,LED_BLUE_Pin,GPIO_PIN_RESET);
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
 
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_CAN_Init();
  MX_TIM16_Init();
  /* USER CODE BEGIN 2 */
 
  HAL_GPIO_WritePin(LED_BLUE_GPIO_Port,LED_RED_Pin,GPIO_PIN_RESET);
  HAL_GPIO_WritePin(LED_BLUE_GPIO_Port,LED_BLUE_Pin,GPIO_PIN_RESET);
  /* USER CODE END 2 */
 
  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */
 
  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */
 
  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */
 
  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */
 
 
  /* Create the thread(s) */
  /* definition and creation of mainTask */
  osThreadDef(mainTask, StartDefaultTask, osPriorityNormal, 0, 256);
  mainTaskHandle = osThreadCreate(osThread(mainTask), NULL);
 
  HAL_GPIO_WritePin(LED_BLUE_GPIO_Port,LED_GREEN_Pin,GPIO_PIN_RESET);
  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */
 
  /* Start scheduler */
  osKernelStart(); // board crashed here
 
  /* We should never get here as control is now taken by the scheduler */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
 
 
  while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}
 

can you help me please ?

Best regards

Loïc

2 REPLIES 2
Piranha
Chief II
    __HAL_SYSCFG_REMAPMEMORY_SRAM();
 
    // Enable the SYSCFG peripheral clock
    __HAL_RCC_SYSCFG_CLK_ENABLE();
    // Remap SRAM at 0x00000000

The order...

LROUS.14
Associate

Good afternoon,

I change instruction order

but it the same

freertos doesn't start correctly

best regards