@@ -22,7 +22,6 @@ processor configuration options:
2222- Timer interrupt option with at least one interruptible timer for ThreadX.
2323- Interrupt option (implied by the timer interrupt option).
2424- Xtensa Exception Architecture 2 (XEA2) or Exception Architecture 3 (XEA3).
25- Please note that XEA1 is NOT supported.
2625
2726Minimal support for certain evaluation boards is provided via a board
2827independent "XTBSP" API implemented by a board specific library. This
@@ -35,157 +34,75 @@ this board support (a "raw" platform), but you will have to provide the
3534clock frequency and drivers for any on-board devices you want to use.
3635
3736
38- 2. Building the ThreadX run-time Library
37+ 2. Building the ThreadX Library and the Xtensa Example
3938
4039By default, you will build for the Xtensa instruction set simulator. If
4140you have a supported emulation board, you can build to run on that. You
42- can also build to run on a raw Xtensa core with no "board support", a
43- good starting point for supporting your own target platform. Cadence Design Systems
44- recommends doing functional development on the simulator because it
45- is easier to debug with, then move to a board if/when you need to test
46- hardware drivers or real-time performance.
41+ will have to provide the XTBSP functions for any other board you want to
42+ run on. We recommend you start by running on the simulator, then moving
43+ to your hardware target or emulation platform.
4744
48- ThreadX/Xtensa comes with a Makefile as well as DOS .bat file, taking
49- advantage of xt-make, a version of GNU make that comes with Xtensa Tools
50- (you can just as well use generic GNU make if you have it installed).
51- The Makefile works on any host platform and provides for incremental builds.
52- The .bat file works on DOS/Windows only and always cleans before building.
53- The build for each target platform is placed in a sub-directory so several
54- platform builds can coexist even with incremental rebuilds.
45+ ThreadX/Xtensa is built using the ThreadX Cmake infrastructure. See the
46+ standard ThreadX documentation for details of the build process. In the
47+ cmake/ directory there is a file named xtensa.cmake which defines the
48+ Cmake configuration for the Xtensa target. Both Cmake and the Ninja tool
49+ need to be installed to build ThreadX.
5550
56- First, make sure you have installed Xtensa Tools and your processor
57- configuration, and be sure that Xtensa Tools are in your search path.
51+ You will also need to ensure that the Xtensa SDK tools have been installed
52+ and are on the path, and XTENSA_SYSTEM and XTENSA_CORE are set appropriately
53+ in the environment. Refer to the SDK documentation for details.
5854
59- If you wish to build for an evaluation board that is supported by an
60- external package, be sure the appropriate package is installed. See the
61- introduction (section 0) to determine if you need an external package.
62- If you are using an external board package, set the environment variable
63- XTENSA_BOARDS to the absolute path of the root of the installed support
64- package (or you can pass this to xt-make commands on the command line).
65- eg. XTENSA_BOARDS = C:\usr\xtensa\RB-2007.1-xtav60 for Avnet LX60 board.
66- You do not need to set XTENSA_BOARDS if using a Cadence Design Systems supported
67- board with Xtensa Tools RB-2007.2 and up (support is bundled with the tools).
55+ The following commands will build the ThreadX library (some changes may be
56+ required based on your setup) -
6857
69- Next, change directories to the ThreadX installation directory, as follows:
58+ cmake -S $(TX_SRCDIR) -B $(TX_BLDDIR) -DCMAKE_TOOLCHAIN_FILE=$(TX_SRCDIR)/cmake/xtensa.cmake -GNinja $(TX_SRCDIR)
59+ cmake --build $(TX_BLDDIR)
7060
71- > cd c:\threadx\xtensa\gnu
61+ where TX_SRCDIR is the root of the ThreadX source tree, and TX_BLDDIR is
62+ the location where you want the build output to go.
7263
73- Now build the ThreadX library (tx.a) by executing the build_threadx.bat
74- batch file (or using the Makefile directly) while inside the threadx
75- directory, as follows:
64+ Once the library is built, the Xtensa example can be built by going into
65+ the directory ports/xtensa/xcc/example_build and running this command -
7666
77- > build_threadx.bat
67+ xt-clang -mlongcalls -Os -g -I../../../../common/inc -I../../../../common_smp/inc
68+ -I../../../../ports/xtensa/xcc/inc -o demo_threadx.exe demo_threadx.c
69+ ../../../../build/libthreadx.a -lxtutil
7870
79- which always builds for the simulator (but you can edit it), or
80-
81- > xt-make
82-
83- which by default builds for the simulator (PLATFORM=sim), or either of
84-
85- > xt-make PLATFORM=board BOARD=<board>
86- or
87- > xt-make BOARD=<board>
88-
89- which builds for a specified supported board (note PLATFORM=board is
90- default when BOARD is defined). eg. BOARD=xtav60 for the Avnet LX60
91- (XT-AV60) board.
92-
93- > xt-make PLATFORM=raw
94-
95- which builds for a raw Xtensa core with no "board support".
96-
97- > xt-make PLATFORM=gdbio
98-
99- Provides some very slow I/O support through the xt-gdb debugger.
100- For GDBIO to work, xt-gdb must remain connected to the target.
101-
102- If you are building for an Xtensa processor configuration that is not the
103- default you selected when you installed Xtensa Tools, you need to define the
104- environment variable XTENSA_CORE. If your configuration is not in the
105- default registry you selected when you installed Xtensa Tools, you also
106- need to define the environment variable XTENSA_SYSTEM. See tools manuals.
107- You can avoid defining these in your environment if you pass the variables
108- you need to redefine into xt-make as follows:
109-
110- > xt-make XTENSA_CORE=<your_config_name> XTENSA_SYSTEM=<your_registry> ...
111-
112- There are more details about build options in the comment in the Makefile.
113-
114- At this point, all the ThreadX objects are located in a library file: tx.a .
115- This file must be linked with your application in order to use ThreadX.
116- This library and all the intermediate object files are placed in a platform
117- specific sub-directory named the same as BOARD or PLATFORM (if BOARD is not
118- defined), for example "sim", "xtkc705".
11971
12072To build ThreadX with thread-safe C library support, define TX_THREAD_SAFE_CLIB
121- in your build, as described in section 5 and in the Makefile. Please note
122- that the C library is only safe for use in threads, not in interrupt handlers.
123- It may also safely be used in tx_application_define (after tx_kernel_enter,
124- before threads are running).
125-
73+ to 1 (this is set by default in tx_port.h). Note that the C library is only
74+ safe for use in threads, not in interrupt handlers. It may also safely be used
75+ in tx_application_define (after tx_kernel_enter, before threads are running).
12676
127- 3. Demonstration System
12877
129- The ThreadX demonstration is designed to execute under Xtensa instruction set
130- simulator (ISS) or on a supported evaluation board programmed with your Xtensa
131- processor configuration.
78+ 3. Running the Example
13279
133- Building the demonstration is easy, simply execute the build_threadx_demo.bat
134- batch file while inside threadx directory, as follows:
80+ The ThreadX Xtensa example is designed to be run on the Xtensa simulator (ISS)
81+ or a hardware target. By default the example is built for the simulator target.
82+ To run it,
13583
136- > build_threadx_demo.bat
84+ xt-run demo_threadx.exe
13785
13886or
13987
140- > xt-make demo
88+ xt-gdb demo_threadx.exe (if you want to run it under the debugger)
14189
142- Be sure to set or pass into xt-make the variables described in section 2 above
143- for building the ThreadX library, including the PLATFORM or BOARD you want to
144- run on.
145-
146- This compiles demo_threadx.c (which is the demonstration application) and links
147- it with the ThreadX objects in tx.a. The resulting file demo_threadx.out is a
148- ELF binary file that can be downloaded and executed on the target.
149-
150- The demo binary appears in the platform specific sub-directory described earlier.
151- For the following commands, change to that directory or prepend it as the path
152- of demo_threadx.out.
153-
154-
155- To execute on the simulator:
156-
157- > xt-run [--turbo] demo_threadx.out
158-
159- The option --turbo provides much faster, but non-cycle-accurate simulation.
160- Refer to the Xtensa simulator user manual for further simulator options.
161-
162-
163- To execute on the simulator using the Xplorer GUI based debugger:
164-
165- > xplorer --debug demo_threadx.out
166-
167-
168- To execute on a supported evaluation board, download demo_threadx.out per
169- instructions in the tools manuals. Be sure the board has been programmed
170- with the correct configuration and is set up to boot from RAM and debug
171- a downloaded program! Optionally you may connect a terminal or terminal
172- emulator to the serial port on the board with settings as described in
173- the board user manual, and see the output of printf on the terminal (if
174- the demo was compiled with DEMO_USE_PRINTF or DEMO_USE_XTUTIL).
90+ To execute on a supported hardware target, download the example to the board
91+ following instructions in the SDK manuals. Make sure the board has been set
92+ up with the correct configuration (if emulation board) and is set up to boot
93+ from RAM and debug a downloaded program. Optionally you may connect a terminal
94+ or terminal emulator to the serial port on the board with settings as described
95+ in the board user manual, and see the output of printf on the terminal (if
96+ the board support package supports directing standard output to the port).
17597
17698To obtain I/O on a "raw" platform such as an unsupported board, you need
17799to provide low level I/O drivers (eg. inbyte() and outbyte() for character
178100I/O if you want to use printf etc.). You can run "raw" executables on
179101any Xtensa platform, including simulator and any board, but you will not
180102see any behavior specific to the platform (eg. display, printed output,
181103stopping simulation at end of program). You can, while debugging, use a
182- debugger mechanism called GDBIO to obtain basic I/O. Use PLATFORM=GDBIO
183- on your xt-make command line - this is the same as "raw" except it links
184- some stubs that communicate through the debugger. It is very slow!
185-
186- WARNING: It is tempting to add printf calls to other threads in the demo.
187- If you modify the code in any way, you may need adjust affected threads'
188- stack sizes. This is especially true if you add a printf call. See 4.5.
104+ debugger mechanism called GDBIO to obtain basic I/O. This requires linking
105+ with the gdbio support library. See the SDK documentation for details.
189106
190107
1911084. System Initialization
@@ -272,16 +189,14 @@ are provided in tx_port.h assuming no optimization (default, -O0).
272189Threads that call C library functions may need larger stacks than those
273190that don't. In particular, use of printf requires a very large stack and
274191will usually cause a stack overflow if inserted in a thread without
275- enlarging its stack size. See DEMO_STACK_SIZE_PRINTF in demo_threadx.c
276- for a guideline. Use printf with care!
192+ enlarging its stack size.
277193
278194
2791955. Assembler / Compiler Switches
280196
281197The following are compiler switches used in building the ThreadX library
282- and demonstration system. These can be supplied by editing the Makefile
283- or by overriding the COPT or CFLAGS variables in the make command line
284- (eg. make COPT="-O2 -DTX_THREAD_SAFE_CLIB"). More details in Makefile.
198+ and demonstration system. These can be supplied by editing the xtensa.cmake
199+ file or by overriding from the environment or command line.
285200
286201Compiler Switch Meaning
287202
@@ -291,7 +206,6 @@ Compiler Switch Meaning
291206 -mlongcalls Allows assembler and linker to convert call
292207 instructions to longer indirect call sequences
293208 when target is out of range.
294- -x assembler-with-cpp Passes .s and .S files through C preprocessor.
295209 -Dmacro Define a preprocessor macro with no value.
296210 -Dmacro=value Define a preprocessor macro with a value.
297211
@@ -306,9 +220,6 @@ Application Defines (preprocessor macros definable with the -D option):
306220 can be customized in tx_application_define.
307221 Default off.
308222
309- NOTE: Thread safe support for Xtensa C library requires Xtensa Tools
310- version RF-2015.2 or later.
311-
312223 TX_ENABLE_STACK_CHECKING Enable generic ThreadX support for stack
313224 overflow checking. This can help avoid long
314225 debugging sessions or customer support calls
@@ -382,7 +293,7 @@ Application Defines (preprocessor macros definable with the -D option):
382293 higher bit numbers over those with lower bit
383294 numbers at the same level. This works only for
384295 low and medium priority interrupts that can be
385- dispatched to C handlers on either NX cores or
296+ dispatched to C handlers on either NX cores or
386297 on LX cores with 32 or fewer interrupts.
387298
388299 TX_SYSTEM_STACK_SIZE=n Specify the size of the interrupt stack, which
@@ -456,7 +367,7 @@ If multiple threads use a register, the caller must save and restore it.
456367
457368The saved context stack frames for context switches that occur as a result
458369of interrupt handling (interrupt frame) or from thread-level API calls
459- (solicited frame) are described in human readable form in xtensa_context.h .
370+ (solicited frame) are described in human readable form in xtensa_context.h.
460371All suspended threads have one of these two types of stack frames. The top
461372of the suspended thread's stack is pointed to by tx_thread_stack_ptr in the
462373associated thread control block TX_THREAD. An Xtensa architecture port-specific
0 commit comments