Merge pull request #14 from bikeNomad/master
authortexane <texane@gmail.com>
Thu, 20 Oct 2011 05:15:54 +0000 (22:15 -0700)
committertexane <texane@gmail.com>
Thu, 20 Oct 2011 05:15:54 +0000 (22:15 -0700)
Minor improvements to utilities and example makefile

Makefile
example/blink_flash/Makefile
flash/main.c

index 4c3b44b8321bf12f1972b0a94895e0e980be4775..a6545e83b64b54141b26ba3ea5ce126118e2a570 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ LDFLAGS=-lstlink -lusb-1.0 -lsgutils2 -L.
 
 LIBRARY=libstlink.a
 
-all:  $(LIBRARY) test_usb test_sg 
+all:  $(LIBRARY) flash gdbserver test_usb test_sg 
 
 $(LIBRARY): $(OBJS_LIB)
        @echo "objs are $(OBJS_LIB)"
@@ -42,5 +42,15 @@ clean:
        rm -rf $(LIBRARY)
        rm -rf test_usb*
        rm -rf test_sg*
+
+distclean: clean
+       $(MAKE) -C flash clean
+       $(MAKE) -C gdbserver clean
        
-.PHONY: clean all
+flash:
+       $(MAKE) -C flash
+
+gdbserver:
+       $(MAKE) -C gdbserver
+
+.PHONY: clean all flash gdbserver
index d0583902969d5baeeb75bf45055cd94a921970ca..77764715d9f42de214acc8895786329624ff49cb 100644 (file)
@@ -5,7 +5,18 @@ CC=arm-none-eabi-gcc
 OBJCOPY=arm-none-eabi-objcopy
 
 CFLAGS=-O2 -mlittle-endian -mthumb
-CFLAGS+=-mcpu=cortex-m3 -ffreestanding -nostdlib -nostdinc
+
+CFLAGS=-g -O2 -mlittle-endian -mthumb
+ifeq ($(CONFIG_STM32L_DISCOVERY), 1)
+       CFLAGS+=-mcpu=cortex-m3 -DCONFIG_STM32L_DISCOVERY
+else ifeq ($(CONFIG_STM32VL_DISCOVERY), 1)
+       CFLAGS+=-mcpu=cortex-m3 -DCONFIG_STM32VL_DISCOVERY=1
+else ifeq ($(CONFIG_STM32F4_DISCOVERY), 1)
+       CFLAGS+=-mcpu=cortex-m4 -DCONFIG_STM32F4_DISCOVERY=1    
+else
+$(error "must specify CONFIG_ for board!")
+endif
+       CFLAGS+=-ffreestanding -nostdlib -nostdinc
 
 # to run from FLASH
 CFLAGS+=-Wl,-T,stm32_flash.ld
index 3b9416dff1b885f2d8714dacb7f60bf01b407bbd..a443f95f6bb58b59460e3231a5a650d637763d6c 100644 (file)
@@ -17,6 +17,11 @@ struct opts
   size_t size;
 };
 
+static void usage(void)
+{
+    puts("stlinkv1 command line: ./flash {read|write} /dev/sgX path addr <size>");
+    puts("stlinkv2 command line: ./flash {read|write} path addr <size>");
+}
 
 static int get_opts(struct opts* o, int ac, char** av)
 {
@@ -75,6 +80,7 @@ int main(int ac, char** av)
   if (get_opts(&o, ac - 1, av + 1) == -1)
   {
     printf("invalid command line\n");
+    usage();
     goto on_error;
   }
 
@@ -86,7 +92,7 @@ int main(int ac, char** av)
   }
   else /* stlinkv2 */
   {
-    sl = stlink_open_usb(NULL, 10);
+    sl = stlink_open_usb(10);
     if (sl == NULL) goto on_error;
   }