Heinrich Schuchardt | feff3e6 | 2023-04-28 08:52:41 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
| 3 | cp command |
| 4 | ========== |
| 5 | |
| 6 | Synopsis |
| 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 | |
| 17 | Description |
| 18 | ----------- |
| 19 | |
| 20 | The cp command is used to copy *count* chunks of memory from the *source* |
| 21 | address to the *target* address. If the *target* address points to NOR flash, |
Rasmus Villemoes | 88a5b32 | 2024-01-03 11:47:04 +0100 | [diff] [blame^] | 22 | the flash is programmed. When the *target* address points at ordinary memory, |
| 23 | memmove() is used, so the two regions may overlap. |
Heinrich Schuchardt | feff3e6 | 2023-04-28 08:52:41 +0200 | [diff] [blame] | 24 | |
| 25 | The number bytes in one chunk is defined by the suffix defaulting to 4 bytes: |
| 26 | |
| 27 | ====== ========== |
| 28 | suffix 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 | |
| 37 | source |
| 38 | source address, hexadecimal |
| 39 | |
| 40 | target |
| 41 | target address, hexadecimal |
| 42 | |
| 43 | count |
| 44 | number of words to be copied, hexadecimal |
| 45 | |
| 46 | Examples |
| 47 | -------- |
| 48 | |
| 49 | The example device has a NOR flash where the lower part of the flash is |
| 50 | protected. We first copy to RAM, then to unprotected flash. Last we try to |
| 51 | write 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 | |
| 73 | Configuration |
| 74 | ------------- |
| 75 | |
| 76 | The 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 |
| 78 | CONFIG_MTD_NOR_FLASH=y. |
| 79 | |
| 80 | Return value |
| 81 | ------------ |
| 82 | |
| 83 | The return value $? is set to 0 (true) if the command was successfully, |
| 84 | 1 (false) otherwise. |