Johan Jonker | b46f061 | 2023-10-18 16:02:19 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | .. Copyright (C) 2023 Johan Jonker <jbx6244@gmail.com> |
| 3 | |
| 4 | RKMTD |
| 5 | ===== |
| 6 | |
| 7 | Info |
| 8 | ---- |
| 9 | |
| 10 | The command rkmtd creates a virtual block device to transfer |
| 11 | Rockchip boot block data to and from NAND with block orientated |
| 12 | tools like "ums" and "rockusb". |
| 13 | |
| 14 | It uses the Rockchip MTD driver to scan for boot blocks and copies |
| 15 | data from the first block in a GPT formatted virtual disk. |
| 16 | Data must be written in U-boot "idbloader.img" format and start at |
| 17 | partition "loader1" offset 64. The data header is parsed |
| 18 | for length and offset. When the last sector is received |
| 19 | it erases up to 5 erase blocks on NAND and writes boot blocks |
| 20 | in a pattern depending on the NAND ID. Data is then verified. |
| 21 | When a block turns out bad the block header is discarded. |
| 22 | |
| 23 | Limitations |
| 24 | ----------- |
| 25 | |
| 26 | - Support with CONFIG_ROCKCHIP_NAND MTD driver only. |
| 27 | - Support for Rockchip boot block header type 1 only. |
| 28 | - Pattern for listed NAND IDs only. (Logic still not disclosed by Rockchip) |
| 29 | - The MTD framework driver data and NAND ID must be extracted at a lower level. |
| 30 | |
| 31 | Available rkmtd commands |
| 32 | ------------------------ |
| 33 | |
| 34 | .. code-block:: bash |
| 35 | |
| 36 | rkmtd bind <label> - bind RKMTD device |
| 37 | rkmtd unbind <label> - unbind RKMTD device |
| 38 | rkmtd info [<label>] - show all available RKMTD devices |
| 39 | rkmtd dev [<label>] - show or set current RKMTD device |
| 40 | |
| 41 | U-boot settings |
| 42 | --------------- |
| 43 | |
| 44 | Config to enable Rockchip MTD support: |
| 45 | |
| 46 | .. code-block:: bash |
| 47 | |
| 48 | CONFIG_MTD=y |
| 49 | CONFIG_MTD_RAW_NAND=y |
| 50 | CONFIG_SYS_NAND_DRIVER_ECC_LAYOUT=y |
| 51 | CONFIG_SYS_NAND_USE_FLASH_BBT=y |
| 52 | CONFIG_ROCKCHIP_NAND=y |
| 53 | |
| 54 | Option to keep existing NAND data unchanged: |
| 55 | |
| 56 | .. code-block:: bash |
| 57 | |
| 58 | CONFIG_ROCKCHIP_NAND_SKIP_BBTSCAN=y |
| 59 | |
| 60 | Commands to enable: |
| 61 | |
| 62 | .. code-block:: bash |
| 63 | |
| 64 | CONFIG_CMD_USB=y |
| 65 | CONFIG_CMD_RKMTD=y |
| 66 | CONFIG_CMD_ROCKUSB=y |
| 67 | CONFIG_CMD_USB_MASS_STORAGE=y |
| 68 | |
| 69 | Linux Host (PC) tool commands combinations that work |
| 70 | ---------------------------------------------------- |
| 71 | |
| 72 | .. table:: |
| 73 | :widths: 20 44 |
| 74 | |
| 75 | ==================== ============================================ |
| 76 | U-boot Linux |
| 77 | ==================== ============================================ |
| 78 | rkmtd bind 0 |
| 79 | rockusb 0 rkmtd 0 |
| 80 | upgrade_tool pl |
| 81 | |
| 82 | upgrade_tool rl 64 512 idbloader_backup.img |
| 83 | |
| 84 | upgrade_tool wl 64 idbloader.img |
| 85 | |
| 86 | upgrade_tool rd |
| 87 | |
| 88 | rkdeveloptool ppt |
| 89 | |
| 90 | rkdeveloptool rl 64 512 idbloader_backup.img |
| 91 | |
| 92 | rkdeveloptool wlx loader1 idbloader.img |
| 93 | |
| 94 | rkdeveloptool wl 64 idbloader.img |
| 95 | |
| 96 | rkdeveloptool rd |
| 97 | |
| 98 | rkflashtool r 64 512 > idbloader_backup.img |
| 99 | |
| 100 | rkflashtool w 64 512 < idbloader.img |
| 101 | ums 0 rkmtd 0 |
| 102 | dd if=/dev/sda1 of=idbloader_backup.img |
| 103 | |
| 104 | dd if=idbloader.img of=/dev/sda1 |
| 105 | ==================== ============================================ |