Commit Graph

49321 Commits

Author SHA1 Message Date
Gregory Nutt
8cca30b44c Signal must be masked when it is delivered to a signal handler
Signal must be masked when it is delivered to a signal handler per:

https://pubs.opengroup.org/onlinepubs/007904875/functions/sigaction.html:

When a signal is caught by a signal-catching function installed by sigaction(), a new signal mask is calculated and installed for the duration of the signal-catching function (or until a call to either sigprocmask() or sigsuspend() is made). This mask is formed by taking the union of the current signal mask and the value of the sa_mask for the signal being delivered [XSI] [Option Start] unless SA_NODEFER or SA_RESETHAND is set, [Option End] and then including the signal being delivered. If and when the user's signal handler returns normally, the original signal mask is restored.

Any action queued for that signal while the signal is masked should be deferred. It should go into the group pending signal list and should not be processed until until the signal is unmasked (which should occur when the signal handler returns).
2023-05-18 01:19:12 +08:00
Michal Lenc
cf04f2e555 w25qxxxjv: add dual die support for 1 Gbit flash
1 Gbit W25Q01JV flash uses two 512 Mbit dies. This requires specific
operations in the driver in order to support the entire 1 Gbit region.
This commit adds dual die support for W25Q01JV flash.

Generally the driver has to switch active dies when die specific read from
status register is required (therefore before read, write, erase and when
checking if write status register was successful).

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-05-18 01:10:55 +08:00
Liyu Wang
d7d6fa4d82 Fix windows compile errors because of double quotes in config
The "CONFIG_APPS_DIR" generated in .config has double quotes and is not recognized as a path by most make systems. This commits removes these double quotes to make the compile successfully.
2023-05-17 11:56:29 -03:00
Tiago Medicci Serrano
496a77653a arch/xtensa/esp32_esp32s3: prevent arch's libc in the userspace
ESP32 and ESP32-S3 should use the ROM-defined versions of the libc
in flat build and, when building the protected mode, in the kernel.

The ROM-defined version of the libc functions can't be used in the
userspace, however, because it isn't allowed to access the memory
region in flash directly from the userspace. That being said,
`LIBC_PREVENT_STRING_KERNEL` should be selected to avoid building
any implementation of the libc, being the ROM-defined versions
linked instead.

NuttX's software implemented version of the libc will be built in
the userspace. Also, the assembly-defined version of some of the
libc functions (`XTENSA_xxx`) may also be selected to be used in
the userspace.
2023-05-17 13:58:48 +08:00
Tiago Medicci Serrano
58e97e521c libc/string: prevent libc in the kernel/userspace optionally
Add the `LIBC_PREVENT_STRING_KERNEL` and `LIBC_PREVENT_STRING_USER`
that are meant to be selected by the chip if no libc implementation
is going to be built. If selected, neither NuttX's software version
of the libc nor any architecture-specific implementation will be
built in the kernel or in the userspace, respectively. In this
case, the linker may provide a ROM-defined version of the libc
functions instead.
2023-05-17 13:58:48 +08:00
chao an
6be363ff35 drivers/serial: fix race condition in multi-thread write
if multiple threads are doing serial read/write at the same time,
the driver will only wake up one of the thread, which will cause
other threads fail to be woken up in time and cause blocking

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-17 07:56:08 +02:00
Huang Qi
23ad4700a9 drivers/serial/pty.c: Fix coverity issue
Coverity report that `ntotal` may be a negative value.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-05-17 07:44:26 +02:00
guoshichao
e1096bd35c libc/regex: add regex implementation
add regex implementation for libc, the implementation are ported from
musl project

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-05-17 10:25:18 +08:00
hujun5
81bdb97536 libc/misc: add fdsan api doc
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-05-17 10:24:42 +08:00
hujun5
90387a5b41 libc/misc: add fdsan module
FD (file descriptor) is widely used in system software development,
and almost all implementations of posix os (including nuttx) use FD as an index.
the value of fd needs to be allocated starting from the minimum available value of 3, and each process has a copy,
so the same fd value is very easy to reuse in the program.

In multi threaded or multi process environments without address isolation,
If the ownership, global variables, and competition relationships of fd are not properly handled,
there may be issues with fd duplication or accidental closure.
Further leading to the following issues, which are difficult to troubleshoot.

1. Security vulnerability: the fd we wrote is not the expected fd and will be accessed by hackers to obtain data
2. Program exceptions or crashes: write or read fd failures, and program logic errors
3. The structured file XML or database is damaged: the data format written to the database is not the expected format.

