Picon

time_t (unsigned/signed)

Greg, 


I note that NuttX time_t is not signed, I cannot found any detail of signed/unsigned in POSIX. 

But in Linux and other system that i know time_t is signed.


It could be better to set time_t signed ? 


Pierre



__._,_.___
Posted by: pn_bouteville-Qt13gs6zZMY@public.gmane.org



__,_._,___
Picon

[PATCH] sched: \0-terminate strings in any case

strncpy will not copy the terminating \0 into the destination if the
source is larger than the size of the destination.
Ensure that the last byte is always zero and let strncpy only copy
CONFIG_TASK_NAME_SIZE-1 bytes.

The issue of unterminated names can be observed in ps when creating a
pthread while CONFIG_TASK_NAME_SIZE is set to 8.

This patch fixes pthread_create(), task_namesetup() and prctl(). The
idle task in sched/os_start.c is already using strncpy with
CONFIG_TASK_NAME_SIZE-1 after nulling the tcb so there is no issue
there.
---
 nuttx/sched/pthread/pthread_create.c | 3 ++-
 nuttx/sched/task/task_prctl.c        | 5 +++--
 nuttx/sched/task/task_setup.c        | 3 ++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/nuttx/sched/pthread/pthread_create.c b/nuttx/sched/pthread/pthread_create.c
index 70c00a4..9d530f6 100644
--- a/nuttx/sched/pthread/pthread_create.c
+++ b/nuttx/sched/pthread/pthread_create.c
 <at>  <at>  -114,7 +114,8  <at>  <at>  static inline void pthread_argsetup(FAR struct pthread_tcb_s *tcb, pthread_addr_
 #if CONFIG_TASK_NAME_SIZE > 0
   /* Copy the pthread name into the TCB */

-  strncpy(tcb->cmn.name, g_pthreadname, CONFIG_TASK_NAME_SIZE);
+  tcb->cmn.name[CONFIG_TASK_NAME_SIZE-1] = 0;
+  strncpy(tcb->cmn.name, g_pthreadname, CONFIG_TASK_NAME_SIZE-1);
 #endif /* CONFIG_TASK_NAME_SIZE */

   /* For pthreads, args are strictly pass-by-value; that actual
diff --git a/nuttx/sched/task/task_prctl.c b/nuttx/sched/task/task_prctl.c
index b0e00f3..f9b807d 100644
--- a/nuttx/sched/task/task_prctl.c
+++ b/nuttx/sched/task/task_prctl.c
 <at>  <at>  -133,9 +133,10  <at>  <at>  int prctl(int option, ...)

         if (option == PR_SET_NAME)
           {
-            /* tcb->name may not be null-terminated */
+            /* Ensure that tcb->name will be null-terminated, truncating if necessary */

-            strncpy(tcb->name, name, CONFIG_TASK_NAME_SIZE);
+            strncpy(tcb->name, name, CONFIG_TASK_NAME_SIZE-1);
+            tcb->name[CONFIG_TASK_NAME_SIZE-1] = '\0';
           }
         else
           {
diff --git a/nuttx/sched/task/task_setup.c b/nuttx/sched/task/task_setup.c
index 1b838ee..f76f99f 100644
--- a/nuttx/sched/task/task_setup.c
+++ b/nuttx/sched/task/task_setup.c
 <at>  <at>  -425,7 +425,8  <at>  <at>  static void task_namesetup(FAR struct task_tcb_s *tcb, FAR const char *name)

   /* Copy the name into the TCB */

-  strncpy(tcb->cmn.name, name, CONFIG_TASK_NAME_SIZE);
+  tcb->cmn.name[CONFIG_TASK_NAME_SIZE-1] = 0;
+  strncpy(tcb->cmn.name, name, CONFIG_TASK_NAME_SIZE-1);
 }
 #else
 #  define task_namesetup(t,n)
-- 
1.8.4.2

-- 
- Daniel Willmann <dwillmann@...>       http://www.sysmocom.de/
=======================================================================
* sysmocom - systems for mobile communications GmbH
* Schivelbeiner Str. 5
* 10439 Berlin, Germany
* Sitz / Registered office: Berlin, HRB 134158 B
* Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte

------------------------------------
Posted by: Daniel Willmann <dwillmann@...>
------------------------------------

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

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/nuttx/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/nuttx/join
    (Yahoo! ID required)

<*> To change settings via email:
    nuttx-digest@... 
    nuttx-fullfeatured@...

