diff --git a/Makefile b/Makefile index 5ae74df..26bfc5c 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ clean: test: openocd -f interface/stlink-v2-1.cfg -f script/rtl8710.ocd -c "init" -c "reset halt" -c "rtl8710_flash_read_id" -c "shutdown" +mac: + openocd -f interface/stlink-v2-1.cfg -f script/rtl8710.ocd -c "init" -c "reset halt" -c "rtl8710_flash_read_mac" -c "shutdown" + dump: openocd -f interface/stlink-v2-1.cfg -f script/rtl8710.ocd -c "init" -c "reset halt" -c "rtl8710_flash_read_id" -c "rtl8710_flash_read dump.bin 0 1048576" -c "shutdown" diff --git a/rtl8710_flasher.tcl b/rtl8710_flasher.tcl index ea061c7..b0ea0b4 100644 --- a/rtl8710_flasher.tcl +++ b/rtl8710_flasher.tcl @@ -5,6 +5,8 @@ set rtl8710_flasher_command_read 3 set rtl8710_flasher_command_write 4 set rtl8710_flasher_command_verify 5 +set rtl8710_flasher_mac_address_offset 0xA088 + set rtl8710_flasher_ready 0 set rtl8710_flasher_capacity 0 set rtl8710_flasher_auto_erase 0 @@ -208,6 +210,23 @@ proc rtl8710_flash_verify {local_filename loc} { } } +proc rtl8710_flash_read_mac {} { + global rtl8710_flasher_mac_address_offset + global rtl8710_flasher_buffer + rtl8710_flasher_init + rtl8710_flasher_read_block $rtl8710_flasher_mac_address_offset 6 + set mac "" + mem2array mac 8 [expr {$rtl8710_flasher_buffer + 0x20}] 6 + set res "MAC address: " + append res [format %02X $mac(0)] + append res ":" [format %02X $mac(1)] + append res ":" [format %02X $mac(2)] + append res ":" [format %02X $mac(3)] + append res ":" [format %02X $mac(4)] + append res ":" [format %02X $mac(5)] + echo $res +} + proc rtl8710_flash_auto_erase {on} { global rtl8710_flasher_auto_erase if {[expr {$on != 0}]} { diff --git a/script/rtl8710.ocd b/script/rtl8710.ocd index c2f78e8..2a3f1c5 100644 --- a/script/rtl8710.ocd +++ b/script/rtl8710.ocd @@ -101,6 +101,8 @@ set rtl8710_flasher_command_read 3 set rtl8710_flasher_command_write 4 set rtl8710_flasher_command_verify 5 +set rtl8710_flasher_mac_address_offset 0xA088 + set rtl8710_flasher_ready 0 set rtl8710_flasher_capacity 0 set rtl8710_flasher_auto_erase 0 @@ -304,6 +306,23 @@ proc rtl8710_flash_verify {local_filename loc} { } } +proc rtl8710_flash_read_mac {} { + global rtl8710_flasher_mac_address_offset + global rtl8710_flasher_buffer + rtl8710_flasher_init + rtl8710_flasher_read_block $rtl8710_flasher_mac_address_offset 6 + set mac "" + mem2array mac 8 [expr {$rtl8710_flasher_buffer + 0x20}] 6 + set res "MAC address: " + append res [format %02X $mac(0)] + append res ":" [format %02X $mac(1)] + append res ":" [format %02X $mac(2)] + append res ":" [format %02X $mac(3)] + append res ":" [format %02X $mac(4)] + append res ":" [format %02X $mac(5)] + echo $res +} + proc rtl8710_flash_auto_erase {on} { global rtl8710_flasher_auto_erase if {[expr {$on != 0}]} {