Compare commits

...

21 commits

Author SHA1 Message Date
Alin Jerpelea
148c631a2d documentation: Add release notes for 12.2.1 release
This is a local copy taken from the confluence notes
https://cwiki.apache.org/confluence/display/NUTTX/NuttX+12.2.1

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2023-07-10 18:00:25 +08:00
chao an
ec145d5823 sched/pthread: fix race condition on pthread_cond_wait()
pthread_cond_wait() should be an atomic operation in the mutex lock/unlock.
Since the sched_lock() has been wrongly deleted in the previous commit,
the context switch will occurred after the mutex was unlocked:

--------------------------------------------------------------------
  Task1(Priority 100)             |      Task2(Priority 101)
                                  |
  pthread_mutex_lock(mutex);      |
  |                               |
  pthread_cond_wait(cond, mutex)  |
  |  |                            |
  |  |                            |
  |  ->enter_critical_section()   |
  |  ->pthread_mutex_give(mutex)  | ----> pthread_mutex_lock(mutex);    // contex switch to high priority task
  |                               |       pthread_cond_signal(cond);    // signal before wait
  |                               | <---- pthread_mutex_unlock(mutex);  // switch back to original task
  |  ->pthread_sem_take(cond->sem)|                                     // try to wait the signal, Deadlock.
  |  ->leave_critical_section()   |
  |
  |  ->pthread_mutex_take(mutex)  |
  |                               |
  pthread_mutex_lock(mutex);      |
---------------------------------------------------------------------

This PR will bring back sched_lock()/sched_unlock() to avoid context switch to ensure atomicity

Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:14 +08:00
guoshichao
9efa398c69 libs/libc/aio/lio_listio: fix the heap use-after-free bug
1. the lio_sigsetup() method use a universal sighand instance across all
aiocb instances, but inside the lio_sighandler() method, if one aiocb is
handle finished, then this method will free the sighand instance that
come along with current aiocb instance. thus when handle next aiocb
instance, use-after-free crash will happen. in order to solve this
problem, we make each aiocb instance have their own sighand instance
2. make the lio_listio implementation can pass the
ltp/open_posix_testsuite/lio_listio testcases
3. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/lio_listio.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-08 13:49:41 +08:00
Mingjie Shen
0dba857028 drivers/sensors/apds9960.c: Fix resource leak in error handling
Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2023-07-08 13:49:01 +08:00
Mingjie Shen
b6f3f2eedc cxd56_dmac, lcd_dev: fix null pointer dereference
Check return values of following functions for null:
   - board_lcd_getdev
   - get_device

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2023-07-07 15:07:10 -03:00
SPRESENSE
75d62344c2 cxd56/alt1250: Change power on sequence
Change the power on sequence according to ALT1250 modem spec.
2023-07-07 17:25:58 +03:00
Alan Carvalho de Assis
68b67e692e esp32s2: Fix UART1 default pins
The default pins to UART1 should be 17 (TXD) and 18 (RXD).
2023-07-07 16:22:43 +02:00
Jorge Rodriguez Herranz
51f0fc57da Fix gpio outputs from being configured as interrupts in stm32f0l0g0 gpio driver 2023-07-07 16:20:05 +02:00
SPRESENSE
a5fe4ec813 arch: cxd56xx: Fix bug when watchdog restart
Fix a bug that watchdog is expired in less time than the specified time
when restarting without clearing interrupt.
2023-07-07 14:39:18 +03:00
Xiang Xiao
9d1b8f0966 libc/pwd: Correct the geos related comment and ddd ROOT_GEOS macro
fix the minor issue in https://github.com/apache/nuttx/pull/7998

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-07 14:38:30 +03:00
Xiang Xiao
a9c7381b59 libc/pwd: Reuse g_passwd and g_passwd_buffer in getpwbuf
like other similar functions(e.g. getpwnam and getpwuid)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-07 14:38:30 +03:00
guoshichao
11fcbc5c45 libs/libc/aio: fix aio_error compatible bug
1. make the aio_error implementation can pass the
ltp/open_posix_testsuite/aio_error testcases
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_error.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-07 14:37:39 +03:00
SPRESENSE
2bbc0938db drivers: video: isx012: Fix system clock to HV mode
ISX012 doesn't work if CONFIG_CPUFREQ_RELEASE_LOCK is enabled
without this changes.
2023-07-07 12:28:03 +03:00
SPRESENSE
7c9f572eae drivers: video: isx019: Fix system clock to HV mode
ISX019 doesn't work if CONFIG_CPUFREQ_RELEASE_LOCK
is enabled without this changes.

Signed-off-by: Takumi Ando <t-ando@advaly.co.jp>
2023-07-07 12:28:03 +03:00
raiden00pl
b787e9ec3b arch/armv8-m/arm_secure_irq.c: fix writing to the NVIC_AIRCR register
Register key (VECTKEY) must be written, otherwise the write is ignored.