<*> To unsubscribe from this group, send an email to:
    nuttx-unsubscribe@...

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

Picon

Using USB serial (possibly usbnsh) on STM32F401

Hello!

I'd like to ask how good is the support for USB serial console on 
STM32F401 chips? These can be found on Nucleo F401 boards, but there's 
no usbnsh config for them. Given this and the recent discussion about 
USB in STM32F429 (which probably doesn't apply to STM32F401, the 
discussion is about USB HS, STM32F401 have USB FS only) I think it's 
better to ask before I decide to use STM32F401 in  place of STM32F103.

Thx in advance!

Regards,
FCh

------------------------------------
Posted by: Freddie Chopin <freddie_chopin@...>
------------------------------------

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

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/nuttx/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/nuttx/join
    (Yahoo! ID required)

<*> To change settings via email:
    nuttx-digest@... 
    nuttx-fullfeatured@...

<*> To unsubscribe from this group, send an email to:
    nuttx-unsubscribe@...

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

Picon

nuttx boot up question

Hi Everybody:

When i porting nuttx to my board (allwinner-a10), After up_irqinitialize() and irqenable(); When i call up_enable_irq() to enable timer intterupt and i can't see any debug message by lldbg(); What's matter with it,after enable up_enable_irq;



__._,_.___
Posted by: maosuyun2009-/E1597aS9LQAvxtiuMwx3w@public.gmane.org



__,_._,___
Picon

[PATCH] drivers/serial: Re-initialize semaphores on uart_close()

In case a thread is doing a blocking operation (e.g. read()) on a serial
device, while it is being terminated by pthread_cancel(), then
uart_close() gets called, but the semaphore (dev->recv.sem in the above
example) is still blocked.

This means that once the serial device is opened next time, data will
arrive on the serial port (and driver interrupts handled as normal), but
the received characters never arrive in the reader thread.

This patch adresses the problem by re-initializing the semaphores on the
last uart_close() on the device.
---
 nuttx/drivers/serial/serial.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/nuttx/drivers/serial/serial.c b/nuttx/drivers/serial/serial.c
index 9754bf3..940095e 100644
--- a/nuttx/drivers/serial/serial.c
+++ b/nuttx/drivers/serial/serial.c
 <at>  <at>  -110,6 +110,16  <at>  <at>  static const struct file_operations g_serialops =
  ************************************************************************************/

 /************************************************************************************
+ * Name: sem_reinit
+ ************************************************************************************/
+
+static int sem_reinit(sem_t *sem, int pshared, unsigned int value)
+{
+  sem_destroy(sem);
+  return sem_init(sem, pshared, value);
+}
+
+/************************************************************************************
  * Name: uart_takesem
  ************************************************************************************/

 <at>  <at>  -1109,6 +1119,18  <at>  <at>  static int uart_close(FAR struct file *filep)

   irqrestore(flags);

+  /* We need to re-initialize the semaphores if this is the last close
+   * of the device, as the close might be caused by pthread_cancel() of
+   * a thread currently blocking on any of them */
+
+  sem_reinit(&dev->xmitsem,  0, 0);
+  sem_reinit(&dev->recvsem,  0, 0);
+  sem_reinit(&dev->xmit.sem, 0, 1);
+  sem_reinit(&dev->recv.sem, 0, 1);
+#ifndef CONFIG_DISABLE_POLL
+  sem_reinit(&dev->pollsem,  0, 1);
+#endif
+
   uart_givesem(&dev->closesem);
   return OK;
  }
-- 
2.1.3

-- 
- Harald Welte <laforge@...>           http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)

------------------------------------
Posted by: Harald Welte <laforge@...>
------------------------------------

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

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/nuttx/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/nuttx/join
    (Yahoo! ID required)

<*> To change settings via email:
    nuttx-digest@... 
    nuttx-fullfeatured@...

<*> To unsubscribe from this group, send an email to:
    nuttx-unsubscribe@...

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

Picon

sscanf: better posix conformance [1 Attachment]

<*>[Attachment(s) from Sebastien Lorquet included below]

Greg,

I tried sscanf with "%02X" and got surprised that the result was intepreted as
decimal.

According to opengroup, %x and %X should be both accepted for hex data parsing:

http://pubs.opengroup.org/onlinepubs/009695399/functions/fscanf.html

Attached is a simple patch to support this.

Best regards,

-- 
S├ębastien Lorquet

<*>Attachment(s) from Sebastien Lorquet:

