Skip to content

AVR DA/DB: fix for build failure and other smaller fixes - #20677

Merged
xiaoxiang781216 merged 4 commits into
apache:masterfrom
Swatantra-66:pr/avrdx-fixes-13.1
Oct 16, 2026
Merged

xiaoxiang781216 merged 4 commits into
apache:masterfrom
Swatantra-66:pr/avrdx-fixes-13.1

Conversation

@Swatantra-66

Copy link
Copy Markdown
Contributor

Submitted on behalf of Kerogit [email protected] per the patch series and discussion on [email protected].

Summary

This patch series fixes build failure for AVR DA/DB family and adds some other smaller fixes.

The build failure was caused by patch series that added LIBC_ATOMIC_IRQ Kconfig option during 13.1 development. Commit 4ca2256 selects this option by default for AVR chips but not for the DA/DB family, causing a build failure (atomic functions are missing.) The first patch of this series simply adds missing "select LIBC_ATOMIC_IRQ" for this family as well.

Other than that, version 13.1 added a performance regression which manifested as dropped bytes in USART peripheral during receive (with heavy round-robin preemptive scheduling load.) The regression was bisected to commit b32712d that fixes some bugs (which were affecting AVR DA/DB default build as well) but apparently adds more time-consuming work to context switch with interrupts disabled. The patch for this simply documents this possibility in the USART driver description.

The remaining patches fix unused variable warning, make (very unlikely) board initialization error more visible and reorder manipulation with stack pointer during context restore to do it in the way (presumably) intended by the chip manufacturer.

Impact

After the patch is applied, it is again possible to build the code.
Other than that, there is no impact on existing code/users.
The stack pointer reordering change is done in file shared with other AVR families - #ifdef blocks are used to cause no change for them.

Testing

I confirm that changes are verified on local setup and work as intended:

  • Build Host: Linux, AMD, GCC-AVR 14.2
  • Target: AVR (AVR128DA28), breadxavr:nsh

Testing logs before change:

$ tools/configure.sh -l breadxavr:nsh
$ make -j16
...
avr-ld: .../nuttx.git/staging/libsched.a(sem_destroy.o): in function `.L3':
sem_destroy.c:(.text.nxsem_destroy+0x46): undefined reference to `__atomic_load_4'
...

Testing logs after change:

$ tools/configure.sh -l breadxavr:nsh
$ make -j16
Register: nsh
Register: sh
LD: nuttx
Memory region Used Size Region Size %age Used
flash: 56377 B 128 KB 43.01%
sram: 780 B 16 KB 4.76%
eeprom: 0 B 512 B 0.00%
rodata: 606 B 4 KB 14.79%
CP: nuttx.hex
CP: nuttx.asm

To verify that the stack pointer change did not affect other AVR families, mega1284p-xplained:nsh was built before and after the change. The resulting binary was identical (with the exception of version string.)
Header and source files were checked by checkpatch with no issues found, spelling checked with aspell.

PR verification Self-Check

  • This PR introduces only one functional change.
  • I have updated all required description fields above.
  • My PR adheres to Contributing Guidelines and Documentation (git commit title and message, coding standard, etc).
  • My PR is still work in progress (not ready for review).
  • My PR is ready for review and can be safely merged into a codebase.

@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Arch: avr Issues related to all AVR(8-bit or 32-bit) architectures Size: S The size of the change in this PR is small Board: avr labels Oct 15, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@jerpelea jerpelea left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove
Signed-off-by: Swatantra Yadav [email protected]

Kerogit added 4 commits October 15, 2026 17:02
Patch 4ca2256 did not add required
select statement to AVR DA/DB subarchitecture. This patch fixes that.

Signed-off-by: Kerogit <[email protected]>
… speed

Patch series that includes commits 6e0d325 and b32712d fixed multiple
problems with preemptive scheduling combined with tickless configuration.
AVR DA/DB family uses tickless system by default and was affected by these
bugs too.

The patches, however, add more work to preemption code and that work
is done with interrupts disabled. This has noticeable impact on USART
communication using higher speeds, causing receive buffer overruns
and dropped bytes.

This patch adds a note about (not) achievable USART baud rate
to the documentation.

Signed-off-by: Kerogit <[email protected]>
According to their documentation, older AVR chips do not handle
stack pointer write in any special way. The newer chips (DA/DB family)
on the other hand disable interrupts in hardware when stack pointer
low byte is written, making sure that the program has time to also
write stack pointer high byte.

NuttX already assigns the stack pointer with interrupts disabled
but there is no reason to not do the write as intended.

The change is only in effect for the newer family and does not affect
the older chips. (Compiled binary is identical.)

Signed-off-by: Kerogit <[email protected]>
This patch silences a warning caused by unconditionally declared
variable which is only used with specific configuration.

Also, if the initialization fails, panic instead of returning.
(This should not happen since the code runs in initialization
phase but silently returning is not the correct action.)

Signed-off-by: Kerogit <[email protected]>
@Swatantra-66

Copy link
Copy Markdown
Contributor Author

@jerpelea Done. Removed the second Signed-off-by from all 4 commits, preserving only the author's DCO sign-off as requested.

@xiaoxiang781216
xiaoxiang781216 merged commit 97c643b into apache:master Oct 16, 2026
15 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: avr Issues related to all AVR(8-bit or 32-bit) architectures Area: Documentation Improvements or additions to documentation Board: avr Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants