Skip to main content

Tool for flashing Realtek RTL87xxx Bluetooth SoCs via UART

Project description

rtkprog

Tool for flashing Realtek RTL87xxx Bluetooth SoCs via UART

Installation / Dependencies

Using uv

$ uv sync

Using pip

$ pip install -r requirements.txt

Essential System Images

Before being able to write and run Zephyr application images, some essential system images (such as Bootloader patches, System patches, and Configuration files) must be programmed in advance, which can be downloaded from Zephyr's hal_realtek repository.

Hardware Setup & Auto-Reset

This tool supports auto-reset via serial RTS / DTR lines. This allows switching between bootloader mode and normal application mode in software without physical interaction with the board (e.g. via buttons / switches / jumpers). For this, the following wiring is required:

USB-UART Pin RTL87x2x Pin Pin Name Description
RTS RESET RESET Active-low chip-reset input
DTR P0_3 LOG/BOOT Boot mode select (low = download mode)

Usage

./rtkprog.py --help
usage: rtkprog [-h] [-p PORT] [-b BAUD] [-v | -q] COMMAND ...

Tool for programming Realtek RTL87xxx BT SoCs

positional arguments:
  COMMAND
    write          Write binary file(s) to flash (auto-erases required sectors)
    read           Read flash to file(s)
    erase          Erase flash sections or entire chip (default)
    mac            Read or write the MAC address in flash
    reset          Reset the chip
    terminal       Reset the chip and open bidirectional connection to serial port
    efuse          Read eFuse CRC16 status

options:
  -h, --help       show this help message and exit
  -p, --port PORT  Serial port (default: /dev/ttyUSB0)
  -b, --baud BAUD  Baud rate for binary transfer and terminal (default: 921600).
  -v               Increase verbosity (-v = INFO, -vv = DEBUG)
  -q, --quiet      Suppress all output below ERROR

Flash Write

One or multiple binaries can be written to different flash locations using the format: -w <ADDRESS,SEEK,FILE>

Optionally, a MAC address can be provided with --mac, which will be patched during flashing. Using --mac auto preserves the existing MAC address. Using this parameter can save a write cycle compared to using rtkprog mac --mac XX:XX:XX:XX:XX:XX when the configuration file is being flashed anyway.

The writing process automatically erases the required flash pages before performing the write operation.

./rtkprog.py -v \
    --port /dev/ttyUSB0 \
    --baud 921600 \
    write \
    --mac XX:XX:XX:XX:XX:XX \
    -w 0x4001000,0x200,bin/rtl87x2g/configFile_x.x.x.x-hash.bin \
    -w 0x4002000,0x200,bin/rtl87x2g/BANK0_boot_patch_MP_release_x.x.x.x_hash.bin \
    -w 0x400a000,0x200,bin/rtl87x2g/BANK1_boot_patch_MP_release_x.x.x.x_hash.bin \
    -w 0x4012000,0x200,bin/rtl87x2g/OTAHeader_Bank0_x.x.x.x-hash.bin \
    -w 0x4013000,0x200,bin/rtl87x2g/BANK0_sys_patch_MP_release_x.x.x.x_hash.bin \
    -w 0x401b000,0x200,bin/rtl87x2g/bt_stack_patch_MP_master_x.x.x.x_hash.bin \
    -w 0x402d000,0x0,zephyr.bin

Note: For the system images an offset 0x200 is used, because they contain a 512 bytes header.

Flash Read

The entire flash memory of the chip can be dumped to a file, or specific sections can be read using the following command, format: <ADDRESS,SIZE,FILE>

./rtkprog.py -v \
    --port /dev/ttyUSB0 \
    --baud 921600 \
    read -r 0x4001000,0x1000,image.bin

Flash Erase

Erases one or multiple regions in flash, format: <ADDRESS,SIZE>

./rtkprog.py -v \
    --port /dev/ttyUSB0 \
    erase -r 0x4001000,0x1000

Read MAC Address

Read/write the MAC address.

./rtkprog.py -v \
    --port /dev/ttyUSB0 \
    mac --mac XX:XX:XX:XX:XX:XX

Read eFuse Status

This command can be used to determine if eFuses have been burned (CRC16 = 0xFFFF = not burned).

./rtkprog.py -v \
    --port /dev/ttyUSB0 \
    efuse

License

This software is released under the Apache-2.0 License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rtkprog-0.2.1.tar.gz (108.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rtkprog-0.2.1-py3-none-any.whl (114.7 kB view details)

Uploaded Python 3

File details

Details for the file rtkprog-0.2.1.tar.gz.

File metadata

  • Download URL: rtkprog-0.2.1.tar.gz
  • Upload date:
  • Size: 108.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for rtkprog-0.2.1.tar.gz
Algorithm Hash digest
SHA256 be9762ff67d763d87158ecd6317a501ee4bf1a6e0a222eedad5ef47c08134d81
MD5 a896c8ed5be4e2c51a5ecb02a22a714d
BLAKE2b-256 060f946682544e7d6b12e05db8fbbae1524aeac731fbf42513ad806b9c46a841

See more details on using hashes here.

Provenance

The following attestation bundles were made for rtkprog-0.2.1.tar.gz:

Publisher: build_and_publish.yml on a-labs-io/rtkprog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rtkprog-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: rtkprog-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 114.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for rtkprog-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80299513c7f7d1558b1cf684a64c7da32d2031c35608696e8af49928bffc185c
MD5 fb06247aa2ef23a3ba21408ab65e131e
BLAKE2b-256 73459121c652c9ae8c977da0770320b930a94e0aa879e38f7d64d9eceb37debb

See more details on using hashes here.

Provenance

The following attestation bundles were made for rtkprog-0.2.1-py3-none-any.whl:

Publisher: build_and_publish.yml on a-labs-io/rtkprog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page