README.mflash 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. This document describes m[g]flash support in u-boot.
  2. Contents
  3. 1. Overview
  4. 2. Porting mflash driver
  5. 3. Mflash command
  6. 4. Misc.
  7. 1. Overview
  8. Mflash and gflash are embedded flash drive. The only difference is mflash is
  9. MCP(Multi Chip Package) device. These two device operate exactly same way.
  10. So the rest mflash repersents mflash and gflash altogether.
  11. 2. Porting mflash driver
  12. 2-1. Board configuration
  13. * Mflash driver support
  14. #define CONFIG_CMD_MG_DISK
  15. #define CONFIG_LIBATA
  16. * Environment variable support (optional)
  17. #define CONFIG_ENV_IS_IN_MG_DISK
  18. Also CONFIG_ENV_ADDR and CONFIG_ENV_SIZE should be defined.
  19. CONFIG_ENV_ADDR is byte offset starting from 0.
  20. Following example sets environment variable location to 0x80000 (1024'th
  21. sector) and size of 0x400 (1024 byte)
  22. #define CONFIG_ENV_ADDR 0x80000
  23. #define CONFIG_ENV_SIZE 0x400
  24. * Reserved size config (optional)
  25. If you want to use some reserved area for bootloader, environment variable or
  26. whatever, use CONFIG_MG_DISK_RES. The unit is KB. Mflash's block operation
  27. method use this value as start offset. So any u-boot's partition table parser
  28. and file system command work consistently. You can access this area by using
  29. mflash command.
  30. Following example sets 10MB of reserved area.
  31. #define CONFIG_MG_DISK_RES 10240
  32. 2-2. Porting mg_get_drv_data function
  33. Mflash is active device and need some gpio control for proper operation.
  34. This board dependency resolved by using mg_get_drv_data function.
  35. Port this function at your board init file. See include/mg_disk.h
  36. Here is some pseudo example.
  37. static void custom_hdrst_pin (u8 level)
  38. {
  39. if (level)
  40. /* set hard reset pin to high */
  41. else
  42. /* set hard reset pin to low */
  43. }
  44. static void custom_ctrl_pin_init (void)
  45. {
  46. /* Set hard reset, write protect, deep power down pins
  47. * to gpio.
  48. * Set these pins to output high
  49. */
  50. }
  51. struct mg_drv_data* mg_get_drv_data (void)
  52. {
  53. static struct mg_drv_data prv;
  54. prv.base = /* base address of mflash */
  55. prv.mg_ctrl_pin_init = custom_ctrl_pin_init;
  56. prv.mg_hdrst_pin = custom_hdrst_pin;
  57. return &prv;
  58. }
  59. 3. Mflash command
  60. * initialize : mgd init
  61. * random read : mgd read [from] [to] [size]
  62. ex) read 256 bytes from 0x300000 of mflash to 0xA0100000 of host memory
  63. mgd read 0x300000 0xA0100000 256
  64. * random write : mgd write [from] [to] [size]
  65. * sector read : mgd readsec [sector] [to] [count]
  66. ex) read 10 sectors starts from 400 sector to 0xA0100000
  67. mgd readsec 400 0xA0100000 10
  68. * sector write : mgd writesec [from] [sector] [count]
  69. 4. Misc.
  70. Mflash's device interface name for block driver is "mgd".
  71. Here is ext2 file system access example.
  72. mgd init
  73. ext2ls mgd 0:1 /boot
  74. ext2load mgd 0:1 0xa0010000 /boot/uImage 1954156