blob: 12a24e19fee6dad8dace074bddc058aa21075031 [file] [log] [blame]
Heinrich Schuchardt40ad2cc2023-04-28 08:52:41 +02001.. SPDX-License-Identifier: GPL-2.0+:
2
3cp command
4==========
5
6Synopsis
7--------
8
9::
10
11 cp source target count
12 cp.b source target count
13 cp.w source target count
14 cp.l source target count
15 cp.q source target count
16
17Description
18-----------
19
20The cp command is used to copy *count* chunks of memory from the *source*
21address to the *target* address. If the *target* address points to NOR flash,
22the flash is programmed.
23
24The number bytes in one chunk is defined by the suffix defaulting to 4 bytes:
25
26====== ==========
27suffix chunk size
28====== ==========
29.b 1 byte
30.w 2 bytes
31.l 4 bytes
32.q 8 bytes
33<none> 4 bytes
34====== ==========
35
36source
37 source address, hexadecimal
38
39target
40 target address, hexadecimal
41
42count
43 number of words to be copied, hexadecimal
44
45Examples
46--------
47
48The example device has a NOR flash where the lower part of the flash is
49protected. We first copy to RAM, then to unprotected flash. Last we try to
50write to protectd flash.
51
52::
53
54 => mtd list
55 List of MTD devices:
56 * nor0
57 - device: flash@0
58 - parent: root_driver
59 - driver: cfi_flash
60 - path: /flash@0
61 - type: NOR flash
62 - block size: 0x20000 bytes
63 - min I/O: 0x1 bytes
64 - 0x000000000000-0x000002000000 : "nor0"
65 => cp.b 4020000 5000000 200000
66 => cp.b 4020000 1e00000 20000
67 Copy to Flash... done
68 => cp.b 4020000 0 20000
69 Copy to Flash... Can't write to protected Flash sectors
70 =>
71
72Configuration
73-------------
74
75The cp command is available if CONFIG_CMD_MEMORY=y. Support for 64 bit words
76(cp.q) depends on CONFIG_MEM_SUPPORT_64BIT_DATA=y. Copying to flash depends on
77CONFIG_MTD_NOR_FLASH=y.
78
79Return value
80------------
81
82The return value $? is set to 0 (true) if the command was successfully,
831 (false) otherwise.