flash_bsl: correct entry sequence.

Contributed by Micle Chebotarev <mcheb@yandex.ru>.
This commit is contained in:
Daniel Beer 2013-09-16 16:28:29 +12:00
parent fb3617e486
commit 520b9cd071
1 changed files with 50 additions and 37 deletions

View File

@ -548,49 +548,62 @@ static int flash_bsl_writemem(device_t dev_base,
} }
static void entry_delay(void)
{
delay_ms(1);
}
static int enter_via_dtr_rts(struct flash_bsl_device *dev) static int enter_via_dtr_rts(struct flash_bsl_device *dev)
{ {
/*
* Implement the sequence shown on page 8 of TI document SLAU319A,
* via serial-port control lines.
*/
sport_t fd = dev->serial_fd; sport_t fd = dev->serial_fd;
int status;
/* drive RST# line low */ if (ioctl(fd, TIOCMGET, &status) == -1)
if (sport_set_modem(fd, SPORT_MC_RTS | SPORT_MC_DTR) != 0) { {
return -1; perror("Read Port Error\n");
return -1;
} }
entry_delay( );
/* drive TEST line high then low again */ status &= ~SPORT_MC_DTR;
if (sport_set_modem(fd, SPORT_MC_DTR) != 0) { status |= SPORT_MC_RTS;
return -1; if (sport_set_modem(fd, status) != 0)
{
return -1;
} }
entry_delay( ); delay_ms(250);
if (sport_set_modem(fd, SPORT_MC_RTS | SPORT_MC_DTR) != 0) {
return -1;
}
entry_delay( );
/* drive TEST line high followed by RST# line */ status &= ~SPORT_MC_RTS;
if (sport_set_modem(fd, SPORT_MC_DTR) != 0) { if (sport_set_modem(fd, status) != 0)
return -1; {
return -1;
} }
entry_delay( ); delay_ms(10);
if (sport_set_modem(fd, 0) != 0) {
return -1;
}
entry_delay( );
if (sport_set_modem(fd, SPORT_MC_RTS) != 0) {
return -1;
}
entry_delay( );
status |= SPORT_MC_RTS;
if (sport_set_modem(fd, status) != 0)
{
return -1;
}
delay_ms(10);
status &= ~SPORT_MC_RTS;
if (sport_set_modem(fd, status) != 0)
{
return -1;
}
delay_ms(10);
status |= SPORT_MC_RTS;
if (sport_set_modem(fd, status) != 0)
{
return -1;
}
delay_ms(10);
status |= SPORT_MC_DTR;
if (sport_set_modem(fd, status) != 0)
{
return -1;
}
delay_ms(10);
sport_flush(fd);
delay_ms(10);
/* BSL should now be running! */ /* BSL should now be running! */
return 0; return 0;
@ -600,14 +613,14 @@ static void exit_via_dtr_rts(struct flash_bsl_device *dev)
{ {
sport_t fd = dev->serial_fd; sport_t fd = dev->serial_fd;
/* RST# and TEST LOW */ /* Pulse RST# low */
sport_set_modem(fd, SPORT_MC_RTS | SPORT_MC_DTR); sport_set_modem(fd, SPORT_MC_RTS);
/* wait a brief period */ /* wait a brief period */
entry_delay( ); delay_ms(10);
/* RST# HIGH */ /* RST# HIGH */
sport_set_modem(fd, SPORT_MC_DTR); sport_set_modem(fd, SPORT_MC_DTR | SPORT_MC_RTS);
} }
static void flash_bsl_destroy(device_t dev_base) static void flash_bsl_destroy(device_t dev_base)