diff --git a/dfu.c b/dfu.c index d8d114f..7afe6a3 100644 --- a/dfu.c +++ b/dfu.c @@ -319,6 +319,10 @@ void dfu_close() void dfu_erase(int nbytes) { + // Enter Programming Mode. + md380_command(0x91, 0x01); + usleep(100000); + erase_block(0x00000000); erase_block(0x00010000); erase_block(0x00020000); @@ -339,6 +343,9 @@ void dfu_erase(int nbytes) erase_block(0x001c0000); erase_block(0x001d0000); } + + // Zero address. + set_address(0x00000000); } void dfu_read_block(int bno, uint8_t *data, int nbytes) @@ -371,4 +378,5 @@ void dfu_write_block(int bno, uint8_t *data, int nbytes) } get_status(); + wait_dfu_idle(); } diff --git a/md380.c b/md380.c index b635bb2..20ad7ec 100644 --- a/md380.c +++ b/md380.c @@ -310,7 +310,7 @@ static void md380_download() dfu_read_block(bno, &radio_mem[bno*1024], 1024); ++radio_progress; - if (radio_progress % 16 == 0) { + if (radio_progress % 32 == 0) { fprintf(stderr, "#"); fflush(stderr); } @@ -332,7 +332,7 @@ static void md380_upload(int cont_flag) dfu_write_block(bno, &radio_mem[bno*1024], 1024); ++radio_progress; - if (radio_progress % 16 == 0) { + if (radio_progress % 32 == 0) { fprintf(stderr, "#"); fflush(stderr); } @@ -344,7 +344,7 @@ static void md380_upload(int cont_flag) // static int md380_is_compatible() { - return strncmp("AH017$", (char*)&radio_mem[0], 6) == 0; + return 1; } // diff --git a/uv380.c b/uv380.c index ea8f894..8e9c4f1 100644 --- a/uv380.c +++ b/uv380.c @@ -334,7 +334,7 @@ static void uv380_download() dfu_read_block(bno, &radio_mem[bno*1024], 1024); ++radio_progress; - if (radio_progress % 16 == 0) { + if (radio_progress % 32 == 0) { fprintf(stderr, "#"); fflush(stderr); } @@ -350,13 +350,11 @@ static void uv380_upload(int cont_flag) dfu_erase(MEMSZ); - fprintf(stderr, "Sending data... "); - fflush(stderr); for (bno=0; bno