nuttx/Documentation/guides/languages/pysimcoder.rst
Vinicius May f6ecf80ebb Documentation: brand new layout for NuttX documentation.
The documentation grew one page at a time, so the tree follows the
history of who wrote what and not the shape of NuttX. Scheduling is
spread over three places, a driver page can sit above the subsystem
that owns it, and the front page lists everything at the same level.
That is a lot to face when all you want to know is where the scheduler
lives.

This change files every page under the code it describes. It is a move,
not a rewrite: outside the ten pages named below, every page keeps the
text that is already in master, and no page's text is deleted.

What it does:

* Groups the table of contents into nine chapters.
* Moves the OS subsystems under os/: scheduling, memory, drivers,
  filesystem, networking, IPC, interrupts, libs, time.
* Renames the platform pages to the names the source tree uses, and
  derives their tags from the tree instead of by hand.
* Splits guides/ by subject.
* Adds Documentation/redirects.py, with a rule for every page that left
  its old path, so old URLs keep working. The redirect page also carries
  a link's #anchor across to the new page.

Ten pages have text that is new or rewritten. Nine of them are the
landing page of a chapter, which has to exist for the new structure:

    index                  the front page
    os/index               OS Design
    os/scheduling/index    Scheduling
    os/interrupts/index    Interrupts
    os/ipc/index           IPC
    os/time/index          Time and timers
    about/index            About
    developing/index       Developing NuttX
    ReleaseNotes/index     Release notes

The tenth is os/libs/libbuiltin, the only page here with technical
content: libs/libbuiltin/ had no page at all. Five SVG diagrams come
with these pages, hand-written XML with no editor metadata.

Nothing outside Documentation/ is touched.

How it was checked:

* Sphinx builds with -W: no warnings, and no document left outside a
  toctree.
* A script, offered in the PR, proves the narrow claim this rests on.
  For every page outside the ten named above it erases what a move
  touches -- link target, path, tag line, toctree block, table border --
  from the whole old text and the whole new text, and requires the two
  to be byte for byte identical. It also requires every sentence of a
  deleted page to turn up somewhere, and every page that left its old
  path to have a redirect, from a URL that existed, to where its content
  went. It exits non-zero and names the page if any of that is not true,
  and it tests added pages too, so forgetting to declare one cannot make
  it pass.
* An independent audit checked 133 factual claims on these ten pages
  against the tree, one shell command per claim: 130 confirmed, 1
  refuted and fixed here, 2 not checkable.
* tools/checkpatch.sh is clean over the range.

The diff is large because moving a page changes every link that points
to it. Most of it is pure renames, and board pages that gained one tag
line.

Assisted-by: Claude:claude-opus-5
2026-10-08 01:40:54 +08:00

