From b99031694a7ec75c7a96b97efb8530f0c99a5afa Mon Sep 17 00:00:00 2001 From: bernd Date: Sat, 6 Aug 2011 16:41:58 +0200 Subject: [PATCH 01/12] Disable memcpy/memmove optimazation in simulat0r, it collides with the efforts not to interfere with libc --- firmware/sysdefs.h | 2 ++ 1 file changed, 2 insertions(+) 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 From f2907a3db10e867397b20d98172386106c9e9436 Mon Sep 17 00:00:00 2001 From: bernd Date: Sat, 6 Aug 2011 16:44:01 +0200 Subject: [PATCH 02/12] Give a cp suggestion to fix .gitignore mismatches --- simulat0r/bin/update-bridge-files.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/simulat0r/bin/update-bridge-files.sh b/simulat0r/bin/update-bridge-files.sh index 76db0b4..c349c22 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 + echo " give this command a try if the following diff looks reasonable:" + echo " cp $i simulat0r/$i" diff -y $i simulat0r/$i fi done From 66d742fe8cd9111a8ad56c0b1df59141149a596e Mon Sep 17 00:00:00 2001 From: bernd Date: Sat, 6 Aug 2011 16:44:48 +0200 Subject: [PATCH 03/12] Fix warning --- simulat0r/firmware/applications/default.c | 1 + 1 file changed, 1 insertion(+) 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() { From ccb9a6a6c3cd2268652ffe9640f3fd22fd8ab562 Mon Sep 17 00:00:00 2001 From: bernd Date: Sat, 6 Aug 2011 16:45:25 +0200 Subject: [PATCH 04/12] Fix warning --- simulat0r/firmware/core/gpio/gpio.c | 1 + 1 file changed, 1 insertion(+) 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) { From 3308ced1c372203cf07c537f4f9363813855dfe9 Mon Sep 17 00:00:00 2001 From: bernd Date: Sat, 6 Aug 2011 16:50:25 +0200 Subject: [PATCH 05/12] =?UTF-8?q?Don=C2=B4t=20hide=20symbols=20that=20do?= =?UTF-8?q?=20not=20collide=20with=20libc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simulat0r/firmware/libc-unc0llide.h | 7 ------- 1 file changed, 7 deletions(-) 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 From 12b98a8bd64b6b8d47423c543b8eeb7cfcad542e Mon Sep 17 00:00:00 2001 From: bernd Date: Sat, 6 Aug 2011 16:51:37 +0200 Subject: [PATCH 06/12] Provide a dummy secrets file for simulat0r builds --- simulat0r/firmware/SECRETS | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 simulat0r/firmware/SECRETS 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 From b47978690d48463ba1f739e170c036034031fe9b Mon Sep 17 00:00:00 2001 From: bernd Date: Sat, 6 Aug 2011 16:52:48 +0200 Subject: [PATCH 07/12] Adjust simulat0r .gitignore files to match r0ket --- simulat0r/firmware/.gitignore | 1 + simulat0r/firmware/l0dable/.gitignore | 3 +++ 2 files changed, 4 insertions(+) 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/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 From 5c9d624a7bb8822fe003408c2256e5690d67a699 Mon Sep 17 00:00:00 2001 From: bernd Date: Sat, 6 Aug 2011 16:54:47 +0200 Subject: [PATCH 08/12] Fix warning --- firmware/l0dable/nick_life.c | 1 + 1 file changed, 1 insertion(+) diff --git a/firmware/l0dable/nick_life.c b/firmware/l0dable/nick_life.c index 818c232..49d4dce 100644 --- a/firmware/l0dable/nick_life.c +++ b/firmware/l0dable/nick_life.c @@ -256,6 +256,7 @@ static void reset_area() { } } +extern uint32_t getRandom(void); 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) { From c8ff3182c0524123f0cd9e65a978123cfa5f0769 Mon Sep 17 00:00:00 2001 From: bernd Date: Sat, 6 Aug 2011 16:58:44 +0200 Subject: [PATCH 09/12] Avoid fatal error code from pure informational diff command --- simulat0r/bin/update-bridge-files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simulat0r/bin/update-bridge-files.sh b/simulat0r/bin/update-bridge-files.sh index c349c22..441bc53 100755 --- a/simulat0r/bin/update-bridge-files.sh +++ b/simulat0r/bin/update-bridge-files.sh @@ -54,6 +54,6 @@ for i in `find firmware -type f -name .gitignore`; do echo WARNING: $i mismatches simulat0r/$i echo " give this command a try if the following diff looks reasonable:" echo " cp $i simulat0r/$i" - diff -y $i simulat0r/$i + diff -y $i simulat0r/$i || true fi done From 456ec10713532729fb13e3b880d4e8b33a0de72a Mon Sep 17 00:00:00 2001 From: roy rocket Date: Sat, 6 Aug 2011 18:59:37 +0200 Subject: [PATCH 10/12] Fixed declaration f00 --- firmware/l0dable/nick_life.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/firmware/l0dable/nick_life.c b/firmware/l0dable/nick_life.c index 49d4dce..4faed8f 100644 --- a/firmware/l0dable/nick_life.c +++ b/firmware/l0dable/nick_life.c @@ -256,7 +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) { From a06b1eac47110853a9952cd9f373a053d7b3a0d8 Mon Sep 17 00:00:00 2001 From: schneider Date: Sat, 6 Aug 2011 21:52:33 +0200 Subject: [PATCH 11/12] added modified crypt tool --- tools/crypto/generate-keys.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); From 2440982fb1802cf6647745b9433b66c0bb53960e Mon Sep 17 00:00:00 2001 From: schneider Date: Sat, 6 Aug 2011 21:52:45 +0200 Subject: [PATCH 12/12] more error handling in gang flash --- tools/bootloader/gangflash | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) 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")