diff --git a/Makefile b/Makefile index 7a5d284..a79a187 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ FIRMWARE_ADDRESS = 0x10001000 -BUFFER = 0x10008000 +BUFFER_ADDRESS = 0x10008000 BUFFER_SIZE = 262144 FLASH_SECTOR_SIZE = 4096 all: - arm-none-eabi-gcc -Wall -g -Os -mlittle-endian -mlong-calls -mthumb -mcpu=cortex-m3 -mfloat-abi=soft -mthumb-interwork -ffunction-sections -ffreestanding -fsingle-precision-constant -Wstrict-aliasing=0 -Wl,-T,rtl8710.ld -nostartfiles -nostdlib -u main -Wl,--section-start=.text=$(FIRMWARE_ADDRESS) -DBUFFER=$(BUFFER) rtl8710_flasher.c spi_flash.c -o rtl8710_flasher.elf + arm-none-eabi-gcc -Wall -g -Os -mlittle-endian -mlong-calls -mthumb -mcpu=cortex-m3 -mfloat-abi=soft -mthumb-interwork -ffunction-sections -ffreestanding -fsingle-precision-constant -Wstrict-aliasing=0 -Wl,-T,rtl8710.ld -nostartfiles -nostdlib -u main -Wl,--section-start=.text=$(FIRMWARE_ADDRESS) -DBUFFER_ADDRESS=$(BUFFER_ADDRESS) rtl8710_flasher.c spi_flash.c -o rtl8710_flasher.elf arm-none-eabi-objcopy -O binary rtl8710_flasher.elf rtl8710_flasher.bin gcc make_array.c -o make_array cp rtl8710_cpu.ocd rtl8710.ocd echo "set rtl8710_flasher_firmware_ptr $(FIRMWARE_ADDRESS)" >>rtl8710.ocd - echo "set rtl8710_flasher_buffer $(BUFFER)" >>rtl8710.ocd + echo "set rtl8710_flasher_buffer $(BUFFER_ADDRESS)" >>rtl8710.ocd echo "set rtl8710_flasher_buffer_size $(BUFFER_SIZE)" >>rtl8710.ocd echo >>rtl8710.ocd echo "array set rtl8710_flasher_code {" >>rtl8710.ocd diff --git a/README.md b/README.md index ac9818e..aa119dc 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ compare file (filename) with flash offset (offset) ### rtl8710_flash_auto_erase [1/0] set auto_erase option on/off. flash pages will be autoerased when writing ### rtl8710_flash_auto_verify [1/0] -set auto_verify on/off. each block of data will be auto verified when writing -## example: +set auto_verify option on/off. each block of data will be auto verified when writing +## examples: ``` openocd -f interface/stlink-v2-1.cfg -f rtl8710.ocd -c "init" -c "reset halt" -c "rtl8710_flash_read_id" -c "rtl8710_flash_read dump.bin 0 1048576" -c "shutdown" ``` diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..cbd6bb2 --- /dev/null +++ b/TODO.txt @@ -0,0 +1,5 @@ +TESTING +better documentation +error handling +timeout handling + diff --git a/make_array.c b/make_array.c index d2ba33f..86e2620 100644 --- a/make_array.c +++ b/make_array.c @@ -4,22 +4,19 @@ int main(){ ssize_t i, l; - uint32_t value; + uint32_t value, index; uint8_t buffer[24]; - int started, index; - started = index = 0; + index = 0; while(1){ l = read(0, buffer, 24); if(l < 1)break; - if(started)printf("\n"); - started = 1; printf("\t"); for(i = 0; i < l; i += 4){ value = ((uint32_t)buffer[i + 0] << 0) | ((uint32_t)buffer[i + 1] << 8) | ((uint32_t)buffer[i + 2] << 16) | ((uint32_t)buffer[i + 3] << 24); if(i)printf(" "); printf("%d 0x%08X", index++, (unsigned int)value); } + printf("\n"); } - printf("\n"); } diff --git a/rtl8710_flasher.c b/rtl8710_flasher.c index c01cd17..9415d54 100644 --- a/rtl8710_flasher.c +++ b/rtl8710_flasher.c @@ -2,13 +2,13 @@ #include #include "spi_flash.h" -#define MEM_START (*(volatile uint32_t *)(BUFFER + 0x00)) -#define MEM_COMMAND (*(volatile uint32_t *)(BUFFER + 0x04)) -#define MEM_STATUS (*(volatile uint32_t *)(BUFFER + 0x08)) -#define MEM_PARAM (*(volatile uint32_t *)(BUFFER + 0x0C)) -#define MEM_OFFSET (*(volatile uint32_t *)(BUFFER + 0x10)) -#define MEM_LEN (*(volatile uint32_t *)(BUFFER + 0x14)) -#define MEM_DATA ((volatile uint8_t *)(BUFFER + 0x20)) +#define MEM_START (*(volatile uint32_t *)(BUFFER_ADDRESS + 0x00)) +#define MEM_COMMAND (*(volatile uint32_t *)(BUFFER_ADDRESS + 0x04)) +#define MEM_STATUS (*(volatile uint32_t *)(BUFFER_ADDRESS + 0x08)) +#define MEM_PARAM (*(volatile uint32_t *)(BUFFER_ADDRESS + 0x0C)) +#define MEM_OFFSET (*(volatile uint32_t *)(BUFFER_ADDRESS + 0x10)) +#define MEM_LEN (*(volatile uint32_t *)(BUFFER_ADDRESS + 0x14)) +#define MEM_DATA ((volatile uint8_t *)(BUFFER_ADDRESS + 0x20)) #define COMMAND_READ_ID 0 #define COMMAND_MASS_ERASE 1