Heinrich Schuchardt | 40ad2cc | 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, |
| 22 | the flash is programmed. |
| 23 | |
| 24 | The number bytes in one chunk is defined by the suffix defaulting to 4 bytes: |
| 25 | |
| 26 | ====== ========== |
| 27 | suffix 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 | |
| 36 | source |
| 37 | source address, hexadecimal |
| 38 | |
| 39 | target |
| 40 | target address, hexadecimal |
| 41 | |
| 42 | count |
| 43 | number of words to be copied, hexadecimal |
| 44 | |
| 45 | Examples |
| 46 | -------- |
| 47 | |
| 48 | The example device has a NOR flash where the lower part of the flash is |
| 49 | protected. We first copy to RAM, then to unprotected flash. Last we try to |
| 50 | write 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 | |
| 72 | Configuration |
| 73 | ------------- |
| 74 | |
| 75 | The 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 |
| 77 | CONFIG_MTD_NOR_FLASH=y. |
| 78 | |
| 79 | Return value |
| 80 | ------------ |
| 81 | |
| 82 | The return value $? is set to 0 (true) if the command was successfully, |
| 83 | 1 (false) otherwise. |