Commit Graph
114 Commits
Author SHA1 Message Date
Pavel Pisa 25a479d5e6 cpukit/dev/can: correct round-robin on same priority Tx
When the device is open multiple times and data
are sent to driver by multiple FIFOs/edges then
round-robin between same priority prevents
one application blocking whole bandwidth.

The problem has been introduced during switch
from original uLUt/LinCAN to NewLib provided TAILQ

Signed-off-by: Pavel Pisa <ppisa@pikron.com>
2026-08-13 17:30:05 -05:00
Aaron Nyholm fa81c05170 cpukit/dev/io: Add NULL check to iodev
Added check to prevent NULL access in rtems_iodev_destory_unregistered.
2026-07-29 15:50:58 +00:00
Kinsey Moore 098ba8472d cpukit/flashdev: Clarify interface and update consumers
This clarifies the flashdev out of band read and write interfaces and
updates any consumers of those interfaces. This was partially refactored
at one point and the refactoring didn't extend to the consumers as it
should have.
2026-07-27 12:15:22 +10:00
Michal Lenc 7f98bd8469 i2c: move drivers from cpukit to bsps/shared
More i2c drivers from cpukit to bsps/shared to allow them use BSP
infrastructure if needed. The framework code i2c-bus.c and i2c-dev.c
kept at its original location.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-07-02 18:33:01 -05:00
Michal Lenc 5ebf57e2af can: move drivers from cpukit to bsps/shared
Move CAN controllers from cputik to bsps/shared directory. This will
allow to use BSP level interface which may be needed for some
controllers. Generic CAN stack implementation is still kept in the
original directory as this shoudl be independent from the low level
driver interface.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-07-02 18:33:01 -05:00
M Mithilesh 77eda6f760 cpukit/confdefs: Add CAN stack resource calculation
The CAN/CAN FD stack requires a worker task per configured queue.
Empirical profiling confirms the CAN worker task utilizes ~404 bytes
of stack space on 32-bit architectures.

This patch introduces CONFIGURE_MAXIMUM_CAN_QUEUES to dynamically
inject the required CAN worker tasks into the master _CONFIGURE_TASKS
pool. Because the 404-byte usage falls below RTEMS_MINIMUM_STACK_SIZE,
provisioning them as standard system tasks automatically guarantees
sufficient stack space overhead.

Additionally, this patch removes the hardcoded +0x1000 stack padding
in rtems_task_create to prevent workspace exhaustion, and adds the
spcan01 test to verify the CONFIGURE_MAXIMUM_CAN_QUEUES macro behavior.

Closes #5193
2026-07-02 17:36:27 -05:00
Aaron Nyholm ed072a2501 iodev: Add iodev driver
Add iodev driver and related test
2026-06-25 17:37:09 -05:00
Cheng Mingming e73cb3ee2b cpukit/dev/can: Reject out-of-range CAN queue priority
can_bus_ioctl_create_queue() validates the priority supplied by user
space via the RTEMS_CAN_CREATE_QUEUE ioctl. The valid range is 0 to
RTEMS_CAN_QUEUE_PRIO_NR - 1, since RTEMS_CAN_QUEUE_PRIO_NR is the
number of available priority classes.

The previous check rejected only values greater than
RTEMS_CAN_QUEUE_PRIO_NR, so a priority equal to RTEMS_CAN_QUEUE_PRIO_NR
passed validation and was stored in edge_prio. Reject this value at
the ioctl boundary instead of accepting an out-of-range priority and
relying on later internal handling.

Use >= so that only priorities within the documented range are
accepted.
2026-06-18 16:30:42 +00:00
Cheng Mingming a241e49bda cpukit/dev/flash: Fix region bitmap clear size
rtems_flashdev_register() cleared the region allocator bitmap with
memset( table->bit_allocator, 0, alloc_array_len ) where alloc_array_len
held the number of uint32_t words.  Since bit_allocator is a uint32_t
array, only one byte per word was zeroed, leaving the rest of the bitmap
uninitialised.  Stale bits can make
rtems_flashdev_find_unallocated_region() report region slots as
allocated and fail REGION_SET with ENOMEM while slots are actually free.

Rename RTEMS_FLASHDEV_BITALLOC_LENGTH to RTEMS_FLASHDEV_BITALLOC_WORD_LENGTH
to make the word count explicit, add RTEMS_FLASHDEV_BITALLOC_BYTE_LENGTH for
the size in bytes, and clear the whole bitmap using the byte length.
2026-06-10 09:42:54 +08:00
Michal Lenc 3cb2e57560 cpukit/dev/can: fail controller init if worker task start doesn't start
CAN controllers need a running worker task to function. Check if
the task is actually started and return NULL (and free already allocated
resources) if it fails.

Also assert if cleanup functions fail.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-05-14 15:46:10 +00:00
Pavel Pisa 48d8b2bdea cpukit/dev/can/sja1000: fix build failure on i386 with I/O option
Disable PCI/PCIe and other buses I/O mapped access
because rtems/cpukit build is not allowed to access
BSP specific headers during build.

rtems/bsps/i386/include/i386_io.h

Cannot be used.

This is temporal workaround for

rtems/rtos/rtems#5563

Signed-off-by: Pavel Pisa <ppisa@pikron.com>
2026-04-29 02:41:08 +02:00
Michal Lenc 558615a28e cpukit/dev/can/ctucanfd/ctucanfd.c: fix typo
folowing -> following in license header

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-04-27 21:26:51 -05:00
Michal LencandPavel Pisa df346b439b can: add support for SJA1000 CAN controller
This commit adds support for a stand alone SJA1000 CAN controller. This
is classical CAN only capable controller, so no FD support here. The
driver's implementation is similar to CTU CAN FD, thus interrupt handler
triggers a semaphore in main worker thread that takes care of handling
interrupts and receiving and sending messages.

The controller utilizes its one TX buffer for sending messages with
abort function available if higher priority message is present in
the software queue.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
Co-authored-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
2026-04-27 21:26:51 -05:00
Michal Lenc 8ac4b4c412 can/ctucanfd: add can prefix to rtems_ctucanfd_initialize
This commit renames function rtems_ctucanfd_initialize to
rtems_can_ctucanfd_initialize. It standardizes the naming for CAN
controllers to always begin with rtems_can_ (similar to virtual
controller or sja1000 at the moment under review).

This is an API breaking change.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-04-12 07:33:41 -05:00
M Mithilesh 2970f882c9 cpukit/dev/can: Check task start status in queue init (CID 1642607) 2026-03-06 11:08:21 -06:00
M Mithilesh 1af2b99fa9 cpukit/can: Fix out-of-bounds array access
Add bounds checking to txtb_id to prevent out-of-bounds writes
in the TX buffer array. Fixes Coverity CID 1642617 and resolves
Issue #5248.
2026-02-27 15:49:12 -06:00
Kinsey Moore ef52cb5fbc cpukit/dev/can: Resolve sign comparison warning
Make the constant unsigned so that signedness on both sides of the
comparison matches.
2026-02-09 17:23:00 +00:00
Gedare Bloom 149df22aeb cpukit/dev: reformat io files
Closes #5443.
2026-02-05 10:46:11 -07:00
Gedare Bloom 1b17076054 cpukit/dev/spi: reformat
Updates #5443.
2026-02-05 10:46:11 -07:00
Gedare Bloom 4ced2b7f33 cpukit/dev/serial: reformat
Updates #5443.
2026-02-05 10:46:11 -07:00
Gedare Bloom 0e85986583 cpukit/dev/i2c: reformat
updates #5443.
2026-02-05 10:46:11 -07:00
Gedare Bloom ffd859a304 cpukit/dev/flash: reformat
Updates #5443
2026-02-05 10:46:11 -07:00
Gedare Bloom c6cdbd2c60 cpukit/dev/can: reformat
Updates #5443
2026-02-05 10:46:09 -07:00
Gedare Bloom fbc96a878b cpukit/dev: relocate iovprintf.c
Updates #5374
2026-02-02 19:16:07 +00:00
Joel Sherrill 0b7eb103fe cpukit/dev: Address -Wsign-compare warnings
This warning occurs when comparing a signed variable to an unsigned one.
This addresses warnings that only occurred on 64-bit targets.  For the
ones which only appeared on 64-bit targets, the cause was frequently
a mismatch when comparing a combination off_t, ssize_t, and int.
2026-02-02 12:48:43 -06:00
Yash cecbf340e9 cpukit/dev/can: Fix spelling errors in comments
Correct 'succesful' to 'successful' and 'succesfully' to 'successfully'
in the CAN and CTUCANFD driver comments.

Updates #5429
2026-01-24 17:01:35 +00:00
Michal Lenc 40305e360f can: fix -Wsign-compare warnings
Fixes -Wsign-compare compile warnings in CAN code. This introduces
the change in rtems_ctucanfd_initialize where ntxbufs is changed from
int to unsigned int, thus making the ntxbufs < 0 obsolete.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2025-12-18 19:14:40 -06:00
Joel Sherrill 089a16b6e8 cpukit/dev/can/can-bus.c: Address type-limits warnings
These changes were made to address GCC -Wtype-limits warnings.
In this case, the variables were unsigned and there was no need to
check them for being <= 0.

Updates #5388.
2025-12-11 23:53:16 +00:00
Joel Sherrill 426f938869 cpukit/.../flashdev.c: Correct comparisons of different signedness
The GCC warning -Wsign-compare flagged these instances of comparing
signed and unsigned types. A common pair was size_t and int.
2025-12-04 18:46:23 -05:00
Kinsey Moore e3592620d7 cpukit/flashdev: Return error for missing callbacks
When a callback does not exist, the Flashdev API should return error
where possible instead of success. When the API returns success for
missing callbacks, the Flashdev API client code may end up using
uninitialized variables as if they were filled by the API.

Closes #5391
2025-11-10 12:29:32 -06:00
Joel Sherrill 34f9c5690d cpukit: Address unused parameter warnings
Add "(void) param;" annotation to address unused parameter warnings.
Found with GCC's warning -Wunused-parameter.
2025-10-10 21:59:38 +00:00
Kinsey Moore 38e8e5c286 cpukit/flashdev: Add full support for NAND devices
This extends the flashdev API to support the additional calls required
by NAND device backends. This also adds region-relative IOCTLs to
prevent reimplementation of offset logic in top-end flashdev/filesystem
adapters.
2025-10-02 20:12:51 -04:00
Joel Sherrill 60458df1c2 cpukit/dev/can/*: Address unused parameter warnings
Add "(void) param;" annotation to address unused parameter warnings.
Found with GCC's warning -Wunused-paramter.
2025-09-26 22:38:34 +00:00
Kinsey Moore 75e7f5cb80 cpukit/flashdev: Add unregister call and private data destructor
This adds an API call allowing for unregistration to include destruction
of private data that is not managed by the flashdev framework. This also
updates the existing consumers of flashdev to use the new private data
destructor callback.
2025-09-22 10:04:58 -05:00
Michal Lenc e8de13e0c5 cpukit/dev/can/can-bittiming.c: remove calls to abs()
Using abs() on unsigned integers leads to GCC warning -Wabsolute-value.
This commit removes the calls to abs() and replaces them with ternary
conditional operator. This keeps the correct error calculation
previously ensured by abs() call.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2025-09-20 20:47:14 +02:00
Joel Sherrill 106363b29d cpukit/*: Correct implicit fallthrough warnings
Use RTEMS_FALL_THROUGH() to annotate case statements which
intentionally do not have a break statement.
2025-09-19 19:02:25 +00:00
Kinsey Moore 509ce2fde4 cpukit/flashdev: Remove unnecessary reinitialization 2025-09-10 18:56:24 +00:00
Aaron Nyholm f93f3b87c8 flashdev: Added missing copyright 2025-09-09 16:09:49 +00:00
Amar Takhar b714e4a809 ascii: Remove non-ASCII characters
We will soon be enforcing ASCII-only characters for source.
2025-05-22 19:35:12 +00:00
Joel Sherrill 91cc54bcf9 cpukit/dev/i2c/*: Relicense to 2-BSD
All files were written by Chris Johns who has previously given
permission to relicense.

Update #3053.
2025-03-19 01:16:19 +00:00
Gedare Bloom 8e6ded473c rtems: update licenses to 2BSD
This is an update of many lingering embedded brains GmbH licenses from
the RTEMS License to the 2-BSD license where possible depending on the
joint copyrights.

Updates #3053.
2025-02-10 15:44:09 +00:00
Michal Lenc 91237f06f9 can/ctucanfd: use STM mode if CAN_CTRLMODE_PRESUME_ACK is set
Self Test mode in CTU CAN FD has generally better much for
CAN_CTRLMODE_PRESUME_ACK mode compared to self-acknowledge mode (SAM)
It considers transmitted frame valid even if dominant acknowledge bit
was not receive, therefore it presumes acknowledge.

Moreover, this mode is available even in older CTU CAN FD versions.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2025-02-07 01:06:01 +00:00
Gedare Bloom db425a09b1 dev/can: remove URLs from copyrights 2025-02-07 00:30:36 +00:00
Michal LencandPavel Pisa e6f6eccaef can: add support for CTU CAN FD controller
This commit adds support for CTU CAN FD controller. The controller
can be initialized from BSP by ctucanfd_initialize() function call.
It also implements the dynamic redistribution of hardware transmission
buffers to CAN stack priority classes in order to avoid possible
priority inversion.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
Co-authored-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
2025-01-28 08:25:28 +01:00
Michal LencandPavel Pisa 0cbb9eb9f9 can: add support for a simple virtual CAN controller
This commit adds a support for a simple virtual CAN controller. This
controller can be used to test CAN stack functions and serves as an
inspiration for further controller implementations.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
Co-authored-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
2025-01-28 08:25:28 +01:00
Michal LencandPavel Pisa c3f4e215b1 cpukit: add support for common CAN/CAN FD stack
This adds support for common full-featured CAN/CAN FD stack to RTEMS.
The API is provided in form the form of the POSIX character driver with
each CAN controller (chip) registered as node into “/dev”
namespace.

The stack utilizes FIFO queues (also called edges) organized
into oriented edges between controller side and application side.
Edges, responsible for message transfers from application to controller
and vice versa, can have different priorities and function as priority
classes.

The stack provides run time configuration options to create new
queues with desired priority, direction and filter, making it
suitable for various applications requirements. There is also a
possibility to configure controller’s characteristics (bit rate,
mode, chip specific ioctl calls). Both blocking and nonblocking mode
is supported.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
Co-authored-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
2025-01-28 01:57:28 +00:00
Sebastian Huber 2c64cf1bd8 dev/serial/sc16is752-spi: Fix warnings
Fix several may be used uninitialized warnings.
2024-11-12 16:21:20 +00:00
Aaron Nyholm 87c725b6ed flashdev: Add sector IOCTLs
Added new IOCTLs to flashdev to get sector info.
Updated flashdev shell command and flashdev test with new IOCTLs.
2024-11-06 22:35:20 +00:00
Sebastian Huber ce1fb41a6c kvprintf(): Fix '+' conversion handling
For example, printf("%+i", 1) prints "+1".  However, kvprintf() did
print just "1" for this example.  According to PRINTF(3):

  A sign must always be placed before a number produced by a signed
  conversion.

For "%+r" radix conversions, keep the "+" handling as it is, since this
is a non-standard conversion.  For "%+p" pointer conversions, continue
to ignore the sign modifier to be in line with libc.

This change allows to support the ' conversion modifier in the future.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1310
2024-09-12 23:34:28 +00:00
Sebastian Huber 1e68298847 dev/io: Fix "%hhi" conversion
The signedness of "char" is implementation-dependent.
2024-06-13 17:19:35 +00:00