Compare commits
4 Commits
9119ee215b
...
1d39889818
Author | SHA1 | Date |
---|---|---|
Olaf Rempel | 1d39889818 | |
Olaf Rempel | 9d1fdb5c4c | |
Olaf Rempel | c4f55407bc | |
Olaf Rempel | 890158860b |
10
butterfly.c
10
butterfly.c
|
@ -39,6 +39,8 @@
|
|||
#define SERIAL_BAUDRATE B115200
|
||||
#define SERIAL_TIMEOUT 1000
|
||||
|
||||
#define WRITE_SIZE_EEPROM 16
|
||||
|
||||
struct multiboot_ops butterfly_ops;
|
||||
|
||||
typedef struct bfly_privdata_s
|
||||
|
@ -106,7 +108,7 @@ static int bfly_optarg_cb(int val, const char *arg, void *privdata)
|
|||
}
|
||||
break;
|
||||
|
||||
case 'e': /* no verify after write */
|
||||
case 'e': /* chip erase */
|
||||
p_priv->chip_erase = 1;
|
||||
break;
|
||||
|
||||
|
@ -115,6 +117,7 @@ static int bfly_optarg_cb(int val, const char *arg, void *privdata)
|
|||
fprintf(stderr, "Usage: butterfly_prog [options]\n"
|
||||
" -a <address> - optional: twi address for twiboot bridge mode\n"
|
||||
" -d <device> - selects butterfly serial device\n"
|
||||
" -e - executes a chip erase\n"
|
||||
" -r <flash|eeprom>:<file> - reads flash/eeprom to file (.bin | .hex | -)\n"
|
||||
" -w <flash|eeprom>:<file> - write flash/eeprom from file (.bin | .hex)\n"
|
||||
" -n - disable verify after write\n"
|
||||
|
@ -688,7 +691,10 @@ static int butterfly_write(struct multiboot * p_mboot,
|
|||
{
|
||||
p_mboot->progress_cb(p_progress_msg, pos, p_dbuf->length);
|
||||
|
||||
uint16_t len = MIN(p_priv->buffersize, p_dbuf->length - pos);
|
||||
uint16_t len = (memtype == 'F') ? p_priv->buffersize : WRITE_SIZE_EEPROM;
|
||||
|
||||
len = MIN(len, p_dbuf->length - pos);
|
||||
|
||||
if (butterfly_write_data(p_priv, p_dbuf->data + pos, len, memtype))
|
||||
{
|
||||
p_mboot->progress_cb(p_progress_msg, -1, -1);
|
||||
|
|
|
@ -457,6 +457,12 @@ static int hexfile_write(const char *filename, struct databuf *dbuf)
|
|||
}
|
||||
}
|
||||
|
||||
if (addr_min >= addr_max)
|
||||
{
|
||||
addr_min = 0;
|
||||
addr_max = dbuf->length;
|
||||
}
|
||||
|
||||
addr_min = addr_min & ~0x0F;
|
||||
addr_max = (addr_max + 0x0F) & ~0x0F;
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ static void progress_mode0_cb(const char *msg, int pos, int size)
|
|||
* ************************************************************************* */
|
||||
static void progress_mode1_cb(const char *msg, int pos, int size)
|
||||
{
|
||||
if (pos != -1 && size != -1)
|
||||
if (pos != -1 && size > 0)
|
||||
{
|
||||
char stars[51];
|
||||
int i;
|
||||
|
@ -111,7 +111,7 @@ static void progress_mode2_cb(const char *msg, int pos, int size)
|
|||
{
|
||||
static int old_count;
|
||||
|
||||
if (pos != -1 && size != -1)
|
||||
if (pos != -1 && size > 0)
|
||||
{
|
||||
if (pos == 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue