when C++ lib has an atomic implementation, we shouldn't include NuttX defined macros to avoid conflicts
Fix errors like:
build/include/libcxx/__atomic/atomic.h:445:1: error: expected identifier before numeric constant
445 | atomic_fetch_add(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
| ^~~~~~~~~~~~~~~~
Signed-off-by: raiden00pl <raiden00@railab.me>
This reverts commit 29e50ffa73.
reason:
Placing the main thread and the gourd in the same memory block, and allocating and freeing memory simultaneously, presents the following two problems:
When the main thread creates a child thread and performs a detach operation, there is a possibility that the main thread may have exited, but the main thread's TCB (Transaction Control Block) may not have been released.
This could potentially cause the main thread's TCB to be double-freed. The core contradiction in this problem lies in binding the main thread's TCB (Trust Container Registry) and the group together. When releasing the main thread's TCB, an additional check is needed to ensure the main thread was the last to leave the group. If this check and the free operation are atomically guaranteed, the logic is sound, and double freeing won't occur. However, this atomicity cannot be completely guaranteed. If other free operations cause a block, problems still arise.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
This allows the compiler to automatically identify which string functions
can be compiled into libraries, and the compiler's internal implementation
is faster than libc functions.
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Add MTD driver for Winbond W25N series SPI NAND flash.
Currently supports W25N01GV (1Gbit/128MB).
Features:
- Standard SPI interface with configurable frequency (up to 104 MHz)
- Hardware ECC enabled by default
- Block erase with sleep-based wait (releases SPI bus)
- Page read/write with busy-wait for fast operations
Limitations:
- No bad block management (BBM). Factory bad blocks and runtime bad
blocks are not tracked.
- No bad block table (BBT) scanning at initialization.
- No Quad SPI support (standard SPI only).
- No access to spare area (64 bytes/page) or OTP region.
Tested using:
- Board with STM32H743
- W25N01GV on SPI at 96 MHz with DMA enabled
- Flash mounted using littlefs
- Tested using sdbench:
- Sequential write speed of 1760 KB/s
- Sequential read speed of 4900 KB/s
Signed-off-by: Julian Oes <julian@oes.ch>
Add handling for GPIOC_SETDEBOUNCE to set GPIO pin debounce duration.
Add handling for GPIOC_SETMASK to enable/disable GPIO interrupt mask.
Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
Add a safe synchronous hrtimer cancel API, hrtimer_cancel_sync().
If the timer callback is currently executing, this function waits
until the callback has completed and the timer state transitions
to HRTIMER_STATE_INACTIVE.
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
Enable up_alarm_start and up_timer_start by default so they can be used
by both the tickless scheduler and the high-resolution timer subsystem.
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
NuttX provides the wdog module to implement timers for the scheduler.
While it is lightweight and efficient, wdog only supports tick-level timers,
typically in milliseconds. Although the tick duration can be configured,
setting it to microsecond or nanosecond resolution is not practical.
Doing so may cause an interrupt storm, where the CPU is constantly
occupied handling tick interrupts.
To address this limitation, a new hrtimer module is introduced.
It coexists with the wdog module, providing both tick-level timers
for wdog and high-resolution timers (nanosecond-level) directly to users.
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
TCP_CORK and TCP_NODELAY behave almost exactly the opposite,
so first provide simple support for TCP_CORK.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
In order to reduce code duplication, use the eeprom/spi_xx25xx
driver within mtd/at25ee.
The eeprom/xxx.h includes have been merged into eeprom/eeprom.h, to
provide a common include file like mtd/mtd.h.
Signed-off-by: Antoine Juckler <6445757+ajuckler@users.noreply.github.com>
In rare case, the round-nearest behavior in the clkcnt_best_multshift
may result in converted tv_nsec > NSEC_PER_SEC. This commit fixed the
issue.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
Upperhalf supports multiple working modes at the same time,
which is specified by NIC when register
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Ref: https://man7.org/linux/man-pages/man7/packet.7.html
1. For `socket(AF_PACKET, int socket_type, int protocol)`: When `protocol` is set to `htons(ETH_P_ALL)`, then all protocols are received. If `protocol` is set to zero, no packets are received.
2. For `bind`: `bind` can optionally be called with a nonzero `sll_protocol` to start receiving packets for the protocols specified.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
When tcb may has been released in caller, the return pointer to tcb->name is dangling pointer. So add a buffer in caller, even if tcb is released, buffer is still valid.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
The clang compiler has also defined `__GNUC__`, which can't be used to
decide the compiler version.
And the version used to decide whether the builtin function
`__builtin_dynamic_object_size` exist is not correct.
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
1. We add default PCP because some of our apps may not want to set PCP
manually (e.g. Our user may just ping with pre-set PCP)
2. The `vlan_qos` is used as PCP when setting Linux's priority mapping:
https://github.com/torvalds/linux/blob/v6.12/net/8021q/vlan.c#L590
Although `vlan_qos` is not used when creating VLAN on Linux, we can
use it as PCP on creating VLAN (without changing its meaning), and
keep compatible with Linux's creating (Exactly the same when
`vlan_qos` is 0).
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
Inspired by Linux's way, we also create VLAN devices for managing VLAN,
which will become interfaces like `eth0.58`.
QinQ is also supported, we can create VLAN devices above another VLAN
devices, like `eth0.100.101` (or even `eth0.1.2.3.4`, also supported on
Linux).
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
As pull request apache#17200 & apache#17368 introduced support for scheduling sleep, a documentation is needed for different sleep interfaces.
This patch adds the description for sleep interfaces currently provided in NuttX, including Scheduled sleep(nxsched_sleep()...), Signal-scheduled sleep(nxsig_sleep()...), and Busy sleep(up_udelay()).
Signed-off-by: Haokun Dong <donghaokun@lixiang.com>
Add support for the page erase (PE), sector erase (SE) and chip erase
(CE) dedicated commands on supported devices.
They can be triggered using the corresponding IOCTL commands
EEPIOC_PAGEERASE, EEPIOC_SECTORERASE and
EEPIOC_CHIPERASE.
On unsupported devices, this is equivalent to writing a full page,
sector, or the entire EEPROM to 0xFF.
Signed-off-by: Antoine Juckler <6445757+ajuckler@users.noreply.github.com>
Add complete driver support for the QST QMI8658 6-axis IMU sensor featuring
3-axis accelerometer and 3-axis gyroscope with I2C interface and uORB
integration.
Key features implemented:
* Full I2C communication with configurable frequency (default 400kHz)
* Multiple accelerometer ranges (±2g, ±4g, ±8g, ±16g) and ODR settings
* Multiple gyroscope ranges (±16 to ±1024 dps) with high ODR support
* Low-pass filter configuration for both sensors
* Temperature sensing with 16-bit resolution
* Self-test capability for both accelerometer and gyroscope
* Calibration-on-demand support with offset registers
* FIFO buffer management (framework ready)
* Interrupt-driven and polling mode support
* Complete uORB integration with sensor_accel and sensor_gyro topics
Driver components added:
* Core driver implementation (qmi8658_uorb.c) with register operations
* Header file with register definitions and scale factors (qmi8658.h)
* Kconfig options for driver configuration and polling mode
* Build system integration (CMakeLists.txt, Make.defs)
* Comprehensive documentation with API reference and usage examples
The driver follows NuttX sensor framework conventions and provides
robust error handling, mutex protection, and comprehensive debugging
support through CONFIG_DEBUG_SENSORS.
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Replace the pipe() macro definition with a proper function implementation
to improve POSIX compliance and debugging capabilities. The new pipe()
function serves as a wrapper around pipe2() with flags set to 0.
Changes include:
- Convert pipe() from macro to function declaration in unistd.h
- Add lib_pipe.c implementation file with proper function documentation
- Update build system files (CMakeLists.txt and Make.defs) to include
the new source file when CONFIG_PIPES is enabled
- Add pipe() entry to libc.csv for symbol tracking
This change allows for better debugging, proper symbol resolution,
and follows NuttX coding standards for library function implementations.
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>