Skip to content

interpreters/berry: Add Berry scripting language#3564

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
speccy88:codex/add-berry-interpreter
Jun 27, 2026
Merged

interpreters/berry: Add Berry scripting language#3564
xiaoxiang781216 merged 1 commit into
apache:masterfrom
speccy88:codex/add-berry-interpreter

Conversation

@speccy88

@speccy88 speccy88 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add Berry as an optional interpreter under apps/interpreters/berry.
  • Pin upstream Berry at commit 4db341475df9e9ad18e6741ef978b4c467690e09 and fetch it from the upstream archive during Make/CMake builds.
  • Add Makefile, CMake, Kconfig, and NuttX Berry configuration.
  • Apply a small default-port patch so Berry reports NuttX in its startup banner and avoids the NuttX optarg macro collision.

Related PRs

Impact

  • New opt-in config: CONFIG_INTERPRETERS_BERRY.
  • Default command: berry.
  • Default priority: 100.
  • Default stack size: 12288.
  • Depends on ARCH_SETJMP_H, LIBC_FLOATINGPOINT, and SYSTEM_SYSTEM.
  • Keeps Berry shared-library module loading disabled, so it does not require CONFIG_LIBC_DLFCN.
  • Berry object files in the ESP32-C3 USB-console validation build: text=136529 data=0 bss=1004 dec=137533.

Testing

Host validation:

git diff --check -- interpreters/berry

Target build validation was done with current NuttX commit 5feb1c4b8b3fda0bfeccbf49a2be8865169cdfd4, this apps branch, RISC-V GCC 13.2.0, and kconfig-frontends on macOS arm64.

The USB-console profile was used for board testing because esp32c3-devkit:nsh routes NSH to UART0, while this board is attached via /dev/cu.usbmodem101 using ESP32-C3 USB Serial/JTAG.

./tools/configure.sh -a ../nuttx_apps_berry_pr esp32c3-devkit:usbconsole
kconfig-tweak --file .config --enable CONFIG_INTERPRETERS_BERRY \
  --set-str CONFIG_INTERPRETERS_BERRY_PROGNAME berry \
  --set-val CONFIG_INTERPRETERS_BERRY_STACKSIZE 12288 \
  --set-val CONFIG_INTERPRETERS_BERRY_PRIORITY 100
make olddefconfig
make -j8
make flash ESPTOOL_PORT=/dev/cu.usbmodem101 ESPTOOL_BAUD=460800

Build result for that ESP32-C3 image:

Memory region         Used Size  Region Size  %age Used
             ROM:      370348 B         4 MB      8.83%
     iram0_0_seg:       14656 B     321296 B      4.56%
     irom0_0_seg:      215736 B         4 MB      5.14%
     dram0_0_seg:       23168 B     321296 B      7.21%
     drom0_0_seg:      304776 B         4 MB      7.27%
    rtc_iram_seg:          52 B       8168 B      0.64%
rtc_reserved_seg:          0 GB         24 B      0.00%
text=230382 data=44356 bss=283630 dec=558368
nuttx.bin=370312 bytes

Runtime smoke test on ESP32-C3:

NuttShell (NSH)
nsh> berry -v
Berry 1.1.0
nsh> berry -e print(40+2)
42
nsh> berry
Berry 1.1.0 (build in Jun 26 2026, 09:07:01)
[GCC 13.2.0] on NuttX (default)
> import os
> os.exit(0)
nsh>

Companion sim:berry build and smoke test are documented in apache/nuttx#19224.

Comment thread interpreters/berry/README.md Outdated
Comment thread interpreters/berry/Kconfig Outdated
Comment thread interpreters/berry/0001-Fix-Berry-default-port-for-NuttX.patch
Comment thread interpreters/berry/include/berry_conf.h
acassis
acassis previously approved these changes Jun 26, 2026

@acassis acassis 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.

@speccy88 I will approve, but I agree with @xiaoxiang781216, better to submit these change to berry mainline

@speccy88 speccy88 marked this pull request as ready for review June 27, 2026 00:43
@speccy88 speccy88 dismissed stale reviews from acassis and xiaoxiang781216 via 02c6985 June 27, 2026 00:54
@speccy88 speccy88 force-pushed the codex/add-berry-interpreter branch from 1471dcb to 02c6985 Compare June 27, 2026 00:54
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>
@speccy88 speccy88 force-pushed the codex/add-berry-interpreter branch from 02c6985 to 39a4f0d Compare June 27, 2026 01:14
@xiaoxiang781216 xiaoxiang781216 merged commit a2b1cc1 into apache:master Jun 27, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Berry embedded scripting support as an optional NuttX system app

3 participants