mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Fix messed up merge commit; add button user feedback via sysled
This commit is contained in:
+7
-77
@@ -1117,8 +1117,14 @@ void handle_button(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
print_string("Short button press detected; no action.\n");
|
print_string("Short button press detected; no action.\n");
|
||||||
|
set_sys_led_state(SYS_LED_ON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Give the user feedback for button press
|
||||||
|
set_sys_led_state(SYS_LED_SLOW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1154,6 +1160,7 @@ void idle(void)
|
|||||||
}
|
}
|
||||||
reg_write_m(RTL837X_REG_SEC_COUNTER);
|
reg_write_m(RTL837X_REG_SEC_COUNTER);
|
||||||
reg_read_m(RTL837X_REG_SEC_COUNTER);
|
reg_read_m(RTL837X_REG_SEC_COUNTER);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
print_sfr_data();
|
print_sfr_data();
|
||||||
write_char('\n');
|
write_char('\n');
|
||||||
@@ -2045,84 +2052,7 @@ void bootloader(void)
|
|||||||
rtl8372_init();
|
rtl8372_init();
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
<<<<<<< resetbutton
|
|
||||||
check_and_flash_update_image();
|
check_and_flash_update_image();
|
||||||
=======
|
|
||||||
// Check update in progress and move blocks
|
|
||||||
flash_region.addr = FIRMWARE_UPLOAD_START;
|
|
||||||
flash_region.len = 0x100;
|
|
||||||
flash_read_bulk(flash_buf);
|
|
||||||
if (flash_buf[0] == 0x00 && flash_buf[1] == 0x40) {
|
|
||||||
__xdata uint32_t dest = 0x0;
|
|
||||||
__xdata uint32_t source = FIRMWARE_UPLOAD_START;
|
|
||||||
__xdata uint16_t i = 0;
|
|
||||||
__xdata uint16_t j = 0;
|
|
||||||
__xdata uint8_t * __xdata bptr;
|
|
||||||
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;
|
|
||||||
for (i = 0; i < 1024; i++) {
|
|
||||||
flash_region.addr = source;
|
|
||||||
flash_region.len = 0x200;
|
|
||||||
flash_read_bulk(flash_buf);
|
|
||||||
bptr = flash_buf;
|
|
||||||
for (j = 0; j < 0x200; j++) {
|
|
||||||
// print_byte(*bptr); write_char(' ');
|
|
||||||
crc16(bptr++);
|
|
||||||
// print_short(crc_value); write_char(':');
|
|
||||||
}
|
|
||||||
source += 0x200;
|
|
||||||
// write_char('\n'); print_short(crc_value); write_char(' ');
|
|
||||||
if (i%16 == 0)
|
|
||||||
write_char('.');
|
|
||||||
}
|
|
||||||
if (crc_value == 0xb001) {
|
|
||||||
print_string("\nChecksum OK\n");
|
|
||||||
print_string("Update in progress, moving firmware to start of FLASH.");
|
|
||||||
source = FIRMWARE_UPLOAD_START;
|
|
||||||
// A 512kByte = 4MBit Flash has 128*8=1024 512byte blocks, we copy only 896
|
|
||||||
// (don't overwrite config @ 0x700000)
|
|
||||||
for (i = 0; i < 896; i++) {
|
|
||||||
// print_string("Writing block: ");
|
|
||||||
// print_short(dest);
|
|
||||||
flash_region.addr = source;
|
|
||||||
flash_region.len = 0x200;
|
|
||||||
flash_read_bulk(flash_buf);
|
|
||||||
if (!(i & 0x7)) {
|
|
||||||
flash_region.addr = dest;
|
|
||||||
flash_sector_erase();
|
|
||||||
write_char('.');
|
|
||||||
}
|
|
||||||
flash_region.addr = dest;
|
|
||||||
flash_region.len = 0x200;
|
|
||||||
flash_write_bytes(flash_buf);
|
|
||||||
dest += 0x200;
|
|
||||||
source += 0x200;
|
|
||||||
}
|
|
||||||
print_string("\nDeleting uploaded flash image\n");
|
|
||||||
dest = FIRMWARE_UPLOAD_START;
|
|
||||||
for (register uint8_t i=0; i < 128; i++) {
|
|
||||||
flash_region.addr = dest;
|
|
||||||
flash_sector_erase();
|
|
||||||
dest += 0x1000;
|
|
||||||
}
|
|
||||||
print_string("Resetting now");
|
|
||||||
delay(200);
|
|
||||||
reset_chip();
|
|
||||||
}
|
|
||||||
print_string("Checksum incorrect, please upload the image again\n");
|
|
||||||
print_string("Erasing bad uploaded flash image\n");
|
|
||||||
dest = FIRMWARE_UPLOAD_START;
|
|
||||||
for (register uint8_t i=0; i < 128; i++) {
|
|
||||||
flash_region.addr = dest;
|
|
||||||
flash_sector_erase();
|
|
||||||
dest += 0x1000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>>>>>>> main
|
|
||||||
|
|
||||||
#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
|
||||||
|
|||||||
Reference in New Issue
Block a user