Merge pull request #57 from nfi/tests

CI: Run MSPSim tests
This commit is contained in:
Joakim Eriksson 2022-05-18 16:40:20 +02:00 committed by GitHub
commit 3d5140730e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 103 additions and 276 deletions

205
Makefile
View File

@ -1,205 +0,0 @@
###############################################################
# Makefile for mspsim
#
# Needed stuff in the PATH:
# java, javac (JDK 11 or newer)
#
# Under MS-DOS/Windows
# A GNU compatible Make (for example Cygwin's)
###############################################################
###############################################################
# Settings
###############################################################
CC=javac
JAVA=java
JAR=jar
RM=rm -f
###############################################################
# System dependent
###############################################################
ifndef HOST_OS
ifeq ($(OS),Windows_NT)
HOST_OS := Windows
else
HOST_OS := $(shell uname)
endif
endif
ifeq ($(HOST_OS),Windows)
# These setting are for Windows
SEPARATOR=;
else
# This settings are for UNIX
SEPARATOR=:
endif
###############################################################
# Arguments
###############################################################
EMPTY :=
SPACE := ${EMPTY} ${EMPTY}
LIBS := ${wildcard lib/*.jar}
BUILD := build
CLASSPATH=${subst ${SPACE},${SEPARATOR},$(BUILD)/ ${LIBS}}
CCARGS=-deprecation -Xlint:unchecked -source 11 -target 11 -classpath ".${SEPARATOR}${CLASSPATH}" -d $(BUILD)
JAVAARGS=-classpath "${CLASSPATH}"
###############################################################
# SERVER OBJECTS
###############################################################
ifndef FIRMWAREFILE
ESBFIRMWARE = firmware/esb/sensor-demo.esb
SKYFIRMWARE = firmware/sky/blink.sky
Z1FIRMWARE = firmware/z1/blink.z1
WISMOTEFIRMWARE = firmware/wismote/blink.wismote
TYNDALLFIRMWARE = firmware/tyndall/blink.tyndall
EXP5438FIRMWARE = firmware/exp5438/testcase-bits.exp5438
else
ESBFIRMWARE = ${FIRMWAREFILE}
SKYFIRMWARE = ${FIRMWAREFILE}
Z1FIRMWARE = ${FIRMWAREFILE}
WISMOTEFIRMWARE = ${FIRMWAREFILE}
TYNDALLFIRMWARE = ${FIRMWAREFILE}
EXP5438FIRMWARE = ${FIRMWAREFILE}
endif
ifdef MAPFILE
MAPARGS := -map=$(MAPFILE)
endif
CPUTEST := tests/cputest.firmware
TIMERTEST := tests/timertest.firmware
SCRIPTS := ${addprefix scripts/,autorun.sc duty.sc}
BINARY := README.txt license.txt CHANGE_LOG.txt images/*.jpg images/*.png firmware/*/*.firmware ${SCRIPTS}
PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli config debug platform ${addprefix platform/,esb sky jcreate sentillausb z1 tyndall ti wismote} plugin profiler emulink net ui util extutil/highlight extutil/jfreechart}
SOURCES := ${wildcard *.java $(addsuffix /*.java,$(PACKAGES))}
OBJECTS := ${addprefix $(BUILD)/,$(SOURCES:.java=.class)}
JARFILE := mspsim.jar
###############################################################
# MAKE
###############################################################
.PHONY: all compile jar help run runesb runsky test cputest $(CPUTEST) mtest
all: compile
compile: $(OBJECTS)
jar: $(JARFILE)
$(JARFILE): $(OBJECTS)
-@$(RM) JarManifest.txt
@echo >>JarManifest.txt "Manifest-Version: 1.0"
@echo >>JarManifest.txt "Sealed: true"
@echo >>JarManifest.txt "Main-Class: se.sics.mspsim.Main"
@echo >>JarManifest.txt "Class-path: ${LIBS}"
$(JAR) cfm $(JARFILE) JarManifest.txt images/*.jpg -C $(BUILD) .
-@$(RM) JarManifest.txt
%.esb: jar
java -jar $(JARFILE) -platform=esb $@ $(ARGS)
%.sky: jar
java -jar $(JARFILE) -platform=sky $@ $(ARGS)
%.z1: jar
java -jar $(JARFILE) -platform=z1 $@ $(ARGS)
%.exp5438: jar
java -jar $(JARFILE) -platform=exp5438 $@ $(ARGS)
%.tyndall: jar
java -jar $(JARFILE) -platform=tyndall $@ $(ARGS)
%.wismote: jar
java -jar $(JARFILE) -platform=wismote $@ $(ARGS)
help:
@echo "Usage: make [all,compile,clean,run,runsky,runesb]"
run: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.Main $(FIRMWAREFILE) $(MAPARGS) $(ARGS)
runesb: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.esb.ESBNode $(ESBFIRMWARE) $(MAPARGS) $(ARGS)
runsky: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(SKYFIRMWARE) $(MAPARGS) $(ARGS)
runskyprof: compile
$(JAVA) -agentlib:yjpagent $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(SKYFIRMWARE) $(MAPARGS) $(ARGS)
runtelos: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.TelosNode $(SKYFIRMWARE) $(MAPARGS) $(ARGS)
runz1: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.z1.Z1Node $(Z1FIRMWARE) $(MAPARGS) $(ARGS)
runtyndall: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.tyndall.TyndallNode $(TYNDALLFIRMWARE) $(MAPARGS) $(ARGS)
runwismote: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.wismote.WismoteNode $(WISMOTEFIRMWARE) $(MAPARGS) $(ARGS)
runexp5438: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.ti.Exp5438Node $(EXP5438FIRMWARE) $(MAPARGS) $(ARGS)
test: cputest
cputest: $(CPUTEST)
$(JAVA) $(JAVAARGS) se.sics.mspsim.util.Test $(CPUTEST)
timertest: $(TIMERTEST)
$(JAVA) $(JAVAARGS) se.sics.mspsim.util.Test $(TIMERTEST)
$(CPUTEST):
(cd tests && $(MAKE))
$(TIMERTEST):
(cd tests && $(MAKE))
mtest: compile $(CPUTEST)
@-$(RM) mini-test_cpu.txt
$(JAVA) $(JAVAARGS) se.sics.util.Test -debug $(CPUTEST) >mini-test_cpu.txt
###############################################################
# ARCHIVE GENERATION
###############################################################
source:
zip -9 mspsim-source-`date '+%F'`.zip Makefile $(BINARY) $(addsuffix /*.java,$(PACKAGES)) tests/Makefile tests/*.c tests/*.h lib/*.*
###############################################################
# CLASS COMPILATION
###############################################################
$(BUILD):
@mkdir $@
$(BUILD)/%.class : %.java $(BUILD)
$(CC) $(CCARGS) $<
###############################################################
# CLEAN (untrusted, use with great care!!!)
###############################################################
.PHONY: clean
clean:
-$(RM) -r $(BUILD)
distclean: clean
-$(RM) -f $(JARFILE)

View File

@ -1,40 +1,39 @@
* MSPSim version 0.9x
### MSPSim version 0.9x
MSPSim is a Java-based instruction level emulator of the MSP430 series
microprocessor and emulation of some sensor networking
platforms. Supports loading of IHEX and ELF firmware files, and has
some tools for monitoring stack, setting breakpoints, and profiling.
* System requirements
### System requirements
You need a recent Java to run MSPSim. Java SE 1.7 or newer is recommended.
The current version of MSPSim also requires make or ant for compiling.
You need a recent Java to run MSPSim. Java 11 or newer is recommended.
The current version of MSPSim also requires ant for compiling.
* Building MSPSim
### Building MSPSim
You will build MSPSim by typing
>make
> ant
* Running examples
### Running examples
Run the default example on the ESB node emulator by typing:
>make runesb
> ant runesb
(here you can pass the PIR with the mouse and click on the
user button to get reaction from the example application).
Run the default example on the Sky node emulator by typing:
>make runsky
> ant runsky
(this is a leds-blinker only and does not react to any mouse
movements or button clicks).
### Main Features
* Main Features
- Instruction level emulation of MSP430 microprocessor
- Supports loading of ELF and IHEX files
- Easy to add external components that emulates external HW
@ -55,8 +54,9 @@ Run the default example on the Sky node emulator by typing:
- Basic A/D subsystem (not complete)
- Watchdog
* Limitations of the emulation (some of them) on version 0.9x
- currently the emulator runs as if it can use all memory as RAM
### Limitations of the emulation (some of them) on version 0.9x
- Currently, the emulator runs as if it can use all memory as RAM
(e.g. flash writes, etc not supported)
- no DMA implementation
- timer system not 100% emulated
- No DMA implementation
- Timer system not 100% emulated

View File

@ -102,6 +102,30 @@
</java>
</target>
<target name="runwismote" depends="jar" description="run MSPSim with platform Wismote">
<property name="FIRMWAREFILE" value="firmware/wismote/blink.wismote"/>
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.platform.wismote.WismoteNode">
<arg value="${FIRMWAREFILE}"/>
<arg line="${ARGS}"/>
</java>
</target>
<target name="runtyndall" depends="jar" description="run MSPSim with platform Tyndall">
<property name="FIRMWAREFILE" value="firmware/tyndall/blink.tyndall"/>
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.platform.tyndall.TyndallNode">
<arg value="${FIRMWAREFILE}"/>
<arg line="${ARGS}"/>
</java>
</target>
<target name="runexp5438" depends="jar" description="run MSPSim with platform exp5438">
<property name="FIRMWAREFILE" value="firmware/exp5438/tesetcase-bits.exp5438"/>
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.platform.ti.Exp5438">
<arg value="${FIRMWAREFILE}"/>
<arg line="${ARGS}"/>
</java>
</target>
<target name="run" depends="jar" description="run MSPSim">
<property name="FIRMWAREFILE" value="firmware/sky/blink.sky"/>
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.Main">
@ -110,19 +134,25 @@
</java>
</target>
<target name="cputest" depends="jar" description="run MSPSim CPU test">
<property name="FIRMWAREFILE" value="tests/cputest.sky"/>
<available file="${FIRMWAREFILE}" type="file" property="cputest.firmware"/>
<fail message="Please compile the cputest firmware first." unless="cputest.firmware"/>
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.util.Test">
<arg value="${FIRMWAREFILE}"/>
<arg line="${ARGS}"/>
<target name="test-cpu" depends="jar" description="run MSPSim CPU test">
<java fork="true" classpath="${jarfile}"
classname="se.sics.mspsim.util.Test"
failonerror="true"
timeout="10000">
<arg value="firmware/sky/cputest.sky"/>
</java>
</target>
<target name="test" depends="jar"/>
<target name="test-timer" depends="jar" description="run MSPSim Timer test">
<java fork="true" classpath="${jarfile}"
classname="se.sics.mspsim.util.Test"
failonerror="true"
timeout="10000">
<arg value="firmware/sky/timertest.sky"/>
</java>
</target>
<target name="test" depends="jar, test-cpu, test-timer"/>
<target name="clean" description="clean up" >
<delete dir="${build}"/>

BIN
firmware/sky/cputest.sky Normal file

Binary file not shown.

BIN
firmware/sky/timertest.sky Normal file

Binary file not shown.

View File

@ -67,7 +67,8 @@ public class Test implements USARTListener {
lineBuffer.setLength(0);
System.out.println("#|" + line);
if (line.startsWith("FAIL:")) {
System.exit(0);
System.err.println("Tests failed!");
System.exit(1);
} else if (line.startsWith("EXIT")) {
System.out.println("Tests succeded!");
System.exit(0);

View File

@ -1,17 +1,7 @@
### Check if we are running under Windows
ifndef WINDIR
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif
.SUFFIXES:
#MCU=msp430x149
MCU=msp430x1611
#MCU=msp430f149
MCU=msp430f1611
### Compiler definitions
CC = msp430-gcc
@ -21,8 +11,7 @@ AR = msp430-ar
OBJCOPY = msp430-objcopy
STRIP = msp430-strip
BSL = msp430-bsl
CFLAGSNO = -I. -DWITH_ASCII \
-Wall -mmcu=$(MCU) -g
CFLAGSNO = -I. -Wall -mmcu=$(MCU) -g
CFLAGS += $(CFLAGSNO) -Os
SOURCES := msp430setup.c
@ -33,7 +22,7 @@ OBJECTS := $(SOURCES:.c=.o)
all: cputest.firmware timertest.firmware
%.firmware: %.co $(OBJECTS)
%.firmware: %.o $(OBJECTS)
$(CC) -mmcu=$(MCU) -Wl,-Map=$(@:.firmware=.map) $(CFLAGS) -o $@ $^
%.ihex: %.firmware
@ -42,11 +31,8 @@ all: cputest.firmware timertest.firmware
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.co: %.c
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
%.u: %.ihex
msp430-jtag -eI $^
clean:
rm -f *~ *.lst *.map *.co *.o *.ihex *.firmware
rm -f *~ *.lst *.map *.o *.ihex *.firmware

View File

@ -79,13 +79,14 @@ static int caseID = 0;
/*---------------------------------------------------------------------------*/
static int pos = 0;
static unsigned int times[10];
interrupt(TIMERB1_VECTOR) timerb1 (void) {
if (TBIV == 2) {
if (pos < 10) {
times[pos] = TBR;
pos++;
TBCCR1 = TBCCR1 + 100;
}
interrupt(TIMERB1_VECTOR) timerb1 (void)
{
if(TBIV == 2) {
if(pos < 10) {
times[pos] = TBR;
pos++;
TBCCR1 = TBCCR1 + 100;
}
}
}
/*---------------------------------------------------------------------------*/
@ -259,13 +260,13 @@ static void testBitFields() {
invert.green ^= 1;
assertTrue(invert.green == 0);
assertTrue(pelle == 0x4711);
}
/*--------------------------------------------------------------------------*/
static int flag;
interrupt(UART0TX_VECTOR)
usart_tx_test0(void)
interrupt(UART0TX_VECTOR) usart_tx_test0 (void)
{
printf("*IRQ: Flags:%d %d\n", IFG1, UTCTL0);
flag++;
@ -352,7 +353,7 @@ uint16_t test_calib_busywait_delta( int calib )
int8_t aclk_count = 2;
uint16_t dco_prev = 0;
uint16_t dco_curr = 0;
set_dco_calib( calib );
while( aclk_count-- > 0 )
@ -391,18 +392,18 @@ void busyCalibrateDco()
for( calib=0,step=0x800; step!=0; step>>=1 )
{
// if the step is not past the target, commit it
printf(" step: %d\n", step);
if((tmp = test_calib_busywait_delta(calib|step)) <= TARGET_DCO_DELTA )
printf(" step: %d\n", step);
if((tmp = test_calib_busywait_delta(calib|step)) <= TARGET_DCO_DELTA )
{
calib |= step;
printf(" committed: tmp = %d\n", tmp);
}
}
// if DCOx is 7 (0x0e0 in calib), then the 5-bit MODx is not useable, set it to 0
if( (calib & 0x0e0) == 0x0e0 )
calib &= ~0x01f;
set_dco_calib( calib );
}
@ -429,5 +430,9 @@ main(void)
busyCalibrateDco();
/* printf("PROFILE\n"); */
printf("EXIT\n");
return 0;
/* Short delay to allow serial output to finish */
__delay_cycles(2000);
return 0;
}

View File

@ -76,17 +76,17 @@ static int caseID = 0;
#define RTIMER_ARCH_SECOND 4096
#define CLOCK_SECOND 128
#define CLOCK_CONF_SECOND CLOCK_SECOND
#define INTERVAL (RTIMER_ARCH_SECOND / CLOCK_SECOND)
/*---------------------------------------------------------------------------*/
static int pos = 0;
static unsigned int ticka0 = 0;
static unsigned int count = 0;
static unsigned int seconds = 0;
static unsigned int last_tar = 0;
static volatile unsigned int ticka0 = 0;
static volatile unsigned int count = 0;
static volatile unsigned int seconds = 0;
static volatile unsigned int last_tar = 0;
interrupt(TIMERA1_VECTOR) timera1 (void) {
interrupt(TIMERA1_VECTOR) timera1 (void)
{
if(TAIV == 2) {
eint();
do {
@ -99,7 +99,7 @@ interrupt(TIMERA1_VECTOR) timera1 (void) {
}
}
if(count % CLOCK_CONF_SECOND == 0) {
if(count % CLOCK_SECOND == 0) {
++seconds;
}
} while((TACCR1 - TAR) > INTERVAL);
@ -109,7 +109,8 @@ interrupt(TIMERA1_VECTOR) timera1 (void) {
/*---------------------------------------------------------------------------*/
interrupt(TIMERA0_VECTOR) timera0 (void) {
interrupt(TIMERA0_VECTOR) timera0 (void)
{
ticka0++;
TACCR0 += 4;
}
@ -132,6 +133,10 @@ static void testCase(char *description) {
}
static void testTimers() {
unsigned int counter = 0;
testCase("Timers");
dint();
/* Timer A1 */
/* Select ACLK 32768Hz clock, divide by 8 */
@ -154,10 +159,11 @@ static void testTimers() {
eint();
while (ticka0 < 200) {
printf("Timer a0:%d \n", ticka0);
for(counter = 0; ticka0 < 100 && counter < 2000; counter++) {
printf("Timer a0:%d\n", ticka0);
}
assertTrue(ticka0 >= 100);
assertTrue(count > 10);
}
int
@ -170,5 +176,9 @@ main(void)
testTimers();
printf("EXIT\n");
/* Short delay to allow serial output to finish */
__delay_cycles(2000);
return 0;
}