CMakeLists.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. # Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. # All rights reserved.
  3. #
  4. # This software is supplied "AS IS" without any warranties.
  5. # RDA assumes no responsibility or liability for the use of the software,
  6. # conveys no license or title under any patent, copyright, or mask work
  7. # right to the product. RDA reserves the right to make changes in the
  8. # software without notification. RDA also make no representation or
  9. # warranty that such application will be suitable for the specified use
  10. # without further testing or modification.
  11. configure_file(include/boot_config.h.in ${out_inc_dir}/boot_config.h)
  12. install_headers(include/image_header.h OUTPUT ${out_inc_dir})
  13. if(CONFIG_SOC_8910)
  14. set(target bootloader)
  15. add_library(${target} STATIC
  16. 8910/boot_platform.c
  17. 8910/boot_secure.c
  18. src/boot_entry_v7a.S
  19. src/boot_sffs_port.c
  20. src/boot_delay.c
  21. src/boot_mem.c
  22. src/boot_spi_flash.c
  23. src/boot_debuguart.c
  24. src/boot_trace.c
  25. src/boot_fdl.c
  26. src/boot_fdl_dnld.c
  27. src/boot_aes.c
  28. src/boot_vfs.c
  29. src/boot_irq_gic.c
  30. src/boot_timer.c
  31. src/boot_uart.c
  32. src/boot_uart_cmn.c
  33. src/boot_mmu.c
  34. src/boot_uimage.c
  35. src/boot_udc.c
  36. src/boot_usb_fdl_channel.c
  37. src/boot_pdl.c
  38. src/boot_pdl_uimage.c
  39. src/boot_lcd.c
  40. src/boot_unity.c
  41. src/boot_override.c
  42. )
  43. set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${out_lib_dir})
  44. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  45. target_include_directories(${target} PUBLIC include)
  46. target_link_libraries(${target} PRIVATE calclib boot_calclib_crc)
  47. target_include_targets(${target} PRIVATE hal fs sffs bdev driver fsmount
  48. nvm cpio_parser lcdpanel)
  49. set(rmarun_ld ldscripts/ramrun_8910.ld)
  50. set(target boot2)
  51. add_uimage(${target} ${rmarun_ld} 8910/boot2_start.c)
  52. target_compile_definitions(${target}_ldscript PRIVATE
  53. RAMRUN_IMAGE_START=${CONFIG_BOOT2_IMAGE_START}
  54. RAMRUN_IMAGE_SIZE=${CONFIG_BOOT2_IMAGE_SIZE}
  55. RAMRUN_MMU_ENABLE=1
  56. )
  57. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  58. target_link_whole_archive(${target} PRIVATE bootloader)
  59. target_link_group(${target} PRIVATE hal osi_lib fupdate fupdate_security_boot fsmount sffs bdev)
  60. target_include_targets(${target} PRIVATE hal fs sffs bdev fupdate fupdate_security_boot driver)
  61. target_link_libraries(${target} PRIVATE ${libc_file_name} ${libgcc_file_name})
  62. set(boot2_img ${out_hex_dir}/boot2.img)
  63. set(boot2_lzma ${boot2_img}.lzmar)
  64. add_custom_command(OUTPUT ${boot2_lzma}
  65. COMMAND ${cmd_lzmare2} ${boot2_img} ${boot2_lzma}
  66. DEPENDS ${boot2_img}
  67. )
  68. set(target boot)
  69. add_uimage(${target} ${rmarun_ld} 8910/boot_start.c)
  70. target_compile_definitions(${target}_ldscript PRIVATE
  71. RAMRUN_IMAGE_START=${CONFIG_BOOT_IMAGE_START}
  72. RAMRUN_IMAGE_SIZE=${CONFIG_BOOT_IMAGE_SIZE}
  73. RAMRUN_FLASH_SIZE=${CONFIG_BOOT_UNSIGN_IMAGE_SIZE}
  74. RAMRUN_MMU_ENABLE=0
  75. )
  76. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  77. target_link_whole_archive(${target} PRIVATE bootloader)
  78. target_link_group(${target} PRIVATE hal calclib boot_calclib_crc)
  79. target_include_targets(${target} PRIVATE kernel)
  80. target_link_libraries(${target} PRIVATE ${libc_file_name} ${libgcc_file_name})
  81. target_incbin(${target} ${boot2_lzma} gBoot2CompData BALIGN 8)
  82. set(target fdl1)
  83. add_uimage(${target} ${rmarun_ld} 8910/fdl1.c)
  84. target_compile_definitions(${target}_ldscript PRIVATE
  85. RAMRUN_IMAGE_START=${CONFIG_FDL1_IMAGE_START}
  86. RAMRUN_IMAGE_SIZE=${CONFIG_FDL1_IMAGE_SIZE}
  87. RAMRUN_FLASH_SIZE=${CONFIG_BOOT_UNSIGN_IMAGE_SIZE}
  88. RAMRUN_MMU_ENABLE=0
  89. )
  90. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  91. target_link_whole_archive(${target} PRIVATE bootloader)
  92. target_link_group(${target} PRIVATE hal osi_lib)
  93. target_include_targets(${target} PRIVATE driver)
  94. target_link_libraries(${target} PRIVATE ${libc_file_name} ${libgcc_file_name})
  95. set(target fdl2)
  96. add_uimage(${target} ${rmarun_ld} 8910/fdl2.c)
  97. target_compile_definitions(${target}_ldscript PRIVATE
  98. RAMRUN_IMAGE_START=${CONFIG_FDL2_IMAGE_START}
  99. RAMRUN_IMAGE_SIZE=${CONFIG_FDL2_IMAGE_SIZE}
  100. RAMRUN_MMU_ENABLE=1
  101. )
  102. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  103. target_include_targets(${target} PRIVATE fs fsmount nvm calclib cpio_parser driver)
  104. target_link_whole_archive(${target} PRIVATE bootloader cpio_parser)
  105. target_link_group(${target} PRIVATE hal calclib boot_calclib_crc sffs fsmount bdev osi_lib nvm lz4 fs)
  106. target_link_libraries(${target} PRIVATE ${libc_file_name} ${libgcc_file_name})
  107. target_incbin_size(${target} ${CMAKE_CURRENT_SOURCE_DIR}/8910/calibparam.bin gDefCalibParam gDefCalibParamSize)
  108. set(target flash_test_fdl)
  109. add_uimage(${target} ${rmarun_ld} flash_test_fdl/flash_test_main.c)
  110. target_compile_definitions(${target}_ldscript PRIVATE
  111. RAMRUN_IMAGE_START=${CONFIG_FDL1_IMAGE_START}
  112. RAMRUN_IMAGE_SIZE=${CONFIG_FDL1_IMAGE_SIZE}
  113. RAMRUN_MMU_ENABLE=0
  114. )
  115. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  116. target_link_whole_archive(${target} PRIVATE bootloader)
  117. target_link_group(${target} PRIVATE hal osi_lib)
  118. target_include_targets(${target} PRIVATE driver)
  119. target_link_libraries(${target} PRIVATE ${libc_file_name} ${libgcc_file_name})
  120. endif()
  121. if(CONFIG_SOC_8850)
  122. set(target bootloader)
  123. add_library(${target} STATIC)
  124. set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${out_lib_dir})
  125. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  126. target_include_directories(${target} PUBLIC include)
  127. target_link_libraries(${target} PRIVATE calclib boot_calclib_crc driver fupdate boot_ex_ql) #quectel update
  128. target_include_targets(${target} PRIVATE hal fs sffs bdev driver fsmount nvm cpio_parser fupdate boot_ex_ql lcdpanel)
  129. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SDMMC THEN ${target} PRIVATE boot_ex_sdmmc)
  130. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_EMMC THEN ${target} PRIVATE boot_ex_emmc)
  131. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SDMMC2 THEN ${target} PRIVATE boot_ex_sdmmc2)
  132. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_EMMC2 THEN ${target} PRIVATE boot_ex_emmc2)
  133. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_FAT_RDONLY THEN ${target} PRIVATE boot_ex_fat_rdonly)
  134. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_FAT_RW THEN ${target} PRIVATE boot_ex_fat_rw)
  135. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_SPI6_EXT_NOR THEN ${target} PRIVATE boot_ex_spi6nor)
  136. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI_FLASH THEN ${target} PRIVATE boot_ex_spiflash)
  137. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_NAND_FLASH THEN ${target} PRIVATE boot_ex_nandflash)
  138. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI6_NAND THEN ${target} PRIVATE boot_ex_spi6nand)
  139. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_LCD THEN ${target} PRIVATE boot_ex_lcd)
  140. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_LED THEN ${target} PRIVATE boot_ex_led)
  141. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_ADC THEN ${target} PRIVATE boot_ex_adc)
  142. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SCATTER THEN ${target} PRIVATE boot_ex_scatter)
  143. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI4_EXTNSFFS THEN ${target} PRIVATE boot_ex_spi4exnsffs boot_ex_spi4exnsffs_cfg)
  144. target_link_libraries_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI4_NORFLASH THEN ${target} PRIVATE boot_ex_spi4norflash)
  145. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SDMMC THEN ${target} PRIVATE boot_ex_sdmmc)
  146. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_EMMC THEN ${target} PRIVATE boot_ex_emmc)
  147. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SDMMC2 THEN ${target} PRIVATE boot_ex_sdmmc2)
  148. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_EMMC2 THEN ${target} PRIVATE boot_ex_emmc2)
  149. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_FAT_RDONLY THEN ${target} PRIVATE boot_ex_fat_rdonly)
  150. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_FAT_RW THEN ${target} PRIVATE boot_ex_fat_rw)
  151. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_SPI6_EXT_NOR THEN ${target} PRIVATE boot_ex_spi6nor)
  152. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI_FLASH THEN ${target} PRIVATE boot_ex_spiflash)
  153. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_NAND_FLASH THEN ${target} PRIVATE boot_ex_nandflash)
  154. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI6_NAND THEN ${target} PRIVATE boot_ex_spi6nand)
  155. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_LCD THEN ${target} PRIVATE boot_ex_lcd)
  156. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_LED THEN ${target} PRIVATE boot_ex_led)
  157. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_ADC THEN ${target} PRIVATE boot_ex_adc)
  158. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SCATTER THEN ${target} PRIVATE boot_ex_scatter)
  159. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI4_EXTNSFFS THEN ${target} PRIVATE boot_ex_spi4exnsffs boot_ex_spi4exnsffs_cfg)
  160. target_include_targets_if(CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI4_NORFLASH THEN ${target} PRIVATE boot_ex_spi4norflash)
  161. target_sources(${target} PRIVATE
  162. 8850/boot_platform.c
  163. 8850/boot_secure.c
  164. src/boot_entry_v7a.S
  165. src/boot_sffs_port.c
  166. src/boot_delay.c
  167. src/boot_mem.c
  168. src/boot_spi_flash.c
  169. src/boot_debuguart.c
  170. src/boot_trace.c
  171. src/boot_fdl.c
  172. src/boot_vfs.c
  173. src/boot_irq_gic.c
  174. src/boot_timer.c
  175. src/boot_ifc_uart.c
  176. src/boot_uart_cmn.c
  177. src/boot_userial.c
  178. src/boot_mmu.c
  179. src/boot_uimage.c
  180. src/boot_unity.c
  181. src/boot_override.c
  182. src/boot_lcd.c
  183. src/boot_efuse.c
  184. src/boot_pdl.c
  185. src/boot_pdl_uimage.c
  186. )
  187. set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${out_lib_dir})
  188. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  189. target_include_directories(${target} PUBLIC include)
  190. target_link_libraries(${target} PRIVATE calclib boot_calclib_crc)
  191. target_include_targets(${target} PRIVATE hal fs sffs bdev driver fsmount
  192. nvm cpio_parser lcdpanel)
  193. set(rmarun_ld ldscripts/ramrun_8850.ld)
  194. set(psrmarun_ld ldscripts/psramrun_8850.ld)
  195. if(NOT QL_PROJECT_MIXER)
  196. set(target spl)
  197. add_simage(${target} ${rmarun_ld} 8850/spl_start.c)
  198. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  199. target_link_whole_archive(${target} PRIVATE bootloader)
  200. target_link_group(${target} PRIVATE hal calclib boot_calclib_crc fupdate fupdate_security_boot sffs bdev osi_lib fsmount boot_ex_ql) #quectel update
  201. target_include_targets(${target} PRIVATE kernel fs sffs bdev fupdate fupdate_security_boot fsmount driver boot_ex_ql)
  202. target_link_libraries(${target} PRIVATE ${libc_file_name} ${libgcc_file_name})
  203. set(target boot)
  204. add_simage(${target} ${psrmarun_ld} 8850/boot_start.c)
  205. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  206. target_link_whole_archive(${target} PRIVATE bootloader)
  207. target_link_group(${target} PRIVATE hal calclib boot_calclib_crc osi_lib) #quectel update
  208. target_include_targets(${target} PRIVATE kernel fs sffs bdev fupdate fsmount driver)
  209. target_link_libraries(${target} PRIVATE ${libc_file_name} ${libgcc_file_name})
  210. set(target norfdl)
  211. add_simage(${target} ${rmarun_ld} 8850/fdl.c)
  212. target_compile_definitions(${target}_ldscript PRIVATE
  213. RAMRUN_IMAGE_START=${CONFIG_NORFDL_IMAGE_START}
  214. RAMRUN_IMAGE_SIZE=${CONFIG_NORFDL_IMAGE_SIZE}
  215. )
  216. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  217. target_include_targets(${target} PRIVATE fs fsmount nvm calclib boot_calclib_crc cpio_parser driver boot_ex_ql) #quectel update
  218. target_link_whole_archive(${target} PRIVATE bootloader cpio_parser)
  219. target_link_group(${target} PRIVATE hal calclib boot_calclib_crc sffs fsmount bdev osi_lib nvm lz4 fs boot_ex_ql) #quectel update
  220. target_link_libraries(${target} PRIVATE ${libc_file_name} ${libgcc_file_name})
  221. endif()
  222. endif()
  223. if(CONFIG_SOC_8811)
  224. set(target bootloader)
  225. add_library(${target} STATIC
  226. 8811/boot_platform.c
  227. 8811/boot_secure.c
  228. src/boot_entry_v8m.S
  229. src/boot_sffs_port.c
  230. src/boot_delay.c
  231. src/boot_mem.c
  232. src/boot_spi_flash.c
  233. src/boot_debuguart.c
  234. src/boot_trace.c
  235. src/boot_fdl.c
  236. src/boot_fdl_dnld.c
  237. src/boot_aes.c
  238. src/boot_vfs.c
  239. src/boot_irq_nvic.c
  240. src/boot_timer.c
  241. src/boot_ifc_uart.c
  242. src/boot_uart_cmn.c
  243. src/boot_unity.c
  244. src/boot_override.c
  245. )
  246. if (CONFIG_TFM_SUPPORT)
  247. target_sources(${target} PRIVATE 8811/boot_status.c 8811/boot_rng.c)
  248. endif()
  249. set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${out_lib_dir})
  250. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  251. target_include_directories(${target} PUBLIC include)
  252. target_link_libraries(${target} PRIVATE calclib boot_calclib_crc)
  253. target_include_targets(${target} PRIVATE hal fs sffs bdev driver fsmount nvm cpio_parser)
  254. set(rmarun_ld ldscripts/ramrun_8811.ld)
  255. set(target boot2)
  256. add_simage(${target} ${rmarun_ld} 8811/boot2_start.c)
  257. target_compile_definitions(${target}_ldscript PRIVATE
  258. RAMRUN_IMAGE_START=${CONFIG_BOOT2_IMAGE_START}
  259. RAMRUN_IMAGE_SIZE=${CONFIG_BOOT2_IMAGE_SIZE}
  260. )
  261. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  262. target_link_whole_archive(${target} PRIVATE bootloader)
  263. target_link_group(${target} PRIVATE hal osi_lib fupdate fupdate_security_boot fsmount sffs bdev calclib boot_calclib_crc)
  264. target_include_targets(${target} PRIVATE hal fs sffs bdev fupdate fupdate_security_boot driver)
  265. target_link_libraries(${target} PRIVATE ${libc_file_name} ${libgcc_file_name})
  266. set(boot2_img ${out_hex_dir}/boot2.img)
  267. set(boot2_lzma ${boot2_img}.lzma)
  268. add_custom_command(OUTPUT ${boot2_lzma}
  269. COMMAND ${cmd_lzmacomp} ${boot2_img}
  270. DEPENDS ${boot2_img}
  271. )
  272. set(target boot)
  273. add_simage(${target} ${rmarun_ld} 8811/boot_start.c)
  274. target_compile_definitions(${target}_ldscript PRIVATE
  275. RAMRUN_IMAGE_START=${CONFIG_BOOT_IMAGE_START}
  276. RAMRUN_IMAGE_SIZE=${CONFIG_BOOT_IMAGE_SIZE}
  277. RAMRUN_FLASH_SIZE=${CONFIG_BOOTLOADER_SIZE}
  278. )
  279. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  280. target_link_whole_archive(${target} PRIVATE bootloader)
  281. target_link_group(${target} PRIVATE hal osi_lib fupdate fupdate_security_boot fsmount sffs bdev calclib boot_calclib_crc)
  282. target_include_targets(${target} PRIVATE hal fs sffs bdev fupdate fupdate_security_boot driver)
  283. target_link_libraries(${target} PRIVATE ${libc_file_name} ${libgcc_file_name})
  284. target_incbin_size(${target} ${boot2_lzma} gBoot2CompData gBoot2CompSize BALIGN 8)
  285. set(target norfdl)
  286. add_simage(${target} ${rmarun_ld} 8811/fdl.c)
  287. target_compile_definitions(${target}_ldscript PRIVATE
  288. RAMRUN_IMAGE_START=${CONFIG_NORFDL_IMAGE_START}
  289. RAMRUN_IMAGE_SIZE=${CONFIG_NORFDL_IMAGE_SIZE}
  290. )
  291. target_compile_definitions(${target} PRIVATE OSI_LOG_TAG=LOG_TAG_BOOT)
  292. target_include_targets(${target} PRIVATE fs fsmount nvm calclib cpio_parser driver)
  293. target_link_whole_archive(${target} PRIVATE bootloader cpio_parser)
  294. target_link_group(${target} PRIVATE hal calclib boot_calclib_crc sffs fsmount bdev osi_lib nvm lz4 fs)
  295. target_link_libraries(${target} PRIVATE ${libc_file_name} ${libgcc_file_name})
  296. endif()
  297. relative_glob(srcs include/*.h src/*.[ch]
  298. 8811/*.[ch] 8910/*.[ch] 8850/*.[ch]
  299. fdl1/*.[ch] fdl2/*.[ch] flash_test_fdl/*.[ch]
  300. boot/*.[ch] uart_ramrun/*.[ch] spl_start/*.[ch]
  301. )
  302. beautify_c_code(bootloader ${srcs})