fix(ch390): deepen reset recovery
This commit is contained in:
@@ -329,6 +329,37 @@ static void ch390_runtime_refresh_diag(void)
|
||||
}
|
||||
}
|
||||
|
||||
static bool ch390_runtime_recover_chip(struct netif *netif, const uint8_t *mac)
|
||||
{
|
||||
g_ch390_ready = 0u;
|
||||
g_ch390_irq_pending = 0u;
|
||||
|
||||
ch390_hardware_reset();
|
||||
if (ch390_runtime_probe_identity() == 0u) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ch390_software_reset();
|
||||
if (ch390_runtime_probe_identity() == 0u) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ch390_phy_power_cycle();
|
||||
ch390_default_config();
|
||||
|
||||
if (ch390_mac_address_valid(mac)) {
|
||||
ch390_set_mac_address((uint8_t *)mac);
|
||||
}
|
||||
|
||||
ch390_runtime_prepare_netif(netif);
|
||||
ch390_runtime_sync_mac(netif);
|
||||
ch390_runtime_refresh_diag();
|
||||
g_ch390_ready = g_diag.id_valid;
|
||||
g_ch390_irq_pending = 0u;
|
||||
|
||||
return g_ch390_ready != 0u;
|
||||
}
|
||||
|
||||
struct pbuf *ch390_runtime_input_frame(struct netif *netif)
|
||||
{
|
||||
struct ethernetif *ethernetif = (struct ethernetif *)netif->state;
|
||||
@@ -444,11 +475,8 @@ void ch390_runtime_init(struct netif *netif, const uint8_t *mac)
|
||||
ch390_gpio_init();
|
||||
SEGGER_RTT_WriteString(0, "ETH init: spi\r\n");
|
||||
ch390_spi_init();
|
||||
SEGGER_RTT_WriteString(0, "ETH init: reset\r\n");
|
||||
ch390_hardware_reset();
|
||||
|
||||
SEGGER_RTT_WriteString(0, "ETH init: probe\r\n");
|
||||
g_ch390_ready = ch390_runtime_probe_identity();
|
||||
SEGGER_RTT_WriteString(0, "ETH init: deep reset\r\n");
|
||||
g_ch390_ready = (uint8_t)ch390_runtime_recover_chip(netif, mac);
|
||||
if (g_ch390_ready == 0u) {
|
||||
ch390_runtime_prepare_netif(netif);
|
||||
netif_set_link_down(netif);
|
||||
@@ -456,11 +484,9 @@ void ch390_runtime_init(struct netif *netif, const uint8_t *mac)
|
||||
return;
|
||||
}
|
||||
|
||||
SEGGER_RTT_WriteString(0, "ETH init: default\r\n");
|
||||
ch390_default_config();
|
||||
SEGGER_RTT_WriteString(0, "ETH init: mac\r\n");
|
||||
if (ch390_mac_address_valid(mac)) {
|
||||
ch390_set_mac_address((uint8_t *)mac);
|
||||
ch390_runtime_sync_mac(netif);
|
||||
}
|
||||
else {
|
||||
if (mac != NULL) {
|
||||
@@ -660,15 +686,7 @@ bool ch390_runtime_emergency_reset(struct netif *netif)
|
||||
}
|
||||
g_tx_consecutive_timeout = 0u;
|
||||
|
||||
ch390_software_reset();
|
||||
ch390_delay_us(5000u);
|
||||
ch390_default_config();
|
||||
ch390_runtime_prepare_netif(netif);
|
||||
ch390_runtime_sync_mac(netif);
|
||||
g_ch390_irq_pending = 0u;
|
||||
|
||||
ch390_runtime_refresh_diag();
|
||||
g_ch390_ready = g_diag.id_valid;
|
||||
(void)ch390_runtime_recover_chip(netif, (netif != NULL) ? netif->hwaddr : NULL);
|
||||
|
||||
if (g_ch390_ready == 0u) {
|
||||
SEGGER_RTT_WriteString(0, "ETH emergency reset: chip not responding\r\n");
|
||||
|
||||
Reference in New Issue
Block a user