README.mediatek 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. # SPDX-License-Identifier: GPL-2.0+
  2. #
  3. # Copyright (C) 2018 MediaTek Inc.
  4. # Ryder Lee <ryder.lee@kernel.org>
  5. This document describes how to compile the U-Boot and how to change U-Boot
  6. configuration about the MediaTek SoCs.
  7. Build Procedure
  8. ===============
  9. -Set the cross compiler:
  10. # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
  11. -Clean-up old residuals:
  12. # make mrproper
  13. -Configure the U-Boot:
  14. # make <defconfig_file>
  15. # make
  16. - For the MT7623n bananapi R2 board use "mt7623n_bpir2_defconfig"
  17. - For the MT7629 reference board use "mt7629_rfb_defconfig"
  18. Boot sequence
  19. =============
  20. -Bootrom -> MTK preloader -> U-Boot
  21. - MT7623n
  22. This version of U-Boot doesn't implement SPL. So, MTK preloader binary
  23. is needed to boot up:
  24. https://github.com/BPI-SINOVOIP/BPI-R2-bsp/tree/master/mt-pack/mtk/bpi-r2/bin
  25. -Bootrom -> SPL -> U-Boot
  26. - MT7629
  27. Configuration update
  28. ====================
  29. To update the U-Boot configuration, please refer to doc/README.kconfig
  30. MediaTek image header
  31. =====================
  32. Currently there are two image headers used for MediaTek chips:
  33. - BootROM image header. This header is used by the first stage bootloader. It records
  34. the desired compatible boot device, integrity information and its load address.
  35. The on-chip BootROM will firstly verify integrity and compatibility of the bootloader.
  36. If verification passed, the BootROM will then load the bootloader into on-chip SRAM,
  37. and pass control to it.
  38. Note that this header is actually a combination of three independent headers:
  39. Device header, BRLYT header and GFH header.
  40. Used by U-Boot SPL of MT7629 and preloader of MT7623.
  41. - MediaTek legacy image header. This header was originally used by the legacy image. It
  42. basically records the load address, image size and image name.
  43. After all low level initializations passed, the preloader will locate the LK image and
  44. load it into DRAM, and pass control to it.
  45. Now this header is used by U-Boot of MT7623.
  46. To generate these two headers with mkimage:
  47. # mkimage -T mtk_image -a <load_addr> -n <option_string> -d <input_file> <image_file>
  48. - mtk_image means using MediaTek's header generation method.
  49. - load_addr is the load address of this image.
  50. For first stage bootloader like U-Boot SPL or preloader, it usually points to the
  51. on-chip SRAM.
  52. For second stage bootloader like U-Boot, it usually points to the DRAM.
  53. - option_string contains options to generate the header.
  54. The option string is using the follow format:
  55. key1=value1;key2=value2;...
  56. The following key names are valid:
  57. lk: If lk=1, LK image header is used. Otherwise BootROM image header is used.
  58. lkname: The name of the LK image header. The maximum length is 32.
  59. The default value is "U-Boot".
  60. media: Desired boot device. The valid values are:
  61. nand : Parallel NAND
  62. snand: Serial NAND
  63. nor : Serial NOR
  64. emmc : eMMC
  65. sdmmc: SD
  66. nandinfo: Desired NAND device type, a combination of page size, oob size and
  67. optional device capacity. Valid types are:
  68. 2k+64 : for Serial NAND, 2KiB page size + 64B oob size
  69. 2k+120 : for Serial NAND, 2KiB page size + 120B oob size
  70. 2k+128 : for Serial NAND, 2KiB page size + 128B oob size
  71. 4k+256 : for Serial NAND, 4KiB page size + 256B oob size
  72. 1g:2k+64 : for Parallel NAND, 2KiB page size + 64B oob size, total 1Gbit size
  73. 2g:2k+64 : for Parallel NAND, 2KiB page size + 64B oob size, total 2Gbit size
  74. 4g:2k+64 : for Parallel NAND, 2KiB page size + 64B oob size, total 4Gbit size
  75. 2g:2k+128: for Parallel NAND, 2KiB page size + 128B oob size, total 2Gbit size
  76. 4g:2k+128: for Parallel NAND, 2KiB page size + 128B oob size, total 4Gbit size
  77. MT7629 partitions on Serial NOR
  78. ===============================
  79. Start End Size Description
  80. 00000000 - 0000ffff: 64KiB U-Boot SPL
  81. 00010000 - 0005ffff: 320KiB U-Boot
  82. 00060000 - 0006ffff: 64KiB U-Boot env / MediaTek NVRAM
  83. 00070000 - 000affff: 256KiB RF calibration data
  84. 000b0000 - xxxxxxxx: all left Firmware image
  85. BPi-R2 (MT7623N) partitions on SD
  86. =================================
  87. Please note that the last two partitions can vary from different Linux distributions
  88. depending on the MBR partition table.
  89. Start End Size Description
  90. 00000000 - 000001ff: 512B Device header (with MBR partition table)
  91. 00000200 - 000007ff: 1536B BRLYT header
  92. 00000800 - 0004ffff: 318KiB Preloader (with GFH header)
  93. 00050000 - 000fffff: 704KiB U-Boot
  94. 00100000 - 063fffff: 99MiB Reserved
  95. 06400000 - 163fffff: 256MiB Partition 1 (FAT32)
  96. 16400000 - xxxxxxxx: all left Partition 2 (ext4)
  97. Upgrading notice on Serial NOR
  98. ==============================
  99. Example: MT7629
  100. The command sf is used to operate the Serial NOR device:
  101. - To probe current NOR flash:
  102. # sf probe
  103. - To erase a region:
  104. # sf erase <offset> <len>
  105. - To write data to an offset:
  106. # sf write <data_addr> <offset> <len>
  107. - To boot kernel:
  108. # bootm 0x300b0000
  109. The memory address range 0x30000000 - 0x3fffffff is mapped to the NOR flash.
  110. The DRAM starts at 0x40000000.
  111. Please note that the output binary u-boot-mtk.bin is a combination of SPL and U-Boot,
  112. and it should be write to beginning of the flash.
  113. Otherwise you should use standalone files:
  114. spl/u-boot-spl-mtk.bin for SPL,
  115. u-boot.img for U-Boot.
  116. Upgrading notice on SD / eMMC
  117. =============================
  118. Example: MT7623
  119. Normally only Preloader and U-Boot can be upgraded within U-Boot, and other partitions
  120. should be written in PC.
  121. - To probe current SD card / eMMC:
  122. # mmc dev 0 for eMMC
  123. # mmc dev 1 for SD
  124. - To erase a region:
  125. # mmc erase <blk_offset> <blk_num>
  126. - To write data to a block offset:
  127. # mmc write <data_addr> <blk_offset> <blk_num>
  128. - To load kernel image from partition 1:
  129. # fatload mmc 0:1 <load_address> <path_to_kernel_uImage> for eMMC
  130. # fatload mmc 1:1 <load_address> <path_to_kernel_uImage> for SD
  131. - To boot kernel:
  132. # bootm <load_address>
  133. The DRAM starts at 0x80000000.
  134. Please note that we use block offset and block count for SD card, not the byte offset.
  135. The block size is always 512 bytes for SD card.
  136. Documentation
  137. =============
  138. http://wiki.banana-pi.org/Banana_Pi_BPI-R2