<*> 1 of 1 File(s)
https://groups.yahoo.com/neo/groups/nuttx/attachments/566399035;_ylc=X3oDMTJydjNtNTkwBF9TAzk3MzU5NzE0BGdycElkAzIzMzg5MDcwBGdycHNwSWQDMTcwNTAwNjU1OQRzZWMDYXR0YWNobWVudARzbGsDdmlld09uV2ViBHN0aW1lAzE0MTgzNzU1Mzc- 
  <*> scanf.patch

------------------------------------
Posted by: Sebastien Lorquet <sebastien@...>
------------------------------------

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

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/nuttx/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/nuttx/join
    (Yahoo! ID required)

<*> To change settings via email:
    nuttx-digest@... 
    nuttx-fullfeatured@...

<*> To unsubscribe from this group, send an email to:
    nuttx-unsubscribe@...

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

Picon

Fix USB NSH on STM32F429i-Disco board (sort of) [1 Attachment]

Hey Greg,

I finally got a chance to test the USB NSH configuration on my STM32F429i-Disco board.  Seems it still didn't work out of the box, but I was able to do some debug on it.

I believe the attached patch is required to make the HS core in the STM32F4 work in FS mode (as needed on the STM32F429i-Disco board).  This register write is enabling the FS PHY in the HS block.  Without it, there is no chance it can work.  The otghshost.c file already contains this write, but it was not added to the otghsdev.c file.

The reason I say it "sort of" works in the subject line is because after adding this patch during debug, the usbnsh started working perfectly.  But then when I disabled the Build Setup -> Debug Options -> Generate Debug Symbols config option, it stopped working for some reason.  Re-enable generation of debug symbols and it starts working again.  Not sure what's going on there.  There weren't any differences in the optimization level, so it must be something else.

Ken


__._,_.___

Attachment(s) from Ken Pettit | View attachments on the web

1 of 1 File(s)

Posted by: Ken Pettit <pettitkd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>



__,_._,___
Picon

partition on sdcard

Greg, 


Is Nuttx  support sdcard with partition table ? 

If yes, Howto mount it ? 


My sdcard is in "/dev/mmcsd0", so I was done like this:

=> mount("/dev/mmcsd0","/mnt","vfat",0,NULL)

but this mount a FAT32 without partition table.

like "mount /dev/sda /mnt" on linux

But I want to mount like "mount /dev/sda1 /mnt" 


Ps: I have successfully mounted a sdcard with partition table (like mount /dev/sda /mnt).   


Pierre


Log (here fat32 is on sdcard with partition table ) 

ERR[     0.000000]uart_register: Registering /dev/ttyS0

NO T[     0.000000]initialize LCD !

DEB[     0.410000]Initializing SPI port 0

INF[     0.410000]Successfully initialized SPI port 0

DEB[     0.410000]Binding SPI port 0 to MMC/SD slot 0

ERR[     0.610000]mmcsd_mediainitialize: Identified SD ver2 card/with block access

INF[     0.610000]Successfuly bound SPI port 0 to MMC/SD slot 0

INF[     0.610000]Successfully initialized SDCARD port 0

ERR[     0.620000]fat_checkbootrecord: ERROR: Signature: aa55 FS sectorsize: 36352 HW sectorsize: 512

ERR[     0.630000]fat_mount: FAT32:

ERR[     0.630000]fat_mount:    HW  sector size:     512

ERR[     0.630000]fat _mount:        sectors:         30679040

ERR[     0.630000]fat_mount:    FAT reserved:        32

ERR[     0.630000]fat_mount:        sectors:         30676992

ERR[     0.630000]fat_mount:        start sector:    2080

ERR[     0.630000]fat_mount:        root sector:     2

ERR[     0.640000]fat_mount:        root entries:    0

ERR[     0.640000]fat_mount:        data sector:     32010

ERR[     0.640000]fat_mount:        FSINFO sector:   2049

ERR[     0.640000]fat_mount:        Num FATs:        2

ERR[     0.640000]fat_mount:        FAT sectors:     14965

ERR[     0.640000]fat_mount:        sectors/cluster: 16

ERR[     0.640000]fat_mount:        max clusters:    1915439

ERR[     0.650000]fat_mount:    FSI free count       1915438

ERR[     0.650000]fat_mount:        next free        2

NOT[     0.650000]Board Ready !



Log (here fat32 is on sdcard without partition table ) :

ERR[   &n bsp; 0.000000]uart_register: Registering /dev/ttyS0

