Skip to content
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
139 changes: 139 additions & 0 deletions docs/fw_binaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,142 @@ extract the FSBL and PMUFW from the complete boot image.
configuration:
* path

## For Rockchip devices

Current implementation of support for the Rockchip SoCs, RAMboot and
SPL DFU are supported.

As there's no implementation for Rockchip USB protocol support, it is
possible to push the DDR init files and SPL files from Rockchip but the next
step will fail.

Mainline u-boot does not support boot from RAM and boot from SPL DFU,
it has to be patched.

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/7).
Copy link

Choose a reason for hiding this comment

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

This branch is using outdated U-Boot RAM-boot patches, please update the MR to use latest version of the series, at the moment v2. Also plan on sending a v3 with a small update next few days/week.


### 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/).
Copy link

Choose a reason for hiding this comment

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

Should probably link to "upstream" https://github.com/rockchip-linux/rkbin tree.

Suggested change
[Rockchip rkbin](https://github.com/radxa/rkbin/tree/develop-v2024.03/).
[Rockchip rkbin](https://github.com/rockchip-linux/rkbin).


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.

The configuration parameters are:

**xpl:** Binary blob generated with bootmerger. For instance, here, ``rk3399_uboot.bin``.
* path: path to the blob

**u-boot-fit:** U-boot FIT image.
* path: Path to the FIT image. Typically, ``u-boot.itb``


### 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:
Copy link

Choose a reason for hiding this comment

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

With the latest U-Boot RK RAM-boot series you should build U-Boot with something like following to produce u-boot-rockchip-usb47X.bin files.

make <board>_defconfig rockchip-ramboot.config


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

These are the files needed to boot from RAM.

The configuration parameters are:

**code471:** File to use for maskrom code 0x471.

configuration:
* path: Path to the ``u-boot-rockchip-usb471.bin`` file
* delay: Optional delay in milliseconds before loading next binary

**code472:** File to use for maskrom code 0x472.

configuration:
* path: Path to the ``u-boot-rockchip-usb472.bin`` file


### 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
Copy link
Contributor

Choose a reason for hiding this comment

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

I encountered an issue while using this configuration. After
recompilation of U-Boot, only my SPL was being updated, i needed to power cycle the board to
be able to update U-Boot Proper.

I found out that the board's DDR was not properly erased after a reset,
thus when using snagrecover with DFU to update both u-boot, SPL was correctly updated but would boot an old u-boot proper instead of retrieving it through DFU, since DFU comes after RAM in SPL boot order.

A solution to this would be to disable U-Boot's configuration option CONFIG_SPL_RAM_DEVICE=n Support booting from preloaded image in RAM.

Could you please add this option to the list along with the explanation that I gave?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, right. On reset/reboot, the RAM is not reset so it'll find the ramboot binary and use it instead of DFU. I've added some notes in the doc about that.

```

On some systems, rebooting the system won't reset the memory content. This means that
booting over DFU after having done a boot from RAM will result in u-boot loading the
Copy link
Contributor

Choose a reason for hiding this comment

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

Hello Arnaud,
thanks for adding a explanation and the solution to my problem.

I think the current explanation might mislead some users. U-Boot SPL will boot a U-Boot proper if it is present in RAM, whether it was put there by "boot from DFU" or by "boot from RAM".

This could lead some users that only use "boot from DFU" to not disable CONFIG_SPL_RAM_DEVICE.

We could maybe write something along the lines of: "This means that booting over DFU when there is already u-boot proper in RAM will boot the later and not download the new one from DFU, e.g. if you run snagrecover two times in a row, u-boot proper might not be updated in these cases"

u-boot version from the boot from RAM boot and won't try to load u-boot over DFU.

To solve this, disable boot from RAM with:

```
# CONFIG_SPL_RAM_DEVICE is not set
```

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``
Copy link

Choose a reason for hiding this comment

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

These mkimage-in-simple-bin.*-files are temporary files generated by binman during building of the final output u-boot-rockchip.bin-file.
This should probably not encourage users to rely on these files as they could be renamed and/or removed as part of a future update of U-Boot.

- ``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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: you're missing a "configuration:" after the "u-boot-fit:" entry.

The configuration parameters are:

**code471:** File to use for maskrom code 0x471.

configuration:
* path: Path to the TPL file. For instance, ``mkimage-in-simple-bin.mkimage-rockchip-tpl``.
Copy link

Choose a reason for hiding this comment

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

mkimage-in-simple-bin.mkimage-rockchip-tpl is a temporary file used by binman and may not be a good example.

* delay: Optional delay in milliseconds before loading next binary

**code472:** File to use for maskrom code 0x472.

configuration:
* path: Path to the SPL. For instance, ``mkimage-in-simple-bin.mkimage-u-boot-spl``.
Copy link

Choose a reason for hiding this comment

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

mkimage-in-simple-bin.mkimage-u-boot-spl is a temporary file used by binman and may not be a good example.

* delay: Optional delay in milliseconds before loading next binary

**u-boot-fit:** U-boot FIT image.
* path: Path to the FIT image. Typically, ``u-boot.itb``
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"
Copy link

Choose a reason for hiding this comment

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

Have you seen a device use PID 2207? What device is this intended to match?

This list is missing the following known PIDs:

  • RV1106/RV1103: 110c
  • RV1103B/RV1106B: 110e
  • RV1126B: 110f
  • RK3528: 350c
  • RK3562: 350d
  • RK3576: 350e
  • RK3506: 350f

You could probably just use ATTRS{idVendor}=="2207" and skip the ATTRS{idProduct} matching.

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",
Copy link

Choose a reason for hiding this comment

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

This is missing RV1106, RV1103B and RV1126B.

Suggested change
"rv1126": "2207:110b",
"rv1126": "2207:110b",
"rv1106": "2207:110c",
"rv1103b": "2207:110e",
"rv1126b": "2207:110f",

"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"
Copy link

Choose a reason for hiding this comment

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

This is missing RK3528, RK3562, RK3576 and RK3506.

Suggested change
"rk3588": "2207:350b"
"rk3588": "2207:350b"
"rk3588": "2207:350b",
"rk3528": "2207:350c",
"rk3562": "2207:350d"
"rk3576": "2207:350e"
"rk3506": "2207:350f"

}
}

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