Files
rtl8710_openocd/README.md
2024-12-04 06:58:11 +06:00

114 lines
3.0 KiB
Markdown

# RTL-8710 openocd support
OpenOCD support for RTL8710 and integrated flash.
Uses and links against ROM functions, they're there anyway so whatever, we get a smaller flasher binary and codebase this way too.
## pins:
### SWD
- SWDIO: GE3
- SWCLK: GE4
### JTAG
- TRST: GE0
- TDI: GE1
- TDO: GE2
- TMS: GE3
- TCK: GE4
## building:
```
make
```
# RTL8710 OpenOCD Commands
### Core Functions
- `rtl8710_flasher_init`
init flasher, loads firmware and reads flash ID to determine capacity
- `rtl8710_flasher_mrw [reg]`
reads 32-bit value from specified register
- `rtl8710_flasher_wait`
polls control register at `buffer + 0x00` until operation completes
- `rtl8710_flasher_load_block [filename] [offset] [length]`
loads data block from file into buffer at `buffer + 0x20`
- `rtl8710_flasher_block [command] [offset] [len]`
internal function for read/write/verify operations. Command must be `"read"`, `"write"` or `"verify"`
### Block Operations
- `rtl8710_flasher_read_block [offset] [len]`
reads block from flash into buffer
- `rtl8710_flasher_write_block [offset] [len]`
writes buffer contents to flash
- `rtl8710_flasher_verify_block [offset] [len]`
verifies flash contents against buffer
### Flash Commands
- `rtl8710_flash_read_id`
reads JEDEC ID and displays manufacturer ID, memory type and capacity
- `rtl8710_flash_read_mac`
reads MAC address from flash offset `0xA088`
- `rtl8710_flash_erase [type] [offset]`
erases flash memory. Type must be `"mass"` or `"sector"`. For sector erase, specify offset
- `rtl8710_flash_mass_erase`
performs mass erase of entire flash chip
- `rtl8710_flash_sector_erase [offset]`
erases single sector at specified offset
- `rtl8710_flash_read [filename] [offset] [size]`
reads `size` bytes from flash at `offset` to `filename`
- `rtl8710_flash_write [filename] [offset]`
writes file to flash at `offset`, using configured buffer size chunks
- `rtl8710_flash_verify [filename] [offset]`
verifies flash contents against file at `offset`, using configured buffer size chunks
### Configuration
- `rtl8710_flash_auto_erase [1/0]`
enables/disables automatic sector erase before write operations
- `rtl8710_flash_auto_verify [1/0]`
enables/disables automatic verification after write operations
### System Control
- `rtl8710_reboot`
triggers system reboot by writing `0x05FA0007` to AIRCR register @ `0xE000ED0C`
## Example Usage
```bash
# Read 1MB from flash
openocd -f interface/stlink-v2-1.cfg -f rtl8710.ocd -c "init" -c "reset halt" \
-c "rtl8710_flash_read_id" -c "rtl8710_flash_read dump.bin 0 1048576" -c "shutdown"
# write to flash with auto erase/verify
openocd -f interface/stlink-v2-1.cfg -f rtl8710.ocd -c "init" -c "reset halt" \
-c "rtl8710_flash_auto_erase 1" -c "rtl8710_flash_auto_verify 1" \
-c "rtl8710_flash_write dump.bin 0" -c "shutdown"
```
# About
RTL8710 OpenOCD support based on work by Rebane (rebane@alkohol.ee)
This document and the attached source code is released under GPLv2.