blob: 1481380ba6c57c17bf8b246fb9c94147a648ab0b [file] [log] [blame]
Johan Jonkerb46f0612023-10-18 16:02:19 +02001.. SPDX-License-Identifier: GPL-2.0+
2.. Copyright (C) 2023 Johan Jonker <jbx6244@gmail.com>
3
4RKMTD
5=====
6
7Info
8----
9
10The command rkmtd creates a virtual block device to transfer
11Rockchip boot block data to and from NAND with block orientated
12tools like "ums" and "rockusb".
13
14It uses the Rockchip MTD driver to scan for boot blocks and copies
15data from the first block in a GPT formatted virtual disk.
16Data must be written in U-boot "idbloader.img" format and start at
17partition "loader1" offset 64. The data header is parsed
18for length and offset. When the last sector is received
19it erases up to 5 erase blocks on NAND and writes boot blocks
20in a pattern depending on the NAND ID. Data is then verified.
21When a block turns out bad the block header is discarded.
22
23Limitations
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
31Available 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
41U-boot settings
42---------------
43
44Config 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
54Option to keep existing NAND data unchanged:
55
56.. code-block:: bash
57
58 CONFIG_ROCKCHIP_NAND_SKIP_BBTSCAN=y
59
60Commands 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
69Linux 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 ==================== ============================================