Compare commits

..

568 commits

Author SHA1 Message Date
Jorge Guzman
e59fee53af nshlib, graphics/microwindows: require the keyboard byte stream
Both read a keyboard as a stream of characters:  NSH uses a USB HID
keyboard for stdin, and the raw mode of the Microwindows keyboard driver
decodes the stream with the codec.  That stream now comes from
INPUT_KEYBOARD_BYTESTREAM rather than from the USB HID driver itself.

Say so, so that Kconfig refuses a combination that cannot work instead of
letting the application read events and treat them as text.  No in-tree
configuration selects either option.

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2026-08-02 18:36:37 +08:00
Jorge Guzman
ece6221edb examples/hidkbd: follow the byte stream option rename
The example gated its decoding on HIDKBD_ENCODED, which no longer
exists: the USB HID keyboard driver reports through the keyboard upper
half now, and what produces the byte stream is
INPUT_KEYBOARD_BYTESTREAM.

Left as it was, the option could never be satisfied and the example
would quietly stop decoding special keys.

Reaching the option again brings hidkbd_decode() back into the build
after a spell of being unreachable, and it uses isprint() without
including ctype.h. That is an error rather than a warning under the
-Werror the CI builds with, in the nine configurations that enable
EXAMPLES_HIDKBD, so add the include here rather than in a later commit.

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2026-08-02 18:36:37 +08:00
Jorge Guzman
b62cec9eb1 system/kbd: inject keys into a uinput keyboard
Somebody porting a board has to work on the application side before the
keyboard driver exists, and somebody reviewing that work often does not
have the board at hand at all.

With -i the tool goes the other way and writes into a uinput keyboard,
either what it reads from its own stdin or every key of another keyboard.
So an application reading /dev/ukeyboard is driven from the serial
console, or from whatever is on the far end of it, and a real keyboard
and an injected one can drive it at the same time, which neither can do
on its own since an application opens a single device.

Nothing in the application changes:  it is reading a keyboard like any
other, which is the point.

Validated on a Linum STM32H753BI, forwarding a USB HID keyboard and the
serial console into the same virtual keyboard, with the LVGL terminal
reading it.  24 press and release pairs survived the crossing with no
duplicate, no orphan and three keys held at once.

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2026-08-02 18:36:37 +08:00
Jorge Guzman
47b3f92f9d examples/lvglterm: read any keyboard through one input path
The terminal had three input sources to choose from, and its own help
text explained why:  the physical keyboard options "differ in the data
the keyboard device delivers on read(), so pick the one that matches the
hardware".  That is the abstraction leaking.  A user had to know that
the keyboard was USB rather than a matrix in order to compile the
terminal, and swapping one for the other meant rebuilding.

There are two sources now, touch and physical, and the physical one
reads any keyboard registered with keyboard_register().  Which format
arrives is decided by INPUT_KEYBOARD_BYTESTREAM, a property of the build
rather than of the hardware, so the terminal no longer asks.

Cursor keys reported as special events scroll the terminal, which is
what a driver following the current contract sends.  The out of band
codes that the M5Stack Cardputer reports as ordinary presses are still
honoured, so that board keeps working until its driver is converted.

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2026-08-02 18:36:37 +08:00
Jorge Guzman
f52bc61adb games/NXDoom: handle the special key events
i_get_event() handled KEYBOARD_PRESS and KEYBOARD_RELEASE and dropped
everything else, so every key reported as KEYBOARD_SPECPRESS went
nowhere.  On the simulator that is already every arrow key, since
sim_keyboard reports them that way:  the game is unplayable and says
nothing about why.

Handle all four types.  A special key carries a value from enum
kbd_keycode_e rather than a character, so it gets its own translation
into doomkeys.h and contributes no printable character to the event.

The map covers what the game binds by default, which now includes Ctrl,
Shift and Alt.  Fire, run and strafe are on the modifiers, so a keyboard
that reports them is the difference between playing and walking around.

Enter needed folding onto KEY_ENTER as well.  A driver reports it as the
character that it produces, which is the line feed, so it never arrived
as KEYCODE_ENTER and never matched the carriage return that the game
binds the menu to.  Confirmed on hardware with a USB keyboard.

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2026-08-02 18:36:37 +08:00
Jorge Guzman
a8e6021c6e system/kbd: add a keyboard dump that reads any keyboard
The hidkbd and keyboard examples do the same thing for one kind of
keyboard each:  hidkbd reads a USB HID keyboard as a byte stream, and
keyboard reads an upper half keyboard as events.  Neither works with the
other, so bringing up a new keyboard means picking the right example
first, and there is no answer for somebody whose keyboard is neither.

Every keyboard registered with keyboard_register() is read the same way,
so one tool covers them all:  USB HID, matrix, simulator, virtio, VNC.

The payload follows INPUT_KEYBOARD_BYTESTREAM rather than a switch of
its own.  An application has no business knowing what hardware is behind
the device, and a build cannot mix the two formats anyway.

The two examples stay for now.  They are what the in-tree configurations
still name, and removing them has to wait until those configurations
have been moved over.

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2026-08-02 18:36:37 +08:00
Marco Casaroli
37a1f0e068 audioutils/lame: pin the checkout and build its AVX-512 sources
The bundled encoder was checked out from lame's trunk with no revision, so
every build took whatever trunk happened to be at that moment.  lame's trunk
grows vector tiers over time, and each one adds sources that the two build
files have to name:  r6655 offered AVX2 to the vector routines on 2026-07-25,
and r6718 and r6720 added an AVX-512 tier on 2026-07-30.  The AVX-512 sources
were never listed, so sim:alsa stopped linking on x86 hosts:

  takehiro.c:332:    undefined reference to `quantize_lines_xrpow_avx512'
  takehiro.c:533:    undefined reference to `ix_max_avx512'
  takehiro.c:569:    undefined reference to `count_bit_esc_avx512'
  vbrquantize.c:261: undefined reference to `calc_sfb_noise_x34_avx512'

Pin the checkout to r6720 through a LAME_VERSION variable, as the rest of
apps/ pins its third-party sources, and list the three AVX-512 files that
revision provides.  The pin is what keeps the two in step:  the source list is
maintained by hand, so it can only be correct for a known revision.

The checkout is also only performed when lame/configure is absent and is never
updated afterwards, so before this an unpinned tree was frozen at whatever
trunk was on the day it was first built.  Anyone who checked out before
2026-07-30 still links and cannot reproduce the failure, which is why this
surfaced only in CI.

Makefile named just vector/xmm_quantize_sub.c and none of the other vector
sources, so a Make build on an x86 host fails the same way with a longer list
of symbols, from SSE2 upwards.  CI builds sim:alsa through CMake only, so that
half was latent rather than visible.  Both files now list the same nine
sources under the same host condition.

Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 19:44:51 -03:00
Marco Casaroli
20dc5e5167 testing/fs/xipfs: Cover the FDPIC module loader.
Adds two sections to the xipfs suite, guarded by CONFIG_FDPIC so a build
without the loader is unaffected.  They belong here rather than in their own
test because what they exercise is modules loaded *out of the filesystem* --
the pin, the in-place mapping and the loader are one path.

'fdpic' asserts on the loader properties that otherwise fail *quietly*: a
loader that skips DT_INIT_ARRAY runs a C++ module happily with every global
left zero, one that skips DT_JMPREL loads a module that hard-faults only
once it calls out, and one that mis-sizes the descriptor pool corrupts the
heap.  None of those announce themselves.  The module exit status is the
channel -- each module checks its own invariants and reports a bitmask.  It
also covers shared libraries across concurrent instances, per-instance data,
the leaf-library GOT fallback, the R_ARM_FUNCDESC descriptor pool, and every
firmware entry point that has to resolve a module callback, including
mq_notify and timer_create with SIGEV_THREAD.

'reject' mutates a known-good module byte by byte and asserts the loader
refuses it rather than loading something broken: a missing import, and more
DT_NEEDED entries than the walk will follow.

The modules are embedded as headers, for the same reason as in
examples/fdpicxip, and built for cortex-m3 for the same reason: one set of
blobs then runs on both the v7-M and v8-M targets.  Their sources and the
makefile that regenerates these headers live in
apps/examples/fdpicxip/modules, so the copies the two apps carry are built
from the same sources in the same way.

Verified on a Pimoroni Pico Plus 2: fdpic 33/33, reject 7/7, and the whole
suite 130/130 with them included.  The same three numbers on mps2-an500 under
QEMU, which is a Cortex-M7 rather than the RP2350's Cortex-M33.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-07-31 18:47:17 -03:00
Marco Casaroli
859c014d4d examples/fdpicxip: Demonstrate FDPIC modules executed in place.
The FDPIC counterpart of examples/nxflatxip, kept separate from it: that
example is about NXFLAT, and mixing the two module formats into one program
would leave neither demonstrating anything clearly.

Four subcommands, each showing one property of the loader.  'qsort' is the
simplest case it has -- one self-contained module, two concurrent instances,
one shared copy of the text in flash and a private copy of the data each,
with the pin count showing the extent held in place while they run and
released after.  'solib' adds a shared library, so two objects are mapped
and each instance still gets its own copy of both objects' data.  'cxx' is
the same in C++, which additionally requires global constructors to have run
in dependency order before main.  'jmprel' is a module whose imports are all
in DT_JMPREL rather than DT_REL.

The modules are embedded as headers rather than built as part of the app:
linking one needs arm-uclinuxfdpiceabi binutils, which the tree does not
require, so the headers are committed and both this example and
testing/fs/xipfs build with a plain toolchain.

Their sources are in modules/, with a makefile that rebuilds every header
from them on an explicit 'make regen NUTTX_DIR=...' and is never invoked by
the application build.  It drives nuttx/tools/fdpic and writes the headers
this example needs alongside the ones testing/fs/xipfs needs, so one source
tree serves both and the two cannot drift apart.  CPU is cortex-m3 there
deliberately: a v7-M module runs on the v8-M targets too, so one set of blobs
serves both the RP2350 and mps2-an500, while a cortex-m33 build produces
blobs the Cortex-M7 cannot execute at all.

This demonstrates; it does not assert.  The assertions are in the fdpic and
reject sections of apps/testing/fs/xipfs.

Verified on a Pimoroni Pico Plus 2: all four subcommands, and nxflatxip
unaffected alongside them.  Also verified on mps2-an500 under QEMU, which is
a Cortex-M7 -- a different core generation from the RP2350's Cortex-M33.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-07-31 18:47:17 -03:00
tuansuper
5f286fc924 flashtool: Fix compile error due to missing statement after default label
In flashtool_main.c, the 'default:' label in a switch statement was
followed directly by '}', which is invalid in C.
This commit adds a 'break;' statement after the default label to
resolve the error.

Signed-off-by: tuansuper <tunainnet@tutanota.com>
2026-07-31 10:32:58 -03:00
Marco Casaroli
2631d3e59a testing/ostest: build the perf test only where it can link
perf_gettime() and perf_getfreq() are kernel functions, defined in
sched/clock/clock_perf.c.  Neither appears in syscall.csv, and libc supplies
only perf_gettime(), under CONFIG_ARCH_HAVE_PERF_EVENTS_USER_ACCESS.  So a
protected or kernel build cannot resolve either of them from user space:

  ostest/perf_gettime.c:91:  undefined reference to `perf_gettime'
  ostest/perf_gettime.c:184: undefined reference to `perf_getfreq'
  make[1]: *** [nuttx_user.elf] Error 1

The call in user_main() is guarded by CONFIG_ARCH_PERF_EVENTS &&
!CONFIG_ARCH_PERF_EVENTS_USER_ACCESS -- which is exactly the case where the
symbols are kernel-only -- so every such configuration fails to link.
mps3-an547:knsh is one: it sets CONFIG_SCHED_IRQMONITOR, which makes
ARCH_PERF_EVENTS default y.  mps2-an521:knsh escapes only because it sets
neither monitor, leaving ARCH_PERF_EVENTS off, so the call compiles out and
the archive member is never pulled in.

Require CONFIG_BUILD_FLAT, where ostest links against the kernel's own copy.
No configuration that runs the test today stops running it.

Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 09:49:59 -03:00
Ricard Rosson
be43888aa5 netutils/mdns: raise responder stack size default to 8KiB
CONFIG_NETUTILS_MDNS_STACKSIZE defaulted to DEFAULT_TASK_STACKSIZE,
which resolves to as little as 2KiB on some targets.  The bundled
mjansson responder uses a deeper stack than that (DNS record parsing
with name decompression, plus the send/receive buffers) and overflows
on startup, taking the board down with a hardfault before it answers a
single query.

Default to 8KiB, the value that reliably runs the responder, and
correct the help text, which previously claimed a 4KiB default that did
not match DEFAULT_TASK_STACKSIZE.

Assisted-by: Claude (Anthropic Claude Code)
Signed-off-by: Ricard Rosson <ricard@groundbits.com>
2026-07-31 15:19:31 +08:00
Abhishek Mishra
fc14d02ae0 nshlib,fsutils: add Kconfig deps for NSH console login with PBKDF2
Require a cryptodev backend for FSUTILS_PASSWD and tie NSH console/telnet
login to ROMFS passwd generation when ETC_ROMFS is enabled.

Fixes #19573

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-07-31 10:20:23 +08:00
Abhishek Mishra
917e2e860b testing/ostest: create temp passwd file for multiuser test
Install a minimal passwd file at CONFIG_LIBC_PASSWD_FILEPATH before
getpwnam() checks so sim:ostest does not require a pre-built /etc/passwd.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-07-31 01:14:30 +08:00
Abhishek Mishra
484474bbbe testing/ostest: extend multiuser credential and IPC tests
Add getresuid/setreuid coverage plus ownership and permission checks
for message queues, named semaphores, shared memory, and FIFOs.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-07-31 01:14:30 +08:00
Abhishek Mishra
92c3b6446d nsh: show real, effective, and saved IDs in id command
Use getresuid() and getresgid() for Linux-style id output with name
resolution and a groups= list based on the effective GID.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-07-31 01:14:30 +08:00
Jorge Guzman
07c1234372 games/NXDoom: draw in the pixel format of the frame buffer
The blit assumed a 32-bit frame buffer:  it wrote a uint32_t per pixel
and converted the palette with ARGBTO32 as it went, so the image came
out wrong anywhere else.  It also drew at the origin, leaving the image
in a corner of a display it does not fill, and indexed the source by the
output column, which costs a division for every pixel of every frame.

Convert the palette once per palette change into the format the frame
buffer actually uses, map output columns to source columns through a
table built at startup, and centre the result.  Output rows that come
from the same source row are copied rather than converted again.

Four options are added, all off by default, so that a board can trade
memory for speed where it pays:

  GAMES_NXDOOM_FB_CMAP blits palette indices and lets a frame buffer
  that has a colour map do the conversion in hardware.

  GAMES_NXDOOM_FILLSCREEN stretches the image over the whole display
  rather than scaling it by a whole number.

  GAMES_NXDOOM_ROWSTAGE builds each row in a staging buffer so that the
  frame buffer only sees burst-friendly copies.

  GAMES_NXDOOM_STATIC_SCRNBUF places the render target in .bss, which
  keeps it out of external memory on a board whose heap is mostly that.

On an STM32H753 driving a 1024x600 panel from SDRAM, the last two are
worth 2.7x together.

Also open the frame buffer with O_CLOEXEC.

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2026-07-31 01:07:59 +08:00
Acfboy
6870186707 graphics/microwindows: fix missing HAVE_FNT_SUPPORT in Makefile
Without this Make variable, Objects.rules does not add font_fnt.o
to the build, causing undefined reference to fnt_createfont at link time.

Signed-off-by: Acfboy <AcfboyU@outlook.com>
2026-07-30 09:42:18 +02:00
Marco Casaroli
2492317f15 examples/nxflatxip: Run an NXFLAT module in place out of xipfs.
The point of a writable execute-in-place file system is that a module can
arrive after the firmware was built and still run without being copied into
RAM.  This demonstrates exactly that, end to end: it writes an NXFLAT module
into xipfs the way a download would, declaring the size up front so the
extent is exact, checks the file system can hand out a real flash pointer
for it, and runs two instances concurrently.

Both instances report the address of their own text and of their stack.  The
text address is the same in both and is inside the flash window -- it is the
address the file occupies on the media -- while the stacks differ.  While
they run, the extent carries one pin per instance, which is what stops the
defragmenter relocating code that is executing.

Two subcommands cover the file system rather than the module.  bench times a
bulk read out of the mapped flash before and after a write, which on the
RP2350 is the cost of whichever path the driver used to restore XIP.  defrag
fills the volume, deletes every other file until an allocation genuinely
cannot be satisfied, compacts, retries the same allocation, then verifies
every relocated file byte for byte and again after a remount, printing a
block map at each step.

The module has neither static data nor string constants, and reports through
a callback into the firmware instead of formatting its own output.  That is
not stylistic: the ldnxflat in circulation resolves the GOT entries for .bss
objects into the import table, and drops the addend when it resolves the
PC-relative references to .rodata, so a module using either quietly computes
wrong addresses.  The comment in module/xipmod.c records both.  The callback
also exercises the other direction of the interface, firmware code entered
with the module's data base still live in r10.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-07-28 16:47:49 +08:00
Marco Casaroli
3a03552c6a testing/fs/xipfs: Add a test suite for the xipfs file system.
Twelve sections, selected by name on the command line because the power loss
sweeps run for minutes while everything else runs in seconds.

The routine part covers the VFS paths, the write-once rules (reopen for
write, append, seek during write, truncate of a written file are all refused)
and both mmap variants: that a plain mapping lands inside the media window
with no heap growth, that MAP_XIP_STRICT fails with ENXIO rather than
copying, and that N mappings of one file produce N pins on one extent.

The rest is aimed at the two properties that are easy to get wrong and quiet
when they are:

Pin release.  A pin taken by one task and a task that dies with a mapping
still live both have to end with the extent movable again -- the second
without the task ever calling munmap, since a module that faults never will.
Both are checked by asking the defragmenter to move the extent afterwards.

Power-loss atomicity.  With CONFIG_FS_XIPFS_FAULT_INJECT the suite fails the
Nth flash operation, remounts, and checks the volume is consistent and every
file that had been committed is byte-for-byte intact.  It sweeps N across
create, unlink and defragmentation, and repeats the sweep with the failing
write torn -- a partial program rather than a clean refusal -- which is what
a real power loss mid-program leaves behind.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-07-28 16:47:49 +08:00
Marco Casaroli
b695ec057f system/xipfs: Add a command to compact a xipfs volume and report it.
xipfs has a defragmentation ioctl and no way to reach it from a shell.  The
only caller was a demo in examples/nxflatxip, which built its own block map
to show what compaction had done.

  xipfs [-n] [-t <ms>] [<mountpoint>]

-n surveys and reports without moving anything: where each file sits, a map
of the volume, and how much of the free space a single allocation can reach.
That last number is the one a caller facing -ENOSPC actually wants; at 0%
the largest possible file already fits however scattered the map looks.

The compaction is asked for through a descriptor for the mountpoint
directory, so no file inside the volume is open while it runs and a single
pass can reach every extent.

The walk descends into the directories xipfs synthesises from names, and
reports each file by its path relative to the mount, so a volume that uses
them is described in full rather than down to its first level.

Block totals come from statfs rather than XIPFSIOC_EXTENTINFO, because that
one does name a file and an empty volume has none, yet its geometry is still
worth reporting.

Assisted-by: Claude Code:claude-opus-4-8
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-07-28 16:47:49 +08:00
Acfboy
ce49ac9053 examples/microwindows: add mwdemo demo application
This ports mwdemo.c from Microwindows as a standalone NuttX example
application.  mwdemo is the primary Win32 API demo in the Microwindows
project, featuring 3D graphics, window controls, timer-driven
animation, and bitmap image rendering.

The demo runs on both qemu-intel64:mw and sim:mw configurations.

Signed-off-by: Acfboy <AcfboyU@outlook.com>

examples/microwindows: address review, clean up mwdemo.

- Replace minimal copyright notice with full Apache 2.0 license header
- Use angle brackets for system and microwindows includes
- Remove OS-specific dead code (DOS_TURBOC, RTEMS, EMSCRIPTEN/MULTIAPP)
- Drop unused demo-mode macros and their corresponding dead code paths
  (IMAGE, CLIENT3D, CLIPDEMO, ARCDEMO).  Keep a fixed GRAPH3D+CONTROLS
  configuration as the single NuttX demo.
- Add g_ prefix to global variable (image -> g_image)
- Move demoWndData typedef from mid-file to Private Types section
- Merge WinMain body into main() and remove the WinMain indirection
- Removed unused images.

Signed-off-by: Acfboy <AcfboyU@outlook.com>
2026-07-28 09:53:05 +02:00
Acfboy
ae601e2892 graphics/microwindows: introduce Microwindows graphics support to NuttX
This commit integrates the Microwindows core into the NuttX apps
build system:

- Downloads a pinned upstream commit during build and compiles the
  engine, drivers and precompiled bitmap fonts via Microwindows'
  Objects.rules files.
- Adds Kconfig options for framebuffer path, keyboard driver
  selection (event-mode, raw byte-stream, none, custom), and
  mouse/touchscreen driver selection (relative, touchscreen, none,
  custom).
- Uses the MWCONFIG_FILE mechanism to inject NuttX-specific
  configuration (mwconfig.nuttx) without modifying upstream headers.
- The NuttX screen, keyboard, mouse and touchscreen drivers are
  pulled from upstream Microwindows. Driver selection is controlled
  via ARCH=NUTTX and Kconfig-driven KEYBOARD/MOUSE variables in
  the Makefile.
- Depends on VIDEO_FB for the framebuffer device.
- Builds the mwin library (Win32 API layer) when MICROWINDOWS_MWIN
  is enabled.

Co-authored-by: Pavel Pisa <ppisa@pikron.com>
Signed-off-by: Pavel Pisa <ppisa@pikron.com>
Signed-off-by: Acfboy <AcfboyU@outlook.com>
2026-07-28 09:53:05 +02:00
Filipe Cavalcanti
636047a4e0 examples/fb: add SMPTE color bar example
Add a -p option to select the pattern to draw. The existing expanding
rectangles animation remains the default, and a new "smpte" pattern
fills the display with seven equal vertical bars (white, yellow, cyan,
green, magenta, red and blue), which is useful to verify color ordering
and channel wiring of a framebuffer display.

To support more than one palette, the draw_rect() helpers now receive
the color value to write instead of an index into the per-format color
tables. Monochrome displays pick black or white per bar using a BT.601
luma threshold.

The FBIO_UPDATE ioctl is moved out of draw_rect() into a new
present_area() helper, so the SMPTE pattern can draw every bar and
then update the display only once.

Assisted-by: Cursor:claude-opus-5
Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2026-07-28 10:46:12 +08:00
dependabot[bot]
61161866f0 build(deps): bump docker/login-action from 4.4.0 to 4.5.1
Bumps [docker/login-action](https://github.com/docker/login-action) from 4.4.0 to 4.5.1.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](af1e73f918...abd2ef45e7)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 4.5.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-28 10:46:03 +08:00
Matteo Golin
b42589e8e7 games/NXDoom: Fix warnings in i_pcsound module
This fixes all the warnings in the i_pcsound module caused when enabling
the sound feature Kconfig option. This warnings would prevent CI from
passing.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-07-27 13:24:25 -03:00
Matteo Golin
a5c0e9c188 apps/games/NXDoom: Add support for RTTTL DOOM theme
Implements and RTTTL player music module to play the DOOM theme song
over RTTTL.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-07-27 13:24:25 -03:00
Marco Casaroli
57e761f724 build: Omit default priority ELF symbol.
Do not define nx_priority for applications that use SCHED_PRIORITY_DEFAULT. The ELF loader already uses its scheduler default when the symbol is absent, avoiding the invalid priority-zero value previously encoded by Application.mk.

Keep emitting nx_priority, and retaining it through stripping, for explicit numeric priorities.

Assisted-by: Zed:GPT-5.6 Terra
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-07-27 12:19:41 -03:00
Junbo Zheng
fabafbc361 nshlib: add relative image path support in boot command
cmd_boot passed the image path straight to boardctl(), which resolves
it in a context that does not inherit the NSH shell cwd, so relative
paths failed and only absolute paths worked. Use nsh_getfullpath() to
resolve relative paths against the cwd before calling boardctl().

Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
2026-07-27 09:38:34 -03:00
Alan Carvalho de Assis
8d5e9f3754 system/readline: Fix small issues
This PR fixes some small issues raised by Xiang Xiao.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-07-26 18:46:45 -03:00
aviralgarg05
f2ceac78db examples/sotest: support packaged shared library fixtures.
Extend the examples/sotest packaging path so the shared-library test
fixtures can also be prepared through nxpkg-style package artifacts.

Generate shared-index.json and pkgsotest.nsh from the built modprint
and sotest shared objects, recording the correct target arch/compat
metadata and SHA-256 digests for the packaged shared-library fixtures.
Allow sotest to run in either its existing builtin-ROMFS flow or from
explicit shared-library paths, with a --mount helper mode for
preparing the builtin test mount separately. Keep the paired fixture
outputs in one grouped make step so parallel builds do not re-enter
the generator independently.

This makes the sotest shared-library example usable as a
package-style fixture producer for the Dynamic ELF/nxpkg series,
useful for validating the shared-library side of the packaging flow
where the loader should consume installed artifacts rather than only
the default builtin test paths. The existing builtin-ROMFS path is
preserved with no regression to the normal sotest example flow.

Assisted-by: Claude:claude-sonnet-5
Assisted-by: OpenAI Codex:gpt-5.6-sol
Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-07-26 20:54:58 +08:00
Marco Casaroli
3ecd036f8f audioutils/lame: Add CMake vector sources.
Add the SSE2 and AVX2 vector implementation files to the CMake libmp3lame target for x86 simulator hosts. LAME's enabled runtime dispatch paths call these functions, so omitting them leaves sim:alsa with unresolved symbols at link time.

Non-x86 simulator hosts continue to use LAME's scalar implementation.

Assisted-by: Zed:GPT-5.6 Terra
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-07-26 08:33:06 -03:00
Felipe Moura
355d090d83 netutils/dropbear: back chacha20-poly1305 with NuttX /dev/crypto
Replace the bundled libtomcrypt chacha20-poly1305 implementation with an
adapter that drives the NuttX crypto device: the SSH construction maps onto
CRYPTO_CHACHA20_DJB (the original 64-bit counter/nonce ChaCha20
parameterization used by chacha20-poly1305@openssh.com) for the packet
length and payload streams, and onto CRYPTO_POLY1305 for the authentication
tag (plain MACs are driven in two steps through /dev/crypto: COP_FLAG_UPDATE
feeds the data, a final call retrieves the tag).

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
2026-07-26 07:54:11 -03:00
Junbo Zheng
101b713be6 nshlib: add du command support
Add a du command to NSH that recursively summarizes the size of each
path argument in 1K-blocks, or human-readable form with -h.

Supports -s (summary only), -a (all files), -d N (max-depth), and -h,
matching GNU du semantics.

Testing:

Built and ran on sim:nsh with:
```bash
  cmake -B out/nuttx_sim_nsh -S nuttx -DBOARD_CONFIG=sim:nsh -GNinja
  ninja -C out/nuttx_sim_nsh
  ./out/nuttx_sim_nsh/nuttx

  nsh> du
  397449  /data/test/elf
  71993   /data/test/coredump
  5       /data/test/log2
  3251    /data/test/log1
  472700  /data/test

  nsh> du -h
  388.1M  /data/test/elf
  70.3M   /data/test/coredump
  4.1K    /data/test/log2
  3.1M    /data/test/log1
  461.6M  /data/test
```

Host Ubuntu22.04 du on the same directory:
```bash
  $ du
  397456  ./elf
  72000   ./coredump
  8       ./log2
  3252    ./log1
  472720  .

  $ du -h
  389M  ./elf
  71M   ./coredump
  8.0K  ./log2
  3.2M  ./log1
  462M  .
```

Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
2026-07-26 07:39:39 -03:00
aviralgarg05
6ca1272b99 examples/elf: extend nxpkg validation coverage.
Extend the examples/elf ROMFS path so nxpkg validation can use
generated package fixtures instead of hand-managed metadata.

Generate index.json, bad-index.json, pkgtest.nsh, and pkgfail.nsh
from the built hello ELF, recording the correct target arch/compat
metadata and SHA-256 digest for the valid fixture. Keep mismatched-
target and missing-artifact cases alongside the valid fixture so
nxpkg target selection and failure handling can be exercised from
the same example tree. Group the paired fixture outputs in one make
step so parallel builds do not re-enter the generator independently.

This keeps the fixture metadata tied to the actual built hello
artifact instead of relying on manually maintained hashes or ad hoc
shell setup, making follow-up review and later test reruns more
predictable. There is no intended loader or board-behavior change;
this is limited to fixture generation inside examples/elf.

Assisted-by: Claude:claude-sonnet-5
Assisted-by: OpenAI Codex:gpt-5.6-sol
Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-07-25 12:06:28 -03:00
Felipe Moura
690ec808e5 netutils/dropbear: back hmac-sha2-256 with NuttX /dev/crypto
Replace the bundled libtomcrypt HMAC modules with an adapter that computes the hmac-sha2-256 packet MAC through the NuttX crypto device using CRYPTO_SHA2_256_HMAC sessions.

Require CRYPTO, CRYPTO_RANDOM_POOL, CRYPTO_CRYPTODEV and CRYPTO_CRYPTODEV_SOFTWARE_CRYPTO explicitly instead of selecting crypto support.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
2026-07-24 18:34:35 -03:00
Alan C. Assis
ae237624ee readline: Improve robustness of editing and escape-sequence handling
Replace fragile cursor compensation with full-line redraws where needed,
fix Ctrl+W buffer/screen corruption, properly consume unrecognized CSI
sequences, and always clean up leaked local-echo characters from buggy
serial drivers. These changes make line editing consistent across
terminals while preserving existing behavior.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Code (Sonnet 5)
2026-07-24 14:12:38 -03:00
Alan C. Assis
48eb95998b readline: Make prompt-caching available
readline cached the current prompt only when TAB completion was enabled,
even though line-editing redraws also depend on that cached prompt.
With TAB completion disabled, full-line redraws erased the prompt and
repainted only the command buffer. Make the prompt cache available
whenever line editing is enabled.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-07-24 14:12:38 -03:00
Alan C. Assis
893f0c31ee readline: remove 5x duplicated in redraw code
The original readline_common.c file had some duplicated code that was
causing the nsh to be more than 1KB bigger. This clean up will allow
adding line editing without increasing the final firmware size too much.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Code
2026-07-24 14:12:38 -03:00
Alan C. Assis
51bfd48e78 system/readline: Add support for line movements and editing
This commit adds support to nsh> command line editing. This is one
of the most missing feature of the NuttShell. If you typed a long
command line and make a mistake you need to press Backspace and
remove everything until reach that typo. Only the basic editing
feature is enabled by default (left/right keys movement, Home/End
to move to the beginning or ending of the command line).

More advanced features are available when CONFIG_READLINE_EDIT_EMACS
is selected. It enables the Emacs-style control keys (Ctrl+A/B/D/E/F/K/U/W)
that allow more flexible line editing.

Other more advanced feature is enabled when CONFIG_READLINE_CMD_HISTORY
and CONFIG_READLINE_EDIT_EMACS_REVERSE_SEARCH are enabled. It allows the
user to press Ctrl+R to do reverse search in the command line history.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Code
2026-07-24 14:12:38 -03:00
Alan C. Assis
0304721c85 readline: Don't assert on a zero-length RL_WRITE
Then readline_write() was called with buflen == 0 it was causing a
debug assertion. Now it returns early for instead of asserting.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-07-24 14:12:38 -03:00
Carlos Sánchez de La Lama
094b988be3 interpreters: add Tcl support
Tcl is added using The Jim Interpreter. Jim is an opensource small-footprint
implementation of the Tcl programming language. It implements a large subset
of Tcl and adds new features like references with garbage collection,
closures, built-in Object Oriented Programming system, Functional Programming
commands, first-class arrays and UTF-8 support.

Signed-off-by: Carlos Sánchez de La Lama <csanchezdll@gmail.com>
2026-07-24 17:15:49 +08:00
wangjianyu3
86afa6d182 netutils/rexecd: forward PRIORITY/STACKSIZE config in CMake build
The Makefile build already forwards both values via PRIORITY /
STACKSIZE.  Align the CMake build with the Makefile so that
CONFIG_NETUTILS_REXECD_PRIORITY and CONFIG_NETUTILS_REXECD_STACKSIZE
take effect under CMake as well.

Assisted-by: GitHubCopilot:claude-4.8-opus
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-07-23 17:18:08 -03:00
Matteo Golin
d273af4834 applications/audioutils/morsey: Update Morsey version
Use newer version without compile time warnings that prevent CI from
building.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-07-23 09:31:29 +02:00
Abhishek Mishra
e751331ecb ci: fix sim/login ROMFS passwd credential for promptpasswd.sh
NUTTX_ROMFS_PASSWD_PASSWORD lacked a special character, so nuttx's
promptpasswd.sh rejects it and headless CI builds fail at etctmp.c when
sim/login is built.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-07-22 17:21:22 +08:00
Abhishek Mishra
c02683e282 !nshlib: Remove fixed login; require FSUTILS_PASSWD
Report password policy failures clearly from useradd and passwd when a
password does not meet complexity requirements.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-07-22 17:21:22 +08:00
Abhishek Mishra
608f13fd4b !fsutils/passwd: Replace TEA with PBKDF2-HMAC-SHA256
Migrate passwd encrypt/verify to PBKDF2 modular crypt format using
kernel cryptodev (CRYPTO_PBKDF2_HMAC_SHA256 via /dev/crypto).  Add
passwd_pbkdf2 wrapper, base64url helpers, complexity validation, and
pbkdf2_test for RFC 6070 vector coverage.  FSUTILS_PASSWD selects
CRYPTO, ALLOW_BSD_COMPONENTS, and CRYPTO_CRYPTODEV so existing sim
defconfigs keep building.  Change NSH_LOGIN_USERNAME default to root and
remove fixed-login password defaults.

BREAKING CHANGE: TEA-encoded /etc/passwd entries no longer verify.
Regenerate each entry after upgrading.  Pair with the nuttx host mkpasswd
changes in apache/nuttx#19209.  Boards must enable the appropriate
software or hardware crypto backend for PBKDF2 at runtime.  When
CONFIG_NSH_LOGIN_FIXED=y, set CONFIG_NSH_LOGIN_PASSWORD in the board
defconfig or menuconfig; there is no default password.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-07-22 17:21:22 +08:00
hanzhijian
01c6a60581 testing/drivers: add watchdog notifier cmocka coverage
Extend the watchdog drivertest with notifier ordering, duplicate registration, repeated delivery, unregister, NULL-data, and concurrent registration coverage.

Register the watchdog test when either reset-cause or timeout-notifier support is available. Keep hardware watchdog cases gated by reset-cause support and allow notifier-only simulator builds through both Make and CMake.

Keep test state in the watchdog fixture and notifier blocks so callbacks do not depend on shared notifier state.

Assisted-by: OpenAI Codex
Signed-off-by: hanzhijian <hanzhijian@zepp.com>
2026-07-21 15:37:01 -03:00
anjiahao
067b0ccf28 Application.mk:define application attribute in elf symbol
Emit --defsym for nx_stacksize, nx_priority (and nx_uid/nx_gid/nx_mode
under CONFIG_SCHED_USER_IDENTITY) into MODLDFLAGS so the ELF binary
loader can recover the application's configured attributes at load time.

Also skip builtin registration for separately-built module ELFs
(BUILD_MODULE instead of DYNLIB).

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-07-21 05:47:25 -03:00
dependabot[bot]
593bfca047 build(deps): bump actions/setup-python from 6 to 7
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 6 to 7.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-21 16:47:02 +08:00
Matteo Golin
c814059f6c examples/txmorse: Example application for transmitting Morse code
Adds an example application leveraging the Morsey library for
transmitting Morse code, either to the console (debug) or to GPIO
devices for now as the two supported sinks.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-07-21 05:46:11 -03:00
Matteo Golin
4d3bb6e7c9 audioutils/morsey: Add the Morsey library
This commit adds the Morsey library (Apache 2.0 licensed) to be
downloaded from an external repository so it can be used in NuttX
applications.

This library parses ASCII text into Morse code marks to be played by a
user-implemented 'transmit' function (i.e. over an LED, buzzer, audio
sink, etc.).

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-07-21 05:46:11 -03:00
Abhishek Mishra
1e490d3fbe dropbear: rename libtomcrypt symbols to avoid NuttX collisions
Rename base64_encode, base64_decode, and ecc_make_key in bundled
libtomcrypt to avoid duplicate symbol link errors when dropbear is built
alongside netutils/codecs and NuttX crypto (e.g. sim:dropbear).

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-07-20 12:45:48 -04:00
Jorge Guzman
865393d419 system/curl: add a small curl-like HTTP client command
Add the "curl" NSH command: a command-line HTTP client built on top of
the netutils webclient library. It implements a subset of the real curl
options: GET and POST (and other methods via -X), custom request headers
(-H), a raw request body (-d, including -d @file), multipart/form-data
file uploads (-F name=@file), saving the response body to a file (-o)
and verbose output (-v). HTTP only (no HTTPS).

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2026-07-20 10:21:57 +02:00
Ansh Rai
98f683dea8 apps: Sanitize PROGNAME for _main symbol generation
Program names containing '-' (e.g. renaming hello to hello-world via
PROGNAME) previously generated an invalid identifier <PROGNAME>_main
when constructing internal entry-point symbols. This caused build
failures for C/C++ applications due to invalid identifiers in compiler
definitions and generated builtin_proto.h.

Introduce PROGSYM, a sanitized copy of PROGNAME with '-' replaced by
'_', and use it wherever an internal C/Zig identifier is constructed
(the -Dmain= defines, the Zig RENAMEMAIN rule, and the REGISTER
call's entry-point argument). Preserve the original PROGNAME for the
registered NSH command name and builtin registry entry, where hyphens
are valid and expected.

The Zig RENAMEMAIN path is also updated to use PROGSYM for consistency.
The current hello_zig and leds_zig examples do not exercise this path,
since neither uses a literal 'fn main' entry point, but the change
keeps symbol generation consistent for future Zig applications.

Testing (WSL2 Ubuntu, x86_64, sim:nsh):
- CONFIG_EXAMPLES_HELLO_PROGNAME="hello-world": clean build,
  'hello-world' runs and prints 'Hello, World!!'
- Reverted to default PROGNAME="hello": clean build, no regression
- Confirmed by inspection that RENAMEMAIN's sed substitution does not
  fire on either current .zig source (generated _tmp.zig is
  byte-identical to the source)

Fixes #19447

Signed-off-by: Ansh Rai <anshrai331@gmail.com>
2026-07-20 10:21:26 +02:00
Felipe Moura
7469e88bfa netutils/dropbear: retain child exit status for NSH PTY session
The per-session NSH task is reaped with waitpid() in
dropbear_nshsession.c.  Without CONFIG_SCHED_CHILD_STATUS the kernel does
not retain the child exit status, so waitpid() returns ECHILD right after
authentication and the interactive session never starts
("NSH session wait failed: Unknown error 10").

Depend on SCHED_HAVE_PARENT and SCHED_CHILD_STATUS (following the project's
depends-on-over-select convention) so the requirement is explicit; boards
enabling Dropbear must set these in their defconfig.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
2026-07-20 10:04:50 +02:00
Matteo Golin
5114ddd6c0 examples/baromonitor: New LVGL example which integrates with barometer
This example is an LVGL application which reads pressure and temperature
data from a barometer and displays it on gauges. It is intended to
provide an idea of what LVGL on NuttX can practically be used for in an
application.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-07-20 09:40:04 +08:00
Filipe Cavalcanti
09682dad05 interpreters/python: support build without network
Adds options to support building when CONFIG_NET is not set.
This allows building Python for boards that do not have networking support.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2026-07-17 08:37:30 +08:00
Old-Ding
62d04ed484 system: fastboot: bound filedump path parsing
Parse the filedump path token into the existing PATH_MAX-sized buffer
before reading the optional offset and size arguments. This bounds the
write without constructing a scanf format string at runtime.

Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
2026-07-16 15:59:21 +08:00
raiden00pl
eceb30e59c codespell: ignore ANS error
ignore ANS codespell error. ANS -> Alert Notification Service in bLE

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-07-15 08:40:55 +02:00
raiden00pl
f5b2c354ca wireless/bluetooth/nimble: make transport ACL buffer count configurable
The controller<->host ACL pool was hardcoded to 10 buffers (~6 KiB with
the 251-byte ACL size). Expose NIMBLE_TRANSPORT_ACL_FROM_LL_COUNT and
NIMBLE_TRANSPORT_ACL_FROM_HS_COUNT (default 10) so RAM-constrained
single-connection peripherals can lower it.

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-07-15 08:40:55 +02:00
Old-Ding
850f481344 examples: fix local socket address lengths
The configured path size already includes its NUL terminator. Adding
another byte made the maximum address length exceed sockaddr_un, while
ustream could write at sun_path[UNIX_PATH_MAX].

Use the existing bounded copy length directly as the path portion of
the socket address and rely on strlcpy for termination.

Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
2026-07-13 12:28:07 +02:00
Matteo Golin
b39228cd41 !examples/audio_rtttl: Implement example using RTTTL library
This commit fixes the audio_rtttl example (which was undocumented and
previously used kernel-level functions) such that now it uses the RTTTL
parsing library. Contributors can implement 'players' for different
types of audio sinks. Currently, PWM is supported.

BREAKING: The previous version of this example only supported a single
board (Spresense) and uses public interfaces from the kernel code. Now
it only uses user-space interfaces and supports any board implementing
those interfaces. Users who relied on the old behaviour should submit a
patch to add a new player to this application which uses the desired
audio sink for the Spresense through user-space interfaces.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-07-13 10:02:37 +08:00
Mihai Pacuraru
3762a64bc6 examples/mqttc: add a subscriber client implementation example
Implement the subscriber client that optionally integrates
    the TLS layer and can reconnect to the broker if the
    application is running in unstable network environments.

    The client is compliant with all 3 levels of QoS.

Signed-off-by: Mihai Pacuraru <mpacuraru@protonmail.com>
2026-07-13 10:02:05 +08:00
Felipe Moura
9b540556a1 netutils/dropbear: don't require a hardware TRNG
Dropbear gathers its entropy from /dev/urandom (libtomcrypt's
rng_get_bytes tries /dev/urandom before /dev/random), so requiring
ARCH_HAVE_RNG and DEV_RANDOM shuts the port out of targets without a
hardware TRNG -- including the simulator, where a dropbear
configuration silently loses NETUTILS_DROPBEAR at configure time.
Keep only the DEV_URANDOM requirement.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
2026-07-12 15:56:25 -03:00
Jorge Guzman
62b7e95530 nshlib: top: add Linux-like summary and flicker-free refresh
Print a summary header before the task list in the style of the
Linux top command: uptime, task counts (total/running/sleeping),
CPU busy/idle and memory usage, all gathered via sysinfo().

Refresh the screen in place (cursor home + erase-line per row +
erase-below) instead of clearing the whole screen every cycle,
which removes the flicker.

Poll stdin during the update interval and exit on 'q', ESC or
Ctrl-C. Previously the only exit path was the SIGINT handler,
which requires both CONFIG_ENABLE_ALL_SIGNALS (handler) and
CONFIG_TTY_SIGINT (serial console converts Ctrl-C into SIGINT,
default n); on configurations missing either option top could
not be terminated at all.

Tested on linum-stm32h753bi:nsh.

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2026-07-12 10:00:40 +08:00
Old-Ding
1d5f816874 system: audio: parse command filenames with PATH_MAX
Parse command filename tokens into PATH_MAX-sized buffers before
reading optional raw audio parameters. This bounds nxplayer and
nxrecorder input without runtime-built scanf formats.

Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
2026-07-11 12:40:07 -03:00
liang.huang
2bcc6b96ea testing/sched: fix off-by-one sample count in timerjitter
cur_cnt++ in the loop condition increments even when the loop body
doesn't run, so avg is divided by one more sample than was collected.

Signed-off-by: liang.huang <liang.huang@houmo.ai>
2026-07-11 12:31:24 -03:00
Abhishek Mishra
1d15c81f69 ci: supply sim/login ROMFS passwd credential in build jobs
NuttX master now requires CONFIG_BOARD_ETC_ROMFS_PASSWD_PASSWORD for
sim/login builds. The nuttx-apps workflow mirrors nuttx CI but never
exported NUTTX_ROMFS_PASSWD_PASSWORD, so Linux sim-02 and macOS sim
jobs failed inside the Docker build container.

Set the documented test credential at the job and step level and
export it explicitly before cibuild.sh runs.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-07-11 07:31:04 -03:00
Peter Barada
27c466a429 crypto: Fix CRC-32 test case 8
Normal Crypto API usage is to call ioctl(CGCGSESSION) to initialize
the session, then one (or more) calls to ioctl(CIOCCRYPT) with flag
bit COP_FLAG_UPDATE set to append to the hash/xform calculation, then
a call to ioctl(CIOCCRYPT) with flag bit COP_FLAG_UPDATE cleared to
extract the result, and finally ioctl(CIOCFSESSION) to finish the
session. This follows the classic init / update* / finish data
processing model.

However crc32.c test case 8 precedes ioctl(CIOCCRYPT) with
COP_FLAG_UPDATE set with ioctl(CIOCGSESSION) and follows it with
ioctl(CIOCCRYPT) with COP_FLAG_UPDATE cleared to extract the CRC, and
then ioctl(CIOCFSESSION) to finish the session, all _within_ the loop
to CRC eight segments.  This works with the software implementation
since the intermediate CRC-32 is carried forward out of one session to
seed the next session. Fix by moving the init and finish portions out
of the loop in test case 8.

Signed-off-by: Peter Barada <peter.barada@gmail.com>
2026-07-10 13:02:44 +08:00
orbisai0security
d071a0b585 fix: V-001 security vulnerability
Automated security fix generated by OrbisAI Security

Signed-off-by: OrbisAI Security <mediratta01.pally@gmail.com>
2026-07-10 13:01:42 +08:00
raiden00pl
33b528a0de lte/lapi: fix warnings
fix warnings lte/lapi on sim:

   warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-07-09 13:57:49 +02:00
Alan Carvalho de Assis
707b24e5cb system/ping: Fix a segmentation fault when using ping
nsh> ping google.com
[   37.180000] dns_query_error: ERROR: IPv4 dns_recv_response fa: -84,
               server address: 8.8.8.8
Segmentation fault.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-07-09 09:42:30 +08:00
Old-Ding
0566af556a examples: lp503x: Fix command argument handling
The lp503x shell command handlers receive the remaining input string as their argument. Treat empty colour arguments as the query case, document that query form in help text, and keep colour and brightness values signed until the existing range checks have run so invalid values are not silently truncated.

Guard the readline_stream() result before using it as a buffer index. readline_stream() returns EOF on end of file or failure, and writing buffer[len] before checking len can write before the stack buffer.

Use MAX_BRIGHTNESS consistently for brightness range checks.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
2026-07-09 09:41:15 +08:00
Old-Ding
17b028e592 examples: wgetjson: check allocations before use
Several malloc() results in the wgetjson example were used before checking for allocation failure, which could crash low-memory paths before cleanup ran.

Return or propagate allocation errors before using the allocated buffers. Use explicit NULL comparisons for the new pointer checks to match review feedback.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
2026-07-09 09:35:19 +08:00
Old-Ding
7fa0767e30 examples: nrf24l01_term: reserve RX terminator
read_pkt() terminates the received payload with buff[ret], but a full-size read can leave no room for that trailing NUL byte.

Limit the read length to one byte less than the buffer size so the received payload remains safely terminated before it is printed.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
2026-07-09 09:30:49 +08:00
Old-Ding
fd525988f8 netutils: smtp: treat recv EOF as an error
recv() returns zero when the peer closes the TCP connection cleanly. The SMTP response path only treated negative returns as errors, so EOF could leave stale or empty response data to be checked as if a server reply had arrived.

Return ERROR on zero-length receives at each SMTP response point and keep the SPDX copyright header within the project line length limit.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
2026-07-09 09:29:57 +08:00
Old-Ding
13f04f65b1 examples: nrf24l01_btle: Fix RX terminator bounds
nrf24_read() reads up to the nRF24L01 maximum payload length and then appends a NUL terminator for the receive buffer. A full 32-byte payload can therefore write one byte past the local rbuf[32].

Reserve one extra byte for the terminator while keeping the read length capped at NRF24L01_MAX_PAYLOAD_LEN. Dump the number of bytes actually received in the debug path.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
2026-07-09 09:28:21 +08:00
Old-Ding
5226be524c system/vncviewer: Drain truncated desktop names
The RFB ServerInit message carries the desktop name as a length-prefixed field. vncviewer caps the copied name to fit conn->name, but it must still consume the remaining bytes from the socket when the advertised name is longer than the local buffer.

Drain the unused suffix so the next RFB message is read from the correct boundary. Reuse the same discard helper for other skipped RFB payloads.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
2026-07-09 09:28:13 +08:00
Old-Ding
54905cd0ff examples: xmlrpc: bound header value copy
xmlrpc_handler() stores HTTP header values in a CONFIG_XMLRPC_STRINGSIZE + 1 byte buffer, but it passed CONFIG_EXAMPLES_XMLRPC_BUFFERSIZE to xmlrpc_getheader(). With the defaults, that allows a 1024 byte copy into a 65 byte destination.

Make xmlrpc_getheader() treat size as the destination capacity, reserve one byte for the terminator, and pass sizeof(value) from the caller.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
2026-07-09 09:27:44 +08:00
Old-Ding
662133eeca testing: nettest: Fix TCP server terminator bounds
The TCP nettest server receives up to TEST_BUFFER_SIZE bytes and then appends a NUL terminator before checking for the exit command. A full-size receive can therefore write one byte past the receive buffer.

Reserve one extra byte for the terminator while keeping the recv() limit and echo length capped at TEST_BUFFER_SIZE.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
2026-07-09 09:27:28 +08:00
Old-Ding
50ffee7a85 examples: Fix network echo receive terminators
The netloop and poll TCP echo examples receive up to IOBUFFER_SIZE bytes and then append a NUL terminator before logging the data. A full-size receive can therefore write one byte past the input buffer.

Reserve one extra byte in the buffers that are terminated after recv(). Keep the receive limit and echo length capped at IOBUFFER_SIZE so the data path is unchanged.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
2026-07-09 09:27:18 +08:00
Old-Ding
3dc9bd4598 README: Fix application directory wording.
Fix two wording issues in the apps README.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
2026-07-09 09:26:16 +08:00
hanzhijian
81accb0832 apps: fix distclean for partial builds and residual .kconfig files
The current distclean implementation has two issues:

1. Application.mk does not remove .kconfig on distclean, so stale
   config fragments from earlier builds can pollute subsequent ones.

2. Several external-library Makefiles (lame, libshvc, libulut) run
   "make -C <subdir> distclean" without checking whether the
   subdirectory exists.  When the library was never downloaded (common
   in CI partial-build environments), distclean fails with "No such
   file or directory".

Fix:

- Application.mk: add $(call DELFILE, .kconfig) to the distclean
  target so that .kconfig is cleaned along with .built, .depend, etc.

- audioutils/lame/Makefile: guard the distclean recipe with
  "if [ -d $(DST_PATH) ]; then ...; fi" and use $(MAKE) instead
  of bare make.

- netutils/libshvc/Makefile, netutils/libulut/Makefile: same
  directory-existence guard for their distclean recipes.

- crypto/wolfssl/Makefile: change "distclean:" to "distclean::"
  (double-colon) so it does not override the distclean:: rule
  inherited from Application.mk.

Signed-off-by: hanzhijian <hanzhijian@zepp.com>
2026-07-09 09:25:33 +08:00
raiden00pl
cb7097a4e7 interial: fix SPDX License Identifier
licence is Apache-2.0, not BSD

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-07-09 02:08:43 +02:00
raiden00pl
dd109a88de inertial/madgwick: add CMake build support
add CMake build support for madgwick and update inertial/madgwick/.gitignore

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-07-09 02:08:43 +02:00
Matteo Golin
26c5dd8305 games/NXDoom: Use dirent for glob implementation
NuttX has dirent, so the glob implementation can be used. This removes
the warning for no native glob implementation.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-07-09 01:51:54 +02:00
Matteo Golin
3f04a28cbd games/NXDoom: Add LIBC_LOCALE dependency
The locale functions of libc are necessary for some parts of NXDoom.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-07-09 01:51:54 +02:00
Jorge Guzman
dd24407c71 examples/lvglterm: add USB HID keyboard input with cursor scrolling
Rework the terminal input selection into an explicit three-way Kconfig
choice so the format each keyboard delivers is picked up front:

  - On-screen keyboard (touch) - default, unchanged behaviour.
  - Matrix / upper-half keyboard - reads struct keyboard_event_s events
    (for example the M5Stack Cardputer matrix on /dev/kbd0).
  - USB HID keyboard - reads a byte stream (for example /dev/kbda with
    CONFIG_USBHOST_HIDKBD).

The physical-keyboard variant now polls the device non-blocking from the
LVGL thread (no dedicated task), mirroring the touch variant.  The USB
path decodes the stream with the keyboard codec, so with a driver built
for CONFIG_HIDKBD_ENCODED the Up/Down cursor keys scroll the terminal;
a plain-ASCII stream still works as ordinary key presses.

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2026-07-07 09:52:42 +08:00
dependabot[bot]
5971d9c19f build(deps): bump docker/login-action from 4.2.0 to 4.4.0
Bumps [docker/login-action](https://github.com/docker/login-action) from 4.2.0 to 4.4.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](650006c6eb...af1e73f918)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 4.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-07 09:48:55 +08:00
Old-Ding
64f9e8a4b7 system: nxinit: bound debug argv dump
Check the service argv array bound before reading the current entry in the debug dump loop. A full argument array may not have an in-array NULL terminator, so the old condition could read one entry past the array while CONFIG_SYSTEM_NXINIT_DEBUG is enabled.

Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
2026-07-07 09:47:23 +08:00
raiden00pl
c785d40af7 examples: add Lely CANopen slave example
add Lely CANopen slave example

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-07-06 11:02:13 -03:00
raiden00pl
962d90bb6e examples: add Lely CANopen master example
add Lely CANopen master example

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-07-06 11:02:13 -03:00
Alan Carvalho de Assis
caa7d7faa5 apps/nsh: Don't disable error by default
NSH error shouldn't be disabled by default, even when in SMALL
Memory because it will make difficult to discover why things are
not working. It should be disabled manually by experienced dev.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-07-06 09:13:02 -03:00
raiden00pl
c706dd87a7 canutils/lely: fix unreliable download/unpack/patch logic
Rebuild from a clean tree in one recipe so a stale state no longer breaks the build.

This commit also simplify some build logic.

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-07-06 20:04:57 +08:00
Old-Ding
e94e89113a examples: gps: bound NMEA line reads
The GPS example appends serial input to a fixed-size NMEA line buffer until CR or LF without checking the buffer limit. A malformed or overlong input line can write past the end of line[], and the code also uses ch even when read() does not return a byte.

Read bytes only after a successful read(), stop storing at MINMEA_MAX_LENGTH - 1, drain overlong lines until the line ending, and skip parsing truncated sentences.

Generated-by: OpenAI Codex
Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
2026-07-06 16:31:53 +08:00
Old-Ding
f1d53c875d tools: format bitmap converter
Run the bitmap converter through the Python formatter required by checkpatch so the Python 3 print syntax fix passes the project style checks.

Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
2026-07-06 16:31:47 +08:00
Old-Ding
c0228d7b57 tools: Fix bitmap converter print syntax
Use Python 3 print function syntax so bitmap_converter.py can be parsed by current Python interpreters while preserving the existing usage message and exit path.

Generated-by: OpenAI Codex
Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
2026-07-06 16:31:47 +08:00
Old-Ding
6eead56aa9 system: resmonitor: check CPU load reads
Keep the default zero CPU value when the procfs load file cannot be read, and trim only the newline that was actually present. This avoids parsing uninitialized stack data in fillcpu and avoids writing before the showinfo CPU buffer when fgets returns no data.

Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
2026-07-06 16:31:38 +08:00
Abhishek Mishra
da3234f936 !fsutils/passwd: remove insecure default TEA encryption keys
Use 0 as a Kconfig placeholder. The nuttx build rejects unset keys
and can generate random values when configured.

BREAKING CHANGE: CONFIG_FSUTILS_PASSWD_KEY1..4 no longer default to
0x12345678 / 0x9abcdef0. Configs that relied on those defaults must
set keys manually or enable BOARD_ETC_ROMFS_PASSWD_RANDOMIZE_KEYS in
nuttx. Fix: set keys in menuconfig or enable random key generation.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-07-06 16:30:13 +08:00
raiden00pl
afe2a0eafc canutils/lely: add dependencies for Kconfig options
some options depends on others and not selecting them can cause compilation errors.

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-07-06 08:24:00 +02:00
Felipe Moura
4d5f60005c netutils/dropbear: add scp support via SSH exec requests
Code Clean up - Remove unnecessary code.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
2026-07-05 15:06:17 +08:00
Felipe Moura
ec134a99a8 netutils/dropbear: add scp support via SSH exec requests
Add SCP support do the dropbear server.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
2026-07-05 15:06:17 +08:00
Tiago Medicci
8e00b4d672 interpreters/python: Disable no-maybe-uninitialized warning
This commit disables the `no-maybe-uninitialized` warning because
it's wrongly evaluated after increasing the optimization level of
the Python's library.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-07-03 09:19:04 -03:00
Jorge Guzman
59d3a0d0ae examples/lvglterm: support physical keyboard input
Refactor the LVGL terminal into a shared core (lvglterm.c) plus two
selectable input variants: the existing on-screen touch keyboard
(lvglterm_touch.c) and a new physical keyboard variant (lvglterm_kbd.c) that
reads key events from a /dev/kbdN device and streams them to the shell.

The input source is chosen with a Kconfig choice (touch by default, keeping
the previous behaviour).  The keyboard variant reads its device from
CONFIG_EXAMPLES_LVGLTERM_KBD_DEV (default /dev/kbd0), overridable by the first
command-line argument, and scrolls the output with the Fn cursor keys.  A font
choice (UNSCII 8 or 16) is added for low-resolution displays.

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2026-07-03 09:16:58 -03:00
Matteo Golin
c91abf2c8d games/NXDoom: Fix build warnings
This commit resolves all of the build warnings that were preventing
NXDoom from compiling in CI runs.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-07-02 09:08:46 -03:00
Frederick Blais
e61f46536e interpreters/berry: Fix Wshadow build errors
The pinned Berry source emits -Wshadow diagnostics in a couple of files. NuttX CI passes -Werror, so sim:berry fails when those third-party warnings are promoted to errors.\n\nAdd -Wno-shadow to Berry-specific compiler flags in both Make and CMake paths, keeping the local source patch limited to the NuttX port changes.

Signed-off-by: Frederick Blais <fred_blais5@hotmail.com>
2026-07-02 09:07:50 -03:00
dependabot[bot]
e3f7126a8f build(deps): bump actions/cache from 5 to 6
Bumps [actions/cache](https://github.com/actions/cache) from 5 to 6.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-30 20:45:56 +02:00
Matteo Golin
53bc21feb8 apps/games/NXDoom: Style ignores
Ignore some style/spelling errors in the DOOM port that cannot be fixed.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-06-30 15:22:55 -03:00
Matteo Golin
073188b50d games/NXDoom: Initial port of Chocolate DOOM to NuttX.
This commit includes a (highly) modified version of Chocolate DOOM which
can run on NuttX. The majority of the modifications were made to pass
the NuttX style check. Some small modifications have been added to
support keyboard input, render graphics to frame buffers and directly
use the POSIX interfaces NuttX supplies, stripping out Windows/Mac stuff
and any references to SDL.

NOTE: Sound is currently not supported in any capacity, nor is the
networking stuff. A lot of Chocolate DOOM code was stripped out since it
was unused. If there is a need/desire to add it back later, the original
Chocolate DOOM source can be used as a reference.

WARNING: The NuttX keyboard codec is incredibly non-standard and so
there are problems translating from X11 keys to NuttX ones to play DOOM.
Right now, the CTRL key for firing doesn't work because the NuttX codec
has no concept of it. The NuttX codec should be modified (and other
input devices supported), but at the time of this port I am not
sufficiently comfortable doing so since I am afraid of breaking other
things in the kernel.

NOTE: This port (and likely the original DOOM) seems to be written with
32-bit computers in mind. As such, most things are given the type of
natural `int`, even when a single byte might do. There are significant
size optimizations that could be made to make this more suited to
embedded devices that NuttX typically runs on.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-06-30 15:22:55 -03:00
Matteo Golin
53ca441b32 apps/games/NXDoom: Original Chocolate DOOM source
This commit adds the original Chocolate DOOM source which forms a basis
for the NuttX port of DOOM.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-06-30 15:22:55 -03:00
Xiang Xiao
5ead824fff apps: Fix O_ACCMODE bitmask checks after Linux flag alignment
After aligning NuttX open() flag constants with Linux (O_RDONLY=0,
O_WRONLY=1, O_RDWR=2), code that used '(flags & O_RDONLY)' or
'(flags & O_WRONLY)' as a bitmask check is broken because O_RDONLY
is now 0.  Fix by using '(flags & O_ACCMODE)' comparisons instead.

  - usrsocktest: replace 'flags & O_RDWR' with 'flags & O_ACCMODE'
    in fcntl F_GETFL assertions
  - dd: verify mode used '(oflags & O_RDONLY)' to detect verify;
    replace with '(oflags & O_ACCMODE) == O_RDWR'
  - dpopen: replace '(oflag & O_RDWR) == O_RDWR' with
    '(oflag & O_ACCMODE) == O_RDWR'
  - usbmsc: replace 'flags & O_WRONLY' with
    '(flags & O_ACCMODE) == O_RDONLY'
  - fcntl_test: replace '(flags & O_WRONLY) == 0' with
    '(flags & O_ACCMODE) == O_RDONLY'

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-06-30 12:19:58 -04:00
Frederick Blais
fc25af7cd7 interpreters/berry: Patch CRLF upstream source directly
Berry's downloaded default/berry.c uses CRLF line endings, while the local NuttX patch was LF. Fresh Linux and CMake builds failed when patch saw the line-ending mismatch.

Regenerate the local Berry patch against the pinned upstream CRLF source and apply it directly in both Make and CMake fetch paths. This keeps the integration working until the Berry-side change is merged upstream and the pinned commit can be updated.

Signed-off-by: Frederick Blais <fred_blais5@hotmail.com>
2026-06-30 23:55:57 +08:00
hanzhijian
9b51035300 nshlib/nsh_fscmds: Fix potential NULL pointer dereferences
Fix two potential NULL pointer dereferences in nsh_fscmds.c:

1. fdinfo_callback: asprintf() failure left filepath potentially
   NULL, which was then passed to nsh_catfile(). Add early return
   on asprintf failure.

2. cmd_cat: malloc(BUFSIZ) for stdin reading was used without
   checking the return value. Add NULL check with -ENOMEM return.

Also fix a typo in error message: 'nsh_catfaile' -> 'nsh_catfile'.

Signed-off-by: hanzhijian <hanzhijian@zepp.com>
2026-06-30 10:05:08 -03:00
hanzhijian
f57aa7b4cf nshlib/nsh_fscmds: Display modification time in ls -l output
Fixes #17063

Add modification time display to ls -l long format output.
The timestamp is shown as 'YYYY-MM-DD HH:MM' between the permission
string and the file size, following the ISO long-iso format.

Files with st_mtime == 0 (e.g., procfs, tmpfs pseudo-entries) skip
the timestamp display to avoid showing a meaningless epoch time.

Signed-off-by: hanzhijian <hanzhijian@zepp.com>
2026-06-30 10:03:03 -03:00
wangjianyu3
c503843e38 netutils/rexecd: add -t option to serve connections without a thread
By default rexecd spawns a detached worker thread per accepted connection
to allow concurrent sessions. Add a "-t" runtime option to instead handle
each connection inline in the main task, avoiding the per-connection
worker stack (CONFIG_NETUTILS_REXECD_STACKSIZE) allocation from the heap.
This matters on low-memory targets with limited free heap.

With "-t", connections are served strictly one at a time: a long-running
or interactive command blocks the accept loop until it finishes. Without
it, the existing thread-per-connection behaviour is unchanged.

Assisted-by: GitHubCopilot:claude-4.8-opus
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-06-30 13:46:37 +08:00
Michal Lenc
535ecd8640 testing/libc/fopencookie/fopencookie.c: fix spellcheck
succesfull => successful

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-06-29 12:29:42 +02:00
Xiang Xiao
d172f81ecc apps: Replace O_RDOK with O_RDONLY after alias removal
The O_RDOK/O_WROK aliases have been removed from fcntl.h.  Replace
all remaining O_RDOK usage with O_RDONLY in the apps repository.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-06-29 07:42:09 +02:00
Xiang Xiao
4c560ef0a2 apps: Replace O_RDOK with O_RDONLY after alias removal
The O_RDOK/O_WROK aliases have been removed from fcntl.h.  Replace
all remaining O_RDOK usage with O_RDONLY in the apps repository.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-06-28 13:00:52 +02:00
Frederick Blais
a2b1cc16da interpreters/berry: Add Berry scripting language
Add an optional Berry interpreter under apps/interpreters.

Fetch the pinned upstream source and apply the NuttX default-port patch.

Generate Berry constant objects and build the NSH command through Kconfig.

Make and CMake build paths are included for normal app integration.

Signed-off-by: Frederick Blais <fred_blais5@hotmail.com>
2026-06-28 02:16:58 +08:00
wangjianyu3
253f1d40c3 netutils/rexecd: use dpopen() instead of popen() to get raw fd
popen() now returns a fopencookie-backed FILE* whose fileno() yields the
cookie pointer rather than a real descriptor, so poll() silently ignores
the negative fd and the relay loop blocks forever waiting for command
completion. See https://github.com/apache/nuttx-apps/pull/3511

Use dpopen()/dpclose() to obtain the raw bidirectional socket descriptor
directly, restoring the EOF/POLLHUP command-completion signal.

Assisted-by: GitHubCopilot:claude-4.8-opus
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-06-27 08:47:46 -03:00
wangjianyu3
d29ae9bda6 netutils/rexec: initialize ret to avoid maybe-uninitialized
When the relay loop exits early without entering any branch, ret would be
returned uninitialized, tripping -Werror=maybe-uninitialized. Initialize
it to 0.

Assisted-by: GitHubCopilot:claude-4.8-opus
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-06-27 08:47:46 -03:00
Alan Carvalho de Assis
ae718ba47f nsh/echo: Fix echo previous behavior, single write with '\n'
This commit fixes the previous behavior where an echo with a
single string and its default new line is send as single write().

This issue came from:  https://github.com/apache/nuttx-apps/pull/1559

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-06-27 13:44:14 +02:00
Felipe Moura
fee2ddbf54 netutils/dropbear: add Dropbear SSH server port for NuttX
Integrated SSH daemon authenticating against FSUTILS_PASSWD, with an
ECDSA P-256 host key and an NSH session over a PTY per connection. Built
from the upstream Dropbear tarball (pinned commit) and patched for
NuttX, using Dropbear's bundled libtomcrypt for all crypto. setsid()
(apache/nuttx#19184) and link() now come from NuttX, not local stubs.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
2026-06-27 08:42:00 -03:00
Michal Lenc
e44c4f370f testing/libc: add stdbit test
Adds the testing application used for CI stdc*_ functions tests.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-06-27 19:28:34 +08:00
Nightt
cea2f89f74 industry/scpi: add unit parser config options
Expose scpi-parser unit support through explicit Kconfig options instead of raw CFLAGS.

Map each option to the corresponding upstream USE_UNITS_* compile-time define, preserving the existing default unit set while allowing users to enable groups such as USE_UNITS_TIME.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-06-25 23:48:43 +08:00
dependabot[bot]
085ca0606e build(deps): bump actions/checkout from 6 to 7
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-23 13:26:39 -04:00
aviralgarg05
da143595e1 apps: add missing module metadata for executable tools
Add the missing module metadata for the executable ELF helpers used by the package fixture flow so the generated artifacts describe their target and type consistently.

Also fix the existing embedlog spelling issue that is picked up by the current apps check, keeping this branch clean under CI.

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-06-22 22:27:07 +08:00
Andrew Au
d9874394dd testing/sig_sp_test: add test for SP context restore on signal return
Add a test that verifies modifying SP (REG_R13) in the saved register
context is honored on signal return. The test pushes values onto the
stack, triggers SIGALRM, and in the handler advances SP to skip a
value, then verifies the correct value is popped after signal return.

This exercises the SP relocation fix in arm_sigdeliver.c for ARMv7-M
and ARMv8-M architectures.

Signed-off-by: Andrew Au <cshung@gmail.com>
2026-06-22 10:21:40 -03:00
Xiang Xiao
326b68aa36 examples/userfs: use designated initializers for struct dirent
The g_rootdir[] table initialized each entry's struct dirent member
positionally as { DTYPE_FILE, "FileN" }, which assumes d_type is the
first field.  This breaks when struct dirent gains the POSIX d_ino field
as its first member (see apache/nuttx: "fs/dirent: add d_ino member to
struct dirent"): the file-name string would be assigned to d_type,
producing -Wint-conversion warnings and an "initializer element is not
computable at load time" error.

Use designated initializers (.d_type / .d_name) so the table is robust
against the field order of struct dirent.

Also fix a 'Initiallly' typo in a nearby comment flagged by codespell.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-06-22 10:20:43 -03:00
Abhishek Mishra
75ee4d9090 nshlib: Add su, id, and whoami identity commands
Add NSH commands for switching effective credentials and inspecting
session identity. Update login and prompt to reflect effective user.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-06-20 15:38:45 -03:00
aviralgarg05
65854ea805 system/nxpkg: add local package lifecycle helper
Add the initial nxpkg command, metadata and store handling, the local install/list path, and the repository export helper.

Keep the current flow scoped to local artifacts and target-qualified repository entries so it remains usable as an incremental MVP while follow-up features land separately.

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-06-20 15:05:28 -03:00
Nightt
477d04b975 examples/gps: print units after measurements
Move GPS example units after the printed values to match the requested output style.

Wrap long printf format strings for checkpatch.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-06-20 11:51:35 -03:00
Nightt
1a6d06c3be examples/gps: show units in output
The GPS example prints parsed measurements without explicit units. The RMC
floating-point speed path also used minmea_tocoord(), even though speed is
not a coordinate.

Add units to the output labels, print speed with minmea_tofloat(), and print
GGA altitude as a scaled value with the sentence-provided unit.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-06-20 11:51:35 -03:00
Shoji Tokunaga
8d6c495365 examples/rust: Show command arguments in hello_rust_cargo
Print each argument passed from nsh with its index, and report when
the example is running on the simulator target. This makes the Rust
example demonstrate both C argv handling and target-specific output.

Signed-off-by: Shoji Tokunaga <toku@mac.​com>
2026-06-20 10:33:46 -03:00
Shoji Tokunaga
d1202bd501 examples/rust: Avoid the infinite loop on sim for hello_rust_cargo
On the sim target (Windows/macOS/Linux), hello_rust_cargo_main() ended
with an infinite `loop {}` that never returned control to NSH, so the
example could not exit and the shell prompt hung.

Introduce a Cargo `sim` feature that is enabled only when CONFIG_ARCH_SIM
is set, and use it to compile out the trailing infinite loop and return 0
instead. Other embedded targets keep the original looping behavior.

Signed-off-by: Shoji Tokunaga <toku@mac.com>
2026-06-20 10:33:46 -03:00
Abhishek Mishra
ee4727fdba testing/ostest: Add multi-user permission regression tests
Add CONFIG_TESTING_OSTEST_MULTIUSER tests for seteuid, file permissions,
and pseudoFS/tmpfs permission enforcement.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-06-19 12:19:18 -03:00
Tiago Medicci
1e19ceb347 examples/webpanel: Add a web panel application to configure NuttX
Initial development of the NuttX's Web Panel application. This is
a self-hosted web page application that enables retrieving system
info, provides a simple NSH terminal and enables uploading files.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-06-18 09:14:36 -03:00
Tiago Medicci
b523f0e513 interpreters/python: Optmize Python for size
This aims to reduce Python's library size.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-06-16 14:54:51 -03:00
Tiago Medicci
ec764fbbab examples/lws_echo: Add a simple websocket server example
This commit adds a simple websocket server example that echoes data
back to the client using libwebsockets.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-06-16 14:27:29 -03:00
Tiago Medicci
d6cf3015d8 netutils/libwebsockets: Fix error regarding building with CMake
Prior to this change, if an empty folder existed instead of the
actual libwebsockets source, the build would fail. This commit
checks for an actual file instead, avoid such kind of errors.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-06-16 14:27:29 -03:00
Tiago Medicci
4263e27d92 netutils/libwebsockets: Enable libwebsockets server
This commit enables building libwebsockets server based on a new
Kconfig entry.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-06-16 14:27:29 -03:00
Tiago Medicci
d106011a7f netutils/libwebsockets: Remove hard dependency on mbedTLS
libwebsockets can be built without TLS support. To allow this, it
was necessary to create a specific Kconfig option that enables TLS
support if OPENSSL_MBEDTLS_WRAPPER is enabled. Otherwise, TLS is
not supported (but libwebsockets can still be used with plain ws://
connections).

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-06-16 14:27:29 -03:00
Tiago Medicci
c51180d780 examples/mdnsd: Create an event-based starter for mDNS daemon
Start the mDNS daemon based on the event of getting a new IP
address for any of the system's network interfaces. This allows
DHCP client to trigger the mDNS daemon after getting a new IP
address, for instance.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-06-16 14:24:42 -03:00
Jukka Laitinen
4740945157 ostest: Make POSIX timers test work with CONFIG_ENABLE_PARTIAL_SIGNALS
POSIX timers test doesn't really need signal actions, so we can change it
to synchronously wait for the signal in sigwaitinfo, instead of registering
a signal handler.

Also exclude the test from compilation with CONFIG_DISABLE_ALL_SIGNALS;
the test does require at least partial signal support.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-06-16 08:49:22 +02:00
Nightt
afc652243e examples/thttpd: use procfs for tasks CGI
The tasks CGI used nxsched_foreach() to walk scheduler internals and read
fields directly from struct tcb_s. That exposes an application example to
non-standard OS internals.

Read task information from /proc/<pid>/status instead, matching the public
procfs interface used by other task listing tools.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-06-14 08:56:44 -03:00
Filipe Cavalcanti
c00dc40525 interpreters/python: support nuttx-periphery package
Adds support for installing nuttx-periphery Python package by default
on Python support. This package provides API for accessing Nuttx
character drivers.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2026-06-12 11:56:37 -04:00
Filipe Cavalcanti
e18a206082 interpreters/python: update repack_wheel script
Updates the repack_wheel_add_pyc.py script to support other packages,
not only pip.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2026-06-12 11:56:37 -04:00
Lars Kruse
397047fa37 benchmarks/mtd: use uniform output style for numbers
One of the four values emitted by this interactive tools uses the
hexadecimal presentation. The other values are decimal numbers.
Now the confusion is avoided: all numbers use the decimal
representation.

In addition the suffix "size" is added to the "Erase block" label
in order to clarify its meaning.

Signed-off-by: Lars Kruse <devel@sumpfralle.de>
2026-06-10 16:43:17 +08:00
Peter Barada
499352fb0c testing/drivers/hash: Add unaligned buffer size test
Add hash testing of unaligned buffer sizes via multiple call to
ioctl(CIOCCRYPT) in a single session with buffer sizes incrementally
increasing from zero size to 255 (with monotoncially increasing
byte value data) to force all sizes to be handled by cryptodev
implementations.

Signed-off-by: Peter Barada <peter.barada@gmail.com>
2026-06-10 16:42:13 +08:00
Nightt
fa2dd70386 system/popen: Avoid copying FILE
Use fopencookie() to attach the popen fd and shell pid to the returned FILE stream instead of copying FILE into the popen container.

Keep the upstream dpopen()/dpclose() implementation as the process and descriptor backend, and make pclose() close the cookie-backed stream directly.

Fixes #2937.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-06-09 19:35:15 +08:00
hanzhijian
03171162f1 system/uorb: introduce CONFIG_UORB_FORMAT for format string control
Introduce a new CONFIG_UORB_FORMAT Kconfig option to control whether
uORB format strings are compiled in. UORB_LISTENER, UORB_GENERATOR,
and DEBUG_UORB all select UORB_FORMAT automatically, so format strings
are included when any of these features are enabled.

This replaces the previous approach of guarding format strings with
CONFIG_DEBUG_UORB, which prevented uorb_listener from displaying
sensor data when debug output was disabled.

Signed-off-by: hanzhijian <hanzhijian@zepp.com>
2026-06-09 17:02:03 +08:00
Felipe Moura
8b43c71595 examples/rng90: add RNG90 example
Add a new RNG90 example application that opens the RNG90 character device, reads random bytes, and prints them in hexadecimal format.

The example supports optional command-line arguments for device path and byte count and integrates with Kconfig, Make, and CMake build flows.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
2026-06-09 12:36:04 +08:00
Shoji Tokunaga
33d96e92e5 apps/tools: Enable Rust sim builds on Intel Macs
Select the Mach-O Rust target (x86_64-unknown-nuttx-macho.json) when
building Rust apps for the simulator on x86_64 macOS.

Signed-off-by: Shoji Tokunaga <toku@mac.com>
2026-06-09 07:08:41 +08:00
hanzj
8b4d20e411 system/uorb: fix listener_top not showing topic data
listener_update() only prints topic data when delta_generation is
non-zero (i.e., new data arrived since last check). In listener_top,
the first call adds objects to the list, and subsequent calls only
print if new data was published between iterations. This results in
listener_top -T showing only the header with no topic rows.

Fix by always printing the current topic state in listener_update,
setting frequency to 0 when no new data arrives. This ensures
listener_top displays all topics every iteration.

Fixes apache/nuttx-apps#3202

Signed-off-by: hanzj <hanzhijian@zepp.com>
2026-06-06 18:27:56 +08:00
raiden00pl
80907e514c lte: make lte_initialize() build without the ALT1250 daemon
Guard the daemon path (and is_daemon_running()) with CONFIG_MODEM_ALT1250 and
return OK from lte_initialize() when it is not set, so lapi builds and works
for kernel-resident LTE modems.

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-06-06 15:53:14 +08:00
simbit18
0758631811 workflows/build.yml: Fix Skipping sim\windows in the MSVC job
Fix

====================================================================================
Cmake in present: sim\windows
Configuration/Tool: sim\windows
2026-06-05 16:01:37
------------------------------------------------------------------------------------
  Cleaning...
  Skipping: sim\windows
------------------------------------------------------------------------------------
End: 2026-06-05 16:01:37
====================================================================================

The "windows-latest" and “windows-2025” labels in GitHub Actions will be migrated to use Visual Studio 2026 by default. Customers needing Visual Studio 2022 must migrate to the windows-2022 image.

https://github.com/actions/runner-images/issues/14017

Signed-off-by: simbit18 <simbit18@gmail.com>
2026-06-06 08:44:50 +08:00
fangpeina
1d7d4fe67e system/nxinit: fix init parser to handle multiple quoted arguments
Fix argument parsing in init_parse_arguments() to properly handle
multiple quoted arguments like 'echo "arg1" "arg2"' by skipping
quote characters after processing them.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-06-05 09:43:45 +08:00
wangjianyu3
d79d8107b3 system/nxinit: Fix signal mask inheritance
The init process has blocked all signals, spawned services would
inherit that mask. This could cause services to miss important
signals like SIGTERM during graceful shutdown.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-06-05 09:43:45 +08:00
wangjianyu3
b73a5acf92 system/nxinit: Fix missing check for import argument
Add missing return value check for init_parse_arguments function.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-06-05 09:43:45 +08:00
v-maomingju
63c691eae2 system/nxinit: fix unused variable warning
fix the unused variable warnings for name and status in init.c.

Signed-off-by: v-maomingju <v-maomingju@xiaomi.com>
2026-06-05 09:43:45 +08:00
wangjianyu3
84d6b1276f system/nxinit: Avoid SIGCHLD race with ppoll()
Pending all signals(SIGCHLD) when ppoll() is not invoked to
avoid race conditions.

Case reproduction

  Set examples/hello as a service that exits immediately after startup.

  ```init.rc
  on boot
     start hello

  service hello hello
     restart_period 0
  ```

  Log - without this patch:

    # Service hello only restarts about 100 times, ppoll is not woken up
    # after the hello process with PID 119 exits.

    [    4.391274] [ 2] [ 0] init_main: service 'hello' pid 118 exited status 0
    [    4.401423] [ 2] [ 0] init_main: started service 'hello' pid 119

  Log - with this patch:

    # ppoll() can still be woken up normally after tens of thousands of
    # restarts of service hello in stress test.

    [  268.447747] [ 2] [ 0] init_main: service 'hello' pid 34503 exited status 0

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-06-05 09:43:45 +08:00
fangpeina
78bf19c83c system/nxinit: prevent parser from reading past string boundry
Any string ending with whitespace passed to init_parse_arguments()
could cause the parser to advance past the string boundary and read
unintended memory content.
 - " echo "A" \0& echo "B" should be parsed
   as a command with two argvs instand of five.
 - "command arg  " may lead to uncertain results.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-06-05 09:43:45 +08:00
wangjianyu3
b0fdffb7f6 system/nxinit: Fix timespec incomplete error in action.h
/.../apps/system/nxinit/action.h:72:19: error: field 'time_run' has incomplete type
    72 |   struct timespec time_run;
       |                   ^~~~~~~~

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-06-05 09:43:45 +08:00
fangpeina
62b74502fe system/nxinit: fix uninitialized 'wstatus' warning
reap_process() referenced an undeclared identifier 'wtatus' on
the WIFSIGNALED branch (typo of 'wstatus'). Some toolchains then
flagged a -Wmaybe-uninitialized on the surrounding wstatus use.

Correct the typo so WIFSIGNALED/WTERMSIG operate on the actual
wstatus value returned by waitpid().

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-06-05 09:43:45 +08:00
fangpeina
3d26835e0c system/nxinit: fix compilation errors in action.c
action.c uses clock_gettime(CLOCK_MONOTONIC, ...) but did not
pull in <nuttx/clock.h> directly, which fails to build on
configurations where the header is not transitively included.

Add the missing #include.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-06-05 09:43:45 +08:00
wangjianyu3
df01c3cbfc system/nxinit: Handle trailing file '\0'
When ETC_ROMFS is disabled to reduce the bin size, we can provide the init.rc
file via a pseudo-file in the boards/vendor directory. For example:
  - CONFIG_ETC_ROMFS=n
  - CONFIG_PSEUDOFS_FILE=y
  - CONFIG_DISABLE_PSEUDOFS_OPERATIONS=n
  ```C
  FAR const char *init_rc =
    "on init\n"
    "    start console\n";
    "service console sh\n"
    "    restart_period 100\n";

  int fd = open("/etc/init.d/init.rc", O_WRONLY | O_CREAT);
  /* ... */
  ssize_t n = write(fd, init_rc, strlen(init_rc) + 1);
  /* ... */
  close(fd);
  ```

The last character '\0' in the file content will be treated as a new line,
and the number of parsed parameters will be zero (abnormal, there should be
at least one keyword).

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-06-05 09:43:45 +08:00
hanzj
e86c0b997d system/nxinit: skip empty lines in init.rc parser
Empty lines in init.rc caused parsing to fail with -EINVAL because init_parse_arguments() returns 0 for empty strings, triggering the 'argc < 1' error path in init_action_parse() and accessing uninitialized argv[0] in init_service_parse().

Fix by skipping empty lines and lines containing only whitespace before attempting to match section keywords or calling parser callbacks.

Fixes apache/nuttx-apps#3513

Signed-off-by: hanzj <hanzhijian@zepp.com>
2026-06-04 13:11:09 -03:00
Shoji Tokunaga
840c2f30db apps/rust: Add dependencies for Rust cargo in make builds
Add a Rust make helper that collects crate input files, and use it for
the Rust hello and slint examples.

This makes the generated Rust static libraries depend on the crate
sources, manifests, build scripts. Hook the libraries into both context
and all, so re-running make after editing Rust inputs rebuilds the crate.

Signed-off-by: Shoji Tokunaga <toku@mac.com>
2026-06-04 08:58:07 -03:00
Arjav Patel
c106a02b58 examples/microros_sub: Add minimal Int32 subscriber example.
Mirror of microros_pub for the receive direction.  Creates a node,
subscribes to /nuttx_sub with std_msgs/Int32, drives an rclc_executor
spin loop, and prints each received value.  Exercises the new
rclc_executor + subscription callback path on top of the
microros_transport library shipped in apps/system/microros.

Validates the NuttX-native transport in the agent->client direction
end-to-end against a micro-ROS agent + ros2 topic pub on the host.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-06-04 14:30:34 +08:00
cuiziwei
97802bd9e0 testing/libc/popen: add popen/dpopen test for shell and no-shell modes
Add tests for popen()/pclose() and dpopen()/dpclose() that work in
both shell (NSH) and no-shell (direct posix_spawnp) modes.  The test
binary doubles as its own target via the --echo sub-command.

Tests:
 1-4: popen  - basic read, multi-arg, pclose, invalid mode
 5-7: dpopen - basic read, multi-arg, dpclose

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2026-06-02 23:35:28 +08:00
cuiziwei
740fda9630 system/popen: support no-shell mode via posix_spawnp
When NSH_LIBRARY is not available, dpopen()/popen() can still execute
commands by splitting the command string by whitespace and calling
posix_spawnp() directly.  Shell syntax (pipes, redirects, globbing)
is not supported in this mode.

Add CONFIG_SYSTEM_POPEN_MAXARGUMENTS (default 7) to control the
argv array size for the no-shell path.

Remove the hard dependency on NSH_LIBRARY from SYSTEM_POPEN so the
feature can be used in minimal configurations without a shell.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2026-06-02 23:35:28 +08:00
cuiziwei
0d35e2e0bb system/popen: add dpopen/dpclose fd-based interface
Add dpopen()/dpclose() as the descriptor-based counterpart of
popen()/pclose(), analogous to how dprintf() relates to fprintf().
dpopen() returns a raw file descriptor instead of a FILE stream,
avoiding the stdio.h dependency for callers that only need an fd.

Refactor popen() as a thin wrapper: dpopen() + fdopen() + FILE
container.  All pipe creation and process spawning logic now lives
in dpopen.c.

Also remove the hard dependency on NSH_LIBRARY from SYSTEM_POPEN.
When NSH is available, commands are executed through sh -c with full
shell syntax support.  When NSH is not available, commands are split
by whitespace and executed directly via posix_spawnp().

Add CONFIG_SYSTEM_POPEN_MAXARGUMENTS (default 7) to control the
argv array size for the no-shell path.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2026-06-02 23:35:28 +08:00
Eren Terzioglu
3a255d5463 testing/drivers/crypto: Fix typo on hash test
Fix typo issue on hash test

Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
2026-06-02 15:15:03 +02:00
Shoji Tokunaga
9796690b7b apps/cmake: Fix aarch64 NuttX Rust target specs
Add aarch64 Rust target specs for NuttX, including a Mach-O variant
for macOS sim builds. Use the NuttX custom targets instead of
aarch64-apple-darwin so Rust std is built with target_os=nuttx while
still producing link-compatible objects for sim.

Signed-off-by: Shoji Tokunaga <toku@mac.com>
2026-06-02 13:06:58 +02:00
Arjav Patel
1081225509 examples/microros_pub: Add minimal Int32 publisher example.
End-to-end exercise of the micro-ROS stack on NuttX: calls
microros_transport_init() to register the configured backend,
brings up rclc_support / node / publisher, publishes 30
std_msgs/Int32 messages on /nuttx_pub at 1 Hz, then tears the
stack down cleanly.

The example's Make.defs adds $(APPDIR)/system/microros/transport
to its own CFLAGS rather than the system/microros Make.defs, so
the transport-glue header path is not pushed into the global
search path for unrelated apps.

Serves as the smoke test for the transport layer and as a template
for downstream publisher apps.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-06-02 00:15:25 +08:00
Arjav Patel
5e91459b1a system/microros: Add UDP and serial custom transport backends.
Micro XRCE-DDS expects the application to supply open/close/write/read
callbacks for the wire transport. Add a single dispatcher that
registers the selected backend via rmw_uros_set_custom_transport(),
plus two backends:

transport/microros_transport_udp.c
  BSD-socket UDP backend. Opens an AF_INET/SOCK_DGRAM socket,
  resolves CONFIG_MICROROS_AGENT_IP/PORT, connect()s it, and uses
  send/recv. The socket fd is stashed in uxrCustomTransport->args
  so no module-level state is needed.

transport/microros_transport_serial.c
  termios serial backend. Opens CONFIG_MICROROS_SERIAL_DEVICE with
  O_RDWR|O_NOCTTY|O_CLOEXEC, switches to raw 8N1 at
  CONFIG_MICROROS_SERIAL_BAUD, and uses poll/read/write. Fd is
  again stashed in uxrCustomTransport->args.

Both backends are mutually exclusive at compile time via Kconfig;
the dispatcher selects which set of callbacks to register. Wired
into both the legacy Make build (CSRCS in system/microros/Makefile)
and the CMake build (separate microros_transport static library
with the transport directory only exposed to its INTERFACE).

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-06-02 00:15:25 +08:00
Arjav Patel
0a0118b93c system/microros: Wire libmicroros include layout and sim final link.
libmicroros is installed by colcon under include/<pkg>/<pkg>/file.h
for ament-packaged headers (e.g. rcl, rmw, rosidl) and the flat
include/<pkg>/file.h for a few others (e.g. rclc). A single
-I include/ therefore resolves <rclc/rclc.h> but not <rcl/rcl.h>.

Enumerate every immediate subdirectory of include/ in addition to
include/ itself so both layouts resolve.

Switch the library hand-off from LDLIBS to EXTRA_LIBS. The sim
target's final link pulls EXTRA_LIBS, not LDLIBS, so the previous
form left rcl/rclc/rcutils symbols unresolved.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-06-02 00:15:25 +08:00
Arjav Patel
3d6ea0ccec system/microros: Fix toolchain attribute strip breaking libc inlines.
micro_ros_lib/toolchain.cmake.in initialised C and CXX flags with
-D'__attribute__(x)=' to silence GCC attributes the upstream ament
build is not aware of. The strip also removed __gnu_inline__ and
__always_inline__ from NuttX's libc string.h inlines, so each
micro-ROS translation unit emitted external definitions of strcmp,
strcpy, strlen and friends. Sim final link then failed with ~50
multiple-definition errors.

Drop the define from both flag init lines so the attributes survive
and the inlines collapse as intended.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-06-02 00:15:25 +08:00
Peter Barada
fa46bdf9e8 testing/drivers/crypto: Add SH224 hash test
Add SHA224 hash test using results generated from sha224sum.

Modify "huge block" testing since allocating 600KB to hash all
at once fails on most microcontrollers.  Instead allocate a
smaller block and pass into syshash_update() enough times to
hash 600KB of data.

Signed-off-by: Peter Barada <peter.barada@gmail.com>
2026-05-31 11:44:37 +08:00
hanzj
07647d3fd4 system/lzf: Fix missing space in Kconfig help text.
Fix a missing space in the Kconfig help text for SYSTEM_LZF:
'Enable theLZF' → 'Enable the LZF'.

Signed-off-by: Zepp-Hanzj <Zepp-Hanzj@users.noreply.github.com>
Signed-off-by: hanzj <hanzjian@zepp.com>
2026-05-28 21:27:01 +02:00
Nightt
c0fc208202 system/settings: Bound storage string handling
Use configured key, value, and filename limits while loading and saving settings storage data.

The text backend now builds backup filenames with a sized buffer and bounded formatting, and both text and binary loading reject keys or string values that are not terminated within their configured field sizes. This completes #3109 without changing the storage formats.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-28 14:35:54 +02:00
Nightt
a74b2fc61b system/settings: Bound public string handling
Use strnlen() for public key, value, and storage path length checks so user-provided settings strings are validated against the configured maximum sizes before they are scanned.

Use bounded key comparisons and strlcpy() for fixed-size settings fields. This addresses part of #3109 without changing the settings API or storage formats.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-28 14:35:54 +02:00
hanzj
b5b54e7663 interpreters/quickjs,testing/nettest: fix typos in Kconfig and source.
Fix spelling errors in QuickJS Kconfig and nettest source:
* "distable" -> "disable" in INTERPRETERS_QUICKJS_NONE description
* "destory" -> "destroy" in INTERPRETERS_QUICKJS_EXT_HOOK option
  and help text (2 occurrences)
* "err_destory" -> "err_destroy" label in nettest_tcpserver.c
  (3 occurrences: 2 goto targets and 1 label definition)

These are cosmetic fixes with no functional change.

Signed-off-by: hanzj <hanzjian@zepp.com>
2026-05-28 15:02:31 +08:00
Matteo Golin
418cf21224 apps/nxinit: Fix uninitialized variable
Without debug enabled, the code would not compile due to checking
`WIFEXITED(wstatus)` when `wstatus` was uninitialized.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-05-28 01:08:11 -03:00
Matteo Golin
2b5899c7d4 apps/nxinit: Make init.rc file path configurable
The init.rc file path is now configurable to allow users to choose where
to put the startup script. This is useful for devices that mount
external media to a special directory like `/sd`.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-05-28 01:08:11 -03:00
Matteo Golin
6d8708184e apps/nxinit: Fix service length error
Would not compile due to typo in macro describing service name length.

Change ensures that:
* We do not malloc an extra `len` bytes since this is already allocated
  as part of the struct
* The name string always has a null terminating byte

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>

FIx
2026-05-28 01:08:11 -03:00
Matteo Golin
241096a87b apps/nxinit: Fix Kconfig typo
Fix typo in help string.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-05-28 01:08:11 -03:00
Alan Carvalho de Assis
c28e61fd39 system/nxinit: Change NXInit to EXPERIMENTAL
Since NXInit still under development, it is better to change it to
EXPERIMENTAL.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-05-27 17:20:07 -03:00
Alan Carvalho de Assis
5341a2fc92 system/nxinit: Add final event
Add the final event option to the Kconfig

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-05-27 17:20:07 -03:00
Alan Carvalho de Assis
d8ead1a0f3 system/nxinit: Remove deprecated BOARDIOC_INIT ioctl
Since boardctl(BOARDIOC_INIT, 0) was removed from all boards, it is
not right to use it here.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-05-27 17:20:07 -03:00
Alan Carvalho de Assis
820eb64f1a system/nxinit: Change LOG_DEBUG to LOG_USER
Make it clear it is a userspace log.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-05-27 17:20:07 -03:00
Alan Carvalho de Assis
cdb89a54f6 system/nxinit: Let use a define to define the class max cmds
Avoid fixing the max 99 class cmds directly in the code.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-05-27 17:20:07 -03:00
Alan Carvalho de Assis
7af8ed81fd system/nxinit: Fix name[0] issue
This an issue where a variable was declared as name[0]

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-05-27 17:20:07 -03:00
Alan Carvalho de Assis
610de9816d system/nxinit: Add comments to the Kconfig
This comments to be visible to the users

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-05-27 17:20:07 -03:00
wangjianyu3
84e87a5158 system/nxinit: Add reboot_on_failure for service
Add support for the reboot_on_failure option to the service.

When the execution of a command within a certain action fails (returning
a non-zero status code), NxInit will continue to execute subsequent commands or
actions and will not proactively terminate the startup process. To implement
the functionality of "terminating the startup process after a command
execution fails", there are two methods:
a. Execute conditional statements (if/then/else/fi) via exec command,
   but this depends on sh:
   ```
   on init
       exec -- set +e; \
               mount -t fatfs /dev/data /data ; \
               if [ $? -ne 0 ] ; \
               then \
                 echo "failed" ; \
                 reboot ; \
               else \
                 echo "succeed" ; \
               fi;
   ```
b. Via service's oneshot + reboot_on_failure:
   /* Although the example uses sh, it does not depend on it and can be
    * replaced with any other Builtin Apps.
    */
   ```
   on init
       exec_start mkdir_tmp
       ls /tmp

   service mkdir_tmp sh -c "mkdir /tmp"
       reboot_on_failure 0
       oneshot
   ```

Test
  - RC
      service console sh
          class core
          override
    >     reboot_on_failure 0
          restart_period 10000
  - Runtime
      [    0.150000] [ 3] [ 0] init_main: == Dump Services ==
      ...
      [    0.170000] [ 3] [ 0] init_main: Service 0x40486ea0 name 'console' path 'sh'
      [    0.170000] [ 3] [ 0] init_main:   pid: 0
      [    0.170000] [ 3] [ 0] init_main:   arguments:
      [    0.170000] [ 3] [ 0] init_main:       [0] 'service'
      [    0.170000] [ 3] [ 0] init_main:       [1] 'console'
      [    0.170000] [ 3] [ 0] init_main:       [2] 'sh'
      [    0.170000] [ 3] [ 0] init_main:   classes:
      [    0.170000] [ 3] [ 0] init_main:     'core'
      [    0.170000] [ 3] [ 0] init_main:   restart_period: 10000
    > [    0.170000] [ 3] [ 0] init_main:   reboot_on_failure: 0
      [    0.170000] [ 3] [ 0] init_main:   flags:
      [    0.170000] [ 3] [ 0] init_main:     'override'
      ...
      [    0.380000] [ 3] [ 0] init_main: started service 'console' pid 4
      ...
      nsh> kill -9 4
      [    8.060000] [ 3] [ 0] init_main: service 'console' flag 0x20000004 add 0x4
      [    8.060000] [ 3] [ 0] init_main:   -flag 'running'
      [    8.060000] [ 3] [ 0] init_main: service 'console' flag 0x20000000 add 0x8
      [    8.060000] [ 3] [ 0] init_main:   +flag 'restarting'
    > [    8.060000] [ 3] [ 0] init_main: Error reboot on failure of service 'console' reason 0

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-05-27 17:20:07 -03:00
wangjianyu3
84f798d434 system/nxinit: Add exec_start support for action
Format: exec_start <service>

Start the specified service and pause the processing of any additional
initialization commands until the service completes its execution. This
command operates similarly to the `exec` command; the key difference is
that it utilizes an existing service definition rather than requiring
the `exec` argument vector.

This feature is particularly intended for use with the `reboot_on_failure`
built-in command to perform all types of essential checks during system boot.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-05-27 17:20:07 -03:00
wangjianyu3
8049d91a95 system/nxinit: Add oneshot support for service
Add support for the oneshot option to the service.

Test
  - RC
      service telnet telnetd
          class test
    >     oneshot
          restart_period 3000
  - Runtime
      [    0.150000] [ 3] [ 0] init_main: == Dump Services ==
      ...
      [    0.160000] [ 3] [ 0] init_main: Service 0x40486aa8 name 'telnet' path 'telnetd'
      [    0.160000] [ 3] [ 0] init_main:   pid: 0
      [    0.160000] [ 3] [ 0] init_main:   arguments:
      [    0.160000] [ 3] [ 0] init_main:       [0] 'service'
      [    0.160000] [ 3] [ 0] init_main:       [1] 'telnet'
      [    0.160000] [ 3] [ 0] init_main:       [2] 'telnetd'
      [    0.160000] [ 3] [ 0] init_main:   classes:
      [    0.160000] [ 3] [ 0] init_main:     'test'
      [    0.170000] [ 3] [ 0] init_main:   restart_period: 3000
      [    0.170000] [ 3] [ 0] init_main:   reboot_on_failure: -1
      [    0.170000] [ 3] [ 0] init_main:   flags:
    > [    0.170000] [ 3] [ 0] init_main:     'oneshot'
      ...
      [    0.370000] [ 3] [ 0] init_main: starting service 'telnet' ...
      [    0.380000] [ 3] [ 0] init_main: service 'telnet' flag 0x2 add 0x4
      [    0.380000] [ 3] [ 0] init_main:   +flag 'running'
      [    0.380000] [ 3] [ 0] init_main: service 'telnet' flag 0x6 add 0x8
      [    0.380000] [ 3] [ 0] init_main:   -flag 'restarting'
      [    0.380000] [ 3] [ 0] init_main: service 'telnet' flag 0x6 add 0x1
      [    0.380000] [ 3] [ 0] init_main:   -flag 'disabled'
      [    0.380000] [ 3] [ 0] init_main: started service 'telnet' pid 9
      ...
      nsh> kill -9 9
      nsh> [    7.350000] [ 3] [ 0] init_main: service 'telnet' flag 0x6 add 0x4
      [    7.350000] [ 3] [ 0] init_main:   -flag 'running'
      [    7.350000] [ 3] [ 0] init_main: service 'telnet' flag 0x2 add 0x80000001
      [    7.350000] [ 3] [ 0] init_main:   +flag 'disabled'
      [    7.350000] [ 3] [ 0] init_main:   +flag 'remove'
      [    7.350000] [ 3] [ 0] init_main: service 'telnet' pid 9 exited status 1
    > [    7.360000] [ 3] [ 0] init_main: removing service 'telnet' ...

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-05-27 17:20:07 -03:00
wangjianyu3
4281a1096f system/nxinit: Warning for long commands
If the command of an action takes too long (greater than
CONFIG_SYSTEM_NXINIT_ACTION_WARN_SLOW milliseconds, 50 ms by default),
a warning log will be output for analysis and debugging.

For example:

  a. sleep 1
       [    0.340000] [ 3] [ 0] init_main: executing NSH command 'sleep 1'
       [    1.360000] [ 3] [ 0] init_main: NSH command 'sleep 1' exited 0
     > [    1.360000] [ 3] [ 0] init_main: command 'sleep' took 1020 ms

  b. hello (add sleep(1) to examples/hello)

       [    1.390000] [ 3] [ 0] init_main: executed command 'hello' pid 14
       [    1.390000] [ 3] [ 0] init_main: waiting 'hello' pid 14
       Hello, World!!
     > [    2.400000] [ 3] [ 0] init_main: command 'hello' pid 14 took 1010 ms
       [    2.400000] [ 3] [ 0] init_main: command 'hello' pid 14 exited status 0

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-05-27 17:20:07 -03:00
wangjianyu3
7c02e7f555 system/nxinit: Add NSH builtin support for action
Enable CONFIG_SYSTEM_SYSTEM to support nsh builtins, which depends on nsh.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-05-27 17:20:07 -03:00
wangjianyu3
8594627d8a system/nxinit: Add class start/stop for service
Usage:
  class_start <classname>
  class_stop <classname>

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-05-27 17:20:07 -03:00
wangjianyu3
492a86691d system/nxinit: Add NuttX Init
This component (abbreviated as "NxInit") is specifically developed
for NuttX and intended for system initialization. While we have
adopted the Android Init Language among various syntax options,
this is a brand-new implementation—it is not a port or variant of
Android Init.

Refer to the implementation of Android Init Language, consists of five broad
classes of statements: Actions, Commands, Services, Options, and Imports.

Actions support two types of triggers: event and action. Action triggers also
support runtime triggering. Services support lifecycle management, including
automatic restart (at specified intervals), and starting/stopping
individually or by class. Import supports files or directories, and we may
add a static method in the future. The following are some differences:
  1. The Android Init Language treats lines starting with `#` as comments,
     while we use a preprocessor to handle comments.
  2. For action commands, we can omit "exec" and directly execute
     built-in apps or nsh builtins.
  3. Regarding the property service, users can either adapt it by self or
     directly use the preset NVS-based properties.
  4. Only part of standard action commands and service options are
     implemented currlently.

To enable system/nxinit:
  ```diff
  -CONFIG_INIT_ENTRYPOINT="nsh_main"
  +CONFIG_INIT_ENTRYPOINT="init_main"
  +CONFIG_SYSTEM_NXINIT=y
  ```

For format and additional details, refer to:
  https://android.googlesource.com/platform/system/core/+/
  master/init/README.md

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-05-27 17:20:07 -03:00
wangjianyu3
ed063a0981 nshlib: fix infinite loop on broken stdout in nsh_catfile
When stdout is broken (e.g. PTY master closed), nsh_catfile could spin
forever: write() fails, error logging generates syslog output to
/dev/log, next read() picks it up, write() fails again, ad infinitum.

Two fixes:
- nsh_console: drop the _err() in nsh_consolewrite entirely.  The risk
  is errno-agnostic (EPIPE / EIO / ENOSPC / ...): any failure logged
  here can be re-injected by the syslog backend when OUTFD is bound to
  /dev/log.  Callers already see the failure via the negative return
  value and errno, so on-failure logging at this layer is redundant.
- nsh_fsutils: jump straight from the inner write-failure path to a
  single errout: cleanup label instead of using a two-level break +
  flag check, so a failed write cannot fall through to another read().

Assisted-by: GitHubCopilot:claude-4.7-opus
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-05-26 16:06:28 -03:00
Shoji Tokunaga
72bedd5c5d apps/tools: Make hello_rust_cargo buildable with make
* Add JSON specification compatibility flag.
* Add Rust target conversion support for `aarch64` on macOS.

Signed-off-by: Shoji Tokunaga <toku@mac.com>
2026-05-26 23:30:12 +08:00
Jiri Vlasak
d0fa5af39b audioutils: Add RTTTL parsing library
Add a simple library for parsing Ring Tone Text Transfer Language
(RTTTL).

Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
2026-05-26 09:55:31 -03:00
dependabot[bot]
84022eaa81 build(deps): bump docker/login-action from 4.0.0 to 4.2.0
Bumps [docker/login-action](https://github.com/docker/login-action) from 4.0.0 to 4.2.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](b45d80f862...650006c6eb)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 4.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-26 17:30:37 +08:00
Arjav Patel
939ed0ca2a apps/system/microros: add rcutils strcasecmp strings.h include patch.
POSIX specifies strcasecmp/strncasecmp in <strings.h>, not <string.h>.
On NuttX (and other strict POSIX environments) rcutils/src/strcasecmp.c
only includes <string.h>, causing an implicit-declaration error for
strcasecmp when cross-compiling.

Patch 0003 adds #include <strings.h> guarded by !_WIN32, matching the
existing Windows/POSIX split in the file.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
55a7d4d2df apps/system/microros: define __NuttX__ in cross-compile toolchain flags.
Add -D__NuttX__ to CMAKE_C_FLAGS_INIT and CMAKE_CXX_FLAGS_INIT in
toolchain.cmake.in so that all cross-compiled micro-ROS packages see the
NuttX target macro.  Without this, rcutils/src/process.c follows the
__linux__ branch and references program_invocation_name, a glibc-only
extension absent from the NuttX C library.

Pair with 0002-rcutils-process-nuttx-compat.patch which additionally
guards the linux branch with !defined(__NuttX__), ensuring the embedded
fallback path is taken on NuttX even if the host compiler defines any
linux-flavoured macros.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
9a0c249c79 apps/system/microros: add CMake ExternalProject build support.
Mirror the Makefile build pipeline into CMakeLists.txt using
ExternalProject_Add so that CMake-based NuttX builds (cmake --build)
can also produce libmicroros.a.  The external project delegates to the
existing Makefile targets, then exposes the result via an IMPORTED
STATIC library target with correct INTERFACE_INCLUDE_DIRECTORIES.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
7dbebe1673 apps/system/microros: add DIR-typedef NuttX guard patch.
NuttX defines DIR as a struct type in dirent.h.  The rcutils filesystem
source has a bare typedef int DIR that triggers a redefinition error when
NuttX system headers are on the include path.  Guard it with #ifndef DIR
so the typedef is skipped when the type is already defined.

Applied automatically during the micro_ros_src/src fetch step with
  patch -p1 --forward --ignore-whitespace ... || true
so the build is idempotent if the upstream ever merges a fix.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
cb316ec165 apps/system/microros: wire libmicroros.a into LDLIBS and CFLAGS.
When CONFIG_SYSTEM_MICROROS=y, add the prebuilt libmicroros.a to LDLIBS
and the colcon-installed include/ tree to CFLAGS/CXXFLAGS so that any
application in nuttx-apps can include micro-ROS headers and link against
the library without extra flags.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
b1a4d3fcd5 apps/system/microros: add libmicroros.a colcon build pipeline.
Replace the Directory.mk stub with a full Application.mk-based Makefile
that builds libmicroros.a from upstream micro-ROS sources via colcon.
Build pipeline (six steps, each a Make target):

  1. micro_ros_dev/install  -- clone + build ament/colcon host tools
  2. micro_ros_src/src      -- git clone all Jazzy micro-ROS packages
                               with --depth 1; apply DIR-typedef guard
                               patch; mark unused packages COLCON_IGNORE
  3. toolchain.cmake        -- sed-substitute CC/CXX/CFLAGS into template
  4. colcon.meta            -- sed-substitute Kconfig resource limits
  5. micro_ros_src/install  -- colcon cross-build (merge-install,
                               packages-ignore-regex=.*_cpp)
  6. libmicroros.a          -- ar-merge all install/lib/*.a into one
                               archive; copy include/ tree

clean:: removes generated files; distclean:: removes all fetched dirs.
Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
e764594d26 apps/system/microros: add CMake cross-compile toolchain template.
Add toolchain.cmake.in and include_override/assert.h for the colcon
cross-build.  Key differences from the old robertobucher port:
  - Drop -DCLOCK_MONOTONIC=0: NuttX defines CLOCK_MONOTONIC=1 and
    the override broke nanosleep() on newer kernels.
  - CMAKE_SYSTEM_PROCESSOR is a placeholder substituted per-arch.
  - include_override/assert.h works around the rosidl NDEBUG issue
    (https://github.com/ros2/rosidl/pull/739).

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
98d3a0bcb0 apps/system/microros: add colcon.meta.in resource-limit template.
Add a colcon.meta.in template that is substituted at build time with
Kconfig values.  Key settings:
  - Custom transport only (UCLIENT_PROFILE_CUSTOM_TRANSPORT=ON,
    UCLIENT_PROFILE_STREAM_FRAMING=ON) -- actual UDP/serial callbacks
    are wired in Phase 4.
  - RCL_MICROROS=ON (Jazzy/Kilted renamed flag replacing the old
    RCL_COMMAND_LINE_ENABLED/RCL_LOGGING_ENABLED pair).
  - RCUTILS_NO_FILESYSTEM=OFF -- NuttX provides POSIX filesystem.
  - Resource limits use @MAX_NODES@/@MAX_PUBLISHERS@ etc. placeholders
    substituted from CONFIG_MICROROS_MAX_* Kconfig values.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
0f8f9125f0 apps/system/microros: add micro_ros_lib directory skeleton.
Add micro_ros_lib/ subdirectory with a .keep sentinel so the directory
is tracked by git before any generated build artifacts appear.  All
colcon/fetch outputs land here and are gitignored by the parent .gitignore.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Nightt
0dd221cc76 system/settings: Drop unused recursive mutex type
The settings save path no longer re-enters g_settings.mtx, so the mutex does not need to be initialized as PTHREAD_MUTEX_RECURSIVE.

This keeps the #3105 fix independent of CONFIG_PTHREAD_MUTEX_TYPES and destroys the temporary mutex attribute object after initialization.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-25 14:36:36 +02:00
Nightt
2d949fa7c5 system/settings: Avoid recursive save locking
Fix #3105 by making the immediate save path write pending settings while the caller still owns g_settings.mtx instead of calling the timer callback, which locks the same mutex again.

The cached-save timer callback still takes the mutex before using the same locked helper, so asynchronous saves keep their existing synchronization while non-cached saves no longer depend on a recursive mutex.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-25 14:36:36 +02:00
Nightt
f8a48fa5f3 testing/sd_stress: Harden file creation cleanup
Close the temporary file descriptor when create_files() fails after open(), and release the read buffer before returning from the path-length failure branch.

This is logically separable from the #3205 stale-directory fix: it does not change how existing /sd/stress is handled, but keeps the same failure paths from leaking resources while the stress test exits after an error.

The scope intentionally stays within sd_stress failure cleanup and does not touch SD/MMC transfer behavior or other testing drivers.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-25 10:28:32 +08:00
Nightt
2d6cd74215 testing/sd_stress: Handle stale temporary directories
Fix #3205 by removing stale sdstress work directories left by previous interrupted or failed runs before starting a new test.

The cleanup only removes entries matching the generated tmpNNN file pattern. If the directory contains any unexpected entry, the test fails instead of deleting user data.

Also make create_dir() and remove_dir() use their path argument instead of the fixed temporary directory names.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-25 10:28:32 +08:00
Nightt
8568013436 netutils/thttpd: Apply the same check to related allocation sites
Extend the allocation-failure check to httpd_strdup(), the thttpd-local wrapper that has the same failure contract as strdup().

This is logically separable from the direct strdup()/asprintf() fixes: it prevents using hs->hostname before checking whether the wrapped string allocation succeeded, and releases the partially allocated server state on failure.

The scope intentionally does not extend to malloc(), calloc(), or other raw allocators because #1727 specifically calls out strdup()/asprintf(), and covering all allocation APIs would make this PR much broader.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-23 16:30:52 -04:00
Nightt
c44f9a0556 apps: Fix unchecked strdup()/asprintf() as requested in #1727
Add missing failure handling for direct strdup() and asprintf() calls where the allocated result is consumed locally before any NULL/error check.

This keeps the scope to the functions named in #1727 and avoids changing pass-through return sites where callers already receive NULL on allocation failure.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-23 16:30:52 -04:00
Tiago Medicci
58b780c280 interpreters/python: Add ctypes prototype patches for NuttX
Integrate NuttX-specific ctypes and posixmodule updates.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-05-22 21:51:31 +08:00
Tiago Medicci
965cddfa36 system/libffi: Add libffi package integration
Add Kconfig, build rules, and ignore entries required to build and
package libffi as a standalone system component.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-05-22 21:51:31 +08:00
Shoji Tokunaga
c9c5c75d08 examples/rust: Fix hello_rust_cargo CMake settings
Use the hello_rust_cargo-specific Kconfig symbols for the built-in
application stack size and priority.

Previously, CMake referenced the generic hello example symbols, so the
configured hello_rust_cargo stack size could be ignored.

Signed-off-by: Shoji Tokunaga <toku@mac.com>
2026-05-22 15:00:26 +08:00
raiden00pl
5cce60aa9a examples: add pulse count example
add pulse count driver example. Previously it was mixed with PWM example.

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-22 13:39:32 +08:00
raiden00pl
2ad3e4e17b examples/pwm: remove refenrences to PULSECOUNT
Remove refenrences to PULSECOUNT from PWM example.
Pulse count driver will be handled by separate application.

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-22 13:39:32 +08:00
Nightt
5355adb9cf apps: Fix codespell warnings.
Fix the reported typo warnings and ignore the V4L2 parm field name in apps codespell configuration, matching the main NuttX repository.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-22 13:39:04 +08:00
Nightt
fcd10aa725 examples/lp503x: Open device write-only.
Open the LP503X device with O_WRONLY because the driver registers the device node with write-only permissions and the example controls it through ioctl().

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-22 13:39:04 +08:00
Nightt
b4f1e29494 apps: Fix additional open() arguments.
Add missing mode arguments to direct open() calls that use O_CREAT.

Also open the lp503x device with explicit read-only flags instead of O_CREAT, matching the device-node usage.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-22 13:39:04 +08:00
Nightt
5c703f5603 nshlib/testing: Fix open() arguments.
Pass explicit open flags for the NSH script redirect file so the mode argument is used as file creation permissions.

Add the missing mode argument to AIO ostest open() calls that create the test file.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-22 13:39:04 +08:00
Xiang Xiao
f9f59bd0f8 !apps: drop redundant casts on tv_sec/tv_nsec and fix printf formats
Now that time_t is unconditionally 64-bit (signed int64_t) and the
struct timespec fields tv_sec / tv_nsec are wide enough on their own,
the explicit (uint64_t)/(int64_t)/(int) casts that used to guard the
multiplications and subtractions in *_us / *_ms / *_ns helpers are no
longer needed.  Drop them to keep the timekeeping math readable.

In the same spirit, this commit also normalises the printf-style format
specifiers and casts used to print tv_sec / tv_nsec / tv_usec values.
The prior code was a mix of "%d"/"%u"/"%ld"/"%lu"/"%lld" with matching
(int)/(unsigned long)/(long long) casts; some formats truncated time_t
on 32-bit hosts, others mismatched signedness or width.  Replace all
such cases with the portable POSIX-recommended forms:

  - tv_sec  (time_t,       signed, impl-defined width) -> %jd  + (intmax_t)
  - tv_nsec (long,         signed)                     -> %ld  (no cast)
  - tv_usec (suseconds_t / long)                       -> %ld  (no cast)

Also drop two stale `(FAR const time_t *)&ts.tv_sec` casts that are
unnecessary now that ts.tv_sec is plain time_t.

Arithmetic-cleanup files (existing scope):

  - benchmarks/cyclictest/cyclictest.c:        timediff_us()
  - benchmarks/sd_bench/sd_bench_main.c:       get_time_delta_us()
  - examples/oneshot/oneshot_main.c:           maxus computation
  - examples/watchdog/watchdog_main.c:         current_time_ms (x2)
  - industry/nxmodbus/nxmb_internal.h:         nxmb_util_clock_ms()
  - netutils/ntpclient/ntpclient.c:            timespec2ntp()
  - netutils/ptpd/ptpd.c:                      ptp_adjtime()
  - system/dd/dd_main.c:                       elapsed accounting
  - testing/drivers/drivertest/drivertest_posix_timer.c:
                                               get_timestamp()
  - testing/drivers/sd_stress/sd_stress_main.c:get_time_delta()
  - testing/sched/getprime/getprime_main.c:    elapsed accounting
  - testing/sched/pthread_mutex_perf/pthread_mutex_perf.c:
                                               timespec_avg()

Printf-format-fix files (new in this revision):

  - examples/adjtime/adjtime_main.c
  - examples/charger/charger_main.c
  - examples/netpkt/netpkt_ethercat.c
  - fsutils/mkfatfs/mkfatfs.c
  - graphics/tiff/tiff_initialize.c
  - netutils/ptpd/ptpd.c
  - nshlib/nsh_timcmds.c
  - system/coredump/coredump.c
  - system/ptpd/ptpd_main.c
  - testing/drivers/drivertest/drivertest_oneshot.c
  - testing/mm/kasantest/kasantest.c
  - testing/ostest/semtimed.c
  - testing/sched/pthread_mutex_perf/pthread_mutex_perf.c
  - testing/sched/timerjitter/timerjitter.c
  - testing/testsuites/kernel/time/cases/clock_test_clock01.c
  - testing/testsuites/kernel/time/cases/clock_test_smoke.c

No behavioural change.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-22 13:38:25 +08:00
Arjav Patel
e9d1141f7c apps/system/microros: Add CMakeLists.txt for CMake support.
Add CMakeLists.txt file for CMake build system integration.
Enables the micro-ROS library module to be built using NuttX CMake
build system alongside traditional Make-based builds.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Arjav Patel
faf07ed3b0 apps/system/microros: Add .gitignore for library build artifacts.
Ignore build outputs and generated files:
- Directories: micro_ros_src/, micro_ros_dev/, build/, install/
- Build outputs: libmicroros.a, toolchain.cmake, colcon.meta
- Archives: *.tar.gz

Prevents build artifacts and downloaded sources from being committed.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Arjav Patel
0be4928893 apps/system/microros: Add Makefile skeleton.
Add Makefile with standard NuttX build system integration. Follows
the MENUDESC + Directory.mk pattern used throughout nuttx-apps.
Enables the system/microros module to be built as part of the apps
directory build process.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Arjav Patel
2a3a41d53a apps/system/microros: Add Kconfig with configuration options.
Add Kconfig file defining CONFIG_SYSTEM_MICROROS and related options:
- MICROROS_DISTRO: ROS 2 distribution selection (default jazzy)
- MICROROS_TRANSPORT_UDP/SERIAL: Transport method selection
- MICROROS_AGENT_IP/PORT: UDP agent address configuration
- MICROROS_SERIAL_DEVICE/BAUD: Serial transport configuration
- Resource limits: MAX_NODES, MAX_PUBLISHERS, MAX_SUBSCRIPTIONS,
  MAX_SERVICES, MAX_CLIENTS

Allows menuconfig integration for micro-ROS library configuration.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Arjav Patel
bda3448106 apps/system/microros: Create empty library skeleton.
Add Make.defs with copyright header for the micro-ROS library
build system. This establishes the directory structure for Phase 2,
with actual build logic to follow in subsequent steps.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Filipe Cavalcanti
43bc7e99d6 system/nxdiag: add CMake support for NXDiag tool
Supports building NXDiag with CMake.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2026-05-21 12:34:05 +08:00
Eren Terzioglu
173e19cde1 apps/examples: Add path option to SPI Slave test
Add path option to spislv_test example

Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
2026-05-19 07:02:31 -03:00
Shunchao Hu
02153debae system/ping: Fallback to ping6 for gethost error handling.
When ping only receives an IPv6 DNS response, the current command
reports "ping_gethostip" and exits even though ping6 can still
handle the target.

Keep the existing ping and ping6 netutils interfaces unchanged and
add a one-way fallback in the ping command. If IPv4 name resolution
fails, ping will spawn ping6 with the same arguments and let ping6
report the final result.

Signed-off-by: Shunchao Hu <ankohuu@gmail.com>
2026-05-19 09:56:01 +02:00
Shoji Tokunaga
e536adaabc apps/cmake: Add DEPENDS for Rust-related files.
* Add `DEPENDS` to ensure staticlib rebuilds when Rust-related files change.
* Uses `GLOB_RECURSE` to search for Rust-related files.

Signed-off-by: Shoji Tokunaga <toku@mac.com>
2026-05-19 11:22:47 +08:00
Abhishek Mishra
ecfc1b5b61 nshlib: add chmod and chown builtins
Add minimal chmod/chown support to NSH using the
existing libc/VFS syscall interfaces.

Supported forms:

  - chmod <octal-mode> <path>
  - chown <uid>[:gid] <path>

The chown implementation supports the numeric
ownership forms already handled by the underlying
NuttX chown() implementation, including unchanged
uid/gid semantics via omitted fields.

Only numeric permission modes and numeric uid/gid
forms are supported in this initial implementation.

This adds interactive filesystem permission and
ownership management support to NSH and aligns the
shell more closely with standard POSIX environments.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-05-19 09:56:24 +08:00
raiden00pl
f0f7c5ada9 wakaama: add support for TLV
add support for LWM2M TLV

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-18 16:18:53 -04:00
Tiago Medicci
8ba84edb0a interpreters/python: Enable using pip to install Python packages
This commit enables using `pip` as a pre-compiled (pyc) built-in
distributed along with cpython.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-05-18 15:08:30 -04:00
raiden00pl
2fce07fe1c testing/drivertest_pwm: remove references to CONFIG_PWM_MULTICHAN
remove references to CONFIG_PWM_MULTICHAN

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-18 11:35:09 -04:00
raiden00pl
8bd6615034 examples/pwm: remove references to CONFIG_PWM_MULTICHAN
remove references to CONFIG_PWM_MULTICHAN

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-18 11:35:09 -04:00
Matteo Golin
86fb38fbe4 boot/mcuboot: Update commit version
This updates the version of mcuboot used by NuttX now that BOARDIOC_INIT
is removed.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-05-18 09:03:47 +02:00
Shoji Tokunaga
bb7c83b01c apps:cmake: Add APPLE to a build target for sim's configuration using CMake.
* Add Rust target conversion support for `aarch64` on acOS/Linux (and Linux `arm`).
* When a Rust target is unsupported and results in an empty configuration, trigger a CMake `FATAL_ERROR`.

Signed-off-by: Shoji Tokunaga <toku@mac.com>
2026-05-18 12:22:48 +08:00
Shoji Tokunaga
c10ce6aa4f apps/cmake: Make hello_rust_cargo buildable with cmake
* Resolve APPDIR.
* Remove "debug" from RUST_PROFILE_FLAG.
* Add JSON specification compatibility flag.
* Correct the directory structure for RUST_LIB_PATH.

Signed-off-by: Shoji Tokunaga <toku@mac.com>
2026-05-14 07:16:15 -04:00
xiaoxiang781216
21b28a4126 testing/ltp: silence -Wshift-count-overflow on -Werror builds
The LTP open_posix_testsuite header timespec.h has, since 2019:

  #define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1)

When time_t is 64 bits (the default after sched/remove-system-time64),
the shift reaches the sign bit of the underlying type and toolchains
emit -Wshift-count-overflow, which the LTP build promotes to a hard
error via -Werror.  This breaks rv-virt/citest and rv-virt/citest64
on CI.

The diagnostic is benign here (TIME_T_MAX itself is correct) and the
defect is in upstream LTP, so disable the warning alongside the other
'should be removed in the future' relaxations until upstream is fixed.

Signed-off-by: xiaoxiang781216 <xiaoxiang781216@gmail.com>
2026-05-14 09:42:44 +02:00
zhanghongyu
5d15d97418 netlib: replace DNS ping with gateway ping for connectivity check
Refactor netlib_check_ipconnectivity() to use gateway/router ping instead
of DNS server ping for network connectivity checks. Add IPv6 support.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-05-14 11:58:15 +08:00
zhanghongyu
97485342aa netlib_ipv6route.c: fix the issue of parsing IPv6 routing entries
Update the column ruler and field labels in route_ipv6_entry comment
to match the actual output: lowercase to uppercase, remove colons.
Consistent with Nuttx definition

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-05-14 11:58:15 +08:00
raiden00pl
275a083464 ci: retry git clone for nuttx-ntfc-testing
github infra is not stable so even "git clone" from github repos can fail with error: 500.
With this commit we try to clone repo few more times.

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-12 11:31:11 -04:00
Xiang Xiao
a6477ec8dc !apps: replace sclock_t with clock_t and drop redundant time_t/off_t casts
Align with the upstream nuttx change that drops the sclock_t alias now
that clock_t is itself a signed 64-bit type (int64_t).  Beyond the pure
sclock_t -> clock_t rename, this commit also removes the
now-unnecessary (time_t)-1 / (time_t)0 / (off_t)-1 casts that were
papering over the previously-unsigned time_t.

Files touched:

  - examples/alarm/alarm_main.c:        sclock_t -> clock_t
  - netutils/dhcpd/dhcpd.c:             sclock_t -> clock_t
  - netutils/ftpd/ftpd.c:               sclock_t -> clock_t
  - netutils/thttpd/libhttpd.c,
    netutils/thttpd/tdate_parse.c:      drop (time_t)-1 / (time_t)0 /
                                        (off_t)-1 sentinel casts
  - system/resmonitor/filldisk.c,
    system/zmodem/zm_receive.c:         sclock_t -> clock_t
  - testing/ostest/wdog.c:              sclock_t -> clock_t (the bulk
                                        of the rename, 30 sites)
  - testing/testsuites/kernel/syscall/cases/{clock_nanosleep_test,
    fsync_test,time_test}.c:            drop (time_t)-1 casts in the
                                        new signed-time_t world

No behavioural change.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-11 17:38:32 +08:00
Xiang Xiao
72837c8d26 !apps: drop CONFIG_SYSTEM_TIME64 conditionals
NuttX always uses a 64-bit system clock now (time_t/clock_t are
always 64-bit). Remove the obsolete CONFIG_SYSTEM_TIME64 #ifdef
branches and Kconfig dependency.

  - examples/dronecan: drop SYSTEM_TIME64 dependency
  - examples/netlink_route: always use PRIx64
  - netutils/netinit: always use the 1-hour LONG_TIME_SEC
  - netutils/ptpd: always pack the 48-bit seconds field and apply
    the 64-bit overflow guard in timespec_delta_ns()
  - testing/ostest/semtimed: always validate tv_sec >= 0

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-11 17:38:32 +08:00
Xiang Xiao
ed746548ca !testing/libc/scanftest: drop CONFIG_LIBC_LONG_LONG from help text
CONFIG_LIBC_LONG_LONG has been removed; long long support is now
unconditional.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-11 17:38:32 +08:00
Xiang Xiao
3adb14f12d !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support
The matching nuttx commit removes CONFIG_HAVE_LONG_LONG; clean up the
remaining users in nuttx-apps so that "long long" is always assumed:

  - examples/noteprintf, examples/nxscope:
        unconditionally exercise the %lld / long long branch.
  - fsutils/mkfatfs/configfat.c:
        drop the 32-bit fall-back paths in mkfatfs_nfatsect12/16/32;
        always use uint64_t for the FAT-size arithmetic.
  - logging/nxscope/nxscope_chan.c:
        drop the CONFIG_HAVE_LONG_LONG guard around the 64-bit
        sample helpers.
  - netutils/ftpd, netutils/ntpclient:
        always emit the 64-bit format strings.
  - testing/fs/fstest/fstest_main.c:
        drop the parallel 32-bit verification path; keep only the
        64-bit (long long) random pattern generator.
  - system/zmodem/host/nuttx/compiler.h:
        remove the host-side CONFIG_HAVE_LONG_LONG stub macro.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-11 17:38:32 +08:00
raiden00pl
783957da07 system/uorb: DEBUG_UORB depends on float data
DEBUG_UORB depends on float data, FIXED16 not supported

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-06 08:54:32 +02:00
raiden00pl
b3cf222836 system/sensorscope: support for fixe16 data
system/sensorscope: support for fixe16 data

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-06 08:54:32 +02:00
Matteo Golin
dca76ccb78 codespell: Ignore lines without typos
Ignore some new lines with incorrect spelling error detection.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-05-06 13:27:05 +08:00
Matteo Golin
5b0cae9ab0 !apps: Simplify NuttX initialization
BREAKING: In an effort to simplify board initialization logic for NuttX,
NSH will no longer support architecture initialization. This will happen
during boot via the BOARD_LATE_INITIALIZE option. The boardctl command
BOARDIOC_INIT is also no longer available from user-space.

Quick fix:
Any application relying on BOARDIOC_INIT should now enable
BOARD_LATE_INITIALIZE to have initialization performed by the kernel in
advance of the application running. If control over initialization is
still necessary, BOARDIOC_FINALINIT should be implemented and used.
Boards relying on NSH for initialization should also enable
BOARD_LATE_INITIALIZE instead.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-05-06 13:27:05 +08:00
raiden00pl
a9881037ea nimble: remove -Wno-pointer-to-int-cast from CFLAGS
it's not needed and cause warnings for C++ builds:

cc1plus: warning: command-line option '-Wno-pointer-to-int-cast' is valid for C/ObjC but not for C++
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-05 13:29:11 -04:00
Serg Podtynnyi
ded0a17514 graphics/lvgl: bump version to 9.2.2
Update lvlg version to 9.2.2, includes fix for nuttx lcd release
Get version from config in Makefile
Get version from config in cmake file

Signed-off-by: Serg Podtynnyi <serg@podtynnyi.com>
2026-05-03 17:39:10 +02:00
shichunma
0105a9b238 netutils/ntpclient: guard DHCP-only helpers
fix a warning that static function defined by not used

Signed-off-by: Jerry Ma <masc2008@gmail.com>
2026-04-30 13:29:42 +02:00
shichunma
c82957109f netutils: prefer DHCP-provided NTP servers for ntpc
Use the DHCP-learned NTP server list as the default ntpc server source when DHCP option 42 is available.

Fall back to CONFIG_NETUTILS_NTPCLIENT_SERVER only when DHCP does not provide any NTP servers, and restart ntpc when the DHCP-provided server list changes.

Signed-off-by: Jerry Ma <masc2008@gmail.com>
2026-04-24 10:44:08 -03:00
shichunma
4b705721ca netutils/dhcpc: parse DHCP NTP server option
Request DHCP option 42 and store the returned IPv4 NTP server
addresses in struct dhcpc_state for later consumers.

Signed-off-by: Jerry Ma <masc2008@gmail.com>
2026-04-24 10:44:08 -03:00
wangjianyu3
62f3d37041 examples/vncviewer: add VNC viewer for LCD display
Add a minimal VNC viewer application that connects to a VNC server
and renders the remote desktop on a local LCD.

Features:
- RFB 3.8 protocol with VNC Authentication (DES, pure software)
- Raw encoding with pixel format auto-detected from LCD driver
- Row-by-row rendering via LCDDEVIO_PUTAREA (minimal RAM usage)
- LCD resolution and format queried at runtime via LCDDEVIO_GETVIDEOINFO
- Auto-reconnect on connection loss with 2-second retry

Usage:
  vncviewer <host> [port]
  vncviewer -p <password> <host> [port]
  vncviewer -p <password> -d <lcd_devno> <host> [port]

Assisted-by: GitHubCopilot:claude-4.6-opus
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-24 14:58:49 +02:00
Tiago Medicci
6379e531de system/irtest: Set irtest command line size to CONFIG_LINE_MAX
Let `irtest` command line size be equal to CONFIG_LINE_MAX so that
bigger (or smaller) commands can be set.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-04-24 14:58:05 +02:00
Tiago Medicci
9b6b7607f2 system/irtest: Avoids silently truncating long write_data commands
Long write_data commands can be truncated without any check due to
the maximum size of CONFIG_SYSTEM_IRTEST_MAX_SIRDATA. This commit
adds a check to avoid a silent fail.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-04-24 14:58:05 +02:00
Tiago Medicci
6cb1a04fe7 system/irtest: Fix issues regarding portability and buffer size
This commit fixes issues regarding portability by using variables
with fixed width (and their format macro constants).

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-04-24 14:58:05 +02:00
Tiago Medicci
901278a4ba examples: Remove deprecated rmtchar example application
The upper-half RMT driver is no longer available on NuttX. Instead,
Espressif's RMT peripheral was bound directly to the lirc driver.
For testing purposes, use the `irtest` application. NuttX OS PR
https://github.com/apache/nuttx/pull/18654 removed the upper-half
driver interface used by this application, so removing it does not
break any existing feature on NuttX.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-04-24 14:58:05 +02:00
raiden00pl
eccfba4776 .github: use ntfc test cases from Apache repo
use ntfc test cases from Apache repo

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-04-24 19:55:57 +08:00
raiden00pl
180607372a .github/build.yml: improve ntfc installation
increase retries and timeout for pip install and try again in case of failure

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-04-24 19:55:57 +08:00
raiden00pl
773f69d5d9 modbus: add nxmodbus
NxModbus is a lightweight Modbus protocol stack implementation for NuttX RTOS.

This commit adds:
- nxmodbus stack
- nxmbserver - Modbus Server (Slave) example
- nxmbclient - Modbus Client (Master) tool

Supported Modbus transports:
- ASCII
- RTU over serial port
- TCP
- RAW (ADU) for custom transport implementations

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-04-20 12:45:17 -03:00
Alan Carvalho de Assis
2016c0b6ae apps/modbus: Move modbus to inside industry/
Modbus is a protocol mostly used on industries and since it is a
protocol it is not a category to be at root of apps/

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-04-20 08:42:37 +02:00
Alan Carvalho de Assis
2ee08209a0 apps/modbus: Move modbus to inside industry/
Modbus is a protocol mostly used on industries and since it is a
protocol it is not a category to be at root of apps/

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-04-20 08:42:37 +02:00
Michal Lenc
8e9f5a8d3a nshlib/nsh_timcmds.c: fix incorrect time set during summer time
Value zero in tm_isdst means daylight saving time (or summer
time) is not in effect. This is obviously not true for half of the year
in most timezones and keeping it at zero leads to incorrect time
being set. This commit sets tm_isdst to -1, which means the information
is not available and it should be handled according to timezone rules.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-04-17 11:11:53 -03:00
raiden00pl
722f3193ce modbus: move freemodbus to a separate directory
move freemodbus to modbus/freemodbus so it is possible to add other
modbus implementations

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-04-14 09:09:42 +02:00
dependabot[bot]
f22a8d0d4f build(deps): bump actions/upload-artifact from 7.0.0 to 7.0.1
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 7.0.0 to 7.0.1.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v7...v7.0.1)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-14 11:01:10 +08:00
dependabot[bot]
a6c11a1db7 build(deps): bump actions/github-script from 8.0.0 to 9.0.0
Bumps [actions/github-script](https://github.com/actions/github-script) from 8.0.0 to 9.0.0.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v8...v9)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-version: 9.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-14 11:00:57 +08:00
Michal Lenc
7dc8cec1ac examples/hello_nim/Kconfig: name consistent with other Hello World apps
Use "Hello, language" scheme to keep the naming consistency with other
Hello World applications for different languages.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-04-13 00:28:32 +08:00
Piyush Patle
96a003072d include/debug.h: fix checkpatch fallout in touched apps files
Clean up style issues in the files touched by the <nuttx/debug.h> include
migration so the full apps-side PR passes checkpatch.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
2026-04-11 10:39:27 -03:00
Piyush Patle
9d849adfab include/debug.h: Use <nuttx/debug.h> in apps
Replace app-side includes of <debug.h> with <nuttx/debug.h> to use the
header from the NuttX tree explicitly after the header move.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
2026-04-11 10:39:27 -03:00
Filipe Cavalcanti
3591378113 crypto/mbedtls: expose include paths as public
Expose include paths as public when using CMake.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2026-04-10 12:23:37 -03:00
Filipe Cavalcanti
bfbeafabbf netutils/mqttc: fix patch and add mbedtls dependency
Add mbedtls dependecy and fix patch path.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2026-04-10 12:23:37 -03:00
wangjianyu3
f95b53d15b examples/camera: add -m option for horizontal mirror preview
Add -m command line option to enable horizontal mirror on the
camera sensor via VIDIOC_S_CTRL + V4L2_CID_HFLIP.  This uses
the sensor hardware mirror (e.g. GC0308 register 0x14 bit[0])
with zero CPU overhead.

Also refactor parse_arguments to use a loop-based parser so
options can appear in any order.

Usage: camera 0 -m    (mirror preview)
       camera -jpg -m (mirror still capture)

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-09 10:34:06 -03:00
wangjianyu3
21dd3082c1 examples/camera: handle RGB565X (BE) format from 8-bit DVP camera
Some image sensors on 8-bit DVP buses (e.g. GC0308) produce RGB565X
(big-endian) pixel data — the high byte is clocked out first and
stored first in PSRAM by the ESP32-S3 CAM controller.

The V4L2 framework does not negotiate formats automatically, so try
RGB565 first and fall back to RGB565X if S_FMT fails.

When the sensor reports RGB565X:
 - Invalidate D-Cache after DQBUF so the CPU reads fresh DMA data
 - Byte-swap each pixel in place from BE to LE RGB565 for display

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-09 10:34:06 -03:00
wangjianyu3
52b36deb13 examples/camera: use MMAP with USERPTR fallback and fix NX stride
Use MMAP buffer allocation by default so the driver can manage
DMA-capable memory with proper alignment and cache attributes.
Fall back to USERPTR if the driver does not support MMAP.

Also fix NX framebuffer stride calculation to use the actual
display width instead of hardcoded values.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-09 10:34:06 -03:00
liuhongchao
a6286ee0ea graphics/input: Add getevent input event monitor tool.
Add getevent utility for monitoring input events including
mouse clicks/movement, multi-touch coordinates/pressure,
and keyboard key presses. Supports automatic device detection
in /dev and command-line device path specification with
non-blocking I/O.

Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
2026-04-09 11:59:19 +02:00
Lup Yuen Lee
9db3e26c85 graphics/libyuv: Download libyuv from NuttX Mirror Repo
NuttX Build Target `sim:nxcamera` failed to build because chromium.googlesource.com is blocking our download of libyuv library: https://github.com/apache/nuttx/actions/runs/24106742084/job/70356374433#step:10:603

```
Configuration/Tool: sim/nxcamera
Building NuttX...
curl -L https://chromium.googlesource.com/libyuv/libyuv/+archive/refs/heads/stable.tar.gz -o libyuv.tar.gz
gzip: stdin: not in gzip format
```

This PR updates the libyuv Makefile to download libyuv from the NuttX Mirror Repo instead: https://github.com/NuttX/nuttx/releases/tag/libyuv

Signed-off-by: Lup Yuen Lee <luppy@appkaki.com>
2026-04-08 18:40:26 +08:00
Shunchao Hu
231ac397a7 canutils/lely-canopen: avoid patch reapply on repeated builds.
The patch step currently uses a phony target, so it is executed
again when the build is repeated in the same source tree. In that
case `patch -N` detects previously applied patches and returns 1,
which make treats as a failure.

Replace the phony patch target with a stamped `.patched` file so
the patch step is not re-run unnecessarily.

Fixes #3188

Signed-off-by: Shunchao Hu <ankohuu@gmail.com>
2026-04-03 11:18:21 +02:00
raiden00pl
5c867b21e6 examples/nxscope: control stream interval from CLI
add the ability to control the stream interval from the CLI
which is useful for performance testing

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-04-02 10:02:16 -03:00
simbit18
b8718d8c52 build.yml: Fix No files were found with the provided path
Fix

Warning: No files were found with the provided path: buildartifacts/.

Signed-off-by: simbit18 <simbit18@gmail.com>
2026-04-02 06:41:51 +08:00
wangjianyu3
073df9d1de examples/uvc_cam: add UVC camera streaming app
Usage: uvc_cam [nframes] [video_dev] [uvc_dev]

V4L2 capture -> write UVC gadget device.
Uses boardctl to initialize/deinitialize UVC gadget.
Queries sensor pixel format, resolution and frame rate via V4L2.
Uses poll() to wait for USB host streaming state.
Supports optional device path arguments (default /dev/video0, /dev/uvc0).
Supports configurable frame count (0=infinite).

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-03-30 14:52:06 +08:00
Tiago Medicci
dc4ecc973e ci: split xtensa jobs into three separate jobs (instead of two)
This is necessary because new defconfig were recently added to
Xtensa-based Espressif SoCs and the build job may exceed 2 hours.
In order to avoid increasing job timeout, a specific job for each
supported SoC (ESP32, ESP32-S2 and ESP32-S3) was created instead.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-03-28 09:40:28 +08:00
Vlad Pruteanu
cd2b0c0e87 testing/crypto: Add pbkdf2 test app
This adds support for testing PBKDF2 implementation. Test
vectors for SHA1 are taken from RFC6070. SHA256 vectors
were extrapolated using an online PBKDF2 generator which
was checked against RFC6070.

Signed-off-by: Vlad Pruteanu <pruteanuvlad1611@yahoo.com>
2026-03-27 21:46:08 +08:00
raiden00pl
e564816e1d .github: install NTFC from PIP
install NTFC package from PIP

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-03-27 20:37:09 +08:00
Filipe Cavalcanti
f3a7282230 netutils/cjson: fix apps path in CMake
Fix mismatch on apps directory naming when it is cloned under 'nuttx-apps' instead of 'apps'.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2026-03-26 20:18:52 -04:00
wangjianyu3
6a1b2c6903 system/nxrecorder: Fix null pointer dereference in argument parsing
When a command has no arguments (e.g., 'q', 'quit', 'stop'), the strtok_r()
function returns NULL for the arg parameter. The argument trimming loop was
dereferencing this NULL pointer without checking, causing undefined behavior
and system hang on ESP32-S3.

This commit adds a null check before dereferencing the arg pointer in the
leading space trimming loop.

Tested on ESP32-S3 (lckfb-szpi-esp32s3) - quit command now works correctly.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-03-26 10:42:48 +01:00
dependabot[bot]
509b807462 build(deps): bump docker/login-action from 3.7.0 to 4.0.0
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.7.0 to 4.0.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](c94ce9fb46...b45d80f862)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 4.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-24 13:00:16 +08:00
wangjianyu3
460281a90f system/fastboot: fix socket() parameter order for TCP transport
SOCK_CLOEXEC and SOCK_NONBLOCK were incorrectly passed as the
third argument (protocol) instead of being OR'd into the second
argument (type). This caused socket() to fail with EPROTONOSUPPORT
(errno 93) on NuttX.

Move SOCK_CLOEXEC | SOCK_NONBLOCK to the type parameter and set
protocol to 0.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-03-23 08:46:18 -03:00
raiden00pl
b986eef7a7 system/sensorscope: fix compilation
fix compilation error:

sensorscope_main.c:314:3: error: implicit declaration of function 'list_initialize'; did you mean 'fs_initialize'? [-Wimplicit-function-declaration]

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-03-23 11:00:44 +01:00
Lup Yuen Lee
5fe0877989 CI: Revert GitHub Actions for Docker
All CI Builds have been failing since 18 hours ago:
- https://github.com/apache/nuttx/pull/18571#issuecomment-4104792750
- https://github.com/apache/nuttx/actions/runs/23389990049

> _The action docker/login-action@v4 is not allowed in apache/nuttx because all actions must be from a repository owned by your enterprise, created by GitHub, or match one of the patterns: 1Password/load-secrets-action@13f58eec61, 1Password/load-secrets-action@8d0d610af1, 1Password/load-secrets-action@dafbe7cb03, AdoptOpenJDK/install-jdk@*, BobAnkh/auto-generate-changelog@*, DavidAnson/markdownlint-cli2-action@07035fd053, DavidAnson/markdownlint-cli2-action@30a0e04f18, EnricoMi/publish-unit-test-result-action@*, JamesIves/github-pages-deploy-action@4a3abc783e, JamesIves/github-pages-deploy-action@d92aa235d0, Jimver/cuda-toolkit@6008063726, Jimver/cuda-toolkit@b6fc3a9f3f, JustinBeckwith/linkinator-action@af984b9f30f63e796..._

That's because ASF Infrastructure Team has mandated that we use the Hash Versions of GitHub Actions for Docker, stated below:
- https://github.com/apache/infrastructure-actions/blob/main/actions.yml
- Which generates: https://github.com/apache/infrastructure-actions/blob/main/approved_patterns.yml
- Due to: https://github.com/apache/infrastructure-actions/pull/547

```yaml
docker/build-push-action:
  10e90e3645eae34f1e60eeb005ba3a3d33f178e8:
    tag: v6.19.2
docker/login-action:
  c94ce9fb468520275223c153574b00df6fe4bcc9:
    tag: v3.7.0
docker/metadata-action:
  c299e40c65443455700f0fdfc63efafe5b349051:
    tag: v5.10.0
docker/setup-buildx-action:
  8d2750c68a42422c14e847fe6c8ac0403b4cbd6f:
    tag: v3.12.0
```

This PR reverts our GitHub Actions for Docker to the hash versions stated above.

Signed-off-by: Lup Yuen Lee <luppy@appkaki.com>
2026-03-22 14:41:17 +08:00
raiden00pl
7884410be2 examples/nxscope: add UDP interface
add UDP interface for examples/nxscope

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-03-18 12:43:50 -03:00
raiden00pl
193fadfaa8 logging/nxscope: add UDP transfer interface
add UDP transfer interface for nxscope

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-03-18 12:43:50 -03:00
Neil Berkman
cb880b7257 boot/nxboot: remove unused header variable
The header variable in nxboot_perform_update() is no longer
used after validate_image() was changed to take only the fd.

Signed-off-by: Neil Berkman <neil@xuku.com>
2026-03-18 13:06:05 +01:00
Neil Berkman
83af0a011e boot/nxboot: update stale comment to reflect CRC validation
The comment previously stated CRC was not calculated before
boot. This is no longer accurate after adding full image CRC
validation in validate_image().

Signed-off-by: Neil Berkman <neil@xuku.com>
2026-03-18 13:06:05 +01:00
Neil Berkman
4decc1699a boot/nxboot: add flush barriers and CRC-validate primary before boot
Two hardening fixes for nxboot power-loss resilience:

1. Add flash_partition_flush() calls between critical partition
   operations in perform_update(). Without explicit flush barriers,
   writes may remain buffered in RAM (e.g. via FTL rwbuffer) when
   nxboot proceeds to the next phase. A power loss between phases
   can leave the recovery image uncommitted while the staging
   partition has already been consumed.

   Flush points added:
   - After copy_partition(primary, recovery) completes
   - After copy_partition(update, primary) completes, before
     erasing the staging first sector

2. Replace validate_image_header() with validate_image() in the
   final primary validation path of nxboot_perform_update(). The
   header-only check validates magic and platform identifier but
   does not CRC-check the image body. After an interrupted update,
   a corrupt primary with an intact header would pass this check
   and be booted, resulting in a persistent boot failure.

Signed-off-by: Neil Berkman <neil@xuku.com>
2026-03-18 13:06:05 +01:00
wangjianyu3
8cd9e9acc2 examples/camera: fix spelling errors
Fix typos found by codespell:
- camera_bkgd.c: defaul -> default
- camera_main.c: memorys -> memories (2 occurrences)
- camera_main.c: freame -> frame
- camera_main.c: valiable -> variable

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-03-16 17:45:24 +01:00
wangjianyu3
10056077f4 examples/camera: fix build error and still capture logic
Add missing #include <sys/boardctl.h> in camera_bkgd.c to fix
implicit declaration of boardctl() and undeclared BOARDIOC_NX_START.

Also fix capture_num check in camera_main.c to only apply still
capture size enumeration when capture_type is STILL_CAPTURE.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-03-16 17:45:24 +01:00
Filipe Cavalcanti
3a156581ca examples/rmtchar: fix source file ordering for RMTCHAR
rmtchar_main.c is coming after rmtchar_common.c, which causes an
undefined reference error. This change fixes the problem.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2026-03-15 15:42:00 -04:00
Huang Qi
ea22a66dcf tools: Fix target-pointer-width type in x86 target configs
Remove quotes around target-pointer-width values in i486 and x86_64
target configuration files to change from string to numeric type.
This change is required due to recent rustc JSON format modifications
that expect numeric values instead of strings for target-pointer-width.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-03-13 12:37:55 +01:00
Huang Qi
f90e1e184f tools/build: Make Rust target triples for x86 use JSON files
X86 support for Rust needs more test and verification, and not
upstreamed to Rust side yet.

It's better to use custom target triples for x86 by json files for now,
and it can be upstreamed to Rust side if stable enough.

Changed the Rust target triples in the CMake configuration to reference JSON files for x86_64 and i486 architectures. This improves the build process by providing more detailed target specifications.
* Added JSON files for i486 and x86_64 targets
* Updated CMake functions to use the new target triples
* Enhanced build directory structure for Rust crates

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-03-13 12:37:55 +01:00
Huang Qi
68f9e5424b codespell: Add ARCHTYPE to ignore list
ARCHTYPE is a valid abbreviation for 'architecture type' used
consistently across the codebase. This matches the nuttx repo's
.codespellrc configuration.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-03-10 18:23:22 -03:00
Huang Qi
b5d151f73f cmake/tools: Fix panic_immediate_abort deprecation in Rust build
Replace deprecated -Zbuild-std-features=panic_immediate_abort with
-Cpanic=immediate-abort compiler flag via RUSTFLAGS.

The panic_immediate_abort feature has been stabilized as a real panic
strategy in recent Rust nightly versions. The old method of enabling
it via -Zbuild-std-features is no longer supported and triggers a
compile error in core/src/panicking.rs.

Changes:
* cmake/nuttx_add_rust.cmake: Use RUSTFLAGS with -Cpanic=immediate-abort
* tools/Rust.mk: Use RUSTFLAGS with -Cpanic=immediate-abort

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-03-10 18:23:22 -03:00
Neil Berkman
8579459bb0 boot/nxboot: fix Clang warnings for format and va_start
Use PRIdOFF instead of %ld for off_t arguments in flash.c syslog
calls, fixing -Wformat errors when off_t is not long.

Change nxboot_progress parameter from enum progress_type_e to int
to avoid undefined behavior from va_start on a parameter that
undergoes default argument promotion (-Wvarargs).

Signed-off-by: Neil Berkman <neil@xuku.com>
2026-03-10 13:28:22 +01:00
dependabot[bot]
2964c8cc3d build(deps): bump docker/login-action from 3 to 4
Bumps [docker/login-action](https://github.com/docker/login-action) from 3 to 4.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-10 11:08:39 +01:00
dependabot[bot]
45d4c7098b build(deps): bump actions/download-artifact from 7 to 8
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 7 to 8.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v7...v8)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-04 16:38:39 +01:00
dependabot[bot]
af7222ec9f build(deps): bump actions/upload-artifact from 6.0.0 to 7.0.0
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-03 10:13:49 +01:00
Mihai Pacuraru
7d13ee204b examples/mqttc: Fix mqtt_init() failed message typo (ERRPR -> ERROR).
Modify the message logged when mqtt_init() failed to execute properly.

Signed-off-by: Mihai Pacuraru <mpacuraru@protonmail.com>
2026-03-02 17:14:44 +01:00
Mihai Pacuraru
c46ed184ed examples/mqttc: Fix QOS arguments parsing (char->long).
Modify the switch cases in parsearg function for QOS levels definition.
The comparison was made between a long value and a char.

Signed-off-by: Mihai Pacuraru <mpacuraru@protonmail.com>
2026-03-02 17:14:44 +01:00
ouyangxiangzhen
e4b84b29d4 ostest/hrtimer: Update the comments.
This commit updated the comments.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
256d6685d5 sched/hrtimer: Refactor the hrtimer_test.
This commit refactored the hrtimer_test and provided significantly
improved test-cases for both SMP and non-SMP.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
d33830e83f ostest/hrtimer: Increase the tolerent latency.
For QEMU, virtual CPUs can be preempted by any high priority thread in
test environments. This can cause the timer to be triggered later than
expected. This commit increased the tolerant latency to avoid the test
failures.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
0bbf5dc092 sched/hrtimer: Improve code readability
This commit improved the code readability.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
1c0281be15 sched/hrtimer: relocate the hrtimer test to simplify.
This commit relocated the hrtimer test to simplify the code.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
e69f9e902b sched/hrtimer: Fix test in QEMU.
This commit fixed the hrtimer test.
In a QEMU environment, the hrtimer latency can be arbitrary because vCPUs can be preempted. We can not assert the latency. we can only issue alerts for excessively high latency.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
9b84a0ab02 sched/hrtimer: Simplify the hrtimer test.
This commit simplified the hrtimer test.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
05e8b0ae60 ostest/hrtimer: Remove HRTIMER_TEST to simplify the code.
This commit removed HRTIMER_TEST to simplify the code.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
ouyangxiangzhen
da105afee2 ostest/hrtimer: Add missing assert.h
This commit added missing assert.h.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-26 13:42:45 -05:00
Matteo Golin
e0d118e349 examples/powerled: Fix board initialization compilation
When NSH_ARCHINIT is not enabled, initialization is to be performed by
boardctl(BOARDIOC_INIT). However, the boardctl header is not included so
this causes compilation to fail. This commit corrects that issue.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-02-26 12:10:01 +08:00
Eren Terzioglu
0b084ded88 testing/crypto: Add options to disable hash tests
Add options to disable individual hash tests for devices not supported each hash

Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
2026-02-24 13:36:32 +08:00
Lup Yuen Lee
fe546acfc7 github/workflow: Sync the new PR Labeling Workflow from NuttX Repo to NuttX Apps
This PR replicates the new PR Labeling Workflow from NuttX Repo to NuttX Apps Repo. For Future Syncing:
- Copy from NuttX Repo to NuttX Apps: `.github/workflows/labeler.yml` and `.github/workflows/pr_labeler.yml`
- Edit `.github/workflows/labeler.yml` and change `repository: apache/nuttx` to `repository: apache/nuttx-apps`
- Don't overwrite `.github/labeler.yml` by NuttX Repo

The new workflow reimplements PR Labeling with two triggers: pull_request and workflow_run. We no longer need pull_request_target, which is an unsafe trigger and may introduce security vulnerabilities.

The New PR Labeler is explained here:
- https://lupyuen.org/articles/prtarget
- https://github.com/apache/nuttx/issues/18359

Modified Files:

`.github/workflows/labeler.yml`: Changed the (read-write) pull_request_target trigger to (read-only) pull_request trigger. Compute the Size Label (e.g. Size: XS) and Arch Labels (e.g. Area: Examples). Save the PR Labels into a PR Artifact.

`.github/labeler.yml`: Added comment to clarify that NuttX PR Labeler only supports a subset of the `actions/labeler` syntax: `changed-files` and `any-glob-to-any-file`. Note: Don't overwrite this file by NuttX Repo.

New Files:

`.github/workflows/pr_labeler.yml`: Contains the workflow_run trigger, which is executed upon completion of the pull_request trigger. Download the PR Labels from the PR Artifact. Write the PR Labels into the PR.

Signed-off-by: Lup Yuen Lee <luppy@appkaki.com>
2026-02-23 20:33:22 +08:00
Matteo Golin
448b0bd0a6 interpreters: Fix spelling errors
Fix some spelling errors for CI.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-02-18 11:01:02 +01:00
Matteo Golin
3ce356378d !interpreters/python: Align naming of configuration options
Aligns `CONFIG_INTERPRETER_*` options to `CONFIG_INTERPRETERS_*` options
to be consistent with other interpreters.

BREAKING CHANGE: All configurations using `CONFIG_INTERPRETER_PYTHON_*`
options will no longer compile due to missing symbol errors. The fix is
very quick: any configurations using this options should add a trailing
S following INTERPRETER in the affected Kconfig variables. I believe
`./tools/refresh.sh` should also be capable of doing this automatically.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-02-18 11:01:02 +01:00
Matteo Golin
a604c46b00 !interpreters/minibasic: Align naming of configuration options
Aligns `CONFIG_INTERPRETER_*` options to `CONFIG_INTERPRETERS_*` options
to be consistent with other interpreters.

BREAKING CHANGE: All configurations using `CONFIG_INTERPRETER_MINIBASIC_*`
options will no longer compile due to missing symbol errors. The fix is
very quick: any configurations using this options should add a trailing
S following INTERPRETER in the affected Kconfig variables. I believe
`./tools/refresh.sh` should also be capable of doing this automatically.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-02-18 11:01:02 +01:00
Matteo Golin
468ded86bb !interpreters/lua: Align naming of configuration options
Aligns `CONFIG_INTERPRETER_*` options to `CONFIG_INTERPRETERS_*` options
to be consistent with other interpreters.

BREAKING CHANGE: All configurations using `CONFIG_INTERPRETER_LUA_*`
options will no longer compile due to missing symbol errors. The fix is
very quick: any configurations using this options should add a trailing
S following INTERPRETER in the affected Kconfig variables. I believe
`./tools/refresh.sh` should also be capable of doing this automatically.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-02-18 11:01:02 +01:00
Matteo Golin
be2cdfa597 !interpreters/bas: Align naming of configuration options
Aligns `CONFIG_INTERPRETER_*` options to `CONFIG_INTERPRETERS_*` options
to be consistent with other interpreters.

BREAKING CHANGE: All configurations using `CONFIG_INTERPRETER_BAS_*`
options will no longer compile due to missing symbol errors. The fix is
very quick: any configurations using this options should add a trailing
S following INTERPRETER in the affected Kconfig variables. I believe
`./tools/refresh.sh` should also be capable of doing this automatically.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-02-18 11:01:02 +01:00
Arjav Patel
76e02c0dd6 netutils/cjson: update cJSON download URL format
Modified CMakeLists.txt, Kconfig, and Makefile to change the cJSON download URL to include 'refs/tags/' for proper version fetching. This ensures compatibility with GitHub's archive download requirements.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-02-16 10:29:27 -03:00
Arjav Patel
1ab486d1d0 netutils/cjson: update download URL for cJSON tarball to include refs/tags
Modified the CMakeLists.txt and Makefile to ensure the correct format for downloading the cJSON tarball from GitHub by including 'refs/tags/' in the URL. This change addresses issues with fetching the correct version of the library.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-02-16 10:29:27 -03:00
Matteo Golin
7289c27a85 testing/{ostest,sched/smp}: Remove BOARD_LOOPSPERMSEC references
In an effort to avoid unexpected behaviour from users not calibrating
BOARD_LOOPSPERMSEC, a compilation error occurs when it is undefined. On
some systems, this is allowed (those that use timer implementations
instead of busy-looping for delays). In these cases, we should busy-loop
using the clock time instead of relying on a possibly
undefined/uncalibrated macro.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-02-09 09:21:50 +01:00
zhanghongyu
d48b45000d netlib_xarp: remove redundant cast
removes redundant type casts in ARP-related network library functions.
The casts from req.arp_dev (already a char array) to (FAR char *)
are unnecessary and can be safely removed.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-02-04 01:52:49 +08:00
fangpeina
bb9229de06 testing/drivers: set default vendor dalay to 1 for rtc cases run correctly
Set default VENDOR_DELAY to 1 for reliable test execution

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-02-03 17:36:49 +08:00
fangpeina
f9dc9bc21e testing: Fix cmocka_syscall_test crash when CONFIG_FDCHECK enable
Fix cmocka_syscall_test crash when CONFIG_FDCHECK is enabled.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-02-03 17:36:49 +08:00
fangpeina
eb9b9a2d60 netutils/rexecd: fix rpname mismatch with rexec when using AF_RPMSG
When using AF_RPMSG (-r option), rexecd was setting the rp_name
to the raw port number, while rexec was using htons(port). This
caused a mismatch where rexec couldn't connect to rexecd.

This commit fixes the issue by applying htons() to REXECD_PORT
when setting rp_name in the AF_RPMSG case, making it consistent
with the rexec client implementation.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-02-03 10:18:57 +08:00
hujun5
b2d4ad67b1 testing/ostest: Add performance event time counter test
Integrate up_perf_gettime() test into ostest suite with comprehensive
test coverage including monotonicity verification, interval statistics,
and frequency validation. The test verifies performance event counter
functionality across 5 independent test cases with proper error handling.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-02-02 14:01:00 +08:00
zhaoxingyu1
eda1309745 mtdconfig: modify config names for mtdconfig testcases 2
change nvs module testcase name TESTING_MTD_CONFIG_FAIL_SAFE
to TESTING_MTD_CONFIG_NVS and modify the configuration names
related to mtdconfig testing.

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-02-02 11:01:19 +08:00
zhaoxingyu1
d9d434d97e mtdconfig: lomtdconfig device change to depends on !MTD_CONFIG_NONE
Because  MTD_CONFIG configuration item in drivers/mtd/Kconfig
has changed.

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-02-02 11:01:19 +08:00
zhaoxingyu1
102c078834 mtd/nvs: modify config name to MTD_CONFIG_NVS part1
Because the MTD_CONFIG configuration item in
drivers/mtd/Kconfig has changed

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-02-02 11:01:19 +08:00
wangxingxing
2908f10154 apps/system/ymodem: Optimized ymodem for burn during bootloader
If device automatically enters the ymodem rb mode when it starts up,
the PC tool does not need to send rb command anymore. Here, when a
specified number of consecutive 'C' are received, the subsequent
ymodem protocol content will continue.

Signed-off-by: wangxingxing <wangxingxing@xiaomi.com>
2026-02-02 11:00:19 +08:00
anjiahao
8804f086b3 ymodem:sbrb.py send command need flush and reset input buffer
These changes fix reliability issues when initiating ymodem transfers
over serial connections.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-02-02 11:00:19 +08:00
makejian
367e9dca01 testing: move nist-sts into drivers/rng directory
Move NIST Statistical Test Suite (nist-sts) testing module from testing/drivers/
into testing/drivers/rng/ directory to better organize RNG (random number generator)
related tests that utilize /dev/random device.

Changes:
- Create testing/drivers/rng/ directory structure
- Move nist-sts from testing/drivers/ to testing/drivers/rng/nist-sts
- Update build configuration file paths:
  - CMakeLists.txt
  - Makefile
  - Make.defs
- Maintain all test patches and Kconfig settings

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-29 12:08:50 +08:00
liqinhui
b80d67c628 netutils/netinit: Support the NETINIT_MACADDR
Support getting MAC address from boardctl(BOARDIOC_MACADDR) via NETINIT_MACADDR.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2026-01-29 12:08:20 +08:00
wangxingxing
42e3566147 testing/fs:reduce the test time of fs test
Reduce TEST_NUM from 1000 to 100 in fs_opendir_test.c
Reduce loop count from 100 to 30 in fs_stream_test.c

Signed-off-by: wangxingxing <wangxingxing@xiaomi.com>
2026-01-28 10:37:52 -03:00
wangxingxing
f2ba4883fa testing/fs:remove the usleep of evend_fd read to solve the questiong of sem wait
Remove unnecessary usleep(1000) in the read thread of eventfd test.
The eventfd read operation will block and wait for data naturally via semaphore, no additional delay is needed.

Signed-off-by: wangxingxing <wangxingxing@xiaomi.com>
2026-01-28 10:37:52 -03:00
ligd
050fb406c2 testing/eventfd_test: avoid the orphan Thread
Replace sleep() with pthread_join() to properly wait for the child thread to finish, avoiding orphan threads.
Change sleep(1) to usleep(1000) to reduce test time while maintaining synchronization.
Fix loop iteration count mismatch between reader thread (6 iterations) and writer (5 iterations).

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-01-28 10:37:52 -03:00
guohao15
4ac3732734 testing/fdcheck: fix fd close in other thread
Fix file descriptor leak issue where fd was stored in test_state for deferred close, but could fail when CONFIG_FDCHECK is enabled because fd cannot be closed in a different thread.

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2026-01-28 10:37:52 -03:00
wangchengdong
ebe2dd57dd ostest/hrtimer: sync hrtimer ostest with latest hritmer update
sync hrtimer ostest with latest hritmer update

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-27 23:11:48 +08:00
ouyangxiangzhen
71561d2979 testing/ostest: run spinlock_test only in flat mode.
Since the kernel spinlocks can only work in flat mode, this commit
allowed spinlock_test only in flat mode.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
06d07b1522 testing/ostest: Fix Coverity for spinlock test.
This commit fixed coverity for spinlock test.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
5eef7f324f testing/ostest: refactor the spinlock test.
This commit refactored the spinlock test for better accuracy and
minimized jitters introduced by scheduling.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
anpeiyun
52c2a8909b ostest/spinlock: Check the return value.
This commit added checking for the return value.

Signed-off-by: anpeiyun <anpeiyun@xiaomi.com>
2026-01-27 22:59:36 +08:00
anpeiyun
f86246f7c6 ostest/spinlock: fix the operations does not affect the result.
When expanding the macro VERIY, (0 == pthread_barrier_wait(&param->pub->barrier)) < 0 always false.
Regardless of the value of its operands.

Signed-off-by: anpeiyun <anpeiyun@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
36e701448c ostest/spinlock: Check the return value.
This commit added checking for the return value.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
7fb71aa57a testing/drivers: Fix posix timer assertions.
On QEMU, if vcpus are preempted by other threads, the deviation of the
timer might be very large, causing assertion failure. This commit
addressed the problem.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
jiangtao16
1b8c90c12d ostest: Add spinlock/rspinlock.
This commit added spinlock/rspinlock test.

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
35cf746025 testing/drivers: Fix wrong test-cases.
This commit fixed totally wrong test-cases for the periodical timers.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
b9bf7f5c4f testing/drivers: Change uint32_t time to uint64_t.
This commmit fixed the time multiplication overflow issue.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
62fe1a3ac5 ostest/wdog: Fix a synchronizing bug.
If we updated `callback_cnt` before the `triggered_tick` in the wdog timer callback, the `wdtest_rand` might failed randomly. This commit fixed the synchronizing bug by swapping the execution order of updating.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
69bfda8736 apps/ostest: Fix wqueue_test in flat mode.
This commit re-enabled wqueue_test in flat mode.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
ce3e35233c benchmark/taclebench: Add clock measurement.
This commit added clock measurement for taclebench.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
429a65901f apps/testing: Fix timerjitter iteration
This commit used the interval to calculate the timejitter iteration.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
f687088453 apps/testing: Fix timerjitter interval
This commit increased the default interval of the timerjitter to avoid errors with large USEC_PER_TICK setting.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
e0e9f3d7e5 apps/testing: Fix Coverity.
This commit is to make Coverity happy.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
a16c545134 testing/drivers: Fixed the wrong test-case.
This commit fixed the wrong-test case where the time is acquired after
the timer being set, leading to the assertion failure.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
ae7a0d81e9 testing/drivers: Fix posix timer assertions.
On QEMU, if vcpus are preempted by other threads, the deviation of the
timer might be very large, causing assertion failure. This commit
addressed the problem.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
01e5e50619 testing/time: Relax the timing constraints.
On SIM and QEMU, it is inevitable that the simulating vCPU got preempted
by other threads, causing large timing delay. This commit relax the timing
constraints to reduce the CT error.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
a4b43521f4 testing/drivers: Fix posix timer assertions.
On QEMU, if vcpus are preempted by other threads, the deviation of the
timer might be very large, causing assertion failure. This commit
addressed the problem.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
ouyangxiangzhen
0faaed99a5 testing/drivertest: Fix timing issues on QEMU and sims.
Since sim and qemu are not cycle accurate simulators, if the vCPU thread is preempted by other high priority tasks, it may cause timing issues. This is easy to happen when the test machine is busy. This commit modifies the condition of timing error and prints out the latency as a warning.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-27 22:59:36 +08:00
hujun5
8aa48c4fb6 examples: foc: Add critical section protection to FOC control loop
Introduce CONFIG_EXAMPLES_FOC_CONTROL_CRITSEC configuration option to enable
critical section protection in the FOC (Field-Oriented Control) motor control
examples. This adds irq-safe critical sections around the main control loop
processing to prevent race conditions and ensure atomic updates of motor
control state and parameters during interrupt handling.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-27 20:48:04 +08:00
fangpeina
35f3690a4c nshlib: Add stderr redirection support
This commit implements stderr redirection in HSN, support
Bash-like syntax for redirecting standard error output.
Support both foreground and background commands.

example:
- nsh> ls noexists 2> err.log
- nsh> ls noexists 2> err.log &
- nsh> ls noexists 2>> err.log
- nsh> sh < /dev/ttyS0 > /dev/ttyS0 2> /dev/ttyS1 &
- nsh> sh < /dev/ttyS0 > /dev/ttyS0 2>&1 &

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-01-27 03:14:00 +08:00
hujun5
80c2b43197 testing/ostest: fix uninitialized variable warning in wdog test
Initialize the flags variable to 0 to fix compiler warning about
potential use of uninitialized variable. The flags variable is
conditionally assigned in wdtest_rand() based on callback count.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-27 03:09:24 +08:00
wangxingxing
9c022949e4 fs/test:Fix formatting check issues
fix the typo error of fs cases

Signed-off-by: wangxingxing <wangxingxing@xiaomi.com>
2026-01-26 22:09:19 +08:00
wangxingxing
2d2394201c fs/bugfix: fix the fd error of fs test
remove test_state of fs test cases

Removes unnecessary test_state structure usage for tracking file descriptors
Adds missing close(newfd) call in fs_dup_test.c to prevent file descriptor leaks
Simplifies test code by eliminating redundant fd tracking that could lead to incorrect resource management

Signed-off-by: wangxingxing <wangxingxing@xiaomi.com>
2026-01-26 22:09:19 +08:00
yukangzhi
71593dffad apps/system/trace: support binary dump of noteram
This patch adds support for dumping binary contents from noteram via the
`trace dump -b <file>` command. Changes include:

- Add a `binary` parameter to `trace_dump()` and the public header
  `system/trace/trace.h` to indicate binary output mode.
- Update `trace_dump()` to set the noteram read mode to binary using
  `NOTERAM_SETREADMODE` when requested.
- Update `trace dump` CLI parsing in `system/trace/trace.c` to accept
  the `-b` flag and pass it through to `trace_dump()`.
- Update usage/help text to include the new `-b` option.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-26 19:32:42 +08:00
hongfengchen
c69df55cd0 rexecd: fix type change
Fix cast from pointer to integer of different size to ensure
proper type conversion and avoid compilation warnings.

Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
2026-01-26 19:32:27 +08:00
tengshuangshuang
34e4d7eacd testing: add unistd.h for drivertest_touchpanel.c
Add unistd.h header file to drivertest_touchpanel.c to fix missing
sleep/usleep function declarations in touchpanel driver tests.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-26 19:32:27 +08:00
hongfengchen
d0e949cb24 testing: add unistd.h and pthread.h headers
Add unistd.h and pthread.h for memorystress_main.c, unistd.h for
dhm.c and cachetest_main.c, and pthread.h for kv_test_019.c to fix
missing declarations.

Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
2026-01-26 19:32:27 +08:00
hongfengchen
b56c785640 testing: add missing header files
Add missing header files in netutils and lsan modules to fix
implicit function declarations and improve compilation compatibility.

Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
2026-01-26 19:32:27 +08:00
hongfengchen
9a3778cb91 testing: add malloc.h for fstest.h
Add malloc.h header file to fstest.h to fix missing malloc/free
function declarations in filesystem test suites.

Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
2026-01-26 19:32:27 +08:00
dongjiuzhu1
854d00e49e system/uorb: uorb_listener add new features.
Add nonwakeup ways to using uorb_listener

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-26 19:31:45 +08:00
dongjiuzhu1
1f990388ec system/uorb: support non-wakeup subscribe.
default subscribing is wakeup.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-26 19:31:45 +08:00
hujun5
d1de009bc2 sched: inline enter_critical_section
Inline enter_critical_section function calls in performance-critical
paths to reduce function call overhead while maintaining consistent
semantics, improving overall system latency and responsiveness in
real-time scenarios.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-26 16:39:15 +08:00
Vlad Pruteanu
c883c3f6dd testing/drivers/crypto/hmac.c: Add long keys
This adds 2 tests, which include keys that are
longer than the SHA's block size.

Signed-off-by: Vlad Pruteanu <pruteanuvlad1611@yahoo.com>
2026-01-26 10:58:22 +08:00
mazhuang
5c822ea4d3 rpmsgsocket:add rpmsg socket test cases
Signed-off-by: mazhuang <mazhuang@xiaomi.com>
2026-01-24 17:07:42 +08:00
Jiri Vlasak
0e1ccbe35d license: Fix typo in LICENSE file
license: Fix typo in LICENSE file

Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
2026-01-23 11:05:48 -03:00
Jiri Vlasak
72f57fc34e netutils: Add BARE
BARE is a simple binary representation for structured application data.

cbare, the BARE implementation ported by this commit, is an I/O agnostic
C implementation of the BARE message encoding.

Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
2026-01-23 11:05:48 -03:00
guohao15
197401975a mtdconfig: support ram_mtdconfig device && lomtdconfig device
For nvs test in qemu

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2026-01-23 10:07:11 +08:00
likun17
a454cf4d94 system/uorb: uorb_listener flush functionality optimization.
uorb/listener:Added flush failure prompt information.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-23 10:01:33 +08:00
likun17
ada12ce175 system/uorb: uorb_listener adds new features.
uorb/listener.c: Added flush function.
aurora:/ # uorb_listener -f sensor_accel_uncal,sensor_mag_uncal,sensor_aaa
Waited for 5 seconds without flush complete event. Giving up. err:25

Result:
        Topic [sensor_mag_uncal0] flush: FAILURE. [-1]
        Topic [sensor_accel_uncal0] flush: SUCCESS.
Total number of flush topics: 1/2

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-23 10:01:33 +08:00
likun17
183deb66e9 system/uorb: uorb_listener adds new features.
add get sensor device information based on topic.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-23 10:01:33 +08:00
Bartosz Wawrzynek
f09d0b2e09 apps: Fix minor issues for latest toolchains
- crypto/mbedtls: Add -Wno-cpp flag to suppress warnings
- interpreters/quickjs: Add flags to suppress warnings
- lte/alt1250: Fix spelling issues in comments
- system/dd: Add missing includes for modern compilers
- system/zlib: Add -Wno-cpp flag
- testing/cxx: Include missing algorithm header

Signed-off-by: Bartosz <bartol2205@gmail.com>
2026-01-23 10:00:52 +08:00
fangpeina
715da6bde6 system/ymodem: fix send err when partial write
Fix buffer offset calculation in ymodem_send_buffer() to correctly
handle partial writes by advancing the buffer pointer and adjusting
the remaining size on each retry.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-01-23 09:43:22 +08:00
hujun5
19dcc896d7 sched/tcb: add a reference count to the TCB to prevent it from being deleted.
To replace the large lock with smaller ones and reduce the large locks related to the TCB,
in many scenarios, we only need to ensure that the TCB won't be released
instead of locking, thus reducing the possibility of lock recursion.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-22 11:06:12 -03:00
hongfengchen
b72f7997a3 system/popen: close newfd correctly
Fixes a bug where newfd is not properly closed when newfd[0] equals newfd[1].
This can cause file descriptor leaks in certain edge cases where the read
and write sides of the pipe are duplicated.

Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
2026-01-22 19:54:56 +08:00
wangzhi16
f16a45a854 examples/pipe: bugfix testcase of fifo
There are three bug in fifo testcase.

1. line 211 and line 295 should be nbytes not ret.
2. coverity report error:
CID 1667262: (#4 of 11): Double close (USE_AFTER_FREE)
11. double_close: Calling close(int) will close the handle fd that has already been closed. [Note: The source code implementation of this function has been overwritten by the built-in model.]

Double close will ocurr when line 234 is true and goto line 341, close again!
Now, Using the previous code logic, Use a tid and an errout_with_null_thread to avoid uninitialized problems.

3. since line 295 is used ret not nbytes, error not expose before.

When the end of read and write are opened, end of write will write successfully even if end of read not read.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-22 19:53:39 +08:00
wangzhi16
5c6d646d76 testing/fs: add testcase to test the stability of memfd.
Supplement ostest test cases.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-22 19:53:39 +08:00
wangzhi16
094b0f235a test/mutex: fix mutex testcases.
Multiple threads should use the same lock for resource protection.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-22 19:53:39 +08:00
yukangzhi
122a4a6f4e apps/examples/popen: Modify kconfig file
This test depends on !DISABLE_POSIX_TIMERS.

arm-none-eabi/bin/ld:
apps/examples/popen/libapps_popen.a(popen_main.c.obj):
in function `popen_main':
apps/examples/popen/popen_main.c:62:(.text.popen_main+0x1c):
undefined reference to `timer_create'

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-22 19:52:02 +08:00
yukangzhi
3c99bad310 crctest: Test the CRC library that the E2E depends on.
Test the CRC Library defined in the AUTOSAR specification

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-22 19:51:51 +08:00
tengshuangshuang
b6203955f9 syscall: fix listen case bug
Skip UDP listen test when CONFIG_NET_UDP is disabled to prevent
test failures on configurations without UDP support.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-22 19:48:57 +08:00
tengshuangshuang
338301de76 timerjitter: fix signal-cause error
Handle timer-delivered signals correctly to prevent assertions when
signal-related events occur during timing measurements.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-22 19:48:57 +08:00
tengshuangshuang
be26d79633 syscall: fix badfd test for fdcheck compatibility
Handle fdcheck path for badfd test to prevent unexpected dumps when
fdcheck is enabled, allowing proper testing of bad file descriptor
error cases.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-22 19:48:57 +08:00
tengshuangshuang
b86457dfcb apps/testing: fix syscall cases for fdcheck compatibility
Guard fdcheck-sensitive paths in setsocketopt, dup2, and fsync tests
to avoid assertion failures when fdcheck is enabled, ensuring tests
can properly verify error handling behavior.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-22 19:48:57 +08:00
tengshuangshuang
8afe3c0645 test: clean driver_audio_test (void *) cast
Drop unnecessary casts in driver_audio_test to silence compiler
warnings and improve code clarity.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-22 19:48:57 +08:00
tengshuangshuang
4df2ce98aa testing: fix net case bug
Adjust net socket test expectations for correct behavior to prevent
false test failures in network socket test cases.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-22 19:48:57 +08:00
tengshuangshuang
df48348fca test: fix timerjitter data style error
Fix timerjitter output formatting for date/time fields to match
expected format and improve test result readability.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-22 19:48:57 +08:00
tengshuangshuang
6249f22f97 tests: fix cache_test and arch_lib_test date style error
Correct date formatting in cache_test and arch_lib_test outputs to
ensure consistent date/time display format across test results.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-22 19:48:57 +08:00
tengshuangshuang
5216065fb8 cache_test: fix up_flash_dcache error
Fix flash dcache helper error handling in cache_test to properly
handle errors when flushing data cache operations fail.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-22 19:48:57 +08:00
likun17
8146403512 system/uorb: uorb listener bug fix.
Fixed the issue that instance+1 subscription will be triggered when
topic exists in this core

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-22 03:34:51 +08:00
tengshuangshuang
10873c6b59 testing: specify arch kconfig for testsuites
Specify architecture configuration in testsuites Kconfig to ensure
correct architecture-specific settings and build configurations.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-21 14:44:00 -03:00
tengshuangshuang
40a890626d testing: specify arch format Kconfig
Specify architecture format in Kconfig to ensure proper configuration
handling for different architectures in testing modules.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-21 14:44:00 -03:00
zhenwei fang
72fe4e21e1 nsh: fix nsh redirect fd double close
avoid double-close of redirection fds

Signed-off-by: zhenwei fang <fangzhenwei@bytedance.com>
2026-01-21 14:42:50 -03:00
Côme VINCENT
85b1a1c8c1 fix(macro): fix CAPIO_FREQUENCY macro typo
Going from CAPIOC_FREQUENCE to CAPIO_FREQUENCY according to nuttx/pull/16925

Signed-off-by: Côme VINCENT <44554692+comejv@users.noreply.github.com>
2026-01-21 16:59:08 +01:00
makejian
57ced95c07 crypto/openssl-wrapper: align SSL_CTX_new declaration with OpenSSL
Remove the extra rngctx parameter from SSL_CTX_new() to match
the standard OpenSSL API signature:
  SSL_CTX *SSL_CTX_new(const SSL_METHOD *method)

This improves compatibility with code written for OpenSSL.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-21 19:25:02 +08:00
makejian
690d8bddce crypto/openssl-wrapper: fix SSL error code mapping
Map mbedtls error codes to OpenSSL standard return codes in
SSL_connect/SSL_do_handshake:
- Return 1 on success
- Return 0 on controlled shutdown
- Return -1 on fatal error (was returning mbedtls error codes)

This aligns the return values with OpenSSL specification where
SSL_get_error() should be called to get the actual error reason.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-21 19:25:02 +08:00
makejian
825007aafb crypto/openssl-wrapper: export SSL_CTX_load_verify_file and SSL_CTX_load_verify_dir
Export SSL_CTX_load_verify_file() and SSL_CTX_load_verify_dir()
interfaces to allow loading CA certificates from file or directory.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-21 19:25:02 +08:00
makejian
22f85e8b61 benchmarks/fpu: improve timing precision to milliseconds
Change FPU benchmark timing from seconds to milliseconds for better accuracy.
This allows for more precise measurement of test cycles, especially for
shorter test runs that previously completed within a single second.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-21 07:43:09 -03:00
makejian
9148fb9718 benchmarks: Add Whetstone FPU benchmark
Add the Whetstone floating-point benchmark to NuttX applications.
The Whetstone benchmark is a widely-used tool for evaluating FPU
(floating-point unit) performance.

This benchmark is ported from netlib.org whetstone.c which has a
custom permissive license requiring attribution. Therefore it
depends on ALLOW_CUSTOM_PERMISSIVE_COMPONENTS.

Usage: whetstone [loops]

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-21 07:43:09 -03:00
Jiri Vlasak
37403210f9 netutils/nng: Update help for NETUTILS_NNG
NNG depends on options that, if not enabled, makes compilation or
runtime crashes. Noting these options in help helps to find out which
are such options.

Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
2026-01-21 09:48:11 +08:00
wangchengdong
5456849446 ostest/hrtimer: Add threaded hrtimer tests
Add threaded hrtimer tests

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-21 00:29:40 +08:00
wangchengdong
840c4fceef ostest/hrtimer: align hrtimer callback declaration
align hrtimer callback declaration with latest update of hrtimer

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-21 00:29:40 +08:00
wangchengdong
19dd2531fb testing/ostest: fix build issue
fix:

  Building NuttX...

  /d/a/nuttx-apps/nuttx-apps/sources/apps/Application.mk:238: target 'signest.c.d.a.nuttx-apps.nuttx-  apps.sources.apps.testing.ostest.o' given more than once in the same rule

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-20 17:01:42 +01:00
guoshichao
755fae7ac1 system/cu: merge the cu.h to cu_main.c
Merge the cu.h header file contents into cu_main.c to simplify the
code structure. The cu_globals_s structure and related definitions
are now directly in cu_main.c.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-20 10:23:34 +01:00
makejian
ddc699a4f3 system/cu: fix signal handler to use sa_sigaction
The sigint() function uses siginfo->si_user but was declared with
only one parameter (int sig). This causes compilation error because
siginfo is undeclared.

Fix by:
1. Rename sigint to cu_exit with proper sigaction signature
2. Use sa_sigaction instead of sa_handler to receive siginfo_t
3. Pass cu pointer via sa.sa_user for signal handler access

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-20 10:23:34 +01:00
wangchengdong
d9afe2db8c signals: fix build and runtime issues when signals all isabled
Fix build and runtime issues when signals all disabled.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-19 22:55:19 +08:00
zhanghongyu
9c85568c4f icmpv6_ping.c: change socket type from SOCK_DGRAM to SOCK_RAW.
standardize the implementation of ping6 to better comply with socket
permissions on certain systems.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-19 22:52:06 +08:00
makejian
d2902008fe openssl-wrapper: fix code style compliance
Fix coding style issues in OpenSSL/MbedTLS wrapper implementation:
- Align whitespace and indentation
- Fix line formatting
- Ensure consistent code style per NuttX standards

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-19 22:51:14 +08:00
makejian
bafe30898a openssl-wrapper: mapping more error code whitin mbedtls and openssl when ssl error
VELAPLATFO-66562

Change-Id: Ibb1446a7fcae1d2bc09d75052466a6ce084103b8
Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-19 22:51:14 +08:00
makejian
49e2592e34 openssl-mbedtls-wrapper: export SSL_ASSERT* macro
VELAPLATFO-62586

Change-Id: I2ceac930c87196a16ea7ddf5e4130bb991b51025
Signed-off-by: makejian <makejian@xiaomi.com>
(cherry picked from commit d0547662d5006ec0a348d89d3d7e251ef4bb183c)
2026-01-19 22:51:14 +08:00
makejian
94ffd5e9f0 openssl_wrapper_mbedtls: extend openssl interfaces in ssl module for mqtt
VELAPLATFO-62586

Change-Id: I3b56b028e76aee118ed90211c097ac3fe86bc129
Signed-off-by: makejian <makejian@xiaomi.com>
(cherry picked from commit 7a567e98489f64b740044b9ce4066fa8d41af359)
2026-01-19 22:51:14 +08:00
makejian
33d5062ba6 openssl_wrapper_mbedtls: support bio interfaces in openssl
VELAPLATFO-62586

Change-Id: I5d7675c05dc3a52c1cb15a6132b969a19f848248
Signed-off-by: makejian <makejian@xiaomi.com>
(cherry picked from commit 409c86a062a816b56a3a48b1111102d12f24a48f)
2026-01-19 22:51:14 +08:00
guoshichao
782de2748f cu: implement the cu exit logic like top cmd
using the local cu_globals_s instance to manange the cu exit procedure

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-19 22:48:25 +08:00
guanyi3
a75fa37090 usrsocktest: fix TEST_ASSERT_EQUAL fail for POLLIN
This assertion should be removed because the POLLIN event is now only
raised when there is data pending to be received. Previously, POLLIN
was incorrectly set as soon as the connection was established, even
when no data was available, which was not consistent with the expected
behavior.

Signed-off-by: guanyi3 <guanyi3@xiaomi.com>
2026-01-19 22:46:45 +08:00
wangchengdong
df30f84f33 ostest/hrtimer: sync hrtimer test with latest updates
Synchronize the hrtimer ostest with the latest hrtimer changes.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-19 08:37:08 -03:00
guoshichao
5595a01fcd watchdog: disable the drivertest_watchdog_api testcase on some platform
When we support the watchdog interrupt on the Armv7-A platform with
the TEE enabled, the watchdog interrupt needs to be configured as
a FIQ to avoid the impact of interrupt disabling in the AP.
In this case, the drivertest_watchdog_api testcase cannot pass the
test in such a scenario.

This is because the drivertest_watchdog_api itself requires
calling a specified callback after the watchdog interrupt is
triggered, instead of directly dumping the AP's context and
then asserting the system.

Therefore, when both CONFIG_ARCH_ARMV7A and CONFIG_ARCH_HAVE_TRUSTZONE
are enabled, we need to skip the current drivertest_watchdog_api
testcase.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-19 17:51:42 +08:00
liqinhui
45a6b0365c netutils/ping: Support ICMP filter for ping.
Add setsockopt support to filter ICMP packets.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2026-01-19 14:09:31 +08:00
makejian
056ba984e8 tinycrypto: add unix as compile flags to use dev/random
Add UNIX platform flag to tinycrypto build configuration to enable access to /dev/random for secure random number generation.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-19 14:07:21 +08:00
likun17
ed7bb51b14 system/uorb:unit_test bug fix
Fixed the error message caused by inconsistent definitions of pthread_t on different platforms.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-19 12:22:40 +08:00
dongjiuzhu1
7ba3638507 system/uorb: merge set_info to orb_advertise_multi_queue_info.
support new api: orb_advertise_multi_queue_info to advertise topic
with info

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-19 12:22:40 +08:00
likun17
3d97bf02e4 system/uorb:Loop bug fix
Fixed the epoll issue that when multiple events come only the first POLLIN is entered.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-19 12:22:40 +08:00
zhangshuai39
11c8220fd5 netlib: Replace perror with nerr
Use the nerr interface for error print.

Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
2026-01-17 12:09:13 +08:00
zhanghongyu
faefee4897 MQTT-C: compile tests only if no with_mbedtls is enabled
tests only supports tests in non-encrypted mode. when we open tests
compilation in other modes, there will be many compilation warning
with mismatched parameter types, and it will not run correctly.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-16 21:12:36 +08:00
gaohedong
54bef649ea net/ptpd: fix compile warning issue
In some scenarios, dynamic memory allocation is not allowed, so it is modified to a static allocation method.

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2026-01-16 21:12:22 +08:00
guoshichao
e804886c68 libuv: fix sendmsg parameter type in NuttX port
Update the libuv NuttX port patch to change sendmsg() parameter from
"struct msghdr *msg" to "const struct msghdr *msg" in the NuttX-specific
implementation stub. This maintains compatibility after NuttX's socket API
was made POSIX-compliant with const-correct parameters.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-16 21:10:55 +08:00
guoshichao
0a90fe5167 benchmarks/ramspeed: add cmake build support
Add CMakeLists.txt for the RAMSpeed benchmark application, enabling it to
be built with the CMake build system alongside the existing Makefile-based
build. This ensures consistent build behavior across build systems.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-16 21:09:07 +08:00
zhanghongyu
c62d0d0875 netlib_setarp.c: add ATF_PERM to mark arp entry as permanent
Improve the behavior of the ARP table so that the manually configured
ARP table has the highest priority, can only be manually modified to
other values, otherwise will never change again, and will not time out.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-16 21:08:26 +08:00
anjiahao
63e2650487 elf:avoid interference between different ELFs generated by symtab
if defined CONFIG_EXAMPLES_ELF and CONFIG_EXAMPLES_MODLUE,
elf will generated BINDIR, so generated symtab will interference.
It supports inputting multiple specified files in mksymtab.sh to
avoid interference.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-01-16 21:07:56 +08:00
v-tangmeng
6630c08783 examples/elf: add support for CONFIG_DISABLE_SIGNALS
make the example elf can work with SIGNAL disabled

Signed-off-by: v-tangmeng <v-tangmeng@xiaomi.com>
2026-01-16 21:07:56 +08:00
anjiahao
27e0811312 elf:Delete unnecessary generation, elf does not use kernel api
delete the mod_symtab.c generate procedure

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-01-16 21:07:56 +08:00
anjiahao
91f55245eb apps:modify examples elf compile method
rearrange the elf test directory, make the sub-testcase in separate
directory

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-01-16 21:07:56 +08:00
zhanghongyu
2b0a4a20f5 iptables: add file lock to prevent concurrent overwrite
the kernel can only prevent the concurrency of s/getsockopt, but
iptables will call these interfaces multiple times at a time. We
need to wait for one iptables to complete before executing the second
one, otherwise the data will be overwritten.

iptables flow:
get current iptables entries [1] -> add new entry 2 [1,2] -> set to kernel [1,2]
get current iptables entries [1] -> add new entry 3 [1,3] -> set to kernel [1,3]
entry 2 is lost

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-15 17:20:03 +08:00
daichuan
859fc54c96 netutils/ping: change socket type to SOCK_RAW
The ping socket creation method is changed from SOCK_DGRAM to SOCK_RAW,
because SOCK_DGRAM may not have permission in some environments (e.g. Docker).
Also add checksum calculation when send, and perform IP header processing when receive.

Signed-off-by: daichuan <daichuan@xiaomi.com>
2026-01-15 17:19:29 +08:00
zhanghongyu
5f634815cb iptables: fix the ipv4 mask conversion error
the configured mask should be in network byte order, but the logic here
calculates it as host byte order.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-15 17:12:03 +08:00
zhanghongyu
3e3b8c6936 graphics/libyuv: fix the typo.
fix the typo.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-15 16:46:40 +08:00
wangchengdong
60d814efa2 sched/signal: Add support to disable partial or all signals
Fix dependency issue when signals are partially or fully enabled

Co-authored-by: guoshichao <guoshichao@xiaomi.com>
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-15 15:48:54 +08:00
zhaoxingyu1
26fcdbd9ad mtdconfig/nvs: fix typo error in nvs testcase
such as: 2st->2nd, 3st->3rd and so on

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-15 10:26:21 +08:00
zhaoxingyu1
32facd5b3a mtd/nvs: testcases fit the situation where erasestate is 0
Special_id dynamically adjusts based on erase value

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-15 10:26:21 +08:00
zhaoxingyu1
58c2473b38 apps/testing: nvs testcases support remove align size
mtd/nvs removes CONFIG_MTD_WRITE_ALIGN_SIZE,
testcases need to be modified meanwhile

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-15 10:26:21 +08:00
gaohedong
af8ff17f95 netlib: fixed compilation issues
fixed compilation issues

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2026-01-15 10:26:02 +08:00
haopengxiang
680dca1121 ltp: close mq_close/3-1 testcase when open CONFIG_FDCHECK
Caused the cause will used after free on fd

Signed-off-by: haopengxiang <haopengxiang@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-01-15 10:25:21 +08:00
ligd
429f24afbd ltp: close mq_close/4-1 testcase when open CONFIG_FDCHECK
Caused the cause will used after free on fd

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-01-15 10:25:21 +08:00
ligd
b7b2ba37a1 timer_test: reduce the sleep time to improve testing efficiency
reduce the sleep time

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-01-15 10:25:21 +08:00
jingfei
97545f6ff9 ymodem:rb of ymodem add prefix and suffix for download file name
Adding parameters to rb main can add prefixes and suffixes
to the file names to be downloaded

Signed-off-by: jingfei <jingfei@xiaomi.com>
2026-01-15 01:24:17 +08:00
liucheng5
58326d39dc system/uorb: add a new uorb topic ENG
Add a new uorb topic for ENG sensor

Signed-off-by: liucheng5 <liucheng5@xiaomi.com>
Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-14 10:49:28 -05:00
meijian
b0b90ac728 apps/net: add http connectivity check API
Add netlib_check_httpconnectivity() to verify HTTP service connectivity by sending GET request and validating status code.

Signed-off-by: meijian <meijian@xiaomi.com>
2026-01-13 10:55:40 +08:00
raiden00pl
a22bf844cd .github/build.yml: fix python venv installation
install venv package in one command to avoid issues with ubuntu mirrors

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-01-12 11:04:21 -05:00
Matteo Golin
8d4e872402 !testing/cmocka: Compile cmocka as a libary only by default
BREAKING CHANGE

This commit introduces a Kconfig switch to include the cmocka binary
built from cmocka_main.c. The default behaviour is now changed so that
cmocka is built as a library only, which would be the desired behaviour
for users creating their own cmocka projects.

To restore the old behaviour (where the cmocka program is compiled), add
CONFIG_TESTING_CMOCKA_PROG=y to your legacy configuration.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-01-12 10:14:55 +08:00
shichunma
7daac30cb4 system/iptables: avoid trap when running "iptables -L"
A trap occurs every time CONFIG_NET_NAT is enabled while CONFIG_NET_IPFILTER is not.

Signed-off-by: Jerry Ma <masc2008@gmail.com>
2026-01-11 15:07:15 -05:00
gaohedong
d594c953a1 net/vlan: fix issue of vlan pcp config
Fix a issue of vlan pcp config.
`vconfig add eth0 10` will create eth0.10 with VID=10 and no PCP(0)
`vconfig add eth0 10 3` will create eth0.10 with VID=10 and PCP=3

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2026-01-12 00:55:47 +08:00
hujun5
21f4156048 sighand: need block WAKEUP_SIGNAL in current tcb
If the main thread receives the signal, the waiter_main will not be awakened.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-12 00:55:33 +08:00
Huang Qi
4e8a0ae4c4 style: Fix coding style violations in nuttx-apps
Fix various coding style issues including:
- Case statement formatting
- Include placement and ordering
- Whitespace issues
- Long line formatting
- Bracket alignment

Affected modules:
- audioutils, examples, include
- netutils, system

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-01-12 00:54:48 +08:00
zhangshuai39
63f61d080a netutils/ntpclient: Fix a large number of print DNS request errors
Before attempting to sample via NTP, network connectivity should be checked to avoid frequent sampling that could cause network error logs to overflow.

Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
2026-01-11 15:57:05 +08:00
zhangshuai39
13a019450a netlib: Add an empty macro definition to the two connectivity functions
The `netlib_check_ipconnectivity` and `netlib_check_ifconnectivity` functions depend on the `NETUTILS PING` configuration item. When `NETUTILS PING` is not enabled, a compilation error will occur; therefore, an empty macro definition is added.

Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
2026-01-11 15:54:38 +08:00
meijian
c61fb846d7 apps/net: add if network conntivity check API
Perform connectivity testing on the specified network interface card.

Signed-off-by: meijian <meijian@xiaomi.com>
2026-01-09 14:03:20 +08:00
Zhe Weng
10eae1dc6b vconfig: Support setting default PCP when creating VLAN
Now we allow setting a default PCP when creating VLAN like:
`vconfig add iface-name vlan-id [pcp]`
e.g.
`vconfig add eth0 10` will create eth0.10 with VID=10 and no PCP(0)
`vconfig add eth0 10 3` will create eth0.10 with VID=10 and PCP=3

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2026-01-08 22:51:19 +08:00
Zhe Weng
ae7c168bf6 nshlib: Add vconfig command
Add vconfig command

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2026-01-08 22:51:19 +08:00
mazhuang
9c4103d496 nsh_syscmds/rpmsg: add rpmsg test command support
User can use rpmsg test /dev/rpmsg/<cpuname> to test the rpmsg
channel

Signed-off-by: mazhuang <mazhuang@xiaomi.com>
2026-01-08 22:50:11 +08:00
buxiasen
1512f9c6e5 netlib/ping: fix the stack variable not initialized.
We add devname in ping_info_s, but not initializeed, cause
data abort as value in stack possible not NULL.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-01-07 11:58:13 +08:00
wangchengdong
416c315f92 ostest: sync hrtimer ostest with hrtimer updates
Update the hrtimer ostest to reflect recent changes in the hrtimer
implementation.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-07 09:44:42 +08:00
Huang Qi
73bc5cbcc6 interpreters: Add mquickjs JavaScript interpreter integration
Add complete integration for the MicroQuickJS JavaScript interpreter,
supporting both CMake and Make build systems with automatic source
acquisition.

Key features:
* FetchContent downloads mquickjs from bellard/mquickjs if local
  git repository is not available in interpreters/mquickjs/mquickjs/
* Builds mqjs_stdlib host tool to generate mqjs_stdlib.h and
  mquickjs_atom.h headers during build
* Creates libmquickjs library with proper header generation dependencies
  to prevent parallel build failures
* Provides mqjs NSH application for interactive JavaScript execution
* Configurable task priority and stack size via Kconfig options
  (INTERPRETERS_MQJS_PRIORITY, INTERPRETERS_MQJS_STACKSIZE)
* Supports both 32-bit and 64-bit architectures with appropriate build flags

Files added:
* CMakeLists.txt - CMake build configuration with FetchContent support
* Kconfig - Configuration options for interpreter features
* Make.defs - Make build definitions
* Makefile - Alternative Make-based build support
* .gitignore - Ignores generated files and local mquickjs source directory

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-01-07 09:44:19 +08:00
Felipe MdeO
ca11a7e093 system/smf: Port SMF .c/.h files to NuttX
This commit add state machine framework lib to the NuttX project. Also an example is added to help users understand and use this feature.

Changes: Added some files. No impact in other features are expected.

Adjust SMF macro names

Fix issues requested during MR review

update kconfig

fix ci-cd issue

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
2026-01-05 12:50:04 -05:00
Zhe Weng
4f93ec0a43 pkt: Set sll_protocol for raw socket to ETH_P_ALL
Ref: https://man7.org/linux/man-pages/man7/packet.7.html

We should either set protocal when creating socket or binding, otherwise
we cannot capture any packet.

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2026-01-04 21:41:21 +08:00
buxiasen
157ecb091d iperf: compatible work with no IPv4
We possible want to use iperf to test rpmsg socket etc.

Fix error when enable iperf and no IPv4
```
arm-none-eabi-ld: warning: ~/nuttx/nuttx has a LOAD segment with RWX permissions
arm-none-eabi-ld: ~/nuttx/staging/libapps.a(iperf_main.c.~.apps.netutils.iperf_1.o): in function `iperf_main':
~/apps/netutils/iperf/iperf_main.c:248:(.text.iperf_main+0x330): undefined reference to `inet_ntoa_r'
arm-none-eabi-ld: ~/apps/netutils/iperf/iperf_main.c:240:(.text.iperf_main+0x354): undefined reference to `netlib_get_ipv4addr'
arm-none-eabi-ld: ~/nuttx/staging/libapps.a(iperf.c.~.apps.netutils.iperf_1.o): in function `iperf_print_addr':
~/apps/netutils/iperf/iperf.c:226:(.text.iperf_print_addr+0x3c): undefined reference to `inet_ntoa'
```

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-01-04 00:06:17 +08:00
buxiasen
188838469c kernel/syscall: fix required INET may case no support
We may possible enable socket and no ipv4

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-01-04 00:06:17 +08:00
meijian
3467f9b82d apps/net: add ip address connectivity check API
The system checks connectivity with the input IP address; if no IP address is provided, it defaults to checking DNS server connectivity.

Signed-off-by: meijian <meijian@xiaomi.com>
2026-01-04 00:05:38 +08:00
dongjiuzhu1
150c5756a0 examples/capture: support monitor edge change by signal
add monitor code about edge change

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-03 23:51:26 +08:00
zhangshuai39
6830e297cf dhcpd: Supports kernel mode compilation
The previous method of terminating the dhcp daemon via a global variable has been removed; instead, the `kill pid` command is used. Also, because the original `dhcp_start` method creates tasks via `task_create`, which is not supported in kernel mode, `dhcp_start` is not compiled in kernel mode. The daemon can be started in kernel mode using `dhcpd xxx &`.

Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
2026-01-02 12:29:42 -03:00
nuttxs
9ad4c3c395 netutils/dhcpc.h: fix the compilation error caused by undefined
CONFIG_NETDB_DNSSERVER_NAMESERVERS

Provide a default value for CONFIG_NETDB_DNSSERVER_NAMESERVERS if
CONFIG_NETDB_DNSCLIENT is not enabled

Signed-off-by: nuttxs <zhaoqing.zhang@sony.com>
2026-01-02 14:12:10 +01:00
p-szafonimateusz
85539a1223 github/ci: add support for NTFC
Add support for NTFC testing framework.

At the moment NTFC is downloaded from a private repo,
and installed with pip and venv. In the future NTFC repositories
will be migrated to Apache organization.

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-12-31 16:33:10 -03:00
dongjiuzhu1
c90b64ed8b nshlib/ls_handler: eliminate floating-point operations for human-readable sizes
Replace floating-point arithmetic with fixed-point integer math to avoid
linking soft-float library (~2-3KB Flash) when displaying human-readable
file sizes (ls -lh command).

Changes:
- Use integer division and modulo to calculate size components
- Calculate decimal part: (remainder * 10) / unit for one decimal place
- Refactor duplicated code: consolidate GB/MB/KB logic into single path
- Remove CONFIG_HAVE_FLOAT dependency

This eliminates calls to __aeabi_f2d, __aeabi_fmul, __aeabi_i2f and other
ARM EABI floating-point helpers, reducing Flash footprint for systems
compiled with -mfloat-abi=soft.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-31 16:32:27 -03:00
zhangkai25
710aef6bd0 iperf: Increase the priority of the report thread
ensure it is not blocked by the iperf thread, preventing iperf from completing

Signed-off-by: zhangkai25 <zhangkai25@xiaomi.com>
2025-12-30 19:51:57 +08:00
dongjiuzhu1
e5c85d1ca2 netutils/ptpd: Add switch correction time change
The current gPTP stack does not support path delay correction of the Switch.
This patch adds the path delay correction field in the Header.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
03ca9ba500 netutils/ptpd: using -B to control BMCA message
new option -B to BMCA message

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
54cbc2ee0d netutils/ptpd: support PTP ethernet transport
support ptp by rawsocket

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
65d29de0f7 netutils/ptpd: add NET_PKT to enable PTP
support ptp clock device

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
54d55fe5f4 netutils/ptpd: add NETUTILS_PTPD_ADJTIME_THRESHOLD_NS to accelerate adjustment
optimize the speed of adjustment

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
d3504bf9b3 netutils/ptpd: support adjtime for ptp device
support ptp clock deivce to adjust time

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
4426ce733a netutils/ptpd: using dynamic config to config clien-only mode and delaye2e
fix compile warning when only enable PTPD_CLIENT or PTPD_SERVER

ptpd.c:493:38: error: 'CONFIG_NETUTILS_PTPD_PRIORITY1' undeclared (first
use in this function); did you mean 'CONFIG_NETUTILS_PTPD_CLIENT'?

ptpd.c:494:39: error: 'CONFIG_NETUTILS_PTPD_CLASS' undeclared (first use
in this function); did you mean 'CONFIG_NETUTILS_PTPD_CLIENT'?

ptpd.c:495:39: error: 'CONFIG_NETUTILS_PTPD_ACCURACY' undeclared (first
use in this function); did you mean 'CONFIG_NETUTILS_PTPD_DEBUG'?
ptpd.c:498:38: error: 'CONFIG_NETUTILS_PTPD_PRIORITY2' undeclared (first
use in this function); did you mean 'CONFIG_NETUTILS_PTPD_CLIENT'?

ptpd.c:502:36: error: 'CONFIG_NETUTILS_PTPD_CLOCKSOURCE' undeclared
(first use in this function); did you mean
'CONFIG_NETUTILS_PTPD_STACKSIZE'?

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
5d34a0906a netutils/ptp: destroy donesem at the end of ptpd_status
fix minor issue

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
Xiang Xiao
832e61c1c4 netutils/ptpd: Add the missing comparison in is_better_clock
The original implementation only checked if each field was less than,
but didn't check for greater than before proceeding to the next field.
This caused incorrect clock selection behavior in the PTP Best Master
Clock Algorithm (BMCA).

The fix expands each comparison to explicitly check both < and >
conditions, returning the appropriate result immediately. This ensures
proper precedence evaluation according to IEEE 1588 specification:
- gm_priority1
- gm_quality (class, accuracy, variance)
- gm_priority2
- gm_identity

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
e718fdd2c6 netutils/ptpd: get nanoseconds by SO_TIMESTAMPNS to satisfy higher precision
using nanoseconds as timestamp

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
4411a41bc2 netutils/ptpd: using hardware_ts to replace CONFIG_NET_TIMESTAMP
runtime to config the ways of timestamp

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
ac881e5108 system/ptpd: provide more parameter by struct ptpd_config_s when starting ptpd
origin command change to new command:
ptpd start interface & -> ptpd -i eth0 &
ptpd stop pid          -> ptpd -d pid
ptpd status pid        -> ptpd -t status

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
28302ae7d7 system/ptpd: using main task to replace new task
new starting command:
ptpd start interface &

we should run it in background ways

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
d1f59bef8e netutils/ptpd: using DEBUG_PTP_ERR/WARN/INFO to replace NETUTILS_PTPD_DEBUG
using new ptp clock device debug function

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
e4ddfdeed1 netutils/ptpd: byte align for ptp structure
pass structure between remote and local core

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
dongjiuzhu1
3ddda82313 netutils/ptpd: add CMakelist for ptpd
support cmake build

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-30 08:51:51 -03:00
Zhe Weng
40c7982816 netlib: Add support for adding/removing VLAN device
Add support for adding/removing VLAN device

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2025-12-30 11:17:38 +08:00
zhangkai25
b2f7ead2dd apps/examples/udp: Update CMAKEList.txt for UDP tests under CMAKE
add Update CMAKEList.txt for UDP tests under CMAKE

Signed-off-by: zhangkai25 <zhangkai25@xiaomi.com>
2025-12-29 22:34:52 +08:00
zhangkai25
1ca7838482 apps/testing: add cmock_test for enet in order to test send and receive pkt
add cmock_test for enet in order to test send and receive pkt

Signed-off-by: zhangkai25 <zhangkai25@xiaomi.com>
2025-12-29 22:30:56 +08:00
Matteo Golin
39310946ec testing/nuts: NuttX Unit Test Selection (NUTS) application.
Introduces a collection of unit tests for NuttX, built on top of the
cmocka framework. Tests are organized into suites/groups which can be
individually included/excluded from the build using Kconfig. Output is
easily legible and separated with headers including the test group name.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2025-12-28 10:28:14 +08:00
meijian
9da2bc0696 apps/net: add get iobinfo api
Obtain detailed IOB information by parsing the /proc/iobinfo file.

Signed-off-by: meijian <meijian@xiaomi.com>
2025-12-25 12:27:27 -05:00
wangchengdong
fb4f80665d ostest/hrtimer: Fix typos
The current code incorrectly used the CONFIG_SCHED_EVENTS
macro in ostest.h for hrtimer_test(). This has been corrected to use CONFIG_HRTIMER.

Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
2025-12-25 23:06:42 +08:00
zhangshuai39
09ddb06c9d dhcpd: Align makefile implementation
Improve the CMakeLists.txt to achieve the same compilation results as Makefile.

Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
2025-12-25 11:17:17 -03:00
gaohedong
9f035ea0be qnet/wireless: fix compile warning of i8sak
fix tasking compile warning isssue
warnning log:  undefined reference to 'g_ieee802154_status_string'

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2025-12-25 18:05:23 +08:00
gaohedong
9dc6781bf9 net/wireless: dup g_ieee802154_status_string from kernel
dup g_ieee802154_status_string from kernel to fix cmopil issue

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2025-12-25 18:05:23 +08:00
gaohedong
de6aac8afb net/wireless: fix compile warning
fix tasking compile warning isssue
warnning log: unused variable "IEEE802154_STATUS_STRING"

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2025-12-25 18:05:23 +08:00
gaohedong
74c71145da net/ethernet: ARP can be configured on interface
ARP can be configured on interface

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2025-12-25 12:25:02 +08:00
gaohedong
b56795e1e2 net/ping: utils ping should depends on ipv4
utils ping should depends on ipv4

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2025-12-25 12:24:30 +08:00
wangchen
f89773cbc8 ping: Initialize info.devname to NULL
Initialize info.devname to NULL to solve the problem of the SO-BINDTODEVICE property being set incorrectly in the icmp_ping function

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2025-12-25 12:24:04 +08:00
meijian
5d3b2d07d6 ping: add -I for bind device
Add -I option to specify the network device to use for sending ICMP
echo requests. This allows users to explicitly bind ping to a
specific network interface, which is particularly useful in
multi-homed systems with multiple network interfaces.

Signed-off-by: meijian <meijian@xiaomi.com>
2025-12-25 12:24:04 +08:00
zhangshuai39
532a055abb paho_mqtt: Add mqtt compilation files
It provides the necessary compilation files and configuration management files, and offers a publish demo and a subscribe demo

Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
2025-12-25 12:20:17 +08:00
zhangshuai39
de87836c7a netpkt: Add parameters to support specific network cards
Supports sending and receiving data packets on specified interfaces.

Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
2025-12-25 09:45:30 +08:00
meijian
4b3070c081 apps/net: add ip conflict check API
Supports checking for IP conflicts on a NIC.

Signed-off-by: meijian <meijian@xiaomi.com>
2025-12-25 09:44:47 +08:00
zhanghongyu
837c27d6e3 netutils/libwebsockets: add cmake support
add libwebsockets cmake support

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-25 09:43:48 +08:00
wangchengdong
4d98ecccaf testing/ostest: add hrtimer API functional tests
Add functional tests for the newly added hrtimer APIs,
including hrtimer_init(), hrtimer_start(), and hrtimer_cancel().

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2025-12-24 09:52:18 +08:00
zhengyu9
b78ab0c6e8 fsutils/flashtool: add flashtool command support
Introducing flashtool command with following capabilities:
- Flash geometry information display
- Bad blocks checking
- Page contents read/write
- Block erase
- Full flash erase

Signed-off-by: zhengyu9 <zhengyu9@xiaomi.com>
2025-12-23 11:25:16 -05:00
p-szafonimateusz
8856a587a6 testsuites/Kconfig: fix codespell issues
fix codespell issues

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-12-23 09:12:02 -03:00
p-szafonimateusz
951740627b testing/testsuites/Kconfig: add missing dependencies for test cases
add missing dependencies for test cases to avoid compilation errors

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-12-23 09:12:02 -03:00
p-szafonimateusz
008433dcfe testing/testsuites: add cmake support
add cmake support for testsuites

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
Co-authored-by: v-wangshihang <v-wangshihang@xiaomi.com>
Co-authored-by: v-chenglong8 <v-chenglong8@xiaomi.com>
Co-authored-by: xuxin19 <xuxin19@xiaomi.com>
Co-authored-by: zhangshoukui <zhangshoukui@xiaomi.com>
2025-12-23 09:12:02 -03:00
Matteo Golin
0045d8b546 uorb/listener: Fix typos
Fix typo in comments and strings.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2025-12-22 12:07:36 +01:00
zhangshuai39
26a969ac71 apps/netutils: Modify the MQTT compilation file to enable MQTT testing
Modify the build and test files to make the MQTT test cases run.

Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
2025-12-22 11:11:59 +08:00
fangpeina
c4da1b5b9f system/cu: Optimize I/O performance with batch read/write
Due to DMA-based transfers, the rx buffer can receive a large amount
of data at once. The previous character-by-character processing approach
was inefficient.

Modify character-by-character read to block read of the entire buffer.
This improves throughput and reduces CPU overhead, especially for high-speed
serial communication or other DMA-based transfers.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2025-12-18 21:49:00 +08:00
Alan Carvalho de Assis
8cb7dd0694 apps/testing: Add pthread_mutex_perf created by Anchao
During the discussion about the impact of adding counter to TCB
Mr anchao created a pthread mutex performance example:
https://github.com/apache/nuttx/pull/17468#issuecomment-3660925314

Because this example can exercise (not ideally) the pthread mutex
I decided to add it to apps/testing/sched, the program name will
be called "pmutexp" (because "pmp" is not a good name).

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2025-12-16 20:57:58 -03:00
dependabot[bot]
a5e455cc1c build(deps): bump actions/cache from 4 to 5
Bumps [actions/cache](https://github.com/actions/cache) from 4 to 5.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-16 09:24:27 +01:00
dependabot[bot]
c487d669cf build(deps): bump actions/download-artifact from 6 to 7
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-16 09:23:57 +01:00
dependabot[bot]
8e7ec46cce build(deps): bump actions/upload-artifact from 5 to 6
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-15 21:21:53 -05:00
yangsong8
60f5a68c96 adb: adb tcp server configuration depends on NET_TCPBACKLOG
For TCP-based adb, if the current CPU contains TCP protocol stack,
then NET_TCPBACKLOG needs to be enabled.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-11 19:16:23 +08:00
yangsong8
953fa21fef adb: adb shell depends on SCHED_CHILD_STATUS
Without this configuration, when executing exit in adb shell,
adb will not be able to exit because it cannot receive the
close packet.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-11 19:16:23 +08:00
chenxiaoyi
a59436985c testing: getTimeofday_test: fix build warning
getTimeofday_test.c:68:22: error: variable 'cnt' set but not used [-Werror,-Wunused-but-set-variable]

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2025-12-10 12:17:44 +01:00
Yanfeng Liu
aa3320fab4 import/Make.defs: use _start entry name
This reverts `_start` entry name to fix issue#17443 together with
nuttx side pull#17450.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2025-12-10 19:05:56 +08:00
zhengyu16
cfff7f5a22 nshlib: add -f for umount
adds support for the -f (force) option to the NSH umount command

Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com>
2025-12-10 12:16:49 +08:00
yangsong8
dbc99dbf35 apps/spitool: Support multiple trans
By adding a parameter -r, spitool can exchange multiple transactions.
example:
spi exch -b 1 -t 0 -n 0 -f 3000000 -m 1 -w 32 -x 1 -r 2 f001fff1 0000ff35

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-10 11:26:43 +08:00
yangsong8
74293114aa apps/system: fix spitool can not send data issue
when use cmd 'spi exch -b 1 -f 3000000 -m 1  -n 0 -w 32 -x 1 1f',
the last character '1f' can not be trans out.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-10 11:26:43 +08:00
yangsong8
00154fd818 apps/system/composite: change cmake build name to conn and disconn
The executable file compiled by cmake has the same filename as
that compiled by make.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-10 11:24:35 +08:00
yangsong8
f82e6c2229 nsh: return EOF when nread is 0
If enable CONFIG NSH_CLE. When sh reads data and detects that nread is 0,
return EOF and exit.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-10 11:24:14 +08:00
yangsong8
2bc4bdadee apps/nsh: fix switchboot command spelling error
modify swtichboot -> switchboot

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-10 11:24:14 +08:00
Filipe Cavalcanti
c3b5c6cedf boot/mcuboot: update MCUBoot version
Updates default MCUBoot hash.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2025-12-09 23:10:01 +08:00
hujun5
24e1c4df6f testing/ostest/smp_call.c: fix smp_call cpu_set inconsistency issue
If we set CONFIG_SMP_DEFAULT_CPUSET=1
This will cause the value of cpuset to be 0x1,
((1 << CONFIG_SMP_NCPUS) - 1) will result in the cpuset being 0x11,
leading to test case errors.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-12-09 09:44:37 -05:00
yangsong8
e19d99022a apps/fastboot: fix build warning
apps/system/fastboot/fastboot.c:351:43: error: '%s' directive output may be truncated writing up to 63 bytes into a region of size 60 [-Werror=format-truncation=] ...... apps/system/fastboot/fastboot.c:351:3: note: 'snprintf' output between 5 and 68 bytes into a destination of size 64 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ apps/system/fastboot/fastboot.c:351:43: error: '%s' directive output may be truncated writing up to 63 bytes into a region of size 60 [-Werror=format-truncation=] ...... apps/system/fastboot/fastboot.c:351:3: note: 'snprintf' output between 5 and 68 bytes into a destination of size 64 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-09 20:16:21 +08:00
yangsong8
9633580d2c apps/fastboot: add switchboot command
The switchboot command can be sent even without enabling sh

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-09 20:16:21 +08:00
yangsong8
63c1767d33 apps/fastboot: organize an api for external apps to call
add an interface fastboot_handler. This interface can be called
when nsh is disable.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-09 20:16:21 +08:00
yangsong8
5eae4c8f15 apps/fastboot: Enable network via ioctl during fastboot initialization
Bring up the network when do fastboot tcp init.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-09 20:16:21 +08:00
raiden00pl
641f7ced84 testing/ltp: add ltp zip file to gitignore
add ltp zip file to gitignore

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-12-05 17:53:57 +01:00
raiden00pl
5549f66dc1 testing/memtester: fix build error for cmake
fix broken CMakeLists.txt for memtester

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-12-05 17:53:57 +01:00
raiden00pl
39cb6fefda testing/memtester: add memtester.zip to gitignore
add memtester.zip to gitignore

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-12-05 17:53:57 +01:00
raiden00pl
8c5c506e40 testing/cachetest: fix compilation error for arm64
fix compilation error:

cachetest_main.c:37:26: error: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=]
   37 | #define CACHETEST_PREFIX "CACHE Test: "
      |                          ^~~~~~~~~~~~~~
cachetest_main.c:150:20: note: in expansion of macro 'CACHETEST_PREFIX'
  150 |   syslog(LOG_INFO, CACHETEST_PREFIX "waddr:%p, uncacheble addr start:%p,"
      |                    ^~~~~~~~~~~~~~~~
cachetest_main.c:151:17: note: format string is defined here
  151 |          "size:%u\n", info->waddr,
      |                ~^
      |                 |
      |                 unsigned int
      |                %lu

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-12-05 17:53:57 +01:00
simbit18
a78a3a461b workflows/build.yml: fix fatal: write error: No space left on device
Fixed error verified in this PR https://github.com/apache/nuttx/pull/17423

added to the workflow:

- Show Disk Space

- Free Disk Space (Ubuntu)
  Only Android runtime removed

- Post-build Disk Space

We can now monitor disk space.

Signed-off-by: simbit18 <simbit18@gmail.com>
2025-12-05 11:44:11 +08:00
1659 changed files with 181828 additions and 7731 deletions

View file

@ -1,2 +1,16 @@
mynewt-nimble/nimble/host/services/ans/src/ble_svc_ans.c
mynewt-nimble/nimble/host/services/ans/include
#include "services/ans/ble_svc_ans.h"
#include "crypto/controlse/ccertificate.hxx"
* notifications for the ANS Unread Alert Status characteristic
object = new Controlse::CCertificate(
Controlse::CCertificate cert(se, settings->key_id);
auto certificate = Controlse::CCertificate(
* |---------- [-rw-r--r-- 15] afile.txt
g_afile.name = "afile.txt";
"*.deh", "*.hhe", "*.seh", NULL);
MUSIC("introa"), MUSIC("runnin"), MUSIC("stalks"), MUSIC("countd"),
MUSIC("betwee"), MUSIC("doom"), MUSIC("the_da"), MUSIC("shawn"),
MUSIC("messag"), MUSIC("count2"), MUSIC("ddtbl3"), MUSIC("ampie"),
MUSIC("tense"), MUSIC("shawn3"), MUSIC("openin"), MUSIC("evil"),
/* ANS service */

View file

@ -8,3 +8,9 @@ exclude-file = .codespell-ignore-lines
# Ignore complete files (e.g. legal text or other immutable material).
skip =
LICENSE,
examples/webpanel/content/www/xterm.min.js,
**/games/NXDoom/src/doom/d_englsh.h,
**/games/NXDoom/src/doom/d_french.h
# Ignore words list (FTP protocol commands and technical terms)
ignore-words-list = ALLO, ARCHTYPE, parm, shiftIn

3
.github/labeler.yml vendored
View file

@ -17,6 +17,9 @@
# specific language governing permissions and limitations
# under the License.
#
# Note: NuttX PR Labeler only supports a subset of the
# `actions/labeler` syntax: `changed-files` and
# `any-glob-to-any-file`. See .github/workflows/labeler.yml
# add arch labels

View file

@ -230,7 +230,7 @@ jobs:
skip_build=1
fi
# For "Arch / Board: xtensa": Build xtensa-01, xtensa-02
# For "Arch / Board: xtensa": Build xtensa-01, xtensa-02, xtensa-03
elif [[ "$arch_contains_xtensa" == "1" || "$board_contains_xtensa" == "1" ]]; then
if [[ "$board" != *"xtensa-"* ]]; then
skip_build=1

View file

@ -85,7 +85,7 @@ jobs:
echo "apps_ref=$APPS_REF" >> $GITHUB_OUTPUT
- name: Checkout nuttx repo
uses: actions/checkout@v6
uses: actions/checkout@v7
with:
repository: apache/nuttx
ref: ${{ steps.gittargets.outputs.os_ref }}
@ -95,7 +95,7 @@ jobs:
run: git -C sources/nuttx fetch --tags
- name: Checkout apps repo
uses: actions/checkout@v6
uses: actions/checkout@v7
with:
repository: apache/nuttx-apps
ref: ${{ steps.gittargets.outputs.apps_ref }}
@ -106,7 +106,7 @@ jobs:
run: tar zcf sources.tar.gz sources
- name: Archive Source Bundle
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v7.0.1
with:
name: source-bundle
path: sources.tar.gz
@ -121,7 +121,7 @@ jobs:
[
"arm-01", "risc-v-01", "sim-01", "xtensa-01", "arm64-01", "x86_64-01", "other",
"arm-02", "risc-v-02", "sim-02", "xtensa-02",
"arm-03", "risc-v-03", "sim-03",
"arm-03", "risc-v-03", "sim-03", "xtensa-03",
"arm-04", "risc-v-04",
"arm-05", "risc-v-05",
"arm-06", "risc-v-06",
@ -135,6 +135,10 @@ jobs:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
# Documented sim/login CI test credential (not a production secret).
# Used when CONFIG_BOARD_ETC_ROMFS_PASSWD_ENABLE=y and defconfig omits
# the password. See nuttx tools/update_romfs_password.sh.
NUTTX_ROMFS_PASSWD_PASSWORD: NuttXSimLogin1!
strategy:
max-parallel: 12
@ -143,8 +147,18 @@ jobs:
steps:
- name: Show Disk Space
run: df -h
- name: Free Disk Space (Ubuntu)
run: |
sudo rm -rf /usr/local/lib/android
- name: After CLEAN-UP Disk Space
run: df -h
- name: Download Source Artifact
uses: actions/download-artifact@v6
uses: actions/download-artifact@v8
with:
name: source-bundle
path: .
@ -153,7 +167,7 @@ jobs:
run: tar zxf sources.tar.gz
- name: Docker Login
uses: docker/login-action@v3
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
with:
registry: ghcr.io
username: ${{ github.actor }}
@ -169,13 +183,45 @@ jobs:
uses: ./sources/nuttx/.github/actions/ci-container
env:
BLOBDIR: /tools/blobs
NUTTX_ROMFS_PASSWD_PASSWORD: NuttXSimLogin1!
with:
run: |
echo "::add-matcher::sources/nuttx/.github/gcc.json"
export NUTTX_ROMFS_PASSWD_PASSWORD=NuttXSimLogin1!
export ARTIFACTDIR=`pwd`/buildartifacts
for i in 1 2 3; do
python -m pip install \
--default-timeout=100 \
--retries 10 \
ntfc==0.0.1 && break
echo "Retry $i failed..."
sleep 5
done
mkdir /github/workspace/nuttx-ntfc
mkdir /github/workspace/nuttx-ntfc/external
cd /github/workspace/nuttx-ntfc
# get NTFC test cases
cd external
for i in 1 2 3 4 5; do
git clone -b release-0.0.1 https://github.com/apache/nuttx-ntfc-testing && break
if [ "$i" -eq 5 ]; then
echo "Failed to clone nuttx-ntfc-testing after $i attempts"
exit 1
fi
delay=$((i * 10))
echo "Clone attempt $i failed; retrying in ${delay}s..."
rm -rf nuttx-ntfc-testing
sleep "$delay"
done
mv nuttx-ntfc-testing nuttx-testing
export NTFCDIR=/github/workspace/nuttx-ntfc
echo "::add-matcher::sources/nuttx/.github/gcc.json"
git config --global --add safe.directory /github/workspace/sources/nuttx
git config --global --add safe.directory /github/workspace/sources/apps
cd sources/nuttx/tools/ci
cd /github/workspace/sources/nuttx/tools/ci
if [ "X${{matrix.boards}}" = "Xcodechecker" ]; then
./cibuild.sh -c -A -N -R --codechecker testlist/${{matrix.boards}}.dat
else
@ -183,7 +229,11 @@ jobs:
./cibuild.sh -c -A -N -R -S testlist/${{matrix.boards}}.dat
fi
- uses: actions/upload-artifact@v5
- name: Post-build Disk Space
if: always()
run: df -h
- uses: actions/upload-artifact@v7.0.1
if: ${{ always() }}
with:
name: linux-${{matrix.boards}}-builds
@ -198,7 +248,7 @@ jobs:
DOCKER_BUILDKIT: 1
steps:
- name: Download Source Artifact
uses: actions/download-artifact@v6
uses: actions/download-artifact@v8
with:
name: source-bundle
path: .
@ -207,7 +257,7 @@ jobs:
run: tar zxf sources.tar.gz
- name: Docker Login
uses: docker/login-action@v3
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
with:
registry: ghcr.io
username: ${{ github.actor }}
@ -228,7 +278,7 @@ jobs:
cd sources/nuttx
./tools/ci/cibuild-oot.sh
- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v7.0.1
if: ${{ always() }}
with:
name: oot-build-artifacts
@ -251,13 +301,15 @@ jobs:
runs-on: macos-15-intel
needs: macOS-Arch
if: ${{ needs.macOS-Arch.outputs.skip_all_builds != '1' }}
env:
NUTTX_ROMFS_PASSWD_PASSWORD: NuttXSimLogin1!
strategy:
max-parallel: 2
matrix:
boards: ${{ fromJSON(needs.macOS-Arch.outputs.selected_builds) }}
steps:
- name: Download Source Artifact
uses: actions/download-artifact@v6
uses: actions/download-artifact@v8
with:
name: source-bundle
path: .
@ -267,7 +319,7 @@ jobs:
- name: Restore Tools Cache
id: cache-tools
uses: actions/cache@v4
uses: actions/cache@v6
env:
cache-name: ${{ runner.os }}-cache-tools
with:
@ -279,17 +331,18 @@ jobs:
# Released version of Cython has issues with Python 11. Set runner to use Python 3.10
# https://github.com/cython/cython/issues/4500
- uses: actions/setup-python@v6
- uses: actions/setup-python@v7
with:
python-version: '3.10'
- name: Run Builds
run: |
echo "::add-matcher::sources/nuttx/.github/gcc.json"
export NUTTX_ROMFS_PASSWD_PASSWORD=NuttXSimLogin1!
export ARTIFACTDIR=`pwd`/buildartifacts
cd sources/nuttx/tools/ci
./cibuild.sh -i -c -A -R testlist/${{matrix.boards}}.dat
- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v7.0.1
with:
name: macos-${{matrix.boards}}-builds
path: buildartifacts/
@ -319,7 +372,7 @@ jobs:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
- uses: msys2/setup-msys2@v2
with:
msystem: MSYS
@ -352,7 +405,7 @@ jobs:
- run: git config --global core.autocrlf false
- name: Download Source Artifact
uses: actions/download-artifact@v6
uses: actions/download-artifact@v8
with:
name: source-bundle
path: .
@ -372,7 +425,7 @@ jobs:
cd sources/nuttx/tools/ci
./cibuild.sh -g -i -A -C -N -R testlist/${{matrix.boards}}.dat
- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v7.0.1
with:
name: msys2-${{matrix.boards}}-builds
path: buildartifacts/
@ -391,12 +444,12 @@ jobs:
msvc:
needs: msvc-Arch
if: ${{ needs.msvc-Arch.outputs.skip_all_builds != '1' }}
runs-on: windows-latest
runs-on: windows-2022
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
# Set up Python environment and install kconfiglib
- name: Set up Python and install kconfiglib
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: '3.10'
- name: Install kconfiglib
@ -406,7 +459,7 @@ jobs:
- run: git config --global core.autocrlf false
- name: Download Source Artifact
uses: actions/download-artifact@v6
uses: actions/download-artifact@v8
with:
name: source-bundle
path: .
@ -424,7 +477,7 @@ jobs:
cd sources\nuttx\tools\ci
.\cibuild.ps1 -n -i -A -C -N testlist\windows.dat
- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v7.0.1
with:
name: msvc-builds
path: ./sources/buildartifacts/

View file

@ -28,14 +28,14 @@ jobs:
steps:
- name: Checkout nuttx repo
uses: actions/checkout@v6
uses: actions/checkout@v7
with:
repository: apache/nuttx
path: nuttx
fetch-depth: 0
- name: Checkout apps repo
uses: actions/checkout@v6
uses: actions/checkout@v7
with:
repository: apache/nuttx-apps
path: apps

View file

@ -23,7 +23,7 @@ jobs:
issues: write
steps:
- name: Add labels issues automatically based on their body.
uses: actions/github-script@v8
uses: actions/github-script@v9.0.0
with:
script: |
const body = context.payload.issue.body;

View file

@ -12,34 +12,139 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This workflow will fetch the updated PR filenames, compute the Size Label
# and Arch Labels, then save the PR Labels into a PR Artifact. The
# PR Labels will be written to the PR inside the "workflow_run" trigger
# (pr_labeler.yml), because this "pull_request" trigger has read-only
# permission. Don't use "pull_request_target", it's unsafe.
# See https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=321719166#GitHubActionsSecurity-Buildstriggeredwithpull_request_target
name: "Pull Request Labeler"
on:
- pull_request_target
- pull_request
jobs:
labeler:
permissions:
contents: read
pull-requests: write
issues: write
pull-requests: read
issues: read
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Assign labels based on paths
uses: actions/labeler@main
# Checkout one file from our trusted source: .github/labeler.yml
# Never checkout and execute any untrusted code from the PR.
- name: Checkout labeler config
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true
repository: apache/nuttx-apps
ref: master
path: labeler
fetch-depth: 1
persist-credentials: false
sparse-checkout: .github/labeler.yml
sparse-checkout-cone-mode: false
- name: Assign labels based on the PR's size
uses: codelytv/pr-size-labeler@v1.10.3
# Fetch the updated PR filenames. Compute the Size Label and Arch Labels.
- name: Compute PR labels
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ignore_file_deletions: true
xs_label: 'Size: XS'
s_label: 'Size: S'
m_label: 'Size: M'
l_label: 'Size: L'
xl_label: 'Size: XL'
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const pull_number = context.issue.number;
// Fetch the array of updated PR filenames:
// { status: 'added', filename: 'arch/arm/test.txt', additions: 3, deletions: 0, changes: 3 }
// { status: 'removed', filename: 'Documentation/legacy_README.md', additions: 0, deletions: 2531, changes: 2531 }
// { status: 'modified', filename: 'Documentation/security.rst', additions: 1, deletions: 0, changes: 1 }
const listFilesOptions = github.rest.pulls.listFiles
.endpoint.merge({ owner, repo, pull_number });
const listFilesResponse = await github.paginate(listFilesOptions);
// Sum up the number of lines changed
const sizeFiles = listFilesResponse
.filter(f => (f.status != 'removed')); // Ignore deleted files
var linesChanged = 0;
for (const file of sizeFiles) {
linesChanged += file.changes;
}
console.log({ linesChanged });
// Compute the Size Label
const sizeLabel =
(linesChanged <= 10) ? 'Size: XS'
: (linesChanged <= 100) ? 'Size: S'
: (linesChanged <= 500) ? 'Size: M'
: (linesChanged <= 1000) ? 'Size: L'
: 'Size: XL';
var prLabels = [ sizeLabel ];
// Parse the Arch Label Patterns in .github/labeler.yml. Condense into:
// "Arch: arm":
// - any-glob-to-any-file: 'arch/arm/**'
// - any-glob-to-any-file: ...
const fs = require('fs');
const config = fs.readFileSync('labeler/.github/labeler.yml', 'utf8')
.split('\n') // Split by newline
.map(s => s.trim()) // Remove leading and trailing spaces
.filter(s => (s != '')) // Remove empty lines
.filter(s => !s.startsWith('#')) // Remove comments
.filter(s => !s.startsWith('- changed-files:')); // Remove "changed-files"
// Convert the Arch Label Patterns from config to archLabels.
// archLabels will contain the mappings for Arch Label and Filename Pattern:
// { label: "Arch: arm", pattern: "arch/arm/.*" },
// { label: "Arch: arm64", pattern: "arch/arm64/.*" }, ...
var archLabels = [];
var label = "";
for (const c of config) {
// Get the Arch Label
if (c.startsWith('"')) { // "Arch: arm":
label = c.split('"')[1]; // Arch: arm
} else if (c.startsWith('- any-glob-to-any-file:')) { // - any-glob-to-any-file: 'arch/arm/**'
// Convert the Glob Pattern to Regex Pattern
const pattern = c.split("'")[1] // arch/arm/**
.split('.').join('\\.') // . becomes \.
.split('*').join('[^/]*') // * becomes [^/]*
.split('[^/]*[^/]*').join('.*'); // ** becomes .*
archLabels.push({
label, // Arch: arm
pattern: '^' + pattern + '$' // Match the Line Start and Line End
});
} else {
// We don't support all rules of `actions/labeler`
throw new Error('.github/labeler.yml should contain only changed-files and any-glob-to-any-file, not: ' + c);
}
}
// Search the filenames for matching Arch Labels
for (const archLabel of archLabels) {
if (prLabels.includes(archLabel.label)) {
break;
}
for (const file of listFilesResponse) {
const re = new RegExp(archLabel.pattern);
const match = re.test(file.filename);
if (match && !prLabels.includes(archLabel.label)) {
prLabels.push(archLabel.label);
break;
}
}
}
console.log({ prLabels });
// Save the PR Number and PR Labels into a PR Artifact
// e.g. 'Size: XS\nArch: avr\n'
const dir = 'pr';
fs.mkdirSync(dir);
fs.writeFileSync(dir + '/pr-id.txt', pull_number + '\n');
fs.writeFileSync(dir + '/pr-labels.txt', prLabels.join('\n') + '\n');
# Upload the PR Artifact as pr.zip
- name: Upload PR artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pr
path: pr/

View file

@ -17,7 +17,7 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
fetch-depth: 0
- run: mkdir super-linter.report

90
.github/workflows/pr_labeler.yml vendored Normal file
View file

@ -0,0 +1,90 @@
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This workflow will fetch the PR Labels from the PR Artifact, and write
# the PR Labels into the PR. The workflow is called after the
# "pull_request" trigger (labeler.yml). This "workflow_run" trigger uses a
# GitHub Token with Write Permission, so we must never run any untrusted
# code from the PR, and we must always extract and use the PR Artifact
# safely. See https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=321719166#GitHubActionsSecurity-Buildstriggeredwithworkflow_run
name: "Set Pull Request Labels"
on:
workflow_run:
workflows: ["Pull Request Labeler"]
types:
- completed
jobs:
pr_labeler:
permissions:
contents: read
pull-requests: write
issues: write
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
# Download the PR Artifact, containing PR Number and PR Labels
- name: Download PR artifact
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
# Unzip the PR Artifact
- name: Unzip PR artifact
run: unzip pr.zip
# Write the PR Labels into the PR
- name: Write PR labels
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const fs = require('fs');
// Read the PR Number and PR Labels from the PR Artifact
// e.g. 'Size: XS\nArch: avr\n'
const issue_number = Number(fs.readFileSync('pr-id.txt'));
const labels = fs.readFileSync('pr-labels.txt', 'utf8')
.split('\n') // Split by newline
.filter(s => (s != '')); // Remove empty lines
console.log({ issue_number, labels });
// Write the PR Labels into the PR
// e.g. [ 'Size: XS', 'Arch: avr' ]
await github.rest.issues.setLabels({
owner,
repo,
issue_number,
labels
});

View file

@ -122,6 +122,7 @@ ifneq ($(strip $(PROGNAME)),)
NLIST := $(shell seq 1 $(words $(PROGNAME)))
$(foreach i, $(NLIST), \
$(eval PROGNAME_$(word $i,$(PROGOBJ)) := $(word $i,$(PROGNAME))) \
$(eval PROGSYM_$(word $i,$(PROGOBJ)) := $(subst -,_,$(word $i,$(PROGNAME)))) \
$(eval PROGOBJ_$(word $i,$(PROGLIST)) := $(word $i,$(PROGOBJ))) \
$(eval PRIORITY_$(word $i,$(REGLIST)) := \
$(if $(word $i,$(PRIORITY)),$(word $i,$(PRIORITY)),$(lastword $(PRIORITY)))) \
@ -133,7 +134,31 @@ ifneq ($(strip $(PROGNAME)),)
$(if $(word $i,$(GID)),$(word $i,$(GID)),$(lastword $(GID)))) \
$(eval MODE_$(word $i,$(REGLIST)) := \
$(if $(word $i,$(MODE)),$(word $i,$(MODE)),$(lastword $(MODE)))) \
$(eval STACKSIZE_$(word $i,$(PROGLIST)) := $(STACKSIZE_$(word $i,$(REGLIST)))) \
$(eval PRIORITY_$(word $i,$(PROGLIST)) := $(PRIORITY_$(word $i,$(REGLIST)))) \
$(eval UID_$(word $i,$(PROGLIST)) := $(UID_$(word $i,$(REGLIST)))) \
$(eval GID_$(word $i,$(PROGLIST)) := $(GID_$(word $i,$(REGLIST)))) \
$(eval MODE_$(word $i,$(PROGLIST)) := $(MODE_$(word $i,$(REGLIST)))) \
)
# Emit the application's configured attributes as absolute ELF symbols
# (nx_stacksize, nx_priority, and nx_uid/nx_gid/nx_mode under
# CONFIG_SCHED_USER_IDENTITY) so the binary loader can recover them.
# Per-target so each PROGLIST entry picks up its own STACKSIZE_/PRIORITY_.
$(PROGLIST): MODLDFLAGS += \
$(if $(STACKSIZE_$@),--defsym nx_stacksize=$(STACKSIZE_$@)) \
$(if $(filter-out SCHED_PRIORITY_DEFAULT,$(PRIORITY_$@)),--defsym nx_priority=$(PRIORITY_$@))
ifeq ($(CONFIG_SCHED_USER_IDENTITY),y)
$(PROGLIST): MODLDFLAGS += \
$(if $(UID_$@),--defsym nx_uid=$(UID_$@)) \
$(if $(GID_$@),--defsym nx_gid=$(GID_$@)) \
$(if $(MODE_$@),--defsym nx_mode=$(MODE_$@))
endif
# Keep the attribute symbols through --strip-unneeded so the binary loader
# can still read them from the stripped runtime image in bin/.
$(PROGLIST): NX_KEEP = $(if $(STACKSIZE_$@),-K nx_stacksize) $(if $(filter-out SCHED_PRIORITY_DEFAULT,$(PRIORITY_$@)),-K nx_priority) $(if $(UID_$@),-K nx_uid) $(if $(GID_$@),-K nx_gid) $(if $(MODE_$@),-K nx_mode)
endif
# Condition flags
@ -148,7 +173,7 @@ ifeq ($(WASM_BUILD),y)
DO_REGISTRATION = n
endif
ifeq ($(DYNLIB),y)
ifeq ($(BUILD_MODULE),y)
DO_REGISTRATION = n
endif
@ -223,7 +248,7 @@ endef
# rename "main()" in $1 to "xxx_main()" and save to $2
define RENAMEMAIN
$(ECHO_BEGIN)"Rename main() in $1 and save to $2"
$(Q) ${shell cat $1 | sed -e "s/fn[ ]\+main/fn $(addsuffix _main,$(PROGNAME_$@))/" > $2}
$(Q) ${shell cat $1 | sed -e "s/fn[ ]\+main/fn $(addsuffix _main,$(PROGSYM_$@))/" > $2}
$(ECHO_END)
endef
@ -310,7 +335,7 @@ $(PROGLIST): $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ) $(MAINZIGOBJ) $(MAINDOBJ)
ifneq ($(CONFIG_DEBUG_SYMBOLS),)
$(Q) mkdir -p $(BINDIR_DEBUG)
$(Q) cp $@ $(BINDIR_DEBUG)
$(Q) $(MODULESTRIP) $@
$(Q) $(MODULESTRIP) $(NX_KEEP) $@
endif
install:: $(PROGLIST)
@ -319,14 +344,14 @@ install:: $(PROGLIST)
else
$(MAINCXXOBJ): $(PREFIX)%$(CXXEXT)$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(eval $<_CXXFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(addsuffix _main,$(PROGNAME_$@))})
$(eval $<_CXXELFFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(addsuffix _main,$(PROGNAME_$@))})
$(eval $<_CXXFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(addsuffix _main,$(PROGSYM_$@))})
$(eval $<_CXXELFFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(addsuffix _main,$(PROGSYM_$@))})
$(if $(and $(CONFIG_MODULES),$(MODCXXFLAGS)), \
$(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@))
$(MAINCOBJ): $(PREFIX)%.c$(SUFFIX)$(OBJEXT): %.c
$(eval $<_CFLAGS += ${DEFINE_PREFIX}main=$(addsuffix _main,$(PROGNAME_$@)))
$(eval $<_CELFFLAGS += ${DEFINE_PREFIX}main=$(addsuffix _main,$(PROGNAME_$@)))
$(eval $<_CFLAGS += ${DEFINE_PREFIX}main=$(addsuffix _main,$(PROGSYM_$@)))
$(eval $<_CELFFLAGS += ${DEFINE_PREFIX}main=$(addsuffix _main,$(PROGSYM_$@)))
$(if $(and $(CONFIG_MODULES),$(MODCFLAGS)), \
$(call ELFCOMPILE, $<, $@), $(call COMPILE, $<, $@))
@ -362,10 +387,11 @@ ifeq ($(DO_REGISTRATION),y)
$(REGLIST): $(DEPCONFIG) Makefile
$(eval PROGNAME_$@ := $(basename $(notdir $@)))
$(eval PROGSYM_$@ := $(subst -,_,$(PROGNAME_$@)))
ifeq ($(CONFIG_SCHED_USER_IDENTITY),y)
$(call REGISTER,$(PROGNAME_$@),$(PRIORITY_$@),$(STACKSIZE_$@),$(if $(BUILD_MODULE),,$(PROGNAME_$@)_main),$(UID_$@),$(GID_$@),$(MODE_$@))
$(call REGISTER,$(PROGNAME_$@),$(PRIORITY_$@),$(STACKSIZE_$@),$(if $(BUILD_MODULE),,$(PROGSYM_$@)_main),$(UID_$@),$(GID_$@),$(MODE_$@))
else
$(call REGISTER,$(PROGNAME_$@),$(PRIORITY_$@),$(STACKSIZE_$@),$(if $(BUILD_MODULE),,$(PROGNAME_$@)_main))
$(call REGISTER,$(PROGNAME_$@),$(PRIORITY_$@),$(STACKSIZE_$@),$(if $(BUILD_MODULE),,$(PROGSYM_$@)_main))
endif
register:: $(REGLIST)
@ -393,6 +419,7 @@ clean::
$(call CLEANAROBJS)
$(call CLEAN)
distclean:: clean
$(call DELFILE, .kconfig)
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)

View file

@ -55,12 +55,12 @@ add_subdirectory(fsutils)
add_subdirectory(games)
add_subdirectory(graphics)
add_subdirectory(industry)
add_subdirectory(inertial)
add_subdirectory(interpreters)
add_subdirectory(logging)
add_subdirectory(lte)
add_subdirectory(math)
add_subdirectory(mlearning)
add_subdirectory(modbus)
add_subdirectory(netutils)
add_subdirectory(nshlib)
add_subdirectory(platform)

28
LICENSE
View file

@ -1282,7 +1282,7 @@ apps/system/telnet/telnet_client.c
Copyright (C) 2017 Gregory Nutt. All rights reserved.
Author: Gregory Nutt <gnutt@nuttx.org>
The original authors of libtelnet are listed below. Per their licesne,
The original authors of libtelnet are listed below. Per their license,
"The author or authors of this code dedicate any and all copyright
interest in this code to the public domain. We make this dedication for
the benefit of the public at large and to the detriment of our heirs and
@ -2248,3 +2248,29 @@ AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
netutils/bare/
==============
MIT License
Copyright (c) 2022 Frank Smit
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -34,7 +34,7 @@ NuttX directory. Like:
If all of the above conditions are TRUE, then NuttX will be able to find the
application directory. If your application directory has a different name or is
location at a different position, then you will have to inform the NuttX build
located at a different position, then you will have to inform the NuttX build
system of that location. There are several ways to do that:
1) You can define `CONFIG_APPS_DIR` to be the full path to your application
@ -140,7 +140,7 @@ project. One must:
main()
```
4. Set the requirements in the file: `Makefile`, specially the lines:
4. Set the requirements in the file: `Makefile`, specifically the lines:
```makefile
PROGNAME = progname

View file

@ -36,11 +36,20 @@ if(CONFIG_AUDIOUTILS_LAME)
list(APPEND CFG_CMDS "--cross-prefix=${CROSSDEV}")
endif()
# The revision to check out. See the comment in Makefile: an unpinned
# checkout stops linking on the day lame's trunk grows its next vector tier.
# Raise this deliberately, together with the vector source list below.
if(NOT DEFINED LAME_VERSION)
set(LAME_VERSION 6720)
endif()
# # Download lame if no lame/configure found
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lame/configure")
execute_process(
COMMAND "svn" "checkout" "https://svn.code.sf.net/p/lame/svn/trunk/lame"
"lame" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
COMMAND "svn" "checkout" "-r" "${LAME_VERSION}"
"https://svn.code.sf.net/p/lame/svn/trunk/lame" "lame"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
# Set source path
@ -75,7 +84,6 @@ if(CONFIG_AUDIOUTILS_LAME)
"${SRC_PATH}/libmp3lame/newmdct.c"
"${SRC_PATH}/libmp3lame/psymodel.c"
"${SRC_PATH}/libmp3lame/quantize.c"
"${SRC_PATH}/libmp3lame/vector/xmm_quantize_sub.c"
"${SRC_PATH}/libmp3lame/quantize_pvt.c"
"${SRC_PATH}/libmp3lame/set_get.c"
"${SRC_PATH}/libmp3lame/vbrquantize.c"
@ -87,6 +95,21 @@ if(CONFIG_AUDIOUTILS_LAME)
"${SRC_PATH}/libmp3lame/version.c"
"${SRC_PATH}/libmp3lame/presets.c")
if(CONFIG_HOST_X86 OR CONFIG_HOST_X86_64)
list(
APPEND
CSRCS
"${SRC_PATH}/libmp3lame/vector/xmm_quantize_sub.c"
"${SRC_PATH}/libmp3lame/vector/xmm_choose_table.c"
"${SRC_PATH}/libmp3lame/vector/xmm_quantize_lines.c"
"${SRC_PATH}/libmp3lame/vector/xmm_calc_sfb_noise.c"
"${SRC_PATH}/libmp3lame/vector/avx2_choose_table.c"
"${SRC_PATH}/libmp3lame/vector/avx2_quantize_lines.c"
"${SRC_PATH}/libmp3lame/vector/avx512_choose_table.c"
"${SRC_PATH}/libmp3lame/vector/avx512_quantize_lines.c"
"${SRC_PATH}/libmp3lame/vector/avx512_calc_sfb_noise.c")
endif()
# Add custom target to generate config_h
set(CONFIG_H_FILE "${CMAKE_CURRENT_SOURCE_DIR}/lame/configure")
set(CONFIG_OPTIONS

View file

@ -20,10 +20,19 @@
#
############################################################################
# The revision to check out. lame's trunk grows vector tiers over time --
# SSE2, then AVX2, then AVX-512 -- and each one adds sources that this file
# and CMakeLists.txt have to name, so an unpinned checkout stops linking on
# the day upstream adds the next one. Raise this deliberately, together with
# the vector source list below.
LAME_VERSION ?= 6720
# Download lame if no lame/configure found
lame-svn:
$(Q) echo "svn checkout lame ..."
$(Q) svn checkout https://svn.code.sf.net/p/lame/svn/trunk/lame lame
$(Q) svn checkout -r $(LAME_VERSION) \
https://svn.code.sf.net/p/lame/svn/trunk/lame lame
ifeq ($(wildcard lame/configure),)
context:: lame-svn
@ -72,7 +81,6 @@ CSRCS += $(SRC_PATH)/libmp3lame/bitstream.c \
$(SRC_PATH)/libmp3lame/newmdct.c \
$(SRC_PATH)/libmp3lame/psymodel.c \
$(SRC_PATH)/libmp3lame/quantize.c \
$(SRC_PATH)/libmp3lame/vector/xmm_quantize_sub.c \
$(SRC_PATH)/libmp3lame/quantize_pvt.c \
$(SRC_PATH)/libmp3lame/set_get.c \
$(SRC_PATH)/libmp3lame/vbrquantize.c \
@ -84,6 +92,23 @@ CSRCS += $(SRC_PATH)/libmp3lame/bitstream.c \
$(SRC_PATH)/libmp3lame/version.c \
$(SRC_PATH)/libmp3lame/presets.c
# lame's configure enables the SSE2, AVX2 and AVX-512 dispatch paths whenever
# the host compiler accepts their per-function target attributes, and the
# scalar code then calls into them, so the whole group has to be built on an
# x86 host. Other hosts keep lame's scalar implementation.
ifneq ($(CONFIG_HOST_X86)$(CONFIG_HOST_X86_64),)
CSRCS += $(SRC_PATH)/libmp3lame/vector/xmm_quantize_sub.c \
$(SRC_PATH)/libmp3lame/vector/xmm_choose_table.c \
$(SRC_PATH)/libmp3lame/vector/xmm_quantize_lines.c \
$(SRC_PATH)/libmp3lame/vector/xmm_calc_sfb_noise.c \
$(SRC_PATH)/libmp3lame/vector/avx2_choose_table.c \
$(SRC_PATH)/libmp3lame/vector/avx2_quantize_lines.c \
$(SRC_PATH)/libmp3lame/vector/avx512_choose_table.c \
$(SRC_PATH)/libmp3lame/vector/avx512_quantize_lines.c \
$(SRC_PATH)/libmp3lame/vector/avx512_calc_sfb_noise.c
endif
LAME_CONFIG_SCRIPT := $(CURDIR)$(DELIM)lame$(DELIM)configure
$(DST_PATH)/config.h:
@ -102,6 +127,6 @@ ifneq ($(PREFIX),)
endif
distclean::
$(Q)cd $(DST_PATH) && make distclean
$(Q)if [ -d $(DST_PATH) ]; then cd $(DST_PATH) && $(MAKE) distclean; fi
include $(APPDIR)/Application.mk

View file

@ -169,15 +169,33 @@ static int calc_samples(int fs, int tempo, int num, int dots)
switch (num)
{
case 0: n = 3; break;
case 1: n = 2; break;
case 2: n = 1; break;
case 4: n = 0; break;
case 8: div = 1; break;
case 16: div = 2; break;
case 32: div = 3; break;
case 64: div = 4; break;
default: div = -1; break;
case 0:
n = 3;
break;
case 1:
n = 2;
break;
case 2:
n = 1;
break;
case 4:
n = 0;
break;
case 8:
div = 1;
break;
case 16:
div = 2;
break;
case 32:
div = 3;
break;
case 64:
div = 4;
break;
default:
div = -1;
break;
}
if (dots <= 4)

1
audioutils/morsey/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
morsey

View file

@ -0,0 +1,6 @@
config AUDIOUTILS_MORSEY
bool "Morse code playing library"
default n
---help---
Simple library for parsing ASCII text into playable Morse code. Not
necessarily restricted to audio.

View file

@ -0,0 +1,25 @@
############################################################################
# apps/audioutils/morsey/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifneq ($(CONFIG_AUDIOUTILS_MORSEY),)
CONFIGURED_APPS += $(APPDIR)/audioutils/morsey
endif

View file

@ -0,0 +1,50 @@
############################################################################
# apps/audioutils/morsey/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(APPDIR)/Make.defs
CSRCS = $(MORSEY_DIR)/morsey.c
MORSEY_DIR = morsey
MORSEY_VERSION = v1.0.1
MORSEY_MORSEY_H_SHA256 = 55f45e7b9a4d810f928ffe3ee9bea4cc318e28b1f49abf9512aee2638bd1dbfa
MORSEY_MORSEY_C_SHA256 = 12babc90d3518e026c344c38dc3701287c41fd6b41a3ec96fb36c77907be78f8
$(MORSEY_DIR):
$(Q) echo "Cloning Morsey repo..."
$(Q) git clone --depth=1 --branch=$(MORSEY_VERSION) https://github.com/linguini1/morsey.git
$(Q) touch $(MORSEY_DIR)
$(Q) echo "Checking Morsey hashes..."
$(Q) $(APPDIR)/tools/check-hash.sh sha256 $(MORSEY_MORSEY_H_SHA256) $@/morsey.h
$(Q) $(APPDIR)/tools/check-hash.sh sha256 $(MORSEY_MORSEY_C_SHA256) $@/morsey.c
create_includes: $(MORSEY_DIR)/morsey.h
$(Q) cp $< $(APPDIR)/include/audioutils
context:: $(MORSEY_DIR)
$(Q) $(MAKE) create_includes
distclean::
$(call DELFILE, $(APPDIR)/include/audioutils/morsey.h)
$(call DELDIR, morsey)
include $(APPDIR)/Application.mk

1
audioutils/rtttl-c/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/rtttl-c

View file

@ -0,0 +1,21 @@
config AUDIOUTILS_RTTTL_C
bool "RTTTL parsing library"
default n
---help---
Simple library for parsing Ring Tone Text Transfer Language (RTTTL)
Define how to make a sound:
void
play_tone(struct rtttl_tone tone)
{
/* TODO: Make a sound with
* tone.frequency_100hz
* tone.period_us
* tone.duration_us
*/
}
and then play RTTTL string:
rtttl_play("...", play_tone);

View file

@ -0,0 +1,25 @@
############################################################################
# apps/audioutils/rtttl-c/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifneq ($(CONFIG_AUDIOUTILS_RTTTL_C),)
CONFIGURED_APPS += $(APPDIR)/audioutils/rtttl-c
endif

View file

@ -0,0 +1,50 @@
############################################################################
# apps/audioutils/rtttl-c/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(APPDIR)/Make.defs
CSRCS = $(RTTTL_C_DIR)/rtttl.c
RTTTL_C_DIR = rtttl-c
RTTTL_C_VERSION = v0.1.0
RTTTL_C_RTTTL_H_SHA256 = 6331174ae34a419ad427d9755f8ba9d3b6a92c09ecc4f36bbe07ec5e4d0cc007
RTTTL_C_RTTTL_C_SHA256 = f0db64ef0b68136bac24616a3d62508bcc54ccdd68265d6447d99b264653b7b9
$(RTTTL_C_DIR):
$(Q) echo "Cloning rtttl-c repo..."
$(Q) git clone --depth=1 --branch=$(RTTTL_C_VERSION) https://git.sr.ht/~qeef/rtttl-c
$(Q) touch $(RTTTL_C_DIR)
$(Q) echo "Checking rtttl-c hashes..."
$(Q) $(APPDIR)/tools/check-hash.sh sha256 $(RTTTL_C_RTTTL_H_SHA256) $@/rtttl.h
$(Q) $(APPDIR)/tools/check-hash.sh sha256 $(RTTTL_C_RTTTL_C_SHA256) $@/rtttl.c
create_includes: $(RTTTL_C_DIR)/rtttl.h
$(Q) cp $< $(APPDIR)/include/audioutils
context:: $(RTTTL_C_DIR)
$(Q) $(MAKE) create_includes
distclean::
$(call DELFILE, $(APPDIR)/include/audioutils/rtttl.h)
$(call DELDIR, rtttl-c)
include $(APPDIR)/Application.mk

View file

@ -443,8 +443,8 @@ static inline void tsnorm(struct timespec *ts)
static inline int64_t timediff_us(struct timespec t1, struct timespec t2)
{
int64_t ret;
ret = 1000000 * (int64_t) ((int) t1.tv_sec - (int) t2.tv_sec);
ret += (int64_t) ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
ret = 1000000 * (t1.tv_sec - t2.tv_sec);
ret += (t1.tv_nsec - t2.tv_nsec) / 1000;
return ret;
}
@ -458,11 +458,11 @@ static inline int64_t timediff_us_timer(struct timer_status_s after,
t2 = after.timeleft;
if (t2 < t1)
{
ret = (int64_t) (t1 - t2);
ret = t1 - t2;
}
else
{
ret = (int64_t) (after.timeout - (t2 - t1));
ret = after.timeout - (t2 - t1);
}
return ret;

View file

@ -102,10 +102,10 @@ int main(int argc, FAR char *argv[])
/* Report the device structure */
printf("FLASH device parameters:\n");
printf(" Sector size: %10d\n", info.sectorsize);
printf(" Sector count: %10d\n", info.numsectors);
printf(" Erase block: %10" PRIx32 "\n", geo.erasesize);
printf(" Total size: %10d\n", info.sectorsize * info.numsectors);
printf(" Sector size: %10d\n", info.sectorsize);
printf(" Sector count: %10d\n", info.numsectors);
printf(" Erase block size: %10" PRIu32 "\n", geo.erasesize);
printf(" Total size: %10d\n", info.sectorsize * info.numsectors);
if (info.sectorsize != geo.erasesize)
{
@ -124,7 +124,7 @@ int main(int argc, FAR char *argv[])
goto errout_with_driver;
}
/* Fill the buffer with known data and print it in hex format */
/* Fill the buffer with known data */
for (int i = 0; i < info.sectorsize; i++)
{

View file

@ -39,6 +39,7 @@
#include <sys/poll.h>
#include <nuttx/sched.h>
#include <nuttx/spinlock.h>
/****************************************************************************
* Private Types
@ -129,7 +130,7 @@ static size_t performance_gettime(FAR struct performance_time_s *result)
}
/****************************************************************************
* Pthread swtich performance
* Pthread switch performance
****************************************************************************/
static FAR void *pthread_switch_task(FAR void *arg)

View file

@ -0,0 +1,31 @@
# ##############################################################################
# apps/benchmarks/ramspeed/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_BENCHMARK_RAMSPEED)
nuttx_add_application(
NAME
${CONFIG_BENCHMARK_RAMSPEED_PROGNAME}
SRCS
ramspeed_main.c
STACKSIZE
${CONFIG_BENCHMARK_RAMSPEED_STACKSIZE}
PRIORITY
${CONFIG_BENCHMARK_RAMSPEED_PRIORITY})
endif()

View file

@ -130,8 +130,8 @@ static uint64_t get_time_delta_us(const struct timespec *start,
const struct timespec *end)
{
uint64_t elapsed;
elapsed = (((uint64_t)end->tv_sec * NSEC_PER_SEC) + end->tv_nsec);
elapsed -= (((uint64_t)start->tv_sec * NSEC_PER_SEC) + start->tv_nsec);
elapsed = (end->tv_sec * NSEC_PER_SEC) + end->tv_nsec;
elapsed -= (start->tv_sec * NSEC_PER_SEC) + start->tv_nsec;
return elapsed / 1000.;
}
@ -451,7 +451,7 @@ int main(int argc, char *argv[])
cfg.run_duration *= 1000;
bench_fd = open(BENCHMARK_FILE,
O_CREAT | (verify ? O_RDWR : O_WRONLY) | O_TRUNC);
O_CREAT | (verify ? O_RDWR : O_WRONLY) | O_TRUNC, 0666);
if (bench_fd < 0)
{

View file

@ -1,10 +1,11 @@
From 71f51cd5ca4f492a464fb12d5bce91e5fbba300a Mon Sep 17 00:00:00 2001
From 6d0be04a4b4208447e75c369e9811d089f466739 Mon Sep 17 00:00:00 2001
From: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
Date: Tue, 11 Jun 2024 16:01:23 +0800
Date: Thu, 3 Apr 2025 11:59:02 +0800
Subject: [PATCH] tacle-bench: add makefile and all-in-one main file
The original taclebench is used for WCET analysis. This commit allows most taclebench test cases (except parallel test cases) to be compiled and executed.
Change-Id: I707b8ac58d3ddc4b7974c5bedecac1a7b5c887f9
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
---
Makefile | 12 +
@ -65,14 +66,14 @@ Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
bench/test/cover/cover.c | 3 +
bench/test/duff/duff.c | 3 +
bench/test/test3/test3.c | 3 +
taclebench.c | 349 ++++++++++++++++++
59 files changed, 532 insertions(+)
taclebench.c | 366 ++++++++++++++++++
59 files changed, 549 insertions(+)
create mode 100644 Makefile
create mode 100644 taclebench.c
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2385c61
index 0000000..75ca0a1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,12 @@
@ -83,7 +84,7 @@ index 0000000..2385c61
+TEST_SRCS := $(shell find bench/test -name "*.c")
+
+all:
+ cc -DALL_IN_ONE ${APP_SRCS} ${KERNEL_SRCS} ${SEQUENTIAL_SRCS} ${TEST_SRCS} bench/kernel/cosf/wcclibm.c taclebench.c -static -o taclebench
+ cc -DALL_IN_ONE ${APP_SRCS} ${KERNEL_SRCS} ${SEQUENTIAL_SRCS} ${TEST_SRCS} bench/kernel/cosf/wcclibm.c taclebench.c -static -o taclebench -O3
+
+clean:
+ rm -f taclebench
@ -888,11 +889,12 @@ index 0235738..6eaf8c2 100755
diff --git a/taclebench.c b/taclebench.c
new file mode 100644
index 0000000..1231b87
index 0000000..aaff1bb
--- /dev/null
+++ b/taclebench.c
@@ -0,0 +1,349 @@
@@ -0,0 +1,366 @@
+#include <stdio.h>
+#include <time.h>
+
+int main_epic(void);
+int main_mpeg2(void);
@ -954,6 +956,10 @@ index 0000000..1231b87
+
+int main(void)
+{
+ struct timespec start_ts;
+ struct timespec end_ts;
+ clock_gettime(CLOCK_MONOTONIC, &start_ts);
+
+ if (main_epic() != 0)
+ {
+ printf("main_epic error\n");
@ -1239,6 +1245,18 @@ index 0000000..1231b87
+ printf("main_bitonic error\n");
+ }
+
+ clock_gettime(CLOCK_MONOTONIC, &end_ts);
+ long sec_diff = end_ts.tv_sec - start_ts.tv_sec;
+ long nsec_diff = end_ts.tv_nsec - start_ts.tv_nsec;
+
+ if (nsec_diff < 0)
+ {
+ sec_diff -= 1;
+ nsec_diff += 1000000000;
+ }
+
+ printf("%ld.%09ld seconds\n", sec_diff, nsec_diff);
+
+ return 0;
+}
--

View file

@ -0,0 +1,31 @@
# ##############################################################################
# apps/benchmarks/whetstone/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_BENCHMARK_WHETSTONE)
nuttx_add_application(
NAME
${CONFIG_BENCHMARK_WHETSTONE_PROGNAME}
SRCS
whetstone.c
STACKSIZE
${CONFIG_BENCHMARK_WHETSTONE_STACKSIZE}
PRIORITY
${CONFIG_BENCHMARK_WHETSTONE_PRIORITY})
endif()

View file

@ -0,0 +1,34 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config BENCHMARK_WHETSTONE
tristate "Double Precision Benchmark"
default n
depends on ALLOW_CUSTOM_PERMISSIVE_COMPONENTS
---help---
Enable a Whetstone test.
This benchmark is based on the C converted version from
https://www.netlib.org/benchmark/whetstone.c which has a
custom permissive license requiring attribution.
if BENCHMARK_WHETSTONE
config BENCHMARK_WHETSTONE_PROGNAME
string "Program name"
default "whetstone"
---help---
This is the name of the program that will be used when the NSH ELF
program is installed.
config BENCHMARK_WHETSTONE_PRIORITY
int "Whetstone test task priority"
default 100
config BENCHMARK_WHETSTONE_STACKSIZE
int "Whetstone test stack size"
default DEFAULT_TASK_STACKSIZE
endif

View file

@ -0,0 +1,23 @@
############################################################################
# apps/benchmarks/whetstone/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifneq ($(CONFIG_BENCHMARK_WHETSTONE),)
CONFIGURED_APPS += $(APPDIR)/benchmarks/whetstone
endif

View file

@ -0,0 +1,32 @@
############################################################################
# apps/benchmarks/whetstone/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(APPDIR)/Make.defs
# WHETSTONE speed test
PROGNAME = $(CONFIG_BENCHMARK_WHETSTONE_PROGNAME)
PRIORITY = $(CONFIG_BENCHMARK_WHETSTONE_PRIORITY)
STACKSIZE = $(CONFIG_BENCHMARK_WHETSTONE_STACKSIZE)
MODULE = $(CONFIG_BENCHMARK_WHETSTONE)
MAINSRC = whetstone.c
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,520 @@
/****************************************************************************
* apps/benchmarks/whetstone/whetstone.c
*
* SPDX-License-Identifier: LicenseRef-Painter-Engineering-Whetstone
*
* Converted Whetstone Double Precision Benchmark
* Version 1.2 22 March 1998
*
* (c) Copyright 1998 Painter Engineering, Inc.
* All Rights Reserved.
*
* Permission is granted to use, duplicate, and
* publish this text and program as long as it
* includes this entire comment block and limited
* rights reference.
*
* Converted by Rich Painter, Painter Engineering, Inc. based on the
* www.netlib.org benchmark/whetstoned version obtained 16 March 1998.
*
* A novel approach was used here to keep the look and feel of the
* FORTRAN version. Altering the FORTRAN-based array indices,
* starting at element 1, to start at element 0 for C, would require
* numerous changes, including decrementing the variable indices by 1.
* Instead, the array e1[] was declared 1 element larger in C. This
* allows the FORTRAN index range to function without any literal or
* variable indices changes. The array element e1[0] is simply never
* used and does not alter the benchmark results.
*
* The major FORTRAN comment blocks were retained to minimize
* differences between versions. Modules N5 and N12, like in the
* FORTRAN version, have been eliminated here.
*
* An optional command-line argument has been provided [-c] to
* offer continuous repetition of the entire benchmark.
* An optional argument for setting an alternate loop count is also
* provided. Define PRINTOUT to cause the pout() function to print
* outputs at various stages. Final timing measurements should be
* made with the PRINTOUT undefined.
*
* Questions and comments may be directed to the author at
* r.painter@ieee.org
****************************************************************************/
/****************************************************************************
* Benchmark #2 -- Double Precision Whetstone (A001)
*
* o This is a REAL*8 version of
* the Whetstone benchmark program.
*
* o DO-loop semantics are ANSI-66 compatible.
*
* o Final measurements are to be made with all
* WRITE statements and FORMAT sttements removed.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
/* standard C library headers required */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
/* the following is optional depending on the timing function used */
#include <time.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* map the FORTRAN math functions, etc. to the C versions */
#define DSIN sin
#define DCOS cos
#define DATAN atan
#define DLOG log
#define DEXP exp
#define DSQRT sqrt
#define IF if
#define USAGE "usage: whetdc [-c] [loops]\n"
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* function prototypes */
void pout(long n, long j, long k, double x1,
double x2, double x3, double x4);
void pa(double e[]);
void p0(void);
void p3(double x, double y, FAR double *z);
/****************************************************************************
* Private Data
****************************************************************************/
/* COMMON t,t1,t2,e1(4),j,k,l */
double t;
double t1;
double t2;
double e1[5];
int j;
int k;
int l;
/****************************************************************************
* Public Functions
****************************************************************************/
int main(int argc, FAR char *argv[])
{
/* used in the FORTRAN version */
long loop;
long i;
long n1;
long n2;
long n3;
long n4;
long n6;
long n7;
long n8;
long n9;
long n10;
long n11;
double x1;
double x2;
double x3;
double x4;
double x;
double y;
double z;
int ii;
int jj;
/* added for this version */
long loopstart;
long startmsec;
long finimsec;
float KIPS;
int continuous;
struct timespec ts;
loopstart = 1000; /* see the note about loop below */
continuous = 0;
ii = 1; /* start at the first arg (temp use of ii here) */
while (ii < argc)
{
if (strncmp(argv[ii], "-c", 2) == 0 || argv[ii][0] == 'c')
{
continuous = 1;
}
else if (atol(argv[ii]) > 0)
{
loopstart = atol(argv[ii]);
}
else
{
fprintf(stderr, USAGE);
return 1;
}
ii++;
}
LCONT:
/* Start benchmark timing at this point. */
clock_gettime(CLOCK_REALTIME, &ts);
startmsec = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
/* The actual benchmark starts here. */
t = .499975;
t1 = 0.50025;
t2 = 2.0;
/* With loopcount loop=10, one million Whetstone instructions
* will be executed in EACH MAJOR loop..A MAJOR loop IS EXECUTED
* 'ii' TIMES TO INCREASE WALL-CLOCK TIMING ACCURACY.
*
* loop = 1000;
*/
loop = loopstart;
ii = 1;
jj = 1;
IILOOP:
n1 = 0;
n2 = 12 * loop;
n3 = 14 * loop;
n4 = 345 * loop;
n6 = 210 * loop;
n7 = 32 * loop;
n8 = 899 * loop;
n9 = 616 * loop;
n10 = 0;
n11 = 93 * loop;
/* Module 1: Simple identifiers */
x1 = 1.0;
x2 = -1.0;
x3 = -1.0;
x4 = -1.0;
for (i = 1; i <= n1; i++)
{
x1 = (x1 + x2 + x3 - x4) * t;
x2 = (x1 + x2 - x3 + x4) * t;
x3 = (x1 - x2 + x3 + x4) * t;
x4 = (-x1 + x2 + x3 + x4) * t;
}
#ifdef PRINTOUT
IF (jj == ii)
{
pout(n1, n1, n1, x1, x2, x3, x4);
}
#endif
/* Module 2: Array elements */
e1[1] = 1.0;
e1[2] = -1.0;
e1[3] = -1.0;
e1[4] = -1.0;
for (i = 1; i <= n2; i++)
{
e1[1] = (e1[1] + e1[2] + e1[3] - e1[4]) * t;
e1[2] = (e1[1] + e1[2] - e1[3] + e1[4]) * t;
e1[3] = (e1[1] - e1[2] + e1[3] + e1[4]) * t;
e1[4] = (-e1[1] + e1[2] + e1[3] + e1[4]) * t;
}
#ifdef PRINTOUT
IF (jj == ii)
{
pout(n2, n3, n2, e1[1], e1[2], e1[3], e1[4]);
}
#endif
/* Module 3: Array as parameter */
for (i = 1; i <= n3; i++)
{
pa(e1);
}
#ifdef PRINTOUT
IF (jj == ii)
{
pout(n3, n2, n2, e1[1], e1[2], e1[3], e1[4]);
}
#endif
/* Module 4: Conditional jumps */
j = 1;
for (i = 1; i <= n4; i++)
{
if (j == 1)
{
j = 2;
}
else
{
j = 3;
}
if (j > 2)
{
j = 0;
}
else
{
j = 1;
}
if (j < 1)
{
j = 1;
}
else
{
j = 0;
}
}
#ifdef PRINTOUT
IF (jj == ii)
{
pout(n4, j, j, x1, x2, x3, x4);
}
#endif
/* Module 5: Omitted
* Module 6: Integer arithmetic
*/
j = 1;
k = 2;
l = 3;
for (i = 1; i <= n6; i++)
{
j = j * (k - j) * (l - k);
k = l * k - (l - j) * k;
l = (l - k) * (k + j);
e1[l - 1] = j + k + l;
e1[k - 1] = j * k * l;
}
#ifdef PRINTOUT
IF (jj == ii)
{
pout(n6, j, k, e1[1], e1[2], e1[3], e1[4]);
}
#endif
/* Module 7: Trigonometric functions */
x = 0.5;
y = 0.5;
for (i = 1; i <= n7; i++)
{
x = t * DATAN(t2 * DSIN(x) * DCOS(x) /
(DCOS(x + y) + DCOS(x - y) - 1.0));
y = t * DATAN(t2 * DSIN(y) * DCOS(y) /
(DCOS(x + y) + DCOS(x - y) - 1.0));
}
#ifdef PRINTOUT
IF (jj == ii)
{
pout(n7, j, k, x, x, y, y);
}
#endif
/* Module 8: Procedure calls */
x = 1.0;
y = 1.0;
z = 1.0;
for (i = 1; i <= n8; i++)
{
p3(x, y, &z);
}
#ifdef PRINTOUT
IF (jj == ii)
{
pout(n8, j, k, x, y, z, z);
}
#endif
/* Module 9: Array references */
j = 1;
k = 2;
l = 3;
e1[1] = 1.0;
e1[2] = 2.0;
e1[3] = 3.0;
for (i = 1; i <= n9; i++)
{
p0();
}
#ifdef PRINTOUT
IF (jj == ii)
{
pout(n9, j, k, e1[1], e1[2], e1[3], e1[4]);
}
#endif
/* Module 10: Integer arithmetic */
j = 2;
k = 3;
for (i = 1; i <= n10; i++)
{
j = j + k;
k = j + k;
j = k - j;
k = k - j - j;
}
#ifdef PRINTOUT
IF (jj == ii)
{
pout(n10, j, k, x1, x2, x3, x4);
}
#endif
/* Module 11: Standard functions */
x = 0.75;
for (i = 1; i <= n11; i++)
x = DSQRT(DEXP(DLOG(x) / t1));
#ifdef PRINTOUT
IF (jj == ii)
{
pout(n11, j, k, x, x, x, x);
}
#endif
/* THIS IS THE END OF THE MAJOR loop. */
if (++jj <= ii)
{
goto IILOOP;
}
/* Stop benchmark timing at this point. */
clock_gettime(CLOCK_REALTIME, &ts);
finimsec = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
/* Performance in Whetstone KIP's per second is given by
*
* (100*loop*ii)/TIME
*
* where TIME is in seconds.
*/
printf("\n");
if (finimsec - startmsec <= 0)
{
printf("Insufficient duration- Increase the loop count\n");
return 1;
}
printf("Loops: %ld, Iterations: %d, Duration: %ld millisecond.\n",
loop, ii, finimsec - startmsec);
KIPS = (100.0 * loop * ii) / ((float)(finimsec - startmsec) * 1000);
if (KIPS >= 1000.0)
{
printf("C Converted Double Precision Whetstones: %.1f MIPS\n",
KIPS / 1000.0);
}
else
{
printf("C Converted Double Precision Whetstones: %.1f KIPS\n", KIPS);
}
if (continuous)
{
goto LCONT;
}
return 0;
}
void
pa(double e[])
{
j = 0;
L10:
e[1] = (e[1] + e[2] + e[3] - e[4]) * t;
e[2] = (e[1] + e[2] - e[3] + e[4]) * t;
e[3] = (e[1] - e[2] + e[3] + e[4]) * t;
e[4] = (-e[1] + e[2] + e[3] + e[4]) / t2;
j += 1;
if (j < 6)
{
goto L10;
}
}
void
p0(void)
{
e1[j] = e1[k];
e1[k] = e1[l];
e1[l] = e1[j];
}
void p3(double x, double y, FAR double *z)
{
double x1;
double y1;
x1 = x;
y1 = y;
x1 = t * (x1 + y1);
y1 = t * (x1 + y1);
*z = (x1 + y1) / t2;
}
#ifdef PRINTOUT
void
pout(long n, long j, long k, double x1, double x2, double x3, double x4)
{
printf("%7ld %7ld %7ld %12.4e %12.4e %12.4e %12.4e\n",
n, j, k, x1, x2, x3, x4);
}
#endif

View file

@ -45,6 +45,9 @@ if(CONFIG_BOOT_MCUBOOT)
set(SRCS
mcuboot/boot/bootutil/src/boot_record.c
mcuboot/boot/bootutil/src/bootutil_area.c
mcuboot/boot/bootutil/src/bootutil_img_hash.c
mcuboot/boot/bootutil/src/bootutil_loader.c
mcuboot/boot/bootutil/src/bootutil_misc.c
mcuboot/boot/bootutil/src/bootutil_public.c
mcuboot/boot/bootutil/src/caps.c

View file

@ -22,11 +22,11 @@ config MCUBOOT_REPOSITORY
config MCUBOOT_VERSION
string "MCUboot version"
default "fefc398cc13ebbc527e297fe9df78cd98a359d75"
default "e36d3c8d6ca5e0ed1f510f2a7d110f405a7c396b"
---help---
Defines MCUboot version to be downloaded. Either release tag
or commit hash should be specified. Using newer MCUboot version
may cause compatability issues.
may cause compatibility issues.
config MCUBOOT_ENABLE_LOGGING
bool "Enable MCUboot logging"

View file

@ -44,6 +44,9 @@ endif
CFLAGS += -Wno-undef -Wno-unused-but-set-variable
CSRCS := $(MCUBOOT_UNPACK)/boot/bootutil/src/boot_record.c \
$(MCUBOOT_UNPACK)/boot/bootutil/src/bootutil_area.c \
$(MCUBOOT_UNPACK)/boot/bootutil/src/bootutil_img_hash.c \
$(MCUBOOT_UNPACK)/boot/bootutil/src/bootutil_loader.c \
$(MCUBOOT_UNPACK)/boot/bootutil/src/bootutil_misc.c \
$(MCUBOOT_UNPACK)/boot/bootutil/src/bootutil_public.c \
$(MCUBOOT_UNPACK)/boot/bootutil/src/caps.c \

View file

@ -39,7 +39,7 @@
* Name: miniboot_main
*
* Description:
* Minimal bootlaoder entry point.
* Minimal bootloader entry point.
*
****************************************************************************/
@ -49,10 +49,6 @@ int main(int argc, FAR char *argv[])
syslog(LOG_INFO, "*** miniboot ***\n");
/* Perform architecture-specific initialization (if configured) */
boardctl(BOARDIOC_INIT, 0);
#ifdef CONFIG_BOARDCTL_FINALINIT
/* Perform architecture-specific final-initialization (if configured) */

View file

@ -169,7 +169,7 @@ enum progress_msg_e
****************************************************************************/
#ifdef CONFIG_NXBOOT_PROGRESS
void nxboot_progress(enum progress_type_e type, ...);
void nxboot_progress(int type, ...);
#else
#define nxboot_progress(type, ...) do {} while (0)
#endif

View file

@ -417,6 +417,7 @@ static int perform_update(struct nxboot_state *state, bool check_only)
syslog(LOG_INFO, "Creating recovery image.\n");
nxboot_progress(nxboot_progress_start, recovery_create);
copy_partition(primary, recovery, state, false);
flash_partition_flush(recovery);
nxboot_progress(nxboot_progress_end);
nxboot_progress(nxboot_progress_start, validate_recovery);
successful = validate_image(recovery);
@ -444,6 +445,8 @@ static int perform_update(struct nxboot_state *state, bool check_only)
nxboot_progress(nxboot_progress_start, update_from_update);
if (copy_partition(update, primary, state, true) >= 0)
{
flash_partition_flush(primary);
/* Erase the first sector of update partition. This marks the
* partition as updated so we don't end up in an update loop.
* The sector is written back again during the image
@ -884,7 +887,6 @@ int nxboot_perform_update(bool check_only)
int ret;
int primary;
struct nxboot_state state;
struct nxboot_img_header header;
ret = nxboot_get_state(&state);
if (ret < 0)
@ -908,9 +910,9 @@ int nxboot_perform_update(bool check_only)
}
}
/* Check whether there is a valid image in the primary slot. This just
* checks whether the header is valid, but does not calculate the CRC
* of the image as this would prolong the boot process.
/* Check whether there is a valid image in the primary slot. Validates
* both the header and the full image CRC to ensure integrity before
* booting.
*/
primary = flash_partition_open(CONFIG_NXBOOT_PRIMARY_SLOT_PATH);
@ -919,8 +921,7 @@ int nxboot_perform_update(bool check_only)
return ERROR;
}
get_image_header(primary, &header);
if (!validate_image_header(&header))
if (!validate_image(primary))
{
ret = ERROR;
}

View file

@ -28,6 +28,7 @@
#include <stdio.h>
#include <errno.h>
#include <inttypes.h>
#include <string.h>
#include <stddef.h>
#include <fcntl.h>
@ -75,6 +76,26 @@ int flash_partition_open(const char *path)
return fd;
}
/****************************************************************************
* Name: flash_partition_flush
*
* Description:
* Flushes any buffered writes to the underlying storage. This ensures
* data is physically committed to flash before the caller proceeds.
*
* Input parameters:
* fd: Valid file descriptor.
*
* Returned Value:
* 0 on success, -1 on failure.
*
****************************************************************************/
int flash_partition_flush(int fd)
{
return fsync(fd);
}
/****************************************************************************
* Name: flash_partition_close
*
@ -137,14 +158,15 @@ int flash_partition_write(int fd, const void *buf, size_t count, off_t off)
pos = lseek(fd, off, SEEK_SET);
if (pos != off)
{
syslog(LOG_ERR, "Could not seek to %ld: %s\n", off, strerror(errno));
syslog(LOG_ERR, "Could not seek to %" PRIdOFF ": %s\n",
off, strerror(errno));
return ERROR;
}
nbytes = write(fd, buf, count);
if (nbytes != count)
{
syslog(LOG_ERR, "Write to offset %ld failed %s\n",
syslog(LOG_ERR, "Write to offset %" PRIdOFF " failed %s\n",
off, strerror(errno));
return ERROR;
}
@ -195,15 +217,16 @@ int flash_partition_read(int fd, void *buf, size_t count, off_t off)
pos = lseek(fd, off, SEEK_SET);
if (pos != off)
{
syslog(LOG_ERR, "Could not seek to %ld: %s\n", off, strerror(errno));
syslog(LOG_ERR, "Could not seek to %" PRIdOFF ": %s\n",
off, strerror(errno));
return ERROR;
}
nbytes = read(fd, buf, count);
if (nbytes != count)
{
syslog(LOG_ERR, "Read from offset %ld failed %s\n", off,
strerror(errno));
syslog(LOG_ERR, "Read from offset %" PRIdOFF " failed %s\n",
off, strerror(errno));
return ERROR;
}

View file

@ -79,6 +79,22 @@ int flash_partition_open(const char *path);
int flash_partition_close(int fd);
/****************************************************************************
* Name: flash_partition_flush
*
* Description:
* Flushes any buffered writes to the underlying storage.
*
* Input parameters:
* fd: Valid file descriptor.
*
* Returned Value:
* 0 on success, -1 on failure.
*
****************************************************************************/
int flash_partition_flush(int fd);
/****************************************************************************
* Name: flash_partition_write
*

View file

@ -124,7 +124,7 @@ static const char *progress_msgs[] =
****************************************************************************/
#ifdef CONFIG_NXBOOT_PROGRESS
void nxboot_progress(enum progress_type_e type, ...)
void nxboot_progress(int type, ...)
{
#ifdef CONFIG_NXBOOT_PRINTF_PROGRESS
va_list arg;
@ -264,16 +264,10 @@ int main(int argc, FAR char *argv[])
FAR struct boardioc_reset_cause_s cause;
#endif
#if defined(CONFIG_BOARDCTL) && !defined(CONFIG_NSH_ARCHINIT)
/* Perform architecture-specific initialization (if configured) */
boardctl(BOARDIOC_INIT, 0);
#ifdef CONFIG_BOARDCTL_FINALINIT
/* Perform architecture-specific final-initialization (if configured) */
boardctl(BOARDIOC_FINALINIT, 0);
#endif
#endif
syslog(LOG_INFO, "*** nxboot ***\n");

View file

@ -29,7 +29,7 @@
#include <spawn.h>
#include <fcntl.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/debug.h>
#include "builtin/builtin.h"

View file

@ -6,7 +6,7 @@
config CANUTILS_CANDUMP
tristate "SocketCAN candump tool"
default n
depends on NET_CAN && CANUTILS_LIBCANUTILS
depends on NET_CAN && CANUTILS_LIBCANUTILS && ENABLE_ALL_SIGNALS
---help---
Enable the SocketCAN candump tool ported from
https://github.com/linux-can/can-utils

View file

@ -25,7 +25,7 @@
****************************************************************************/
#include <sys/ioctl.h>
#include <debug.h>
#include <nuttx/debug.h>
#include <errno.h>
#include <nuttx/can/can.h>

View file

@ -25,7 +25,7 @@
****************************************************************************/
#include <sys/ioctl.h>
#include <debug.h>
#include <nuttx/debug.h>
#include <errno.h>
#include <nuttx/can/can.h>

View file

@ -25,7 +25,7 @@
****************************************************************************/
#include <sys/ioctl.h>
#include <debug.h>
#include <nuttx/debug.h>
#include <errno.h>
#include <nuttx/can/can.h>

View file

@ -25,7 +25,7 @@
****************************************************************************/
#include <sys/ioctl.h>
#include <debug.h>
#include <nuttx/debug.h>
#include <errno.h>
#include <nuttx/can/can.h>

View file

@ -25,7 +25,7 @@
****************************************************************************/
#include <sys/ioctl.h>
#include <debug.h>
#include <nuttx/debug.h>
#include <errno.h>
#include <nuttx/can/can.h>

View file

@ -25,7 +25,7 @@
****************************************************************************/
#include <sys/ioctl.h>
#include <debug.h>
#include <nuttx/debug.h>
#include <errno.h>
#include <nuttx/can/can.h>

View file

@ -51,6 +51,7 @@ config CANUTILS_LELYCANOPEN_OBJUPLOAD
config CANUTILS_LELYCANOPEN_SDEV
bool "Lely CANopen enable static device description support"
default n
depends on CANUTILS_LELYCANOPEN_OBJNAME
config CANUTILS_LELYCANOPEN_CSDO
bool "Lely CANopen enable Client-SDO support"
@ -67,6 +68,7 @@ config CANUTILS_LELYCANOPEN_TPDO
config CANUTILS_LELYCANOPEN_MPDO
bool "Lely CANopen enable Multiplex PDO support"
default n
depends on CANUTILS_LELYCANOPEN_TPDO
config CANUTILS_LELYCANOPEN_SYNC
bool "Lely CANopen enable SYNC support"
@ -95,14 +97,17 @@ config CANUTILS_LELYCANOPEN_MASTER
config CANUTILS_LELYCANOPEN_NG
bool "Lely CANopen enable node guardian support"
default n
depends on CANUTILS_LELYCANOPEN_EMCY
config CANUTILS_LELYCANOPEN_NMTBOOT
bool "Lely CANopen enable NMT boot slave support"
default n
depends on CANUTILS_LELYCANOPEN_MASTER && CANUTILS_LELYCANOPEN_CSDO
config CANUTILS_LELYCANOPEN_NMTCFG
bool "Lely CANopen enable NMT configuration request support"
default n
depends on CANUTILS_LELYCANOPEN_MASTER && CANUTILS_LELYCANOPEN_CSDO
config CANUTILS_LELYCANOPEN_GW
bool "Lely CANopen enable gateway support"

View file

@ -31,11 +31,16 @@ WD := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'}
LELYCANOPEN_VERSION = $(patsubst "%",%,$(strip $(CONFIG_CANUTILS_LELYCANOPEN_VERSION)))
LELYCANOPEN_TARBALL = lely-core-$(LELYCANOPEN_VERSION).tar.gz
LELYCANOPEN_UNPACKNAME = lely-core-master-$(LELYCANOPEN_VERSION)
LELYCANOPEN_SRCNAME = lely-core
UNPACK ?= tar -zxf
LELYCANOPEN_SRCDIR = $(WD)/$(LELYCANOPEN_SRCNAME)
# The GitLab "archive/master" tarball unpacks to a directory named
# lely-core-master-<sha>, where <sha> is the current tip of master
LELYCANOPEN_UNPACKGLOB = lely-core-master-*
LELYCANOPEN_PATCHES = $(sort $(wildcard *.patch))
# CAN network object
CSRCS += $(LELYCANOPEN_SRCDIR)/src/can/buf.c
@ -169,37 +174,34 @@ STACKSIZE = $(CONFIG_CANUTILS_LELYCANOPEN_TOOLS_COCTL_STACKSIZE)
MAINSRC = $(LELYCANOPEN_SRCDIR)/tools/coctl.c
endif
# Download and unpack tarball if no git repo found
# Download, unpack and patch the Lely CANopen sources.
ifeq ($(wildcard $(LELYCANOPEN_SRCNAME)/.git),)
$(LELYCANOPEN_TARBALL):
@echo "Downloading: $(LELYCANOPEN_TARBALL)"
$(Q) curl -L -O $(CONFIG_CANUTILS_LELYCANOPEN_URL)/$(LELYCANOPEN_TARBALL)
$(Q) curl -fL -o $@.tmp $(CONFIG_CANUTILS_LELYCANOPEN_URL)/$(LELYCANOPEN_TARBALL)
$(Q) mv $@.tmp $@
$(LELYCANOPEN_SRCNAME): $(LELYCANOPEN_TARBALL)
@echo "Unpacking: $(LELYCANOPEN_TARBALL) -> $(LELYCANOPEN_UNPACKNAME)"
$(LELYCANOPEN_SRCNAME)/.patched: $(LELYCANOPEN_TARBALL) $(LELYCANOPEN_PATCHES)
@echo "Unpacking: $(LELYCANOPEN_TARBALL) -> $(LELYCANOPEN_SRCNAME)"
$(Q) rm -rf $(LELYCANOPEN_SRCNAME) $(LELYCANOPEN_UNPACKGLOB)
$(Q) $(UNPACK) $(LELYCANOPEN_TARBALL)
$(Q) mv $(LELYCANOPEN_UNPACKGLOB) $(LELYCANOPEN_SRCNAME)
$(Q) for patch in $(LELYCANOPEN_PATCHES); do \
echo "Patching: $$patch"; \
patch -s -N -p1 -d $(LELYCANOPEN_SRCNAME) < $$patch || exit 1; \
done
$(Q) touch $@
patch_src: $(LELYCANOPEN_SRCNAME)
# Get the name of the directory created by the tar command
$(eval LELYCANOPEN_UNPACKNAME := $(shell ls -d lely-core-master*))
$(Q) mv $(LELYCANOPEN_UNPACKNAME) $(LELYCANOPEN_SRCNAME)
$(Q) cat 0001-tools-eliminate-multiple-definitions-of-poll-compile.patch | patch -s -N -d $(LELYCANOPEN_SRCNAME) -p1
$(Q) cat 0002-tools-coctl.c-fix-printf-issues.patch | patch -s -N -d $(LELYCANOPEN_SRCNAME) -p1
$(Q) cat 0003-src-co-nmt.c-fix-compilation.patch | patch -s -N -d $(LELYCANOPEN_SRCNAME) -p1
$(Q) cat 0004-tools-coctl.c-add-missing-mutex-init.patch | patch -s -N -d $(LELYCANOPEN_SRCNAME) -p1
$(Q) cat 0005-add-NuttX-support.patch | patch -s -N -d $(LELYCANOPEN_SRCNAME) -p1
$(Q) echo "Patching $(LELYCANOPEN_SRCNAME)"
context:: $(LELYCANOPEN_SRCNAME)/.patched
distclean::
$(Q) rm -rf $(LELYCANOPEN_SRCNAME) $(LELYCANOPEN_UNPACKGLOB)
$(call DELFILE, $(LELYCANOPEN_TARBALL))
context:: patch_src
else
context:: $(LELYCANOPEN_SRCNAME)
endif
distclean::
ifeq ($(wildcard $(LELYCANOPEN_SRCNAME)/.git),)
$(call DELDIR, $(LELYCANOPEN_SRCNAME))
$(call DELFILE, $(LELYCANOPEN_TARBALL))
endif
include $(APPDIR)/Application.mk

View file

@ -34,7 +34,10 @@ include(nuttx_parse_function_args)
# - riscv32: riscv32imc/imac/imafc-unknown-nuttx-elf
# - riscv64: riscv64imac/imafdc-unknown-nuttx-elf
# - x86: i686-unknown-nuttx
# - x86_64: x86_64-unknown-nuttx
# - x86_64: x86_64-unknown-nuttx-macho for sim on macOS,
# x86_64-unknown-nuttx otherwise
# - aarch64: aarch64-unknown-nuttx-macho for sim on macOS,
# aarch64-unknown-nuttx otherwise
#
# Inputs:
# ARCHTYPE - Architecture type (e.g. thumbv7m, riscv32)
@ -48,9 +51,22 @@ include(nuttx_parse_function_args)
function(nuttx_rust_target_triple ARCHTYPE ABITYPE CPUTYPE OUTPUT)
if(ARCHTYPE STREQUAL "x86_64")
set(TARGET_TRIPLE "x86_64-unknown-nuttx")
if(CONFIG_ARCH_SIM AND CONFIG_HOST_MACOS)
set(TARGET_TRIPLE
"${PROJECT_SOURCE_DIR}/tools/x86_64-unknown-nuttx-macho.json")
else()
set(TARGET_TRIPLE "${PROJECT_SOURCE_DIR}/tools/x86_64-unknown-nuttx.json")
endif()
elseif(ARCHTYPE STREQUAL "x86")
set(TARGET_TRIPLE "i686-unknown-nuttx")
set(TARGET_TRIPLE "${PROJECT_SOURCE_DIR}/tools/i486-unknown-nuttx.json")
elseif(ARCHTYPE STREQUAL "aarch64")
if(CONFIG_ARCH_SIM AND CONFIG_HOST_MACOS)
set(TARGET_TRIPLE
"${PROJECT_SOURCE_DIR}/tools/aarch64-unknown-nuttx-macho.json")
else()
set(TARGET_TRIPLE
"${PROJECT_SOURCE_DIR}/tools/aarch64-unknown-nuttx.json")
endif()
elseif(ARCHTYPE MATCHES "thumb")
if(ARCHTYPE MATCHES "thumbv8m")
# Extract just the base architecture type (thumbv8m.main or thumbv8m.base)
@ -90,6 +106,13 @@ function(nuttx_rust_target_triple ARCHTYPE ABITYPE CPUTYPE OUTPUT)
set(TARGET_TRIPLE "riscv64imac-unknown-nuttx-elf")
endif()
endif()
if(NOT TARGET_TRIPLE)
message(
FATAL_ERROR
"Unsupported Rust target: LLVM_ARCHTYPE=${ARCHTYPE}, LLVM_ABITYPE=${ABITYPE}, LLVM_CPUTYPE=${CPUTYPE}"
)
endif()
set(${OUTPUT}
${TARGET_TRIPLE}
PARENT_SCOPE)
@ -107,6 +130,8 @@ endfunction()
# hello
# CRATE_PATH
# ${CMAKE_CURRENT_SOURCE_DIR}/hello
# FEATURES
# sim
# )
# ~~~
@ -119,6 +144,8 @@ function(nuttx_add_rust)
ONE_VALUE
CRATE_NAME
CRATE_PATH
MULTI_VALUE
FEATURES
REQUIRED
CRATE_NAME
CRATE_PATH
@ -127,34 +154,60 @@ function(nuttx_add_rust)
# Determine build profile based on CONFIG_DEBUG_FULLOPT
if(CONFIG_DEBUG_FULLOPT)
set(RUST_PROFILE_FLAG "--release")
set(RUST_PROFILE "release")
set(RUST_DEBUG_FLAGS "-Zbuild-std-features=panic_immediate_abort")
set(RUST_PANIC_FLAGS "-Zunstable-options -Cpanic=immediate-abort")
else()
set(RUST_PROFILE_FLAG "")
set(RUST_PROFILE "debug")
set(RUST_DEBUG_FLAGS "")
set(RUST_PANIC_FLAGS "")
endif()
foreach(feature ${FEATURES})
list(APPEND RUST_FEATURE_FLAGS --features ${feature})
endforeach()
# Get the Rust target triple
nuttx_rust_target_triple(${LLVM_ARCHTYPE} ${LLVM_ABITYPE} ${LLVM_CPUTYPE}
RUST_TARGET)
# Set up build directory in current binary dir
set(RUST_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CRATE_NAME})
# Get binary directory path using target triple base name if it's a JSON file
if(RUST_TARGET MATCHES ".json$")
get_filename_component(TARGET_BASE ${RUST_TARGET} NAME_WE)
else()
set(TARGET_BASE ${RUST_TARGET})
endif()
set(RUST_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CRATE_NAME}/target)
set(RUST_LIB_PATH
${RUST_BUILD_DIR}/${RUST_TARGET}/${RUST_PROFILE}/lib${CRATE_NAME}.a)
${RUST_BUILD_DIR}/${TARGET_BASE}/${RUST_PROFILE}/lib${CRATE_NAME}.a)
# Create build directory
file(MAKE_DIRECTORY ${RUST_BUILD_DIR})
# Collect Rust source files and manifests as dependencies so that changes in
# the crate trigger a rebuild via CMake/Ninja.
file(
GLOB_RECURSE
RUST_CRATE_SOURCES
CONFIGURE_DEPENDS
"${CRATE_PATH}/Cargo.toml"
"${CRATE_PATH}/Cargo.lock"
"${CRATE_PATH}/build.rs"
"${CRATE_PATH}/src/*.rs"
"${CRATE_PATH}/src/**/*.rs")
# Add a custom command to build the Rust crate
add_custom_command(
OUTPUT ${RUST_LIB_PATH}
COMMAND
${CMAKE_COMMAND} -E env
NUTTX_INCLUDE_DIR=${PROJECT_SOURCE_DIR}/include:${CMAKE_BINARY_DIR}/include:${CMAKE_BINARY_DIR}/include/arch
cargo build --${RUST_PROFILE} -Zbuild-std=std,panic_abort
${RUST_DEBUG_FLAGS} --manifest-path ${CRATE_PATH}/Cargo.toml --target
${RUST_TARGET} --target-dir ${RUST_BUILD_DIR}
RUSTFLAGS=${RUST_PANIC_FLAGS} cargo build ${RUST_PROFILE_FLAG}
-Zbuild-std=std,panic_abort -Zjson-target-spec --manifest-path
${CRATE_PATH}/Cargo.toml --target ${RUST_TARGET} --target-dir
${RUST_BUILD_DIR} ${RUST_FEATURE_FLAGS}
DEPENDS ${RUST_CRATE_SOURCES}
COMMENT "Building Rust crate ${CRATE_NAME}"
VERBATIM)

View file

@ -701,8 +701,12 @@ int main(int argc, FAR char *argv[])
#ifdef CONFIG_STACK_COLORATION
FAR struct tcb_s *tcb;
tcb = nxsched_get_tcb(getpid());
fprintf(stderr, "\nStack used: %zu / %zu\n", up_check_tcbstack(tcb),
tcb->adj_stack_size);
if (tcb != NULL)
{
fprintf(stderr, "\nStack used: %zu / %zu\n", up_check_tcbstack(tcb),
tcb->adj_stack_size);
nxsched_put_tcb(tcb);
}
#else
fprintf(stderr, "\nStack used: unknown"
" (STACK_COLORATION must be enabled)\n");

View file

@ -451,6 +451,7 @@ ifneq ($(CONFIG_LIBTOMCRYPT_DEMOS),)
ifneq ($(CONFIG_LIBTOMCRYPT_LTCRYPT),)
MAINSRC += $(LIBTOMCRYPT_UNPACKNAME)/demos/ltcrypt.c
MODULE += $(CONFIG_LIBTOMCRYPT_LTCRYPT)
PROGNAME += $(CONFIG_LIBTOMCRYPT_LTCRYPT_PROGNAME)
PRIORITY += $(CONFIG_LIBTOMCRYPT_LTCRYPT_PRIORITY)
STACKSIZE += $(CONFIG_LIBTOMCRYPT_LTCRYPT_STACKSIZE)
@ -459,6 +460,7 @@ endif
ifneq ($(CONFIG_LIBTOMCRYPT_HASHSUM),)
MAINSRC += $(LIBTOMCRYPT_UNPACKNAME)/demos/hashsum.c
MODULE += $(CONFIG_LIBTOMCRYPT_HASHSUM)
PROGNAME += $(CONFIG_LIBTOMCRYPT_HASHSUM_PROGNAME)
PRIORITY += $(CONFIG_LIBTOMCRYPT_HASHSUM_PRIORITY)
STACKSIZE += $(CONFIG_LIBTOMCRYPT_HASHSUM_STACKSIZE)
@ -478,6 +480,7 @@ NEWSRC := $(wildcard libtomcrypt/tests/*.c)
CSRCS += $(filter-out $(LIBTOMCRYPT_UNPACKNAME)/tests/test.c, $(NEWSRC))
MAINSRC += $(LIBTOMCRYPT_UNPACKNAME)/tests/test.c
MODULE += $(CONFIG_LIBTOMCRYPT_TEST)
PROGNAME += $(CONFIG_LIBTOMCRYPT_TEST_PROGNAME)
PRIORITY += $(CONFIG_LIBTOMCRYPT_TEST_PRIORITY)
STACKSIZE += $(CONFIG_LIBTOMCRYPT_TEST_STACKSIZE)

View file

@ -129,18 +129,16 @@ if(CONFIG_CRYPTO_MBEDTLS)
# Library Configuration
# ############################################################################
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_INCLUDE_DIRECTORIES ${INCDIR})
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_CXX_INCLUDE_DIRECTORIES ${INCDIR})
nuttx_add_library(mbedtls STATIC)
target_sources(mbedtls PRIVATE ${CSRCS})
target_include_directories(mbedtls PRIVATE ${INCDIR})
target_include_directories(mbedtls PUBLIC ${INCDIR})
nuttx_export_header(TARGET mbedtls INCLUDE_DIRECTORIES ${MBEDTLS_DIR}/include)
# Overlay mbedtls_config.h cannot be in the same nuttx_export_header() as
# ${MBEDTLS_DIR}/include (duplicate path). Alt headers need no export; INCDIR
# supplies them for this library only.
nuttx_create_symlink(
${CMAKE_CURRENT_LIST_DIR}/include/mbedtls/mbedtls_config.h
${NUTTX_APPS_BINDIR}/include/mbedtls/mbedtls/mbedtls_config.h)
target_compile_definitions(mbedtls PRIVATE unix)
if(CONFIG_ARCH_SIM)

View file

@ -48,6 +48,7 @@ MBEDTLS_FRAMEWORK_UNPACKNAME = mbedtls-framework
CFLAGS += ${DEFINE_PREFIX}unix
mbedtls/library/bignum.c_CFLAGS += -fno-lto
mbedtls/library/ctr_drbg.c_CFLAGS += -Wno-array-bounds
# Build break on Assemble compiler if -fno-omit-frame-pointer and -O3 enabled at same time
# {standard input}: Assembler messages:

View file

@ -7,3 +7,25 @@ config OPENSSL_MBEDTLS_WRAPPER
depends on CRYPTO_MBEDTLS
bool "openssl mbedtls wrapper"
default n
if OPENSSL_MBEDTLS_WRAPPER
choice
prompt "Openssl Mbedtls Wrapper Assert Debug"
default OPENSSL_ASSERT_EXIT
config OPENSSL_ASSERT_DEBUG
bool "SSL_ASSERT* will show error file name and line"
config OPENSSL_ASSERT_EXIT
bool "SSL_ASSERT* will just return error code"
config OPENSSL_ASSERT_DEBUG_EXIT
bool "SSL_ASSERT* will show error file name and line, then return error code"
config OPENSSL_ASSERT_DEBUG_BLOCK
bool "SSL_ASSERT* will show error file name and line, then block here with 'while (1)'"
endchoice
endif # OPENSSL_MBEDTLS_WRAPPER

View file

@ -27,16 +27,86 @@
****************************************************************************/
#include <openssl/base.h>
#include <openssl/types.h>
/****************************************************************************
* Public Function Prototypes
* Pre-processor Definitions
****************************************************************************/
/* There are the classes of BIOs */
#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */
#define BIO_TYPE_FILTER 0x0200
#define BIO_TYPE_SOURCE_SINK 0x0400
#define BIO_FLAGS_BASE64_NO_NL 0x100
/* This is used with memory BIOs: BIO_FLAGS_MEM_RDONLY
* means we shouldn't free up or change the data in any way;
* BIO_FLAGS_NONCLEAR_RST means we shouldn't clear data on reset.
*/
#define BIO_FLAGS_MEM_RDONLY 0x200
#define BIO_FLAGS_NONCLEAR_RST 0x400
#define BIO_FLAGS_IN_EOF 0x800
#define BIO_TYPE_NONE 0
#define BIO_TYPE_MEM (1 | BIO_TYPE_SOURCE_SINK)
#define BIO_TYPE_FILE (2 | BIO_TYPE_SOURCE_SINK)
#define BIO_TYPE_BASE64 (11 | BIO_TYPE_FILTER)
/****************************************************************************
* Public Types
****************************************************************************/
struct bio_method_st
{
int type;
char *name;
int (*bwrite_old) (BIO *, const char *, int);
int (*bread_old) (BIO *, char *, int);
int (*create) (BIO *);
int (*destroy) (BIO *);
};
struct bio_st
{
const BIO_METHOD *method;
int flags; /* extra storage */
void *ptr;
struct bio_st *next_bio; /* used by filter BIOs */
struct bio_st *prev_bio; /* used by filter BIOs */
};
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
const BIO_METHOD *BIO_f_base64(void);
const BIO_METHOD *BIO_s_mem(void);
BIO *BIO_new(const BIO_METHOD *method);
BIO *BIO_push(BIO *b, BIO *bio);
void BIO_set_flags(BIO *b, int flags);
int BIO_write(BIO *b, const void *data, int dlen);
int BIO_read(BIO *b, void *data, int dlen);
void BIO_free_all(BIO *bio);
BIO *BIO_next(BIO *b);
int BIO_flush(BIO *b);
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,48 @@
/****************************************************************************
* apps/crypto/openssl_mbedtls_wrapper/include/openssl/crypto.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
****************************************************************************/
#ifndef OPENSSL_MBEDTLS_WRAPPER_CRYPTO_H
#define OPENSSL_MBEDTLS_WRAPPER_CRYPTO_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <openssl/base.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define CRYPTO_num_locks() 1
#define CRYPTO_set_locking_callback(func)
#define CRYPTO_set_id_callback(func)
/* These defines where used in combination with the old locking callbacks,
* they are not called anymore, but old code that's not called might still
* use them.
*/
#define CRYPTO_LOCK 1
#define CRYPTO_UNLOCK 2
#define CRYPTO_READ 4
#define CRYPTO_WRITE 8
#endif /* OPENSSL_MBEDTLS_WRAPPER_CRYPTO_H */

View file

@ -49,6 +49,12 @@ unsigned long ERR_peek_last_error(void);
void ERR_error_string_n(unsigned long e, char *buf, size_t len);
void ERR_free_strings(void);
char *ERR_error_string(unsigned long e, char *buf);
void ERR_clear_error(void);
unsigned long ERR_get_error(void);
void ERR_remove_state(unsigned long pid);
int ERR_load_crypto_strings(void);
void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
void *u);
#ifdef __cplusplus
}

View file

@ -44,6 +44,10 @@
#define EVP_PKEY_X25519 NID_X25519
/****************************************************************************
* Public Types
****************************************************************************/
struct evp_pkey_st
{
void *pkey_pm;
@ -166,6 +170,10 @@ int PKCS5_PBKDF2_HMAC(const char *password, size_t password_len,
const PKEY_METHOD *EVP_PKEY_method(void);
int OpenSSL_add_all_algorithms(void);
void EVP_cleanup(void);
#ifdef __cplusplus
}
#endif

View file

@ -25,13 +25,19 @@
****************************************************************************/
#include <stddef.h>
#include <openssl/ex_data.h>
#include <openssl/types.h>
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#include <openssl/tls1.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
#define SSL_SENT_SHUTDOWN 1
#define SSL_RECEIVED_SHUTDOWN 2
#define SSL_SENT_SHUTDOWN 1
#define SSL_RECEIVED_SHUTDOWN 2
#define SSL_VERIFY_NONE 0x00
#define SSL_VERIFY_PEER 0x01
@ -57,52 +63,134 @@
#define SSL_ERROR_WANT_READ 2
#define SSL_ERROR_WANT_WRITE 3
#define SSL_ERROR_WANT_X509_LOOKUP 4
#define SSL_ERROR_SYSCALL 5/* look at error stack/return value/errno */
#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */
#define SSL_ERROR_ZERO_RETURN 6
#define SSL_ERROR_WANT_CONNECT 7
#define SSL_ERROR_WANT_ACCEPT 8
#define SSL_ERROR_WANT_ASYNC 9
#define SSL_ERROR_WANT_ASYNC_JOB 10
#define SSL_ERROR_WANT_ASYNC_JOB 10
#define SSL_ST_CONNECT 0x1000
#define SSL_ST_ACCEPT 0x2000
#define SSL_ST_MASK 0x0FFF
#define SSL_CB_LOOP 0x01
#define SSL_CB_EXIT 0x02
#define SSL_CB_READ 0x04
#define SSL_CB_WRITE 0x08
#define SSL_CB_ALERT 0x4000 /* used in callback */
#define SSL_CB_READ_ALERT (SSL_CB_ALERT | SSL_CB_READ)
#define SSL_CB_WRITE_ALERT (SSL_CB_ALERT | SSL_CB_WRITE)
#define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT | SSL_CB_LOOP)
#define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT | SSL_CB_EXIT)
#define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT | SSL_CB_LOOP)
#define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT | SSL_CB_EXIT)
#define SSL_CB_HANDSHAKE_START 0x10
#define SSL_CB_HANDSHAKE_DONE 0x20
#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1
#define SSL_FILETYPE_PEM X509_FILETYPE_PEM
/* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success
* when just a single record has been written):
*/
#define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001U
/* Make it possible to retry SSL_write() with changed buffer location (buffer
* contents must stay the same!); this is not the default to avoid the
* misconception that non-blocking SSL_write() behaves like non-blocking
* write():
*/
#define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002U
#define SSLEAY_VERSION 0
#define SSLEAY_CFLAGS 1
#define SSLEAY_BUILT_ON 2
#define SSLEAY_PLATFORM 3
#define SSLEAY_DIR 4
#define SSL2_VERSION 0x0002
#define SSL2_MT_CLIENT_HELLO 1
#define SSLv23_client_method TLS_client_method
#define SSL_library_init() 1
#define SSL_load_error_strings()
/****************************************************************************
* Public Types
****************************************************************************/
typedef unsigned int (*SSL_psk_client_cb_func)(SSL *ssl,
const char *hint,
char *identity,
unsigned int max_identity_len,
unsigned char *psk,
unsigned int max_psk_len);
typedef void (*ossl_msg_cb)(
int write_p, int version, int content_type,
const void *buf, size_t len, SSL *ssl, void *arg);
typedef enum
{
TLS_ST_BEFORE,
TLS_ST_OK,
DTLS_ST_CR_HELLO_VERIFY_REQUEST,
TLS_ST_CR_SRVR_HELLO,
TLS_ST_CR_CERT,
TLS_ST_CR_CERT_STATUS,
TLS_ST_CR_KEY_EXCH,
TLS_ST_CR_CERT_REQ,
TLS_ST_CR_SRVR_DONE,
TLS_ST_CR_SESSION_TICKET,
TLS_ST_CR_CHANGE,
TLS_ST_CR_FINISHED,
TLS_ST_CW_CLNT_HELLO,
TLS_ST_CW_CERT,
TLS_ST_CW_KEY_EXCH,
TLS_ST_CW_CERT_VRFY,
TLS_ST_CW_CHANGE,
TLS_ST_CW_NEXT_PROTO,
TLS_ST_CW_FINISHED,
TLS_ST_SW_HELLO_REQ,
TLS_ST_SR_CLNT_HELLO,
DTLS_ST_SW_HELLO_VERIFY_REQUEST,
TLS_ST_SW_SRVR_HELLO,
TLS_ST_SW_CERT,
TLS_ST_SW_KEY_EXCH,
TLS_ST_SW_CERT_REQ,
TLS_ST_SW_SRVR_DONE,
TLS_ST_SR_CERT,
TLS_ST_SR_KEY_EXCH,
TLS_ST_SR_CERT_VRFY,
TLS_ST_SR_NEXT_PROTO,
TLS_ST_SR_CHANGE,
TLS_ST_SR_FINISHED,
TLS_ST_SW_SESSION_TICKET,
TLS_ST_SW_CERT_STATUS,
TLS_ST_SW_CHANGE,
TLS_ST_SW_FINISHED
TLS_ST_BEFORE,
TLS_ST_OK,
DTLS_ST_CR_HELLO_VERIFY_REQUEST,
TLS_ST_CR_SRVR_HELLO,
TLS_ST_CR_CERT,
TLS_ST_CR_COMP_CERT,
TLS_ST_CR_CERT_STATUS,
TLS_ST_CR_KEY_EXCH,
TLS_ST_CR_CERT_REQ,
TLS_ST_CR_SRVR_DONE,
TLS_ST_CR_SESSION_TICKET,
TLS_ST_CR_CHANGE,
TLS_ST_CR_FINISHED,
TLS_ST_CW_CLNT_HELLO,
TLS_ST_CW_CERT,
TLS_ST_CW_COMP_CERT,
TLS_ST_CW_KEY_EXCH,
TLS_ST_CW_CERT_VRFY,
TLS_ST_CW_CHANGE,
TLS_ST_CW_NEXT_PROTO,
TLS_ST_CW_FINISHED,
TLS_ST_SW_HELLO_REQ,
TLS_ST_SR_CLNT_HELLO,
DTLS_ST_SW_HELLO_VERIFY_REQUEST,
TLS_ST_SW_SRVR_HELLO,
TLS_ST_SW_CERT,
TLS_ST_SW_COMP_CERT,
TLS_ST_SW_KEY_EXCH,
TLS_ST_SW_CERT_REQ,
TLS_ST_SW_SRVR_DONE,
TLS_ST_SR_CERT,
TLS_ST_SR_COMP_CERT,
TLS_ST_SR_KEY_EXCH,
TLS_ST_SR_CERT_VRFY,
TLS_ST_SR_NEXT_PROTO,
TLS_ST_SR_CHANGE,
TLS_ST_SR_FINISHED,
TLS_ST_SW_SESSION_TICKET,
TLS_ST_SW_CERT_STATUS,
TLS_ST_SW_CHANGE,
TLS_ST_SW_FINISHED,
TLS_ST_SW_ENCRYPTED_EXTENSIONS,
TLS_ST_CR_ENCRYPTED_EXTENSIONS,
TLS_ST_CR_CERT_VRFY,
TLS_ST_SW_CERT_VRFY,
TLS_ST_CR_HELLO_REQ,
TLS_ST_SW_KEY_UPDATE,
TLS_ST_CW_KEY_UPDATE,
TLS_ST_SR_KEY_UPDATE,
TLS_ST_CR_KEY_UPDATE,
TLS_ST_EARLY_DATA,
TLS_ST_PENDING_EARLY_DATA_END,
TLS_ST_CW_END_OF_EARLY_DATA,
TLS_ST_SR_END_OF_EARLY_DATA
}
OSSL_HANDSHAKE_STATE;
@ -141,6 +229,8 @@ int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len);
int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type);
int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file);
int SSL_use_certificate_file(SSL *ssl, const char *file, int type);
X509 *SSL_get_peer_certificate(const SSL *ssl);
@ -161,7 +251,7 @@ int SSL_get_error(const SSL *ssl, int ret_code);
OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl);
SSL_CTX *SSL_CTX_new(const SSL_METHOD *method, void *rngctx);
SSL_CTX *SSL_CTX_new(const SSL_METHOD *method);
void SSL_CTX_free(SSL_CTX *ctx);
@ -299,6 +389,78 @@ int SSL_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type);
int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d,
long len);
const SSL_METHOD *TLS_method(void);
const SSL_METHOD *TLS_server_method(void);
const SSL_METHOD *TLS_client_method(void);
const SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */
const SSL_METHOD *TLSv1_server_method(void);
const SSL_METHOD *TLSv1_client_method(void);
const SSL_METHOD *TLSv1_1_method(void); /* TLSv1.1 */
const SSL_METHOD *TLSv1_1_server_method(void);
const SSL_METHOD *TLSv1_1_client_method(void);
const SSL_METHOD *TLSv1_2_method(void); /* TLSv1.2 */
const SSL_METHOD *TLSv1_2_server_method(void);
const SSL_METHOD *TLSv1_2_client_method(void);
SSL_SESSION *SSL_get1_session(SSL *ssl);
void SSL_SESSION_free(SSL_SESSION *session);
int SSL_set_session(SSL *s, SSL_SESSION *session);
const char *SSLeay_version(int t);
const char *SSL_state_string_long(const SSL *s);
const char *SSL_get_cipher_name(const SSL *s);
const char *SSL_alert_type_string_long(int value);
const char *SSL_alert_desc_string_long(int value);
void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb);
void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);
int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);
void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx,
SSL_psk_client_cb_func cb);
long SSL_CTX_set_mode(SSL_CTX *ctx, long larg);
void SSL_CTX_set_info_callback(SSL_CTX *ctx,
void (*cb)(const SSL *ssl, int type, int val));
void SSL_CTX_set_msg_callback(SSL_CTX *ctx,
void (*cb)(int write_p, int version,
int content_type, const void *buf,
size_t len, SSL *ssl, void *arg));
const char *SSL_get_cipher_list(const SSL *s, int n);
long SSL_set_tlsext_host_name(SSL *s, void *parg);
int SSL_get_ex_new_index(long argl, void *argp,
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
CRYPTO_EX_free *free_func);
const char *SSL_get_cipher_list(const SSL *s, int n);
int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str);
int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg);
int SSL_CTX_load_verify_file(SSL_CTX *ctx, const char *CAfile);
int SSL_CTX_load_verify_dir(SSL_CTX *ctx, const char *CApath);
int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
const char *CApath);
#ifdef __cplusplus
}
#endif

View file

@ -30,11 +30,6 @@
#include <openssl/x509_local.h>
#include <openssl/x509_vfy.h>
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Public Types
****************************************************************************/
@ -61,6 +56,24 @@ struct ssl_ctx_st
int read_ahead;
int read_buffer_len;
X509_VERIFY_PARAM param;
/* Default password callback. */
pem_password_cb *default_passwd_callback;
/* Default password callback user data. */
void *default_passwd_callback_userdata;
uint32_t mode;
/* optional informational callback */
void (*info_callback)(const SSL *ssl, int type, int val);
/* callback that allows applications to peek at protocol messages */
ossl_msg_cb msg_callback;
SSL_psk_client_cb_func psk_client_callback;
};
struct ssl_method_func_st
@ -97,16 +110,22 @@ struct ssl_session_st
long timeout;
long time;
X509 *peer;
const SSL_CIPHER *cipher;
int references;
struct
{
char hostname[TLSEXT_MAXLEN_host_name];
} ext;
};
struct ssl_st
{
/* protocol version(one of SSL3.0, TLS1.0, etc.) */
/* protocol version(one of SSL3.0, TLS1.0, etc.) */
int version;
unsigned long options;
/* shut things down(0x01 : sent, 0x02 : received) */
/* shut things down(0x01 : sent, 0x02 : received) */
int shutdown;
CERT *cert;
@ -116,7 +135,7 @@ struct ssl_st
const char **alpn_protos;
RECORD_LAYER rlayer;
/* where we are */
/* where we are */
OSSL_STATEM statem;
SSL_SESSION *session;
@ -129,11 +148,22 @@ struct ssl_st
int err;
void (*info_callback) (const SSL *ssl, int type, int val);
/* SSL low-level system arch point */
/* SSL low-level system arch point */
void *ssl_pm;
SSL_CIPHER *cipher_list;
};
struct ssl_cipher_st
{
const char *name; /* text name */
};
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/

View file

@ -20,42 +20,63 @@
#ifndef OPENSSL_MBEDTLS_WRAPPER_TLS1_H
#define OPENSSL_MBEDTLS_WRAPPER_TLS1_H
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Included Files
****************************************************************************/
#include <openssl/ssl.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define TLS1_AD_DECRYPTION_FAILED 21
#define TLS1_AD_RECORD_OVERFLOW 22
#define TLS1_AD_UNKNOWN_CA 48/* fatal */
#define TLS1_AD_ACCESS_DENIED 49/* fatal */
#define TLS1_AD_DECODE_ERROR 50/* fatal */
#define TLS1_AD_UNKNOWN_CA 48 /* fatal */
#define TLS1_AD_ACCESS_DENIED 49 /* fatal */
#define TLS1_AD_DECODE_ERROR 50 /* fatal */
#define TLS1_AD_DECRYPT_ERROR 51
#define TLS1_AD_EXPORT_RESTRICTION 60/* fatal */
#define TLS1_AD_PROTOCOL_VERSION 70/* fatal */
#define TLS1_AD_INSUFFICIENT_SECURITY 71/* fatal */
#define TLS1_AD_INTERNAL_ERROR 80/* fatal */
#define TLS1_AD_INAPPROPRIATE_FALLBACK 86/* fatal */
#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */
#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */
#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */
#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */
#define TLS1_AD_INAPPROPRIATE_FALLBACK 86 /* fatal */
#define TLS1_AD_USER_CANCELLED 90
#define TLS1_AD_NO_RENEGOTIATION 100
/* codes 110-114 are from RFC3546 */
#define TLS1_AD_UNSUPPORTED_EXTENSION 110
#define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111
#define TLS1_AD_UNRECOGNIZED_NAME 112
#define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113
#define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114
#define TLS1_AD_UNKNOWN_PSK_IDENTITY 115/* fatal */
#define TLS1_AD_NO_APPLICATION_PROTOCOL 120/* fatal */
#define TLS1_AD_UNKNOWN_PSK_IDENTITY 115 /* fatal */
#define TLS1_AD_NO_APPLICATION_PROTOCOL 120 /* fatal */
/* Special value for method supporting multiple versions */
#define TLS_ANY_VERSION 0x10000
#define TLS1_VERSION 0x0301
#define TLS1_1_VERSION 0x0302
#define TLS1_2_VERSION 0x0303
#define SSL_TLSEXT_ERR_OK 0
#define SSL_TLSEXT_ERR_NOACK 3
#define SSL_TLSEXT_ERR_OK 0
#define SSL_TLSEXT_ERR_NOACK 3
#define TLSEXT_MAXLEN_host_name 255
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
long SSL_set_tlsext_host_name(SSL *s, void *parg);
#ifdef __cplusplus
}

View file

@ -20,19 +20,22 @@
#ifndef OPENSSL_MBEDTLS_WRAPPER_TYPES_H
#define OPENSSL_MBEDTLS_WRAPPER_TYPES_H
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Public Types
****************************************************************************/
typedef void SSL_CIPHER;
typedef void CRYPTO_EX_new;
typedef void CRYPTO_THREADID;
typedef void X509_STORE;
typedef void RSA;
typedef void BIO;
typedef int (*OPENSSL_sk_compfunc)(const void *, const void *);
typedef int pem_password_cb(char *buf, int size,
int rwflag, void *userdata);
typedef struct bio_buf_mem_st BIO_BUF_MEM;
typedef struct bio_method_st BIO_METHOD;
typedef struct bio_st BIO;
typedef struct stack_st OPENSSL_STACK;
typedef struct ssl_method_st SSL_METHOD;
typedef struct ssl_method_func_st SSL_METHOD_FUNC;
@ -41,6 +44,7 @@ typedef struct ossl_statem_st OSSL_STATEM;
typedef struct ssl_session_st SSL_SESSION;
typedef struct ssl_ctx_st SSL_CTX;
typedef struct ssl_st SSL;
typedef struct ssl_cipher_st SSL_CIPHER;
typedef struct cert_st CERT;
typedef struct x509_st X509;
typedef struct X509_VERIFY_PARAM_st X509_VERIFY_PARAM;
@ -66,8 +70,4 @@ struct pkey_method_st
int (*pkey_load)(EVP_PKEY *pkey, const unsigned char *buf, int len);
};
#ifdef __cplusplus
}
#endif
#endif /* OPENSSL_MBEDTLS_WRAPPER_TYPES_H */

View file

@ -34,10 +34,13 @@
#include <openssl/obj.h>
#include <openssl/types.h>
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define X509_FILETYPE_PEM 1
#define X509_FILETYPE_ASN1 2
#define X509_FILETYPE_DEFAULT 3
/****************************************************************************
* Public Types
@ -45,7 +48,7 @@ extern "C"
struct x509_st
{
/* X509 certification platform private point */
/* X509 certification platform private point */
void *x509_pm;
const X509_METHOD *method;
@ -56,6 +59,8 @@ struct x509_method_st
int (*x509_new)(X509 *x, X509 *m_x);
void (*x509_free)(X509 *x);
int (*x509_load)(X509 *x, const unsigned char *buf, int len);
int (*x509_load_file)(X509 *x, const char *file);
int (*x509_load_path)(X509 *x, const char *path);
int (*x509_show_info)(X509 *x);
};
@ -66,6 +71,11 @@ struct cert_st
EVP_PKEY *pkey;
};
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/

View file

@ -0,0 +1,147 @@
/****************************************************************************
* apps/crypto/openssl_mbedtls_wrapper/mbedtls/bio_b64.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h>
#include <sys/param.h>
#include <mbedtls/base64.h>
#include <openssl/bio.h>
#include <openssl/types.h>
/****************************************************************************
* Pre-processor definitions
****************************************************************************/
#define BIO_B64_BUFSIZE ((BIO_B64_ENC_LEN / 3) * 4 + 1)
#define BIO_B64_ENC_LEN 192
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int b64_write(BIO *h, const char *buf, int num);
static int b64_read(BIO *h, char *buf, int size);
static int b64_new(BIO *h);
static int b64_free(BIO *data);
/****************************************************************************
* Private Data
****************************************************************************/
static const BIO_METHOD g_methods_b64 =
{
BIO_TYPE_BASE64,
"base64 encoding",
b64_write,
b64_read,
b64_new,
b64_free,
};
/****************************************************************************
* Private Functions
****************************************************************************/
static int b64_write(BIO *b, const char *in, int inl)
{
BIO *next;
int len;
int offset = 0;
int ret = 0;
size_t n;
unsigned char out[BIO_B64_BUFSIZE];
next = BIO_next(b);
if (next == NULL)
{
return 0;
}
while (inl > 0)
{
len = MIN(inl, BIO_B64_ENC_LEN);
ret = mbedtls_base64_encode(out, BIO_B64_BUFSIZE, &n,
(const unsigned char *)in + offset, len);
if (ret < 0)
{
break;
}
ret = BIO_write(next, out, n);
inl -= len;
offset += len;
}
return ret;
}
static int b64_read(BIO *b, char *out, int outl)
{
BIO *next;
int ret;
size_t n;
if (out == NULL)
{
return 0;
}
next = BIO_next(b);
if (next == NULL)
{
return 0;
}
ret = BIO_read(next, out, outl);
if (ret > 0)
{
ret = mbedtls_base64_decode((unsigned char *)out, outl, &n,
(const unsigned char *)out, ret);
if (ret == 0)
{
ret = n;
}
}
return ret;
}
static int b64_new(BIO *bi)
{
return 1;
}
static int b64_free(BIO *a)
{
return 1;
}
/****************************************************************************
* Public Functions
****************************************************************************/
const BIO_METHOD *BIO_f_base64(void)
{
return &g_methods_b64;
}

View file

@ -0,0 +1,151 @@
/****************************************************************************
* apps/crypto/openssl_mbedtls_wrapper/mbedtls/bio_lib.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h>
#include <openssl/bio.h>
/****************************************************************************
* Public Functions
****************************************************************************/
BIO *BIO_new(const BIO_METHOD *method)
{
BIO *bio = zalloc(sizeof(*bio));
if (bio == NULL)
{
return NULL;
}
bio->method = method;
if (method->create != NULL && !method->create(bio))
{
free(bio);
return NULL;
}
return bio;
}
BIO *BIO_push(BIO *b, BIO *bio)
{
BIO *lb;
if (b == NULL)
{
return bio;
}
else if (bio == NULL)
{
return b;
}
lb = b;
while (lb->next_bio != NULL)
{
lb = lb->next_bio;
}
lb->next_bio = bio;
bio->prev_bio = lb;
return b;
}
void BIO_set_flags(BIO *b, int flags)
{
b->flags |= flags;
}
int BIO_write(BIO *b, const void *data, int dlen)
{
if (b == NULL || dlen <= 0)
{
return 0;
}
if (b->method == NULL || b->method->bwrite_old == NULL)
{
return -2;
}
return b->method->bwrite_old(b, data, dlen);
}
int BIO_read(BIO *b, void *data, int dlen)
{
if (b == NULL || dlen <= 0)
{
return 0;
}
if (b->method == NULL || b->method->bread_old == NULL)
{
return -2;
}
return b->method->bread_old(b, data, dlen);
}
int BIO_free(BIO *a)
{
if (a == NULL)
{
return 0;
}
if (a->method != NULL && a->method->destroy != NULL)
{
a->method->destroy(a);
}
free(a);
return 1;
}
void BIO_free_all(BIO *bio)
{
while (bio != NULL)
{
BIO *b = bio;
bio = bio->next_bio;
BIO_free(b);
}
}
BIO *BIO_next(BIO *b)
{
if (b == NULL)
{
return NULL;
}
return b->next_bio;
}
int BIO_flush(BIO *b)
{
return 1;
}

View file

@ -0,0 +1,236 @@
/****************************************************************************
* apps/crypto/openssl_mbedtls_wrapper/mbedtls/bss_mem.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#include <openssl/bio.h>
/****************************************************************************
* Pre-processor definitions
****************************************************************************/
/* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That
* function is applied in several functions in this file and this limit
* ensures that the result fits in an int.
*/
#define LIMIT_BEFORE_EXPANSION 0x5ffffffc
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int mem_write(BIO *h, const char *buf, int num);
static int mem_read(BIO *h, char *buf, int size);
static int mem_new(BIO *h);
static int mem_free(BIO *data);
/****************************************************************************
* Private Types
****************************************************************************/
struct bio_buf_mem_st
{
unsigned long flags;
char *data;
size_t length; /* current number of bytes */
size_t max; /* size of buffer */
size_t offset; /* has been read */
};
/****************************************************************************
* Private Data
****************************************************************************/
static const BIO_METHOD g_mem_method =
{
BIO_TYPE_MEM,
"memory buffer",
mem_write,
mem_read,
mem_new,
mem_free,
};
/****************************************************************************
* Private Functions
****************************************************************************/
static int mem_buf_sync(BIO *b)
{
if (b != NULL && b->ptr != NULL)
{
BIO_BUF_MEM *bbm = (BIO_BUF_MEM *)b->ptr;
if (bbm->offset)
{
bbm->length = bbm->length - bbm->offset;
memmove(bbm->data, bbm->data + bbm->offset, bbm->length);
bbm->offset = 0;
}
}
return 0;
}
static size_t BUF_MEM_grow_clean(BIO_BUF_MEM *bbm, size_t len)
{
char *ret;
size_t n;
if (bbm->length >= len)
{
if (bbm->data != NULL)
{
memset(&bbm->data[len], 0, bbm->length - len);
}
bbm->length = len;
return len;
}
if (bbm->max >= len)
{
memset(&bbm->data[bbm->length], 0, len - bbm->length);
bbm->length = len;
return len;
}
/* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */
if (len > LIMIT_BEFORE_EXPANSION)
{
return 0;
}
n = MAX((len + 3) / 3 * 4, bbm->max);
ret = realloc(bbm->data, n);
if (ret == NULL)
{
return 0;
}
bbm->data = ret;
bbm->max = n;
bbm->length = len;
return len;
}
static int mem_write(BIO *b, const char *in, int inl)
{
BIO_BUF_MEM *bbm = (BIO_BUF_MEM *)b->ptr;
int blen;
if (b->flags & BIO_FLAGS_MEM_RDONLY)
{
return -1;
}
if (inl <= 0)
{
return 0;
}
else if (in == NULL)
{
return -1;
}
blen = bbm->length - bbm->offset;
mem_buf_sync(b);
if (BUF_MEM_grow_clean(bbm, blen + inl) == 0)
{
return -1;
}
memcpy(bbm->data + blen, in, inl);
return inl;
}
static int mem_read(BIO *b, char *out, int outl)
{
BIO_BUF_MEM *bbm = (BIO_BUF_MEM *)b->ptr;
if (outl <= 0)
{
return 0;
}
if (out == NULL)
{
return -1;
}
if (outl > bbm->length - bbm->offset)
{
outl = bbm->length - bbm->offset;
}
memcpy(out, bbm->data + bbm->offset, outl);
bbm->offset += outl;
return outl;
}
static int mem_new(BIO *bi)
{
BIO_BUF_MEM *bbm = zalloc(sizeof(*bbm));
if (bbm == NULL)
{
return 0;
}
bi->ptr = bbm;
return 1;
}
static int mem_free(BIO *a)
{
BIO_BUF_MEM *bbm;
if (a == NULL)
{
return 0;
}
bbm = (BIO_BUF_MEM *)a->ptr;
if (bbm->data)
{
free(bbm->data);
}
free(bbm);
return 1;
}
/****************************************************************************
* Public Functions
****************************************************************************/
const BIO_METHOD *BIO_s_mem(void)
{
return &g_mem_method;
}

View file

@ -38,7 +38,34 @@ unsigned long ERR_peek_last_error(void)
return errno;
}
void ERR_free_strings(void)
{
}
void ERR_error_string_n(unsigned long e, char *buf, size_t len)
{
mbedtls_strerror(e, buf, len);
}
void ERR_clear_error(void)
{
}
unsigned long ERR_get_error(void)
{
return errno;
}
void ERR_remove_state(unsigned long pid)
{
}
int ERR_load_crypto_strings(void)
{
return 1;
}
void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
void *u)
{
}

View file

@ -344,3 +344,12 @@ int EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey,
{
return 0;
}
int OpenSSL_add_all_algorithms(void)
{
return 0;
}
void EVP_cleanup(void)
{
}

View file

@ -21,13 +21,22 @@
* Included Files
****************************************************************************/
#include <nuttx/atomic.h>
#include <openssl/ssl_dbg.h>
#include <openssl/ssl3.h>
#include <openssl/ssl_local.h>
#include "ssl_port.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define SSL_SEND_DATA_MAX_LENGTH 1460
/****************************************************************************
* Private Types
****************************************************************************/
struct alpn_ctx
{
unsigned char data[23];
@ -56,6 +65,7 @@ static SSL_SESSION *SSL_SESSION_new(void)
goto failed2;
}
session->references = 1;
return session;
failed2:
@ -64,12 +74,6 @@ failed1:
return NULL;
}
static void SSL_SESSION_free(SSL_SESSION *session)
{
X509_free(session->peer);
ssl_mem_free(session);
}
static void
_openssl_alpn_to_mbedtls(struct alpn_ctx *ac, char ***palpn_protos)
{
@ -256,7 +260,7 @@ int SSL_get_error(const SSL *ssl, int ret_code)
return ret;
}
SSL_CTX *SSL_CTX_new(const SSL_METHOD *method, void *rngctx)
SSL_CTX *SSL_CTX_new(const SSL_METHOD *method)
{
SSL_CTX *ctx;
CERT *cert;
@ -1014,3 +1018,389 @@ void SSL_set_alpn_select_cb(SSL *ssl, void *arg)
_ssl_set_alpn_list(ssl);
}
SSL_SESSION *SSL_get1_session(SSL *ssl)
{
SSL_ASSERT2(ssl);
atomic_fetch_add(&ssl->session->references, 1);
return ssl->session;
}
void SSL_SESSION_free(SSL_SESSION *session)
{
SSL_ASSERT3(session);
if (atomic_fetch_sub(&session->references, 1) == 1)
{
X509_free(session->peer);
ssl_mem_free(session);
}
}
int SSL_set_session(SSL *s, SSL_SESSION *session)
{
SSL_ASSERT1(s);
SSL_ASSERT1(session);
SSL_SESSION_free(s->session);
s->session = session;
return 1;
}
const char *SSLeay_version(int t)
{
return "not available";
}
const char *SSL_state_string_long(const SSL *s)
{
SSL_ASSERT2(s);
switch (SSL_get_state(s))
{
case TLS_ST_CR_CERT_STATUS:
return "SSLv3/TLS read certificate status";
case TLS_ST_CW_NEXT_PROTO:
return "SSLv3/TLS write next proto";
case TLS_ST_SR_NEXT_PROTO:
return "SSLv3/TLS read next proto";
case TLS_ST_SW_CERT_STATUS:
return "SSLv3/TLS write certificate status";
case TLS_ST_BEFORE:
return "before SSL initialization";
case TLS_ST_OK:
return "SSL negotiation finished successfully";
case TLS_ST_CW_CLNT_HELLO:
return "SSLv3/TLS write client hello";
case TLS_ST_CR_SRVR_HELLO:
return "SSLv3/TLS read server hello";
case TLS_ST_CR_CERT:
return "SSLv3/TLS read server certificate";
case TLS_ST_CR_COMP_CERT:
return "TLSv1.3 read server compressed certificate";
case TLS_ST_CR_KEY_EXCH:
return "SSLv3/TLS read server key exchange";
case TLS_ST_CR_CERT_REQ:
return "SSLv3/TLS read server certificate request";
case TLS_ST_CR_SESSION_TICKET:
return "SSLv3/TLS read server session ticket";
case TLS_ST_CR_SRVR_DONE:
return "SSLv3/TLS read server done";
case TLS_ST_CW_CERT:
return "SSLv3/TLS write client certificate";
case TLS_ST_CW_COMP_CERT:
return "TLSv1.3 write client compressed certificate";
case TLS_ST_CW_KEY_EXCH:
return "SSLv3/TLS write client key exchange";
case TLS_ST_CW_CERT_VRFY:
return "SSLv3/TLS write certificate verify";
case TLS_ST_CW_CHANGE:
case TLS_ST_SW_CHANGE:
return "SSLv3/TLS write change cipher spec";
case TLS_ST_CW_FINISHED:
case TLS_ST_SW_FINISHED:
return "SSLv3/TLS write finished";
case TLS_ST_CR_CHANGE:
case TLS_ST_SR_CHANGE:
return "SSLv3/TLS read change cipher spec";
case TLS_ST_CR_FINISHED:
case TLS_ST_SR_FINISHED:
return "SSLv3/TLS read finished";
case TLS_ST_SR_CLNT_HELLO:
return "SSLv3/TLS read client hello";
case TLS_ST_SW_HELLO_REQ:
return "SSLv3/TLS write hello request";
case TLS_ST_SW_SRVR_HELLO:
return "SSLv3/TLS write server hello";
case TLS_ST_SW_CERT:
return "SSLv3/TLS write certificate";
case TLS_ST_SW_COMP_CERT:
return "TLSv1.3 write server compressed certificate";
case TLS_ST_SW_KEY_EXCH:
return "SSLv3/TLS write key exchange";
case TLS_ST_SW_CERT_REQ:
return "SSLv3/TLS write certificate request";
case TLS_ST_SW_SESSION_TICKET:
return "SSLv3/TLS write session ticket";
case TLS_ST_SW_SRVR_DONE:
return "SSLv3/TLS write server done";
case TLS_ST_SR_CERT:
return "SSLv3/TLS read client certificate";
case TLS_ST_SR_COMP_CERT:
return "TLSv1.3 read client compressed certificate";
case TLS_ST_SR_KEY_EXCH:
return "SSLv3/TLS read client key exchange";
case TLS_ST_SR_CERT_VRFY:
return "SSLv3/TLS read certificate verify";
case DTLS_ST_CR_HELLO_VERIFY_REQUEST:
return "DTLS1 read hello verify request";
case DTLS_ST_SW_HELLO_VERIFY_REQUEST:
return "DTLS1 write hello verify request";
case TLS_ST_SW_ENCRYPTED_EXTENSIONS:
return "TLSv1.3 write encrypted extensions";
case TLS_ST_CR_ENCRYPTED_EXTENSIONS:
return "TLSv1.3 read encrypted extensions";
case TLS_ST_CR_CERT_VRFY:
return "TLSv1.3 read server certificate verify";
case TLS_ST_SW_CERT_VRFY:
return "TLSv1.3 write server certificate verify";
case TLS_ST_CR_HELLO_REQ:
return "SSLv3/TLS read hello request";
case TLS_ST_SW_KEY_UPDATE:
return "TLSv1.3 write server key update";
case TLS_ST_CW_KEY_UPDATE:
return "TLSv1.3 write client key update";
case TLS_ST_SR_KEY_UPDATE:
return "TLSv1.3 read client key update";
case TLS_ST_CR_KEY_UPDATE:
return "TLSv1.3 read server key update";
case TLS_ST_EARLY_DATA:
return "TLSv1.3 early data";
case TLS_ST_PENDING_EARLY_DATA_END:
return "TLSv1.3 pending early data end";
case TLS_ST_CW_END_OF_EARLY_DATA:
return "TLSv1.3 write end of early data";
case TLS_ST_SR_END_OF_EARLY_DATA:
return "TLSv1.3 read end of early data";
default:
return "unknown state";
}
}
const char *SSL_get_cipher_name(const SSL *s)
{
SSL_ASSERT2(s);
SSL_ASSERT2(s->session);
return s->session->cipher->name ? s->session->cipher->name : "(NONE)";
}
const char *SSL_alert_type_string_long(int value)
{
switch (value >> 8)
{
case SSL3_AL_WARNING:
return "warning";
case SSL3_AL_FATAL:
return "fatal";
}
return "unknown";
}
const char *SSL_alert_desc_string_long(int value)
{
switch (value & 0xff)
{
case SSL3_AD_CLOSE_NOTIFY:
return "close notify";
case SSL3_AD_UNEXPECTED_MESSAGE:
return "unexpected message";
case SSL3_AD_BAD_RECORD_MAC:
return "bad record mac";
case SSL3_AD_DECOMPRESSION_FAILURE:
return "decompression failure";
case SSL3_AD_HANDSHAKE_FAILURE:
return "handshake failure";
case SSL3_AD_NO_CERTIFICATE:
return "no certificate";
case SSL3_AD_BAD_CERTIFICATE:
return "bad certificate";
case SSL3_AD_UNSUPPORTED_CERTIFICATE:
return "unsupported certificate";
case SSL3_AD_CERTIFICATE_REVOKED:
return "certificate revoked";
case SSL3_AD_CERTIFICATE_EXPIRED:
return "certificate expired";
case SSL3_AD_CERTIFICATE_UNKNOWN:
return "certificate unknown";
case SSL3_AD_ILLEGAL_PARAMETER:
return "illegal parameter";
case TLS1_AD_DECRYPTION_FAILED:
return "decryption failed";
case TLS1_AD_RECORD_OVERFLOW:
return "record overflow";
case TLS1_AD_UNKNOWN_CA:
return "unknown CA";
case TLS1_AD_ACCESS_DENIED:
return "access denied";
case TLS1_AD_DECODE_ERROR:
return "decode error";
case TLS1_AD_DECRYPT_ERROR:
return "decrypt error";
case TLS1_AD_EXPORT_RESTRICTION:
return "export restriction";
case TLS1_AD_PROTOCOL_VERSION:
return "protocol version";
case TLS1_AD_INSUFFICIENT_SECURITY:
return "insufficient security";
case TLS1_AD_INTERNAL_ERROR:
return "internal error";
case TLS1_AD_USER_CANCELLED:
return "user canceled";
case TLS1_AD_NO_RENEGOTIATION:
return "no renegotiation";
case TLS1_AD_UNSUPPORTED_EXTENSION:
return "unsupported extension";
case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
return "certificate unobtainable";
case TLS1_AD_UNRECOGNIZED_NAME:
return "unrecognized name";
case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
return "bad certificate status response";
case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
return "bad certificate hash value";
case TLS1_AD_UNKNOWN_PSK_IDENTITY:
return "unknown PSK identity";
case TLS1_AD_NO_APPLICATION_PROTOCOL:
return "no application protocol";
default:
return "unknown";
}
}
void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb)
{
ctx->default_passwd_callback = cb;
}
void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u)
{
ctx->default_passwd_callback_userdata = u;
}
void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, SSL_psk_client_cb_func cb)
{
ctx->psk_client_callback = cb;
}
int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)
{
return 0;
}
long SSL_CTX_set_mode(SSL_CTX *ctx, long larg)
{
return ctx->mode |= larg;
}
void SSL_CTX_set_info_callback(SSL_CTX *ctx,
void (*cb)(const SSL *ssl, int type, int val))
{
ctx->info_callback = cb;
}
void SSL_CTX_set_msg_callback(SSL_CTX *ctx,
void (*cb)(int write_p, int version,
int content_type, const void *buf,
size_t len, SSL *ssl, void *arg))
{
ctx->msg_callback = cb;
}
long SSL_set_tlsext_host_name(SSL *s, void *parg)
{
size_t len;
SSL_ASSERT1(s);
SSL_ASSERT1(s->session);
if (parg == NULL)
{
return 1;
}
len = strlen(parg);
if (len == 0 || len > TLSEXT_MAXLEN_host_name)
{
return 0;
}
memset(s->session->ext.hostname, 0, TLSEXT_MAXLEN_host_name);
memcpy(s->session->ext.hostname, parg, len);
return 1;
}
int SSL_CTX_load_verify_file(SSL_CTX *ctx, const char *CAfile)
{
X509 *x;
int ret;
SSL_ASSERT1(ctx);
SSL_ASSERT1(CAfile);
x = X509_new();
ret = X509_METHOD_CALL(load_file, x, CAfile);
if (ret)
{
X509_free(x);
return 0;
}
SSL_CTX_add_client_CA(ctx, x);
return 1;
}
int SSL_CTX_load_verify_dir(SSL_CTX *ctx, const char *CApath)
{
X509 *x;
int ret;
SSL_ASSERT1(ctx);
SSL_ASSERT1(CApath);
x = X509_new();
ret = X509_METHOD_CALL(load_path, x, CApath);
if (ret)
{
X509_free(x);
return 0;
}
SSL_CTX_add_client_CA(ctx, x);
return 1;
}
int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
const char *CApath)
{
if (CAfile == NULL && CApath == NULL)
{
return 0;
}
if (CAfile != NULL && !SSL_CTX_load_verify_file(ctx, CAfile))
{
return 0;
}
if (CApath != NULL && !SSL_CTX_load_verify_dir(ctx, CApath))
{
return 0;
}
return 1;
}
int SSL_get_ex_new_index(long argl, void *argp,
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
CRYPTO_EX_free *free_func)
{
return 0;
}
const char *SSL_get_cipher_list(const SSL *s, int n)
{
return NULL;
}
int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)
{
return 0;
}
int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str)
{
return 0;
}

View file

@ -95,7 +95,8 @@ IMPLEMENT_SSL_METHOD(SSL3_VERSION, -1, TLS_method_func, SSLv3_method);
IMPLEMENT_X509_METHOD(X509_method,
x509_pm_new, x509_pm_free,
x509_pm_load, x509_pm_show_info);
x509_pm_load, x509_pm_load_file,
x509_pm_load_path, x509_pm_show_info);
/**
* @brief get private key object method

View file

@ -27,10 +27,9 @@
#include <openssl/ssl.h>
#include "ssl_pm.h"
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* TLS method function implement */
@ -42,7 +41,7 @@ extern "C"
set_bufflen, \
get_verify_result, \
get_state) \
static const SSL_METHOD_FUNC func_name LOCAL_ATRR = \
static const SSL_METHOD_FUNC func_name = \
{ \
new, \
free, \
@ -62,7 +61,7 @@ extern "C"
#define IMPLEMENT_TLS_METHOD(ver, mode, fun, func_name) \
const SSL_METHOD* func_name(void) \
{ \
static const SSL_METHOD func_name##_data LOCAL_ATRR = \
static const SSL_METHOD func_name##_data = \
{ \
ver, \
mode, \
@ -74,7 +73,7 @@ extern "C"
#define IMPLEMENT_SSL_METHOD(ver, mode, fun, func_name) \
const SSL_METHOD* func_name(void) \
{ \
static const SSL_METHOD func_name##_data LOCAL_ATRR = \
static const SSL_METHOD func_name##_data = \
{ \
ver, \
mode, \
@ -87,14 +86,18 @@ extern "C"
new, \
free, \
load, \
load_file, \
load_path, \
show_info) \
const X509_METHOD* func_name(void) \
{ \
static const X509_METHOD func_name##_data LOCAL_ATRR = \
static const X509_METHOD func_name##_data = \
{ \
new, \
free, \
load, \
load_file, \
load_path, \
show_info \
}; \
return &func_name##_data; \
@ -106,7 +109,7 @@ extern "C"
load) \
const PKEY_METHOD* func_name(void) \
{ \
static const PKEY_METHOD func_name##_data LOCAL_ATRR = \
static const PKEY_METHOD func_name##_data = \
{ \
new, \
free, \
@ -115,6 +118,15 @@ extern "C"
return &func_name##_data; \
}
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/**
* @brief get X509 object method
*

View file

@ -38,7 +38,16 @@
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/error.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define X509_INFO_STRING_LENGTH 8192
#define READ_TIMEOUT_MS 50000 /* 50 seconds */
/****************************************************************************
* Private Types
****************************************************************************/
struct ssl_pm
{
@ -58,7 +67,7 @@ struct ssl_pm
struct x509_pm
{
mbedtls_x509_crt *x509_crt;
mbedtls_x509_crt x509_crt;
mbedtls_x509_crt *ex_crt;
};
@ -68,10 +77,15 @@ struct pkey_pm
mbedtls_pk_context *ex_pkey;
};
/****************************************************************************
* Public Data
****************************************************************************/
unsigned int max_content_len;
/* mbedtls debug level */
#define MBEDTLS_DEBUG_LEVEL 4
/****************************************************************************
* Private Functions
****************************************************************************/
/**
* @brief mbedtls debug function
@ -134,6 +148,7 @@ int ssl_pm_new(SSL *ssl)
mbedtls_ctr_drbg_init(&ssl_pm->ctr_drbg);
mbedtls_entropy_init(&ssl_pm->entropy);
mbedtls_ssl_init(&ssl_pm->ssl);
mbedtls_ssl_conf_read_timeout(&ssl_pm->conf, READ_TIMEOUT_MS);
ret = mbedtls_ctr_drbg_seed(&ssl_pm->ctr_drbg, mbedtls_entropy_func,
&ssl_pm->entropy, pers, pers_len);
@ -210,7 +225,8 @@ int ssl_pm_new(SSL *ssl)
}
mbedtls_ssl_set_bio(&ssl_pm->ssl, &ssl_pm->fd,
mbedtls_net_send, mbedtls_net_recv, NULL);
mbedtls_net_send, mbedtls_net_recv,
mbedtls_net_recv_timeout);
ssl->ssl_pm = ssl_pm;
@ -249,7 +265,7 @@ void ssl_pm_free(SSL *ssl)
static int ssl_pm_reload_crt(SSL *ssl)
{
int ret;
int ret = 0;
int mode;
struct ssl_pm *ssl_pm = ssl->ssl_pm;
struct x509_pm *ca_pm = (struct x509_pm *)ssl->client_CA->x509_pm;
@ -275,29 +291,16 @@ static int ssl_pm_reload_crt(SSL *ssl)
}
mbedtls_ssl_conf_authmode(&ssl_pm->conf, mode);
if (ca_pm->x509_crt)
{
mbedtls_ssl_conf_ca_chain(&ssl_pm->conf, ca_pm->x509_crt, NULL);
}
else if (ca_pm->ex_crt)
mbedtls_ssl_conf_ca_chain(&ssl_pm->conf, &ca_pm->x509_crt, NULL);
if (ca_pm->ex_crt)
{
mbedtls_ssl_conf_ca_chain(&ssl_pm->conf, ca_pm->ex_crt, NULL);
}
if (crt_pm->x509_crt && pkey_pm->pkey)
if (pkey_pm->pkey)
{
ret = mbedtls_ssl_conf_own_cert(&ssl_pm->conf,
crt_pm->x509_crt, pkey_pm->pkey);
}
else if (crt_pm->ex_crt && pkey_pm->ex_pkey)
{
ret = mbedtls_ssl_conf_own_cert(&ssl_pm->conf,
crt_pm->ex_crt, pkey_pm->ex_pkey);
}
else
{
ret = 0;
&crt_pm->x509_crt, pkey_pm->pkey);
}
if (ret)
@ -342,7 +345,8 @@ int ssl_pm_handshake(SSL *ssl)
ret = ssl_pm_reload_crt(ssl);
if (ret)
{
printf("%s: cert reload failed\n", __func__);
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
"%s: cert reload failed\n", __func__);
return 0;
}
@ -364,17 +368,21 @@ int ssl_pm_handshake(SSL *ssl)
}
/* OpenSSL return codes:
* 0 = did not complete, but may be retried
* 0 = The TLS/SSL handshake was not successful but was shut down
* controlled and by the specifications of the TLS/SSL protocol.
* 1 = successfully completed
* <0 = death
* <0 = The TLS/SSL handshake was not successful because a fatal error
* occurred either at the protocol level or a connection failure
* occurred.
*/
if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE)
{
ssl->err = ret;
ssl->err = (ret == MBEDTLS_ERR_SSL_WANT_READ) ? SSL_ERROR_WANT_READ :
SSL_ERROR_WANT_WRITE;
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
"mbedtls_ssl_handshake() return -0x%x", -ret);
return 0; /* OpenSSL: did not complete but may be retried */
return -1;
}
if (ret == 0)
@ -393,10 +401,11 @@ int ssl_pm_handshake(SSL *ssl)
{
ssl->err = ret == MBEDTLS_ERR_SSL_WANT_READ;
return 0;
return -1;
}
printf("%s: mbedtls_ssl_handshake() returned -0x%x\n", __func__, -ret);
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
"%s: mbedtls_ssl_handshake() returned -0x%x\n", __func__, -ret);
/* it's had it */
@ -415,7 +424,7 @@ ssl_ctx_get_mbedtls_x509_crt(SSL_CTX *ssl_ctx)
return NULL;
}
return x509_pm->x509_crt;
return &x509_pm->x509_crt;
}
mbedtls_x509_crt *
@ -451,7 +460,7 @@ int ssl_pm_shutdown(SSL *ssl)
else
{
struct x509_pm *x509_pm =
(struct x509_pm *)ssl->session->peer->x509_pm;
(struct x509_pm *)ssl->session->peer->x509_pm;
x509_pm->ex_crt = NULL;
ret = 1; /* OpenSSL: "The shutdown was successfully completed"
@ -481,6 +490,22 @@ int ssl_pm_read(SSL *ssl, void *buffer, int len)
{
ssl->err = SSL_ERROR_SYSCALL;
}
else if (ret == MBEDTLS_ERR_SSL_WANT_READ)
{
ssl->err = SSL_ERROR_WANT_READ;
}
else if (ret == MBEDTLS_ERR_SSL_WANT_WRITE)
{
ssl->err = SSL_ERROR_WANT_WRITE;
}
else if (ret == MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS)
{
ssl->err = SSL_ERROR_WANT_ASYNC;
}
else
{
ssl->err = SSL_ERROR_SSL;
}
ret = -1;
}
@ -613,7 +638,7 @@ OSSL_HANDSHAKE_STATE ssl_pm_get_state(const SSL *ssl)
case MBEDTLS_SSL_HANDSHAKE_OVER:
state = TLS_ST_OK;
break;
default :
default:
state = TLS_ST_BEFORE;
break;
}
@ -628,20 +653,8 @@ int x509_pm_show_info(X509 *x)
mbedtls_x509_crt *x509_crt;
struct x509_pm *x509_pm = x->x509_pm;
if (x509_pm->x509_crt)
{
x509_crt = x509_pm->x509_crt;
}
else if (x509_pm->ex_crt)
{
x509_crt = x509_pm->ex_crt;
}
else
{
x509_crt = NULL;
}
if (!x509_crt)
x509_crt = &x509_pm->x509_crt;
if (x509_crt->version == 0)
{
return -1;
}
@ -693,7 +706,7 @@ int x509_pm_new(X509 *x, X509 *m_x)
{
struct x509_pm *m_x509_pm = (struct x509_pm *)m_x->x509_pm;
x509_pm->ex_crt = m_x509_pm->x509_crt;
x509_pm->ex_crt = &m_x509_pm->x509_crt;
}
return 0;
@ -706,14 +719,7 @@ void x509_pm_free(X509 *x)
{
struct x509_pm *x509_pm = (struct x509_pm *)x->x509_pm;
if (x509_pm->x509_crt)
{
mbedtls_x509_crt_free(x509_pm->x509_crt);
ssl_mem_free(x509_pm->x509_crt);
x509_pm->x509_crt = NULL;
}
mbedtls_x509_crt_free(&x509_pm->x509_crt);
ssl_mem_free(x->x509_pm);
x->x509_pm = NULL;
}
@ -724,23 +730,8 @@ int x509_pm_load(X509 *x, const unsigned char *buffer, int len)
unsigned char *load_buf;
struct x509_pm *x509_pm = (struct x509_pm *)x->x509_pm;
if (x509_pm->x509_crt)
{
mbedtls_x509_crt_free(x509_pm->x509_crt);
}
if (!x509_pm->x509_crt)
{
x509_pm->x509_crt = ssl_mem_malloc(sizeof(mbedtls_x509_crt));
if (!x509_pm->x509_crt)
{
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
"no enough memory > (x509_pm->x509_crt)");
goto no_mem;
}
}
mbedtls_x509_crt_init(x509_pm->x509_crt);
mbedtls_x509_crt_free(&x509_pm->x509_crt);
mbedtls_x509_crt_init(&x509_pm->x509_crt);
if (buffer[0] != 0x30)
{
load_buf = ssl_mem_malloc(len + 1);
@ -754,32 +745,67 @@ int x509_pm_load(X509 *x, const unsigned char *buffer, int len)
ssl_memcpy(load_buf, buffer, len);
load_buf[len] = '\0';
ret = mbedtls_x509_crt_parse(x509_pm->x509_crt, load_buf, len + 1);
ret = mbedtls_x509_crt_parse(&x509_pm->x509_crt, load_buf, len + 1);
ssl_mem_free(load_buf);
}
else
{
printf("parsing as der\n");
ret = mbedtls_x509_crt_parse_der(x509_pm->x509_crt, buffer, len);
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL, "parsing as der\n");
ret = mbedtls_x509_crt_parse_der(&x509_pm->x509_crt, buffer, len);
}
if (ret)
{
printf("mbedtls_x509_crt_parse return -0x%x", -ret);
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
"mbedtls_x509_crt_parse return -0x%x", -ret);
goto failed;
}
return 0;
failed:
mbedtls_x509_crt_free(x509_pm->x509_crt);
ssl_mem_free(x509_pm->x509_crt);
x509_pm->x509_crt = NULL;
no_mem:
mbedtls_x509_crt_free(&x509_pm->x509_crt);
return -1;
}
int x509_pm_load_file(X509 *x, const char *path)
{
int ret;
struct x509_pm *x509_pm = (struct x509_pm *)x->x509_pm;
mbedtls_x509_crt_free(&x509_pm->x509_crt);
mbedtls_x509_crt_init(&x509_pm->x509_crt);
ret = mbedtls_x509_crt_parse_file(&x509_pm->x509_crt, path);
if (ret)
{
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
"mbedtls_x509_crt_parse_file return -0x%x", -ret);
mbedtls_x509_crt_free(&x509_pm->x509_crt);
return -1;
}
return 0;
}
int x509_pm_load_path(X509 *x, const char *path)
{
int ret;
struct x509_pm *x509_pm = (struct x509_pm *)x->x509_pm;
mbedtls_x509_crt_free(&x509_pm->x509_crt);
mbedtls_x509_crt_init(&x509_pm->x509_crt);
ret = mbedtls_x509_crt_parse_path(&x509_pm->x509_crt, path);
if (ret)
{
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
"mbedtls_x509_crt_parse_file return -0x%x", -ret);
mbedtls_x509_crt_free(&x509_pm->x509_crt);
return -1;
}
return 0;
}
int pkey_pm_new(EVP_PKEY *pk, EVP_PKEY *m_pkey)
{
struct pkey_pm *pkey_pm;
@ -977,7 +1003,8 @@ void _ssl_set_alpn_list(const SSL *ssl)
&((struct ssl_pm *)(ssl->ssl_pm))->conf,
ssl->alpn_protos))
{
fprintf(stderr, "mbedtls_ssl_conf_alpn_protocols failed\n");
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
"mbedtls_ssl_conf_alpn_protocols failed\n");
}
return;
@ -992,7 +1019,8 @@ void _ssl_set_alpn_list(const SSL *ssl)
&((struct ssl_pm *)(ssl->ssl_pm))->conf,
ssl->ctx->alpn_protos))
{
fprintf(stderr, "mbedtls_ssl_conf_alpn_protocols failed\n");
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
"mbedtls_ssl_conf_alpn_protocols failed\n");
}
}
@ -1070,8 +1098,8 @@ void SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
ssl->verify_mode = ctx->verify_mode;
mbedtls_ssl_set_hs_ca_chain(&ssl_pm->ssl, x509_pm_ca->x509_crt, NULL);
mbedtls_ssl_set_hs_own_cert(&ssl_pm->ssl, x509_pm->x509_crt,
mbedtls_ssl_set_hs_ca_chain(&ssl_pm->ssl, &x509_pm_ca->x509_crt, NULL);
mbedtls_ssl_set_hs_own_cert(&ssl_pm->ssl, &x509_pm->x509_crt,
pkey_pm->pkey);
mbedtls_ssl_set_hs_authmode(&ssl_pm->ssl, mode);
}

View file

@ -33,7 +33,9 @@ extern "C"
{
#endif
#define LOCAL_ATRR
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int ssl_pm_new(SSL *ssl);
void ssl_pm_free(SSL *ssl);
@ -57,6 +59,8 @@ int x509_pm_show_info(X509 *x);
int x509_pm_new(X509 *x, X509 *m_x);
void x509_pm_free(X509 *x);
int x509_pm_load(X509 *x, const unsigned char *buffer, int len);
int x509_pm_load_file(X509 *x, const char *path);
int x509_pm_load_path(X509 *x, const char *path);
int pkey_pm_new(EVP_PKEY *pk, EVP_PKEY *m_pk);
void pkey_pm_free(EVP_PKEY *pk);

View file

@ -124,6 +124,11 @@ int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type)
return 0;
}
int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file)
{
return 0;
}
int SSL_use_certificate_file(SSL *ssl, const char *file, int type)
{
return 0;

View file

@ -64,6 +64,7 @@ if(CONFIG_TINYCRYPT)
# Sources
# ############################################################################
list(APPEND CFLAGS -Dunix)
set(CSRCS
${TINYCRYPT_DIR}/lib/source/utils.c ${TINYCRYPT_DIR}/lib/source/ecc.c
${TINYCRYPT_DIR}/lib/source/ecc_platform_specific.c)
@ -120,7 +121,7 @@ if(CONFIG_TINYCRYPT)
if(CONFIG_TINYCRYPT_TEST)
list(APPEND CSRCS ${TINYCRYPT_DIR}/tests/test_ecc_utils.c)
list(APPEND INCDIR ${TINYCRYPT_DIR}/tests/include)
set(CFLAGS -Dhex2bin=ltp_hex2bin -DENABLE_TESTS)
list(APPEND CFLAGS -DENABLE_TESTS)
nuttx_add_application(
NAME

View file

@ -48,6 +48,7 @@ distclean::
$(Q) rm -rf $(TINYCRYPT_UNPACKNAME)
endif
CFLAGS += ${DEFINE_PREFIX}unix
CSRCS += tinycrypt/lib/source/utils.c
ifeq ($(CONFIG_TINYCRYPT_ECC),y)
@ -103,11 +104,11 @@ ifeq ($(CONFIG_TINYCRYPT_CTR_PRNG),y)
CSRCS += tinycrypt/lib/source/ctr_prng.c
endif
ifeq ($(CONFIG_TINYCRYPT_TEST),y)
ifneq ($(CONFIG_TINYCRYPT_TEST),)
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/crypto/tinycrypt/tinycrypt/tests/include
CFLAGS +=-Dhex2bin=ltp_hex2bin
CFLAGS +=-DENABLE_TESTS
CFLAGS += -DENABLE_TESTS
CSRCS += tinycrypt/tests/test_ecc_utils.c
MODULE += $(CONFIG_TINYCRYPT_TEST)
PRIORITY = $(CONFIG_TINYCRYPT_TEST_PRIORITY)
STACKSIZE = $(CONFIG_TINYCRYPT_TEST_STACKSIZE)

View file

@ -168,7 +168,7 @@ distclean::
$(call DELDIR, $(WOLFSSL_UNPACKNAME))
$(call DELDIR, $(WOLFSSL_EXAMPLESNAME))
else
distclean:
distclean::
$(call DELDIR, $(WOLFSSL_UNPACKNAME))
endif

View file

@ -36,6 +36,7 @@ ifneq ($(CONFIG_UTILS_SQLITE),)
PROGNAME = sqlite3
PRIORITY = 100
STACKSIZE = ${CONFIG_UTILS_SQLITE_STACKSIZE}
MODULE = $(CONFIG_UTILS_SQLITE)
MAINSRC = ${BUILDDIR}/shell.c
endif
@ -67,4 +68,3 @@ ifeq ($(wildcard sqlite/.git),)
endif
include $(APPDIR)/Application.mk

View file

@ -35,7 +35,7 @@
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/debug.h>
#include <nuttx/analog/adc.h>
#include <nuttx/analog/ioctl.h>
@ -95,7 +95,7 @@ static void adc_help(FAR struct adc_state_s *adc)
printf("Usage: adc [OPTIONS]\n");
printf("\nArguments are \"sticky\". "
"For example, once the ADC device is\n");
printf("specified, that device will be re-used until it is changed.\n");
printf("specified, that device will be reused until it is changed.\n");
printf("\n\"sticky\" OPTIONS include:\n");
printf(" [-p devpath] selects the ADC device. "
"Default: %s Current: %s\n",

View file

@ -25,6 +25,7 @@
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/time.h>
@ -149,8 +150,8 @@ int main(int argc, FAR char *argv[])
parse_args(&delta, argc, argv);
printf("Delta time is %ld seconds and %ld micro seconds.\n",
(long)delta.tv_sec, delta.tv_usec);
printf("Delta time is %jd seconds and %ld micro seconds.\n",
(intmax_t)delta.tv_sec, delta.tv_usec);
/* Call adjtime function. */
@ -161,8 +162,8 @@ int main(int argc, FAR char *argv[])
}
else
{
printf("Returned olddelta is %ld seconds and %ld micro seconds.\n",
(long)olddelta.tv_sec, olddelta.tv_usec);
printf("Returned olddelta is %jd seconds and %ld micro seconds.\n",
(intmax_t)olddelta.tv_sec, olddelta.tv_usec);
}
return ret;

View file

@ -33,7 +33,7 @@
#include <fcntl.h>
#include <errno.h>
#include <fixedmath.h>
#include <debug.h>
#include <nuttx/debug.h>
#include <unistd.h>
#include <nuttx/input/ajoystick.h>

View file

@ -393,7 +393,7 @@ int main(int argc, FAR char *argv[])
setrel.id = alarmid;
setrel.pid = g_alarm_daemon_pid;
setrel.reltime = (time_t)seconds;
setrel.reltime = seconds;
setrel.event.sigev_notify = SIGEV_SIGNAL;
setrel.event.sigev_signo = CONFIG_EXAMPLES_ALARM_SIGNO;

View file

@ -29,5 +29,5 @@ if(CONFIG_EXAMPLES_AUDIO_SOUND)
STACKSIZE
${CONFIG_EXAMPLES_AUDIO_SOUND_STACKSIZE}
SRCS
audio_rttl.cxx)
audio_rttl_main.c)
endif()

View file

@ -5,9 +5,11 @@
config EXAMPLES_AUDIO_SOUND
bool "Audio tone generator example (RTTL player)"
depends on AUDIO
depends on AUDIOUTILS_RTTTL_C
default n
---help---
Enable the audio RTTL player example
Enable the audio RTTL player example.
if EXAMPLES_AUDIO_SOUND
@ -23,4 +25,12 @@ config EXAMPLES_AUDIO_SOUND_STACKSIZE
int "Audio sound stack size"
default DEFAULT_TASK_STACKSIZE
comment "Program options"
config EXAMPLES_AUDIO_SOUND_MAXLEN
int "Maximum RTTL string length"
default 256
---help---
The maximum length of an RTTL string that can be read from a file.
endif

View file

@ -30,6 +30,6 @@ STACKSIZE = $(CONFIG_EXAMPLES_AUDIO_SOUND_STACKSIZE)
# Audio Example
MAINSRC = audio_rttl.cxx
MAINSRC = audio_rttl_main.c
include $(APPDIR)/Application.mk

View file

@ -1,361 +0,0 @@
/****************************************************************************
* apps/examples/audio_rttl/audio_rttl.cxx
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <arch/board/board.h>
#include <arch/chip/audio.h>
#include "audio_rttl.h"
/****************************************************************************
* Private Types
****************************************************************************/
/* Note - note freq on octave 1 */
#define C 16.35
#define CD 17.32
#define D 18.35
#define DE 19.45
#define E 20.60
#define F 21.83
#define FG 23.12
#define G 24.50
#define A 27.50
#define AB 29.14
#define B 30.84
/* Octave - base freq multiplier for the base freq */
#define OCT2 4
#define OCT3 8
#define OCT4 16
#define OCT5 32
#define OCT6 64
#define OCT7 128
#define OCT8 256
/****************************************************************************
* Public Functions
****************************************************************************/
extern "C" int main(int argc, FAR char *argv[])
{
int freq;
float base_freq;
char temp_note;
int octave;
int duration;
int note_duration;
int base_duration;
int bpm;
int cnt;
/* Set I/O parameters for power on. */
if (!board_audio_power_control(true))
{
printf("Error: board_audio_power_control() failure.\n");
return 1;
}
printf("Start Audio RTTL player\n");
bpm = 0;
octave = 0;
base_duration = 0;
note_duration = 0;
while (*g_song != ':')
{
g_song++;
}
g_song++;
if (*g_song == 'd')
{
g_song = g_song + 2;
base_duration = *g_song - '0';
g_song++;
if ((*g_song >= '0') && (*g_song <= '9'))
{
base_duration = (base_duration * 10) + (*g_song - '0');
g_song++;
}
g_song++;
}
if (*g_song == 'o')
{
g_song = g_song + 2;
octave = *g_song - '0';
g_song = g_song + 2;
}
if (octave == 2)
{
octave = OCT2;
}
else if (octave == 3)
{
octave = OCT3;
}
else if (octave == 4)
{
octave = OCT4;
}
else if (octave == 5)
{
octave = OCT5;
}
else if (octave == 6)
{
octave = OCT6;
}
else if (octave == 7)
{
octave = OCT7;
}
else if (octave == 8)
{
octave = OCT8;
}
if (*g_song == 'b')
{
g_song = g_song + 2;
bpm = 0;
for (cnt = 1; cnt <= 3; cnt++)
{
if (*g_song != ':')
{
bpm = bpm * 10 + (*g_song - '0');
g_song++;
}
}
g_song++;
}
do
{
if ((*g_song >= '0') && (*g_song <= '9'))
{
note_duration = *g_song - '0';
g_song++;
}
if ((*g_song >= '0') && (*g_song <= '9'))
{
note_duration = (note_duration * 10) + (*g_song - '0');
g_song++;
}
if (note_duration > 0)
{
duration = ((60 * 1000L / bpm) * 4) / note_duration;
}
else
{
duration = ((60 * 1000L / bpm) * 4) / base_duration;
}
base_freq = 0;
temp_note = ' ';
switch (*g_song)
{
case 'c':
{
temp_note = 'c';
base_freq = C;
break;
}
case 'd':
{
temp_note = 'd';
base_freq = D;
break;
}
case 'e':
{
temp_note = 'e';
base_freq = E;
break;
}
case 'f':
{
temp_note = 'f';
base_freq = F;
break;
}
case 'g':
{
temp_note = 'g';
base_freq = G;
break;
}
case 'a':
{
temp_note = 'a';
base_freq = A;
break;
}
case 'b':
{
temp_note = 'b';
base_freq = B;
break;
}
case 'p':
{
temp_note = 'p';
break;
}
default:
break;
}
g_song++;
if (*g_song == '.')
{
duration += duration / 2;
g_song++;
}
if (*g_song == '#')
{
if (temp_note == 'c')
{
base_freq = CD;
}
if (temp_note == 'd')
{
base_freq = DE;
}
if (temp_note == 'f')
{
base_freq = FG;
}
if (temp_note == 'a')
{
base_freq = AB;
}
g_song++;
}
if ((*g_song - '0') == '2')
{
octave = OCT2;
}
if ((*g_song - '0') == '3')
{
octave = OCT3;
}
if ((*g_song - '0') == '4')
{
octave = OCT4;
}
if ((*g_song - '0') == '5')
{
octave = OCT5;
}
if ((*g_song - '0') == '6')
{
octave = OCT6;
}
if ((*g_song - '0') == '7')
{
octave = OCT7;
}
if ((*g_song - '0') == '8')
{
octave = OCT8;
}
g_song++;
if (*g_song == ',')
{
g_song++;
}
/* play the sound */
freq = ceil(base_freq * octave);
if (!board_audio_tone_generator(1, -40, freq))
{
break;
}
usleep(duration * 1000L);
}
while (*g_song);
/* Sound off. */
if (!board_audio_tone_generator(0, 0, 0))
{
printf("Error: board_audio_tone_generator() failure.\n");
return 1;
}
/* Set I/O parameters for power off. */
if (!board_audio_power_control(false))
{
printf("Error: board_audio_power_control() failure.\n");
return 1;
}
printf("Done.\n");
return 0;
}

View file

@ -0,0 +1,305 @@
/****************************************************************************
* apps/examples/audio_rttl/audio_rttl_main.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <fcntl.h>
#include <getopt.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#ifdef CONFIG_PWM
#include <nuttx/timers/pwm.h>
#endif
#include <audioutils/rtttl.h>
/****************************************************************************
* Private Types
****************************************************************************/
struct player_s
{
void (*play)(struct rtttl_tone); /* Play RTTTL sound function */
void (*teardown)(void); /* Clean-up function */
void *arg; /* Private data for functions */
};
/****************************************************************************
* Private Data
****************************************************************************/
/* Default song if none was passed. Otherwise, used as buffer for reading
* from a file.
*/
static char g_default_song[CONFIG_EXAMPLES_AUDIO_SOUND_MAXLEN] =
"Test:d=4,o=6,b=90:c,c#,d,d#,e,f,f#,g,a,a#,b,p,b,a#,a,g,"
"f#,f,e,d#,d,c#,c";
/* The selected player is a global variable so it can be accessed from within
* the player functions properly.
*/
static struct player_s g_player;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: play_default
*
* Description:
* The default player choice; prints an error and exits.
*
* Input Parameters:
* sound - The sound to play
*
****************************************************************************/
static void play_default(struct rtttl_tone sound)
{
fprintf(stderr, "No player selected!\n");
return;
}
/****************************************************************************
* Name: teardown_default
*
* Description:
* Default tear-down function. Does nothing.
*
****************************************************************************/
static void teardown_default(void)
{
/* No-op */
return;
}
#ifdef CONFIG_PWM
/****************************************************************************
* Name: play_pwm
*
* Description:
* RTTTL player for audio sinks using PWM devices
*
* Input Parameters:
* sound - The sound to play
*
****************************************************************************/
static void play_pwm(struct rtttl_tone sound)
{
int err;
int i;
struct pwm_info_s info;
int fd = *((int *)g_player.arg);
info.channels[0].channel = 1;
info.channels[0].duty = b16divi(uitoub16(50) - 1, 100); /* 50% duty cycle */
info.channels[0].cpol = PWM_CPOL_NDEF; /* Default */
info.channels[0].dcpol = PWM_DCPOL_NDEF; /* Default */
info.frequency = sound.frequency_100hz / 100;
/* Copy settings to all channels */
for (i = 1; i < CONFIG_PWM_NCHANNELS; i++)
{
info.channels[i] = info.channels[0];
info.channels[i].channel = i + 1;
}
err = ioctl(fd, PWMIOC_SETCHARACTERISTICS, &info);
if (err < 0)
{
fprintf(stderr, "Failed to set PWM characteristics: %d\n", errno);
return;
}
err = ioctl(fd, PWMIOC_START, 0);
if (err < 0)
{
fprintf(stderr, "Failed to start PWM: %d\n", errno);
return;
}
usleep(sound.duration_us); /* Wait */
err = ioctl(fd, PWMIOC_STOP, 0);
if (err < 0)
{
fprintf(stderr, "Failed to stop PWM: %d\n", errno);
}
}
/****************************************************************************
* Name: teardown_pwm
*
* Description:
* Teardown function for PWM players
*
****************************************************************************/
static void teardown_pwm(void)
{
int fd = *((int *)g_player.arg);
close(fd);
}
#endif /* CONFIG_PWM */
/****************************************************************************
* Name: print_usage
*
* Description:
* Prints out the usage information for the program.
*
* Input Parameters:
* sink - The stream to output the usage information
*
****************************************************************************/
static void print_usage(FILE *sink)
{
fprintf(sink, "USAGE: audio_rttl <device path> [-s string] [-f file]\n");
fprintf(sink, "Ex: audio_rttl /dev/tone0\n");
}
/****************************************************************************
* Public Functions
****************************************************************************/
int main(int argc, FAR char *argv[])
{
int err;
int fd;
int c;
FILE *fptr;
size_t bread;
const char *song = g_default_song;
const char *device = NULL;
const char *file = NULL;
g_player.play = play_default;
g_player.teardown = teardown_default;
g_player.arg = NULL;
while ((c = getopt(argc, argv, ":hs:f:")) != -1)
{
switch (c)
{
case 'h':
print_usage(stdout);
break;
case 's':
song = optarg;
break;
case 'f':
file = optarg;
break;
case '?':
fprintf(stderr, "Unknown option -%c\n", optopt);
print_usage(stderr);
return EXIT_FAILURE;
}
}
if (argc <= optind)
{
fprintf(stderr, "Missing argument for device path.\n");
return EXIT_FAILURE;
}
device = argv[optind++];
/* Based on the device path, we choose which player should be used and
* perform the setup.
*/
#ifdef CONFIG_PWM
if (strstr(device, "pwm"))
{
fd = open(device, O_RDWR);
if (fd < 0)
{
fprintf(stderr, "Failed to open %s: %d\n", device, errno);
return EXIT_FAILURE;
}
else
{
g_player.arg = &fd;
}
g_player.play = play_pwm;
g_player.teardown = teardown_pwm;
}
#endif /* CONFIG_PWM */
/* If the user passed a file and a song string, use the string. Otherwise,
* read from the file
*/
if (file != NULL && song == g_default_song)
{
fptr = fopen(file, "r");
if (fptr == NULL)
{
fprintf(stderr, "Couldn't open file '%s': %d", file, errno);
g_player.teardown();
return EXIT_FAILURE;
}
bread =
fread(g_default_song, sizeof(char), sizeof(g_default_song), fptr);
/* Ensure null termination of the string. */
if (bread <= sizeof(g_default_song))
{
g_default_song[bread - 1] = '\0';
}
fclose(fptr);
}
/* Play the song */
err = rtttl_play(song, g_player.play);
if (err != 0)
{
fprintf(stderr, "Failed to play song: %d\n", err);
return err;
}
/* Tear down the player and exit */
g_player.teardown();
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,35 @@
# ##############################################################################
# apps/examples/baromonitor/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_EXAMPLES_BAROMONITOR)
nuttx_add_application(
NAME
${CONFIG_EXAMPLES_BAROMONITOR_PROGNAME}
PRIORITY
${CONFIG_EXAMPLES_BAROMONITOR_PRIORITY}
STACKSIZE
${CONFIG_EXAMPLES_BAROMONITOR_STACKSIZE}
MODULE
${CONFIG_EXAMPLES_BAROMONITOR}
SRCS
baromonitor_main.c)
endif()

View file

@ -0,0 +1,38 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config EXAMPLES_BAROMONITOR
tristate "Barometer monitoring dashboard example"
default n
depends on UORB
depends on LIBC_FLOATINGPOINT
depends on GRAPHICS_LVGL
depends on LV_USE_NUTTX
depends on LV_FONT_MONTSERRAT_24
depends on LV_FONT_MONTSERRAT_32
---help---
Enable the barometer monitoring dashboard.
if EXAMPLES_BAROMONITOR
config EXAMPLES_BAROMONITOR_PROGNAME
string "Program name"
default "baromonitor"
config EXAMPLES_BAROMONITOR_PRIORITY
int "Barometer monitor task priority"
default 100
config EXAMPLES_BAROMONITOR_STACKSIZE
int "Baromonitor stack size"
default DEFAULT_TASK_STACKSIZE
config EXAMPLES_BAROMONITOR_SAMPLERATE
int "Sample rate (ms)"
default 50
---help---
Sample rate in milliseconds of barometer data.
endif # EXAMPLES_BARO_DASHBOARD

View file

@ -0,0 +1,25 @@
############################################################################
# apps/examples/baromonitor/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifneq ($(CONFIG_EXAMPLES_BAROMONITOR),)
CONFIGURED_APPS += $(APPDIR)/examples/baromonitor
endif

View file

@ -0,0 +1,36 @@
############################################################################
# apps/examples/baromonitor/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(APPDIR)/Make.defs
# BAROMONITOR Barometer sensor example built-in application info
PROGNAME = $(CONFIG_EXAMPLES_BAROMONITOR_PROGNAME)
PRIORITY = $(CONFIG_EXAMPLES_BAROMONITOR_PRIORITY)
STACKSIZE = $(CONFIG_EXAMPLES_BAROMONITOR_STACKSIZE)
MODULE = $(CONFIG_EXAMPLES_BAROMONITOR)
# BAROMONITOR Barometer sensor example
MAINSRC = baromonitor_main.c
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,419 @@
/****************************************************************************
* apps/examples/baromonitor/baromonitor_main.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <uORB/uORB.h>
#include <lvgl/lvgl.h>
#include <nuttx/sensors/sensor.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define PRESSURE_COLOUR 0xef4444
#define TEMPERATURE_COLOUR 0x6366f1
#define LINE_WIDTH (8)
#define GAUGE_SIZE (600)
/* Axis limits */
#define PRESS_MIN (960)
#define PRESS_MAX (1010)
#define TEMP_MIN (-30)
#define TEMP_MAX (60)
#define TEMP_THRESH (TEMP_MAX - 10)
#define PRESS_MAJOR_TICKS_EVERY (5)
#define TEMP_MAJOR_TICKS_EVERY (5)
#define NUM_TEMP_LABELS ((TEMP_MAX - TEMP_MIN) / TEMP_MAJOR_TICKS_EVERY)
/****************************************************************************
* Private Data
****************************************************************************/
static const char *g_temp_labels[NUM_TEMP_LABELS + 1];
static char g_label_buf[NUM_TEMP_LABELS][8];
/****************************************************************************
* Private Functions
****************************************************************************/
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
static void lv_nuttx_uv_loop(uv_loop_t *loop, lv_nuttx_result_t *result)
{
lv_nuttx_uv_t uv_info;
void *data;
uv_loop_init(loop);
lv_memset(&uv_info, 0, sizeof(uv_info));
uv_info.loop = loop;
uv_info.disp = result->disp;
uv_info.indev = result->indev;
#ifdef CONFIG_UINPUT_TOUCH
uv_info.uindev = result->utouch_indev;
#endif
data = lv_nuttx_uv_init(&uv_info);
uv_run(loop, UV_RUN_DEFAULT);
lv_nuttx_uv_deinit(&data);
}
#endif
static void set_column_flex(lv_obj_t *obj)
{
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_flex_main_place(obj, LV_FLEX_ALIGN_CENTER, 0);
lv_obj_set_style_flex_cross_place(obj, LV_FLEX_ALIGN_CENTER, 0);
lv_obj_set_style_flex_track_place(obj, LV_FLEX_ALIGN_CENTER, 0);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* baromonitor_main
****************************************************************************/
int main(int argc, FAR char *argv[])
{
lv_nuttx_dsc_t info;
lv_nuttx_result_t result;
lv_obj_t *screen;
lv_obj_t *gauge_cont;
lv_obj_t *press_gauge;
lv_obj_t *press_line;
lv_obj_t *press_cont;
lv_obj_t *press_label;
lv_obj_t *temp_gauge;
lv_obj_t *temp_line;
lv_obj_t *temp_cont;
lv_obj_t *temp_label;
lv_obj_t *title_cont;
lv_obj_t *title;
lv_scale_section_t *section;
lv_style_t indicator_style;
lv_style_t minor_ticks_style;
lv_style_t main_line_style;
lv_style_t section_label_style;
lv_style_t section_minor_ticks_style;
lv_style_t section_main_line_style;
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
uv_loop_t ui_loop;
#endif
int err;
int fd;
bool got_data;
struct sensor_baro sensor_data;
unsigned instance = 0;
char topic[32];
if (argc == 2)
{
instance = atoi(argv[1]);
}
snprintf(topic, sizeof(topic), "sensor_baro%u", instance);
fd = orb_open("sensor_baro", instance, O_RDONLY | O_NONBLOCK);
if (fd < 0)
{
fprintf(stderr, "Could not open %s: %d\n", topic, errno);
return EXIT_FAILURE;
}
printf("Subscribed to %s\n", topic);
/* LVGL setup */
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
lv_memzero(&ui_loop, sizeof(ui_loop));
#endif
if (!lv_is_initialized())
{
printf("Initializing LVGL...\n");
lv_init();
printf("LVGL initialized...\n");
}
lv_nuttx_dsc_init(&info);
lv_nuttx_init(&info, &result);
if (result.disp == NULL)
{
fprintf(stderr, "Failed to initialize LVGL.\n");
close(fd);
return EXIT_FAILURE;
}
/* Set up stuff to render */
screen = lv_screen_active();
set_column_flex(screen);
/* Create containers for layout. We want a spanning title, followed by two
* side-by-side containers for the gauges.
*
* Gauge container is therefore a ROW flex, while its inner containers are
* column flex (scale followed by a label below)
*/
title_cont = lv_obj_create(screen);
lv_obj_set_size(title_cont, LV_PCT(100), LV_PCT(10));
lv_obj_align(title_cont, LV_ALIGN_CENTER, 0, 0);
title = lv_label_create(title_cont);
lv_label_set_text(title, "Barometer monitor");
lv_obj_set_style_text_font(title, &lv_font_montserrat_32, 0);
lv_obj_align(title, LV_ALIGN_CENTER, 0, 0);
gauge_cont = lv_obj_create(screen);
lv_obj_set_size(gauge_cont, LV_PCT(100), LV_PCT(90));
lv_obj_set_flex_flow(gauge_cont, LV_FLEX_FLOW_ROW);
lv_obj_set_style_flex_main_place(gauge_cont, LV_FLEX_ALIGN_CENTER, 0);
lv_obj_set_style_flex_cross_place(gauge_cont, LV_FLEX_ALIGN_CENTER, 0);
lv_obj_set_style_flex_track_place(gauge_cont, LV_FLEX_ALIGN_CENTER, 0);
press_cont = lv_obj_create(gauge_cont);
temp_cont = lv_obj_create(gauge_cont);
set_column_flex(press_cont);
set_column_flex(temp_cont);
lv_obj_set_size(press_cont, LV_PCT(50), LV_PCT(100));
lv_obj_set_size(temp_cont, LV_PCT(50), LV_PCT(100));
/* TODO: Get the text labels on the gauges to be padded better */
/* Pressure gauge */
press_gauge = lv_scale_create(press_cont);
lv_obj_set_size(press_gauge, GAUGE_SIZE, GAUGE_SIZE);
lv_scale_set_mode(press_gauge, LV_SCALE_MODE_ROUND_INNER);
lv_obj_set_style_bg_opa(press_gauge, LV_OPA_COVER, 0);
lv_obj_set_style_bg_color(press_gauge,
lv_palette_lighten(LV_PALETTE_RED, 4), 0);
lv_obj_set_style_radius(press_gauge, LV_RADIUS_CIRCLE, 0);
lv_obj_set_style_clip_corner(press_gauge, true, 0);
lv_obj_set_style_text_font(press_gauge, &lv_font_montserrat_24, 0);
lv_obj_align(press_gauge, LV_ALIGN_LEFT_MID, LV_PCT(5), 0);
lv_scale_set_label_show(press_gauge, true);
lv_scale_set_total_tick_count(press_gauge, (PRESS_MAX - PRESS_MIN));
lv_scale_set_major_tick_every(press_gauge, PRESS_MAJOR_TICKS_EVERY);
lv_obj_set_style_length(press_gauge, 5, LV_PART_ITEMS);
lv_obj_set_style_length(press_gauge, 10, LV_PART_INDICATOR);
lv_scale_set_range(press_gauge, PRESS_MIN, PRESS_MAX);
lv_scale_set_angle_range(press_gauge, 270);
lv_scale_set_rotation(press_gauge, 135);
press_line = lv_line_create(press_gauge);
lv_obj_set_style_line_width(press_line, LINE_WIDTH, LV_PART_MAIN);
lv_obj_set_style_line_rounded(press_line, true, LV_PART_MAIN);
lv_obj_set_style_line_color(press_line, lv_color_black(), LV_PART_MAIN);
lv_obj_center(press_line);
/* Temperature gauge */
temp_gauge = lv_scale_create(temp_cont);
lv_obj_set_size(temp_gauge, GAUGE_SIZE, GAUGE_SIZE);
lv_scale_set_label_show(temp_gauge, true);
lv_scale_set_mode(temp_gauge, LV_SCALE_MODE_ROUND_OUTER);
lv_obj_align(temp_gauge, LV_ALIGN_RIGHT_MID, LV_PCT(-5), 0);
lv_scale_set_total_tick_count(temp_gauge, (TEMP_MAX - TEMP_MIN));
lv_scale_set_major_tick_every(temp_gauge, TEMP_MAJOR_TICKS_EVERY);
lv_obj_set_style_length(temp_gauge, 5, LV_PART_ITEMS);
lv_obj_set_style_length(temp_gauge, 10, LV_PART_INDICATOR);
lv_scale_set_range(temp_gauge, TEMP_MIN, TEMP_MAX);
lv_scale_set_angle_range(temp_gauge, 270);
lv_scale_set_rotation(temp_gauge, 135);
temp_line = lv_line_create(temp_gauge);
lv_obj_set_style_line_width(temp_line, LINE_WIDTH, LV_PART_MAIN);
lv_obj_set_style_line_rounded(temp_line, true, LV_PART_MAIN);
lv_obj_center(temp_line);
/* Generate labels */
for (unsigned i = 0; i < NUM_TEMP_LABELS; i++)
{
snprintf(g_label_buf[i], sizeof(g_label_buf[i]), "%d °C",
TEMP_MIN + i * (TEMP_MAX - TEMP_MIN) / NUM_TEMP_LABELS);
g_temp_labels[i] = (const char *)g_label_buf[i];
}
g_temp_labels[NUM_TEMP_LABELS] = NULL;
lv_scale_set_text_src(temp_gauge, g_temp_labels);
/* Temp gauge styles */
lv_style_init(&indicator_style);
lv_style_set_text_font(&indicator_style, &lv_font_montserrat_24);
lv_style_set_text_color(&indicator_style,
lv_palette_darken(LV_PALETTE_BLUE, 3));
lv_style_set_line_color(&indicator_style,
lv_palette_darken(LV_PALETTE_BLUE, 3));
lv_style_set_width(&indicator_style, 10U); /* Tick length */
lv_style_set_line_width(&indicator_style, 2U); /* Tick width */
lv_obj_add_style(temp_gauge, &indicator_style, LV_PART_INDICATOR);
lv_style_init(&minor_ticks_style);
lv_style_set_line_color(&minor_ticks_style,
lv_palette_lighten(LV_PALETTE_BLUE, 2));
lv_style_set_width(&minor_ticks_style, 5U); /* Tick length */
lv_style_set_line_width(&minor_ticks_style, 2U); /* Tick width */
lv_obj_add_style(temp_gauge, &minor_ticks_style, LV_PART_ITEMS);
lv_style_init(&main_line_style);
lv_style_set_arc_color(&main_line_style,
lv_palette_darken(LV_PALETTE_BLUE, 3));
lv_style_set_arc_width(&main_line_style, 2U); /* Tick width */
/* Section on temperature gauge */
lv_style_init(&section_label_style);
lv_style_init(&section_minor_ticks_style);
lv_style_init(&section_main_line_style);
lv_style_set_text_font(&section_label_style, &lv_font_montserrat_24);
lv_style_set_text_color(&section_label_style,
lv_palette_darken(LV_PALETTE_RED, 3));
lv_style_set_line_color(&section_label_style,
lv_palette_darken(LV_PALETTE_RED, 3));
lv_style_set_line_width(&section_label_style, 5U); /* Tick width */
lv_style_set_line_color(&section_minor_ticks_style,
lv_palette_lighten(LV_PALETTE_RED, 2));
lv_style_set_line_width(&section_minor_ticks_style, 4U); /* Tick width */
lv_style_set_arc_color(&section_main_line_style,
lv_palette_darken(LV_PALETTE_RED, 3));
lv_style_set_arc_width(&section_main_line_style, 4U); /* Tick width */
section = lv_scale_add_section(temp_gauge);
lv_scale_section_set_range(section, TEMP_THRESH, TEMP_MAX);
lv_scale_section_set_style(section, LV_PART_INDICATOR,
&section_label_style);
lv_scale_section_set_style(section, LV_PART_ITEMS,
&section_minor_ticks_style);
lv_scale_section_set_style(section, LV_PART_MAIN,
&section_main_line_style);
/* Data labels */
press_label = lv_label_create(press_cont);
lv_obj_align(press_label, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_text_font(press_label, &lv_font_montserrat_24, 0);
temp_label = lv_label_create(temp_cont);
lv_obj_align(temp_label, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_text_font(temp_label, &lv_font_montserrat_24, 0);
/* Main loop */
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
lv_nuttx_uv_loop(&ui_loop, &result);
#else
for (; ; )
{
err = read(fd, &sensor_data, sizeof(sensor_data));
if (err < 0)
{
fprintf(stderr, "Failed read data from %s: %d\n", topic, errno);
}
else if (err == 0)
{
fprintf(stderr, "No data from %s\n", topic);
}
else
{
got_data = true;
}
if (got_data)
{
/* Update display if we obtained it successfully */
lv_label_set_text_fmt(temp_label, "Temperature: %2.f °C",
sensor_data.temperature);
lv_label_set_text_fmt(press_label, "Pressure: %2.f mbar",
sensor_data.pressure);
lv_scale_set_line_needle_value(press_gauge, press_line, -10,
(int32_t)sensor_data.pressure);
lv_scale_set_line_needle_value(temp_gauge, temp_line, -10,
(int32_t)sensor_data.temperature);
if (sensor_data.temperature < TEMP_THRESH)
{
lv_obj_set_style_line_color(
temp_line, lv_palette_darken(LV_PALETTE_BLUE, 3),
LV_PART_MAIN);
}
else
{
lv_obj_set_style_line_color(
temp_line, lv_palette_darken(LV_PALETTE_RED, 3),
LV_PART_MAIN);
}
got_data = false; /* Reset for next loop */
}
lv_timer_handler();
usleep(CONFIG_EXAMPLES_BAROMONITOR_SAMPLERATE * 1000);
/* TODO: make this equivalent in LIBUV loop */
}
#endif
orb_close(fd);
lv_nuttx_deinit(&result);
lv_deinit();
return EXIT_SUCCESS;
}

View file

@ -31,7 +31,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/debug.h>
#include <nuttx/power/battery_ioctl.h>
#include <nuttx/power/battery_charger.h>
@ -117,7 +117,7 @@ void health_report(int health)
case BATTERY_HEALTH_GOOD:
{
printf("Battery is in good condiction!\n");
printf("Battery is in good condition!\n");
}
break;

Some files were not shown because too many files have changed in this diff Show more