Commit Graph

48291 Commits

Author SHA1 Message Date
chao an
ccaa625930 fs/smart: fix visual studio Compiler Error C2016
D:\archer\code\nuttx\include\nuttx/fs/smart.h(118,1):
  error C2016: C requires that a struct or union has at least one member

Compiler error C2016: C requires that a struct or union has at least one member

Reference:
https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-errors-c2001-through-c2099?view=msvc-170

Signed-off-by: chao.an <anchao@xiaomi.com>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:11:55 +08:00
chao an
634baa5a2f libs: workaround for Visual Studio(MSVC) Compiler Error C2124
D:\archer\code\nuttx\libs\libc\stdlib\lib_strtod.c: error C2124: divide or mod by zero

Windows MSVC restrictions, MSVC doesn't allow division through a
zero literal, but allows it through const variable set to zero

Reference:
https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2124?view=msvc-170

Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:11:55 +08:00
chao an
86aed87487 sys/sysinfo: align sysinfo define with linux
__reserved is a meaningful macro definition in msvc, cannot use this name

Fix visual studio Compiler Error:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d86ad86b-47b7-4677-95fb-e28b3230a009/reserved-problem?forum=vclanguage

Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:11:55 +08:00
chao an
8761cc9bfc libs: fix visual studio Compiler Error C2036
D:\code\nuttx\libs\libc\net\lib_inetpton.c(300,52): error C2036: "void *" : unknown size

Reference:
https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2036?view=msvc-170

Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:11:55 +08:00
chao an
4b4cee8916 build/kconfig: refresh all defconfig
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:07:46 +08:00
chao an
e942a7c55e build/Kconfig: fix warnings detected by kconfiglib
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:07:46 +08:00
chao an
3a0fdb019d nuttx: replace all ARRAY_SIZE()/ARRAYSIZE() to nitems()
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:05:44 +08:00
chao an
cf0769d613 include: Add nitems() definition to sys/param.h
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:05:44 +08:00
Masayuki Ishikawa
3f3e090716 Revert "include/sys/socket.h: Add SOCK_CTRL to socket type"
This reverts commit abba05a934.
2023-02-09 09:13:14 +01:00
Xiang Xiao
916fa4d759 boards/sim: Enable CONFIG_SIM_M32 in nimble
please reference this pr:
https://github.com/apache/mynewt-nimble/pull/1125

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-09 14:36:05 +08:00
ligd
9b35a2e1a1 sim: fix compile warning
sim/sim_doirq.c: In function 'sim_doirq':
Error: sim/sim_doirq.c:79:10: error: function may return address of local variable [-Werror=return-local-addr]
   79 |   return regs;
      |          ^~~~
sim/sim_doirq.c:44:14: note: declared here
   44 |   xcpt_reg_t tmp[XCPTCONTEXT_REGS];
      |              ^~~

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-09 14:22:38 +08:00
ligd
16367aa084 sim: correct save irq flags error when use sim 64bits
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-09 14:22:38 +08:00
ligd
8aecad287c sim: set loop task duration to 10ms
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-09 14:19:09 +08:00
ligd
f102837fe1 sim: realize sim timer tickless
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-09 14:19:09 +08:00
Zhihong Chen
d082af34f7 add hpmicro chip: hpm6750
Signed-off-by: Zhihong Chen <zhihong.chen@hpmicro.com>
2023-02-09 14:17:49 +08:00
TimJTi
4aada75249 Changes to allow board-specific DRP/OTG support
Update sam_udphs.c
2023-02-09 03:42:55 +08:00
Lucas Saavedra Vaz
1fb6dcec3b arch/xtensa/esp32s2: Fix function header 2023-02-09 02:39:54 +08:00
Lucas Saavedra Vaz
b29198a62a arch/xtensa/esp32s3: Add support for touch pad interrupts 2023-02-09 02:39:54 +08:00
Ville Juven
9ac3e841da group_addrenv: Fix call to group_addrenv for targets that don't need it 2023-02-09 00:14:52 +08:00
Nathan Hartman
375cb09ff0 arch/pic32mz: Serial support for termios
Previously, it was impossible to build for PIC32MZ architecture with
CONFIG_SERIAL_TERMIOS because it introduced compiler errors in the
lower half driver.

Fixing the compiler errors and adding an implementation of the
TIOCSERGSTRUCT, TCGETS, and TCSETS ioctl calls.

* arch/mips/src/pic32mz/pic32mz_serial.c
  (): Include nuttx/fs/ioctl.h, needed for the TIOCSERGSTRUCT, TCGETS,
   and TCSETS defines.
  (up_ioctl): Fix compile breakage. Implement TIOCSERGSTRUCT. Make
   TCGETS return data bits, parity, and stop bits. Make TCSETS apply
   changes to data bits, parity, and stop bits.
2023-02-08 23:55:37 +08:00
Nathan Hartman
8b2c8c73e8 arch/tiva: Serial TIOCxBRK BSD-compatible BREAK support
In the lower half UART driver for Tiva architecture (TM4C12x), adding
the TIOCxBRK ioctl calls, which allow an application to transmit a BSD
compatible line BREAK. TIOCSBRK starts the BREAK and TIOCCBRK ends it.

This architecture supports BSD-style BREAK in hardware. We write to
the BRK bit (bit 0) of the UART Line Control register (UARTLCRH) to
start the BREAK, which begins after the UART finishes shifting out the
current character in progress, if any, including its stop bit(s), and
continues indefinitely until we write to the BRK bit again to stop the
BREAK.

* arch/arm/src/tiva/Kconfig
  (config TIVA_UART_BREAKS): New. Appears as CONFIG_TIVA_UART_BREAKS
   in code.

* arch/arm/src/tiva/common/tiva_serial.c
  (struct up_dev_s): Add new field 'brk' to indicate line break in
   progress when built with CONFIG_TIVA_UART_BREAKS.
  (up_ioctl): Add cases for TIOCSBRK to turn BSD-compatible break on
   unconditionally and TIOCCBRK to turn break off unconditionally.
  (up_txint): Block enabling TX interrupt if line break in progress.
   This is similar to the STM32F7 implementation.
2023-02-08 23:55:28 +08:00
SPRESENSE
abba05a934 include/sys/socket.h: Add SOCK_CTRL to socket type
SOCK_CTRL is added to provide special control over network drivers
and daemons. Currently, SOCK_DGRAM and SOCK_STREAM perform this control,
but these use socket resources. In the case of usersocket in particular,
this is a waste of the device's limited socket resources.
2023-02-08 20:43:33 +08:00
ligd
24cdcd9a6e sim: fix kasan report memalign crash when alignment is 1
(0)Allocating 3 bytes aligned to 0x00000001
=================================================================
==1461685==ERROR: AddressSanitizer: invalid alignment requested in posix_memalign: 1, alignment must be a power of two and a multiple of sizeof(void*) == 4 (thread T0)
    #0 0xf7ab1c2f in __interceptor_posix_memalign ../../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:226

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-08 20:37:43 +08:00
ligd
8d0094f6c9 sim: fix color running stack crash when use -Os
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-08 20:37:43 +08:00
qiaohaijiao1
b6472b8b15 sim/sim_alsa: add audio offload capture support.
use host liblame as encoder.

Signed-off-by: qiaohaijiao1 <qiaohaijiao1@xiaomi.com>
2023-02-08 13:55:17 +08:00
yinshengkai
1faeba3f2d sched_note: add SCHED_NOTE_BEGIN/ENDEX interface
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-02-08 13:31:46 +08:00
Huang Qi
b250db5dba serial: Fix a warning if termios enabled
Fix:
```
 serial/serial.c: In function 'uart_ioctl':
Error: serial/serial.c:1397:46: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
 1397 |               FAR struct termios *termiosp = (FAR struct termios *)arg;
      |                                              ^
Error: serial/serial.c:1419:46: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
 1419 |               FAR struct termios *termiosp = (FAR struct termios *)arg;
      |
```

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-02-08 13:31:35 +08:00
Huang Qi
3e41bd8b35 driver/serial: Convert CR to LF in driver
Enable the behavior by default for console,
but configurable by termios.

Binary size:

Before:
   text    data     bss     dec     hex filename
 326460     409    8164  335033   51cb9 nuttx/nuttx

 After:
    text    data     bss     dec     hex filename
 326478     409    8164  335051   51ccb nuttx/nuttx

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-02-08 13:31:35 +08:00
Alan Carvalho de Assis
63a847ebca esp32s3-devkit: Add support LED PWM initialization 2023-02-08 11:02:19 +08:00
Alan Carvalho de Assis
453d9688c7 esp32s3: Add support to PWM using LEDC 2023-02-08 11:02:19 +08:00
Alan Carvalho de Assis
94970f32d7 esp32s2-saola-1: Add initialization to LEDC PWM 2023-02-08 10:56:32 +08:00
Alan Carvalho de Assis
39729bb635 esp32s2: Add support to LEDC PWM 2023-02-08 10:56:32 +08:00
Lucas Saavedra Vaz
d7b66adbeb arch/xtensa/esp32s3: Add support for RTC IRQs 2023-02-08 10:56:15 +08:00
Lucas Saavedra Vaz
14d95eb131 arch/risc-v/esp32c3: Add RTC interrupt support 2023-02-08 10:42:19 +08:00
Nathan Hartman
5d2e1d40dc arch/tiva: Fix inability to control serial CTS/RTS via termios
* arch/arm/src/tiva/common/tiva_serial.c:
  (up_ioctl): PR #8406 (commit 1edec0aaa1) added support for
   configuring the serial port's CTS/RTS flow control at runtime using
   termios when built with CONFIG_SERIAL_TERMIOS and either or both of
   CONFIG_SERIAL_OFLOWCONTROL and CONFIG_SERIAL_IFLOWCONTROL. However,
   a runtime sanity check left over from before prevented this from
   working: When processing ioctl TCSETS, we would return -EINVAL if
   one or both of CCTS_OFLOW and CRTS_IFLOW were requested, which was
   not deserved if the requested features were in fact supported.
   Fixing the sanity check so it depends on features actually
   configured.
2023-02-08 10:31:11 +08:00
raiden00pl
18cf2c4297 boards/stm32f4discovery: add nxscope CDCACM example 2023-02-08 10:06:59 +08:00
raiden00pl
fc322a9c78 boards/sim: add nxscope config 2023-02-08 10:06:59 +08:00
Nathan Hartman
962e072fd5 mips/ld scripts: Fix typo in comment (s/mappled/mapped/) 2023-02-08 10:06:26 +08:00
Nathan Hartman
d383db53f9 boards/pic32mz-starterkit: Fix building with Sourcery toolchain
Fixing an issue that occurred When building with the
Sourcery CodeBench Lite MIPS Toolchain for Linux
(CONFIG_MIPS32_TOOLCHAIN_SOURCERY_CODEBENCH_LITE).
2023-02-08 10:06:01 +08:00
Nathan Hartman
1b3cac19a0 serial: Fix typo in comments (s/besued/because/) 2023-02-08 10:05:27 +08:00
Ville Juven
f4b82b6405 sched/addrenv: Remove up_addrenv_restore
The function is not relevant any longer, remove it. Also remove
save_addrenv_t, the parameter taken by up_addrenv_restore.

Implement addrenv_select() / addrenv_restore() to handle the temporary
instantiation of address environments, e.g. when a process is being
created.
2023-02-08 02:51:23 +08:00
Ville Juven
09e7987121 sched/addrenv: Fix system crash when process group has been deleted
There is currently a big problem in the address environment handling which
is that the address environment is released too soon when the process is
exiting. The current MMU mappings will always be the exiting process's, which means
the system needs them AT LEAST until the next context switch happens. If
the next thread is a kernel thread, the address environment is needed for
longer.

Kernel threads "lend" the address environment of the previous user process.
This is beneficial in two ways:
- The kernel processes do not need an allocated address environment
- When a context switch happens from user -> kernel or kernel -> kernel,
  the TLB does not need to be flushed. This must be done only when
  changing to a different user address environment.

Another issue is when a new process is created; the address environment
of the new process must be temporarily instantiated by up_addrenv_select().
However, the system scheduler does not know that the process has a different
address environment to its own and when / if a context restore happens, the
wrong MMU page directory is restored and the process will either crash or
do something horribly wrong.

The following changes are needed to fix the issues:
- Add mm_curr which is the current address environment of the process
- Add a reference counter to safeguard the address environment
- Whenever an address environment is mapped to MMU, its reference counter
  is incremented
