Skip to content

sim: Add Berry interpreter configuration#19224

Open
speccy88 wants to merge 1 commit into
apache:masterfrom
speccy88:codex/add-berry-docs-sim
Open

sim: Add Berry interpreter configuration#19224
speccy88 wants to merge 1 commit into
apache:masterfrom
speccy88:codex/add-berry-docs-sim

Conversation

@speccy88

Copy link
Copy Markdown

Summary

  • Add Berry interpreter documentation under Documentation/applications/interpreters/berry.
  • Add a sim:berry configuration that enables the Berry interpreter and its required dependencies.

Context

This is the NuttX-side companion for the optional Berry interpreter app proposed in apache/nuttx-apps#3564.

Testing

Built sim:berry against apache/nuttx-apps#3564 locally on macOS arm64:

./tools/configure.sh -a ../nuttx_apps_berry_pr sim:berry
make olddefconfig
make -j8

Runtime smoke test:

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:34:41)
[clang 21.0.0 (clang-2100.1.1.101)] on NuttX (default)
> import os
> os.exit(0)
nsh>

@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Size: M The size of the change in this PR is medium Board: simulator labels Jun 26, 2026
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

acassis
acassis previously approved these changes Jun 26, 2026
@simbit18

simbit18 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Hi @speccy88 please fix

../nuttx/tools/checkpatch.sh -c -u -m -g  f5e3bb24595b78c5e329d13b1ad559a294ed3ef9..HEAD
❌ Missing Signed-off-by
Used config files:
    1: .codespellrc
Some checks failed. For contributing guidelines, see:
  https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md

Doc

Warning, treated as error:
/home/runner/work/nuttx/nuttx/Documentation/applications/interpreters/berry/index.rst:1:Title overline too short.

=================================
``berry`` Berry scripting language
=================================
make: *** [Makefile:52: html] Error 2

@speccy88 speccy88 dismissed stale reviews from acassis and xiaoxiang781216 via 4c55e0c June 27, 2026 09:36
@speccy88 speccy88 force-pushed the codex/add-berry-docs-sim branch from 089cab5 to 4c55e0c Compare June 27, 2026 09:36
@acassis

acassis commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

@speccy88 seems like the defconfig you added is not updated (normalized) with the current nuttx-apps and/or nuttx repos:

Configuration/Tool: sim/berry
2026-06-27 11:57:21
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Building NuttX...
  [1/1] Normalize sim/berry
HEAD detached at pull/19224/merge
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   boards/sim/sim/sim/configs/berry/defconfig

Please rebase your branch with upstream repos and then normalize your board:

$ ./tools/refresh.sh --silent sim:berry

@speccy88 speccy88 force-pushed the codex/add-berry-docs-sim branch from 4c55e0c to 7239051 Compare June 27, 2026 18:25
@speccy88

speccy88 commented Jun 27, 2026

Copy link
Copy Markdown
Author

Updated after apache/nuttx-apps#3564 merged.

I rebased this branch again onto current apache/nuttx master and reran the requested normalization with current apache/nuttx-apps master available as ../apps:

./tools/refresh.sh --silent sim:berry

The refresh completed with no tracked defconfig diff. I also verified locally:

./tools/checkpatch.sh -c -u -m -g origin/master..HEAD
git diff --check origin/master..HEAD
./tools/configure.sh -a ../apps sim:berry
make olddefconfig
make -j8

The local sim:berry build completed successfully. I also smoke-tested the simulator:

berry -v
berry -e print(40+2)

which printed Berry 1.1.0 and 42.

Current pushed head: bcac56e.

@speccy88 speccy88 marked this pull request as ready for review June 27, 2026 18:26
Add a sim:berry configuration to exercise the Berry interpreter.

Document the new berry command under applications/interpreters.

Signed-off-by: Frederick Blais <fred_blais5@hotmail.com>
@speccy88 speccy88 force-pushed the codex/add-berry-docs-sim branch from 7239051 to bcac56e Compare June 27, 2026 18:32
@xiaoxiang781216

Copy link
Copy Markdown
Contributor

@speccy88 but the ci still hit error:

====================================================================================
Configuration/Tool: sim/berry
2026-06-27 22:23:27
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Building NuttX...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100  506k  100  506k    0     0  3941k      0 --:--:-- --:--:-- --:--:-- 3941k
make[3]: *** [Makefile:74: berry] Error 1
make[3]: Target 'context' not remade because of errors.
make[2]: *** [Makefile:57: /github/workspace/sources/apps/interpreters/berry_context] Error 2
make[2]: Target 'context_all' not remade because of errors.
make[1]: *** [Makefile:187: context] Error 2
make: *** [tools/Unix.mk:471: /github/workspace/sources/apps/.context] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 397: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
  [1/1] Normalize sim/berry
On branch master
Your branch is up to date with 'origin/master'.

@acassis

acassis commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

@speccy88 I fetched your PR and tested locally and also got an error:

alan@dev:~/nuttxspace/nuttx$ git fetch upstream pull/19224/head
alan@dev:~/nuttxspace/nuttx$ git checkout FETCH_HEAD
alan@dev:~/nuttxspace/nuttx$ ./tools/configure.sh sim:berry
alan@dev:~/nuttxspace/nuttx$ make
Create version.h
Downloading berry-4db341475df9e9ad18e6741ef978b4c467690e09.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  506k    0  506k    0     0   424k      0 --:--:--  0:00:01 --:--:-- 1584k
Unpacking berry-4db341475df9e9ad18e6741ef978b4c467690e09.zip to berry
patching file default/berry.c
Hunk #1 FAILED at 22 (different line endings).
Hunk #2 FAILED at 103 (different line endings).
Hunk #3 FAILED at 148 (different line endings).
Hunk #4 FAILED at 151 (different line endings).
Hunk #5 FAILED at 272 (different line endings).
Hunk #6 FAILED at 277 (different line endings).
Hunk #7 FAILED at 281 (different line endings).
7 out of 7 hunks FAILED -- saving rejects to file default/berry.c.rej
make[3]: *** [Makefile:74: berry] Error 1
make[2]: *** [Makefile:57: /home/alan/nuttxspace/apps/interpreters/berry_context] Error 2
make[1]: *** [Makefile:187: context] Error 2
make: *** [tools/Unix.mk:471: /home/alan/nuttxspace/apps/.context] Error 2

Seems like your patch 0001-Fix-Berry-default-port-for-NuttX.patch doesn't apply to berry-4db341475df9e9ad18e6741ef978b4c467690e09.zip

Please double check, probably you used a different commit to apply it.

@simbit18

Copy link
Copy Markdown
Contributor

@speccy88 Of course, the same problem exists with CMake

test

Nuttx repository: speccy88/nuttx
Nuttx branch: codex/add-berry-docs-sim
Apps repository: speccy88/nuttx-apps
Apps branch: codex/add-berry-interpreter
Config: sim:berry
Build system: all

[1/9] Creating directories for 'berry_fetch-populate'
[1/9] Performing download step (download, verify and extract) for 'berry_fetch-populate'
-- Downloading...
   dst='/github/workspace/sources/nuttx/build/_deps/berry_fetch-subbuild/berry_fetch-populate-prefix/src/4db341475df9e9ad18e6741ef978b4c467690e09.zip'
   timeout='30 seconds'
   inactivity timeout='none'
-- Using src='https://github.com/berry-lang/berry/archive//4db341475df9e9ad18e6741ef978b4c467690e09.zip'
-- Downloading... done
-- extracting...
     src='/github/workspace/sources/nuttx/build/_deps/berry_fetch-subbuild/berry_fetch-populate-prefix/src/4db341475df9e9ad18e6741ef978b4c467690e09.zip'
     dst='/github/workspace/sources/apps/interpreters/berry/berry'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[2/9] No update step for 'berry_fetch-populate'
[3/9] Performing patch step for 'berry_fetch-populate'
patching file default/berry.c
Hunk #1 FAILED at 22 (different line endings).
Hunk #2 FAILED at 103 (different line endings).
Hunk #3 FAILED at 148 (different line endings).
Hunk #4 FAILED at 151 (different line endings).
Hunk #5 FAILED at 272 (different line endings).
CMake Error at /usr/local/share/cmake-3.26/Modules/FetchContent.cmake:1622 (message):
  Build step for berry_fetch failed: 1
Call Stack (most recent call first):
  /usr/local/share/cmake-3.26/Modules/FetchContent.cmake:1762:EVAL:2 (__FetchContent_directPopulate)
  /usr/local/share/cmake-3.26/Modules/FetchContent.cmake:1762 (cmake_language)
  /github/workspace/sources/apps/interpreters/berry/CMakeLists.txt:44 (FetchContent_Populate)


Hunk #6 FAILED at 277 (different line endings).
Hunk #7 FAILED at 281 (different line endings).
7 out of 7 hunks FAILED -- saving rejects to file default/berry.c.rej
FAILED: berry_fetch-populate-prefix/src/berry_fetch-populate-stamp/berry_fetch-populate-patch /github/workspace/sources/nuttx/build/_deps/berry_fetch-subbuild/berry_fetch-populate-prefix/src/berry_fetch-populate-stamp/berry_fetch-populate-patch 

https://github.com/simbit18/manual-nuttx-ci/actions/runs/28325515810/job/83914783218

@speccy88

Copy link
Copy Markdown
Author

You were right; the failure was real.

Root cause: Berry upstream stores default/berry.c with CRLF line endings, while the NuttX patch file is LF. Fresh Make and CMake builds could therefore reject every hunk before Berry was compiled.

I opened the companion apps fix here: apache/nuttx-apps#3567

That fix normalizes the downloaded Berry default/berry.c before applying the existing patch in both Make and CMake fetch paths.

Validated locally:

  • Fresh Berry archive patch apply path reproduces cleanly after normalization.
  • Make sim:berry build passes.
  • CMake/Ninja sim:berry testbuild passes.
  • Simulator smoke: berry -v => Berry 1.1.0, berry -e print(40+2) => 42.
  • ESP32-C3 hardware smoke on /dev/cu.usbmodem101: flashed esp32c3-devkit:usbconsole with Berry enabled; berry -v and berry -e print(40+2) both work.

Sorry for the churn on this one. The line-ending mismatch should be fixed by the apps PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Documentation Improvements or additions to documentation Board: simulator Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants