Przeglądaj źródła

doc: add ThreadX SMP support and demo documentation

Huaqi Fang 2 miesięcy temu
rodzic
commit
3bf04ff569
3 zmienionych plików z 94 dodań i 2 usunięć
  1. 4 1
      doc/source/changelog.rst
  2. 86 0
      doc/source/design/app.rst
  3. 4 1
      doc/source/design/rtos.rst

+ 4 - 1
doc/source/changelog.rst

@@ -36,6 +36,7 @@ This is release version of ``0.9.0`` of Nuclei SDK, which is still under develop
     To stay lowpower, we also enable ``configUSE_PASSIVE_IDLE_HOOK`` and ``configUSE_IDLE_HOOK`` to ``1`` and in hook code,
     we let it execute ``wfi``.
   - Change FreeRTOS SMP ``smpdemo`` task delay time from 500 to 15 ms to make it possible to let different tasks run on different CORE.
+  - Add ThreadX SMP ``smpdemo`` application to demostrate ThreadX SMP kernel feature on Nuclei RISC-V CPU.
 
 * OS
 
@@ -47,13 +48,15 @@ This is release version of ``0.9.0`` of Nuclei SDK, which is still under develop
   - Add new interrupt masking feature for FreeRTOS porting, when ``configMAX_SYSCALL_INTERRUPT_PRIORITY >= 255``, it will use ``MSTATUS.MIE`` to do interrupt masking
   - Bugfix for UCOSII interrupt masking related API implementation, now optimize the implementation to use ``MSTATUS.MIE`` only to do interrupt masking
   - Bugfix for ThreadX idle task emulation in ``eclic_msip_handler`` task switch function, both ``mcause`` and ``msubm`` need to be saved and restored correctly.
+  - Mention about other RTOSs Nuclei supported, but not in Nuclei SDK, see :ref:`design_rtos_others`
+  - Add support for **ThreadX SMP** kernel support for both Nuclei RISC-V RV32 and RV64 CPU with ECLIC feature enabled.
 
 * Build System
 
   - Add new ``n300e`` CPU core support in build system and npk.yml for evalsoc
   - Add ``-isystem=/include/libncrt`` for nuclei llvm toolchain when using libncrt_xxx library, but ``-isystem=`` feature is not
     the same as gcc, see report here https://github.com/llvm/llvm-project/pull/82084#discussion_r2387373311, so when you use libncrt library with llvm toolchain, the header file could be wrongly included using newlib ones
