Skip to content

Commit

Permalink
Documentation: Update Python documentation for socket module
Browse files Browse the repository at this point in the history
Update Python documentation after supporting Python's socket module
to reflect the commands used to run the RISC-V QEMU.
  • Loading branch information
tmedicci authored and xiaoxiang781216 committed Jan 8, 2025
1 parent 6469e30 commit 154a91c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
32 changes: 27 additions & 5 deletions Documentation/applications/interpreters/python/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,35 @@ This will generate a ``nutxx`` binary. This file can be run using the RISC-V QEM
Try Python in NSH
=================

Before running the RISC-V QEMU, create a raw disk image with the following command:

.. code:: console
$ dd if=/dev/zero of=./mydisk-1gb.img bs=1M count=1024
Then, run RISC-V QEMU with the following command:

.. code:: console
$ .qemu-system-riscv32 -semihosting -M virt,aclint=on -cpu rv32 -smp 1 -bios none -kernel nuttx -nographic
$ 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.062131] board_userled: LED 1 set to 0
[ 0.063269] board_userled: LED 2 set to 0
[ 0.063367] board_userled: LED 3 set to 0
telnetd [4:100]
ABC
NuttShell (NSH) NuttX-10.4.0
nsh> mount_modules
nsh> python_mount_modules
Mounting ROMFS filesystem at target=/usr/local/lib/ with source=/dev/ram1
nsh> export PYTHONHOME /usr/local
nsh> export PYTHON_BASIC_REPL 1
Expand All @@ -58,5 +80,5 @@ Demo

Check the following `asciinema <https://asciinema.org/>`_ demo to see how to run Python on NuttX. You can copy and paste the commands from the demo to try it yourself.

.. image:: https://asciinema.org/a/orkD8fKuahMEgQfBak9abliE4.svg
:target: https://asciinema.org/a/orkD8fKuahMEgQfBak9abliE4
.. image:: https://asciinema.org/a/bYYy1fyIOQ3hOY4lJ7L3WFcNb.svg
:target: https://asciinema.org/a/bYYy1fyIOQ3hOY4lJ7L3WFcNb
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ This configuration is used for 32-bit RISC-V
python
------

Enables the Python interpreter for NuttX. This configuration is based on `nsh`_.
Enables the Python interpreter for NuttX. This configuration is based on `netnsh`_.

For more information on how to build and run Python on NuttX,
please refer to the :doc:`Python Interpreter </applications/interpreters/python/index>` page.
Expand Down

0 comments on commit 154a91c

Please sign in to comment.