2929 LLVM_CACHE_SUFFIX : " build-llvm_libraries_ex"
3030 WASI_SDK_PATH : " /opt/wasi-sdk"
3131 WAMR_COMMON_OPTION :
32- " CONFIG_INTERPRETERS_WAMR=y\\ nCONFIG_INTERPRETERS_WAMR_STACKSIZE=327680\\ nCONFIG_INTERPRETERS_WAMR_LOG=y\\ nCONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN=y\\ nCONFIG_INTERPRETERS_WAMR_REF_TYPES=y\\ nCONFIG_INTERPRETERS_WAMR_ENABLE_SPEC_TEST=y\\ nCONFIG_INTERPRETERS_WAMR_SHARED_MEMORY=y\\ nCONFIG_INTERPRETERS_WAMR_BULK_MEMORY=y\\ nCONFIG_EOL_IS_LF=y\\ nCONFIG_ARM_SEMIHOSTING_HOSTFS=y\\ nCONFIG_ARM_SEMIHOSTING_HOSTFS_CACHE_COHERENCE=y\\ nCONFIG_RISCV_SEMIHOSTING_HOSTFS=y\\ nCONFIG_FS_HOSTFS=y\\ nCONFIG_LIBC_FLOATINGPOINT=y\\ nCONFIG_INTERPRETERS_WAMR_STACK_GUARD_SIZE=1024\\ n"
32+ " CONFIG_INTERPRETERS_WAMR=y\\ nCONFIG_INTERPRETERS_WAMR_LOG=y\\ nCONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN=y\\ nCONFIG_INTERPRETERS_WAMR_REF_TYPES=y\\ nCONFIG_INTERPRETERS_WAMR_ENABLE_SPEC_TEST=y\\ nCONFIG_INTERPRETERS_WAMR_SHARED_MEMORY=y\\ nCONFIG_INTERPRETERS_WAMR_BULK_MEMORY=y\\ nCONFIG_EOL_IS_LF=y\\ nCONFIG_LIBC_FLOATINGPOINT=y\\ nCONFIG_INTERPRETERS_WAMR_STACK_GUARD_SIZE=1024\\ n"
33+ HOSTFS_OPTION :
34+ " CONFIG_ARM_SEMIHOSTING_HOSTFS=y\\ nCONFIG_ARM_SEMIHOSTING_HOSTFS_CACHE_COHERENCE=y\\ nCONFIG_RISCV_SEMIHOSTING_HOSTFS=y\\ nCONFIG_FS_HOSTFS=y\\ n"
3335
3436jobs :
3537 build_llvm_libraries :
5052
5153 spec_test_on_qemu :
5254 runs-on : ubuntu-latest
53- needs : [build_llvm_libraries]
55+ needs : [build_llvm_libraries, build_llvm_libraries_xtensa ]
5456 container :
5557 image : ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
5658 strategy :
8688 target : " riscv64" ,
8789 fpu_type : " none"
8890 },
91+ {
92+ config : " boards/xtensa/esp32s3/esp32s3-devkit/configs/qemu_debug" ,
93+ target : " xtensa" ,
94+ fpu_type : " none"
95+ },
8996 ]
9097
9198 wamr_test_option : [
@@ -117,19 +124,25 @@ jobs:
117124 - target_config : { config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh64" }
118125 wamr_test_option : { mode: "-t aot -X" }
119126
127+ # Our xtensa environment doesn't have enough memory
128+ - target_config : { target: "xtensa" }
129+ wamr_feature_option : { mode: "-G" }
130+
120131 steps :
132+ # Note: we use an unreleased version nuttx for xtensa because
133+ # 12.4 doesn't contain necessary esp32s3 changes.
121134 - name : Checkout NuttX
122135 uses : actions/checkout@v4
123136 with :
124137 repository : apache/nuttx
125- ref : releases/12.4
138+ ref : ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || ' releases/12.4' }}
126139 path : nuttx
127140
128141 - name : Checkout NuttX Apps
129142 uses : actions/checkout@v4
130143 with :
131144 repository : apache/nuttx-apps
132- ref : releases/12.4
145+ ref : ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || ' releases/12.4' }}
133146 path : apps
134147
135148 - name : Checkout WAMR
@@ -149,7 +162,7 @@ jobs:
149162 ./core/deps/llvm/build/lib
150163 ./core/deps/llvm/build/libexec
151164 ./core/deps/llvm/build/share
152- key : ${{ needs.build_llvm_libraries.outputs.cache_key }}
165+ key : ${{ matrix.target_config.target == 'xtensa' && needs.build_llvm_libraries_xtensa.outputs.cache_key || needs.build_llvm_libraries.outputs.cache_key }}
153166
154167 - name : Quit if cache miss
155168 if : contains(matrix.wamr_test_option.mode, 'aot') && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
@@ -161,7 +174,12 @@ jobs:
161174
162175 # Inject the config option to NuttX
163176 # TODO: Merge this into NuttX once GC is generally available
177+ #
178+ # Note: the version of nuttx-apps we use for xtensa does have
179+ # an equivalent. (the default of INTERPRETERS_WAMR_TAIL_CALL is
180+ # different though.)
164181 - name : Modify Kconfig
182+ if : matrix.target_config.target != 'xtensa'
165183 run : |
166184 echo "\n" >> apps/interpreters/wamr/Kconfig
167185 echo "config INTERPRETERS_WAMR_GC" >> apps/interpreters/wamr/Kconfig
@@ -179,6 +197,25 @@ jobs:
179197 - name : Enable WAMR for NuttX
180198 run : |
181199 find nuttx/boards -name defconfig | xargs sed -i '$a\${{ env.WAMR_COMMON_OPTION }}'
200+
201+ - name : Set WAMR stack size for NuttX
202+ if : matrix.target_config.target != 'xtensa'
203+ run : |
204+ find nuttx/boards -name defconfig | xargs sed -i '$aCONFIG_INTERPRETERS_WAMR_STACKSIZE=327680\n'
205+
206+ # because qemu doesn't have a proper emulation of esp32s3 psram,
207+ # we are limited to the internal ram, which is about 400KB.
208+ - name : Set WAMR stack size for NuttX (xtensa)
209+ if : matrix.target_config.target == 'xtensa'
210+ run : |
211+ find nuttx/boards -name defconfig | xargs sed -i '$aCONFIG_INTERPRETERS_WAMR_STACKSIZE=25600\n'
212+
213+ # Note: the nuttx config we happened to use for xtensa already has
214+ # hostfs enabled.
215+ - name : Enable hostfs for NuttX
216+ if : matrix.target_config.target != 'xtensa'
217+ run : |
218+ find nuttx/boards -name defconfig | xargs sed -i '$a\${{ env.HOSTFS_OPTION }}'
182219
183220 - name : Enable WAMR Interpreter for NuttX
184221 run : |
@@ -199,22 +236,91 @@ jobs:
199236 run : |
200237 find nuttx/boards -name defconfig | xargs sed -i '$a\# CONFIG_ARCH_DPFPU is not set\n'
201238
239+ # Note: while a real hardware would need
240+ # INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR=y,
241+ # it doesn't work with xtensa qemu which we use on the CI because it
242+ # doesn't have a proper emulation of I/D separate mappings.
243+ # we work it around by using INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR=n.
244+ # this configuration won't work on a real hardware.
245+ - name : Tweak NuttX config (xtensa)
246+ if : matrix.target_config.target == 'xtensa'
247+ run : |
248+ find nuttx/boards -name defconfig | xargs sed -i '$aCONFIG_INTERPRETERS_WAMR_AOT_WORD_ALIGN_READ=y\n\# CONFIG_INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR is not set\n'
249+
202250 - name : Build wamrc
203251 if : contains(matrix.wamr_test_option.mode, 'aot')
204252 working-directory : apps/interpreters/wamr/wamr/wamr-compiler
205253 run : |
206254 cmake -Bbuild .
207255 cmake --build build
208256
209- - name : Build
210- id : build_firmware
257+ # the nuttx version we use for xtensa requires esptool.py newer than
258+ # what we have in our version of the apache-nuttx-ci-linux image.
259+ - name : Install the latest esptool.py (xtensa)
260+ if : matrix.target_config.target == 'xtensa'
261+ run : |
262+ pip3 install esptool==4.7.0
263+ esptool.py version
264+
265+ - name : Configure NuttX
211266 run : |
212- cd nuttx
213267 tools/configure.sh ${{ matrix.target_config.config }}
268+ working-directory : nuttx
269+
270+ # depending on configurations, the iwasm command line generated
271+ # by spec-test-script can be longer than the default NSH_LINELEN,
272+ # which is 64 or 80.
273+ - name : Tweak NuttX config
274+ run : |
275+ kconfig-tweak --set-val CONFIG_NSH_LINELEN 255
276+ working-directory : nuttx
277+
278+ - name : Build NuttX
279+ run : |
280+ make olddefconfig
214281 make -j$(nproc)
215- echo "firmware=$PWD/nuttx" >> $GITHUB_OUTPUT
282+ working-directory : nuttx
283+
284+ # for xtensa, build a 8MB firmware image.
285+ # simple boot is assumed. (thus the nuttx.bin offset in the image is 0)
286+ # qemu will infer the flash size from the file size.
287+ - name : Post build processing (xtensa)
288+ if : matrix.target_config.target == 'xtensa'
289+ run : |
290+ cd nuttx
291+ dd if=/dev/zero of=flash.img bs=1024 count=8192
292+ dd if=nuttx.bin of=flash.img conv=notrunc
293+ mv flash.img nuttx
294+
295+ - name : Build firmware path
296+ id : build_firmware_path
297+ run : |
298+ echo "firmware=$PWD/nuttx/nuttx" >> $GITHUB_OUTPUT
216299
300+ # for xtensa, use the espressif fork of qemu, which has esp32s3 support.
301+ - name : Install QEMU (xtensa)
302+ if : matrix.target_config.target == 'xtensa'
303+ run : |
304+ apt-get remove -y qemu-system-misc
305+ apt-get update && apt-get install -y libsdl2-2.0-0
306+ ./.github/scripts/install_qemu_xtensa.sh
307+ qemu-system-xtensa --version
308+ working-directory : apps/interpreters/wamr/wamr
309+
310+ - name : Test
311+ if : matrix.target_config.target != 'xtensa'
312+ run : |
313+ cd apps/interpreters/wamr/wamr/tests/wamr-test-suites
314+ ./test_wamr.sh -s spec ${{ matrix.wamr_test_option.mode }} -m ${{ matrix.target_config.target }} -b -Q -P -F ${{ steps.build_firmware_path.outputs.firmware }} ${{ matrix.wamr_feature_option.mode}}
315+
316+ # for xtensa, for some reasons, when running the tests
317+ # with test_wamr.sh -P, nuttx occasionally hangs after
318+ # "total segments stored 6" on the CI.
319+ # i (yamamoto) couldn't reproduce it locally (macOS) even
320+ # with the identical flash image.
321+ # for now, run the tests without -P.
217322 - name : Test
323+ if : matrix.target_config.target == 'xtensa'
218324 run : |
219325 cd apps/interpreters/wamr/wamr/tests/wamr-test-suites
220- ./test_wamr.sh -s spec ${{ matrix.wamr_test_option.mode }} -m ${{ matrix.target_config.target }} -b -Q -P - F ${{ steps.build_firmware .outputs.firmware }} ${{ matrix.wamr_feature_option.mode}}
326+ ./test_wamr.sh -s spec ${{ matrix.wamr_test_option.mode }} -m ${{ matrix.target_config.target }} -b -Q -F ${{ steps.build_firmware_path .outputs.firmware }} ${{ matrix.wamr_feature_option.mode}}
0 commit comments