- Whenever and address environment is unmapped from MMU, its reference
  counter is decremented, and tested. If no more references -> drop the
  address environment and release the memory as well
- To limit the context switch delay, the address environment is freed in
  a separate low priority clean-up thread (LPWORK)
- When a process temporarily instantiates another process's address
  environment, the scheduler will now know of this and will restore the
  correct mappings to MMU

Why is this not causing more noticeable issues ? The problem only happens
under the aforementioned special conditions, and if a context switch or
IRQ occurs during this time.
2023-02-08 02:51:23 +08:00
Ville Juven
5713d85df0 group/group_addrenv: Move address environment from group -> tcb
Detach the address environment handling from the group structure to the
tcb. This is preparation to fix rare cases where the system (MMU) is left
without a valid page directory, e.g. when a process exits.
2023-02-08 02:51:23 +08:00
raiden00pl
ca95d592d3 boards/stm32f4disco: add timer driver support 2023-02-08 02:43:13 +08:00
chao an
68970fe8a1 sim/dynconns: enable more configs to catch compile warning
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-08 02:42:59 +08:00
Igor Mišić
0a4fbcd123 drivers/mtd: add Kconfig options for RAMTRON emulated page & sector size 2023-02-08 01:44:51 +08:00
chao an
1cb11968b7 net/ip: fix compile break if enable NET_LOCAL_SCM
1.
net/slip.c:865:29: warning: unused variable ‘priv’ [-Wunused-variable]
  865 |   FAR struct slip_driver_s *priv =
      |                             ^~~~
net/slip.c: In function ‘slip_rmmac’:
net/slip.c:895:29: warning: unused variable ‘priv’ [-Wunused-variable]
  895 |   FAR struct slip_driver_s *priv =
      |                             ^~~~
2.
local/local_sendmsg.c: In function ‘local_sendmsg’:
local/local_sendmsg.c:423:18: warning: ‘count’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  423 |           return count;
      |                  ^~~~~
local/local_sendmsg.c:131:11: warning: ‘i’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  131 |   while (i-- > 0)
      |          ~^~
local/local_sendmsg.c:71:7: note: ‘i’ was declared here
   71 |   int i;
      |       ^

Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-07 12:46:40 +02:00
chao an
e3a6c16944 net/ip: fix compile break if disable NET_TCP
1.
ipfrag/ipv4_frag.c: In function ‘ipv4_fragin’:
ipfrag/ipv4_frag.c:184:22: warning: ‘head’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  184 |   ipv4->len[1] = head->io_pktlen & 0xff;
      |                  ~~~~^~~~~~~~~~~
ipfrag/ipv4_frag.c:123:21: note: ‘head’ was declared here
  123 |   FAR struct iob_s *head;
      |                     ^~~~

2.
devif/ipv6_input.c: In function ‘ipv6_in’:
devif/ipv6_input.c:60:33: error: ‘TCPIPv6BUF’ undeclared (first use in this function); did you mean ‘UDPIPv6BUF’?
   60 | #define PAYLOAD ((FAR uint8_t *)TCPIPv6BUF)
      |                                 ^~~~~~~~~~

3.
nat/ipv4_nat.c: In function ‘ipv4_nat_inbound_icmp’:
nat/ipv4_nat.c:67:30: error: ‘TCP_HDRLEN’ undeclared (first use in this function); did you mean ‘UDP_HDRLEN’?
   67 |   ((proto) == IP_PROTO_TCP ? TCP_HDRLEN : \
      |                              ^~~~~~~~~~
nat/ipv4_nat.c:323:47: note: in expansion of macro ‘L4_HDRLEN’
  323 |             inner_l4hdrlen = MIN(inner_l4len, L4_HDRLEN(inner->proto));
      |                                               ^~~~~~~~~

Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-07 12:46:40 +02:00
Xiang Xiao
97e994a1f9 Move SEEK_xxx from unistd.h to sys/types.h
so fcntl.h, stdio.h and unistd.h could get these definiton:
https://en.cppreference.com/w/c/io/fseek
https://pubs.opengroup.org/onlinepubs/7908799/xsh/fcntl.html
https://pubs.opengroup.org/onlinepubs/007904975/functions/lseek.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-07 12:16:22 +02:00
dongjiuzhu1
63e6f80fb0 sync: add sync api
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-02-07 12:15:05 +02:00