]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
incorporate a patch from Frederik Hermans -- looks like the 2.4 kernel can not
authorandreaskoepke <andreaskoepke>
Tue, 6 May 2008 14:19:36 +0000 (14:19 +0000)
committerandreaskoepke <andreaskoepke>
Tue, 6 May 2008 14:19:36 +0000 (14:19 +0000)
send all 260 bytes of a normal msp430 program chunk at once, so now you can
choose a proper chunk size on the command line.

tools/platforms/msp430/cppbsl/src/Bsl.cc
tools/platforms/msp430/cppbsl/src/Bsl.h
tools/platforms/msp430/cppbsl/src/Parameters.cc
tools/platforms/msp430/cppbsl/src/Parameters.h
tools/platforms/msp430/cppbsl/src/cppbsl.cc

index d895b20e267b605f001c112d79b367ed3f422fae..e35c4dec31f909536221804db394370304f8e65a 100644 (file)
@@ -152,7 +152,7 @@ int Bsl::writeData(int *err, const uint16_t addr, const uint8_t* data, const uin
     uint16_t adr;
     for(int i=0; i<len; i+=l) {
         l=len-i;
-        if(l>250) l=250;
+        if(l>CHUNKSIZE) l=CHUNKSIZE;
         adr=addr+i;
         r = writeBlock(err, adr, &data[i], l);
         if(r == -1) {
index a7cc0b788acd60ae81d544f5329141d172318e31..7561ca195f5adb1e391dd0ab3f9b180100c6141a 100644 (file)
@@ -46,6 +46,7 @@ class Bsl {
 protected:
     BaseSerial *s;
     const char *image;
+    const int CHUNKSIZE;
     
     enum commands_t {
         MASS_ERASE = 0x18,
@@ -81,7 +82,7 @@ protected:
     int highSpeed(int *err);
     
 public:
-    Bsl(BaseSerial* ser, const char *img) : s(ser), image(img) {
+    Bsl(BaseSerial* ser, const char *img, int cs=250) : s(ser), image(img), CHUNKSIZE(cs) {
     };
 
     ~Bsl() {
index 578035c3e8ed5830e22a89ca2ce92431910839fc..56d7cb1ee64699f5e5f0558709fd38c654dc4366 100644 (file)
@@ -44,7 +44,8 @@ Parameters::Parameters(int argc, char **argv) {
     action = NONE;
     image = 0;
     telosb = false;
-
+    chunksize = 250;
+    
     poptOption optionsTable[] = {
         {"debug",'D', 0, 0, 'd', "print many statements on progress"},
         {"f1x",'1', 0, 0, '1', "Specify CPU family, in case autodetect fails"},
@@ -55,6 +56,8 @@ Parameters::Parameters(int argc, char **argv) {
         {"intelhex",'I', 0, 0, 'I', "force fileformat to be  IntelHex"},
         {"erase",'e', 0, 0, 'e', "erase device"},
         {"reset",'r', 0, 0, 'r', "reset device"},
+        {"send-chunk-size",'s', POPT_ARG_INT | POPT_ARGFLAG_SHOW_DEFAULT,
+         &chunksize, 0, "program msp430 using chunks of this size", ""},
         {"program",'p', POPT_ARG_STRING, &image, 0,
          "Program file", ""},
         {"comport",'c', POPT_ARG_STRING, &device, 0,
@@ -120,6 +123,16 @@ Parameters::Parameters(int argc, char **argv) {
     else if(action == FLASH) {
         exit(1);
     }
+    // force sane chunk size
+    if(chunksize < 150) {
+        chunksize = 150;
+    }
+    else if(chunksize > 250) {
+        chunksize = 250;
+    }
+    // must be even!
+    chunksize /= 2; 
+    chunksize *= 2;
     poptFreeContext(optCon);
 };
 
index c91525bf2ea4ff1832bd409b52ed2fa0af751006..c5f770fb667242f67c0d8faa68be3e839c6a2994 100644 (file)
@@ -61,6 +61,7 @@ public:
     bool telosb;
     
     actions_t action;
+    int chunksize;
     
 public:
     Parameters(int argc, char **argv);
index 21d2213f33b39e6836a3153422480e10a20c90af..353478286e0020b45710a532b0fd303ea668e125 100644 (file)
@@ -71,7 +71,7 @@ int main(int argc, char *argv[]) {
     else {
         bs = new BaseSerial(oldterm, readFD, writeFD, parameters->invertTest, parameters->invertReset);
     }
-    bsl = new Bsl(bs, parameters->img.c_str());
+    bsl = new Bsl(bs, parameters->img.c_str(), parameters->chunksize);
     switch(parameters->action) {
         case Parameters::ERASE:
             r = bsl->erase(&err);
@@ -104,5 +104,5 @@ int main(int argc, char *argv[]) {
     bs->disconnect(&err);
     delete bs;
     delete parameters;
-    return 0;
+    return (r != 0);
 }