Heinrich Schuchardt | 40ad2cc | 2023-04-28 08:52:41 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
Heinrich Schuchardt | 1b0c316 | 2024-01-14 14:53:13 +0100 | [diff] [blame] | 3 | .. index:: |
| 4 | single: cp (command) |
| 5 | |
Heinrich Schuchardt | 40ad2cc | 2023-04-28 08:52:41 +0200 | [diff] [blame] | 6 | cp command |
| 7 | ========== |
| 8 | |
| 9 | Synopsis |
| 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 | |
| 20 | Description |
| 21 | ----------- |
| 22 | |
| 23 | The cp command is used to copy *count* chunks of memory from the *source* |
| 24 | address to the *target* address. If the *target* address points to NOR flash, |
Rasmus Villemoes | 477a1c4 | 2024-01-03 11:47:04 +0100 | [diff] [blame] | 25 | the flash is programmed. When the *target* address points at ordinary memory, |
| 26 | memmove() is used, so the two regions may overlap. |
Heinrich Schuchardt | 40ad2cc | 2023-04-28 08:52:41 +0200 | [diff] [blame] | 27 | |
| 28 | The number bytes in one chunk is defined by the suffix defaulting to 4 bytes: |
| 29 | |
| 30 | ====== ========== |
| 31 | suffix 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 | |
| 40 | source |
| 41 | source address, hexadecimal |
| 42 | |
| 43 | target |
| 44 | target address, hexadecimal |
| 45 | |
| 46 | count |
| 47 | number of words to be copied, hexadecimal |
| 48 | |
| 49 | Examples |
| 50 | -------- |
| 51 | |
| 52 | The example device has a NOR flash where the lower part of the flash is |
| 53 | protected. We first copy to RAM, then to unprotected flash. Last we try to |
| 54 | write 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 | |
| 76 | Configuration |
| 77 | ------------- |
| 78 | |
| 79 | The cp command is available if CONFIG_CMD_MEMORY=y. Support for 64 bit words |
Rasmus Villemoes | dd5b958 | 2024-01-03 11:47:10 +0100 | [diff] [blame] | 80 | (cp.q) is only available on 64-bit targets. Copying to flash depends on |
Heinrich Schuchardt | 40ad2cc | 2023-04-28 08:52:41 +0200 | [diff] [blame] | 81 | CONFIG_MTD_NOR_FLASH=y. |
| 82 | |
| 83 | Return value |
| 84 | ------------ |
| 85 | |
| 86 | The return value $? is set to 0 (true) if the command was successfully, |
| 87 | 1 (false) otherwise. |