Commit Graph

395 Commits

Author SHA1 Message Date
Xiang Xiao eddd90de78 poll: pollsetup should notify only one fd passd by caller
since it's redundant to iterate the whole fds array in setup

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-11-21 09:07:17 +01:00
Ville Juven b3f20d4bd6 uart_tcsendbreak: Remove cancel point, as tcsendbreak is not one
Reference:
https://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_09.html
2023-11-13 08:11:24 -08:00
chao an 85a375cd7d drivers/serial: check the remote device before get name
| #0 0x2119bf1 in rpmsg_get_cpuname rptun/rptun.c:1157
| #1 0x24f97bd in uart_rpmsg_device_destroy serial/uart_rpmsg.c:342
| #2 0x2117d56 in rptun_dev_stop rptun/rptun.c:883
| #3 0x21181d7 in rptun_do_ioctl rptun/rptun.c:922
| #4 0x2119721 in rptun_ioctl_foreach rptun/rptun.c:1086

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-07 18:27:05 +08:00
raiden00pl b565e28da3 Kconfigs: rename {Rpmsg|rpmsg} to RPMGS 2023-10-28 13:58:56 +08:00
hujun5 061be5f18e refine: move BIT Macro to nuttx/bits.h
The BIT macro is widely used in NuttX,
and to achieve a unified strategy,
we have placed the implementation of the BIT macro
in bits.h to simplify code implementation.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-10-12 14:52:56 +08:00
raiden00pl 0e01836f09 serial: add an option that selects uart rpmsg as console 2023-09-22 19:46:26 +08:00
wanggang26 e930476b4b enable O_CLOEXEC explicit
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2023-09-22 13:51:00 +08:00
yinshengkai 1d8e69700f drivers/serial: add ram uart driver
It uses the memory block as the serial communication medium, which can communicate between different processes or different CPUs

Using the following configuration, the cross-core communication rate of 200MHz cortex-M55 is about 461KB/s
RAM_UART_BUFSIZE=1024
RAM_UART_POLLING_INTERVAL=100

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-09-19 09:41:07 +08:00
yinshengkai 1d9097f1df drivers/serial: unmodify head and tail pointers
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-09-19 09:41:07 +08:00
chao an 664927c86e mm/alloc: remove all unnecessary cast for alloc
Fix the minor style issue and remove unnecessary cast

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-30 14:34:20 +08:00
dongjiuzhu1 c983aee38a driver/serial: fix race condition about calling rxflowcontrol in mutli thread
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-08-30 14:33:00 +08:00
dongjiuzhu1 ec4f6ecce2 driver/serial: fix error echo about VT100 escape sequence
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-08-30 14:26:11 +08:00
chao an 7aa45305b7 fs/inode: remove all unnecessary check for filep/inode
Since VFS layer already contains sanity checks, so remove unnecessary lower half checks

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-29 09:47:11 +08:00
chengkai d867c46bbc serial/uart/h5: add bt h5 uart serial driver
Signed-off-by: chengkai <chengkai@xiaomi.com>
2023-08-25 17:17:37 +08:00
xuwenjie 4af8927829 drivers/pty: Support get and set local mode of pty
Signed-off-by: xuwenjie <xuwenjie1@xiaomi.com>
2023-08-18 14:30:22 +08:00
xuxin19 f2f0d7fbad cmake:fix drivers build block during cmake reforming
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2023-08-16 22:38:52 +08:00
zhanghu5 305c213d15 filter out control character in pty echo
Signed-off-by: zhanghu5 <zhanghu5@xiaomi.com>
2023-08-11 13:58:54 +08:00
Lee Lup Yuen b2c1930825 serial/uart_16550: Wait before setting Line Control Register (Synopsys DesignWare 8250)
Some UART Controllers (Synopsys DesignWare 8250) will trigger spurious interrupts when the Line Control Register (LCR) is set while the UART is busy. This patch provides the option (16550_WAIT_LCR) to wait for UART until it's not busy, before setting the LCR. (16550_WAIT_LCR is disabled by default)

