projects
/
fw
/
openocd
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
jlink: add capability dumper and command
[fw/openocd]
/
src
/
flash
/
mflash.c
diff --git
a/src/flash/mflash.c
b/src/flash/mflash.c
index 90e9888bdeb136727bb83645a7f1c111a16f32fd..ba34422237d10cd3c6ac9e1f6e3a30a59f7e5f96 100644
(file)
--- a/
src/flash/mflash.c
+++ b/
src/flash/mflash.c
@@
-209,7
+209,7
@@
static int mg_init_gpio (void)
return ret;
}
return ret;
}
-static int mg_dsk_wait(mg_io_type_wait wait, uint32_t time_var)
+static int mg_dsk_wait(mg_io_type_wait wait
_local
, uint32_t time_var)
{
uint8_t status, error;
struct target *target = mflash_bank->target;
{
uint8_t status, error;
struct target *target = mflash_bank->target;
@@
-228,10
+228,10
@@
static int mg_dsk_wait(mg_io_type_wait wait, uint32_t time_var)
if (status & mg_io_rbit_status_busy)
{
if (status & mg_io_rbit_status_busy)
{
- if (wait == mg_io_wait_bsy)
+ if (wait
_local
== mg_io_wait_bsy)
return ERROR_OK;
} else {
return ERROR_OK;
} else {
- switch (wait)
+ switch (wait
_local
)
{
case mg_io_wait_not_bsy:
return ERROR_OK;
{
case mg_io_wait_not_bsy:
return ERROR_OK;
@@
-259,7
+259,7
@@
static int mg_dsk_wait(mg_io_type_wait wait, uint32_t time_var)
return ERROR_MG_IO;
}
return ERROR_MG_IO;
}
- switch (wait)
+ switch (wait
_local
)
{
case mg_io_wait_rdy:
if (status & mg_io_rbit_status_ready)
{
case mg_io_wait_rdy:
if (status & mg_io_rbit_status_ready)
@@
-720,14
+720,20
@@
COMMAND_HANDLER(mg_write_cmd)
if (ret != ERROR_OK)
return ret;
if (ret != ERROR_OK)
return ret;
+ int filesize;
buffer = malloc(MG_FILEIO_CHUNK);
if (!buffer) {
fileio_close(&fileio);
return ERROR_FAIL;
}
buffer = malloc(MG_FILEIO_CHUNK);
if (!buffer) {
fileio_close(&fileio);
return ERROR_FAIL;
}
+ int retval = fileio_size(&fileio, &filesize);
+ if (retval != ERROR_OK) {
+ fileio_close(&fileio);
+ return retval;
+ }
- cnt = file
io.
size / MG_FILEIO_CHUNK;
- res = file
io.
size % MG_FILEIO_CHUNK;
+ cnt = filesize / MG_FILEIO_CHUNK;
+ res = filesize % MG_FILEIO_CHUNK;
struct duration bench;
duration_start(&bench);
struct duration bench;
duration_start(&bench);
@@
-752,8
+758,8
@@
COMMAND_HANDLER(mg_write_cmd)
if (duration_measure(&bench) == ERROR_OK)
{
command_print(CMD_CTX, "wrote %ld bytes from file %s "
if (duration_measure(&bench) == ERROR_OK)
{
command_print(CMD_CTX, "wrote %ld bytes from file %s "
- "in %fs (%0.3f kB/s)", (long)file
io.
size, CMD_ARGV[1],
- duration_elapsed(&bench), duration_kbps(&bench, file
io.
size));
+ "in %fs (%0.3f kB/s)", (long)filesize, CMD_ARGV[1],
+ duration_elapsed(&bench), duration_kbps(&bench, filesize));
}
free(buffer);
}
free(buffer);
@@
-1121,7
+1127,7
@@
static int mg_storage_config(void)
!= ERROR_OK)
return ret;
!= ERROR_OK)
return ret;
- mg_gen_ataid((mg_io_type_drv_info *)buff);
+ mg_gen_ataid((mg_io_type_drv_info *)
(void *)
buff);
if ((ret = mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_update_stgdrvinfo))
!= ERROR_OK)
if ((ret = mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_update_stgdrvinfo))
!= ERROR_OK)
@@
-1149,7
+1155,7
@@
static int mg_boot_config(void)
buff[0] = mg_op_mode_snd; /* operation mode */
buff[1] = MG_UNLOCK_OTP_AREA;
buff[2] = 4; /* boot size */
buff[0] = mg_op_mode_snd; /* operation mode */
buff[1] = MG_UNLOCK_OTP_AREA;
buff[2] = 4; /* boot size */
- *((uint32_t *)(buff + 4)) = 0; /* XIP size */
+ *((uint32_t *)(
void *)(
buff + 4)) = 0; /* XIP size */
if ((ret = mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_update_xipinfo))
!= ERROR_OK)
if ((ret = mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_update_xipinfo))
!= ERROR_OK)