Swatantra-66 opened a new pull request, #22149:
URL: https://github.com/apache/nuttx/pull/22149
## Summary
Make serial line break support (`tcsendbreak`, `TCSBRK`, and `TCSBRKP`)
optional via `CONFIG_SERIAL_BREAK`, defaulting to `!DEFAULT_SMALL`.
Many memory-constrained targets (`DEFAULT_SMALL=y`) do not require line
break signaling over UART. Currently, `uart_tcsendbreak()` and its associated
ioctl handling are unconditionally compiled into `drivers/serial/serial.c`.
Furthermore, no ARM MCU lower-half serial driver implements a hardware line
break routine—it is only forwarded via `dev->ops->ioctl` passthrough with
BSD-compatible `TIOCSBRK`/`TIOCCBRK`.
When `CONFIG_SERIAL_BREAK` is disabled (`n`):
- `uart_tcsendbreak()` is omitted from compilation.
- The `TCSBRK` and `TCSBRKP` ioctl cases fall through to default, returning
`-ENOTTY`.
- In user space, `tcsendbreak()` receives `-ENOTTY` from `ioctl()`,
returning `-1` with `errno` set to `ENOTTY`.
- Saves **634 bytes** of Flash (`text`) and **160 bytes** of RAM (`data` +
`bss`) in `drivers/serial.o`.
Addresses Issue #20414.
## Impact
- **Is new feature added?** No (adds Kconfig gating option
`CONFIG_SERIAL_BREAK`).
- **Is existing feature changed?** Yes, `TCSBRK` and `TCSBRKP` return
`-ENOTTY` when `CONFIG_SERIAL_BREAK` is disabled.
- **Impact on user:** None when `CONFIG_SERIAL_BREAK=y` (default). For
`DEFAULT_SMALL=y` configurations, `tcsendbreak()` will fail with `ENOTTY`,
saving Flash and RAM.
- **Impact on build:** None.
- **Impact on hardware:** None.
- **Impact on documentation:** Updated
`Documentation/os/drivers/character/serial.rst`.
## Size Difference (sim:nsh)
Configuration: `sim:nsh` (x86_64)
### `drivers/serial.o`
| Section | `CONFIG_SERIAL_BREAK=y` | `CONFIG_SERIAL_BREAK=n` | Difference |
| :--- | :--- | :--- | :--- |
| **text** | 21918 | 21284 | **-634 bytes (-2.9%)** |
| **data** | 1760 | 1712 | **-48 bytes** |
| **bss** | 3696 | 3584 | **-112 bytes** |
| **Total** | 27374 | 26580 | **-794 bytes (-2.9%)** |
## Testing
### Build Verification
- Clean build with `CONFIG_SERIAL_BREAK=y`: Success.
- Clean build with `CONFIG_SERIAL_BREAK=n`: Success.
- `nxstyle` verification on `drivers/serial/serial.c`: 0 errors.
### Runtime Test Log (`sim:nsh`, `CONFIG_SERIAL_BREAK=n`)
```text
nsh> help
help usage: help [-v] [<cmd>]
. dirname free mount set umount
[ date help mv kill unset
? df hexdump pidof pkill uptime
alias dmesg losetup poweroff sleep watch
unalias echo ln quit usleep xd
basename env ls printf source wait
break exec du ps test
cat exit mkdir pwd time
cd expr mkfatfs readlink true
cp false mkfifo rm truncate
cmp fdinfo mkrd rmdir uname
Builtin Apps:
dd gcov hello nsh sh
dumpstack gpio init ostest
nsh> ps
TID PID PPID PRI POLICY TYPE NPX STATE EVENT SIGMASK
STACK COMMAND
0 0 0 0 FIFO Kthread - Ready
0000000000000000 0069584 Idle_Task
1 0 0 224 FIFO Kthread - Waiting Semaphore
0000000000000000 0067456 sim_loop_wq 0x756942400400 0x756942400488
2 0 0 224 FIFO Kthread - Waiting Semaphore
0000000000000000 0067472 hpwork 0x4017cb00 0x4017cb88
4 4 0 100 FIFO Task - Waiting Semaphore
0000000000000000 0067504 init_main
7 7 4 100 FIFO Task - Running
0000000000000000 0067504 sh
nsh> poweroff
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]