updated contiki mote compiler tests to again reflect contiki-cooja-main.c and the updated ContikiMoteType

This commit is contained in:
Fredrik Osterlind 2012-03-09 14:58:23 +01:00
parent 97c7a55eea
commit b49d1892f2
2 changed files with 19 additions and 14 deletions

View File

@ -34,9 +34,12 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
/* This is a stripped version of platform/cooja/contiki-cooja-main.c, used by
* Cooja's Contiki Mote Configuration Wizard */
const struct simInterface *simInterfaces[] = {NULL}; const struct simInterface *simInterfaces[] = {NULL};
long ref_var; /* Placed somewhere in the BSS section */ long referenceVar; /* Placed somewhere in the BSS section */
/* Variables with known memory addresses */ /* Variables with known memory addresses */
int var1=1; int var1=1;
@ -60,8 +63,9 @@ Java_se_sics_cooja_corecomm_[CLASS_NAME]_getMemory(JNIEnv *env, jobject obj, jin
mem_arr, mem_arr,
0, 0,
(size_t) length, (size_t) length,
(jbyte *) (((long)rel_addr) + ref_var) (jbyte *) (((long)rel_addr) + referenceVar)
); );
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
@ -69,7 +73,7 @@ Java_se_sics_cooja_corecomm_[CLASS_NAME]_setMemory(JNIEnv *env, jobject obj, jin
{ {
jbyte *mem = (*env)->GetByteArrayElements(env, mem_arr, 0); jbyte *mem = (*env)->GetByteArrayElements(env, mem_arr, 0);
memcpy( memcpy(
(char*) (((long)rel_addr) + ref_var), (char*) (((long)rel_addr) + referenceVar),
mem, mem,
length); length);
(*env)->ReleaseByteArrayElements(env, mem_arr, mem, 0); (*env)->ReleaseByteArrayElements(env, mem_arr, mem, 0);
@ -85,5 +89,5 @@ Java_se_sics_cooja_corecomm_[CLASS_NAME]_tick(JNIEnv *env, jobject obj)
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_se_sics_cooja_corecomm_[CLASS_NAME]_setReferenceAddress(JNIEnv *env, jobject obj, jint addr) Java_se_sics_cooja_corecomm_[CLASS_NAME]_setReferenceAddress(JNIEnv *env, jobject obj, jint addr)
{ {
ref_var = (((long)&ref_var) - ((long)addr)); referenceVar = (((long)&referenceVar) - ((long)addr));
} }

View File

@ -50,7 +50,7 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.PrintStream; import java.io.PrintStream;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.Properties; import java.util.HashMap;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
@ -66,11 +66,12 @@ import javax.swing.JScrollPane;
import se.sics.cooja.CoreComm; import se.sics.cooja.CoreComm;
import se.sics.cooja.GUI; import se.sics.cooja.GUI;
import se.sics.cooja.SectionMoteMemory;
import se.sics.cooja.MoteType.MoteTypeCreationException; import se.sics.cooja.MoteType.MoteTypeCreationException;
import se.sics.cooja.SectionMoteMemory;
import se.sics.cooja.contikimote.ContikiMoteType; import se.sics.cooja.contikimote.ContikiMoteType;
/* TODO Test common section */ /* TODO Test common section */
/* TODO Test readonly section */
public class ConfigurationWizard extends JDialog { public class ConfigurationWizard extends JDialog {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -141,7 +142,7 @@ public class ConfigurationWizard extends JDialog {
private static File cLibraryFile; private static File cLibraryFile;
private static String javaLibraryName; private static String javaLibraryName;
private static CoreComm javaLibrary; private static CoreComm javaLibrary;
private static Properties addresses; private static HashMap<String, Integer> addresses;
private static int relDataSectionAddr; private static int relDataSectionAddr;
private static int dataSectionSize; private static int dataSectionSize;
private static int relBssSectionAddr; private static int relBssSectionAddr;
@ -195,7 +196,7 @@ public class ConfigurationWizard extends JDialog {
"Changes made in this wizard are reflected in menu Settings, External tools paths.\n" + "Changes made in this wizard are reflected in menu Settings, External tools paths.\n" +
"\n" + "\n" +
"NOTE: You do not need to complete this wizard for emulating motes, such as Sky motes.\n", "NOTE: You do not need to complete this wizard for emulating motes, such as Sky motes.\n",
"Configuration Wizard", "Contiki mote configuration wizard",
JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, options, options[0]); null, options, options[0]);
@ -756,7 +757,7 @@ public class ConfigurationWizard extends JDialog {
} }
testOutput.addMessage("### Parsing map file data for addresses"); testOutput.addMessage("### Parsing map file data for addresses");
addresses = new Properties(); addresses = new HashMap<String, Integer>();
boolean parseOK = ContikiMoteType.parseMapFileData(mapData, addresses); boolean parseOK = ContikiMoteType.parseMapFileData(mapData, addresses);
if (!parseOK) { if (!parseOK) {
testOutput.addMessage("### Error: Failed parsing map file data", MessageList.ERROR); testOutput.addMessage("### Error: Failed parsing map file data", MessageList.ERROR);
@ -836,7 +837,7 @@ public class ConfigurationWizard extends JDialog {
} }
testOutput.addMessage("### Parsing command output for addresses"); testOutput.addMessage("### Parsing command output for addresses");
addresses = new Properties(); addresses = new HashMap<String, Integer>();
boolean parseOK = ContikiMoteType.parseCommandData(commandData, addresses); boolean parseOK = ContikiMoteType.parseCommandData(commandData, addresses);
if (!parseOK) { if (!parseOK) {
testOutput.addMessage("### Error: Failed parsing command output", MessageList.ERROR); testOutput.addMessage("### Error: Failed parsing command output", MessageList.ERROR);
@ -930,11 +931,11 @@ public class ConfigurationWizard extends JDialog {
testOutput.addMessage("### Testing Contiki library memory replacement"); testOutput.addMessage("### Testing Contiki library memory replacement");
testOutput.addMessage("### Configuring Contiki using parsed reference address"); testOutput.addMessage("### Configuring Contiki using parsed reference address");
int relRefAddress = (Integer) addresses.get("ref_var"); if (!addresses.containsKey("referenceVar")) {
if (!addresses.containsKey("ref_var")) { testOutput.addMessage("Could not find address of referenceVar", MessageList.ERROR);
testOutput.addMessage("Could not find address of ref_var", MessageList.ERROR);
return false; return false;
} }
int relRefAddress = (Integer) addresses.get("referenceVar");
javaLibrary.setReferenceAddress(relRefAddress); javaLibrary.setReferenceAddress(relRefAddress);
testOutput.addMessage("### Creating data and BSS memory sections"); testOutput.addMessage("### Creating data and BSS memory sections");
@ -942,7 +943,7 @@ public class ConfigurationWizard extends JDialog {
byte[] initialBssSection = new byte[bssSectionSize]; byte[] initialBssSection = new byte[bssSectionSize];
javaLibrary.getMemory(relDataSectionAddr, dataSectionSize, initialDataSection); javaLibrary.getMemory(relDataSectionAddr, dataSectionSize, initialDataSection);
javaLibrary.getMemory(relBssSectionAddr, bssSectionSize, initialBssSection); javaLibrary.getMemory(relBssSectionAddr, bssSectionSize, initialBssSection);
SectionMoteMemory memory = new SectionMoteMemory(addresses); SectionMoteMemory memory = new SectionMoteMemory(addresses, 0);
memory.setMemorySegment(relDataSectionAddr, initialDataSection); memory.setMemorySegment(relDataSectionAddr, initialDataSection);
memory.setMemorySegment(relBssSectionAddr, initialBssSection); memory.setMemorySegment(relBssSectionAddr, initialBssSection);