Skip to content

RK3399 board support crate for AP, and tools to aid with development - generate SVDs, build clock trees, etc.

Notifications You must be signed in to change notification settings

ahixon/rk3399-tools

Repository files navigation

rk3399-tools

RK3399 board support crate for AP, and tools to aid with development - generate SVDs, build clock trees, etc.

Generating SVDs

Builds the SVD for for the AP core (A72 + A53) or the embedded Cortex M0 core in the RK3399.

Dependencies

python3 -m venv env
source env/bin/activate

python3 -m pip install lxml pycparser

Usage

python3 gen-svd.py <ap|m0> <target.svd>

Uses data/rk3399-part1.xml and data/rk3399-part2.xml as source data for the SVD fields and registers.

I believe these were generated by using pdftoxml on the original PDF datasheets. Currently they are v1.3, but v1.4 of Part 1 is available online.

Also uses data/peripheral_map.txt which should correspond to section 1.1 Address Mapping of the TRM.

Fields defined data/fields.json provide mapping of bit descriptions to field names in the SVD.

Depending on the selected core, the following will be different:

  • CPU
  • bus width
  • number of interrupts
  • peripherals will be mapped to the correct address (see load_map and the commends at the top of data/peripheral_map.txt).

Clock explorer

Allows you to browse the clock tree and gates in a map, disable/enable particular gates and their dependencies.

The UI needs some love, and the map will often show multiple nodes on top of each other. Drag it to move it out of the way.

Double clicking a clock will disable it in the map, and all downstream clocks. It will not let you enable clocks where the parent is disabled.

You can save the state by doing a GET /state/dump/<fname>, and hydrate the clock tree state using GET /state/load/<fname>.

You can also use the following APIs to:

  • GET /clocks/all
  • GET /clocks/<clkname> - gets a particular clock's state
  • POST /clocks/<clkname> - toggles the gate; pass a JSON object with gateEnabled set to whatever you want

Dependencies and usage

python3 -m pip install flask
python3 -m flask --app clkbrowse run

and to generate the source clocks.json file, which contains the clock tree data:

python3 genjson.py

The data files come from the TRM, specifically the tables in 2.3 System Clock Solution and friends.

Clock dumper/loader

python3 clktool.py
  • will generate clock_dump.rs, which creates a Rust program that dumps the current clock tree into a format that can be loaded into the clock explorer (see above)
  • loads a dump file called mostoff.txt and generates clock_init.rs, which is a Rust program that sets up clocks as per your dump file.

About

RK3399 board support crate for AP, and tools to aid with development - generate SVDs, build clock trees, etc.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages