Configure number of passes in interrupt handler logic to avoid losing RX frames
in QEMU environment.
Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
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>
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>
fix an unaligned pointer error for arm32 build:
ctucanfd_pci.c:1361:7: warning: converting a packed 'struct ctucanfd_frame_s'
pointer (alignment 1) to a 'uint32_t' {aka 'long unsigned int'} pointer (alignment 4)
may result in an unaligned pointer value [-Waddress-of-packed-member]
1361 | ptr = (FAR uint32_t *)&rxframe;
Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
Move can_bytes2dlc() and can_dlc2bytes() to a common CAN file
that can be shared between socketCAN implementation and CAN
character driver.
This is the first step to simplifying the logic repeated in
many CAN drivers.
Signed-off-by: raiden00pl <raiden00@railab.me>
For clearing some variables corresponding with the pollfds of the felip in can_close API, we modify poll logic by binding can_reader_s and pollfd.
Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
Corrected CAN FD messages sending in character driver mode.
Assign CAN FD format flag in reception of CAN FD messages.
Corrected some defines mismatches.
The code has been tested in QEMU
qemu-system-x86_64 -m 2G -enable-kvm -smp 1 \
-cpu host,+pcid,+x2apic,+tsc-deadline,+xsave,+rdrand \
-kernel nuttx/nuttx \
-nographic -serial mon:stdio \
-object can-bus,id=canbus0-bus \
-object can-host-socketcan,if=can0,canbus=canbus0-bus,id=canbus0-socketcan \
-device ctucan_pci,canbus0=canbus0-bus,canbus1=canbus0-bus
The overall state of this third party CTU CAN FD driver in NuttX
is far from ideal. It would worth to consult and follow more
closely our Linux kernel driver and even better RTEMS CAN/CAN FD
stack design
https://canbus.pages.fel.cvut.cz/#cancan-fd-subsystem-and-drivers-for-rtems
Signed-off-by: Pavel Pisa <pisa@fel.cvut.cz>
The feature of preventing the same ID frame rotation should be done in the lowerhalf, not in the upperhalf.
Signed-off-by: gaohedong <gaohedong@xiaomi.com>
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
Some macro definitions have already been defined in other header files, redundant macro definitions have been removed in include/nuttx/can.h. Align some code. Remove no use struct (can_response_s) and some variables.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit moves can_bytes2dlc and can_dlc2bytes from kernel internal
functions to API. These functions are necessary to convert bytes to
dlc for CAN FD frames and has to be accessible from the application
since can_hdr_s does not store message length in bytes but directly in
dlc.
Signed-off-by: Michal Lenc <michallenc@seznam.cz>
When initialising the SJA1000 peripheral on some implementations
(SJA1000_FDTOL), "releasing" the buffer when the Rx buffer is empty
causes a buffer pointer misalignment.
On peripheral initialise, remove the flag to "release" the buffer.
This should be safe for all systems using the SJA1000 CAN controller
as a "reset" to the peripheral clears the Rx FIFO.
This driver is based on ESP32 TWAI CAN drivers currently available
in Nuttx, and captures the differences currently present across the
TWAI drivers for easy future adaption to remaining ESP32 platforms
with no loss of support/function. Also provides a generic SJA1000 CAN
driver solution that is CPU-architecture independent.
Changes:
- Low-level driver re-written to allow usage independent of CPU
architecture, and support both SJA1000 and TWAI CAN controllers.
- Platform-specific settings abstracted away to be provided by board
layer.
- Support for multiple instances of SJA1000 driver.
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>
In this nested loop, the iteration variable is the same for both loops.
This is a typo and the inner loop should use a new loop variable.
Signed-off-by: Mingjie Shen <shen497@purdue.edu>
since mmap may exist in block_operations, but truncate may not,
moving mmap beforee truncate could make three struct more compatible
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
- Add mmap into file_operations and remove it from ioctl definitions.
- Add mm_map structure definitions to support future unmapping
- Modify all drivers to initialize the operations struct accordingly
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
- Add truncate into file_operations
- Move truncate to be common for mountpt_operations and file_operations
- Modify all drivers to initialize the operations struct accordingly
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
In the past, header file paths were generated by the incdir command
Now they are generated by concatenating environment variables
In this way, when executing makefile, no shell command will be executed,
it will improve the speed of executing makfile
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
1.Don't check the return value of nxsem_init or nxmutex_init
2.Fix some style issue
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>