Skip to content

Commit 40a9512

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents e51a9ad + b698cc1 commit 40a9512

File tree

705 files changed

+45103
-16398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

705 files changed

+45103
-16398
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
================================
2+
``Cyclictest`` benchmark utility
3+
================================
4+
5+
Cyclictest is a simple program used to measure the real-time capabilities
6+
of a RTOS. Originally, this program comes from the Linux ``rt-tests``.
7+
However, NuttX features its own cyclictest utility which is heavily inspired
8+
by the original program but does not use some advanced features, while adding
9+
features that are NuttX related.
10+
11+
The creation of the new cyclictest arose from the fact that as of February
12+
2025, POSIX time functions (such as ``clock_gettime`` and ``clock_nanosleep``)
13+
depend on the systemtick (if the system is not compiled in the Tickless mode)
14+
which makes small delays practically impossible. However, if we utilize
15+
a hardware device timer, small periodic delays can be achieved with some ``ioctl``
16+
calls.
17+
18+
The documentation needs to be revisited to see how cyclictest performs
19+
when NuttX is compiled in tickless mode.
20+
21+
Replacement for ``clock_gettime`` and ``clock_nanosleep`` in NuttX
22+
------------------------------------------------------------------
23+
24+
Configuring such device timer is simple: firstly, the timer's timeout is set using
25+
the ``TCIOC_SETTIMEOUT`` ``ioctl`` call. Then the ``TCIOC_NOTIFICATION`` ``ioctl`` call
26+
is performed. Afterwards, the timer can be polled using the ``poll`` function
27+
which returns when the timer timeouts.
28+
29+
The thread latency wakeup can be measured using this timer by calling
30+
``TCIOC_GETSTATUS`` ``ioctl`` call after the ``poll`` function has returned.
31+
The ``ioctl`` call fills the ``timer_status_s`` struct which contains two important
32+
fields: ``uint32_t timeleft`` and ``uint32_t timeout``. The latency of the thread can
33+
then be calculated as ``timeout - timeleft``.
34+
35+
Usage of this program
36+
---------------------
37+
38+
Despite some differences, the NuttX port stays as faithful as possible to the original
39+
program, keeping the most important command-line parameters the same.
40+
The user can choose one of two "waiting methods":
41+
42+
- ``clock_nanosleep`` (``W_NANOSLEEP``),
43+
- polling the device (``W_DEVTIMER``).
44+
45+
The user can also choose one of two "measuring methods":
46+
47+
- ``clock_gettime`` (``M_GETTIME``),
48+
- utilizing the device timer (``M_TIMER_API``).
49+
50+
It is possible to combine the waiting and measuring methods. As of February 2025,
51+
using ``W_DEVTIMER`` and ``M_TIMER_API`` produces the best results.
52+
However, it requires a timer device to be registered by your BSP (such as ``/dev/timer1``).
53+
Be also advised that when ``W_DEVTIMER`` is used, only one thread can poll the timer.
54+
55+
Following command-line parameters can be supplied:
56+
57+
- ``-c --clock [CLOCK]``: 0 selects ``CLOCK_REALTIME``, 1 selects ``CLOCK_MONOTONIC`` (default)
58+
- ``-d --distance [US]``: The distance of thread intervals. Default is 500 us.
59+
- ``-D --duration [TIME]``: Set the test duration in seconds. Default is 0 (endless).
60+
- ``-e --help``: Displays help and exits.
61+
- ``-h --histogram [US]``: Output the histogram data to stdout. US is the maximum value to be printed.
62+
- ``-H --histofall``: Same as ``-h`` except that an additional histogram column is displayed at the right that contains summary data of all thread histograms. If cyclictest runs a single thread only, the ``-H`` option is equivalent to ``-h``.
63+
- ``-i --interval [US]``: The thread interval. Default is 1000 us.
64+
- ``-l --loops [N]``: The number of measurement loops. Default is 0 (endless).
65+
- ``-m --measurement [METHODS]``: Sets the time measurement method. 0 selects ``clock_gettime``, 1 uses the NuttX timer API. Be advised that if 1 is selected, you need to specify a timer device (e.g. ``/dev/timer0``) in ``-T``.
66+
- ``-n --nanosleep [METHOD]``: Sets the waiting method: 0 selects ``clock_nanosleep``, 1 waits for the POLLIN flag on a timer device. Default is 0. Choosing 1 works only with one thread, the ``-t`` value is therefore set to 1. If METHOD 1 is selected, you need to specify a timer device (e.g. ``/dev/timer0``) in ``-T``.
67+
- ``-p --prio``: Sets the priority of the first thread.
68+
- ``-t --threads [N]``: The number of test threads to be created. Default is 1.
69+
- ``-T --timer-device [DEV]``: The measuring timer device. Must be specified when ``-m=1`` or ``-n=1``.
70+
- ``-y --policy [NAME]``: Set the scheduler policy, where NAME is fifo, rr, batch, idle, normal, other.
71+
72+
Example usage
73+
-------------
74+
``cyclictest -p 150 -T /dev/timer1 -m 1 -n 1 -h 20 -D 100 -i 50``
75+
76+
Since ``W_DEVTIMER`` is used, only one thread runs every 50 us.
77+
The measurement method is the device timer itself, specified in ``-T``.
78+
The test runs for 100 seconds. The priority is boosted to 150, so the
79+
measurement is not affected by other tasks or communication.
80+
81+
Output of the command (tested on Microchip ATSAMV71Q21B @ 300 MHz):
82+
83+
.. code-block:: text
84+
85+
# Histogram
86+
000000 000000
87+
000001 000000
88+
000002 000000
89+
000003 000000
90+
000004 000000
91+
000005 000000
92+
000006 000000
93+
000007 000000
94+
000008 000000
95+
000009 000000
96+
000010 603045
97+
000011 1395782
98+
000012 000804
99+
000013 000153
100+
000014 000034
101+
000015 000083
102+
000016 000030
103+
000017 000000
104+
000018 000000
105+
000019 000000
106+
# Total: 001999931
107+
# Min Latencies: 00010
108+
# Avg Latencies: 00010
109+
# Max Latencies: 00016
110+
# Histogram Overflows: 00000

