Descriptor head is managed by HW and should not be modified by SW unless:
1. device is after a reset
2. device is before enabling TX or RX
Also set correct tail for RX which should point at the end of ring
(descriptor ring is zero-indexed).
Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
Do not reset RX/TX rings when link status change.
This can break internal card state which is impossible to recovery.
Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
reset RX/TX rings **after** RX/TX are disabled to make sure the rings are
not used by hardware when software modify rings state.
Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
In file_read(), asynchronous reading is supported, so partial reads and the minread parameter are no longer needed.
Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
In btuart_rxwork, There is no case for parsel HCI data of ISO type, but there are corresponding processes in the SIM and vendor driver code.
Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
When the nread return value < 0, if the total length ntotal that has been read is > 0, the function returns ntotal; otherwise, it returns the nread error code.
Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
Read as much data as possible initially, then process each packet individually. Defined the read buffer within the structure and added a rx_len variable to indicate the current read offset. After processing each complete packet, leftover data is moved to rxbuf[0] and rx_len is reduced by the length of the processed packet. The next packet process will start from rxbuf[0] after the read ends at new rxbuf[rx_len].
Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
This commit provided a better recursive spinlock implementation with
less memory-overhead and better performance.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
Some code paths in drivers/serial/serial.c load head and tail values
of receive and transmit circular buffers with interrupts enabled,
making it possible that the interrupt handler changes the value.
As noted in the code, this is safe as long as the load itself is atomic.
That is not true for 8bit architectures which fetch the 16-bit values
using two load instructions. If interrupt handler runs between those
two instructions and changes the value, the read returns corrupted data.
This patch introduces CONFIG_ARCH_LDST_16BIT_NOT_ATOMIC configuration
option which is automatically selected for AVR architecture. Based
on this option, head and tail values are reduced to 8-bit length
so the read remains atomic.
Patch was tested by building on rv-virt:nsh - disassembly of functions
from serial.c showed no difference which is correct as Risc-V does
not need to protect reads of these values. There should be no impact
for architectures that do not set the new configuration option.
It was also tested by by custom echo application running on AVR128DA28.
Signed-off-by: Kerogit <kr.git@kerogit.eu>
This patch fixes calculation of nbuffered value if
CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS is set. Volatile variable that
can be changed in interrupt handler was used in a condition which
branched the calculation into two paths. Precisely timed interrupt
could make the branch that was taken the incorrect one.
Patch was tested by building on AVR DA/DB chip.
Signed-off-by: Kerogit <kr.git@kerogit.eu>
we are using segger RTT protocol over shared memory for two core log/trace: one is NuttX another Linux/Windows. But the base address of shared memory can only be known at runtime, so we change SEGGER_RTT_UNCACHED_OFF from macro to global variable, and update to the correct g_segger_offset after the shared memory is initialized by:
g_segger_offset = (uintptr_t)ishmem - (uintptr_t)&_SEGGER_RTT;
Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
Initial implementation of RFC 5424 support (syslog protocol). Allows
users to force-format the syslog output in a RFC 5424 compatible way,
making NuttX systems 'originators' that are able to interface with
syslog 'collectors' and 'relays' (useful for logging to syslog servers).
In addition to regular formatting options for syslog output, users can
also add structured data (currently only timeQuality is implemented,
assuming no sync and no timezone is no known). Facilities and severities
now also follow RFC 5424. Support for additional features (like
more sdata elements, msgid, etc.) will need to be built into the syslog
implementation if desired.
This patch is a rework of the NuttX file descriptor implementation. The
goal is two-fold:
1. Improve POSIX compliance. The old implementation tied file description
to inode only, not the file struct. POSIX however dictates otherwise.
2. Fix a bug with descriptor duplication (dup2() and dup3()). There is
an existing race condition with this POSIX API that currently results
in a kernel side crash.
The crash occurs when a partially open / closed file descriptor is
duplicated. The reason for the crash is that even if the descriptor is
closed, the file might still be in use by the kernel (due to e.g. ongoing
write to file). The open file data is changed by file_dup3() and this
causes a crash in the device / drivers themselves as they lose access to
the inode and private data.
The fix is done by separating struct file into file and file descriptor
structs. The file struct can live on even if the descriptor is closed,
fixing the crash. This also fixes the POSIX issue, as two descriptors
can now point to the same file.
Signed-off-by: Ville Juven <ville.juven@unikie.com>
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Use the flag CONFIG_ARCH_HAVE_PERF_EVENTS to detect whether the architecture specific code
provides the up_perf_* functions. Now it is mixed with CONFIG_ARCH_PERF_EVENTS, which should
select just whether the perf events (perf_*) are enabled for the configuration.
- drivers/timers/arch_alarm.c: Don't compile the up_perf_* functions here if the
CONFIG_ARCH_HAVE_PERF_EVENTS is defined
- arch/*/*_perf.c: Change CONFIG_ARCH_PERF_EVENTS -> CONFIG_ARCH_HAVE_PERF_EVENTS to
select whether architecture specific up_perf_* functions are provided
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Add a configuration option CONFIG_SEGGER_SYSVIEW_POST_MORTEM to enable
logging continuously into a circular buffer
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Don't assume that perf_getfreq returns nanoseconds, define the
SEGGER_SYSVIEW_TIMESTAMP_FREQ instead.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
mtd/mtd_rwbuffer.c:42:
mtd/mtd_rwbuffer.c: In function 'mtd_erase':
mtd/mtd_rwbuffer.c:189:9: warning: format '%zx' expects argument of type 'size_t', but argument 3 has type 'long long int' [-Wformat=]
189 | finfo("block: %08zx nsectors: %zu\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190 | (intmax_t)block, nsectors);
| ~~~~~~~~~~~~~~~
| |
| long long int
mtd/mtd_rwbuffer.c:189:21: note: format string is defined here
189 | finfo("block: %08zx nsectors: %zu\n",
| ~~~~^
| |
| unsigned int
| %08llx
mtd/mtd_rwbuffer.c: In function 'mtd_ioctl':
mtd/mtd_rwbuffer.c:298:21: warning: format '%d' expects argument of type 'int', but argument 3 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
298 | finfo("blocksize: %d erasesize: %d neraseblocks: %d\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
299 | geo->blocksize, geo->erasesize, geo->neraseblocks);
| ~~~~~~~~~~~~~~
| |
| uint32_t {aka long unsigned int}
...
Signed-off-by: chao an <anchao.archer@bytedance.com>
if rpmsg triggers force flushing when the master core provides lower putc,
characters will be duplicated caused by SYSLOG_DEFAULT also send the char to lower half.
in this PR, we disable force put char to lower putc if CONFIG_SYSLOG_DEFAULT is enabled
Signed-off-by: chao an <anchao.archer@bytedance.com>
The ADS1115 driver uses the `nxsig_usleep()` function to sleep for a
65us delay, but with a 1ms tick resolution and the context-switching
overhead, this is much more than 1ms. Introducing `up_udelay` (even with
a larger duration because of the unreliability of busy-waiting) speeds
up sampling noticeably.
Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
fix various coding style issues for drivers/sensors:
- remove redundant `#define CONFIG_XXX` that should be provided from Kconfig
- correct section banners
- remove empty section banners
- fix some function banners
Signed-off-by: raiden00pl <raiden00@railab.me>
Fix frame reception when CANFD is not enabled and there are many message in
the RX buffer.
The previous implementation assumed that the size of the data in the RX buffer
is constant, which is not true. Fortunately, the amount of
data in the buffer can be easily read from frame->fmt.rwcnt.
Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
Add support for BME688 sensor based on BME680 implementation.
The BME688 is nearly identical to the BME680, and this implementation
reuses much of the existing BME680 code. However, there are some differences
related to gas measurements that make it impractical to use the same driver
without significantly complicating it. BME688 also supports parallel mode
which isn't yet supported.
Signed-off-by: raiden00pl <raiden00@railab.me>
This revises the post-IRQ interruption control logic so that to balance
the disable/enable operations for both chardev and socketcan cases.
Checked with chardev/socketcan on qemu-intel64.
Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>