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