From 03ad78c19050926c4d016534d44d703bbf3f1b2b Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Wed, 21 Aug 2013 00:51:00 +0200 Subject: [PATCH 1/4] Guess platform based on firmware filename suffix --- Makefile | 2 +- build.xml | 7 ++++++- se/sics/mspsim/Main.java | 20 +++++++++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 4891da8..6c4611c 100644 --- a/Makefile +++ b/Makefile @@ -128,7 +128,7 @@ help: @echo "Usage: make [all,compile,clean,run,runsky,runesb]" run: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.util.IHexReader $(ARGS) $(FIRMWAREFILE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.Main $(ARGS) $(FIRMWAREFILE) $(MAPFILE) runesb: compile $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.esb.ESBNode $(ARGS) $(ESBFIRMWARE) $(MAPFILE) diff --git a/build.xml b/build.xml index b50c524..ed932f9 100644 --- a/build.xml +++ b/build.xml @@ -94,7 +94,12 @@ - + + + + + + diff --git a/se/sics/mspsim/Main.java b/se/sics/mspsim/Main.java index f532245..adbfb4b 100644 --- a/se/sics/mspsim/Main.java +++ b/se/sics/mspsim/Main.java @@ -28,16 +28,12 @@ * * This file is part of MSPSim. * - * $Id$ - * * ----------------------------------------------------------------- * * Main * * Authors : Joakim Eriksson, Niclas Finne * Created : 6 nov 2008 - * Updated : $Date$ - * $Revision$ */ package se.sics.mspsim; @@ -95,7 +91,21 @@ public class Main { if (nodeType != null) { node = createNode(nodeType); } else { - platform = config.getProperty("platform", "sky"); + platform = config.getProperty("platform"); + if (platform == null) { + // Default platform + platform = "sky"; + + // Guess platform based on firmware filename suffix. + // TinyOS firmware files are often named 'main.exe'. + String[] a = config.getArguments(); + if (a.length > 0 && !"main.exe".equals(a[0])) { + int index = a[0].lastIndexOf('.'); + if (index > 0) { + platform = a[0].substring(index + 1); + } + } + } nodeType = getNodeTypeByPlatform(platform); node = createNode(nodeType); } From 34ac84b67b37545129c9ee16f54137281309fec9 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Mon, 19 Aug 2013 16:55:20 +0200 Subject: [PATCH 2/4] Added option '-' to separate options from arguments --- se/sics/mspsim/util/ArgumentManager.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/se/sics/mspsim/util/ArgumentManager.java b/se/sics/mspsim/util/ArgumentManager.java index 6623852..5de9524 100644 --- a/se/sics/mspsim/util/ArgumentManager.java +++ b/se/sics/mspsim/util/ArgumentManager.java @@ -76,6 +76,13 @@ public class ArgumentManager extends ConfigManager { ArrayList list = new ArrayList(); ArrayList config = new ArrayList(); for (int i = 0, n = args.length; i < n; i++) { + if ("-".equals(args[i])) { + // The rest should be considered arguments + for(++i; i < args.length; i++) { + list.add(args[i]); + } + break; + } if (args[i].startsWith("-")) { String param = args[i].substring(1); String value = ""; From bfc765a89565c375434419772b1ab955cce9cec2 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Mon, 19 Aug 2013 17:17:07 +0200 Subject: [PATCH 3/4] Made the map file argument an option. Added support for specifying commands as arguments when starting MSPSim. --- Makefile | 34 +++++++++++--------- build.xml | 10 ++++++ se/sics/mspsim/platform/GenericNode.java | 40 +++++++++++++++--------- 3 files changed, 55 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 6c4611c..427ffe5 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,10 @@ TYNDALLFIRMWARE = ${FIRMWAREFILE} EXP5438FIRMWARE = ${FIRMWAREFILE} endif +ifdef MAPFILE +MAPARGS := -map=$(MAPFILE) +endif + CPUTEST := tests/cputest.firmware TIMERTEST := tests/timertest.firmware @@ -107,49 +111,49 @@ $(JARFILE): $(OBJECTS) -@$(RM) JarManifest.txt %.esb: jar - java -jar $(JARFILE) -platform=esb $(ARGS) $@ + java -jar $(JARFILE) -platform=esb $@ $(ARGS) %.sky: jar - java -jar $(JARFILE) -platform=sky $(ARGS) $@ + java -jar $(JARFILE) -platform=sky $@ $(ARGS) %.z1: jar - java -jar $(JARFILE) -platform=z1 $(ARGS) $@ + java -jar $(JARFILE) -platform=z1 $@ $(ARGS) %.exp5438: jar - java -jar $(JARFILE) -platform=exp5438 $(ARGS) $@ + java -jar $(JARFILE) -platform=exp5438 $@ $(ARGS) %.tyndall: jar - java -jar $(JARFILE) -platform=tyndall $(ARGS) $@ + java -jar $(JARFILE) -platform=tyndall $@ $(ARGS) %.wismote: jar - java -jar $(JARFILE) -platform=wismote $(ARGS) $@ + java -jar $(JARFILE) -platform=wismote $@ $(ARGS) help: @echo "Usage: make [all,compile,clean,run,runsky,runesb]" run: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.Main $(ARGS) $(FIRMWAREFILE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.Main $(FIRMWAREFILE) $(MAPARGS) $(ARGS) runesb: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.esb.ESBNode $(ARGS) $(ESBFIRMWARE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.esb.ESBNode $(ESBFIRMWARE) $(MAPARGS) $(ARGS) runsky: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(ARGS) $(SKYFIRMWARE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(SKYFIRMWARE) $(MAPARGS) $(ARGS) runskyprof: compile - $(JAVA) -agentlib:yjpagent $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(ARGS) $(SKYFIRMWARE) $(MAPFILE) + $(JAVA) -agentlib:yjpagent $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(SKYFIRMWARE) $(MAPARGS) $(ARGS) runtelos: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.TelosNode $(ARGS) $(SKYFIRMWARE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.TelosNode $(SKYFIRMWARE) $(MAPARGS) $(ARGS) runz1: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.z1.Z1Node $(ARGS) $(Z1FIRMWARE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.z1.Z1Node $(Z1FIRMWARE) $(MAPARGS) $(ARGS) runtyndall: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.tyndall.TyndallNode $(ARGS) $(TYNDALLFIRMWARE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.tyndall.TyndallNode $(TYNDALLFIRMWARE) $(MAPARGS) $(ARGS) runwismote: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.wismote.WismoteNode $(ARGS) $(WISMOTEFIRMWARE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.wismote.WismoteNode $(WISMOTEFIRMWARE) $(MAPARGS) $(ARGS) runexp5438: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.ti.Exp5438Node $(ARGS) $(EXP5438FIRMWARE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.ti.Exp5438Node $(EXP5438FIRMWARE) $(MAPARGS) $(ARGS) test: cputest diff --git a/build.xml b/build.xml index ed932f9..c92bcb7 100644 --- a/build.xml +++ b/build.xml @@ -10,6 +10,7 @@ + @@ -48,6 +49,7 @@ + @@ -55,6 +57,7 @@ + @@ -63,6 +66,7 @@ + @@ -70,6 +74,7 @@ + @@ -77,6 +82,7 @@ + @@ -84,6 +90,7 @@ + @@ -91,6 +98,7 @@ + @@ -98,6 +106,7 @@ + @@ -109,6 +118,7 @@ + diff --git a/se/sics/mspsim/platform/GenericNode.java b/se/sics/mspsim/platform/GenericNode.java index f566b9a..1fbf72c 100644 --- a/se/sics/mspsim/platform/GenericNode.java +++ b/se/sics/mspsim/platform/GenericNode.java @@ -136,17 +136,21 @@ public abstract class GenericNode extends Chip implements Runnable { } } - int[] memory = cpu.memory; if (firmwareFile.endsWith("ihex")) { // IHEX Reading + int[] memory = cpu.memory; IHexReader reader = new IHexReader(); reader.readFile(memory, firmwareFile); } else { - loadFirmware(firmwareFile, memory); + loadFirmware(firmwareFile); } - if (args.length > 1) { - MapTable map = new MapTable(args[1]); + config.setProperty("firmwareFile", firmwareFile); + + String mapFile = config.getProperty("map"); + if (mapFile != null) { + MapTable map = new MapTable(mapFile); cpu.getDisAsm().setMap(map); + cpu.setMap(map); registry.registerComponent("mapTable", map); } @@ -159,18 +163,16 @@ public abstract class GenericNode extends Chip implements Runnable { registry.registerComponent("controlgui", control); registry.registerComponent("stackchart", new StackUI(cpu)); HighlightSourceViewer sourceViewer = new HighlightSourceViewer(); - if (firmwareFile != null) { - // Add the firmware location to the search path - File fp = new File(firmwareFile).getParentFile(); - if (fp != null) { + // Add the firmware location to the search path + File fp = new File(firmwareFile).getParentFile(); + if (fp != null) { try { - // Get absolute path - fp = fp.getCanonicalFile(); + // Get absolute path + fp = fp.getCanonicalFile(); } catch (Exception e) { - // Ignore + // Ignore } sourceViewer.addSearchPath(fp); - } } control.setSourceViewer(sourceViewer); } @@ -179,7 +181,7 @@ public abstract class GenericNode extends Chip implements Runnable { if (script != null) { File fp = new File(script); if (fp.canRead()) { - CommandHandler ch = (CommandHandler) registry.getComponent("commandHandler"); + CommandHandler ch = registry.getComponent(CommandHandler.class, "commandHandler"); script = script.replace('\\', '/'); System.out.println("Autoloading script: " + script); config.setProperty("autoloadScript", script); @@ -188,7 +190,17 @@ public abstract class GenericNode extends Chip implements Runnable { } } } - config.setProperty("firmwareFile", firmwareFile); + + if (args.length > 1) { + // Run the following arguments as commands + CommandHandler ch = registry.getComponent(CommandHandler.class, "commandHandler"); + if (ch != null) { + for (int i = 1; i < args.length; i++) { + System.out.println("calling '" + args[i] + "'"); + ch.lineRead(args[i]); + } + } + } System.out.println("-----------------------------------------------"); System.out.println("MSPSim " + MSP430Constants.VERSION + " starting firmware: " + firmwareFile); System.out.println("-----------------------------------------------"); From 72ff6f54f2b2010bafaa884cf367b4d4dce5ddbf Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Thu, 22 Aug 2013 23:37:38 +0200 Subject: [PATCH 4/4] Reenabled autostart of emulation --- scripts/autorun.sc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/autorun.sc b/scripts/autorun.sc index 282e6db..4d7e61a 100644 --- a/scripts/autorun.sc +++ b/scripts/autorun.sc @@ -13,5 +13,4 @@ service -f nodegui start service -f serialgui start #service -f stackchart start #rflistener output CC2420 >> rfdata.txt -stop -#start +start