Skip to content

interpreters/berry: Add Berry scripting language#3564

Draft
speccy88 wants to merge 1 commit into
apache:masterfrom
speccy88:codex/add-berry-interpreter
Draft

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

Conversation

@speccy88

@speccy88 speccy88 commented Jun 26, 2026

Copy link
Copy Markdown

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
+#elif defined(__linux)
@@ -103 +105 @@
- const char *optarg;
+ const char *optvalue;

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.

ALL change is general, so it's better to upstream to Berry community.

@@ -0,0 +1,78 @@
/****************************************************************************
* apps/interpreters/berry/include/berry_conf.h

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.

it's better to enable berry by add sim:berry in boards/sim folder.

@speccy88 speccy88 force-pushed the codex/add-berry-interpreter branch from 26a9363 to 1471dcb Compare June 26, 2026 13:40

@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

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