Use DIO mode for normal operation; disable DIO before flashing. Use SYS_LED for indicating booting (slow), flashing (fast) and normal operation (on)

This commit is contained in:
feelfree69
2026-01-22 19:38:17 +01:00
parent 1e8382bd56
commit 0345bf7bf2
4 changed files with 26 additions and 1 deletions
+3
View File
@@ -436,6 +436,9 @@ void handle_post(void)
flash_region.addr = CONFIG_START; flash_region.addr = CONFIG_START;
flash_sector_erase(); flash_sector_erase();
} }
flash_init(0); // Re-initialize flash for non-DIO operation, otherwise flashing fails
set_sys_led_state(SYS_LED_FAST);
crc_value = 0; crc_value = 0;
bindex = 0; bindex = 0;
write_len = 0; write_len = 0;
+1
View File
@@ -124,5 +124,6 @@ void get_random_32(void);
void read_reg_timer(uint32_t * tmr); void read_reg_timer(uint32_t * tmr);
void sfp_print_info(uint8_t sfp); void sfp_print_info(uint8_t sfp);
bool gpio_pin_test(uint8_t pin); bool gpio_pin_test(uint8_t pin);
void set_sys_led_state(uint8_t state);
#endif #endif
+5
View File
@@ -9,6 +9,11 @@
#define RTL837X_REG_HW_CONF 0x6040 #define RTL837X_REG_HW_CONF 0x6040
// Bits 4 & 5: CLOCK DIVIDER from 125MHz for Timer // Bits 4 & 5: CLOCK DIVIDER from 125MHz for Timer
#define SYS_LED_OFF 0
#define SYS_LED_FAST 1
#define SYS_LED_SLOW 2
#define SYS_LED_ON 3
#define RTL837X_REG_LED_MODE 0x6520 #define RTL837X_REG_LED_MODE 0x6520
// Defines the LED Mode for steering the Port LEDS and the System LED // Defines the LED Mode for steering the Port LEDS and the System LED
// BIT 17 set: LED solid on // BIT 17 set: LED solid on
+17 -1
View File
@@ -1416,6 +1416,9 @@ void led_config_9xh(void)
sfr_mask_data(0, 0xe0, 0xa0); sfr_mask_data(0, 0xe0, 0xa0);
reg_write_m(RTL837X_REG_LED_MODE); reg_write_m(RTL837X_REG_LED_MODE);
// Set LED blink rate to slow during booting
set_sys_led_state(SYS_LED_SLOW);
// Disable RLDP (Realtek Loop Detection Protocol) LEDs on loop detection // Disable RLDP (Realtek Loop Detection Protocol) LEDs on loop detection
reg_read_m(RTL837X_REG_LED_RLDP_1); reg_read_m(RTL837X_REG_LED_RLDP_1);
sfr_mask_data(0, 0, 0x3); sfr_mask_data(0, 0, 0x3);
@@ -1442,6 +1445,12 @@ void led_config_9xh(void)
reg_write_m(RTL837X_REG_LED3_0_SET1); reg_write_m(RTL837X_REG_LED3_0_SET1);
} }
void set_sys_led_state(uint8_t state)
{
reg_read_m(RTL837X_REG_LED_MODE);
sfr_mask_data(2, 0x03, state);
reg_write_m(RTL837X_REG_LED_MODE);
}
void led_config(void) void led_config(void)
{ {
@@ -1794,7 +1803,7 @@ void bootloader(void)
// Flash controller should be initialized before any code in other banks is being fetched // Flash controller should be initialized before any code in other banks is being fetched
// See this issue: https://github.com/logicog/RTLPlayground/issues/70 // See this issue: https://github.com/logicog/RTLPlayground/issues/70
print_string("\nInitializing Flash controller\n"); print_string("\nInitializing Flash controller\n");
flash_init(0); flash_init(1);
// Set default for SFP pins so we can start up a module already inserted // Set default for SFP pins so we can start up a module already inserted
sfp_pins_last = 0x33; // signal LOS and no module inserted (for both slots, even if only 1 present) sfp_pins_last = 0x33; // signal LOS and no module inserted (for both slots, even if only 1 present)
@@ -1850,6 +1859,9 @@ void bootloader(void)
__xdata uint8_t * __xdata bptr; __xdata uint8_t * __xdata bptr;
print_string("Identified update image. Checking integrity..."); print_string("Identified update image. Checking integrity...");
flash_init(0); // Re-initialize flash for non-DIO operation, otherwise flashing will fail
set_sys_led_state(SYS_LED_FAST);
crc_value = 0x0000; crc_value = 0x0000;
for (i = 0; i < 1024; i++) { for (i = 0; i < 1024; i++) {
flash_region.addr = source; flash_region.addr = source;
@@ -1910,6 +1922,8 @@ void bootloader(void)
} }
} }
set_sys_led_state(SYS_LED_SLOW);
#ifdef DEBUG #ifdef DEBUG
// This register seems to work on the RTL8373 only if also the SDS // This register seems to work on the RTL8373 only if also the SDS
// Is correctly configured. Therefore, we can test it, here... // Is correctly configured. Therefore, we can test it, here...
@@ -1955,6 +1969,8 @@ void bootloader(void)
print_string("\n> "); print_string("\n> ");
idle_ready = 1; idle_ready = 1;
set_sys_led_state(SYS_LED_ON);
// Wait for commands on serial connection // Wait for commands on serial connection
// sbuf_ptr is moved forward by serial interrupt, l is the position until we have already // sbuf_ptr is moved forward by serial interrupt, l is the position until we have already
// printed out the entered characters // printed out the entered characters