diff --git a/flashstub/README b/flashstub/README deleted file mode 100644 index 90d164c..0000000 --- a/flashstub/README +++ /dev/null @@ -1,19 +0,0 @@ -Flash Stubs -=========== - -For most of the targets, these are assembler routines for executing -a flash write on the supported targets. They are kept here for -reference, but are not used, as the compiled binary code is included -in the target drivers. - -For the STM32l0x, the stubs are written in C++ and emitted as arrays -of half-words for inclusion in the target driver. The use of a higher -level language allows more detailed code and for easy revisions. -These stubs communicate with the driver through a structure defined in -the src/include/stm32l0-nvm.h header. - -The dump-to-array.sh helper script uses sed to transform the output of -'objdump -d' into a half-word array of the instructions that may be -included in C code to declare the stub. FWIW, objcopy doesn't produce -the same output as objdump. It omits some of the instructions, -probably because the object file isn't linked. diff --git a/src/target/efm32.c b/src/target/efm32.c index 3725121..7232743 100644 --- a/src/target/efm32.c +++ b/src/target/efm32.c @@ -49,7 +49,7 @@ static int efm32_flash_write(struct target_flash *f, uint32_t dest, const void *src, size_t len); static const uint16_t efm32_flash_write_stub[] = { -#include "../flashstub/efm32.stub" +#include "flashstub/efm32.stub" }; static bool efm32_cmd_erase_all(target *t); diff --git a/flashstub/Makefile b/src/target/flashstub/Makefile similarity index 90% rename from flashstub/Makefile rename to src/target/flashstub/Makefile index a18cd23..3b137a0 100644 --- a/flashstub/Makefile +++ b/src/target/flashstub/Makefile @@ -8,7 +8,7 @@ ifneq ($(V), 1) Q = @ endif -CFLAGS=-Os -std=gnu99 -mcpu=cortex-m0 -mthumb -I../libopencm3/include +CFLAGS=-Os -std=gnu99 -mcpu=cortex-m0 -mthumb -I../../../libopencm3/include ASFLAGS=-mcpu=cortex-m3 -mthumb all: lmi.stub stm32f4.stub stm32l4.stub nrf51.stub stm32f1.stub efm32.stub diff --git a/src/target/flashstub/README.md b/src/target/flashstub/README.md new file mode 100644 index 0000000..df6bb71 --- /dev/null +++ b/src/target/flashstub/README.md @@ -0,0 +1,13 @@ +Flash Stubs +=========== + +These are simple routines for programming the flash on various Cortex-M +microcontrollers. The routines should be provided with the naked attribute +as the stack may not be available, and must not make any function calls. +The stub must call `stub_exit(code)` provided by `stub.h` to return control +to the debugger. Up to 4 word sized parameters may be taken. + +These stubs are compiled instructions comma separated hex values in the +resulting `*.stub` files here, which may be included in the drivers for the +specific device. The drivers call these flash stubs on the target by calling +`cortexm_run_stub` defined in `cortexm.h`. diff --git a/flashstub/efm32.c b/src/target/flashstub/efm32.c similarity index 100% rename from flashstub/efm32.c rename to src/target/flashstub/efm32.c diff --git a/flashstub/efm32.stub b/src/target/flashstub/efm32.stub similarity index 100% rename from flashstub/efm32.stub rename to src/target/flashstub/efm32.stub diff --git a/flashstub/lmi.c b/src/target/flashstub/lmi.c similarity index 100% rename from flashstub/lmi.c rename to src/target/flashstub/lmi.c diff --git a/flashstub/lmi.stub b/src/target/flashstub/lmi.stub similarity index 100% rename from flashstub/lmi.stub rename to src/target/flashstub/lmi.stub diff --git a/flashstub/nrf51.s b/src/target/flashstub/nrf51.s similarity index 100% rename from flashstub/nrf51.s rename to src/target/flashstub/nrf51.s diff --git a/flashstub/nrf51.stub b/src/target/flashstub/nrf51.stub similarity index 100% rename from flashstub/nrf51.stub rename to src/target/flashstub/nrf51.stub diff --git a/flashstub/stm32f1.c b/src/target/flashstub/stm32f1.c similarity index 100% rename from flashstub/stm32f1.c rename to src/target/flashstub/stm32f1.c diff --git a/flashstub/stm32f1.stub b/src/target/flashstub/stm32f1.stub similarity index 100% rename from flashstub/stm32f1.stub rename to src/target/flashstub/stm32f1.stub diff --git a/flashstub/stm32f4.c b/src/target/flashstub/stm32f4.c similarity index 100% rename from flashstub/stm32f4.c rename to src/target/flashstub/stm32f4.c diff --git a/flashstub/stm32f4.stub b/src/target/flashstub/stm32f4.stub similarity index 100% rename from flashstub/stm32f4.stub rename to src/target/flashstub/stm32f4.stub diff --git a/flashstub/stm32l4.c b/src/target/flashstub/stm32l4.c similarity index 100% rename from flashstub/stm32l4.c rename to src/target/flashstub/stm32l4.c diff --git a/flashstub/stm32l4.stub b/src/target/flashstub/stm32l4.stub similarity index 100% rename from flashstub/stm32l4.stub rename to src/target/flashstub/stm32l4.stub diff --git a/flashstub/stub.h b/src/target/flashstub/stub.h similarity index 100% rename from flashstub/stub.h rename to src/target/flashstub/stub.h diff --git a/src/target/lmi.c b/src/target/lmi.c index 5989990..284e510 100644 --- a/src/target/lmi.c +++ b/src/target/lmi.c @@ -54,7 +54,7 @@ static int lmi_flash_write(struct target_flash *f, static const char lmi_driver_str[] = "TI Stellaris/Tiva"; static const uint16_t lmi_flash_write_stub[] = { -#include "../flashstub/lmi.stub" +#include "flashstub/lmi.stub" }; static void lmi_add_flash(target *t, size_t length) diff --git a/src/target/nrf51.c b/src/target/nrf51.c index 7012669..5025da0 100644 --- a/src/target/nrf51.c +++ b/src/target/nrf51.c @@ -85,7 +85,7 @@ const struct command_s nrf51_read_cmd_list[] = { #define STUB_BUFFER_BASE (SRAM_BASE + 0x28) static const uint16_t nrf51_flash_write_stub[] = { -#include "../flashstub/nrf51.stub" +#include "flashstub/nrf51.stub" }; static void nrf51_add_flash(target *t, diff --git a/src/target/stm32f1.c b/src/target/stm32f1.c index 7c92942..eb2606b 100644 --- a/src/target/stm32f1.c +++ b/src/target/stm32f1.c @@ -89,7 +89,7 @@ static int stm32f1_flash_write(struct target_flash *f, #define FLASHSIZE_F0 0x1FFFF7CC static const uint16_t stm32f1_flash_write_stub[] = { -#include "../flashstub/stm32f1.stub" +#include "flashstub/stm32f1.stub" }; #define SRAM_BASE 0x20000000 diff --git a/src/target/stm32f4.c b/src/target/stm32f4.c index 2061925..95d42cd 100644 --- a/src/target/stm32f4.c +++ b/src/target/stm32f4.c @@ -104,7 +104,7 @@ static const char stm32f2_driver_str[] = "STM32F2xx"; /* This routine uses word access. Only usable on target voltage >2.7V */ static const uint16_t stm32f4_flash_write_stub[] = { -#include "../flashstub/stm32f4.stub" +#include "flashstub/stm32f4.stub" }; #define SRAM_BASE 0x20000000 diff --git a/src/target/stm32l4.c b/src/target/stm32l4.c index 78e14ac..cd984b1 100644 --- a/src/target/stm32l4.c +++ b/src/target/stm32l4.c @@ -110,7 +110,7 @@ static const char stm32l4_driver_str[] = "STM32L4xx"; /* This routine is uses double word access.*/ static const uint16_t stm32l4_flash_write_stub[] = { -#include "../flashstub/stm32l4.stub" +#include "flashstub/stm32l4.stub" }; #define SRAM_BASE 0x20000000