Compare commits

...

2 Commits

Author SHA1 Message Date
Olaf Rempel ebe79687f0 Add parameter to stay in bootloader 2021-03-02 13:23:16 +01:00
Olaf Rempel ce3a80b747 Fix examples 2021-03-02 13:22:52 +01:00
4 changed files with 30 additions and 7 deletions

View File

@ -51,6 +51,7 @@ typedef struct bfly_privdata_s
uint8_t twi_address;
uint8_t chip_erase;
uint8_t stay_in_bootloader;
uint16_t buffersize;
uint16_t flashsize;
@ -64,6 +65,7 @@ static struct option bfly_optargs[] =
{ "address", 1, 0, 'a' }, /* [ -a <address ] */
{ "device", 1, 0, 'd' }, /* -d <device> */
{ "erase", 0, 0, 'e' }, /* [ -e ] */
{ "stay", 0, 0, 's' }, /* [ -s ] */
};
/* *************************************************************************
@ -112,12 +114,17 @@ static int bfly_optarg_cb(int val, const char *arg, void *privdata)
p_priv->chip_erase = 1;
break;
case 's': /* stay in bootloader */
p_priv->stay_in_bootloader = 1;
break;
case 'h':
case '?': /* error */
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"
" -s - stay in bootloader afterwards\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"
@ -389,7 +396,16 @@ static int butterfly_enter_progmode(bfly_privdata_t * p_priv)
* ************************************************************************* */
static int butterfly_leave_progmode(bfly_privdata_t * p_priv)
{
(void)write(p_priv->fd, "L", 1);
if (p_priv->stay_in_bootloader)
{
/* Leave programming mode */
(void)write(p_priv->fd, "L", 1);
}
else
{
/* Exit Bootloader */
(void)write(p_priv->fd, "E", 1);
}
return butterfly_expect_cr(p_priv);
} /* butterfly_leave_progmode */

View File

@ -193,7 +193,7 @@ static int funk_optarg_cb(int val, const char *arg, void *privdata)
" -n - disable verify after write\n"
" -p <0|1|2> - progress bar mode\n"
"\n"
"Example: funkboot -d /dev/ttyUSB0 -a 0x22 -w flash:blmc.hex -w flash:blmc_eeprom.hex\n"
"Example: funkboot -d /dev/ttyUSB0 -a 0x22 -w flash:blmc.hex -w eeprom:blmc_eeprom.hex\n"
"\n");
return -1;

View File

@ -109,7 +109,7 @@ static int mpm_optarg_cb(int val, const char *arg, void *privdata)
" -n - disable verify after write\n"
" -p <0|1|2> - progress bar mode\n"
"\n"
"Example: mpmboot -d /dev/ttyUSB0 -a 0x22 -w flash:blmc.hex -w flash:blmc_eeprom.hex\n"
"Example: mpmboot -d /dev/ttyUSB0 -a 0x22 -w flash:blmc.hex -w eeprom:blmc_eeprom.hex\n"
"\n");
return -1;

View File

@ -74,6 +74,7 @@ struct twi_privdata
uint8_t address;
int fd;
int connected;
int stay_in_bootloader;
uint8_t pagesize;
uint16_t flashsize;
@ -82,8 +83,9 @@ struct twi_privdata
static struct option twi_optargs[] =
{
{ "address", 1, 0, 'a'}, /* -a <addr> */
{ "device", 1, 0, 'd'}, /* [ -d <device> ] */
{ "address", 1, 0, 'a' }, /* -a <addr> */
{ "device", 1, 0, 'd' }, /* [ -d <device> ] */
{ "stay", 0, 0, 's' }, /* [ -s ] */
};
@ -299,7 +301,7 @@ static int twi_close(struct multiboot *mboot)
{
struct twi_privdata *twi = (struct twi_privdata *)mboot->privdata;
if (twi->connected)
if (twi->connected && !twi->stay_in_bootloader)
{
twi_switch_application(twi, BOOTTYPE_APPLICATION);
}
@ -535,17 +537,22 @@ static int twi_optarg_cb(int val, const char *arg, void *privdata)
}
break;
case 's': /* stay in bootloader */
twi->stay_in_bootloader = 1;
break;
case 'h':
case '?': /* error */
fprintf(stderr, "Usage: twiboot [options]\n"
" -a <address> - selects i2c address (0x01 - 0x7F)\n"
" -d <device> - selects i2c device (default: /dev/i2c-0)\n"
" -s - stay in bootloader afterwards\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"
" -p <0|1|2> - progress bar mode\n"
"\n"
"Example: twiboot -a 0x22 -w flash:blmc.hex -w flash:blmc_eeprom.hex\n"
"Example: twiboot -a 0x22 -w flash:blmc.hex -w eeprom:blmc_eeprom.hex\n"
"\n");
return -1;