cp.rst 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. .. SPDX-License-Identifier: GPL-2.0+:
  2. cp command
  3. ==========
  4. Synopsis
  5. --------
  6. ::
  7. cp source target count
  8. cp.b source target count
  9. cp.w source target count
  10. cp.l source target count
  11. cp.q source target count
  12. Description
  13. -----------
  14. The cp command is used to copy *count* chunks of memory from the *source*
  15. address to the *target* address. If the *target* address points to NOR flash,
  16. the flash is programmed.
  17. The number bytes in one chunk is defined by the suffix defaulting to 4 bytes:
  18. ====== ==========
  19. suffix chunk size
  20. ====== ==========
  21. .b 1 byte
  22. .w 2 bytes
  23. .l 4 bytes
  24. .q 8 bytes
  25. <none> 4 bytes
  26. ====== ==========
  27. source
  28. source address, hexadecimal
  29. target
  30. target address, hexadecimal
  31. count
  32. number of words to be copied, hexadecimal
  33. Examples
  34. --------
  35. The example device has a NOR flash where the lower part of the flash is
  36. protected. We first copy to RAM, then to unprotected flash. Last we try to
  37. write to protectd flash.
  38. ::
  39. => mtd list
  40. List of MTD devices:
  41. * nor0
  42. - device: flash@0
  43. - parent: root_driver
  44. - driver: cfi_flash
  45. - path: /flash@0
  46. - type: NOR flash
  47. - block size: 0x20000 bytes
  48. - min I/O: 0x1 bytes
  49. - 0x000000000000-0x000002000000 : "nor0"
  50. => cp.b 4020000 5000000 200000
  51. => cp.b 4020000 1e00000 20000
  52. Copy to Flash... done
  53. => cp.b 4020000 0 20000
  54. Copy to Flash... Can't write to protected Flash sectors
  55. =>
  56. Configuration
  57. -------------
  58. The cp command is available if CONFIG_CMD_MEMORY=y. Support for 64 bit words
  59. (cp.q) depends on CONFIG_MEM_SUPPORT_64BIT_DATA=y. Copying to flash depends on
  60. CONFIG_MTD_NOR_FLASH=y.
  61. Return value
  62. ------------
  63. The return value $? is set to 0 (true) if the command was successfully,
  64. 1 (false) otherwise.