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)"
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
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
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)
{
if (get_opts(&o, ac - 1, av + 1) == -1)
{
printf("invalid command line\n");
+ usage();
goto on_error;
}
}
else /* stlinkv2 */
{
- sl = stlink_open_usb(NULL, 10);
+ sl = stlink_open_usb(10);
if (sl == NULL) goto on_error;
}