0002-Modify-u-boot-using-partition-for-ICE_C860.patch 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. From 536b9e94711a9d12aa96a125f096ae9e4de3d7e8 Mon Sep 17 00:00:00 2001
  2. From: lihm <koumei.lhm@alibaba-inc.com>
  3. Date: Sun, 18 Apr 2021 14:40:20 +0800
  4. Subject: [PATCH 2/2] Modify u-boot using partition for ICE_C860.
  5. ---
  6. board/thead/ice-c860/Kconfig | 4 ++++
  7. common/bootm.c | 1 +
  8. configs/ice_evb_c860_defconfig | 20 +++++++++++++++-----
  9. drivers/fastboot/fb_mmc.c | 7 ++++++-
  10. fs/fs.c | 3 +++
  11. include/configs/ice-c860.h | 23 +++++++++++++----------
  12. 6 files changed, 42 insertions(+), 16 deletions(-)
  13. diff --git a/board/thead/ice-c860/Kconfig b/board/thead/ice-c860/Kconfig
  14. index f3c8bdf6c8..b00f2bc850 100644
  15. --- a/board/thead/ice-c860/Kconfig
  16. +++ b/board/thead/ice-c860/Kconfig
  17. @@ -21,6 +21,10 @@ config SYS_TEXT_BASE
  18. config SPL_TEXT_BASE
  19. default 0xfe400000
  20. +config SPL_MAX_SIZE
  21. + hex
  22. + default 0x2f000
  23. +
  24. config BOARD_SPECIFIC_OPTIONS
  25. def_bool y
  26. select C860_CSKY
  27. diff --git a/common/bootm.c b/common/bootm.c
  28. index 902c13880d..9493ce8077 100644
  29. --- a/common/bootm.c
  30. +++ b/common/bootm.c
  31. @@ -726,6 +726,7 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
  32. /* check image type, for FIT images get FIT kernel node */
  33. *os_data = *os_len = 0;
  34. buf = map_sysmem(img_addr, 0);
  35. + printf("img_addr: 0x%x, buf: %d\n", img_addr, genimg_get_format(buf));
  36. switch (genimg_get_format(buf)) {
  37. #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
  38. case IMAGE_FORMAT_LEGACY:
  39. diff --git a/configs/ice_evb_c860_defconfig b/configs/ice_evb_c860_defconfig
  40. index 5b662d64a4..326bd5e88c 100644
  41. --- a/configs/ice_evb_c860_defconfig
  42. +++ b/configs/ice_evb_c860_defconfig
  43. @@ -1,11 +1,11 @@
  44. CONFIG_CSKY=y
  45. CONFIG_ENV_SIZE=0x20000
  46. -CONFIG_ENV_OFFSET=0x10000
  47. +CONFIG_ENV_OFFSET=0xe0000
  48. CONFIG_NR_DRAM_BANKS=1
  49. CONFIG_TARGET_ICE_C860=y
  50. -CONFIG_SYS_PROMPT="C860 # "
  51. +CONFIG_SYS_PROMPT="T-HEAD# "
  52. CONFIG_DISTRO_DEFAULTS=y
  53. -CONFIG_FIT=y
  54. +CONFIG_BUILD_TARGET="u-boot-with-spl.bin"
  55. CONFIG_DEFAULT_DEVICE_TREE="ice-c860"
  56. CONFIG_DISPLAY_CPUINFO=y
  57. CONFIG_DISPLAY_BOARDINFO=y
  58. @@ -13,12 +13,23 @@ CONFIG_SYS_NS16550=y
  59. CONFIG_OF_PRIOR_STAGE=y
  60. # CONFIG_BLK is not set
  61. # CONFIG_CMD_FLASH is not set
  62. -CONFIG_ENV_IS_NOWHERE=y
  63. +CONFIG_CMD_ERASEENV=y
  64. +CONFIG_CMD_GPT=y
  65. +# CONFIG_DOS_PARTITION is not set
  66. +# CONFIG_ISO_PARTITION is not set
  67. +CONFIG_PARTITION_TYPE_GUID=y
  68. +CONFIG_OF_EMBED=y
  69. CONFIG_ENV_IS_IN_MMC=y
  70. +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
  71. CONFIG_BOARD_EARLY_INIT_R
  72. CONFIG_BOARD_EARLY_INIT_F
  73. CONFIG_OF_CONTROL=y
  74. CONFIG_CLK=y
  75. +CONFIG_UDP_FUNCTION_FASTBOOT=y
  76. +CONFIG_FASTBOOT_BUF_ADDR=0x82000000
  77. +CONFIG_FASTBOOT_FLASH=y
  78. +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  79. +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
  80. CONFIG_DM_MMC=y
  81. CONFIG_MMC_DW=y
  82. CONFIG_MMC_DW_SNPS=y
  83. @@ -26,7 +37,6 @@ CONFIG_DM_ETH=y
  84. CONFIG_ETH_DESIGNWARE=y
  85. # CONFIG_EFI_LOADER is not set
  86. # CONFIG_SPL_SERIAL_SUPPORT is not set
  87. -# CONFIG_PARTITIONS is not set
  88. # CONFIG_SPL_FRAMEWORK is not set
  89. CONFIG_SPL=y
  90. CONFIG_IS_ASIC=y
  91. diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
  92. index b0b19c5762..fa387d87f3 100644
  93. --- a/drivers/fastboot/fb_mmc.c
  94. +++ b/drivers/fastboot/fb_mmc.c
  95. @@ -66,11 +66,16 @@ static lbaint_t fb_mmc_blk_write(struct blk_desc *block_dev, lbaint_t start,
  96. for (i = 0; i < blkcnt; i += FASTBOOT_MAX_BLK_WRITE) {
  97. cur_blkcnt = min((int)blkcnt - i, FASTBOOT_MAX_BLK_WRITE);
  98. - if (buffer) {
  99. + if (buffer < 0x80000000) {
  100. if (fastboot_progress_callback)
  101. fastboot_progress_callback("writing");
  102. blks_written = blk_dwrite(block_dev, blk, cur_blkcnt,
  103. buffer + (i * block_dev->blksz));
  104. + } else if (buffer >= 0x80000000) {
  105. + if (fastboot_progress_callback)
  106. + fastboot_progress_callback("writing");
  107. + blks_written = blk_dwrite(block_dev, blk, cur_blkcnt,
  108. + buffer - 0x80000000 + (i * block_dev->blksz));
  109. } else {
  110. if (fastboot_progress_callback)
  111. fastboot_progress_callback("erasing");
  112. diff --git a/fs/fs.c b/fs/fs.c
  113. index 0c66d60477..5e8fb82735 100644
  114. --- a/fs/fs.c
  115. +++ b/fs/fs.c
  116. @@ -507,12 +507,15 @@ static int _fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
  117. }
  118. #endif
  119. + printf("[lhm]:_fs_read\n");
  120. /*
  121. * We don't actually know how many bytes are being read, since len==0
  122. * means read the whole file.
  123. */
  124. buf = map_sysmem(addr, len);
  125. + printf("map_sysmem1 0x%x, %d, 0x%x\n", addr, len, *(int*)buf);
  126. ret = info->read(filename, buf, offset, len, actread);
  127. + printf("map_sysmem2 0x%x, %d, 0x%x %d\n", addr, len, *(int*)buf, ret);
  128. unmap_sysmem(buf);
  129. /* If we requested a specific number of bytes, check we got it */
  130. diff --git a/include/configs/ice-c860.h b/include/configs/ice-c860.h
  131. index fdaf931348..5fab909003 100644
  132. --- a/include/configs/ice-c860.h
  133. +++ b/include/configs/ice-c860.h
  134. @@ -94,13 +94,16 @@
  135. #define CONFIG_NET_RETRY_COUNT 20
  136. -#define PHYS_FLASH_1 0x00000000 /* Flash Bank #0 */
  137. -#define CONFIG_SYS_FLASH_BASE PHYS_FLASH_1
  138. +// #define PHYS_FLASH_1 0x00000000 /* Flash Bank #0 */
  139. +// #define CONFIG_SYS_FLASH_BASE PHYS_FLASH_1
  140. +// #define CONFIG_SYS_MAX_FLASH_BANKS 1
  141. +// #define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x070000)
  142. +// #define CONFIG_SYS_MMC_ENV_DEV 0
  143. +#define CONFIG_SYS_FLASH_BASE 0x0
  144. #define CONFIG_SYS_MAX_FLASH_BANKS 1
  145. -#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x070000)
  146. +#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET)
  147. #define CONFIG_SYS_MMC_ENV_DEV 0
  148. -
  149. /* Image address in Flash */
  150. #define FLASH_SPL_READ_ADDR 0x100000 /* 1M */
  151. #define FLASH_SPL_SIZE 0x010000 /* 64K */
  152. @@ -112,10 +115,10 @@
  153. #ifdef CONFIG_IS_ASIC
  154. #define TFTP_LOAD_DTB "tftpboot ${dtb_load_addr_virt} c860/ice_evb.dtb ; "
  155. -#define TFTP_LOAD_SLAVE_DTB "tftpboot ${dtb_load_addr_virt} c810/ice_ck810_evb.dtb ; "
  156. +// #define TFTP_LOAD_SLAVE_DTB "tftpboot ${dtb_load_addr_virt} c810/ice_ck810_evb.dtb ; "
  157. #else
  158. #define TFTP_LOAD_DTB "tftpboot ${dtb_load_addr_virt} c860/ice.dtb ; "
  159. -#define TFTP_LOAD_SLAVE_DTB "tftpboot ${dtb_load_addr_virt} c810/ice_ck810.dtb ; "
  160. +// #define TFTP_LOAD_SLAVE_DTB "tftpboot ${dtb_load_addr_virt} c810/ice_ck810.dtb ; "
  161. #endif
  162. #define CONFIG_EXTRA_ENV_SETTINGS \
  163. @@ -125,9 +128,9 @@
  164. "fdt_size_sector=0x20\0" \
  165. "uboot_start_sector=0xa00\0" /* uboot start sector = FLASH_UBOOT_READ_ADDR / 0x200 */ \
  166. "uboot_size_sector=0x400\0" \
  167. - "dtb_start_sector=0x21000\0" /* dtb start sector */ \
  168. + "dtb_start_sector=0x1000\0" /* dtb start sector */ \
  169. "dtb_size_sector=0x1000\0" /* dtb size in sector -> 2MB */ \
  170. - "linux_start_sector=0x22000\0" /* linux start sector */ \
  171. + "linux_start_sector=0x2000\0" /* linux start sector */ \
  172. "linux_size_sector=0xa000\0" /* linux size in sector -> 20MB */ \
  173. "ramdisk_start_sector=0x2c000\0" /* ramdisk start sector */ \
  174. "ramdisk_size_sector=0x10000\0" /* ramdisk size in sector -> 32MB */ \
  175. @@ -140,6 +143,7 @@
  176. "ramdisk_load_addr_phys=0x02000000\0" \
  177. "avail_addr_virt=0x80000000\0" \
  178. "avail_addr_phy=0x00000000\0" \
  179. + "set_bootargs=setenv bootargs console=ttyS0,115200 root=PARTUUID=$uuid_rootfs rootfstype=ext4 rdinit=/sbin/init rootwait rw earlyprintk clk_ignore_unused loglevel=7 eth=$ethaddr\0" \
  180. "update_fdt=" \
  181. "tftpboot ${dtb_load_addr_virt} c860/dt.dtb ; " \
  182. "setexpr fw_sz ${filesize} / 0x200 ; " \
  183. @@ -177,8 +181,7 @@
  184. #define CONFIG_BOOTCOMMAND \
  185. "mmc read ${dtb_load_addr_phys} ${dtb_start_sector} ${dtb_size_sector} ; " \
  186. "mmc read ${linux_load_addr_phys} ${linux_start_sector} ${linux_size_sector} ; " \
  187. - "mmc read ${ramdisk_load_addr_phys} ${ramdisk_start_sector} ${ramdisk_size_sector} ; " \
  188. - "bootm ${linux_load_addr_virt} - ${dtb_load_addr_virt}"
  189. + "run set_bootargs; bootm ${linux_load_addr_virt} - ${dtb_load_addr_virt}"
  190. #endif /* __CONFIG_H */
  191. --
  192. 2.17.1