-  - Recommend ``-fno-strict-aliasing`` as common compiler options should be passed, see :ref:`develop_buildsystem_var_common_flags``
+  - Recommend ``-fno-strict-aliasing`` as common compiler options should be passed, see :ref:`develop_buildsystem_var_common_flags`
   - Must pass ``-fomit-frame-pointer`` when using ``Zc`` extension to generate push/pop instructions, see https://github.com/riscvarchive/riscv-code-size-reduction/issues/194
   - Toolchain Terapines ZCC support is updated to match latest ZCC 4.1.7 release which is integrated with Nuclei Studio 2025.10
 

+ 86 - 0
doc/source/design/app.rst

@@ -3003,6 +3003,91 @@ In Nuclei SDK, we provided code and Makefile for this ``threadx demo`` applicati
     thread 6_7 is running, current is 7, thread 6 counter 5, thread 7 counter 4
 
 
+
+.. _design_app_threadx_smpdemo:
+
+smpdemo
+~~~~~~~
+
+This `threadx smpdemo application`_ is show basic ThreadX-SMP thread functions.
+
+This threadx smp demo is modified based on https://github.com/eclipse-threadx/threadx/blob/v6.4.1_rel/ports_smp/linux/gnu/example_build/sample_threadx.c
+
+In Nuclei SDK, we provided code and Makefile for this ``threadx smpdemo`` application to demostrate ThreadX SMP Kernel ability.
+
+* **RTOS = ThreadX** is added in its Makefile to include ThreadX service
+* **SMP := 2**: it can be 2 or other smp cpu count number, such as 4, 8, etc.
+  **TX_THREAD_SMP_MAX_CORES** in ``OS/ThreadX/ports_smp/nuclei/tx_port.h`` will use this ``SMP_CPU_CNT`` defined via ``SoC/evalsoc/build.mk``
+  to control threadx smp max core numbers.
+* The **TX_INCLUDE_USER_DEFINE_FILE** macro is defined in Makefile, so you can include customized user configuration
+  file ``tx_user.h``
+
+
+**How to run this application:**
+
+.. code-block:: shell
+
+    # Assume that you can set up the Tools and Nuclei SDK environment
+    # cd to the threadx smpdemo directory
+    cd application/threadx/smpdemo
+    # by default, it required ux900fd SMPx2 CPU with ECLIC
+    # Clean the application first
+    make SOC=evalsoc clean
+    # Build and upload the application
+    make SOC=evalsoc upload
+
+**Expected output as below:**
+
+.. code-block:: console
+
+    Nuclei SDK Build Time: Dec  9 2025, 15:31:52
+    Download Mode: SRAM
+    CPU Frequency 50330009 Hz
+    CPU HartID: 0
+    **** ThreadX SMP Linux Demonstration **** (c) 1996-2020 Microsoft Corporation
+
+            thread 0 events sent                    1, thread 0 cpu 0
+            thread 1 messages sent:              1035, thread 1 cpu 1
+            thread 2 messages received:          1530, thread 2 cpu 1
+            thread 3 obtained semaphore:            2, thread 3 cpu 1
+            thread 4 obtained semaphore:            1, thread 4 cpu 1
+            thread 5 events received:               1, thread 5 cpu 1
+            thread 6 mutex obtained:                2, thread 6 cpu 1
+            thread 7 mutex obtained:                2, thread 7 cpu 1
+
+    **** ThreadX SMP Linux Demonstration **** (c) 1996-2020 Microsoft Corporation
+
+            thread 0 events sent                    2, thread 0 cpu 0
+            thread 1 messages sent:             10110, thread 1 cpu 1
+            thread 2 messages received:         10597, thread 2 cpu 1
+            thread 3 obtained semaphore:            5, thread 3 cpu 1
+            thread 4 obtained semaphore:            5, thread 4 cpu 1
+            thread 5 events received:               2, thread 5 cpu 1
+            thread 6 mutex obtained:                6, thread 6 cpu 1
+            thread 7 mutex obtained:                5, thread 7 cpu 1
+
+    **** ThreadX SMP Linux Demonstration **** (c) 1996-2020 Microsoft Corporation
+
+            thread 0 events sent                    3, thread 0 cpu 1
+            thread 1 messages sent:             19285, thread 1 cpu 0
+            thread 2 messages received:         19719, thread 2 cpu 0
+            thread 3 obtained semaphore:            9, thread 3 cpu 0
+            thread 4 obtained semaphore:            9, thread 4 cpu 0
+            thread 5 events received:               3, thread 5 cpu 0
+            thread 6 mutex obtained:               10, thread 6 cpu 0
+            thread 7 mutex obtained:                9, thread 7 cpu 0
+
+    **** ThreadX SMP Linux Demonstration **** (c) 1996-2020 Microsoft Corporation
+
+            thread 0 events sent                    4, thread 0 cpu 0
+            thread 1 messages sent:             28358, thread 1 cpu 1
+            thread 2 messages received:         28817, thread 2 cpu 1
+            thread 3 obtained semaphore:           13, thread 3 cpu 1
+            thread 4 obtained semaphore:           13, thread 4 cpu 1
+            thread 5 events received:               4, thread 5 cpu 1
+            thread 6 mutex obtained:               13, thread 6 cpu 1
+            thread 7 mutex obtained:               13, thread 7 cpu 1
+
 .. _helloworld application: https://github.com/Nuclei-Software/nuclei-sdk/tree/master/application/baremetal/helloworld
 .. _cpuinfo application: https://github.com/Nuclei-Software/nuclei-sdk/tree/master/application/baremetal/cpuinfo
 .. _demo_timer application: https://github.com/Nuclei-Software/nuclei-sdk/tree/master/application/baremetal/demo_timer
@@ -3026,6 +3111,7 @@ In Nuclei SDK, we provided code and Makefile for this ``threadx demo`` applicati
 .. _rt-thread demo smode application: https://github.com/Nuclei-Software/nuclei-sdk/tree/master/application/rtthread/demo_smode
 .. _rt-thread msh application: https://github.com/Nuclei-Software/nuclei-sdk/tree/master/application/rtthread/msh
 .. _threadx demo application: https://github.com/Nuclei-Software/nuclei-sdk/tree/master/application/threadx/demo
+.. _threadx smpdemo application: https://github.com/Nuclei-Software/nuclei-sdk/tree/master/application/threadx/smpdemo
 .. _demo_smode_eclic application: https://github.com/Nuclei-Software/nuclei-sdk/tree/master/application/baremetal/demo_smode_eclic
 .. _demo_eclic_umode application: https://github.com/Nuclei-Software/nuclei-sdk/tree/master/application/baremetal/demo_eclic_umode
 .. _demo_smode_plic application: https://github.com/Nuclei-Software/nuclei-sdk/tree/master/application/baremetal/demo_smode_plic

+ 4 - 1
doc/source/design/rtos.rst

@@ -172,6 +172,8 @@ And in your application code, you need to do the following things:
 
 .. note::
 
+    * We also maintained RT-Thread fork repo as described in https://github.com/riscv-mcu/rt-thread/issues/1,
+      which support RV32 and RV64 and also support SMP feature.
     * You can check the ``application\rtthread\`` for rtthread application reference
     * In RT-Thread, the ``main`` function is created as a RT-Thread thread,
       so you don't need to do any OS initialization work, it is done before ``main``
@@ -216,6 +218,7 @@ And in your application code, you need to do the following things:
 .. note::
 
     * ThreadX itself doesn't have a idle task, see https://github.com/eclipse-threadx/threadx/blob/acf2e57606361f3fa95cc5f9bf8c0370f2c4b898/utility/rtos_compatibility_layers/FreeRTOS/readme.md?plain=1#L113-L114
+    * From Nuclei SDK 0.9.0, we bring support for ThreadX SMP support, and also idle task is by default emulated in Nuclei RISC-V portable code now.
     * You can check the ``application\threadx\`` for threadx application reference
     * Currently we only support single core version, the SMP version is not yet supported.
 
@@ -237,4 +240,4 @@ We also support other RTOSes, but not maintained in Nuclei SDK, please see follo
 .. _RT_Thread: https://www.rt-thread.org/
 .. _RT-Thread Nano: https://github.com/RT-Thread/rtthread-nano
 .. _Eclipse ThreadX: https://github.com/eclipse-threadx/threadx
-.. _RT-Thread BSP For Nuclei: https://github.com/RT-Thread/rt-thread/tree/master/bsp/nuclei/
+.. _RT-Thread BSP For Nuclei: https://github.com/riscv-mcu/rt-thread/blob/nuclei/lts-v4.1.x/bsp/nuclei/nuclei_fpga_eval