The implementation principle of fdsan is based on the implementation of Android
https://android.googlesource.com/platform/bionic/+/master/docs/fdsan.md

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-05-17 10:24:42 +08:00
Nathan Hartman
242127556c Documentation: Add "High Performance, Zero Latency Interrupts"
* Documentation/guides/zerolatencyinterrupts.rst: New. This document is
  converted from CWIKI (see [1]) to reStructuredText and brought into
  the Documentation tree in the repo.

[1] https://cwiki.apache.org/confluence/display/NUTTX/High+Performance%2C+Zero+Latency+Interrupts
2023-05-17 02:23:19 +08:00
liqinhui
f61dc72892 net/tcp:Add NewReno congestion control.
- NewReno congestion control algorithm is used to solve the problem
  of network congestion breakdown. NewReno congestion control includes
  slow start, collision avoidance, fast retransmission, and fast
  recovery. The implementation refers to RFC6582 and RFC5681.

- In addition, we optimize the congestion algorithm. In the conflict
  avoidance stage, the maximum congestion window max_cwnd is used to
  limit the excessive growth of cwnd and prevent network jitter
  caused by congestion. Maximum congestion window max_cwnd is updated
  with the current congestion window cwnd and the update weight is
  0.875 when an RTO timeout occurs.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-05-16 12:35:01 -03:00
Xiang Xiao
7a8cf7ff70 Indent the include statement by two spaces
follow the coding style

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-16 12:34:32 -03:00
chao an
26361ee1d2 tools/nuttx-gdbinit/armv7-a: add fpu support
The offset of the relevant registers in xcp will change after
enabling the FPU, this PR will add fpu offset correct the register offset

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-16 21:40:43 +08:00
Zhe Weng
eb47312518 netdev_upper: Protect quota by spin lock to allow netpkt_xxx be called in interrupt context
Before atomic is ready on every platform, we need a way to protect
quota, previously it's protected by net_lock, but this makes netpkt_xxx
interfaces unable to be called under interrupt context, so changed to
spin lock. Also, we can easily change them into atomic under this
implementation.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-05-16 21:39:05 +08:00
chao an
36591af615 net/rpmsg: initialize semaphore count before wait
recvmsg() will incorrectly return 0 if the count of sema before waiting is greater than 0,
This commit will reinitialize the sema count before waiting:

1181 static ssize_t rpmsg_socket_recvmsg(FAR struct socket *psock,
1182                                     FAR struct msghdr *msg, int flags)
1183 {
...
1255   ret = net_sem_timedwait(&conn->recvsem,
1256                       _SO_TIMEOUT(conn->sconn.s_rcvtimeo)); // recvsem.sem_count == 1; return 0
...
1264   if (!conn->recvdata)              // recvdata not consumed; goto else
1265     {
1266       ret = conn->recvlen;
1267     }
1268   else
1269     {
1270       conn->recvdata = NULL;
1271     }
...
1282   return ret;                        // BUGON! incorrectly return 0 to user
1283 }

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-16 17:15:42 +08:00
chao an
50cf3d8577 tools/nxstyle: add "_NSGetExecutablePath" into ignore list
sim/posix/sim_hostmisc.c:128:6: error: Mixed case identifier found

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-16 17:05:42 +08:00
chao an
150e5a1a0f sim/posix/backtrace: process host backtrace with critical section
backtrace() is not a signal safe

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-16 17:05:42 +08:00
Brennan Ashton
6417ca79ad CI: set-output command is deprecated
CI currently runs with the warning:

