tmedicci opened a new pull request, #2982: URL: https://github.com/apache/nuttx-apps/pull/2982
## Summary - interpreters/python: add wrapper to initialize Python - This wrapper application checks if the Python's modules are already mounted (and mounts them, if not), sets the necessary environment variables and, then, runs the Python interpreter. - interpreters/python: create Python's config files dynamically - The `Setup.local` and the `config.site` files are used by Python's build system to, respectively, enable or disable Python's modules and set/unset available functions in the target system. These files are now set according to NuttX's configs, enabling or disabling Python's features according to the configs set on NuttX. - interpreters/python: set ROMFS-generated data to const char - This allows the data to be placed in the .rodata section, which can be allocated in the flash or other read-only storage, freeing the internal memory. - interpreters/python: add patch to set `_PyRuntime` section - By setting a specific region for the `_PyRuntime` structure, it is possible to move it to the external memory, for instance, freeing the internal memory (this structure occupies around 140KiB). ## Impact This PR provides a set of improvements that allow running Python on NuttX easily: it provides a wrapper that enables running the Python interpreter directly with `python` and enables it to be built by architectures other than the RISC-V QEMU. Documentation will be updated on NuttX's OS repository as soon as we merge this PR. ## Testing Internal CI testing + `rv-virt:python`: ### Building ``` $ make -j distclean && ./tools/configure.sh rv-virt:python && make -j$(nproc) ``` ### Running ``` $ qemu-system-riscv32 -semihosting -M virt,aclint=on -cpu rv32 -smp 8 \ -global virtio-mmio.force-legacy=false \ -device virtio-serial-device,bus=virtio-mmio-bus.0 \ -chardev socket,telnet=on,host=127.0.0.1,port=3450,server=on,wait=off,id=foo \ -device virtconsole,chardev=foo \ -device virtio-rng-device,bus=virtio-mmio-bus.1 \ -netdev user,id=u1,hostfwd=tcp:127.0.0.1:10023-10.0.2.15:23,hostfwd=tcp:127.0.0.1:15001-10.0.2.15:5001 \ -device virtio-net-device,netdev=u1,bus=virtio-mmio-bus.2 \ -drive file=./mydisk-1gb.img,if=none,format=raw,id=hd \ -device virtio-blk-device,bus=virtio-mmio-bus.3,drive=hd \ -bios none -kernel ./nuttx -nographic ABC[ 0.041394] board_userled: LED 1 set to 0 [ 0.042074] board_userled: LED 2 set to 0 [ 0.042178] board_userled: LED 3 set to 0 telnetd [4:100] NuttShell (NSH) NuttX-10.4.0 nsh> python [ 2.321624] check_and_mount_romfs: Mounting ROMFS filesystem at target=/usr/local/lib with source=/dev/ram1 Python 3.13.0 (main, Jan 31 2025, 12:41:21) [GCC 13.2.0] on nuttx Type "help", "copyright", "credits" or "license" for more information. >>> ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org