This patch fixes the spurious UART interrupts for the upcoming port of NuttX to StarFive JH7110 SoC (with Synopsys DesignWare 8250 UART). [The patch is explained here](https://lupyuen.github.io/articles/plic#appendix-fix-the-spurious-uart-interrupts)

drivers/serial/uart_16550.c: If 16550_WAIT_LCR is enabled, wait until UART is not busy before setting LCR

include/nuttx/serial/uart_16550.h: Define the UART Status Register (USR) for checking if UART is busy

drivers/serial/Kconfig-16550: Added option 16550_WAIT_LCR to 16550 UART Config, disabled by default
2023-08-03 08:38:07 +02:00
Xiang Xiao 82e76961cd serial: Simplify the echo process
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-08-01 15:59:28 -03:00
Xiang Xiao abfe082a6f Kconfig: Simplify the conditional default statement
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-16 14:39:20 -03:00
dulibo1 062e08ea3a serial:fix driver/serial/serial.c logic error
Signed-off-by: dulibo1 <dulibo1@xiaomi.com>
2023-07-12 11:28:54 -03:00
chao an 6ee9ec7656 build: add initial cmake build system
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)

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

How to test

From within nuttx/. Configure:

cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja

(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja

This uses ninja generator (install with sudo apt install ninja-build). To build:

$ cmake --build build

menuconfig:

$ cmake --build build -t menuconfig

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

2. cmake/build: reformat the cmake style by cmake-format

https://github.com/cheshirekow/cmake_format

$ pip install cmakelang

$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done

Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08:00
Huang Qi d8a61108cf drivers/ptmx: Fix a potential buffer overflow
Fix warning:
```
serial/ptmx.c:205:34: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 8 [-Wformat-truncation=]
  205 |   snprintf(devname, 16, "/dev/pty%d", minor);
      |
serial/ptmx.c:205:25: note: directive argument in the range [0, 2147483647]
  205 |   snprintf(devname, 16, "/dev/pty%d", minor);
      |                         ^~~~~~~~~~~~
serial/ptmx.c:205:3: note: ‘snprintf’ output between 10 and 19 bytes into a destination of size 16
  205 |   snprintf(devname, 16, "/dev/pty%d", minor);
```

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-06-09 19:41:11 +03:00
Xiang Xiao 87aa067ab3 serial/16550: Include nuttx/clk/clk.h
to avoid the build break when CONFIG_CLK is enabled

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-04 11:37:59 +03:00
zhanghu5 a043657323 dma support 16550 uart
Signed-off-by: zhanghu5 <zhanghu5@xiaomi.com>
2023-05-23 01:32:03 +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
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
hujun5 7f4cb3057a arch/arm64: merge serial_pl011.c and qemu_serial.c
At present, the serial drivers qemu_serial.c and serial_pl011.c on the fvp-v8r and qemu platforms in arm64 are duplicated
and need to be merged. The plan is to place them under the drivers\serial directory to create a common code module,
so that both fvp-v8r and qemu can use the same code.
In the future, if new platforms use pl011 serial ports, they can also be directly reused

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-05-10 09:06:59 +02:00
gaojiawei 64b51bbbf7 driver/serial/pty.c fix update local flags for the pty device attribute
Signed-off-by: gaojiawei <gaojiawei@xiaomi.com>
2023-05-10 00:47:33 +08:00
Xiang Xiao 6f6fce95a2 Replace all sprintf with snprintf
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-08 09:57:01 +02:00
anjiahao 0c9ca52f37 tty:support tty c_cc VMIN & VTIME
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-04-29 13:48:52 +08:00
chao an 507c8145a9 sched/spawn: remove spawn proxy thread to simplify task/posix_spawn()
The spawn proxy thread is a special existence in NuttX, usually some developers
spend a lot of time on stack overflow of spawn proxy thread:

https://github.com/apache/nuttx/issues/9046
https://github.com/apache/nuttx/pull/9081

In order to avoid similar issues, this PR will remove spawn proxy thread to simplify
the process of task/posix_spawn().

1. Postpone the related processing of spawn file actions until after task_init()
2. Delete the temporary thread of spawn proxy and related global variables

Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-27 17:35:58 +08:00
Xiang Xiao bc3e6c84e1 arch: Rename up_[early]serialinit to [arm64|riscv|x86_64][early]serialinit
The naming standard at:
https://cwiki.apache.org/confluence/display/NUTTX/Naming+of+Architecture%2C+MCU%2C+and+Board+Interfaces
requires that all MCU-private function begin with the name of the architecture, not up_.

follow the change from: https://github.com/apache/nuttx/pull/930

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-27 12:35:04 +03:00
Huang Qi 7ce78dd66a Revert "driver/uart_rpmsg: Passthrough data by default"
This reverts commit 64e611d71e.
2023-03-24 14:59:41 -03:00
Huang Qi fab77cd322 drivers/pty: Echo input by default
Align the pty behavior to linux/bsd,

Also fix the ECHO issue with microadb after https://github.com/apache/nuttx/pull/8691.

adb shell will echo normally with this patch.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-21 07:23:17 +09:00
Xiang Xiao e7090022a0 drivers/serial: Fix some typo error report in https://github.com/apache/nuttx/pull/8843
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-20 08:08:04 +01:00
Xiang Xiao b63994b7f7 drivers/serial: Always support c_oflag, c_iflag and c_lflag in termios
CONFIG_SERIAL_TERMIOS only decide whether to support c_cflag field since
many terminal application need the first three fields to work correctly.
For more information please reference:
https://www.mail-archive.com/dev@nuttx.apache.org/msg09321.html

before this change(olimexino-stm32:tiny):
   text    data     bss     dec     hex filename
  34884     328    1768   36980    9074 nuttx
after this change:
   text    data     bss     dec     hex filename
  35052     340    1768   37160    9128 nuttx
delta
   text    data     bss     dec     hex filename
    168      12       0     180      b4 nuttx

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-19 14:54:59 -06:00
Huang Qi 061e98aa98 drivers/serial: Fix wrong ECHO flag
There is a rookie mistake introduced by https://github.com/apache/nuttx/pull/8691,
ECHO flag is a part of Local Mode (c_lflags) instead of c_iflags.

nuttx-apps should do the same change in nsh_login and termcurse_vt100.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-13 16:29:36 -03:00
raiden00pl b9fd059914 drivers/bluetooth: bth4 depends on bluetooth definitions 2023-03-11 20:30:25 -03:00
Huang Qi cfe6c4be8e driver/serial: Only enable tx interrupt if tx buffer is not empty
Fix https://github.com/apache/nuttx/issues/8731

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-08 16:02:56 +02:00
Huang Qi 64e611d71e driver/uart_rpmsg: Passthrough data by default
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-08 16:39:17 +08:00
Tiago Medicci Serrano a3badd26a0 drivers/serial: Echo CR if NL is detected if console
Echoing console's input is now performed by the serial driver
(https://github.com/apache/nuttx/pull/8691). In order to keep old
behavior of CR being echoed by the device, it's needed to detected
whenever NL is being echoed and send CR before sending it.
2023-03-05 09:44:26 +08:00
Huang Qi 44857ab30e driver/serial: Echo only determined by ECHO flag with termios enabled
Fix a bug that can not disable echo even if termios is enabled.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-03 09:44:30 +02:00
Huang Qi 68384e9db4 drivers/serial: Echo input in driver layer
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-03 11:37:41 +08:00
Huang Qi 5ced61ce08 drivers/serial: Include spawn.h required by CONFIG_TTY_LAUNCH
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-02 11:43:28 +08:00
Huang Qi b178ce4da9 driver/pty: Map CR->LF from terminal input
NuttX only treat \n as new line after https://github.com/apache/nuttx/pull/8628,
so need this conversion to interact with terminal emulator.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-02-27 21:12:35 +08:00
Nathan Hartman 409e2f3701 drivers/serial, libc/termios: Implement tcsendbreak
The TERMIOS(3) function tcsendbreak() and the IOCTLs TCSBRK and TCSBRKP
transmit a serial line Break.

Previously NuttX included an extern declaration for tcsendbreak() and
defines for TCSBRK and TCSBRKP but none of these were implemented.
Attempting to build programs that called tcsendbreak() would fail with
a linker error; attempting to use TCSBRK and TCSBRKP would result in an
error at runtime.

This changeset adds the tcsendbreak() function and handling for TCSBRK
and TCSBRKP; tcsendbreak() is implemented in terms of TCSBRK. Both
TCSBRK and TCSBRKP are implemented in terms of the BSD-compatible Break
IOCTLs TIOCSBRK and TIOCCBRK, which must be provided by the lower half
serial driver. Currently, not all lower half serial drivers in NuttX
support these IOCTLs. Those that do implement them may need one or more
Kconfig options to be set, such as `CONFIG_*_U[S]ART_BREAKS` and, on
some architectures, a separate `CONFIG_*_SERIALBRK_BSDCOMPAT`.

* drivers/serial/serial.c
  (uart_tcsendbreak): New function.
  (uart_ioctl): Implement TCSBRK and TCSBRKP.

* libs/libc/termios/lib_tcsendbreak.c
  (): New file.

* libs/libc/termios/Make.defs
  (CSRCS): Add lib_tcsendbreak.c to the build.

Thanks to Xiang Xiao for PR feedback.

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>
2023-02-15 07:50:02 +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
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