diff --git a/firmware/l0dable/nick_life.c b/firmware/l0dable/nick_life.c index 818c232..4faed8f 100644 --- a/firmware/l0dable/nick_life.c +++ b/firmware/l0dable/nick_life.c @@ -256,6 +256,10 @@ static void reset_area() { } } +#ifdef SIMULATOR +extern uint32_t getRandom(void); +#endif + static void random_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1,uchar value) { for(uchar x=x0; x<=x1; ++x) { for(uchar y=y0; y<=y1; ++y) { diff --git a/firmware/sysdefs.h b/firmware/sysdefs.h index 7c2d3d5..10ebfb4 100644 --- a/firmware/sysdefs.h +++ b/firmware/sysdefs.h @@ -62,7 +62,9 @@ typedef unsigned char byte_t; #endif // Save some space +#ifndef SIMULATOR #define memcpy memmove +#endif #endif diff --git a/simulat0r/bin/update-bridge-files.sh b/simulat0r/bin/update-bridge-files.sh index 76db0b4..441bc53 100755 --- a/simulat0r/bin/update-bridge-files.sh +++ b/simulat0r/bin/update-bridge-files.sh @@ -52,6 +52,8 @@ for i in `find firmware -type f -name .gitignore`; do echo OK $i and simulat0r/$i are the same else echo WARNING: $i mismatches simulat0r/$i - diff -y $i simulat0r/$i + echo " give this command a try if the following diff looks reasonable:" + echo " cp $i simulat0r/$i" + diff -y $i simulat0r/$i || true fi done diff --git a/simulat0r/firmware/.gitignore b/simulat0r/firmware/.gitignore index 5323c83..d2d2dd6 100644 --- a/simulat0r/firmware/.gitignore +++ b/simulat0r/firmware/.gitignore @@ -6,3 +6,4 @@ lcd/allfonts.h Makefile.dep table.c table.h +SECRETS.release diff --git a/simulat0r/firmware/SECRETS b/simulat0r/firmware/SECRETS new file mode 100644 index 0000000..8f35c3d --- /dev/null +++ b/simulat0r/firmware/SECRETS @@ -0,0 +1,17 @@ +#ifndef _SECRETS_ +#define _SECRETS_ + +// these keys are not the official keys +// they´re just here to make the simulat0r build + +static uint32_t const meshkey[4] = { + 0x01010101, 0x02020202, 0x03030303, 0x04040404 +}; +static const uint32_t openbeaconkey[4] = { + 0x05050505, 0x06060606, 0x07070707, 0x08080808 +}; +static uint32_t const remotekey[4] = { + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff +}; + +#endif diff --git a/simulat0r/firmware/applications/default.c b/simulat0r/firmware/applications/default.c index 9c699bc..d58e949 100644 --- a/simulat0r/firmware/applications/default.c +++ b/simulat0r/firmware/applications/default.c @@ -6,6 +6,7 @@ #undef main_default int lcdInitConfig() { + return 0; } void main_default() { diff --git a/simulat0r/firmware/core/gpio/gpio.c b/simulat0r/firmware/core/gpio/gpio.c index 2c8d214..990bc12 100644 --- a/simulat0r/firmware/core/gpio/gpio.c +++ b/simulat0r/firmware/core/gpio/gpio.c @@ -53,6 +53,7 @@ void gpioIntDisable (uint32_t portNum, uint32_t bitPos) { uint32_t gpioIntStatus (uint32_t portNum, uint32_t bitPos) { printf("uint32_t gpioIntStatus (uint32_t portNum, uint32_t bitPos)\n"); + return 0; } void gpioIntClear (uint32_t portNum, uint32_t bitPos) { diff --git a/simulat0r/firmware/l0dable/.gitignore b/simulat0r/firmware/l0dable/.gitignore index ca79c34..47ffa2a 100644 --- a/simulat0r/firmware/l0dable/.gitignore +++ b/simulat0r/firmware/l0dable/.gitignore @@ -2,3 +2,6 @@ *.bin usetable.h loadable.ld +*.nik +*.c0d +*.int diff --git a/simulat0r/firmware/libc-unc0llide.h b/simulat0r/firmware/libc-unc0llide.h index 0ca4b6a..690dabe 100644 --- a/simulat0r/firmware/libc-unc0llide.h +++ b/simulat0r/firmware/libc-unc0llide.h @@ -12,12 +12,6 @@ The following symbols were found to be defined within glibc. Use different names within simulat0r to keep the firmware and simulat0r-host universes collision-free. */ #define buf __r0ket_buf -#define deselect __r0ket_deselect -#define ECIES_embedded_public_key_validation __r0ket_ECIES_embedded_public_key_validation -#define ECIES_generate_key_pair __r0ket_ECIES_generate_key_pair -#define ECIES_public_key_validation __r0ket_ECIES_public_key_validation -#define f_sync __r0ket_f_sync -#define getInput __r0ket_getInput #define isalnum __r0ket_isalnum #define isalpha __r0ket_isalpha #define isascii __r0ket_isascii @@ -55,4 +49,3 @@ Use different names within simulat0r to keep the firmware and simulat0r-host uni #define vprintf __r0ket_vprintf #define vsnprintf __r0ket_vsnprintf #define vsprintf __r0ket_vsprintf -#define XTEA_init_key __r0ket_XTEA_init_key diff --git a/tools/bootloader/gangflash b/tools/bootloader/gangflash index 3866e90..bff65a4 100755 --- a/tools/bootloader/gangflash +++ b/tools/bootloader/gangflash @@ -49,10 +49,11 @@ def copy(count, target, dir): while len(flashed) != count: filelist = [] - try: - filelist = os.listdir(target) - except: - pass + while len(filelist) != count: + try: + filelist = os.listdir(target) + except: + pass oldflashed = flashed flashed = [] for x in oldflashed: @@ -67,8 +68,13 @@ def copy(count, target, dir): time.sleep(0.3) print "mkdir", "/tmp/r0ket/"+device os.mkdir("/tmp/r0ket/"+device) - print "mount "+target+device+" "+"/tmp/r0ket/"+device - os.system("mount -t vfat "+target+device+" "+"/tmp/r0ket/"+device) + print "mount -t vfat "+target+device+" "+"/tmp/r0ket/"+device + x = 1 + while x != 0: + x = os.system("mount -t vfat "+target+device+" "+"/tmp/r0ket/"+device) + print "returned", x + if x != 0: + time.sleep(5) os.system("../tools/crypto/generate-keys") #for file in filestocopy: print "cp "+dir+"/* /tmp/r0ket/"+device @@ -87,6 +93,7 @@ def copy(count, target, dir): os.system("touch /tmp/r0ket/"+mount+"/flashed.cfg") print "sync" os.system("sync") + time.sleep(1) print "umount /tmp/r0ket/"+mount os.system("umount /tmp/r0ket/"+mount) print "rm /tmp/r0ket/"+mount @@ -95,12 +102,14 @@ def copy(count, target, dir): print "rm /tmp/r0ket" os.rmdir("/tmp/r0ket") - +os.system("umount /tmp/r0ket/*") +os.system("rm /tmp/r0ket -rf") +os.system("rm /dev/r0ketflash/*") while True: raw_input("Flashed firmware.\nNow cycle power and press enter.") - flash(8, "/dev/lpcflash/", "initial.bin") + flash(9, "/dev/lpcflash/", "initial.bin") raw_input("Flashed bootstrap firmware.\nNow cycle power and press enter.") - copy(8, "/dev/r0ketflash/","files") - flash(8, "/dev/lpcflash/", "final.bin") + copy(9, "/dev/r0ketflash/","files") + flash(9, "/dev/lpcflash/", "final.bin") diff --git a/tools/crypto/generate-keys.c b/tools/crypto/generate-keys.c index 82eea62..602bafa 100644 --- a/tools/crypto/generate-keys.c +++ b/tools/crypto/generate-keys.c @@ -392,7 +392,7 @@ void ECIES_generate_key_pair(void) /* generate a public/private key pair */ //printf("Here is your new public/private key pair:\n"); bitstr_to_hex(buf, x); //printf("Public key: %s:", bufptr); - FILE* f = fopen("pubx.key", "w"); + FILE* f = fopen("files/pubx.key", "w"); if( f == NULL ){ printf("error opening pubx.key\n"); while(1); @@ -402,7 +402,7 @@ void ECIES_generate_key_pair(void) /* generate a public/private key pair */ bitstr_to_hex(buf, y); //printf("%s\n", bufptr); - f = fopen("puby.key", "w"); + f = fopen("files/puby.key", "w"); if( f == NULL ){ printf("error opening puby.key\n"); while(1); @@ -413,7 +413,7 @@ void ECIES_generate_key_pair(void) /* generate a public/private key pair */ bitstr_to_hex(buf, k); //printf("Private key: %s\n", bufptr); - f = fopen("priv.key", "w"); + f = fopen("files/priv.key", "w"); if( f == NULL ){ printf("error opening priv.key\n"); while(1);