Documentation/applications/games/brickmatch/index.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
=========================
44

55
Brickmatch is a kind puzzle game like a mix between tetris and Candy
6-
Crush. It is a 6x6 matrix with blocks (cells) with different colors.
6+
Crush. It is matrix (e.g 6x6, 8x8) with blocks (cells) with different
7+
colors.
78

89
Your goal is to move the blocks of the board to unite three or
910
more with the same color.
@@ -26,7 +27,8 @@ matrix to the right SPI pins (look your board configuration) and the
2627
APDS9960 to the I2C port (also connect its INT pin).
2728

2829
If you don't have an APA102 matrix you can also play it using an LCD
29-
display and a digital joystick (DJOYSTICK) or the console input.
30+
display or led matrix(WS2812) and a digital joystick (DJOYSTICK), gpio pins
31+
or the console input.
3032

3133
Then you can configure and compile the game to play in your board,
3234
i.e. for ESP32-Devkitc there is already an example using the APA102::

Documentation/applications/interpreters/python/index.rst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ How Does it Work?
1818

1919
1. Python for NuttX target initially the ``rv-virt`` (RISC-V QEMU) board.
2020
2. Python modules are stored in `pyc <https://docs.python.org/3/glossary.html#term-bytecode>`_ (byte-code format) and are loaded from a ROMFS image at startup.
21-
3. Environment variables like ``PYTHONHOME`` and ``PYTHON_BASIC_REPL`` need to be set accordingly.
21+
3. The Python wrapper application on NuttX mounts the ROMFS partition which contains the Python modules and sets the required environment variables (``PYTHONHOME`` and ``PYTHON_BASIC_REPL``) automatically.
2222

23-
Building Python NuttX
24-
=====================
23+
Building Python on NuttX
24+
========================
2525

2626
Use the ``rv-virt:python`` config to build Python for NuttX. Note that the CMake scripts don't work for this configuration. For now, please use the makefile build instead:
2727

@@ -66,10 +66,6 @@ Then, run RISC-V QEMU with the following command:
6666
telnetd [4:100]
6767
6868
NuttShell (NSH) NuttX-10.4.0
69-
nsh> python_mount_modules
70-
Mounting ROMFS filesystem at target=/usr/local/lib/ with source=/dev/ram1
71-
nsh> export PYTHONHOME /usr/local
72-
nsh> export PYTHON_BASIC_REPL 1
7369
nsh> python
7470
Python 3.13.0 (main, Dec 4 2024, 17:00:42) [GCC 13.2.0] on nuttx
7571
Type "help", "copyright", "credits" or "license" for more information.

Documentation/components/drivers/character/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,4 @@ Character device drivers have these properties:
7777
serial.rst
7878
timers/index.rst
7979
touchscreen.rst
80+
wireless/index.rst

Documentation/components/drivers/character/serial.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ Serial Device Drivers
4343
``arch/arm/src/lpc214x/lpc214x_serial.c``,
4444
``arch/z16/src/z16f/z16f_serial.c``, etc.
4545

46+
Serial Error Reporting
47+
----------------------
48+
49+
It is possible to check if there are some frame, parity, overrun, break, or
50+
other error using the ioctl TIOCGICOUNT just like on Linux.

Documentation/components/drivers/character/timers/pwm.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,24 @@ of PWM channels should be set before this operation.
182182
183183
The ``PWMIOC_STOPS`` command stops the pulsed output.
184184

185+
.. c:macro:: PWMIOC_FAULTS_FETCH_AND_CLEAR
186+
187+
The ``PWMIOC_FAULTS_FETCH_AND_CLEAR`` command clears fault inputs. Some
188+
faults can be latched (remain active even if the source is not active
189+
anymore) and have to be cleared from the software. This provides an option
190+
to clear faults from the application and re-enable PWM output. It can be
191+
also used to fetch the current faults.
192+
193+
The call takes a pointer to ``unsigned long`` variable as an argument, a
194+
bitmask defining which faults are to be cleared. The driver clears these
195+
faults and fills the argument with the active faults prior to this clear.
196+
Having the argument variable equal to zero will result in no faults cleared
197+
but the user will get the currently active faults. If NULL is passed as
198+
an argument, then all currently set faults are cleared and fetch is not
199+
performed.
200+
201+
This may not be supported by all drivers.
202+
185203
Application Example
186204
~~~~~~~~~~~~~~~~~~~
187205

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
==========================
2+
Wireless character drivers
3+
==========================
4+
5+
.. toctree::
6+
:maxdepth: 1
7+
8+
lpwan/index.rst
7.08 KB
Loading
90.4 KB
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=====
2+
LPWAN
3+
=====
4+
5+
.. toctree::
6+
:maxdepth: 1
7+
8+
sx126x.rst
9+

0 commit comments

Comments
 (0)