NOT[     0.000000]initialize LCD !

DEB[     0.410000]Initializing SPI port 0

INF[     0.410000]Successfully initialized SPI port 0

DEB[     0.410000]Binding SPI port 0 to MMC/SD slot 0

ERR[     0.410000]mmcsd_mediainitialize: Identified SD ver2 card/with block access

INF[     0.420000]Successfuly bound SPI port 0 to MMC/SD slot 0

INF[     0.420000]Successfully initialized SDCARD port 0

ERR[     0.420000]fat_mount: FAT32:

ERR[     0.430000]fat_mount:    HW  sector size:     512

ERR[     0.430000]fat_mount:        sectors:         30679040

ERR[     0.430000]fat_mount:    FAT reserved:        32

ERR[     0.430000]fat_mount:        sectors:         30679040

ERR[     0.430000]fat_mount:        start sector:    32

ERR[     0.430000]fat_mount:        root sector:     2

ERR[     0.430000]fat_mount:        root entries:    0

ERR[     0.430000]fat_mount:        data sector:     29964

ERR[     0.440000]fat_mount:        FSINFO sector:   1

ERR[     0.440000]fat_mount: &nbsp ;      Num FATs:        2

ERR[     0.440000]fat_mount:        FAT sectors:     14966

ERR[     0.440000]fat_mount:        sectors/cluster: 16

ERR[     0.440000]fat_mount:        max clusters:    1915567

ERR[     0.440000]fat_mount:    FSI free count       1915565

ERR[     0.440000]fat_mount:        next free        3





__._,_.___
Posted by: pn_bouteville-Qt13gs6zZMY@public.gmane.org



__,_._,___
Picon

I2C on the STM32F4Discovery

Hi, Greg,

I am experimenting with the STM32F4Discovery board, and specifically with the I2C bus.

I am using the I2C tool and Nuttx-7.6; I enabled the I2C peripheral support and I enabled the I2C Driver support. To the code I added the following two lines:

#define GPIO_I2C1_SCL GPIO_I2C1_SCL_1
#define GPIO_I2C1_SDA GPIO_I2C1_SDA_1

When I try 'i2c bus' the enabled bus appears correctly, but when I scan the bus with 'i2c dev -b1 00 77' none of the attached devices react. I quickly checked the clock and data line with a scope, and the clock seems to be fine, but the data line is constantly low (I checked this without the devices to elimante one of them blocking the bus).

Do you have any idea why the data pin would be constantly low?

Thanks,
Max

__._,_.___
Posted by: max.kriegleder-/E1597aS9LQAvxtiuMwx3w@public.gmane.org



__,_._,___
Picon

strncpy() causes buffer overrun at NuttX 7.6 [1 Attachment]

Hi all.


I found strncpy() causes buffer overrun where n equals to zero at NuttX 7.6.

When n set zero, *dest overrun with filling '\0'.

It may be unintended behavior and seems quite dangerous.

This behavior was revealed after commit d0c76ccacf0dc8988f9617ad82bf4349f456bb08.


So I propose an amendment and attach as patch.


CURRENT NUTTX 7.6

char *strncpy(FAR char *dest, FAR const char *src, size_t n)

{

  char *ret = dest;     /* Value to be returned */

  char *end = dest + n; /* End of dest buffer + 1 byte */


  while ((*dest++ = *src++) != '\0' && dest != end);

  while (dest != end) *dest++ = '\0';

  return ret;

}


FIXED AS BELOW

char *strncpy(FAR char *dest, FAR const char *src, size_t n)

{

  char *ret = dest;     /* Value to be returned */

  char *end = dest + n; /* End of dest buffer + 1 byte */


  while ((dest != end) && (*dest++ = *src++) != '\0');

  while (dest != end) *dest++ = '\0';

  return ret;

}


If my amendment is co rrect, please apply it on next code.

Thanks,

hiro




__._,_.___

Attachment(s) from yasuhiro.osaki-/E1597aS9LQAvxtiuMwx3w@public.gmane.org [nuttx] | View attachments on the web

1 of 1 File(s)

Posted by: yasuhiro.osaki-/E1597aS9LQAvxtiuMwx3w@public.gmane.org



__,_._,___
Picon

M25P16 SPI flash support

Hi Greg & everyone!


Here is a patch that adds support for the M25P16 SPI flash chip to the m25p driver (patch by laforge).


Lazlo



__._,_.___
Posted by: dlsitzer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org



__,_._,___

Gmane