Xtensa ESP32: Fix APP CPU startup... Can't use semaphores on the IDLE thread.
This commit is contained in:
parent
6d5a718b98
commit
81697f2285
|
@ -41,13 +41,12 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <semaphore.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
#include <nuttx/semaphore.h>
|
#include <nuttx/spinlock.h>
|
||||||
#include <nuttx/sched_note.h>
|
#include <nuttx/sched_note.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
|
@ -65,7 +64,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static volatile bool g_appcpu_started;
|
static volatile bool g_appcpu_started;
|
||||||
static sem_t g_appcpu_interlock;
|
static volatile spinlock_t g_appcpu_interlock SP_SECTION;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* ROM function prototypes
|
* ROM function prototypes
|
||||||
|
@ -169,7 +168,7 @@ void xtensa_appcpu_start(void)
|
||||||
/* Handle interlock*/
|
/* Handle interlock*/
|
||||||
|
|
||||||
g_appcpu_started = true;
|
g_appcpu_started = true;
|
||||||
sem_post(&g_appcpu_interlock);
|
spin_unlock(&g_appcpu_interlock);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
/* Reset scheduler parameters */
|
||||||
|
|
||||||
|
@ -271,8 +270,7 @@ int up_cpu_start(int cpu)
|
||||||
* have priority inheritance enabled.
|
* have priority inheritance enabled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sem_init(&g_appcpu_interlock, 0, 0);
|
spin_initialize(&g_appcpu_interlock, SP_LOCKED);
|
||||||
sem_setprotocol(&g_appcpu_interlock, SEM_PRIO_NONE);
|
|
||||||
|
|
||||||
/* Flush and enable I-cache for APP CPU */
|
/* Flush and enable I-cache for APP CPU */
|
||||||
|
|
||||||
|
@ -315,16 +313,8 @@ int up_cpu_start(int cpu)
|
||||||
|
|
||||||
/* And wait for the initial task to run on CPU1 */
|
/* And wait for the initial task to run on CPU1 */
|
||||||
|
|
||||||
while (!g_appcpu_started)
|
spin_lock(&g_appcpu_interlock);
|
||||||
{
|
DEBUGASSERT(g_appcpu_started);
|
||||||
ret = sem_wait(&g_appcpu_interlock);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
DEBUGASSERT(errno == EINTR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sem_destroy(&g_appcpu_interlock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|
|
@ -145,15 +145,16 @@ spinlock_t up_testset(volatile FAR spinlock_t *lock);
|
||||||
* Initialize a non-reentrant spinlock object to its initial, unlocked state.
|
* Initialize a non-reentrant spinlock object to its initial, unlocked state.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* lock - A reference to the spinlock object to be initialized.
|
* lock - A reference to the spinlock object to be initialized.
|
||||||
|
* state - Initial state of the spinlock {SP_LOCKED or SP_UNLOCKED)
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None.
|
* None.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* void spin_initialize(FAR spinlock_t *lock); */
|
/* void spin_initialize(FAR spinlock_t *lock, spinlock_t state); */
|
||||||
#define spin_initialize(i) do { (l) = SP_UNLOCKED; } while (0)
|
#define spin_initialize(l,s) do { *(l) = (s); } while (0)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: spin_initializer
|
* Name: spin_initializer
|
||||||
|
|
Loading…
Reference in New Issue