...
 
Commits (61)
......@@ -4,7 +4,7 @@
# If not explicitely selected (with 'make FPU=1'), compile for FPU emulation
ifeq ($(FPU),)
FPU=0
FPU=1
endif
# To be able to properly handle any combination of (FPU, LEON, release)
......@@ -20,13 +20,13 @@ LEON ?= leon3
RTEMS ?= /opt/rtems-4.8
RTEMS_MAKEFILE_PATH = ${RTEMS}/sparc-rtems4.8/${LEON}
RTEMS_LIB=${RTEMS_MAKEFILE_PATH}/lib
EDISOFT_SUPPORT_PATH ?= /root/development/build/rtems-impr/testsuites/support
EDISOFT_SUPPORT_PATH ?= ${RTEMS}/support
CROSS_PREFIX=sparc-rtems4.8
# If not selected, compile debug version of binary (no optimizations)
#ifeq ($(CFG),)
#CFG=debug
#endif
ifeq ($(CFG),)
CFG=debug
endif
# The directories containing the source files, separated by ':'
#
......@@ -54,8 +54,10 @@ EDISOFT_SRC += ${LEON}.c
# DEAR USER, YOU MUST EDIT THIS
NONFPU_SRC= \
init.c \
task2.c \
${EDISOFT_SRC}
common.c \
task2.c
NONFPU_SRC+=${EDISOFT_SRC}
FPU_SRC= \
task1.c \
......@@ -88,17 +90,17 @@ COMMON += -B${RTEMS_LIB} -specs bsp_specs -qrtems -nodefaultlibs \
# Separate compile options per configuration
ifeq ($(CFG),debug)
CFLAGS += ${COMMON} -g -Wall -D_DEBUG ${INCLUDEFLAGS}
CFLAGS += ${COMMON} -g -Wall -Wextra -D_DEBUG ${INCLUDEFLAGS}
else
CFLAGS += ${COMMON} -g -O2 -Wall ${INCLUDEFLAGS}
CFLAGS += ${COMMON} -g -O2 -Wall -Wextra ${INCLUDEFLAGS}
endif
# FPU section
CFLAGS_FPU = ${CFLAGS}
CFLAGS_NONFPU = ${CFLAGS} -msoft-float
ifeq ($(FPU),0)
CFLAGS_FPU += -msoft-float
LDFLAGS += -msoft-float
ifeq ($(FPU),1)
CFLAGS_FPU += -mhard-float
LDFLAGS += -mhard-float
endif
# A common link flag for all configurations
......@@ -106,10 +108,10 @@ LDFLAGS += ${COMMON} -nodefaultlibs -Wl,--wrap,_IO_Initialize_all_drivers \
${RTEMS_LIB}/libno_event.a ${RTEMS_LIB}/libno_msg.a \
${RTEMS_LIB}/libno_sem.a ${RTEMS_LIB}/libno_timer.a \
${RTEMS_LIB}/libno_rtmon.a ${RTEMS_LIB}/libno_ext.a \
-Wl,--start-group -lrtemscpu -lio -lno_event -lno_msg -lno_sem \
-Wl,--start-group -lrtemscpu -lio -lno_event -lmsg -lno_sem \
-lno_timer -lno_rtmon -lno_ext -lrtemsbsp -llibc -lrtemscpu \
-Wl,--end-group -Wl,--script=linkcmds \
-B/tmp/edilibtmp/edilib/library -lgcc
-B${RTEMS}/support/edilib/library -lm -lgcc -lc
all: inform bin.$(SUFFIX)/${TARGET}
......
#include <printk.h>
#include "system.h"
void die(int task_no, unsigned exitCode)
{
rtems_status_code status = RTEMS_SUCCESSFUL;
exitCode = exitCode << 31;
exitCode |= task_no;
status = rtems_message_queue_send(Q_id, &exitCode, 4);
if (status != RTEMS_SUCCESSFUL) {
printk("[TASK %d] Failed to rtems_message_queue_send, status: %d\n", task_no, status);
}
rtems_task_delete(RTEMS_SELF);
}
/*
* Example initialization file - spawns 2 native FPU tasks
* Example initialization file - spawns 2 tasks
*
*/
#define CONFIGURE_INIT
#define TASKS 2
#define DEFINE_VARS
#include "system.h"
#include "printk.h"
rtems_task shepherd_EntryPoint(rtems_task_argument argument)
{
int tasks_completed = 0;
rtems_interval ticks_per_second;
(void) argument;
printk("[SHEPHERD] Waiting for testing tasks to complete...\n");
(void) rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second);
while(1) {
unsigned buffer;
size_t size;
rtems_status_code status = rtems_message_queue_receive(
Q_id, (void*)&buffer, &size, RTEMS_WAIT, ticks_per_second);
if ( status == RTEMS_SUCCESSFUL ) {
if (size != 4) {
printk("[SHEPHERD] More than 4 bytes sent over Q! (%d)\n", size);
rtems_task_delete(RTEMS_SELF);
}
printk("[SHEPHERD] Task %d completed with exit code %d.\n", buffer&1, buffer>>31);
tasks_completed ++;
if (tasks_completed == 2)
break;
} else if ( status != RTEMS_TIMEOUT ) {
printk("[SHEPHERD] rtems_message_queue_receive failed, status: %d\n", status);
rtems_task_delete(RTEMS_SELF);
}
}
printk("[SHEPHERD] All testing tasks completed.\n");
if (!all_OK)
printk("[SHEPHERD] Some tests failed... :-(\n");
else
printk("[SHEPHERD] All tests passed! :-)\n");
}
rtems_task Init(rtems_task_argument argument)
{
rtems_status_code status;
rtems_name Task_name[TASKS]; /* task names */
rtems_id Task_id[TASKS]; /* task ids */
int i;
rtems_name Task_name[TASKS+1]; /* task names */
rtems_id Task_id[TASKS+1]; /* task ids */
(void) argument;
// Create the synchronization msg Q first
rtems_status_code status = rtems_message_queue_create(
rtems_build_name('Q', '1', ' ', ' '),
TASKS, /* 1 message per task should suffice */
4, /* each message carries the task no (32-bit int) */
RTEMS_DEFAULT_ATTRIBUTES,
&Q_id);
if (status != RTEMS_SUCCESSFUL) {
printk("Failed to rtems_message_queue_create... status:%0x\n", status);
rtems_task_delete(RTEMS_SELF);
}
all_OK = 1;
for(i = 0; i < TASKS; i++)
{
// Initialize Task name
......@@ -25,12 +74,12 @@ rtems_task Init(rtems_task_argument argument)
Task_name[i],
(rtems_task_priority) 2,
RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES, // use RTEMS_DEFAULT_MODES | RTEMS_TIMESLICE for Linux/Windows like
// handling of tasks with same priority (i.e. pre-emption)
i == 1 ? RTEMS_FLOATING_POINT : RTEMS_DEFAULT_ATTRIBUTES,
RTEMS_DEFAULT_MODES | RTEMS_TIMESLICE, // Force pre-emption
i == 1 ? RTEMS_FLOATING_POINT // 2nd task does FPU
: RTEMS_DEFAULT_ATTRIBUTES,
&Task_id[i]);
if (status != RTEMS_SUCCESSFUL) {
printk("Failed to rtems_task_create... status:%0x\n", status);
printk("Failed to rtems_task_create, status: %d\n", status);
rtems_task_delete(RTEMS_SELF);
}
......@@ -38,10 +87,24 @@ rtems_task Init(rtems_task_argument argument)
status = rtems_task_start(
Task_id[i],
i == 1 ? Task1_EntryPoint : Task2_EntryPoint,
i);
i); // task argument passed in the function pointer (the task no)
}
printk("Parent task sleeps for a second...\n");
rtems_task_wake_after(100);
printk("Parent task bids adieu...\n");
// Launch the last task - the "shepherd"
Task_name[i] = rtems_build_name('T', 'T', "0" + i / 10, "0" + i % 10);
status = rtems_task_create(
Task_name[i],
(rtems_task_priority) 2,
RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES | RTEMS_TIMESLICE,
RTEMS_DEFAULT_ATTRIBUTES,
&Task_id[i]);
if (status != RTEMS_SUCCESSFUL) {
printk("Failed to rtems_task_create... status:%0x\n", status);
rtems_task_delete(RTEMS_SELF);
}
status = rtems_task_start(Task_id[i], shepherd_EntryPoint, i);
// Now die and let the shepherd take care of the flock :-)
rtems_task_delete(RTEMS_SELF);
}
#include <rtems/system.h>
#include <rtems/score/types.h>
#include <rtems/rtems/types.h>
#include <rtems/rtems/tasks.h>
......@@ -5,10 +6,22 @@
rtems_task Init(rtems_task_argument argument);
rtems_task Task1_EntryPoint(rtems_task_argument argument);
rtems_task Task2_EntryPoint(rtems_task_argument argument);
void die(int task_no, unsigned exitCode);
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 64
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 20
#define CONFIGURE_TICKS_PER_TIMESLICE 100
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#ifndef DEFINE_VARS
#define GLOBAL
#else
#define GLOBAL extern
#endif
GLOBAL int all_OK;
GLOBAL rtems_id Q_id;
#include <rtems/confdefs.h>
#include <math.h>
#include "system.h"
#include "printk.h"
rtems_task Task1_EntryPoint(rtems_task_argument argument)
{
int j = 0;
int task_no = (int) argument;
printk("Inside task %d...\n", task_no);
double d = task_no;
int j;
double d=task_no;
printk("Inside task %d...\n", task_no);
for(j=0; j<10000; j++) {
int k;
for(k=0; k<10000; k++)
d+=1.001;
d*=1.0001;
}
printk("Computed value by task %d was %ld\n", task_no, (long)d);
rtems_task_delete(RTEMS_SELF);
{
long result = (long) d;
long target = 172003608;
if (target != result) {
printk(
"[TASK %d] Failed! Computed value was %ld instead of %ld\n",
task_no, result, target);
all_OK = 0;
die(task_no, 1);
rtems_task_delete(RTEMS_SELF);
return;
}
}
printk("[TASK %d] Computed the correct floating point result.\n", task_no);
die(task_no, 0);
}
......@@ -3,17 +3,24 @@
rtems_task Task2_EntryPoint(rtems_task_argument argument)
{
int j = 0;
int task_no = (int) argument;
printk("Inside task %d...\n", task_no);
int j;
long long int dummy = 0;
for(j=0; j<100000; j++) {
printk("Inside task %d...\n", task_no);
for(j=0; j<500000; j++) {
int k;
for(k=0; k<100; k++)
dummy ^= k;
dummy++;
}
printk("Computed value by task %d was %d,%d\n", task_no, dummy&0xffffffff, dummy>>32);
rtems_task_delete(RTEMS_SELF);
if (dummy != 500000) {
printk(
"[TASK %d] Failed! Computed value was %lld instead of 500000\n",
task_no, dummy);
all_OK = 0;
die(task_no, 1);
}
printk("[TASK %d] Computed the correct integer result.\n", task_no);
die(task_no, 0);
}
bin.*
deps.*
objs.*
# Configuration section
#
# Use environment variables if found, otherwise fallback to sane defaults
# If not explicitely selected (with 'make FPU=1'), compile for FPU emulation
ifeq ($(FPU),)
FPU=0
endif
# To be able to properly handle any combination of (FPU, LEON, release)
# options, create a SUFFIX (see below) to differentiate output folders
ifeq ($(FPU),1)
FPU_SUFFIX=FPU
else
FPU_SUFFIX=NONFPU
endif
# Build up our settings from our inputs and our environment
LEON ?= ngmp
CROSS_PREFIX ?= sparc-rtems
RTEMS ?= /opt/rtems-4.10
# If not selected, compile debug version of binary (no optimizations)
#ifeq ($(CFG),)
#CFG=debug
#endif
# The directories containing the source files, separated by ':'
#
# DEAR USER, YOU MUST EDIT THIS AND ADD YOUR SOURCE FOLDERS
VPATH=src
# Your source files: regardless of where they reside in the source tree,
# VPATH will locate them...
#
# DEAR USER, YOU MUST EDIT THIS
SRC= \
init.c \
task1.c \
task2.c \
common.c \
memcheck.c
SUFFIX=$(CFG).$(FPU_SUFFIX).$(LEON)
# Build a Dependency list and an Object list, by replacing the .c
# extension to .d for dependency files, and .o for object files.
DEP = $(patsubst %.c, deps.$(SUFFIX)/%.d, ${SRC})
OBJ = $(patsubst %.c, objs.$(SUFFIX)/%.o, ${SRC})
# Your final binary
#
# DEAR USER, YOU MUST EDIT THIS
TARGET=fputest
# What compiler to use for generating dependencies:
# it will be invoked with -MM -MP
CC = ${RTEMS}/bin/${CROSS_PREFIX}-gcc
CDEP = ${CC}
# What include flags to pass to the compiler
INCLUDEFLAGS= -I src
COMMON += -q${LEON} -mcpu=v8 -Wall \
-Wmissing-prototypes -Wimplicit-function-declaration \
-Wstrict-prototypes -Wnested-externs
# Separate compile options per configuration
ifeq ($(CFG),debug)
CFLAGS += ${COMMON} -g -Wall -D_DEBUG ${INCLUDEFLAGS}
else
CFLAGS += ${COMMON} -g -O2 -Wall ${INCLUDEFLAGS}
endif
# Should we generate native FPU instructions for the SRC or not?
ifeq ($(FPU),0)
CFLAGS += -msoft-float
LDFLAGS += -msoft-float
endif
# A common link flag for all configurations
LDFLAGS += ${COMMON}
all: inform bin.$(SUFFIX)/${TARGET}
inform:
ifneq ($(CFG),release)
ifneq ($(CFG),debug)
@echo " "
@echo "Invalid or missing configuration (CFG) "$(CFG)" specified."
@echo " "
@echo "You must specify a configuration when running make, e.g."
@echo " "
@echo " make CFG=debug LEON=leon3mp FPU=1 V=1"
@echo " "
@echo "- Possible choices for CFG are 'release' and 'debug'"
@echo "- Possible choices for LEON are 'leon2', 'leon3mp' and 'ngmp' (default)"
@echo "- Possible choices for FPU are '1' (native) and '0' (emulated) (default)"
@echo "- Possible choices for V are '1' (show commands) and '0' (silent) (default)"
@echo " "
@exit 1
endif
endif
bin.$(SUFFIX)/${TARGET}: ${OBJ} | inform
@mkdir -p $(dir $@)
ifeq ($(V),1)
$(CC) -g -o $@ $^ ${LDFLAGS}
else
@echo [LD] $@
@$(CC) -g -o $@ $^ ${LDFLAGS}
endif
ifeq ($(CFG),release)
@${RTEMS}/bin/${CROSS_PREFIX}-objcopy --only-keep-debug $@ ${@}.debug
@${RTEMS}/bin/${CROSS_PREFIX}-strip $@
endif
@echo Built with RTEMS at ${RTEMS_LIB} for ${LEON}.
objs.$(SUFFIX)/%.o: %.c | src/version.h
@mkdir -p $(dir $@)
ifeq ($(V),1)
$(CC) -c $(CFLAGS) -o $@ $<
else
@echo [CC] $@
@$(CC) -c $(CFLAGS) -o $@ $<
endif
deps.$(SUFFIX)/%.d: %.c
@mkdir -p $(dir $@)
@echo Generating dependencies for $<
@set -e ; $(CDEP) -MM -MP $(INCLUDEFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,objs.$(SUFFIX)\/\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
src/version.h: $(patsubst %, src/%, ${SRC}) Makefile
@/bin/echo -en '#ifndef __VERSION_H__\n' > $@
@/bin/echo -en "#define __VERSION_H__\n" >> $@
@/bin/echo -en 'const char version[] = "1.' >> $@
@git log --oneline | wc -l | tr -d '\n' >> $@
@/bin/echo -n " (" >> $@
@git log --oneline | head -1 | cut -d\ -f1 | tr -d '\n' >> $@
@/bin/echo ')";' >> $@
@/bin/echo -en "#endif\n" >> $@
clean:
@rm -rf deps.* objs.* bin.*
# Unless "make clean" is called, include the dependency files
# which are auto-generated. Don't fail if they are missing
# (-include), since they will be missing in the first invocation!
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(CFG),)
-include ${DEP}
endif
endif
# Configuration section
#
# Use environment variables if found, otherwise fallback to sane defaults
# If not explicitely selected (with 'make FPU=1'), compile for native FPU
ifeq ($(FPU),)
FPU=1
endif
ifeq ($(SMP),)
SMP=_smp
endif
# To be able to properly handle any combination of (FPU, LEON, release)
# options, create a SUFFIX (see below) to differentiate output folders
ifeq ($(FPU),1)
FPU_SUFFIX=FPU
else
FPU_SUFFIX=NONFPU
endif
# Build up our settings from our inputs and our environment
LEON ?= gr740
CROSS_PREFIX ?= sparc-gaisler-rtems5
RTEMS ?= /opt/rcc-1.3-rc5-gcc
# If not selected, compile debug version of binary (no optimizations)
#ifeq ($(CFG),)
CFG=debug
#endif
# The directories containing the source files, separated by ':'
#
# DEAR USER, YOU MUST EDIT THIS AND ADD YOUR SOURCE FOLDERS
VPATH=src
# Your source files: regardless of where they reside in the source tree,
# VPATH will locate them...
#
# DEAR USER, YOU MUST EDIT THIS
SRC= \
init.c \
task1.c \
task2.c \
common.c \
memcheck.c
SUFFIX=$(CFG).$(FPU_SUFFIX).$(LEON)
# Build a Dependency list and an Object list, by replacing the .c
# extension to .d for dependency files, and .o for object files.
DEP = $(patsubst %.c, deps.$(SUFFIX)/%.d, ${SRC})
OBJ = $(patsubst %.c, objs.$(SUFFIX)/%.o, ${SRC})
# Your final binary
#
# DEAR USER, YOU MUST EDIT THIS
TARGET=fputest
# What compiler to use for generating dependencies:
# it will be invoked with -MM -MP
CC = ${RTEMS}/bin/${CROSS_PREFIX}-gcc
CDEP = ${CC}
# What include flags to pass to the compiler
INCLUDEFLAGS= -I src
COMMON += -mcpu=leon3 -qbsp=${LEON}${SMP} -Wall \
-Wmissing-prototypes -Wimplicit-function-declaration \
-Wstrict-prototypes -Wnested-externs
# Separate compile options per configuration
ifeq ($(CFG),debug)
CFLAGS += ${COMMON} -g -Wall -D_DEBUG ${INCLUDEFLAGS}
else
CFLAGS += ${COMMON} -g -O2 -Wall ${INCLUDEFLAGS}
endif
# Should we generate native FPU instructions for the SRC or not?
ifeq ($(FPU),0)
CFLAGS += -msoft-float
LDFLAGS += -msoft-float
endif
# A common link flag for all configurations
LDFLAGS += ${COMMON}
all: inform bin.$(SUFFIX)/${TARGET}
inform:
ifneq ($(CFG),release)
ifneq ($(CFG),debug)
@echo " "
@echo "Invalid or missing configuration (CFG) "$(CFG)" specified."
@echo " "
@echo "You must specify a configuration when running make, e.g."
@echo " "
@echo " make CFG=debug LEON=leon3mp FPU=1 V=1"
@echo " "
@echo "- Possible choices for CFG are 'release' and 'debug'"
@echo "- Possible choices for LEON are 'leon2', 'leon3mp' and 'ngmp' (default)"
@echo "- Possible choices for FPU are '1' (native) and '0' (emulated) (default)"
@echo "- Possible choices for V are '1' (show commands) and '0' (silent) (default)"
@echo " "
@exit 1
endif
endif
bin.$(SUFFIX)/${TARGET}: ${OBJ} | inform
@mkdir -p $(dir $@)
ifeq ($(V),1)
$(CC) -g -o $@ $^ ${LDFLAGS}
else
@echo [LD] $@
@$(CC) -g -o $@ $^ ${LDFLAGS}
endif
ifeq ($(CFG),release)
@${RTEMS}/bin/${CROSS_PREFIX}-objcopy --only-keep-debug $@ ${@}.debug
@${RTEMS}/bin/${CROSS_PREFIX}-strip $@
endif
@echo Built with RTEMS at ${RTEMS_LIB} for ${LEON}.
objs.$(SUFFIX)/%.o: %.c | src/version.h
@mkdir -p $(dir $@)
ifeq ($(V),1)
$(CC) -c $(CFLAGS) -o $@ $<
else
@echo [CC] $@
@$(CC) -c $(CFLAGS) -o $@ $<
endif
deps.$(SUFFIX)/%.d: %.c
@mkdir -p $(dir $@)
@echo Generating dependencies for $<
@set -e ; $(CDEP) -MM -MP $(INCLUDEFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,objs.$(SUFFIX)\/\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
src/version.h: $(patsubst %, src/%, ${SRC}) Makefile
@/bin/echo -en '#ifndef __VERSION_H__\n' > $@
@/bin/echo -en "#define __VERSION_H__\n" >> $@
@/bin/echo -en 'const char version[] = "1.' >> $@
@git log --oneline | wc -l | tr -d '\n' >> $@
@/bin/echo -n " (" >> $@
@git log --oneline | head -1 | cut -d\ -f1 | tr -d '\n' >> $@
@/bin/echo ')";' >> $@
@/bin/echo -en "#endif\n" >> $@
clean:
@rm -rf deps.* objs.* bin.*
# Unless "make clean" is called, include the dependency files
# which are auto-generated. Don't fail if they are missing
# (-include), since they will be missing in the first invocation!
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(CFG),)
-include ${DEP}
endif
endif
#include "system.h"
#include <stdio.h>
void task_begin(int task_no)
{
printf("[TASK %d] Starting...\n", task_no);
fflush(stdout);
}
void task_end(int task_no)
{
rtems_event_send(g_init_task_id, RTEMS_EVENT_0 << task_no);
rtems_task_delete(RTEMS_SELF);
}
/*
* Example initialization file - spawns 2 native FPU tasks
*
*/
#define CONFIGURE_INIT
#define TASKS 4
#define DEFINE_VARS
#include "system.h"
#include <stdio.h>
#include <stdlib.h>
rtems_task Init(rtems_task_argument argument)
{
rtems_status_code status;
rtems_name Task_name[TASKS]; /* task names */
rtems_id Task_id[TASKS]; /* task ids */
int i;
#ifdef MEMCHECK
memcheck();
#endif
all_OK = 1;
g_init_task_id = rtems_task_self();
for(i = 0; i < TASKS; i++)
{
// Initialize Task name
Task_name[i] = rtems_build_name('T', 'T', "0" + i / 10, "0" + i % 10);
// Create Task
status = rtems_task_create(
Task_name[i],
(rtems_task_priority) 2,
RTEMS_MINIMUM_STACK_SIZE,
#if CONFIGURE_SMP_MAXIMUM_PROCESSORS == 1 || CONFIGURE_MAXIMUM_PROCESSORS == 1
// LEON2 system - emulate SMP via Linux/Windows-like
// handling of tasks with same priority (i.e. pre-emption)
RTEMS_DEFAULT_MODES | RTEMS_TIMESLICE,
#else
// LEON3/LEON4 system - use full SMP
RTEMS_DEFAULT_MODES,
#endif
#if __RTEMS_MAJOR__ == 5
// Currently, RCCrc3 has a bug - it needs floating point support
// for all tasks, even those that don't use the FPU - otherwise
// as soon as the FPU task dies, the binary dies as well.
RTEMS_FLOATING_POINT,
#else
(i%2) == 0 ? RTEMS_FLOATING_POINT : RTEMS_DEFAULT_ATTRIBUTES,
#endif
&Task_id[i]);
if (status != RTEMS_SUCCESSFUL) {
printf(
"[MAIN] Failed to rtems_task_create... status:%0x\n",
status);
rtems_task_delete(RTEMS_SELF);
}
// Start Task
status = rtems_task_start(
Task_id[i],
(i%2) == 0 ? Task1_EntryPoint : Task2_EntryPoint,
i);
}
// To give coverage code the opportunity to work, wait for children tasks
// to die first. RTEMS events are used for synchronization.
{
printf("[MAIN] Waiting for testing tasks to complete...\n");
rtems_option options = (RTEMS_EVENT_ANY | RTEMS_WAIT);
rtems_event_set in = 0;
for (i=0; i<TASKS; i++)
in |= (RTEMS_EVENT_0 << i);
rtems_event_set out;
rtems_event_set non_completed = in;
while (non_completed) {
status = rtems_event_receive(in, options, RTEMS_NO_TIMEOUT, &out);
if ( status == RTEMS_SUCCESSFUL ) {
non_completed &= ~out;
printf("[MAIN] Task completed.\n");
fflush(stdout);
}
}
printf("[MAIN] All testing tasks completed.\n");
if (!all_OK)
printf("[MAIN] Some tests failed... :-(\n");
else
printf("[MAIN] All tests passed! :-)\n");
fflush(stdout);
}
exit(0);
}
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "version.h"
#include "system.h"
void memcheck()
{
#ifdef MEMCHECK
// Use alternating bit values to verify proper memory operations,
// by writing values in memory that stress (electrically) the circuits
uint32_t patterns[] = {
0x0,
0xFFFFFFFF,
0xAAAAAAAA,
0x55555555,
0xAA55AA55,
0x55AA55AA,
};
#ifdef CHECK_WRAPAROUNDS_WITH_PRIME_SIZED_WINDOWS
// Prime numbers used to check for potential address space overlaps
// (read comments in the code below that uses this)
unsigned primes[] = { 3, 7, 31, 127 };
unsigned cnt = 0;
#endif
// Counters used in loops below.
int i = 0;
// Detect available memory by repeated allocations.
// Start at 512K.
size_t space = 512*1024;
void *p = malloc(space);
printf("[BOARD TESTER, version %s] - see https://goo.gl/CLrIOC for details\n", version);
printf("[MEMCHECK] Detecting available memory... ");
fflush(stdout);
while(p) {
free(p);
space += 1024*1024; // test memory increases in 1MB increments
p = malloc(space);
}
space -= 1024*1024;
printf("%dK\n", space/1024);
// Now that we know the amount of memory available, reserve it all.
p = malloc(space);
if (!p) {
puts("[MEMCHECK] Unexpected heap error. Aborting...");
fflush(stdout);
exit(1);
}
#ifdef CHECK_WRAPAROUNDS_WITH_PRIME_SIZED_WINDOWS
// How can we make sure that RTEMS doesn't mis-identify our available
// memory and doesn't return 'windowed' areas? (i.e. we think we have
// e.g. 128KB, but in fact, the last 64KB 'mirror' back to the first
// 64KB)?
//
// Simple: we write sequences of values up to prime numbers - e.g.
//
// 0 1 2 0 1 2 0 1 ...
//
// If there is a wrap-around at some offset, the value written will
// NOT be the same as the first time we wrote at the 'mirror' offset,
// since any wraparounds will happen at power-of-two boundaries.
//
// e.g. for a mis-identified 8-byte area as a 16-byte one, we write...
//
// Offset: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Values written: 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0
// ^
// `----- Here memory wraps-around
// Values read: 2 0 1 2 0 1 2 0
//
// Due to the use of a prime number, the wrap-around will be detected;
// we wrote a 0 at offset 0, but it was overwritten with a 2 when we
// wrote at offset 8 (which wrapped around - 'ghost' address space).
printf("[MEMCHECK] Checking for potential address space overlap. Window: ");
for (i=0; i<sizeof(primes)/sizeof(primes[0]); i++) {
uint8_t *pc = p;
unsigned prime = primes[i];
unsigned bytes = space;
printf("%s%d", i?", ":"", prime);
fflush(stdout);
cnt = 0;
while (bytes--) {
*pc++ = cnt;
cnt++;
if (cnt == prime) {
cnt = 0;
}
}
pc = p;
bytes = space;
cnt = 0;
while (bytes--) {
if (*pc != cnt) {
printf("[MEMCHECK] Address space wrapped around at 0x%x!\n",
(unsigned)pc);
fflush(stdout);
exit(1);
}
pc++;
cnt++;
if (cnt == prime) {
cnt = 0;
}
}
}
puts("");
#endif
// Write all over the memory using alternating bit values; this verifies
// proper memory operations, by stressing (electrically) the circuits.
for(i=0; i<sizeof(patterns)/sizeof(patterns[0]); i++) {
unsigned pattern = patterns[i];
uint32_t *pw = p;
unsigned words = space/4;
printf("[MEMCHECK] Writing memory pattern 0x%08x ", pattern);
fflush(stdout);
// Writing the pattern
while(words--) {
*pw++ = pattern;
if ((words & 0xFFFFFF) == 0xFFFFFF) {
printf("\b\b\b\b\b\b%5.2f%%", 100.0*((space/4.0)-words)/(space/4.0));
fflush(stdout);
}
}
printf("\b\b\b\b\b\b\b%5.2f%%\n", 100.0);
pw = p;
words = space/4;
// Verifying the pattern
printf("[MEMCHECK] Reading memory, checking for 0x%08x ", pattern);
fflush(stdout);
while(words--) {
if (*pw != pattern) {
printf(
"\n[MEMCHECK] Failed with pattern 0x%x at offset 0x%x\n",
pattern, (unsigned)pw);
fflush(stdout);
exit(1);
}
if ((words & 0xFFFFFF) == 0xFFFFFF) {
printf("\b\b\b\b\b\b%5.2f%%", 100.0*((space/4.0)-words)/(space/4.0));
fflush(stdout);
}
pw++;
}
printf("\b\b\b\b\b\b\b%5.2f%%\n", 100.0);
}
// A simple final run storing big numbers consecutively.
printf("[MEMCHECK] Writing 32-bit numbers from 0 up to %d ", space/4);
{
uint32_t *pw = p;
unsigned words = space/4;
while(words--) {
*pw++ = words;
if ((words & 0xFFFFFF) == 0xFFFFFF) {
printf("\b\b\b\b\b\b%5.2f%%", 100.0*((space/4.0)-words)/(space/4.0));
fflush(stdout);
}
}
printf("\b\b\b\b\b\b\b%5.2f%%\n", 100.0);
printf("[MEMCHECK] Reading 32-bit numbers from 0 up to %d ", space/4);
pw = p;
words = space/4;
// Verifying the big numbers
while(words--) {
if (*pw != words) {
printf(
"\n[MEMCHECK] Failed with big value 0x%x at offset 0x%x\n",
words, (unsigned)pw);
fflush(stdout);
exit(1);
}
pw++;
if ((words & 0xFFFFFF) == 0xFFFFFF) {
printf("\b\b\b\b\b\b%5.2f%%", 100.0*((space/4.0)-words)/(space/4.0));
fflush(stdout);
}
}
printf("\b\b\b\b\b\b\b%5.2f%%\n", 100.0);
}
free(p);
#else
puts("[MEMCHECK] Memory checks are disabled. Proceeding with main execution...");
fflush(stdout);
#endif
}
// Uncomment this to perform memory checks at startup
// #define MEMCHECK
#include <rtems.h>
rtems_task Init(rtems_task_argument argument);
rtems_task Task1_EntryPoint(rtems_task_argument argument);
rtems_task Task2_EntryPoint(rtems_task_argument argument);
void task_begin(int task_no);
void task_end(int task_no);
void memcheck(void);
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 64
#define CONFIGURE_TICKS_PER_TIMESLICE 100
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#if __RTEMS_MAJOR__ < 5
#define CONFIGURE_SMP_APPLICATION
#ifdef BSP_leon2
#define CONFIGURE_SMP_MAXIMUM_PROCESSORS 1
#else
#define CONFIGURE_SMP_MAXIMUM_PROCESSORS 4
#endif
#else
#ifdef BSP_leon2
#define CONFIGURE_MAXIMUM_PROCESSORS 1
#else
#define CONFIGURE_MAXIMUM_PROCESSORS 4
#endif
#endif
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
#ifndef DEFINE_VARS
#define GLOBAL
#else
#define GLOBAL extern
#endif
GLOBAL rtems_id g_init_task_id;
GLOBAL int all_OK;
#include <rtems/confdefs.h>
#include "system.h"
#include <stdio.h>
rtems_task Task1_EntryPoint(rtems_task_argument argument)
{
int task_no = (int) argument;
task_begin(task_no);
int j;
double d=task_no;
for(j=0; j<10000; j++) {
int k;
for(k=0; k<10000; k++)
d+=1.001;
d*=1.0001;
}
{
long result = (long) d;
long target = 0;
switch(task_no) {
case 0:
target = 172003605L;
break;
case 2:
target = 172003611L;
break;
default:
printf(
"[TASK %d] Failed! Unexpected task number for FPU tests...\n",
task_no);
fflush(stdout);
all_OK = 0;
task_end(task_no);
return;
}
if (target != result) {
printf(
"[TASK %d] Failed! Computed value was %ld instead of %ld\n",
task_no, result, target);
fflush(stdout);
all_OK = 0;
task_end(task_no);
return;
}
}
printf("[TASK %d] Computed the correct floating point result.\n", task_no);
fflush(stdout);
task_end(task_no);
}
#include "system.h"
#include <stdio.h>
rtems_task Task2_EntryPoint(rtems_task_argument argument)
{
int task_no = (int) argument;
task_begin(task_no);
int j;
long long int dummy = 0;
for(j=0; j<500000; j++) {
int k;
for(k=0; k<100; k++)
dummy ^= k;
dummy++;
}
if (dummy != 500000) {
printf(
"[TASK %d] Failed! Computed value was %lld instead of 500000\n",
task_no, dummy);
fflush(stdout);
all_OK = 0;
task_end(task_no);
return;
}
printf("[TASK %d] Computed the correct integer result.\n", task_no);
fflush(stdout);
task_end((int) argument);
}
#ifndef __VERSION_H__
#define __VERSION_H__
const char version[] = "1.104 (940a750)";
#endif
bin.*
objs.*
deps.*
src/version.h
......@@ -7,7 +7,7 @@ ifeq ($(FPU),)
FPU=0
endif
# To be able to properly handle any combination of (FPU, LEON, release)
# To be able to properly handle any combination of (FPU, BSP, release)
# options, create a SUFFIX (see below) to differentiate output folders
ifeq ($(FPU),1)
FPU_SUFFIX=FPU
......@@ -16,11 +16,12 @@ FPU_SUFFIX=NONFPU
endif
# Build up our settings from our inputs and our environment
LEON ?= leon3
RTEMS ?= /opt/rtems-4.11-2016.04.01.${FPU_SUFFIX}
RTEMS_MAKEFILE_PATH = ${RTEMS}/sparc-rtems4.11/${LEON}
CPU ?= cypress
BSP ?= leon3
CROSS_PREFIX ?= sparc-rtems4.12
RTEMS ?= /opt/rtems-4.12
RTEMS_MAKEFILE_PATH = ${RTEMS}/${CROSS_PREFIX}/${BSP}
RTEMS_LIB=${RTEMS_MAKEFILE_PATH}/lib
CROSS_PREFIX=sparc-rtems4.11
# If not selected, compile debug version of binary (no optimizations)
#ifeq ($(CFG),)
......@@ -43,7 +44,7 @@ SRC= \
common.c \
memcheck.c
SUFFIX=$(CFG).$(FPU_SUFFIX).$(LEON)
SUFFIX=$(CFG).$(FPU_SUFFIX).$(BSP)
# Build a Dependency list and an Object list, by replacing the .c
# extension to .d for dependency files, and .o for object files.
......@@ -65,7 +66,7 @@ INCLUDEFLAGS= -I src
# Compilation flags (common)
COMMON += -B${RTEMS_LIB} -specs bsp_specs -qrtems \
-mcpu=cypress -DBSP_${LEON} \
-mcpu=${CPU} -DBSP_${BSP} \
-ffunction-sections -fdata-sections -Wall \
-Wmissing-prototypes -Wimplicit-function-declaration \
-Wstrict-prototypes -Wnested-externs
......@@ -96,10 +97,10 @@ ifneq ($(CFG),debug)
@echo " "
@echo "You must specify a configuration when running make, e.g."
@echo " "
@echo " make CFG=debug LEON=leon3 FPU=1 V=1"
@echo " make CFG=debug BSP=leon3 FPU=1 V=1"
@echo " "
@echo "- Possible choices for CFG are 'release' and 'debug'"
@echo "- Possible choices for LEON are 'leon2' and 'leon3' (default)"
@echo "- Possible choices for BSP are 'leon2' and 'leon3' (default)"
@echo "- Possible choices for FPU are '1' (native) and '0' (emulated) (default)"
@echo "- Possible choices for V are '1' (show commands) and '0' (silent) (default)"
@echo " "
......@@ -117,12 +118,12 @@ else
@$(CC) -g -o $@ $^ ${LDFLAGS}
endif
ifeq ($(CFG),release)
@${CROSS_PREFIX}-objcopy --only-keep-debug $@ ${@}.debug
@${CROSS_PREFIX}-strip $@
@${RTEMS}/bin/${CROSS_PREFIX}-objcopy --only-keep-debug $@ ${@}.debug
@${RTEMS}/bin/${CROSS_PREFIX}-strip $@
endif
@echo Built with RTEMS at ${RTEMS_LIB} for ${LEON}.
@echo Built with RTEMS at ${RTEMS_LIB} for ${BSP}.
objs.$(SUFFIX)/%.o: %.c
objs.$(SUFFIX)/%.o: %.c | src/version.h
@mkdir -p $(dir $@)
ifeq ($(V),1)
$(CC) -c $(CFLAGS) -o $@ $<
......@@ -138,6 +139,16 @@ deps.$(SUFFIX)/%.d: %.c
sed 's,\($*\)\.o[ :]*,objs.$(SUFFIX)\/\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
src/version.h: $(patsubst %, src/%, ${SRC}) Makefile
@/bin/echo -en '#ifndef __VERSION_H__\n' > $@
@/bin/echo -en "#define __VERSION_H__\n" >> $@
@/bin/echo -en 'const char version[] = "1.' >> $@
@git log --oneline | wc -l | tr -d '\n' >> $@
@/bin/echo -n " (" >> $@
@git log --oneline | head -1 | cut -d\ -f1 | tr -d '\n' >> $@
@/bin/echo ')";' >> $@
@/bin/echo -en "#endif\n" >> $@
clean:
@rm -rf deps.* objs.* bin.*
......
Introduction
============
This folder contains the OAR RTEMS scaffolds. The Makefile and example
This folder contains the OAR RTEMS scaffold. The Makefile and example
source code demonstrates how to:
* support both debug and release compilations
* support compilation for native and emulated FPU usage
* support targetting Leon2 and Leon3 CPUs
* enable/disable showing compilation commands
* perform memory, FPU and integer testing of any Leon-based board
Building RTEMS via the RSB
--------------------------
The contrib folder includes a script that you can use to compile RTEMS4.11
The contrib folder includes a script that you can use to compile RTEMS4.12
with the Leon2 and Leon3 BSPs from the OAR repository. Note that
[as discussed in the RTEMS mailing list](https://lists.rtems.org/pipermail/users/2016-February/029782.html),
you will need to compile your BSP for native or emulated FPU, based
......@@ -45,7 +46,7 @@ There are 4 orthogonal compilation options that you can control:
- debug/release compilation (`CFG`)
- emulated/native FPU compilation (`FPU`)
- Leon2/Leon3 target (`LEON`)
- Leon2/Leon3 target (`BSP`)
- show/hide compilation commands (`V`)
## Debug/Release mode
......@@ -90,17 +91,17 @@ To use emulation (default, if `FPU` option is not provided), pass `FPU=0`:
The `FPU` and `CFG` options are completely independent ; you can e.g.
compile a debug version that uses native FPU, and a release one that uses
emulation. Just keep in mind that currently, 4.11
emulation. Just keep in mind that currently, 4.12
[does not allow you to use the same BSP](https://lists.rtems.org/pipermail/users/2016-February/029782.html),
for both native and emulated FPU usage ; you'll have to build separate
BSPs by tweaking the `leon2.cfg`/`leon3.cfg` files when you build RTEMS.
## Select Leon target
Use the `LEON` Makefile parameter to decide which target to build for
Use the `BSP` Makefile parameter to decide which target to build for
(currently, only `leon2` and `leon3` are supported):
$ make CFG=debug FPU=1 LEON=leon3
$ make CFG=debug FPU=1 BSP=leon3
## Verbosity
......@@ -118,23 +119,23 @@ If you want to see the complete commands used, pass `V=1`:
$ touch src/task1.c
$ make CFG=debug FPU=0 V=1
/opt/rtems-4.11-2016.04.01.NONFPU/bin/sparc-rtems4.11-gcc -c \
-B/opt/rtems-4.11-2016.04.01.NONFPU/sparc-rtems4.11/leon3/lib \
/opt/rtems-4.12-2016.06.13.NONFPU/bin/sparc-rtems4.12-gcc -c \
-B/opt/rtems-4.12-2016.06.13.NONFPU/sparc-rtems4.12/leon3/lib \
-specs bsp_specs -qrtems -mcpu=cypress -DBSP_leon3 -ffunction-sections \
-fdata-sections -Wall -Wmissing-prototypes \
-Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs \
-g -Wall -D_DEBUG -I src -msoft-float \
-o objs.debug.NONFPU.leon3/task1.o src/task1.c
/opt/rtems-4.11-2016.04.01.NONFPU/bin/sparc-rtems4.11-gcc -g \
/opt/rtems-4.12-2016.06.13.NONFPU/bin/sparc-rtems4.12-gcc -g \
-o bin.debug.NONFPU.leon3/fputest objs.debug.NONFPU.leon3/init.o \
objs.debug.NONFPU.leon3/task1.o objs.debug.NONFPU.leon3/task2.o \
objs.debug.NONFPU.leon3/common.o -msoft-float \
-B/opt/rtems-4.11-2016.04.01.NONFPU/sparc-rtems4.11/leon3/lib \
-B/opt/rtems-4.12-2016.06.13.NONFPU/sparc-rtems4.12/leon3/lib \
-specs bsp_specs -qrtems -mcpu=cypress -DBSP_leon3 \
-ffunction-sections -fdata-sections -Wall -Wmissing-prototypes \
-Wimplicit-function-declaration -Wstrict-prototypes \
-Wnested-externs -Wl,--gc-sections
Built with RTEMS at /opt/rtems-4.11-2016.04.01.NONFPU/sparc-rtems4.11/leon3/lib for leon3.
Built with RTEMS at /opt/rtems-4.12-2016.06.13.NONFPU/sparc-rtems4.12/leon3/lib for leon3.
# Support
......
#!/bin/bash
#
# This script builds the RTEMS4.11/Sparc cross-compiler
# and Leon2/3 BSPs.
# This script builds the RTEMS/SPARC cross-compiler and the
# LEON2/GR712/GR740 BSPs.
#
# To have a reproducible setup, we suggest you execute
# this script under a Debian jessie chroot, bootstrapped
# via the following:
# The call to sb-check below will stop the build if your environment
# is missing the necessary dependencies. Note that in addition to these,
# the build depends on GCC7 AND GNAT7 - otherwise the creation of the
# toolchain will fail.
#
# mkdir /opt/jessie-chroot
# debootstrap jessie /opt/jessie-chroot
# mount -t proc none /opt/jessie-chroot/proc/
# mount -t sysfs none /opt/jessie-chroot/sys/
# mount -o bind /dev /opt/jessie-chroot/dev/
# mount -o bind /dev/pts /opt/jessie-chroot/dev/pts/
# chroot /opt/jessie-chroot
# apt-get update
# apt-get build-dep binutils gcc g++ gdb unzip git python2.7-dev pax
# If you want to get a pre-made toolchain that was built by this script,
# you can download it in standalone form from:
#
# Then chroot inside it and run this script:
# http://download.tuxfamily.org/taste/RTEMS/rtems-4.12-2017.07.17.tar.bz2
#
# chroot /opt/jessie-chroot
# /path/to/build.rtems.4.11.sh
# This compiler is also automatically installed in the TASTE VM
# (available from https://taste.tuxfamily.org/ - navigate to the Download
# Area, and get the .ova file - which you then import in VirtualBox).
# Upon entering the VM, call Update-TASTE (as indicated in the help
# screen shown upon boot) and the RTEMS toolchain will be installed.
# Stop on any error
set -e
DATE=$(date +"%Y.%m.%d")
mkdir -p /root/rtems.build.logs
BUILD_LOG=/root/rtems.build.logs/${DATE}.log
mkdir -p $HOME/rtems.build.logs
BUILD_LOG=$HOME/rtems.build.logs/${DATE}.log
[ -f ${BUILD_LOG} ] && {
echo "There's already a build log:"
echo " " ${BUILD_LOG}
......@@ -39,60 +36,80 @@ BUILD_LOG=/root/rtems.build.logs/${DATE}.log
# Record the output in $BUILD_LOG (see matching brace)
{
# Begin by checking out the RTEMS Source Builder
mkdir -p /root/development/rtems/src
RSB=/root/development/rtems/src/rtems-source-builder-${DATE}
RTPREFIX=/opt/rtems-4.11-${DATE}
RSBPARENT=$HOME/development/rtems/src
mkdir -p $RSBPARENT
RSB=$RSBPARENT/rtems-source-builder-${DATE}
RTPREFIX=/opt/rtems-4.12-${DATE}
rm -rf ${RTPREFIX}
[ ! -d $RSB ] && {
cd /root/development/rtems/src/
git clone git://git.rtems.org/rtems-source-builder.git rtems-source-builder-${DATE}
cd $RSBPARENT
git clone https://github.com/RTEMS/rtems-source-builder.git rtems-source-builder-${DATE}
}
cd $RSB
git checkout -f 4.11
# What tag/branch to work on? By default this will be in the master branch,
# but you can switch - to e.g. 4.11.2:
#
# git checkout -f 4.11.2
#
# RSB commit ID recommended by Embedded Brains for using RTEMS/SMP:
git checkout -f e2952bb185c1f40027caa76cfd9e4a45b17a8886
# Verify that we have all we need to build
source-builder/sb-check
cd rtems
# Your network firewall may or may not be an issue at this point:
# Many of the source tarballs needed by the RSB are fetched over
# PASV-enabled FTP servers.
#
# If your network is like the one in ESA/ESTEC and this is forbidden,
# you'll have to fetch these tarballs and hardlink to them each time
# (so no FTP action is triggered by the RTEMS RSB builder).
# This is how I do it - adapt according to your needs:
# The sed invocation below also replaces ftp: with http:
# (since this needs no PASV port meddling - which some firewalls object to)
#
# This is the way I do it - adapt it according to your needs:
#
# cd rtems
# [ ! -d sources ] && {
# mkdir -p sources
# cd sources
# cp -al /root/development/rtems/src/rtems-source-builder.working/rtems/sources/* .
# cp -al ~/development/rtems/pkg_sources_cache/* .
# cd ..
# for i in config/tools/*cfg ; do
# cat "$i" | sed 's,ftp://ftp.gnu.org,http://ftp.gnu.org,;s,ftp://gcc.gnu.org,http://gcc.gnu.org,;' > "$i".new && mv "$i".new "$i"
# done
# }
# Build the cross compiler
# (we're in the master branch, which is currently the "unofficial" 4.11)
../source-builder/sb-set-builder --log=stage1.log --prefix=${RTPREFIX} 4.11/rtems-sparc
# Build the cross compiling toolchain
# (we're in the master branch, which is currently the "unofficial" 4.12)
../source-builder/sb-set-builder --with-ada --log=stage1.log --prefix=${RTPREFIX} 4.12/rtems-sparc
# Add the cross compiler to the PATH and checkout RTEMS
export PATH=${RTPREFIX}/bin:$PATH
cd ..
[ ! -d rtems-git ] && {
git clone https://github.com/RTEMS/rtems.git rtems-git
cd rtems-git
# RTEMS commit ID recommended by Embedded Brains for using RTEMS/SMP
git checkout -f 96ce1ec743a1fcf27593ee72cf1695d9eb0290de
cd ..
}
# Build RTEMS
cd rtems-git
git checkout -f 4.11
./bootstrap
cd ..
rm -rf build.${DATE}
mkdir build.${DATE}
cd build.${DATE}
../rtems-git/configure \
--target=sparc-rtems4.11 --prefix=${RTPREFIX} \
--enable-rtemsbsp="leon2 leon3" --enable-posix \
--enable-cxx --enable-networking
--target=sparc-rtems4.12 --prefix=${RTPREFIX} \
--enable-rtemsbsp="leon2 leon3 ngmp" --enable-posix --enable-ada \
--enable-smp --enable-cxx --enable-networking
make all
make install
} |& tee ${BUILD_LOG}
#!/bin/bash
#
# This script builds the RTEMS/SPARC cross-compiler and the
# Leon2/Leon3/NGMP BSPs.
#
# To have a reproducible setup, it would be prudent if you
# executed this script under a Debian stretch chroot,
# bootstrapped via the following:
#
# mkdir /opt/stretch-chroot
# debootstrap stretch /opt/stretch-chroot
# mount -t proc none /opt/stretch-chroot/proc/
# mount -t sysfs none /opt/stretch-chroot/sys/
# mount -o bind /dev /opt/stretch-chroot/dev/
# mount -o bind /dev/pts /opt/stretch-chroot/dev/pts/
# chroot /opt/stretch-chroot
# apt-get update
# apt-get install flex bison make texinfo binutils gcc g++ gdb unzip git python2.7-dev pax libncurses5-dev
#
# Then chroot inside it and run this script:
#
# chroot /opt/stretch-chroot
# /path/to/build.rtems.MORA.sh
# Stop on any error
set -e
DATE=$(date +"%Y.%m.%d")
mkdir -p $HOME/rtems.build.logs
BUILD_LOG=$HOME/rtems.build.logs/${DATE}.log
[ -f ${BUILD_LOG} ] && {
echo "There's already a build log:"
echo " " ${BUILD_LOG}
echo Remove it to continue.
exit 1
}
# Record the output in $BUILD_LOG (see matching brace)
{
# Begin by checking out the RTEMS Source Builder
RSBPARENT=$HOME/development/rtems/src
mkdir -p $RSBPARENT
RSB=$RSBPARENT/rtems-source-builder-${DATE}
RTPREFIX=/opt/rtems-5.1-${DATE}
# rm -rf ${RTPREFIX}
[ ! -d $RSB ] && {
cd $RSBPARENT
git clone https://github.com/RTEMS/rtems-source-builder.git rtems-source-builder-${DATE}
}
cd $RSB
git checkout -f 703532cb04c6990fb21e97cb7347a16e9df11108
# Verify that we have all we need to build
source-builder/sb-check
cd rtems
# Your network firewall may or may not be an issue at this point:
# Many of the source tarballs needed by the RSB are fetched over
# PASV-enabled FTP servers.
#
# If your network is like the one in ESA/ESTEC and this is forbidden,