<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="moz-text-flowed" style="font-family: -moz-fixed;
font-size: 13px;" lang="x-unicode">Been sitting on this patch for
a while now, figured I should finally submit it...<br>
<br>
About a month ago I saw someone saying that they wanted to have
this section of the users guide added in, followed all of the
steps of the userguide up to the point just prior and then wrote
this.
<br>
<br>
One thing to note, the GDB simulation did not work, I couldn't get
it to link up to the SIS simulator (GDB didn't even know what
`target sim` meant). That's why I have written on how to use SIS
directly. No idea where I could track that problem down.
<br>
<br>
---
<br>
user/start/app.rst | 88
+++++++++++++++++++++++++++++++++++++++++++++++++++++-
<br>
1 file changed, 87 insertions(+), 1 deletion(-)
<br>
<br>
diff --git a/user/start/app.rst b/user/start/app.rst
<br>
index fdf6bb7..7e87da8 100644
<br>
--- a/user/start/app.rst
<br>
+++ b/user/start/app.rst
<br>
@@ -8,4 +8,90 @@
<br>
Build Your Application
<br>
======================
<br>
<br>
-TODO
<br>
+An RTEMS application is largely built the same as any other
program using GCC.
<br>
+However, target specific flags will need to be presented to the
compiler in
<br>
+order to build for your specific target. There are also some
differences in
<br>
+symbols needed as part of a standard RTEMS application.
<br>
+
<br>
+At minimum, some features of RTEMS need to be configured.
Configuration of the
<br>
+OS is achieved through a series of ``#define`` macros. The full
list of
<br>
+options is in the RTEMS Classic API Guide - Configuring a System.
<br>
+
<br>
+.. code-block:: c
<br>
+
<br>
+ /* Includes the RTEMS OS Library */
<br>
+ #include <rtems.h>
<br>
+
<br>
+ /* Includes the BSP specific functions */
<br>
+ #include <bsp.h>
<br>
+
<br>
+ #include <stdio.h>
<br>
+
<br>
+ /* Enables the Console Driver for the application */
<br>
+ #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
<br>
+
<br>
+ /* Enables the Clock driver for the application */
<br>
+ #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
<br>
+
<br>
+ /* Initializes RTEMS Task System */
<br>
+ #define CONFIGURE_MAXIMUM_TASKS 1
<br>
+ #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
<br>
+ #define CONFIGURE_INIT
<br>
+
<br>
+ /* Applies the specified configuration */
<br>
+ #include <rtems/confdefs.h>
<br>
+
<br>
+ rtems_task Init(rtems_task_argument args){
<br>
+
<br>
+ printf("Welcome to RTEMS!\n");
<br>
+ fflush(stdout);
<br>
+
<br>
+ rtems_task_delete(RTEMS_SELF);
<br>
+
<br>
+ }
<br>
+
<br>
+In addition, the typical ``main`` symbol is overriden and the
application code
<br>
+entry point is ``Init``, shown with the correct signature above.
From that
<br>
+point the user application would take over control just like any
other
<br>
+C / C++ program.
<br>
+
<br>
+To compile, invoke the installed RTEMS specific GCC with a series
of special
<br>
+flags. Place the above sample file into ``quick-start.c``
<br>
+
<br>
+.. code-block:: none
<br>
+
<br>
+ $HOME/quick-start/rtems/5/bin/sparc-rtems5-gcc
-B$HOME/quick-start/rtems/5/sparc-rtems5/erc32/lib/ -specs
bsp_specs -qrtems -o quick-start.exe quick-start.c
<br>
+
<br>
+Keeping inline with the GCC compilation flag set, any extra or
needed
<br>
+compilation flags can be passed in (e.g. floating point controls,
<br>
+profile, debugging, etc).
<br>
+
<br>
+To test the file, you can use the SPARC Instruction Simulator
(SIS) that is
<br>
+built as part of the SPARC toolchain.
<br>
+
<br>
+.. code-block:: none
<br>
+
<br>
+ $HOME/quick-start/rtems/5/bin/sparc-rtems5-gcc
quick-start.exe
<br>
+
<br>
+In the prompt type ``run`` and the simulator will start and
execute the program
<br>
+
<br>
+.. code-block:: none
<br>
+
<br>
+ $HOME/quick-start/rtems/5/bin/sparc-rtems5-sis -erc32
quick-start.elf
<br>
+
<br>
+ SIS - SPARC/RISCV instruction simulator 2.20, copyright Jiri
Gaisler 2019
<br>
+ Bug-reports to <a class="moz-txt-link-abbreviated" href="mailto:jiri@gaisler.se">jiri@gaisler.se</a>
<br>
+
<br>
+ ERC32 emulation enabled
<br>
+
<br>
+ Loaded quick-start.elf, entry 0x02000000
<br>
+ sis> run
<br>
+ Welcome to RTEMS!
<br>
+
<br>
+Hit CTRL-C to break the simulation
<br>
+
<br>
+.. warning::
<br>
+
<br>
+ Sometimes the SIS simulator may start executing at a very low
rate, in that
<br>
+ case use CTRL-C and then Enter to break the simulation, then
use the 'cont'
<br>
+ command to resume execution at a higher rate
<br>
\ No newline at end of file
<br>
--
<br>
2.11.0
<br>
<br>
</div>
</body>
</html>