The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2023-05-16 15:56:01 +08:00
Brennan Ashton
9a654b658e docs: Generate pdf version of docs for #9095
This implements the changes required to genreate the pdf version
of the documentation. The pdf will be generated as a build artifact
attached to the build. This is the first patch to enable this
a follow on patch to the website repo will publish the pdf to the
NuttX website.
2023-05-16 15:12:10 +08:00
hujun5
6da335cd81 driver/uart_16550: serial output can cause deadlock
All interrupts must be disabled to prevent re-entrancy and to prevent
interrupts from firing in the serial driver code.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-05-16 15:11:38 +08:00
Lwazi Dube
555506a584 arch/arm/sama5: Make EHCI work with slow devices.
Make low/full speed devices work with EHCI while OHCI is disabled. A
high speed USB hub has to be plugged into the root hub. This change
will also allow the optional use of a full speed hub between the
high speed hub and the low/full speed device. A recursive mutex is
used to avoid deadlocks.
2023-05-16 08:14:54 +02:00
raiden00pl
7986a28216 boards/stm32h7: enable HSI48 if OTG clock is HSI48 2023-05-16 03:11:29 +08:00
raiden00pl
507aa430c9 stm32h7/Kconfig: fix CI 2023-05-16 03:11:29 +08:00
Ville Juven
a940ea0134 riscv/riscv_copystate.c: Remove riscv_copystate.c as it is not used anymore
I keep getting confused by this function until I remember again that it is
not used any more. Let's just get rid of it.
2023-05-15 19:35:18 +08:00
shipei
ecbf10b470 modify type of numbytes in audio_buf_desc_s from uint16_t to apb_samp_t
Signed-off-by: shipei <shipei@xiaomi.com>
2023-05-15 19:34:34 +08:00
Sebastien Lorquet
567a3ca37c Fix some warnings in STM32H7 IWDG 2023-05-15 19:34:17 +08:00
raiden00pl
5c3fa2d788 stm32h7/otg: allow USBDEV and USBHOST to work simultaneously 2023-05-15 17:32:32 +08:00
raiden00pl
eee25ea1eb stm32h7/otg: move sanity checks to common header file for use USBDEV and USBHOST 2023-05-15 17:32:32 +08:00
zhanghongyu
62076fb7b9 ipv6_setsockopt: Merge similarity logic
modify the assignment logic to make it easier to extend new options later

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-15 16:48:18 +08:00
Alan Carvalho de Assis
d3b6bbe4fd tools/refresh.sh: Add option to refresh all archs or all chips
Currently when we modify some Kconfig related to some chip or
some architecture we need to run refresh.sh to all boards that
is too slow (more than one hour to finish).

This patch modify the script to update only the boards configs
of an specific chip or only the boards of an specific architecture.

Examples:

$ ./tools/refresh.sh --silent --defaults arch:renesas
  Normalize us7032evb1/ostest
  Normalize us7032evb1/nsh
  Normalize skp16c26/ostest
  Normalize rx65n-rsk2mb/netnsh
  Normalize rx65n-rsk2mb/ipv6
  Normalize rx65n-rsk2mb/nsh
  Normalize rx65n-rsk1mb/netnsh
  Normalize rx65n-rsk1mb/nsh
  Normalize rx65n-grrose/netnsh
  Normalize rx65n-grrose/ipv6
  Normalize rx65n-grrose/nsh
  Normalize rx65n/nsh

It updates the boards from all 'renesas' architecture (m9c, rx65n, sh1)

$ ./tools/refresh.sh --silent --defaults chip:rx65n
  Normalize rx65n-rsk2mb/netnsh
  Normalize rx65n-rsk2mb/ipv6
  Normalize rx65n-rsk2mb/nsh
  Normalize rx65n-rsk1mb/netnsh
  Normalize rx65n-rsk1mb/nsh
  Normalize rx65n-grrose/netnsh
  Normalize rx65n-grrose/ipv6
  Normalize rx65n-grrose/nsh
  Normalize rx65n/nsh

It updates all the boards from renesas chip 'rx65n' family
2023-05-15 10:44:44 +08:00
simbit18
ac392b5306 arch/arm/src/stm32f7/stm32_usbhost.c: Fix nxstyle errors
error: Long line found
2023-05-15 10:44:17 +08:00
Michal Lenc
482cbc4363 w25qxxxjv: fix STATUS2_QE_ENABLED bitfield write
W25QXXXJV_WRITE_STATUS_2 register uses just first byte therefore all
operations has to be done in priv->cmdbuf[0]. Previous priv->cmdbuf[1]
caused QuadSPI mode not being enabled.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-05-15 10:43:55 +08:00
zhanghongyu
c9a843bdca ipv6: support SOL_IPV6 options IPV6_UNICAST_HOPS and IPV6_MULTICAST_HOPS
Added simple support for IPV6_UNICAST_HOPS and IPV6_UNICAST_HOPS, the application can configure the ttl parameters of the socket in user mode.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-13 22:34:21 +08:00
Masayuki Ishikawa
8a70f8a76d boards: Add virtio blk driver to qemu-arm8a and rv-virt
Summary:
- This commit adds blk driver to qemu-armv8a:netnsh,
  rv-virt:netnsh and rv-virt:netnsh64
- Also updates README.txt

Impact:
- None

Testing:
- Tested with qemu-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-05-13 13:58:09 +08:00
Masayuki Ishikawa
498a75a58b drivers: virtio: Add virtio-mmio-blk
Summary:
- This commit adds virtio-mmio-blk driver

Impact:
- None