164 lines
7.2 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.. include:: /substitutions.rst
.. _pysimcoder:
=================================
pysimCoder integration with NuttX
=================================
`PysimCoder <https://github.com/robertobucher/pysimCoder>`__ is as an open source
Rapid Control Application Development Tool which is able to transfer block diagrams into C code.
Combined with NuttX, it can be used in real time control application and as an alternative to
expensive licensed programs and prototyping platforms. Example of `DC motor control application
<https://www.youtube.com/watch?v=6HlGk3ecPNQ>`_ with PID controller and blocks for encoder,
PWM, GPIO and sending data over TCP to real time plotter can be seen on `NuttX Channel
<https://www.youtube.com/channel/UC0QciIlcUnjJkL5yJJBmluw>`_.
This documentation describes the steps that are needed to run application generated by pysimCoder
on NuttX and also keeps the track of peripherals that are supported by pysimCoder for NuttX RTOS.
Peripheral Support
==================
The following list shows the peripherals and functionalities supported in pysimCoder for NuttX RTOS.
========== =======================
Peripheral Notes
========== =======================
ADC
CAN Including SocketCAN
DAC
ENC
GPIO
PWM Multichannel support
UART Serial output
Sensors Basic support for DHTXX
TCP
UDP
========== =======================
Please note that the actual support for NuttX peripherals can be wider that what is mentioned here
in case this documentation was not updated when new functionalities were added to pysimCoder.
NuttX Configuration
===================
Several configuration options are necessary to be set in order to successfully compile pysimCoder
with NuttX. The list is the following:
==================================== =====================================
``CONFIG_ARCH_RAMVECTORS=y`` ``CONFIG_NSH_FILE_APPS=y``
``CONFIG_BOARDCTL_APP_SYMTAB=y`` ``CONFIG_LINE_MAX=64``
``CONFIG_BOARDCTL_OS_SYMTAB=y`` ``CONFIG_NSH_READLINE=y``
``CONFIG_BUILTIN=y`` ``CONFIG_ETC_ROMFS=y``
``CONFIG_ELF=y`` ``CONFIG_PSEUDOTERM=y``
``CONFIG_FS_BINFS=y`` ``CONFIG_TLS_NCLEANUP=1``
``CONFIG_FS_PROCFS=y`` ``CONFIG_PTHREAD_MUTEX_TYPES=y``
``CONFIG_FS_PROCFS_REGISTER=y`` ``CONFIG_PTHREAD_STACK_MIN=1024``
``CONFIG_FS_ROMFS=y`` ``CONFIG_LIBM=y``
``CONFIG_FS_TMPFS=y`` ``CONFIG_RR_INTERVAL=10``
``CONFIG_IDLETHREAD_STACKSIZE=2048`` ``CONFIG_SCHED_WAITPID=y``
``CONFIG_LIBC_EXECFUNCS=y`` ``CONFIG_SERIAL_TERMIOS=y``
``CONFIG_LIBC_STRERROR=y`` ``CONFIG_SYMTAB_ORDEREDBYNAME=y``
``CONFIG_MAX_TASKS=16`` ``CONFIG_SYSTEM_NSH=y``
``CONFIG_NSH_BUILTIN_APPS=y`` ``CONFIG_SYSTEM_NSH_STACKSIZE=4096``
``CONFIG_NSH_FILEIOSIZE=512`` ``CONFIG_INIT_ENTRYPOINT="nsh_main"``
==================================== =====================================
Note that ``CONFIG_LIBM=y`` might not be required for toolchains that already include
standard math library. However it is recommended to add ``CONFIG_LIBM=y`` to ensure
math library is included. Subsequently ``CONFIG_LIBC_FLOATINGPOINT=y`` is needed if double values
are to be printed on terminal.
In case you want to use Network and blocks like TCP or UDP, following configuration
options are required:
============================== ==================================
``CONFIG_NET=y`` ``CONFIG_NET_ROUTE=y``
``CONFIG_NETDB_DNSCLIENT=y`` ``CONFIG_NET_SOLINGER=y``
``CONFIG_NETDEV_LATEINIT=y`` ``CONFIG_NET_STATISTICS=y``
``CONFIG_NETDEV_STATISTICS=y`` ``CONFIG_NET_TCP=y``
``CONFIG_NETINIT_DHCPC=y`` ``CONFIG_NET_TCPBACKLOG=y``
``CONFIG_NETINIT_NOMAC=y`` ``CONFIG_NET_TCP_KEEPALIVE=y``
``CONFIG_NETUTILS_FTPC=y`` ``CONFIG_NET_TCP_WRITE_BUFFERS=y``
``CONFIG_NETUTILS_TELNETD=y`` ``CONFIG_NET_UDP=y``
``CONFIG_NETUTILS_TFTPC=y`` ``CONFIG_SYSTEM_DHCPC_RENEW=y``
``CONFIG_NET_ARP_SEND=y`` ``CONFIG_SYSTEM_NTPC=y``
``CONFIG_NET_BROADCAST=y`` ``CONFIG_SYSTEM_PING6=y``
``CONFIG_NET_IPv6=y`` ``CONFIG_SYSTEM_PING=y``
``CONFIG_NET_LOOPBACK=y`` ``CONFIG_SYSTEM_TEE=y``
``CONFIG_NET_PKT=y``
============================== ==================================
Board and application specific configuration like setting up peripherals or boot options might also be required,
please refer to board and platform documentation for those information. Once NuttX is configured it can be build
by simply running:
.. code-block:: console
$ make
Then we need to export build NuttX which can be done by executing command
.. code-block:: console
$ make export
This creates a zip file nuttx-export-xx.x.x.zip where xx.x.x is the version of NuttX. This file then have to be
moved to pysimCoder directory pysimCoder/CodeGen/nuttx, unzip there and then renamed just to nuttx-export. Then
enter the pysimCoder/CodeGen/nuttx/device directory and execute
.. code-block:: console
$ make
This compiles pysimCoder files that controls functions of separate blocks. PysimCoder can be either installed
on the system (please refer to the `pysimCoder manual <https://github.com/robertobucher/pysimCoder/blob/master/README.md>`_)
or script pysim-run.sh can be used to run pysimCoder without the installation. This script can be found in pysimCoder
root directory and is run by executing command
.. code-block:: console
$ ./pysim-run.sh
Please note that PYSUPSICTRL variable has to be set/exported in order to successfully compile NuttX application
designed with pysimCoder.
Using pysimCoder to design NuttX application
============================================
After running pysimCoder, separate blocks can be selected from the library menu on the left hand side. The menu contains
several libraries, NuttX specific blocks can be found in library "NuttX". It is also possible to use blocks from other
libraries like "input", "output", "math" and so on. Several blocks can have specific parameter options and various number
of inputs/outputs. Double left click on the block opens parameter settings while single right click on the block leads
to number of inputs/outputs setup. The pysimCoder interface can be seen in the picture below.
.. figure:: /guides/image/interface.png
:align: center
:width: 100%
pysimCoder interface: library menu can be seen on the left hand side
The NuttX template Makefile nuttx.tmf has to be selected in order to generate code for NuttX target.
This can be done in the top menu by clicking on Block settings icon which is highlighted in the red circle.
.. figure:: /guides/image/menu.png
:align: center
:width: 100%
pysimCoder menu: red block settings, green generate C-code
Block settings option open the following window (showed in the picture below) where you can set template Makefile and
also Python skript with parameters for the controllers.
.. figure:: /guides/image/template.png
:align: center
:width: 100%
pysimCoder Block settings menu
C code can be generated by selecting Generate C-code icon (highlighted in the green circle). Executable files are then
generated and can be flashed into the target. The flashing procedure can be target specific, please refer to platform´s
documentation. The generated application can be then run from NuttX command line by executing::
nsh> main