Apache NuttX is a mature, real-time embedded operating system (RTOS) https://nuttx.apache.org/
Find a file
Kerogit 25876e327e arch/avr: fix atomic load functions from arch_atomic.c
For AVR, atomic functions generated by LOAD macro turn into load surrounded
by up_irq_save and up_irq_restore. The generated code was incorrect as can
be seen from disassembly of __atomic_load_4:

in   r18, 0x3f ; store interrupts enabled flag
cli            ; disable interrupts
out  0x3f, r18 ; restore the flag
movw r30, r24  ; copy parameter (address) to pointer register
ld   r22, Z    ; indirect load to return value registers
ldd  r23, Z+1
ldd  r24, Z+2
ldd  r25, Z+3
ret            ; return

The interrupts are disabled to be immediately re-enabled, the load only takes
place after that.

Both up_irq_save and up_irq_restore are defined in inline assembly. Other
architectures (x86/486, Risc-V) mark this assembly with clobbers: memory.
Doing the same thing for AVR alleviates the problem:

in      r18, 0x3f ; store interrupts enabled flag
cli               ; disable interrupts
movw    r30, r24  ; copy address
ld      r22, Z    ; load
ldd     r23, Z+1
ldd     r24, Z+2
ldd     r25, Z+3
out     0x3f, r18 ; restore interrupts enabled flag
ret               ; return

Besides compiling the code and checking the assembly, this was tested
with a custom stress application on AVR128DA28.

Assembly of up_irq_enable is marked in the same way with regards to clobbers.

This patch also removes two functions that are not called from anywhere
(up_irq_disabled, putsreg)

Signed-off-by: Kerogit <kr.git@kerogit.eu>
2025-06-09 21:42:21 +08:00
.github build(deps): bump codelytv/pr-size-labeler from 1.10.2 to 1.10.3 2025-05-30 10:34:23 -03:00
arch arch/avr: fix atomic load functions from arch_atomic.c 2025-06-09 21:42:21 +08:00
audio audio/comp: fix build warning caused by invalid return value 2025-06-02 23:10:25 +08:00
binfmt libc/elf: rename modlib to libelf 2025-04-11 09:43:22 +08:00
boards arm64/imx9: Support & configure RGMII-ID on RTL8211F 2025-06-05 08:58:24 +02:00
cmake style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
crypto crypto: unify Private Types banners 2025-05-28 10:17:15 +08:00
Documentation Documentation\components\tools\index.rst: updated help checkpatch.sh tool 2025-06-03 20:16:05 +08:00
drivers arch: Flag all definitions of up_perf_* functions with CONFIG_ARCH_HAVE_PERF_EVENTS 2025-06-06 17:31:10 +08:00
dummy
fs fs: unify Private Types banners 2025-05-28 10:17:15 +08:00
graphics style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
include sched/spinlock: add recursive support(rspinlock_s) for spinlock 2025-06-06 09:48:17 +08:00
libs libs: unify Private Types banners 2025-05-28 10:17:15 +08:00
mm style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
net net/utils: avoid unalign access g_tcp_connections_buffer 2025-06-09 08:04:21 -03:00
openamp style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
pass1 Revert "build depend:Revert Make.dep intermediate ddc file" 2024-09-15 19:29:47 +08:00
sched sched: unify Private Types banners 2025-05-28 10:17:15 +08:00
syscall sched/gettid: Move thread ID to TLS 2025-04-08 22:53:10 +08:00
tools tools/doreleasenotes: remove deprecater API 2025-05-27 20:34:54 +08:00
video Revert "build depend:Revert Make.dep intermediate ddc file" 2024-09-15 19:29:47 +08:00
wireless Bluetooth SMP: added support for Legacy pairing (MITM) with passkey 2025-05-28 21:49:08 +08:00
.asf.yaml github: master branch protection tune. 2025-05-07 18:37:13 -05:00
.codespell-ignore-lines style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
.codespellrc style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
.gitignore gitignore: add Emacs auto-save files 2025-01-15 16:10:22 +08:00
.gitmessage docs/contributing: Add a commit message template 2025-06-03 17:33:24 +08:00
.pre-commit-config.yaml pre-commit: enable codespell checks 2025-05-05 12:34:39 +08:00
.yamllint
AUTHORS AUTHORS: add Matteo Golin 2025-05-27 20:34:16 +08:00
CMakeLists.txt style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
CONTRIBUTING.md style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
INVIOLABLES.md
Kconfig libc/elf: rename modlib to libelf 2025-04-11 09:43:22 +08:00
LICENSE style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
Makefile
NOTICE
README.md
ReleaseNotes

POSIX Badge License Issues Tracking Badge Contributors GitHub Build Badge Documentation Badge

Apache NuttX is a real-time operating system (RTOS) with an emphasis on standards compliance and small footprint. Scalable from 8-bit to 64-bit microcontroller environments, the primary governing standards in NuttX are POSIX and ANSI standards. Additional standard APIs from Unix and other common RTOSs (such as VxWorks) are adopted for functionality not available under these standards, or for functionality that is not appropriate for deeply-embedded environments (such as fork()).

For brevity, many parts of the documentation will refer to Apache NuttX as simply NuttX.

Getting Started

First time on NuttX? Read the Getting Started guide! If you don't have a board available, NuttX has its own simulator that you can run on terminal.

Documentation

You can find the current NuttX documentation on the Documentation Page.

Alternatively, you can build the documentation yourself by following the Documentation Build Instructions.

The old NuttX documentation is still available in the Apache wiki.

Supported Boards

NuttX supports a wide variety of platforms. See the full list on the Supported Platforms page.

Contributing

If you wish to contribute to the NuttX project, read the Contributing guidelines for information on Git usage, coding standard, workflow and the NuttX principles.

License

The code in this repository is under either the Apache 2 license, or a license compatible with the Apache 2 license. See the License Page for more information.