Testing:
- Tested with rv-virt:netnsh which will be updated later

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-05-13 13:58:09 +08:00
Masayuki Ishikawa
1d6a61c034 include: virtio: Add VIRTIO_DEV_BLK definition to virtio-mmio.h
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-05-13 13:58:09 +08:00
zhanghongyu
1def5da221 net: move ttl field into socket_conn_s struct
move ttl filed from udp_conn_s to socket_conn_s structure to make it more than just control udp.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-13 12:39:53 +08:00
TimJTi
b4b9a180c0 Add ATSAMA5D2/D4 Secure Fuse Controller (SFC) driver 2023-05-12 16:29:48 -03:00
simbit18
aa0cb3f76f Fix typos (s/FRQUENCY/FREQUENCY/)
Fix various typos FRQUENCY -> FREQUENCY
2023-05-13 00:31:26 +08:00
simbit18
0a40287b13 libs/libc/pthread: Fix nxstyle errors
error: Long line found
2023-05-12 18:00:15 +03:00
zhanghongyu
06a10202af usrsock_server: fix issues with usrsock_rpmsg_sendto_handler
If the current poll setup only has POLLIN, adding POLLOUT does not cause the
protocol stack to refocus on flags such as TCP_ACK or UDP_POLL, the user is
not notified when flags for POLLOUT relationships appear and vice versa,
so we have to call poll_setup again.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-12 22:40:41 +08:00
Ville Juven
aee45c9c43 riscv/addrenv: Create utility function for dynamic mappings
Move the mapping functionality from up_shmat/shmdt into two generic
mapping functions. This makes it possible to do other mappings besides
user shared memory area mappings.
2023-05-12 22:32:31 +08:00
wangchen
2e6d0815b2 nuttx/net:Support to PMTUD
RFC 1191
When a router is unable to forward a datagram because it exceeds the
   MTU of the next-hop network and its Don't Fragment bit is set, the
   router is required to return an ICMP Destination Unreachable message
   to the source of the datagram, with the Code indicating
   "fragmentation needed and DF set".  To support the Path MTU Discovery
   technique specified in this memo, the router MUST include the MTU of
   that next-hop network in the low-order 16 bits of the ICMP header
   field that is labelled "unused" in the ICMP specification [7].  The
   high-order 16 bits remain unused, and MUST be set to zero.  Thus, the
   message has the following format:

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |   Type = 3    |   Code = 4    |           Checksum            |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |           unused = 0          |         Next-Hop MTU          |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |      Internet Header + 64 bits of Original Datagram Data      |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
RFC 1185
Packet Too Big Message

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |     Type      |     Code      |          Checksum             |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |                             MTU                               |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |                    As much of invoking packet                 |
      +               as will fit without the ICMPv6 packet           +
      |                       exceeding 576 octets                    |

   IPv6 Fields:

   Destination Address

                  Copied from the Source Address field of the invoking
                  packet.

   ICMPv6 Fields:

   Type           2

   Code           0

   MTU            The Maximum Transmission Unit of the next-hop link.

   Description

   A Packet Too Big MUST be sent by a router in response to a packet
   that it cannot forward because the packet is larger than the MTU of
   the outgoing link.  The information in this message is used as part
   of the Path MTU Discovery process [RFC-1191].

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2023-05-12 10:21:52 -03:00
raiden00pl
26536f9f55 boards/stm32f7: rework boards to not use CONFIG_STM32F7_USE_LEGACY_PINMAP=y
In reference to PR #8992
2023-05-12 11:43:08 +08:00
raiden00pl
d205c8c0e0 arch/stm32f7: fixes for pinmap 2023-05-12 11:43:08 +08:00
Lwazi Dube
38ba0aefca usbhost_hub: Prevent crash when the last hub port is used.
An off-by-one error caused invalid memory to be accessed when the
last port was used. The first entry, at index 0, was never used.
The USB standard uses 1-based numbering for hub ports. This number
was used to index an array. This change converts the port number to
a zero-based port index when the array is accessed. The zero-based
value in the port field of the usbhost_hubport_s structure is also
converted before printing.

For testing, this bug was exposed on a 4 port hub when port 4 was
used after changing USBHUB_MAX_PORTS to 4 in hub.h. The bug should
also be triggered without changing hub.h if a 7 port hub is
available.
2023-05-12 11:41:26 +08:00
Alan Carvalho de Assis
694e6f550b esp32xx: Workaround to avoid printing serial trash character
During the serial reconfiguration from bootloader to the
NuttX a trash character "?" (Unicode replacement U+FFFD)
was printed in the screen.

This fix was discovered by Sylvio Alves from Espressif!
2023-05-12 06:30:35 +03:00
Alan Carvalho de Assis
54d92d1a0f Fix typo -EACESS -> -EACCES 2023-05-12 06:29:35 +03:00
Fotis Panagiotopoulos
4231938892 rtc: Fix compiler warning in driver initialization. 2023-05-11 22:18:10 +03:00