allocate secind serial to AHBO
authorJim Morris <morris@wolfman.com>
Thu, 9 Oct 2014 06:40:21 +0000 (23:40 -0700)
committerJim Morris <morris@wolfman.com>
Thu, 9 Oct 2014 06:40:21 +0000 (23:40 -0700)
disable DFU by default

src/main.cpp

index bf75f26..136d8ba 100644 (file)
@@ -55,6 +55,7 @@
 #define second_usb_serial_enable_checksum  CHECKSUM("second_usb_serial_enable")
 #define disable_msd_checksum  CHECKSUM("msd_disable")
 #define disable_leds_checksum  CHECKSUM("leds_disable")
+#define dfu_enable_checksum  CHECKSUM("dfu_enable")
 
 // Watchdog wd(5000000, WDT_MRI);
 
@@ -70,7 +71,6 @@ USBMSD msc __attribute__ ((section ("AHBSRAM0"))) (&u, &sd);
 #else
 USBMSD *msc= NULL;
 #endif
-DFU dfu __attribute__ ((section ("AHBSRAM0"))) (&u);
 
 SDFAT mounter __attribute__ ((section ("AHBSRAM0"))) ("sd", &sd);
 
@@ -99,9 +99,12 @@ void init() {
     //some boards don't have leds.. TOO BAD!
     kernel->use_leds= !kernel->config->value( disable_leds_checksum )->by_default(false)->as_bool();
 
+    bool sdok= (sd.disk_initialize() == 0);
+    if(!sdok) kernel->streams->printf("SDCard is disabled\r\n");
+
 #ifdef DISABLEMSD
     // attempt to be able to disable msd in config
-    if(!kernel->config->value( disable_msd_checksum )->by_default(false)->as_bool()){
+    if(sdok && !kernel->config->value( disable_msd_checksum )->by_default(false)->as_bool()){
         // HACK to zero the memory USBMSD uses as it and its objects seem to not initialize properly in the ctor
         size_t n= sizeof(USBMSD);
         void *v = AHB0.alloc(n);
@@ -113,7 +116,6 @@ void init() {
     }
 #endif
 
-    bool sdok= (sd.disk_initialize() == 0);
 
     // Create and add main modules
     kernel->add_module( new SimpleShell() );
@@ -179,9 +181,12 @@ void init() {
 
     kernel->add_module( &usbserial );
     if( kernel->config->value( second_usb_serial_enable_checksum )->by_default(false)->as_bool() ){
-        kernel->add_module( new USBSerial(&u) );
+        kernel->add_module( new(AHB0) USBSerial(&u) );
+    }
+
+    if( kernel->config->value( dfu_enable_checksum )->by_default(false)->as_bool() ){
+        kernel->add_module( new(AHB0) DFU(&u));
     }
-    kernel->add_module( &dfu );
     kernel->add_module( &u );
 
     // clear up the config cache to save some memory