FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [March 2012 Threads] GCC/ARM_CM3 port locks up during initPosted by Rod on March 27, 2012 I'm using the GCC/ARM_CM3 port of version 7.1.0. My startup code creates tasks and other FreeRTOS objects, and does much other initialization before calling vTaskStartScheduler. It's locking up during the init. I think the heap_2 memory allocation is attempting to invoke the scheduler before it starts. I believe it goes something like this:
I call xTaskCreate (or create a queue or whatever), which calls pvPortMalloc in heap_2.c. This calls xTaskResumeAll.
Because other tasks have already been created, xTaskResumeAll manages the ready/pending list and possibly sets xYieldRequired. I suspect it is then calling portYIELD_WITHIN_API, which calls vPortYieldFromISR and invokes a context switch before I've called vTaskStartScheduler. The application locks up.
I think it might work if I were to somehow make sure that interrupts can never be enabled before the scheduler starts. Instead, I worked around it by creating just one task, starting the scheduler, and doing the rest of my init within the task.
Is this "expected" behavior, or should I have been able to do all my initialization before the scheduler starts?
RE: GCC/ARM_CM3 port locks up during initPosted by Richard on March 28, 2012 “I think the heap_2 memory allocation is attempting to invoke the scheduler before it starts. I believe it goes something like this:
I call xTaskCreate (or create a queue or whatever), which calls pvPortMalloc in heap_2.c. This calls xTaskResumeAll.” xTaskResumeAll() will not attempt a context switch if the scheduler has not started. It will attempt a context switch only if either tick interrupts have been missed while the scheduler was suspended, or tasks were placed into the pending ready list while the scheduler was suspended - but there will be no ticks if the scheduler has not started, and kernel API functions that unblock a task should not be executed before the kernel is started, so neither of these conditions can be true. However...if you have interrupts enabled at this point, and an interrupt executes, and the interrupt itself does something to the kernel, then you will definitely have problems. The kernel itself will keep interrupts disabled from the point the first API call is made to the point that the scheduler is started. Are you manually enabling interrupts anywhere? Regards.
RE: GCC/ARM_CM3 port locks up during initPosted by Rod on April 3, 2012 Thank you for your response.
I am using interrupts before the scheduler starts, but I make sure that the interrupt handler does not call any rtos API before I start the scheduler. I overlooked the fact that the API calls to create tasks, etc. were themselves disabling interrupts and not reenabling them if the scheduler has not yet started. So my interrupts did not trigger, and that's why my app was locking up.
I explicitly reenabled interrupts after making API calls prior to starting the scheduler, and now my code works. However, I think it will make more sense to start the scheduler earlier and do most of my other initialization from a task, rather than trying to do things that require interrupts before I start the scheduler. Now that I see how it works, it makes sense to me.
Thanks for your assistance! :-)
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|