AAC Microtec Sirius User manual

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 1of 106
Sirius Breadboard User Manual
Rev. K
© ÅAC Microtec 2016
ÅAC Microtec AB owns the copyright of this document which is supplied in confidence and which shall
not be used for any purpose other than for which it is supplied and shall not in whole or in part be
reproduced, copied, or communicated to any person without written permission from the owner.

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 2of 106
REVISION LOG
Rev
Date
Change description
A
2015-11-10
First Release
B
2016-03-07
Updates for new release with lots of minor corrections and
clarifications.
C
2016-03-18
Version C released with the following updates:
TCM-S chapter 6 updated
UART chapter update
Spacewire router chapter 6 added.
Added GPIO chapter
Updated SCET ioctl
Corrected BSP section to be board-agnostic
D
2016-03-23
Added driver API for CCSDS
E
2016-05-01
Version E released with the following updates:
GPIO chapter updated
UART32 chapter added
TCM-S chapter updated
Lots of minor corrections and fixes.
F
2016-05-03
Added missing section on TCM-S.
G
2016-06-10
Added NVRAM and PUS 1 commands.
Editorial changes.
H
2016-06-30
Version H released with the following updates:
PUS 2 commands CDPU
SoC specs
TCM-S core app updates
SPW byte alignment
I
2016-09-05
Version I released with the following updates:
GPIO example
HK equations
ADC section
nandflash program bad blocks handling
Boot image information and boot order
Added section on pulse command inputs
Adjusted TCM-S section and synched with TCM-S DDD
Removed TCM-S download command as this isn’t supported
in this release.
J
2016-09-07
Corrected TCM-S RMAP address and command errors that snuck into
release version I.
K
2016-10-11
Version K released with the following updates:
TCM-S RMAP updates
- grouped MMData with the rest of the MM commands
- renamed TMBRControl to TMBRSet
- corrected and clarified TCStatus
- changed order in TMConfig to match implementation
- re-added download information
- trimmed section to match new requirements
SBAND/XBAND pin updates
Added information on reset button to section 9.1
Updated UART section to match UART DDD rev B

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 3of 106
TABLE OF CONTENT
1. INTRODUCTION............................................................................................................... 7
1.1. Applicable releases........................................................................................................................................ 7
1.2. Intended users................................................................................................................................................ 7
1.3. Getting support............................................................................................................................................... 7
1.4. Reference documents .................................................................................................................................... 7
2. EQUIPMENT INFORMATION........................................................................................... 8
2.1. System Overview with peripherals ............................................................................................................... 9
3. SETUP AND OPERATION...............................................................................................10
3.1. User prerequisites........................................................................................................................................ 10
3.2. Connecting cables to the Sirius Breadboard............................................................................................. 11
3.3. Installation of toolchain ............................................................................................................................... 12
3.3.1. Supported Operating Systems................................................................................................................. 12
3.3.2. Installation Steps...................................................................................................................................... 12
3.4. Installing the Board Support Package (BSP) ............................................................................................. 13
3.5. Deploying a Sirius application .................................................................................................................... 13
3.5.1. Establish a debugger connection to the Breadboard................................................................................ 13
3.5.2. Setup a serial terminal to the device debug UART................................................................................... 14
3.5.3. Loading the application............................................................................................................................ 14
3.6. Programming an application (boot image) to system flash...................................................................... 15
4. SOFTWARE DEVELOPMENT.........................................................................................16
4.1. RTEMS step-by-step compilation................................................................................................................ 16
4.2. Software disclaimer of warranty ................................................................................................................. 16
5. RTEMS.............................................................................................................................17
5.1. Introduction................................................................................................................................................... 17
5.2. Watchdog...................................................................................................................................................... 18
5.2.1. Description............................................................................................................................................... 18
5.2.2. RTEMS API.............................................................................................................................................. 18
5.2.3. Usage....................................................................................................................................................... 19
5.3. Error Manager............................................................................................................................................... 21
5.3.1. Description............................................................................................................................................... 21
5.3.2. RTEMS API.............................................................................................................................................. 21
5.3.3. Usage....................................................................................................................................................... 24
5.3.4. Limitations................................................................................................................................................ 26
5.4. SCET.............................................................................................................................................................. 27
5.4.1. Description............................................................................................................................................... 27
5.4.2. RTEMS API.............................................................................................................................................. 27
5.4.3. Usage....................................................................................................................................................... 29
5.5. UART.............................................................................................................................................................. 33
5.5.1. Description............................................................................................................................................... 33
5.5.2. RTEMS API.............................................................................................................................................. 33
5.5.3. Usage description .................................................................................................................................... 36
5.5.4. Limitations................................................................................................................................................ 37
5.6. UART32.......................................................................................................................................................... 37
5.6.1. Description............................................................................................................................................... 37
5.6.2. RTEMS API.............................................................................................................................................. 37

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 4of 106
5.6.3. Usage description .................................................................................................................................... 41
5.6.4. Limitations................................................................................................................................................ 41
5.7. Mass memory................................................................................................................................................ 42
5.7.1. Description............................................................................................................................................... 42
5.7.2. RTEMS API.............................................................................................................................................. 42
5.7.3. Usage....................................................................................................................................................... 47
5.7.4. Limitations................................................................................................................................................ 48
5.8. Spacewire...................................................................................................................................................... 49
5.8.1. Description............................................................................................................................................... 49
5.8.2. RTEMS API.............................................................................................................................................. 49
5.8.3. Usage....................................................................................................................................................... 51
5.8.4. Limitations................................................................................................................................................ 54
5.9. GPIO............................................................................................................................................................... 54
5.9.1. Description............................................................................................................................................... 54
5.9.2. RTEMS API.............................................................................................................................................. 55
5.9.3. Usage description .................................................................................................................................... 57
5.9.4. Limitations................................................................................................................................................ 58
5.10. CCSDS......................................................................................................................................................... 59
5.10.1. Description............................................................................................................................................. 59
5.10.2. RTEMS API............................................................................................................................................ 59
5.10.3. Usage description .................................................................................................................................. 66
5.11. ADC.............................................................................................................................................................. 67
5.11.1. Description............................................................................................................................................. 67
5.11.2. RTEMS API............................................................................................................................................ 67
5.11.3. Usage..................................................................................................................................................... 70
5.11.4. Limitations.............................................................................................................................................. 71
5.12. NVRAM ........................................................................................................................................................ 71
5.12.1. Description............................................................................................................................................. 72
5.12.2. RTEMS API............................................................................................................................................ 72
5.12.3. Usage description .................................................................................................................................. 75
6. SPACEWIRE ROUTER....................................................................................................76
7. TCM-STM...........................................................................................................................77
7.1. Description.................................................................................................................................................... 77
7.2. Block diagram............................................................................................................................................... 77
7.3. Spacewire RMAP .......................................................................................................................................... 78
7.3.1. Input......................................................................................................................................................... 78
7.3.2. Output...................................................................................................................................................... 79
7.4. RMAP address details.................................................................................................................................. 79
7.4.1. TMStatus.................................................................................................................................................. 79
7.4.2. TMConfig ................................................................................................................................................. 80
7.4.3. TMControl................................................................................................................................................ 80
7.4.4. TMFEControl............................................................................................................................................ 80
7.4.5. TMMCFCControl...................................................................................................................................... 81
7.4.6. TMIFControl............................................................................................................................................. 81
7.4.7. TMPRControl ........................................................................................................................................... 81
7.4.8. TMOCFControl......................................................................................................................................... 81
7.4.9. TMCEControl ........................................................................................................................................... 81
7.4.10. TMBRSet ............................................................................................................................................... 82
7.4.11. TMTSControl.......................................................................................................................................... 82
7.4.12. TMSend ................................................................................................................................................. 82

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 5of 106
7.4.13. TCStatus................................................................................................................................................ 82
7.4.14. TCDRControl.......................................................................................................................................... 83
7.4.15. HKData .................................................................................................................................................. 83
7.4.16. SCETTime ............................................................................................................................................. 83
7.4.17. SCETConfig........................................................................................................................................... 84
7.4.18. ErrorStatus............................................................................................................................................. 84
7.4.19. UARTCommand..................................................................................................................................... 84
7.4.20. MMData ................................................................................................................................................. 84
7.4.21. MMStatus............................................................................................................................................... 85
7.4.22. MMWritePointer ..................................................................................................................................... 85
7.4.23. MMReadPointer..................................................................................................................................... 85
7.4.24. MMPartitionConfig.................................................................................................................................. 86
7.4.25. MMPartitionSpace.................................................................................................................................. 86
7.4.26. MMDownloadPartitionData .................................................................................................................... 86
7.4.27. TCCommand.......................................................................................................................................... 86
7.4.28. TMError.................................................................................................................................................. 86
7.4.29. TCError.................................................................................................................................................. 87
7.4.30. UARTData.............................................................................................................................................. 87
7.5. Telemetry....................................................................................................................................................... 87
7.6. Telecommands ............................................................................................................................................. 87
7.7. ECSS standard service ................................................................................................................................ 87
7.7.1. PUS-1 Telecommand verification service ................................................................................................ 87
7.7.2. PUS-2 Device Command Distribution Service......................................................................................... 88
7.8. Limitations .................................................................................................................................................... 88
8. SYSTEM-ON-CHIP DEFINITIONS...................................................................................89
8.1. Memory mapping.......................................................................................................................................... 89
8.2. Interrupt sources.......................................................................................................................................... 90
8.3. SCET timestamp trigger sources................................................................................................................ 90
8.4. Boot images and boot procedure................................................................................................................ 91
8.4.1. Description............................................................................................................................................... 91
8.4.2. Block diagram .......................................................................................................................................... 91
8.4.3. Usage description .................................................................................................................................... 91
8.4.4. Limitations................................................................................................................................................ 92
8.5. Reset behaviour............................................................................................................................................ 92
8.6. Pulse command inputs ................................................................................................................................ 92
8.7. SoC information map ................................................................................................................................... 92
9. CONNECTOR INTERFACES...........................................................................................94
9.1. RESET, Reset pushbutton........................................................................................................................... 94
9.2. JTAG-RTL, FPGA-JTAG connector............................................................................................................. 94
9.3. DEBUG-SW.................................................................................................................................................... 95
9.4. SPW1 - Spacewire......................................................................................................................................... 95
9.5. SPW2 - Spacewire......................................................................................................................................... 96
9.6. ANALOGS, Analog input and 4xGPIO (OBC-S).......................................................................................... 96
9.7. DIGITALS, 3x I2C, PPS and 12xGPIO.......................................................................................................... 97
9.8. COM02_RS4XX, 3xRS422/485...................................................................................................................... 98
9.9. COM35_RS4XX, RS422/485 (OBC-S)........................................................................................................... 98
9.10. CCSDS RS422, S-BAND TRX (TCM-S) ...................................................................................................... 99
9.11. CCSDS LVDS, RS422, X-BAND TRX (TCM-S)......................................................................................... 100
9.13. UMBI –Baseband Umbilical (TCM-S)...................................................................................................... 101
9.14. Pulse Command Outputs......................................................................................................................... 102

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 6of 106
10. UPDATING THE SIRIUS FPGA...................................................................................103
10.1. Prerequisite hardware.............................................................................................................................. 103
10.2. Prerequisite software............................................................................................................................... 103
10.3. Step by step guide.................................................................................................................................... 103
11. MECHANICAL DATA ..................................................................................................104
12. ENVIRONMENTAL INFORMATION ............................................................................104
13. GLOSSARY.................................................................................................................105

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 7of 106
1. Introduction
This manual describes the functionality and usage of the ÅAC Sirius Breadboard. The
Breadboard is a prototype board for products under development, which means that not all
functions are implemented yet. The OBC-STM and TCM-STM functionality is described and
can both run on the breadboard. The breadboard has fitted or non-fitted components and
unique SoCs that give the desired functionality to match either the OBC-STM or TCM-STM.
1.1. Applicable releases
This version of the manual is applicable to the following releases:
OBC-S 0.6.2
TCM-S 0.6.2
1.2. Intended users
This manual is written for the software engineers using the ÅAC Sirius product suite.
1.3. Getting support
If you encounter any problem using the breadboard or another ÅAC product please use the
following address to get help:
Email: [email protected]
1.4. Reference documents
RD#
Document ref
Document name
RD1
http://opencores.org/openrisc,architecture
OpenRISC 1000 Architecture
Manual
RD2
ECSS-E-ST-50-12C
SpaceWire –Links, nodes,
routers and networks
RD3
ECSS-E-ST-50-52C
SpaceWire –Remote memory
access protocol
RD4
ECSS-E-70-41A
Ground systems and
operations –Telemetry and
telecommand packet utilization
RD5
SNLS378B
PC16550D Universal
Asynchronous
Receiver/Transmitter with
FIFOs
RD6
AD7173-8, Rev. A
Low Power, 8-/16-Channel,
31.25 kSPS, 24-Bit, Highly
Integrated Sigma-Delta ADC
RD7
Edition 4.10.99.0
RTEMS BSP and Device
Driver Development Guide
RD8
CCSDS 132.0-B-2
TM Space Data Link Protocol
RD9
CCSDS 232.0-B-2
TC Space Data Link Prototcol

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 8of 106
2. Equipment information
The Sirius Breadboard is a prototyping platform designed to support the TCM-STM, and the
OBC-STM products. The Breadboard layout is depicted in Figure 3-1.
The development board supports both a debugger interface for developing software
applications and a JTAG interface for upgrading the FPGA firmware.
The FPGA firmware implements SoC based on a 32 bit OpenRISC Fault Tolerant processor
[RD1] running at a system frequency of 50 MHz and with the following set of peripherals:
Error manager, error handling, tracking and log of e.g. power loss and/or memory
error detection.
SDRAM 64 MB data + 64 MB EDAC running @100MHz
Spacecraft Elapsed Timer (SCET), for accurate time measurement with a
resolution of 15 µs
SpaceWire, including a three-port SpaceWire router, for communication with
external peripheral units
UARTs (Number of interfaces differ between the products) uses the RS422 and
RS485 line drivers on the board with line driver mode set by software.
GPIOs
Watchdog, fail-safe mechanism to prevent a system lockup
System flash of 2 GB with EDAC-protection for storing boot images in multiple
copies
For the TCM-STM the following additional peripherals are included in the SoC:
CCSDS, communications IP.
Mass memory of 16GB with EDAC-protection, NAND flash based, for storage of
mission critical data.
The input power supply provided to the breadboard shall use a range of +4.5V to absolute
max. of +16V. Nominal voltage supply level shall be set to +5V. The power consumption is
highly dependent on peripheral loads and it ranges from 0.8 W to 2 W.

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 9of 106
2.1. System Overview with peripherals
Figure 2-1 depicts a System-on-Chip (SoC) overview including the related peripherals of the
OBC-STM and TCM-STM products. The figure shows what parts are for which products and
what parts are not yet implemented since the products are still under development.
FPGA
FPU
OpenRISC
1200FT
I/D Cache
I2C
UART
GPIO
CCSDS
Memory
controller
System
flash
controller
Flash
controller
SpaceWire
DMA
Control
Watchdog
Debug
Unit
SCET
Error
manager
2x 64MB
SDRAM
2 GB System
Flash
Radio Interfaces
RS422/LVDS RS422/RS485 JTAG/DEBUG
Pulse CMDUMBI/EGSEETHERNET GPIO
ADC
(Housekeeping)
Ethernet
10/100
ADC
controller
OBC-S/TCM-S
NVRAM
Analog inputs
NVRAM
TCM-S TCM-S/OBC-S Not implemented
Figure 2-1 - The OBC-STM / TCM-STM SoC Overview

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 10 of 106
3. Setup and operation
3.1. User prerequisites
The following hardware and software is needed for the setup and operation of the
Breadboard.
PC computer
1 Gb free space for installation (minimum)
Debian 7 or 8 64-bit with super user rights
USB 2.0
Recommended applications and software
Installed terminal e.g. gtkterm or minicom
Driver for USB/COM port converter, FTDI, www.ftdichip.com
Host build system, e.g. debian package build-essential
The following software is installed by the ÅAC toolchain package
oGCC, C compiler for OpenRISC
oGCC, C++ compiler for OpenRISC
oGNU binutils and linker for OpenRISC
For FPGA update capabilities
Microsemi FlashPro Express v11.7, http://www.microsemi.com/products/fpga-
soc/design-resources/programming/flashpro#software

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 11 of 106
3.2. Connecting cables to the Sirius Breadboard
Figure 3-1 –ÅAC Sirius Breadboard with connector numbering
The Sirius Breadboard runs on a range of 4.5 to 16V DC. The instructions below refer to the
connector numbering in Figure 3-1.
Connect Ground to the black connector 1
Connect 4.5 - 16 V DC to the yellow connector 2. The unit will nominally draw
about 260-300 mA @5V DC.
Connect the 104451 ÅAC Debugger and Ethernet adapter with the 104471
Ethernet debug unit cable to connector 3. Connect the adapter USB-connector to
the host PC. The ÅAC debugger is mainly used for development of custom
software for the OBC-S with monitoring/debug capabilities, but is also used for
programming an image to the system flash memory. For further information refer to
chapter 3.6.
For FPGA updating only: Connect a FlashPro programmer to connector 4 using the
104470 FPGA programming cable assembly. For further information how to update
the SoC refer to Chapter 9.10.
For connecting the SpaceWire:
oOption 1: Connect the nano-D connector to connector 5 or 6. Be careful
when plugging and unplugging this connector.

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 12 of 106
oOption 2: Connect the Display port cable to connector 7 or 8 and to the
104510 Converter board. Connect your SpaceWire system to the
converter board with the SpaceWire cable.
Connecting UARTs:
oOption 1: Connect to the nano-D number 12 (UART0-2) or 13 (UART3-5).
Be careful when plugging and unplugging this connector.
oOption 2: Connect to the debug connector 10 using a flat cable to DSUB
connector harness. This can then be connected to a PC using something
similar to the FTDI USB-COM485/COM422-PLUS4.
For more detailed information about the connectors, see section 8.4.
3.3. Installation of toolchain
This chapter describes instructions for installing the aac-or1k-toolchain.
3.3.1. Supported Operating Systems
Debian 7 64-bit
Debian 8 64-bit
3.3.2. Installation Steps
1. Add the ÅAC Package Archive Server
Open a terminal and execute the following command:
sudo gedit /etc/apt/sources.list.d/aac-repo.list
This will open a graphical editor; add the following lines to the file and then save and
close it:
deb http://repo.aacmicrotec.com/archive/ aac/
deb-src http://repo.aacmicrotec.com/archive/ aac/
Add the key for the package archive as trusted by issuing the following command:
wget -O - http://repo.aacmicrotec.com/archive/key.asc | sudo
apt-key add -
Terminal will echo "OK" on success.
2. Install the Toolchain Package
Update the package cache and install the toolchain by issuing the following commands:
sudo apt-get update
sudo apt-get install aac-or1k-toolchain
Note: The toolchain package is roughly 1GB uncompressed, downloading/installing it
will take some time.

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 13 of 106
3. Setup
In order to use the toolchain commands, the shell PATH variable needs to be set to
include them, this can be done either temporarily for the current shell via
source /opt/aac/aac-path.sh
or permanently by editing the ~/.profile file
gedit ~/.profile
and adding the following snippet at the end of the file, and then save and close it:
# AAC OR1k toolchain PATH setup
if [ -f /opt/aac/aac-path.sh ]; then
. /opt/aac/aac-path.sh >/dev/null
fi
3.4. Installing the Board Support Package (BSP)
The BSP can either be downloaded from http://repo.aacmicrotec.com/bsp or copied from the
accompanying DVD. Simply extract the tarball aac-or1k-xxx-x-bsp-y.tar.bz2 to a directory of
your choice (xxx-x depends on your intended hardware target - OBC-S or TCM-s and y
matches the current version number of that BSP).
The newly created directory aac-or1k-xxx-x-bsp now contains the drivers for both bare-metal
applications and RTEMS. See the included README and chapter 4.1 for build instructions.
3.5. Deploying a Sirius application
3.5.1. Establish a debugger connection to the Breadboard
The Sirius Breadboard is shipped with a debugger which connects to the PC via USB. To
interface the Breadboard, the Open On-Chip Debugger (OpenOCD) software is used. A
script called run_aac_debugger.sh is shipped with the toolchain package which starts an
OpenOCD server for gdb to connect to.
1. Connect the Breadboard according to section 3.
2. Start the run_aac_debugger.sh script from a terminal.
3. If the printed message is according to Figure 3-2, the connection is working.

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 14 of 106
Figure 3-2 - Successful OpenOCD connection to the Breadboard
3.5.2. Setup a serial terminal to the device debug UART
The device debug UART may be used as a debug interface for printf output etc.
A terminal emulator such as minicom or gtkterm is necessary to communicate with the
Breadboard, using these settings:
Baud rate: 115200
Data bits: 8
Stop bits: 1
Parity: None
Hardware flow control: Off
On a clean system with no other USB-to-serial devices connected, the serial port will appear
as /dev/ttyUSB1. However, the numbering may change when other USB devices are
connected and you have to make sure you're using the correct device number to
communicate to the board's debug UART.
3.5.3. Loading the application
Application loading during the development stages (before programming to flash) are done
using gdb.
1.a) Start gdb with the following command from a shell for a bare-metal environment
or1k-aac-elf-gdb
or
1.b) Start gdb with the following command from a shell for an RTEMS environment
or1k-aac-rtems4.11-gdb

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 15 of 106
2. When gdb has opened successfully, connect to the hardware through the
OpenOCD server using the gdb command
target remote localhost:50001
3. To start an executable program in hardware, first specify it's name using the gdb
command file. Make sure the application is in ELF format.
file path/to/binary_to_execute
4. Now it needs to be uploaded onto the target RAM
load
5. In the gdb prompt, type cto start to run the application
3.6. Programming an application (boot image) to system flash
This chapter describes how to program the NAND flash memory with a selected boot image.
To achieve this, the boot image binary is bundled together with the NAND flash
programming application during the latter's compilation and then uploaded to target just as
an ordinary application is started through gdb. The maximum allowed size for the boot
image for this release is 16 Mbyte. The nandflash_program application can be found in the
BSP, see also instructions below.
The below instructions assume that the toolchain is in the PATH, see section 3.3 for how to
accomplish this.
1. Compile the boot image binary according to the rules for that program.
2. Then make sure that this is in a binary-only format and not ELF. This can otherwise
be accomplished with the help of the gcc tools included in the toolchain. Note that
Xis to be replaced according to what your application has been compiled against.
Either elf for a bare-metal application or rtems4.11 for the RTEMS variant.
or1k-aac-X-objcopy -O binary boot_image.elf boot_image.bin
3. See chapter 3.4 for installing the BSP and enter
cd path/to/bsp/aac-or1k-xxx-x-bsp/src/nandflash_program/src
4. Now, compile the nandflash-program application, bundling it together with the boot image
binary.
make nandflash-program.elf PROGRAMMINGFILE=/path/to/boot_image.bin
5. Load the nandflash-program.elf onto the target RAM with the help of gdb and
execute it. Follow the instructions on screen and when it's ready, reboot the board
by resetting or power cycling.

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 16 of 106
4. Software development
Applications to be deployed on the Sirius Breadboard can either use a bare-metal approach
or use the RTEMS OS. This corresponds to the two toolchain prefixes available: or1k-aac-
elf-* or or1k-aac-rtems4.11-*
Drivers for both are available in the BSP, see chapter 3.4 and the BSP README for more
information.
4.1. RTEMS step-by-step compilation
The BSP is supplied with an application example of how to write an application for RTEMS
and engage all the available drivers.
Please note that the toolchain described in chapter 3.3 needs to have been installed and the
BSP unpacked as described in chapter 3.4.
The following instructions detail how to build the RTEMS environment and a test application
1. Enter the BSP src directory:
cd path/to/bsp/aac-or1k-xxx-x-bsp/src/
2. Type make to build the RTEMS target
make
3. Once the build is complete, the build target directory is librtems
4. Set the RTEMS_MAKEFILE_PATH environment variable to point to the librtems
directory
export RTEMS_MAKEFILE_PATH=path/to/librtems/or1k-aac-
rtems4.11/or1k-aac
5. Enter the example directory and build the test application by issuing
cd example
make
Load the resulting application using the debugger according to the instructions in chapter
3.5.
4.2. Software disclaimer of warranty
This source code is provided "as is" and without warranties as to performance or
merchantability. The author and/or distributors of this source code may have made
statements about this source code. Any such statements do not constitute warranties and
shall not be relied on by the user in deciding whether to use this source code.
This source code is provided without any express or implied warranties whatsoever.
Because of the diversity of conditions and hardware under which this source code may be
used, no warranty of fitness for a particular purpose is offered. The user is advised to
test the source code thoroughly before relying on it. The user must assume the entire risk of
using the source code.

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 17 of 106
5. RTEMS
5.1. Introduction
This section presents the RTEMS drivers. The Block diagram representing driver
functionality access via the RTEMS API is shown in Figure 5-1.
Figure 5-1 - Functionality access via RTEMS API

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 18 of 106
5.2. Watchdog
5.2.1. Description
This section describes the driver as one utility for accessing the watchdog device.
5.2.2. RTEMS API
This API represents the driver interface from a user application’s perspective for the RTEMS
driver.
The driver functionality is accessed through RTEMS POSIX API for ease of use. In case of
failure on a function call, the errno value is set for determining the cause.
5.2.2.1. int open(…)
Opens access to the device, it can only be opened once at a time.
Argument name
Type
Direction
Description
filename
char *
in
The absolute path to the file that is to be
opened. Watchdog device is defined as
RTEMS_WATCHDOG_DEVICE_NAME
(/dev/watchdog)
oflags
int
in
A bitwise”or” separated list of values that
determine the method in which the file is to be
opened (whether it should be read only,
read/write).
Return value
Description
> 0
A file descriptor for the device on
success
- 1
see errno values
errno values
EALREADY
Device already opened.
5.2.2.2. int close(…)
Closes access to the device.
Argument name
Type
Direction
Description
fd
int
in
File descriptor received at open
Return value
Description
0
Device closed successfully
-1
see errno values
errno values
EPERM
Device is not open.

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 19 of 106
5.2.2.3. size_t write(…)
Any data is accepted as a watchdog kick.
Argument name
Type
Direction
Description
fd
Int
in
File descriptor received at open
buf
void *
in
Character buffer to read data from
nbytes
size_t
in
Number of bytes to write
Return value
Description
*
nNumber of bytes that were
written.
- 1
see errno values
errno values
EPERM
Device was not opened
EBUSY
Device is busy
5.2.2.4. int ioctl(…)
Ioctl allows for disabling/enabling of the watchdog and setting of the timeout.
Argument name
Type
Direction
Description
fd
int
in
File descriptor received at open
cmd
int
in
Command to send
val
int
in
Data to write
Command table
Val interpretation
WATCHDOG_ENABLE_IOCTL
1 = Enables the watchdog
0 = Disables the watchdog
WATCHDOG_SET_TIMEOUT_IOCTL
0 –255 = Number of seconds until the watchdog barks
Return value
Description
0
Command executed successfully
-1
see errno values
errno values
EINVAL
Invalid data sent
RTEMS_NOT_DEFINED
Invalid I/O command
5.2.3. Usage
To enable the watchdog use the wdt_enable() function.
To disable the watchdog use the wdt_disable() function.
The watchdog must be kicked using wdt_kick() before the timeout occurs or else the
watchdog will bark. Notice that the value shall be set between 1 and 255 seconds. Set to
zero is a false value.

Document number
204911
Version
Rev. K
Issue date
2016-10-11
Sirius Breadboard User Manual
www.aacmicrotec.com
Page 20 of 106
Default value of the watch dog is enabled. When debugged it must be set disabled
otherwise the system restart occasionally.
5.2.3.1. RTEMS
The RTEMS driver must be opened before it can access the watchdog device. Once
opened, all provided operations can be used as described in the RTEMS API defined in
subchapter 5.2.2. And, if desired, the access can be closed when not needed.
Figure 5-2 - RTEMS driver usage description
Note: All calls to the RTEMS driver are blocking calls.
5.2.3.2. RTEMS application example
In order to use the watchdog driver on the RTEMS environment, the following code structure
is suggested to be used:
Inclusion of <fcntl.h> and <unistd.h> are required for using the POSIX functions
open, close, lseek, read and write.
#include <bsp.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <bsp/wdt_rtems.h>
#define CONFIGURE_APPLICATION_NEEDS_WDT_DRIVER
#define CONFIGURE_INIT
rtems_task Init (rtems_task_argument argument);
#include <bsp/bsp_confdefs.h>
#include <rtems/confdefs.h>
rtems_task Init (rtems_task_argument argument)
{
}
Table of contents