Reference:
https://developer.arm.com/documentation/100235/0004/the-cortex-m33-peripherals/system-control-block/application-interrupt-and-reset-control-register
2023-07-07 12:25:13 +03:00
Mingjie Shen
d905a4e8a0 fs/fat: Fix undefined behavior in signed integer overflow check
Testing for overflow by adding a value to a variable to see if it "wraps
around" works only for unsigned integer values, because signed overflow
has undefined behavior according to the C and C++ standards.

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2023-07-07 12:24:13 +03:00
Petro Karashchenko
8ed5d562ee Revert "tools: Fix CONFIG_BASE_DEFCONFIG generation"
This reverts commit bc4266fa48.
2023-07-07 09:51:10 +02:00
lpxiao
9e719bbbb7 1.arch/arm/src/stm32/stm32_rtcounter.c   up_rtc_initialize Possible stall 2.arch/arm/src/stm32/stm32_rtcounter.c up_rtc_settime memory hardfault 2023-07-07 15:35:15 +08:00
Gregory Nutt
50410cb1d5 Fix Deadloop in VFS if CONFIG_CANCELLATION_POINTS is enabled
If cancellation points are enabled, then the following logic is activated in sem_wait().  This causes ECANCELED to be returned every time that sem_wait is called.

    int sem_wait(FAR sem_t *sem)
    {
      ...

      /* sem_wait() is a cancellation point */

      if (enter_cancellation_point())
        {
    #ifdef CONFIG_CANCELLATION_POINTS
          /* If there is a pending cancellation, then do not perform
           * the wait.  Exit now with ECANCELED.
           */

          errcode = ECANCELED;
          goto errout_with_cancelpt;
    #endif
        }
      ...

Normally this works fine.  sem_wait() is the OS API called by the application and will cancel the thread just before it returns to the application.  Since it is cancellation point, it should never be called from within the OS.

There there is is one perverse cases where sem_wait() may be nested within another cancellation point.  If open() is called, it will attempt to lock a VFS data structure and will eventually call nxmutex_lock().  nxmutex_lock() waits on a semaphore:

   int nxmutex_lock(FAR mutex_t *mutex)
   {
     ...

     for (; ; )
       {
         /* Take the semaphore (perhaps waiting) */

         ret = _SEM_WAIT(&mutex->sem);
         if (ret >= 0)
           {
             mutex->holder = _SCHED_GETTID();
             break;
           }

         ret = _SEM_ERRVAL(ret);
         if (ret != -EINTR && ret != -ECANCELED)
           {
             break;
           }
       }
   ...
}

In the FLAT build, _SEM_WAIT expands to sem_wait().  That causes the error in the logic:  It should always expand to nxsem_wait().  That is because sem_wait() is cancellation point and should never be called from with the OS or the C library internally.

The failure occurs because the cancellation point logic in sem_wait() returns -ECANCELED (via _SEM_ERRVAL) because sem_wait() is nested; it needs to return the -ECANCELED error to the outermost cancellation point which is open() in this case.  Returning -ECANCELED then causes an infinite loop to occur in nxmutex_lock().

The correct behavior in this case is to call nxsem_wait() instead of sem_wait().  nxsem_wait() is identical to sem_wait() except that it is not a cancelation point.  It will return -ECANCELED if the thread is canceled, but only once.  So no infinite loop results.

In addition, an nxsem_wait() system call was added to support the call from nxmutex_lock().

This resolves Issue #9695
2023-07-07 15:34:43 +08:00
Alin Jerpelea
26f5e973f6 documentation: Add release notes for 12.2.0 release
This is a local copy taken from the confluence notes
https://cwiki.apache.org/confluence/display/NUTTX/NuttX+12.2.0

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2023-06-30 16:19:21 +08:00
Alin Jerpelea
67541728cf ReleaseNotes: cleanup
remove double and trailing spaces

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2023-06-30 16:19:21 +08:00
32 changed files with 25919 additions and 25219 deletions

50738
ReleaseNotes

File diff suppressed because it is too large Load diff

View file

@ -100,8 +100,8 @@ void up_secure_irq_all(bool secure)
{
int i;
modreg32(secure ? 0 : NVIC_AIRCR_BFHFNMINS,
NVIC_AIRCR_BFHFNMINS, NVIC_AIRCR);
modreg32((secure ? 0 : NVIC_AIRCR_BFHFNMINS) | NVIC_AIRCR_VECTKEY,
(NVIC_AIRCR_VECTKEY_MASK | NVIC_AIRCR_BFHFNMINS), NVIC_AIRCR);
modreg32(secure ? NVIC_DEMCR_SDME : 0,
NVIC_DEMCR_SDME, NVIC_DEMCR);

View file

@ -400,6 +400,12 @@ static void _dmac_intc_handler(int ch)
int itc;
int err;
if (dev == NULL)
{
dmaerr("Cannot get device with channel number %d.\n", ch);
return;
}
mask = (1u << (ch & 1));
if (is_dmac(2, dev))
@ -442,9 +448,16 @@ static int intr_handler_admac1(int irq, void *context, void *arg)
static int intr_handler_idmac(int irq, void *context, void *arg)
{
struct dmac_register_map *dev = get_device(2); /* XXX */
uint32_t stat = dev->intstatus & 0x1f;
uint32_t stat;
int i;
if (dev == NULL)
{
return -ENODEV;
}
stat = dev->intstatus & 0x1f;
for (i = 2; stat; i++, stat >>= 1)
{
if (stat & 1)

View file

@ -200,7 +200,7 @@ static uint32_t cxd56_getreg(uintptr_t regaddr)
/* Show the register value read */
wdinfo("%08x->%08\n", regaddr, regval);
wdinfo("%08x->%08x\n", regaddr, regval);
return regval;
}
#endif
@ -283,6 +283,7 @@ static int cxd56_start(struct watchdog_lowerhalf_s *lower)
wdinfo("Entry\n");
cxd56_putreg(WDOGLOCK_UNLOCK_KEY, CXD56_WDT_WDOGLOCK);
cxd56_putreg(0, CXD56_WDT_WDOGINTCLR); /* reload by write any value */
cxd56_putreg(WDOGCONTROL_RESEN | WDOGCONTROL_INTEN, CXD56_WDT_WDOGCONTROL);
cxd56_putreg(0, CXD56_WDT_WDOGLOCK);
@ -473,6 +474,7 @@ static int cxd56_settimeout(struct watchdog_lowerhalf_s *lower,
/* Set the WDT register according to calculated value */
cxd56_putreg(WDOGLOCK_UNLOCK_KEY, CXD56_WDT_WDOGLOCK);
cxd56_putreg(0, CXD56_WDT_WDOGINTCLR); /* reload by write any value */
cxd56_putreg(reload, CXD56_WDT_WDOGLOAD);
cxd56_putreg(WDOGCONTROL_RESEN | WDOGCONTROL_INTEN, CXD56_WDT_WDOGCONTROL);
cxd56_putreg(0, CXD56_WDT_WDOGLOCK);

View file

@ -171,6 +171,30 @@ volatile bool g_rtc_enabled = false;
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_rtc_waitlasttask
*
* Description:
* wait task done
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
static inline void stm32_rtc_waitlasttask(void)
{
/* Previous write is done? */
while ((getreg16(STM32_RTC_CRL) & RTC_CRL_RTOFF) == 0)
{
stm32_waste();
}
}
/****************************************************************************
* Name: stm32_rtc_beginwr
*
@ -187,12 +211,7 @@ volatile bool g_rtc_enabled = false;
static inline void stm32_rtc_beginwr(void)
{
/* Previous write is done? */
while ((getreg16(STM32_RTC_CRL) & RTC_CRL_RTOFF) == 0)
{
stm32_waste();
}
stm32_rtc_waitlasttask();
/* Enter Config mode, Set Value and Exit */
@ -216,13 +235,7 @@ static inline void stm32_rtc_beginwr(void)
static inline void stm32_rtc_endwr(void)
{
modifyreg16(STM32_RTC_CRL, RTC_CRL_CNF, 0);
/* Wait for the write to actually reach RTC registers */
while ((getreg16(STM32_RTC_CRL) & RTC_CRL_RTOFF) == 0)
{
stm32_waste();
}
stm32_rtc_waitlasttask();
}
/****************************************************************************
@ -384,6 +397,15 @@ int up_rtc_initialize(void)
putreg16(RTC_MAGIC, RTC_MAGIC_REG);
}
modifyreg16(STM32_RCC_BDCR, 0, RCC_BDCR_LSEON);
/* Wait for the LSE clock to be ready */
while ((getreg16(STM32_RCC_BDCR) & RCC_BDCR_LSERDY) == 0)
{
stm32_waste();
}
/* Select the lower power external 32,768Hz (Low-Speed External, LSE)
* oscillator as RTC Clock Source and enable the Clock.
*/
@ -393,12 +415,10 @@ int up_rtc_initialize(void)
/* Enable RTC and wait for RSF */
modifyreg16(STM32_RCC_BDCR, 0, RCC_BDCR_RTCEN);
/* TODO: Possible stall?
* should we set the timeout period? and return with -1
*/
stm32_rtc_waitlasttask();
stm32_rtc_wait4rsf();
stm32_rtc_waitlasttask();
/* Configure prescaler, note that these are write-only registers */
@ -408,6 +428,7 @@ int up_rtc_initialize(void)
stm32_rtc_endwr();
stm32_rtc_wait4rsf();
stm32_rtc_waitlasttask();
#ifdef CONFIG_RTC_HIRES
/* Enable overflow interrupt - alarm interrupt is enabled in
@ -631,7 +652,6 @@ int up_rtc_settime(const struct timespec *tp)
{
struct rtc_regvals_s regvals;
irqstate_t flags;
uint16_t cntl;
/* Break out the time values */
@ -646,16 +666,11 @@ int up_rtc_settime(const struct timespec *tp)
* register (hi-res mode only)
*/
do
{
stm32_rtc_beginwr();
putreg16(RTC_MAGIC, RTC_MAGIC_TIME_SET);
putreg16(regvals.cnth, STM32_RTC_CNTH);
putreg16(regvals.cntl, STM32_RTC_CNTL);
cntl = getreg16(STM32_RTC_CNTL);
stm32_rtc_endwr();
}
while (cntl != regvals.cntl);
stm32_rtc_beginwr();
putreg16(regvals.cnth, STM32_RTC_CNTH);
putreg16(regvals.cntl, STM32_RTC_CNTL);
stm32_rtc_endwr();
putreg16(RTC_MAGIC_TIME_SET, RTC_MAGIC_REG);
#ifdef CONFIG_RTC_HIRES
putreg16(regvals.ovf, RTC_TIMEMSB_REG);

View file

@ -307,7 +307,7 @@ int stm32_configgpio(uint32_t cfgset)
* Should it configured as an EXTI interrupt?
*/
if ((cfgset & GPIO_EXTI) != 0)
if ((pinmode != GPIO_MODER_OUTPUT) && ((cfgset & GPIO_EXTI) != 0))
{
uint32_t regaddr;
int shift;

View file

@ -602,12 +602,12 @@ if ESP32S2_UART1
config ESP32S2_UART1_TXPIN
int "UART1 Tx Pin"
default 37
default 17
range 0 46
config ESP32S2_UART1_RXPIN
int "UART1 Rx Pin"
default 38
default 18
range 0 46
config ESP32S2_UART1_RTSPIN

View file

@ -74,11 +74,15 @@
# error "Select LTE SPI 4 or 5"
#endif
#define POWER_ON_WAIT_TIME (2) /* ms */
#define ACTIVE_SHUTDOWN_TIME (100) /* ms */
#define TIME_TO_STABLE_VDDIO (10) /* ms */
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static struct spi_dev_s *alt1250_poweron(void);
static struct spi_dev_s *alt1250_poweron(bool keep_on);
static void alt1250_poweroff(void);
static bool alt1250_powerstatus(void);
static int alt1250_hibernation_mode(bool enable);
@ -196,7 +200,7 @@ static void set_spiparam(struct spi_dev_s *spidev)
*
****************************************************************************/
static struct spi_dev_s *alt1250_poweron(void)
static struct spi_dev_s *alt1250_poweron(bool keep_on)
{
struct spi_dev_s *spi;
#if defined(CONFIG_CXD56_LTE_SPI4_DMAC) || defined(CONFIG_CXD56_LTE_SPI5_DMAC)
@ -204,6 +208,38 @@ static struct spi_dev_s *alt1250_poweron(void)
dma_config_t conf;
#endif
/* Hi-Z SHUTDOWN and PowerBTN signals before power-on */
cxd56_gpio_config(ALT1250_SHUTDOWN, false);
/* power on alt1250 modem device and wait until the power is distributed */
board_alt1250_poweron();
up_mdelay(POWER_ON_WAIT_TIME);
/* If keep_on is enabled, skip setting the SHUTDOWN signal to low
* because the ALT1250 is already in the power-on state.
*/
if (!keep_on)
{
/* Drive SHUTDOWN signal low */
cxd56_gpio_write(ALT1250_SHUTDOWN, 0);
}
/* Keep the SHUTDOWN signal low for reset period */
up_mdelay(ACTIVE_SHUTDOWN_TIME);
/* Undrive SHUTDOWN signal to rise up to high by pull-up */
cxd56_gpio_write_hiz(ALT1250_SHUTDOWN);
/* Wait VDDIO on Alt1250 stable */
up_mdelay(TIME_TO_STABLE_VDDIO);
/* Initialize spi deivce */
spi = cxd56_spibus_initialize(SPI_CH);
@ -233,10 +269,6 @@ static struct spi_dev_s *alt1250_poweron(void)
}
#endif
/* power on altair modem device */
board_alt1250_poweron();
/* Input enable */
cxd56_gpio_config(ALT1250_SLAVE_REQ, true);
@ -263,7 +295,6 @@ static struct spi_dev_s *alt1250_poweron(void)
/* enable the SPI pin */
spi_pincontrol(SPI_CH, true);
set_spiparam(spi);
return spi;

View file

@ -37,6 +37,7 @@
#include "cxd56_i2c.h"
#include <arch/board/board.h>
#include <arch/chip/pm.h>
/****************************************************************************
* Pre-processor Definitions
@ -59,6 +60,14 @@
#define POWER_CHECK_RETRY (10)
/****************************************************************************
* Private Data
****************************************************************************/
static struct pm_cpu_freqlock_s g_hv_lock =
PM_CPUFREQLOCK_INIT(PM_CPUFREQLOCK_TAG('I', 'S', 0),
PM_CPUFREQLOCK_FLAG_HV);
/****************************************************************************
* Public Functions
****************************************************************************/
@ -163,6 +172,10 @@ struct i2c_master_s *board_isx012_initialize(void)
{
_info("Initializing ISX012...\n");
/* Fix system clock to HV mode */
up_pm_acquire_freqlock(&g_hv_lock);
#ifdef IMAGER_ALERT
cxd56_gpio_config(IMAGER_ALERT, true);
#endif
@ -184,6 +197,10 @@ int board_isx012_uninitialize(struct i2c_master_s *i2c)
_info("Uninitializing ISX012...\n");
/* Release system clock */
up_pm_release_freqlock(&g_hv_lock);
/* Initialize i2c device */
ret = isx012_uninitialize();

View file

@ -38,6 +38,7 @@
#include "cxd56_clock.h"
#include <arch/board/board.h>
#include <arch/chip/pm.h>
/****************************************************************************
* Pre-processor Definitions
@ -54,6 +55,14 @@
#define POWER_CHECK_RETRY (10)
/****************************************************************************
* Private Data
****************************************************************************/
static struct pm_cpu_freqlock_s g_hv_lock =
PM_CPUFREQLOCK_INIT(PM_CPUFREQLOCK_TAG('I', 'S', 0),
PM_CPUFREQLOCK_FLAG_HV);
/****************************************************************************
* Public Functions
****************************************************************************/
@ -134,6 +143,10 @@ struct i2c_master_s *board_isx019_initialize(void)
_info("Initializing ISX019...\n");
/* Fix system clock to HV mode */
up_pm_acquire_freqlock(&g_hv_lock);
while (!g_rtc_enabled && 0 < retry--)
{
/* ISX019 requires stable RTC */
@ -171,6 +184,10 @@ int board_isx019_uninitialize(struct i2c_master_s *i2c)
cxd56_gpio_write_hiz(PIN_IS_DATA0);
cxd56_gpio_write_hiz(PIN_IS_DATA7);
/* Release system clock */
up_pm_release_freqlock(&g_hv_lock);
/* Uninitialize i2c device */
ret = isx019_uninitialize();

View file

@ -315,6 +315,12 @@ int lcddev_register(int devno)
}
priv->lcd_ptr = board_lcd_getdev(devno);
if (!priv->lcd_ptr)
{
ret = -ENODEV;
goto err;
}
ret = priv->lcd_ptr->getplaneinfo(priv->lcd_ptr, 0, &priv->planeinfo);
if (ret < 0)
{

View file

@ -488,7 +488,7 @@ static altmdm_state_t process_state_poweroff(uint32_t event,
altmdm_event_clear(&g_altmdm_dev.event, EVENT_POWERON);
usec2timespec(RESET_INTERVAL, &interval);
nxsig_nanosleep(&interval, NULL);
g_altmdm_dev.spidev = g_altmdm_dev.lower->poweron();
g_altmdm_dev.spidev = g_altmdm_dev.lower->poweron(false);
g_altmdm_dev.lower->set_mready(false);
g_altmdm_dev.lower->set_wakeup(false);
g_altmdm_dev.lower->irqenable(true);
@ -1534,7 +1534,7 @@ int altmdm_init(FAR struct spi_dev_s *spidev,
g_altmdm_dev.current_state = ALTMDM_STATE_SLEEP;
g_altmdm_dev.vp = VP_V4;
g_altmdm_dev.spidev = g_altmdm_dev.lower->poweron();
g_altmdm_dev.spidev = g_altmdm_dev.lower->poweron(true);
g_altmdm_dev.lower->set_mready(false);
g_altmdm_dev.lower->set_wakeup(false);
g_altmdm_dev.lower->irqenable(true);

View file

@ -1218,6 +1218,7 @@ int apds9960_register(FAR const char *devpath,
if (ret != OK)
{
snerr("ERROR: APDS-9960 is not responding!\n");
kmm_free(priv);
return ret;
}
@ -1227,6 +1228,7 @@ int apds9960_register(FAR const char *devpath,
if (ret < 0)
{
snerr("ERROR: Failed to initialize the APDS9960!\n");
kmm_free(priv);
return ret;
}
@ -1240,6 +1242,7 @@ int apds9960_register(FAR const char *devpath,
if (ret < 0)
{
snerr("ERROR: Failed to initialize the APDS9960!\n");
kmm_free(priv);
return ret;
}
@ -1249,6 +1252,7 @@ int apds9960_register(FAR const char *devpath,
if (ret < 0)
{
snerr("ERROR: Failed to initialize the APDS9960!\n");
kmm_free(priv);
return ret;
}
@ -1262,6 +1266,7 @@ int apds9960_register(FAR const char *devpath,
if (ret < 0)
{
snerr("ERROR: Failed to write APDS9960_GCONFIG4!\n");
kmm_free(priv);
return ret;
}
@ -1271,6 +1276,7 @@ int apds9960_register(FAR const char *devpath,
if (ret < 0)
{
snerr("ERROR: Failed to initialize the APDS9960!\n");
kmm_free(priv);
return ret;
}

View file

@ -44,6 +44,16 @@
#include "inode/inode.h"
#include "fs_fat32.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#if defined(CONFIG_FS_LARGEFILE)
# define OFF_MAX INT64_MAX
#else
# define OFF_MAX INT32_MAX
#endif
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
@ -764,7 +774,7 @@ static ssize_t fat_write(FAR struct file *filep, FAR const char *buffer,
/* Check if the file size would exceed the range of off_t */
if (ff->ff_size + buflen < ff->ff_size)
if (buflen > OFF_MAX || ff->ff_size > OFF_MAX - (off_t)buflen)
{
ret = -EFBIG;
goto errout_with_lock;

View file

@ -307,7 +307,7 @@ struct alt_readdata_s
struct alt1250_lower_s
{
FAR struct spi_dev_s * (*poweron)(void);
FAR struct spi_dev_s * (*poweron)(bool keep_on);
void (*poweroff)(void);
bool (*powerstatus)(void);
int (*hiber_mode)(bool);

View file

@ -71,6 +71,8 @@ SYSCALL_LOOKUP(sethostname, 2)
/* Semaphores */
SYSCALL_LOOKUP(nxsem_wait, 1)
SYSCALL_LOOKUP(sem_destroy, 1)
SYSCALL_LOOKUP(sem_post, 1)
SYSCALL_LOOKUP(sem_clockwait, 3)

View file

@ -89,6 +89,13 @@ int aio_error(FAR const struct aiocb *aiocbp)
{
DEBUGASSERT(aiocbp);
/* the aio_reqprio field must be large or equal than 0 */
if (aiocbp->aio_reqprio < 0)
{
return EINVAL;
}
if (aiocbp->aio_result < 0)
{
return -aiocbp->aio_result;

View file

@ -215,55 +215,25 @@ static int lio_sigsetup(FAR struct aiocb * const *list, int nent,
FAR struct sigevent *sig)
{
FAR struct aiocb *aiocbp;
FAR struct lio_sighand_s *sighand;
struct lio_sighand_s sighand;
sigset_t set;
struct sigaction act;
int status;
int i;
/* Allocate a structure to pass data to the signal handler */
sighand = lib_zalloc(sizeof(struct lio_sighand_s));
if (!sighand)
{
ferr("ERROR: lib_zalloc failed\n");
return -ENOMEM;
}
/* Initialize the allocated structure */
sighand->list = list;
sighand->sig = *sig;
sighand->nent = nent;
sighand->pid = _SCHED_GETPID();
/* Save this structure as the private data attached to each aiocb */
for (i = 0; i < nent; i++)
{
/* Skip over NULL entries in the list */
aiocbp = list[i];
if (aiocbp)
{
FAR void *priv = NULL;
/* Check if I/O is pending for this entry */
if (aiocbp->aio_result == -EINPROGRESS)
{
priv = (FAR void *)sighand;
}
aiocbp->aio_priv = priv;
}
}
memset(&sighand, 0, sizeof(struct lio_sighand_s));
sighand.list = list;
sighand.sig = *sig;
sighand.nent = nent;
sighand.pid = _SCHED_GETPID();
/* Make sure that SIGPOLL is not blocked */
sigemptyset(&set);
sigaddset(&set, SIGPOLL);
status = sigprocmask(SIG_UNBLOCK, &set, &sighand->oprocmask);
status = sigprocmask(SIG_UNBLOCK, &set, &sighand.oprocmask);
if (status != OK)
{
int errcode = get_errno();
@ -282,7 +252,7 @@ static int lio_sigsetup(FAR struct aiocb * const *list, int nent,
sigfillset(&act.sa_mask);
sigdelset(&act.sa_mask, SIGPOLL);
status = sigaction(SIGPOLL, &act, &sighand->oact);
status = sigaction(SIGPOLL, &act, &sighand.oact);
if (status != OK)
{
int errcode = get_errno();
@ -293,6 +263,36 @@ static int lio_sigsetup(FAR struct aiocb * const *list, int nent,
return -errcode;
}
/* Save this structure as the private data attached to each aiocb */
for (i = 0; i < nent; i++)
{
/* Skip over NULL entries in the list */
aiocbp = list[i];
if (aiocbp)
{
FAR void *priv = NULL;
/* Check if I/O is pending for this entry */
if (aiocbp->aio_result == -EINPROGRESS)
{
priv = lib_zalloc(sizeof(struct lio_sighand_s));
if (!priv)
{
ferr("ERROR: lib_zalloc failed\n");
return -ENOMEM;
}
memcpy(priv, (FAR void *)&sighand,
sizeof(struct lio_sighand_s));
}
aiocbp->aio_priv = priv;
}
}
return OK;
}
@ -517,7 +517,12 @@ int lio_listio(int mode, FAR struct aiocb * const list[], int nent,
int ret;
int i;
DEBUGASSERT(mode == LIO_WAIT || mode == LIO_NOWAIT);
if (mode != LIO_WAIT && mode != LIO_NOWAIT)
{
set_errno(EINVAL);
return ERROR;
}
DEBUGASSERT(list);
nqueued = 0; /* No I/O operations yet queued */

View file

@ -27,6 +27,7 @@
#include <nuttx/sched.h>
#include <nuttx/clock.h>
#include <nuttx/mutex.h>
#include <nuttx/semaphore.h>
/****************************************************************************
* Pre-processor Definitions
@ -200,15 +201,13 @@ int nxmutex_lock(FAR mutex_t *mutex)
{
/* Take the semaphore (perhaps waiting) */
ret = _SEM_WAIT(&mutex->sem);
ret = nxsem_wait(&mutex->sem);
if (ret >= 0)
{
mutex->holder = _SCHED_GETTID();
break;
}
ret = _SEM_ERRVAL(ret);
if (ret != -EINTR && ret != -ECANCELED)
else if (ret != -EINTR && ret != -ECANCELED)
{
break;
}

View file

@ -21,6 +21,7 @@
# Add the pwd C files to the build
CSRCS += lib_getpwnam.c lib_getpwnamr.c lib_getpwuid.c lib_getpwuidr.c
CSRCS += lib_pwd_globals.c
ifeq ($(CONFIG_LIBC_PASSWD_FILE),y)
CSRCS += lib_find_pwdfile.c lib_pwd_globals.c

View file

@ -133,13 +133,14 @@ static int pwd_foreach(pwd_foreach_match_t match, uintptr_t arg,
*
* The format of the password file is:
*
* user:x:uid:uid:home
* user:x:uid:uid:geos:home
*
* Where:
* user: User name
* x: Encrypted password
* uid: User ID
* uid: Group ID
* geos: User information
* home: Login directory
*/

View file

@ -24,20 +24,9 @@
#include <nuttx/config.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pwd.h>
#include "pwd/lib_pwd.h"
#include "libc.h"
/****************************************************************************
* Private Data
****************************************************************************/
static FAR char *g_buf;
static FAR struct passwd *g_pwd;
/****************************************************************************
* Public Functions
@ -68,51 +57,8 @@ FAR struct passwd *getpwbuf(uid_t uid, gid_t gid, FAR const char *name,
FAR const char *gecos, FAR const char *dir,
FAR const char *shell)
{
FAR struct passwd *result;
FAR char *newbuf;
size_t buflen;
int err;
buflen = strlen(name) + 1 + strlen(gecos) + 1 + strlen(dir) + 1 +
strlen(shell) + 1;
newbuf = (FAR char *)lib_realloc(g_buf, buflen);
if (!newbuf)
{
err = ENOMEM;
goto error;
}
g_buf = newbuf;
if (!g_pwd)
{
g_pwd = (FAR struct passwd *)lib_malloc(sizeof(struct passwd));
}
if (!g_pwd)
{
err = ENOMEM;
goto error;
}
err = getpwbuf_r(uid, gid, name, gecos, dir, shell,
g_pwd, g_buf, buflen, &result);
if (err)
{
goto error;
}
return result;
error:
lib_free(g_pwd);
lib_free(g_buf);
g_pwd = NULL;
g_buf = NULL;
set_errno(err);
return NULL;
FAR struct passwd *pwd = NULL;
int ret = getpwbuf_r(uid, gid, name, gecos, dir, shell, &g_passwd,
g_passwd_buffer, sizeof(g_passwd_buffer), &pwd);
return ret == 0 ? pwd : NULL;
}

View file

@ -71,7 +71,7 @@ FAR struct passwd *getpwnam(FAR const char *name)
return NULL;
}
return getpwbuf(ROOT_UID, ROOT_GID, ROOT_NAME, ROOT_NAME, ROOT_DIR,
return getpwbuf(ROOT_UID, ROOT_GID, ROOT_NAME, ROOT_GEOCS, ROOT_DIR,
ROOT_SHELL);
#endif
}

View file

@ -82,7 +82,7 @@ int getpwnam_r(FAR const char *name, FAR struct passwd *pwd, FAR char *buf,
return 0;
}
return getpwbuf_r(ROOT_UID, ROOT_GID, ROOT_NAME, ROOT_NAME, ROOT_DIR,
return getpwbuf_r(ROOT_UID, ROOT_GID, ROOT_NAME, ROOT_GEOCS, ROOT_DIR,
ROOT_SHELL, pwd, buf, buflen, result);
#endif
}

View file

@ -70,7 +70,7 @@ FAR struct passwd *getpwuid(uid_t uid)
return NULL;
}
return getpwbuf(ROOT_UID, ROOT_GID, ROOT_NAME, ROOT_NAME, ROOT_DIR,
return getpwbuf(ROOT_UID, ROOT_GID, ROOT_NAME, ROOT_GEOCS, ROOT_DIR,
ROOT_SHELL);
#endif
}

View file

@ -81,7 +81,7 @@ int getpwuid_r(uid_t uid, FAR struct passwd *pwd, FAR char *buf,
return 0;
}
return getpwbuf_r(ROOT_UID, ROOT_GID, ROOT_NAME, ROOT_NAME, ROOT_DIR,
return getpwbuf_r(ROOT_UID, ROOT_GID, ROOT_NAME, ROOT_GEOCS, ROOT_DIR,
ROOT_SHELL, pwd, buf, buflen, result);
#endif
}

View file

@ -33,9 +33,14 @@
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_LIBC_PASSWD_LINESIZE
# define CONFIG_LIBC_PASSWD_LINESIZE 80
#endif
#define ROOT_NAME "root"
#define ROOT_UID 0
#define ROOT_GID 0
#define ROOT_GEOCS "root"
#define ROOT_DIR "/root"
#define ROOT_SHELL "/bin/nsh"
@ -51,12 +56,10 @@ extern "C"
#define EXTERN extern
#endif
#ifdef CONFIG_LIBC_PASSWD_FILE
/* Data for non-reentrant group functions */
EXTERN struct passwd g_passwd;
EXTERN char g_passwd_buffer[CONFIG_LIBC_PASSWD_LINESIZE];
#endif
/****************************************************************************
* Public Function Prototypes

View file

@ -26,8 +26,6 @@
#include "pwd/lib_pwd.h"
#ifdef CONFIG_LIBC_PASSWD_FILE
/****************************************************************************
* Public Data
****************************************************************************/
@ -40,5 +38,3 @@ char g_passwd_buffer[CONFIG_LIBC_PASSWD_LINESIZE];
/****************************************************************************
* Public Functions
****************************************************************************/
#endif /* CONFIG_LIBC_GROUP_FILE */

View file

@ -94,6 +94,7 @@ int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex)
sinfo("Give up mutex / take cond\n");
flags = enter_critical_section();
sched_lock();
mutex->pid = INVALID_PROCESS_ID;
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
mflags = mutex->flags;
@ -116,6 +117,7 @@ int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex)
ret = status;
}
sched_unlock();
leave_critical_section(flags);
/* Reacquire the mutex.

View file

@ -83,6 +83,7 @@
"nx_pthread_exit","nuttx/pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","noreturn","pthread_addr_t"
"nx_vsyslog","nuttx/syslog/syslog.h","","int","int","FAR const IPTR char *","FAR va_list *"
"nxsched_get_stackinfo","nuttx/sched.h","","int","pid_t","FAR struct stackinfo_s *"
"nxsem_wait","nuttx/semaphore.h","","int","FAR sem_t *"
"open","fcntl.h","","int","FAR const char *","int","...","mode_t"
"pgalloc", "nuttx/arch.h", "defined(CONFIG_BUILD_KERNEL)", "uintptr_t", "uintptr_t", "unsigned int"
"pipe2","unistd.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0","int","int [2]|FAR int *","int"

Can't render this file because it has a wrong number of fields in line 2.

View file

@ -250,7 +250,7 @@ tools/mkconfig$(HOSTEXEEXT):
include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig$(HOSTEXEEXT)
$(Q) grep -v "CONFIG_BASE_DEFCONFIG" "$(TOPDIR)/.config" > "$(TOPDIR)/.config.tmp"
$(Q) if ! cmp -s "$(TOPDIR)/.config.tmp" "$(TOPDIR)/.config.orig" ; then \
sed -i.bak "/CONFIG_BASE_DEFCONFIG/ { /-dirty/! s/\"$$/-dirty\"/ }" "$(TOPDIR)/.config"; \
sed -i.bak "/CONFIG_BASE_DEFCONFIG/s/\"$$/-dirty\"/" "$(TOPDIR)/.config"; \
else \
sed -i.bak "s/-dirty//g" "$(TOPDIR)/.config"; \
fi

View file

@ -238,7 +238,7 @@ include\nuttx\config.h: $(TOPDIR)\.config tools\mkconfig$(HOSTEXEEXT)
$(Q) grep -v "CONFIG_BASE_DEFCONFIG" "$(TOPDIR)\.config" > "$(TOPDIR)\.config.tmp"
# In-place edit can mess up permissions on Windows
$(Q) if ! cmp -s "$(TOPDIR)\.config.tmp" "$(TOPDIR)\.config.orig" ; then \
sed "/CONFIG_BASE_DEFCONFIG/ { /-dirty/! s/\"$$/-dirty\"/ }" "$(TOPDIR)\.config" > "$(TOPDIR)\.config-temp"; \
sed "/CONFIG_BASE_DEFCONFIG/s/\"$$/-dirty\"/" "$(TOPDIR)\.config" > "$(TOPDIR)\.config-temp"; \
else \
sed "s/-dirty//g" "$(TOPDIR)\.config" > "$(TOPDIR)\.config-temp"; \
fi