blob: 67360e30e41b80f6c6305c7ef78ebf161a81030a [file] [log] [blame]
Heinrich Schuchardtfeff3e62023-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,
Rasmus Villemoes88a5b322024-01-03 11:47:04 +010022the flash is programmed. When the *target* address points at ordinary memory,
23memmove() is used, so the two regions may overlap.
Heinrich Schuchardtfeff3e62023-04-28 08:52:41 +020024
25The number bytes in one chunk is defined by the suffix defaulting to 4 bytes:
26
27====== ==========
28suffix chunk size
29====== ==========
30.b 1 byte
31.w 2 bytes
32.l 4 bytes
33.q 8 bytes
34<none> 4 bytes
35====== ==========
36
37source
38 source address, hexadecimal
39
40target
41 target address, hexadecimal
42
43count
44 number of words to be copied, hexadecimal
45
46Examples
47--------
48
49The example device has a NOR flash where the lower part of the flash is
50protected. We first copy to RAM, then to unprotected flash. Last we try to
51write to protectd flash.
52
53::
54
55 => mtd list
56 List of MTD devices:
57 * nor0
58 - device: flash@0
59 - parent: root_driver
60 - driver: cfi_flash
61 - path: /flash@0
62 - type: NOR flash
63 - block size: 0x20000 bytes
64 - min I/O: 0x1 bytes
65 - 0x000000000000-0x000002000000 : "nor0"
66 => cp.b 4020000 5000000 200000
67 => cp.b 4020000 1e00000 20000
68 Copy to Flash... done
69 => cp.b 4020000 0 20000
70 Copy to Flash... Can't write to protected Flash sectors
71 =>
72
73Configuration
74-------------
75
76The cp command is available if CONFIG_CMD_MEMORY=y. Support for 64 bit words
77(cp.q) depends on CONFIG_MEM_SUPPORT_64BIT_DATA=y. Copying to flash depends on
78CONFIG_MTD_NOR_FLASH=y.
79
80Return value
81------------
82
83The return value $? is set to 0 (true) if the command was successfully,
841 (false) otherwise.