Skip to content

Rockchip SoC support #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions docs/fw_binaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,100 @@ extract the FSBL and PMUFW from the complete boot image.
configuration:
* path

## For Rockchip devices

While it is possible to use the DDR init files and SPL files from Rockchip,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really possible to use snagrecover with the prebuilt SPL images from Rockchip? I don't think that's true in the general case, since they don't have DFU support.

it is easier to use the files generated by u-boot as support for the
Rokchip USB protocol is not implemented.
Nevertheless, this means that to boot u-boot proper, u-boot has to be
patched to get support for:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be clear here: using the prebuilt Rockchip SPL images doesn't work with Snagrecover. People have to patch U-Boot and build the images themselves.


- boot from RAM,
- boot from SPL DFU

The patches have been sent to the u-boot mailing list by their authors
and not yet merged. The patches can all be found inside this
[merge request](https://gitlab.collabora.com/hardware-enablement/rockchip-3588/u-boot/-/merge_requests/5).



### Using binary generated by Rockchip's ``boot_merger``

[example](../src/snagrecover/templates/rockchip-merger.yaml)

Snagboot can upload the ``CODE471_OPTION`` and ``CODE472_OPTION`` of a binary
generated with the ``boot_merger`` tool and configuration files from
[Rockchip rkbin](https://github.com/radxa/rkbin/tree/develop-v2024.03/).

In case of u-boot, this would mean to upload the TPL, SPL and then use SPL DFU
to boot u-boot proper (see later section for SPL DFU).

An example configuration for rk3399 would be:
```
[CHIP_NAME]
NAME=RK330C
[VERSION]
MAJOR=1
MINOR=123
[CODE471_OPTION]
NUM=1
Path1=tpl/u-boot-tpl-dtb.bin
Sleep=1
[CODE472_OPTION]
NUM=1
Path1=spl/u-boot-spl-dtb.bin
Sleep=3000
[LOADER_OPTION]
NUM=2
LOADER1=FlashData
LOADER2=FlashBoot
FlashData=spl/u-boot-spl-dtb.bin
FlashBoot=u-boot.itb
[OUTPUT]
PATH=rk3399_uboot.bin
[FLAG]
471_RC4_OFF=false
```

The ``tpl/u-boot-tpl-dtb.bin``, ``spl/u-boot-spl-dtb.bin``, ``u-boot.itb``
files are generated during u-boot's build. Please note has the ``LOADER_OPTION``
is not handled by snagboot.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also include a specification of snagrecover firmware names and parameters in the same format as for the other SoC families in this documentation. I think it's especially important to describe the "delay" parameter.


### Boot from Ram

[example](../src/snagrecover/templates/rockchip-ramboot.yaml)

When building u-boot with the previously mentioned patches, u-boot will generate two files:

- ``u-boot-rockchip-usb471.bin``
- ``u-boot-rockchip-usb472.bin``

These are the files needed to boot from RAM.
On platforms like rk3588 using the TPL from rockchip, some issues will arrive
when booting. It's due to the ``u-boot-rockchip-usb472.bin`` binary overwriting
the ATAGS provided by the TPL. A possible fix would be to patch u-boot with
https://github.com/u-boot/u-boot/commit/a6e85a35b50ade7df5f32092c1cc05ade303a22a.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


### Boot from SPL DFU

[example](../src/snagrecover/templates/rockchip-spl-dfu.yaml)

To enable u-boot with SPL DFU support in the u-boot configuration, ensure that the
following options are enabled:

```
CONFIG_SPL_DM_USB_GADGET=y
CONFIG_SPL_USB_GADGET=y
CONFIG_SPL_DFU=y
```

The (SPL) USB gadget driver needs to be enabled too.

At the end of the build, the following files will be needed:

- ``mkimage-in-simple-bin.mkimage-u-boot-tpl`` or ``mkimage-in-simple-bin.mkimage-rockchip-tpl``
- ``mkimage-in-simple-bin.mkimage-u-boot-spl``
- ``u-boot.itb``

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

18 changes: 18 additions & 0 deletions src/snagrecover/50-snagboot.rules
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,21 @@ SUBSYSTEM=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="d022", MODE="0660"

#Xilinx rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0050", MODE="0660", TAG+="uaccess"

#Rockchip systems
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="2207", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="110a", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="110b", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="300a", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="301a", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="310b", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="310c", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="320a", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="320b", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="320c", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="330a", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="330c", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="330d", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="330e", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="350a", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2207", ATTRS{idProduct}=="350b", MODE="0660", TAG+="uaccess"
19 changes: 19 additions & 0 deletions src/snagrecover/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@
"imx8mm": "1fc9:0134",
"imx8mq": "1fc9:012b",
"imx53" : "15a2:004e",
},
"rockchip": {
"rv1108": "2207:110a",
"rv1126": "2207:110b",
"rk3066": "2207:300a",
"rk3036": "2207:301a",
"rk3188": "2207:310b",
"rk3128": "2207:310c",
"rk3288": "2207:320a",
"rk322x": "2207:320b",
"rk3328": "2207:320c",
"rk3368": "2207:330a",
"rk3399": "2207:330c",
"px30": "2207:330d",
"rk3308": "2207:330e",
"rk3568": "2207:350a",
"rk3588": "2207:350b"
}
}

Expand Down Expand Up @@ -80,6 +97,8 @@ def init_config(args: list):
if args.usb_path is None:
if soc_family == "imx":
usb_ids = default_usb_ids["imx"][soc_model]
elif soc_family == "rockchip":
usb_ids = default_usb_ids["rockchip"][soc_model]
else:
usb_ids = default_usb_ids[soc_family]

Expand Down
3 changes: 3 additions & 0 deletions src/snagrecover/firmware/firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ def run_firmware(port, fw_name: str, subfw_name: str = ""):
elif soc_family == "zynqmp":
from snagrecover.firmware.zynqmp_fw import zynqmp_run
zynqmp_run(port, fw_name, fw_blob, subfw_name)
elif soc_family == "rockchip":
from snagrecover.firmware.rk_fw import rockchip_run
rockchip_run(port, fw_name, fw_blob)
else:
raise Exception(f"Unsupported SoC family {soc_family}")
logger.info(f"Done installing firmware {fw_name}")
Expand Down
Loading