chip_8850.cmake 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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. set(CROSS_COMPILE arm-none-eabi-)
  12. set(CMAKE_SYSTEM_PROCESSOR ARM)
  13. set(ARCH arm)
  14. set(CONFIG_CACHE_LINE_SIZE 32)
  15. set(CONFIG_SRAM_PHY_ADDRESS 0x00100000)
  16. set(CONFIG_AON_SRAM_PHY_ADDRESS 0x50800000)
  17. set(CONFIG_CP_SRAM_PHY_ADDRESS 0x10100000)
  18. set(CONFIG_ROM_PHY_ADDRESS 0x0)
  19. set(CONFIG_NOR_PHY_ADDRESS 0x60000000)
  20. set(CONFIG_NOR_EXT_PHY_ADDRESS 0x70000000)
  21. set(CONFIG_RAM_PHY_ADDRESS 0x80000000)
  22. set(CONFIG_SRAM_SIZE 0x4000)
  23. set(CONFIG_AON_SRAM_SIZE 0x14000)
  24. set(CONFIG_CP_SRAM_SIZE 0x40000)
  25. set(CONFIG_ROM_SIZE 0x10000)
  26. set(CONFIG_GIC_BASE_ADDRESS 0x00801000)
  27. set(CONFIG_GIC_CPU_INTERFACE_OFFSET 0x00001000)
  28. set(CONFIG_GIC_PRIORITY_BITS 5)
  29. set(CONFIG_IRQ_COUNT 97)
  30. set(CONFIG_SIMAGE_HEADER_SIZE 0x100)
  31. # ROM parameter
  32. set(CONFIG_ROM_SRAM_LOAD_ADDRESS ${CONFIG_AON_SRAM_PHY_ADDRESS})
  33. set(CONFIG_ROM_LOAD_SIZE ${CONFIG_AON_SRAM_SIZE})
  34. set(CONFIG_ROM_SRAM_DATA_SIZE 0xc00)
  35. # BOOT SRAM Layout: ROM_SRAM_DATA, BOOT_SYS_STACK, BOOT_IRQ_STACK, BLUE_SCREEN, sram_heap
  36. # BOOT AON SRAM Layout: text+data+bss, (mmuttbl1)
  37. # BOOT RAM Layout: (mmuttbl1), ram_heap
  38. # Bootloader address size
  39. set(CONFIG_BOOT_IMAGE_START ${CONFIG_APP_RAM_ADDRESS})
  40. set(CONFIG_BOOT_IMAGE_SIZE ${CONFIG_BOOT_FLASH_SIZE})
  41. # FDL address size
  42. set(CONFIG_NORFDL_IMAGE_START ${CONFIG_AON_SRAM_PHY_ADDRESS})
  43. set(CONFIG_NORFDL_IMAGE_SIZE ${CONFIG_AON_SRAM_SIZE})
  44. # FLASH layout: SPL, BOOT, AP, APPIMG, FS_SYS, FS_MODEM, FS_FACTORY
  45. math(EXPR CONFIG_SPL_SIZE "${CONFIG_SPL_FLASH_SIZE}/2" OUTPUT_FORMAT HEXADECIMAL)
  46. math(EXPR CONFIG_SPL1_FLASH_ADDRESS "${CONFIG_SPL_FLASH_ADDRESS}" OUTPUT_FORMAT HEXADECIMAL)
  47. math(EXPR CONFIG_SPL2_FLASH_ADDRESS "${CONFIG_SPL_FLASH_ADDRESS}+${CONFIG_SPL_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
  48. # AP SRAM layout: text+data+bss, heap, BLUE_SCREEN, SVC, IRQ
  49. set(CONFIG_IRQ_STACK_SIZE 0x200)
  50. set(CONFIG_SVC_STACK_SIZE 0x600)
  51. set(CONFIG_BLUE_SCREEN_SIZE 0x600)
  52. # RAM layout: CP, APP, APP_FILEIMG, APP_FLASHIMG
  53. # needs: CONFIG_CP_RAM_SIZE, CONFIG_APP_FLASHIMG_RAM_SIZE, CONFIG_APP_FILEIMG_RAM_SIZE
  54. math(EXPR CONFIG_APP_TRUSTZONE_TOS_RAM_ADDRESS "${CONFIG_RAM_PHY_ADDRESS}+${CONFIG_RAM_SIZE}-${CONFIG_APP_TRUSTZONE_TOS_RAM_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
  55. math(EXPR CONFIG_APP_TRUSTZONE_SML_RAM_ADDRESS "${CONFIG_APP_TRUSTZONE_TOS_RAM_ADDRESS}-${CONFIG_APP_TRUSTZONE_SML_RAM_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
  56. math(EXPR CONFIG_APP_FILEIMG_RAM_ADDRESS "${CONFIG_APP_TRUSTZONE_SML_RAM_ADDRESS}-${CONFIG_APP_FILEIMG_RAM_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
  57. math(EXPR CONFIG_APP_FLASHIMG_RAM_ADDRESS "${CONFIG_APP_FILEIMG_RAM_ADDRESS}-${CONFIG_APP_FLASHIMG_RAM_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
  58. # Quectel: CONFIG_APP2_FLASHIMG_RAM_SIZE/CONFIG_APP2_FILEIMG_RAM_SIZE默认为0x0,只有在使能双APPIMG的时候会用到
  59. math(EXPR CONFIG_APP2_FILEIMG_RAM_ADDRESS "${CONFIG_APP_FLASHIMG_RAM_ADDRESS}-${CONFIG_APP2_FILEIMG_RAM_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
  60. math(EXPR CONFIG_APP2_FLASHIMG_RAM_ADDRESS "${CONFIG_APP2_FILEIMG_RAM_ADDRESS}-${CONFIG_APP2_FLASHIMG_RAM_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
  61. # Quectel: CONFIG_GNSS_RAM_SIZE的内存是用于GNSS打开的场景下 需要保存星历数据,划分出psram空间存储临时更新的数据 然后进行写flash。
  62. math(EXPR CONFIG_GNSS_RAM_ADDRESS "${CONFIG_APP2_FLASHIMG_RAM_ADDRESS}-${CONFIG_GNSS_RAM_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
  63. math(EXPR CONFIG_CP_RAM_ADDRESS "${CONFIG_RAM_PHY_ADDRESS}" OUTPUT_FORMAT HEXADECIMAL)
  64. math(EXPR CONFIG_APP_RAM_ADDRESS "${CONFIG_CP_RAM_ADDRESS}+${CONFIG_CP_RAM_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
  65. math(EXPR CONFIG_APP_RAM_SIZE "${CONFIG_GNSS_RAM_ADDRESS}-${CONFIG_APP_RAM_ADDRESS}" OUTPUT_FORMAT HEXADECIMAL)
  66. # AON SRAM layout: CODE, SHMEM, CP
  67. # needs: CONFIG_AON_SRAM_CODE_SIZE, CONFIG_AON_SRAM_SHMEM_SIZE, CONFIG_AON_SRAM_CP_SIZE
  68. set(CONFIG_AON_SRAM_CODE_SIZE 0x2000)
  69. set(CONFIG_AON_SRAM_SHMEM_SIZE 0x1000)
  70. set(CONFIG_AON_SRAM_CP_SIZE 0x11000)
  71. math(EXPR CONFIG_AON_SRAM_CODE_ADDRESS "${CONFIG_AON_SRAM_PHY_ADDRESS}" OUTPUT_FORMAT HEXADECIMAL)
  72. math(EXPR CONFIG_AON_SRAM_SHMEM_ADDRESS "${CONFIG_AON_SRAM_CODE_ADDRESS}+${CONFIG_AON_SRAM_CODE_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
  73. math(EXPR CONFIG_AON_SRAM_CP_ADDRESS "${CONFIG_AON_SRAM_SHMEM_ADDRESS}+${CONFIG_AON_SRAM_SHMEM_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
  74. set(unittest_ldscript ${SOURCE_TOP_DIR}/components/hal/ldscripts/8850_psram.ld)
  75. set(example_ldscript ${SOURCE_TOP_DIR}/components/hal/ldscripts/8850_psram.ld)
  76. set(ramrun_ldscript ${SOURCE_TOP_DIR}/components/bootloader/ldscripts/ramrun_8850.ld)
  77. set(appstart_ldscript ${SOURCE_TOP_DIR}/components/hal/ldscripts/8850_psram.ld)
  78. #quectel update
  79. if(CONFIG_QUEC_PROJECT_FEATURE_IMAGE_SIGN)
  80. set(pac_fdl_files ${out_hex_dir}/norfdl.sign.img)
  81. else()
  82. set(pac_fdl_files ${out_hex_dir}/norfdl.img)
  83. endif()
  84. # NEVER USE THESE KEYS IN PRODUCTION!
  85. set(security_version 1)
  86. if(CONFIG_QUEC_PROJECT_FEATURE_TEESDK_VTRUST) # quectel update
  87. set(with_chaincert true)
  88. else()
  89. set(with_chaincert false)
  90. endif()
  91. set(with_debugcert_develcert false)
  92. set(with_encrypt false)
  93. if( NOT CONFIG_QUEC_PROJECT_FEATURE_TEESDK_VTRUST) # quectel update
  94. set(SOC_ID 6655aa9900881122)
  95. endif()
  96. set(ENC_KEY 40414243444546470123456789ABcdef55aa55aa55aa55aaA8a9aaabacadaeaf)
  97. set(ENC_IV 3132333435363738393a3b3c3d3e3f40)
  98. set(debug_mask 7c) # open the ap_ca5 bits
  99. if(CONFIG_QUEC_PROJECT_FEATURE_TEESDK_VTRUST) # quectel update
  100. set(key_root_prv ${SOURCE_TOP_DIR}/components/hal/config/8850/bctc/key_root_prv_ec_secp256r1.pem)
  101. set(key_root_pub ${SOURCE_TOP_DIR}/components/hal/config/8850/bctc/key_root_pub_ec_secp256r1.pem)
  102. if (${with_chaincert})
  103. set(chain_cert_prv ${SOURCE_TOP_DIR}/components/hal/config/8850/bctc/chain_cert_prv_ec_secp224k1.pem)
  104. set(chain_cert_pub ${SOURCE_TOP_DIR}/components/hal/config/8850/bctc/chain_cert_pub_ec_secp224k1.pem)
  105. endif()
  106. set(key_debug_prv ${SOURCE_TOP_DIR}/components/hal/config/8850/bctc/key_debug_prv_ec_secp256k1.pem)
  107. set(key_debug_pub ${SOURCE_TOP_DIR}/components/hal/config/8850/bctc/key_debug_pub_ec_secp256k1.pem)
  108. set(key_devel_prv ${SOURCE_TOP_DIR}/components/hal/config/8850/bctc/key_devel_prv_rsa_4096.pem)
  109. set(key_devel_pub ${SOURCE_TOP_DIR}/components/hal/config/8850/bctc/key_devel_pub_rsa_4096.pem)
  110. else()
  111. set(key_root_prv ${SOURCE_TOP_DIR}/components/hal/config/8850/ecc/secp256r1_prv.pem)
  112. set(key_root_pub ${SOURCE_TOP_DIR}/components/hal/config/8850/ecc/secp256r1_pub.pem)
  113. if (${with_chaincert})
  114. set(chain_cert_prv ${SOURCE_TOP_DIR}/components/hal/config/8850/ecc/secp224k1_prv.pem)
  115. set(chain_cert_pub ${SOURCE_TOP_DIR}/components/hal/config/8850/ecc/secp224k1_pub.pem)
  116. endif()
  117. set(key_debug_prv ${SOURCE_TOP_DIR}/components/hal/config/8850/ecc/secp256k1_prv.pem)
  118. set(key_debug_pub ${SOURCE_TOP_DIR}/components/hal/config/8850/ecc/secp256k1_pub.pem)
  119. set(key_devel_prv ${SOURCE_TOP_DIR}/components/hal/config/8850/rsa/4096_prv.pem)
  120. set(key_devel_pub ${SOURCE_TOP_DIR}/components/hal/config/8850/rsa/4096_pub.pem)
  121. endif()
  122. set(ssign_param --force) # ssign parameters: --pkcsv15 --force
  123. if(${with_debugcert_develcert})
  124. set(ssign_param ${ssign_param} --debug_pub ${key_debug_pub})
  125. endif()
  126. set(ssignchain_param --force) # ssignchain parameters: --pkcsv15 --force
  127. set(ssigndebug_param --force) # ssignchain parameters: --pkcsv15 --force
  128. set(ssigndevel_param --force) # ssignchain parameters: --pkcsv15 --force
  129. set(sencrypt_param --type sm4 ${ENC_KEY} ${ENC_IV}) # ssignchain parameters: --type sm4/aes
  130. if(DEFINED SOC_ID)
  131. set(ssignchain_param ${ssignchain_param} --soc_id ${SOC_ID})
  132. endif()
  133. function(sign_image src dst chain enc dev_debug)
  134. if (enc)
  135. set(CURR_CMD_ENC ${cmd_sencrypt} ${sencrypt_param} ${src} ${src}.enc)
  136. else()
  137. set(CURR_CMD_ENC ${CMAKE_COMMAND} -E copy ${src} ${src}.enc)
  138. endif()
  139. if (chain)
  140. set(CURR_CMD_CHAIN ${cmd_ssignchain} ${ssignchain_param} ${chain_cert_prv} ${chain_cert_pub} ${src}.keycert ${src}.chaincert)
  141. else()
  142. set(CURR_CMD_CHAIN ${CMAKE_COMMAND} -E copy ${src}.keycert ${src}.chaincert)
  143. endif()
  144. if (dev_debug)
  145. set(CURR_CMD_DEBUG ${cmd_ssigndebug} ${ssigndebug_param} ${key_debug_prv} ${key_debug_pub} ${key_devel_pub} ${debug_mask} ${src}.chaincert ${src}.debugcert)
  146. set(CURR_CMD_DEV ${cmd_ssigndevel} ${ssigndevel_param} ${key_devel_prv} ${key_devel_pub} ${debug_mask} ${SOC_ID} ${src}.debugcert ${dst})
  147. else()
  148. set(CURR_CMD_DEBUG ${CMAKE_COMMAND} -E copy ${src}.chaincert ${src}.debugcert)
  149. set(CURR_CMD_DEV ${CMAKE_COMMAND} -E copy ${src}.debugcert ${dst})
  150. endif()
  151. add_custom_command(OUTPUT ${dst}
  152. COMMAND ${CURR_CMD_ENC}
  153. COMMAND ${cmd_ssign} ${ssign_param} ${key_root_prv} ${key_root_pub} ${security_version} ${src}.enc ${src}.keycert
  154. COMMAND ${CURR_CMD_CHAIN}
  155. COMMAND ${CURR_CMD_DEBUG}
  156. COMMAND ${CURR_CMD_DEV}
  157. DEPENDS ${src}
  158. )
  159. endfunction()
  160. #Insert simage info to modem.bin
  161. function (mkcpsimage src dst)
  162. execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/components/tfm/get_entry_point.sh
  163. ${MODEM_ROOT_DIR}/${CONFIG_NVM_VARIANTS}/cp.axf
  164. WORKING_DIRECTOTY ${CMAKE_CURRENT_SOURCE_DIR}
  165. OUTPUT_VARIABLE cp_entry_point)
  166. string(STRIP ${cp_entry_point} cp_entry_point)
  167. add_custom_command(OUTPUT ${dst}
  168. COMMENT "Insert header info to cp.bin"
  169. COMMAND ${cmd_mksimage} --bin --load ${CONFIG_FS_MODEM_FLASH_ADDRESS} --entry ${cp_entry_point}
  170. --name "${BUILD_REVISION}-${BUILD_AUTO_REVISION}"
  171. --imgver "1.1" --platform "8811" --check crc
  172. ${src} ${dst}
  173. DEPENDS ${src}
  174. )
  175. endfunction()
  176. function(pacvariant_gen)
  177. if(NOT MODEM_ROOT_DIR)
  178. set(MODEM_ROOT_DIR ${SOURCE_TOP_DIR}/prebuilts/modem/8850)
  179. endif()
  180. if(NOT TRUSTZONE_ROOT_DIR)
  181. set(TRUSTZONE_ROOT_DIR ${SOURCE_TOP_DIR}/${CONFIG_TRUSTZONE_SML_TOS_DIR})
  182. message(STATUS "sml dir ${TRUSTZONE_ROOT_DIR}")
  183. endif()
  184. sign_image(${out_hex_dir}/norfdl.img ${out_hex_dir}/norfdl.sign.img ${with_chaincert} ${with_encrypt} false)
  185. sign_image(${out_hex_dir}/spl.img ${out_hex_dir}/spl.sign.img ${with_chaincert} ${with_encrypt} ${with_debugcert_develcert})
  186. sign_image(${out_hex_dir}/boot.img ${out_hex_dir}/boot.sign.img ${with_chaincert} false false)
  187. sign_image(${out_hex_dir}/${BUILD_TARGET}.img ${out_hex_dir}/${BUILD_TARGET}.sign.img ${with_chaincert} false false)
  188. if(CONFIG_TRUSTZONE_SUPPORT)
  189. add_custom_command(OUTPUT ${out_hex_dir}/tos.img ${out_hex_dir}/sml.img
  190. COMMAND ${cmd_mksimage} --bin --load ${CONFIG_APP_TRUSTZONE_SML_RAM_ADDRESS} --entry ${CONFIG_APP_TRUSTZONE_SML_RAM_ADDRESS}
  191. --name "SML-${BUILD_REVISION}-${BUILD_AUTO_REVISION}"
  192. --imgver "1.1" --platform "8811" --check crc
  193. ${TRUSTZONE_ROOT_DIR}/sml.bin ${out_hex_dir}/sml.img
  194. COMMAND ${cmd_mksimage} --bin --load ${CONFIG_APP_TRUSTZONE_TOS_RAM_ADDRESS} --entry ${CONFIG_APP_TRUSTZONE_TOS_RAM_ADDRESS}
  195. --name "TOL-${BUILD_REVISION}-${BUILD_AUTO_REVISION}"
  196. --imgver "1.1" --platform "8811" --check crc
  197. ${TRUSTZONE_ROOT_DIR}/tos.bin ${out_hex_dir}/tos.img
  198. DEPENDS ${TRUSTZONE_ROOT_DIR}/sml.bin ${TRUSTZONE_ROOT_DIR}/tos.bin
  199. )
  200. # TODO add signed tos and sml to replace tos and sml bin
  201. sign_image(${out_hex_dir}/sml.img ${out_hex_dir}/sml.sign.img ${with_chaincert} false false)
  202. sign_image(${out_hex_dir}/tos.img ${out_hex_dir}/tos.sign.img ${with_chaincert} false false)
  203. endif()
  204. if(CONFIG_FUNC_SUPPORT_SIMLOCK)
  205. message("Simlock function is enable")
  206. set(simlockeydir ${SOURCE_TOP_DIR}/components/hal/config/8850/)
  207. else()
  208. message("Simlock function is disable")
  209. set(simlockeydir NULL)
  210. endif()
  211. #Do CP.bin sign
  212. if(CONFIG_CP_SIGN_ENABLE)
  213. message("Cp.bin sign is enable")
  214. set(signmodembin --signcpbin true)
  215. set(modem_dir ${MODEM_ROOT_DIR}/${CONFIG_NVM_VARIANTS})
  216. set(cpsimage ${out_hex_dir}/cp.image)
  217. set(cpsign ${out_hex_dir}/cp-sign.img)
  218. if(EXISTS ${cpsign})
  219. # message("Remove old cp sign file: cp-sign.img")
  220. file(REMOVE ${cpsign} ${cpsimage})
  221. endif()
  222. mkcpsimage(${modem_dir}/cp.bin ${cpsimage})
  223. sign_image(${cpsimage} ${cpsign} ${with_chaincert} false false)
  224. else()
  225. message("CP sign is disable")
  226. set(signmodembin --signcpbin false)
  227. if(EXISTS ${out_hex_dir}/cp-sign.img)
  228. # message("Remove old cp sign file: cp-sign.img")
  229. file(REMOVE ${out_hex_dir}/cp-sign.img ${out_hex_dir}/cp.image)
  230. endif()
  231. set(cpsign)
  232. endif()
  233. foreach(nvmvariant ${CONFIG_NVM_VARIANTS})
  234. set(vargen_dir ${BINARY_TOP_DIR}/vargen/${nvmvariant})
  235. set(nvitem_bin ${out_hex_dir}/${nvmvariant}_nvitem.bin)
  236. set(modem_cpio ${out_hex_dir}/${nvmvariant}_modem.cpio)
  237. set(indeltanv_cpio ${out_hex_dir}/${nvmvariant}_indeltanv.cpio)
  238. set(ims_deltanv_cpio ${out_hex_dir}/${nvmvariant}_ims_deltanv.cpio)
  239. set(prepack_cpio ${out_hex_dir}/${nvmvariant}_prepack.cpio)
  240. set(pac_file ${out_hex_dir}/${BUILD_TARGET}-${nvmvariant}-${BUILD_RELEASE_TYPE}.pac)
  241. pac_init_fdl(init_fdl)
  242. #quectel update
  243. if(CONFIG_QUEC_PROJECT_FEATURE_IMAGE_SIGN)
  244. set(cfg_spl_depends ${out_hex_dir}/spl.sign.img)
  245. set(cfg_spl cfg-image -i SPL -a ${CONFIG_SPL_FLASH_ADDRESS} -s ${CONFIG_SPL_FLASH_SIZE}
  246. -p ${out_hex_dir}/spl.sign.img -n spl.sign.img)
  247. set(cfg_boot cfg-image -i BOOT -a ${CONFIG_BOOT_FLASH_ADDRESS} -s ${CONFIG_BOOT_FLASH_SIZE}
  248. -p ${out_hex_dir}/boot.sign.img -n boot.sign.img)
  249. set(cfg_ap cfg-image -i AP -a ${CONFIG_APP_FLASH_ADDRESS} -s ${CONFIG_APP_FLASH_SIZE}
  250. -p ${out_hex_dir}/${BUILD_TARGET}.sign.img)
  251. if(CONFIG_TRUSTZONE_SUPPORT)
  252. set(cfg_tz_depends ${out_hex_dir}/sml.sign.img ${out_hex_dir}/tos.sign.img)
  253. set(cfg_tz_sml cfg-image -i SML -a ${CONFIG_TZ_SML_FLASH_ADDRESS} -s ${CONFIG_TZ_SML_FLASH_SIZE}
  254. -p ${out_hex_dir}/sml.sign.img -n sml.sign.img)
  255. set(cfg_tz_tos cfg-image -i TOS -a ${CONFIG_TZ_TOS_FLASH_ADDRESS} -s ${CONFIG_TZ_TOS_FLASH_SIZE}
  256. -p ${out_hex_dir}/tos.sign.img -n tos.sign.img)
  257. endif()
  258. set(cfg_pac_depends DEPENDS ${out_hex_dir}/norfdl.sign.img ${nvitem_bin} ${out_hex_dir}/boot.sign.img
  259. ${out_hex_dir}/${BUILD_TARGET}.sign.img
  260. ${cfg_spl_depends} ${cfg_tz_depends})
  261. else()
  262. set(cfg_spl_depends ${out_hex_dir}/spl.img)
  263. set(cfg_spl cfg-image -i SPL -a ${CONFIG_SPL_FLASH_ADDRESS} -s ${CONFIG_SPL_FLASH_SIZE}
  264. -p ${out_hex_dir}/spl.img -n spl.img)
  265. set(cfg_boot cfg-image -i BOOT -a ${CONFIG_BOOT_FLASH_ADDRESS} -s ${CONFIG_BOOT_FLASH_SIZE}
  266. -p ${out_hex_dir}/boot.img -n boot.img)
  267. set(cfg_ap cfg-image -i AP -a ${CONFIG_APP_FLASH_ADDRESS} -s ${CONFIG_APP_FLASH_SIZE}
  268. -p ${out_hex_dir}/${BUILD_TARGET}.img)
  269. if(CONFIG_TRUSTZONE_SUPPORT)
  270. set(cfg_tz_depends ${out_hex_dir}/sml.img ${out_hex_dir}/tos.img)
  271. set(cfg_tz_sml cfg-image -i SML -a ${CONFIG_TZ_SML_FLASH_ADDRESS} -s ${CONFIG_TZ_SML_FLASH_SIZE}
  272. -p ${out_hex_dir}/sml.img -n sml.img)
  273. set(cfg_tz_tos cfg-image -i TOS -a ${CONFIG_TZ_TOS_FLASH_ADDRESS} -s ${CONFIG_TZ_TOS_FLASH_SIZE}
  274. -p ${out_hex_dir}/tos.img -n tos.img)
  275. endif()
  276. set(cfg_pac_depends DEPENDS ${out_hex_dir}/norfdl.img ${nvitem_bin} ${out_hex_dir}/boot.img
  277. ${out_hex_dir}/${BUILD_TARGET}.img
  278. ${cfg_spl_depends} ${cfg_tz_depends})
  279. endif()
  280. set(cfg_erase_spl cfg-erase-flash -i ERASE_SPL -a ${CONFIG_SPL_FLASH_ADDRESS} -s ${CONFIG_SPL_FLASH_SIZE}) # quectel modify
  281. #if(CONFIG_TRUSTZONE_SUPPORT) #quectel update
  282. # set(cfg_tz_depends ${out_hex_dir}/sml.sign.img ${out_hex_dir}/tos.sign.img)
  283. # set(cfg_tz_sml cfg-image -i SML -a ${CONFIG_TZ_SML_FLASH_ADDRESS} -s ${CONFIG_TZ_SML_FLASH_SIZE}
  284. # -p ${out_hex_dir}/sml.sign.img -n sml.sign.img)
  285. # set(cfg_tz_tos cfg-image -i TOS -a ${CONFIG_TZ_TOS_FLASH_ADDRESS} -s ${CONFIG_TZ_TOS_FLASH_SIZE}
  286. # -p ${out_hex_dir}/tos.sign.img -n tos.sign.img)
  287. #endif()
  288. if(CONFIG_APP_FLASH2_ENABLED)
  289. set(target_flash2_bin ${out_hex_dir}/${BUILD_TARGET}.flash2.bin)
  290. set(cfg_ap2 cfg-image -i AP2 -a ${CONFIG_APP_FLASH2_ADDRESS}
  291. -s ${CONFIG_APP_FLASH2_SIZE} -p ${target_flash2_bin})
  292. endif()
  293. #if(CONFIG_FS_EXT_ENABLED) #quectel update
  294. # set(cfg_fmt_fext cfg-fmt-flash -i FMT_FSEXT -b FEXT -n)
  295. #endif()
  296. if(CONFIG_QUEC_PROJECT_FEATURE_SPI6_EXT_NOR)
  297. if(CONFIG_QUEC_PROJECT_FEATURE_PROG_FW_FMTEXT)
  298. set(cfg_fmt_fext cfg-fmt-flash -i FMT_FSEXT -b FEXT)
  299. else()
  300. set(cfg_fmt_fext cfg-fmt-flash -i FMT_FSEXT -b FEXT -n)
  301. endif()
  302. endif()
  303. if(CONFIG_QUEC_PROJECT_FEATURE_PROG_FW_FMTSYS)
  304. set(cfg_fmt_fssys cfg-fmt-flash -i FMT_FSSYS -b FSYS)
  305. else()
  306. set(cfg_fmt_fssys cfg-fmt-flash -i FMT_FSSYS -b FSYS -n)
  307. endif()
  308. if(CONFIG_SUPPORT_IMS_DELTA_NV)
  309. set(gen_ims_deltanv --imsdeltanv ${ims_deltanv_cpio})
  310. set(cfg_ims_deltanv cfg-pack-cpio -i IMSDELTANV -p ${ims_deltanv_cpio})
  311. endif()
  312. if(CONFIG_SUPPORT_INNER_DELTA_NV)
  313. set(gen_indeltanv --indeltanv ${indeltanv_cpio})
  314. set(cfg_indeltanv cfg-pack-cpio -i INDELTANV -p ${indeltanv_cpio})
  315. endif()
  316. add_custom_command(OUTPUT ${nvitem_bin}
  317. COMMAND python3 ${modemgen_py} vargen8850
  318. --config ${SOURCE_TOP_DIR}/components/hal/config/8850/modem_nvm.json
  319. --source-top ${SOURCE_TOP_DIR}
  320. --binary-top ${BINARY_TOP_DIR}
  321. --cproot ${MODEM_ROOT_DIR}
  322. --aproot ${SOURCE_TOP_DIR}/components/nvitem/8850
  323. --workdir ${vargen_dir}
  324. --fix-size ${CONFIG_NVBIN_FIXED_SIZE}
  325. --deltainc ${out_inc_dir}
  326. --dep ${vargen_dir}/vargen.d
  327. --deprel ${BINARY_TOP_DIR}
  328. --prepackfile ${CONFIG_PACKAGE_FILE_JSON_PATH}
  329. --outHexDir ${out_hex_dir}
  330. --simlockeydir ${simlockeydir}
  331. --ims-region $ENV{IMS_DELTA_NV_ROOT} # quectel modify
  332. ${gen_ims_deltanv}
  333. ${gen_indeltanv}
  334. ${signmodembin}
  335. ${nvmvariant}
  336. ${prepack_cpio} ${nvitem_bin} ${modem_cpio}
  337. DEPFILE ${vargen_dir}/vargen.d
  338. DEPENDS ${cpsign}
  339. WORKING_DIRECTORY ${SOURCE_TOP_DIR}
  340. )
  341. add_custom_command(OUTPUT ${pac_file}
  342. COMMAND python3 ${pacgen_py} ${init_fdl}
  343. cfg-nvitem -n "Calibration" -i 0xFFFFFFFF --use 1 --replace 0 --continue 0 --backup 1
  344. cfg-nvitem -n "LTE Calibration" -i 0x26e --use 1 --replace 0 --continue 0 --backup 1
  345. cfg-nvitem -n "Golden_Calib" -i 0x26f --use 1 --replace 0 --continue 0 --backup 1
  346. cfg-nvitem -n "IMEI" -i 0xFFFFFFFF --use 1 --replace 0 --continue 0 --backup 1
  347. cfg-nvitem -n "IMEI2" -i 0x179 --use 1 --replace 0 --continue 0 --backup 1 # quectel modify
  348. cfg-nvitem -n "GPS_Aptsx" -i 0x1b4 --use 1 --replace 0 --continue 1 --backup 1
  349. cfg-nvitem -n "Simlock" -i 0x1f0 --use 1 --replace 0 --continue 1 --backup 1
  350. cfg-nvitem -n "module_def" -i 0x300 --use 1 --replace 0 --continue 1 --backup 1
  351. #cfg-erase-flash -i ERASE_BOOT -a ${CONFIG_BOOT_FLASH_ADDRESS} -s ${CONFIG_BOOT_FLASH_SIZE} # quectel modify
  352. ${cfg_erase_spl} # quectel modify
  353. #${cfg_spl} # quectel modify
  354. ${cfg_tz_sml}
  355. ${cfg_tz_tos}
  356. #cfg-image -i BOOT -a ${CONFIG_BOOT_FLASH_ADDRESS} -s ${CONFIG_BOOT_FLASH_SIZE} # quectel modify
  357. # -p ${out_hex_dir}/boot.sign.img -n boot.sign.img
  358. ${cfg_boot} # quectel modify
  359. cfg-phase-check
  360. #cfg-nv -s ${CONFIG_NVBIN_FIXED_SIZE} -p ${out_hex_dir}/${nvmvariant}_nvitem.bin # quectel modify
  361. #cfg-fmt-flash -i FMT_FSSYS -b FSYS -n
  362. ${cfg_fmt_fssys} # quectel modify
  363. cfg-fmt-flash -i FMT_FSMOD -b FMOD
  364. ${cfg_fmt_fext}
  365. cfg-nv -s ${CONFIG_NVBIN_FIXED_SIZE} -p ${out_hex_dir}/${nvmvariant}_nvitem.bin # quectel modify
  366. #cfg-image -i AP -a ${CONFIG_APP_FLASH_ADDRESS} -s ${CONFIG_APP_FLASH_SIZE} # quectel modify
  367. # -p ${out_hex_dir}/${BUILD_TARGET}.sign.img
  368. ${cfg_ap} # quectel modify
  369. ${cfg_ap2}
  370. cfg-pack-cpio -i CP -p ${modem_cpio}
  371. ${cfg_ims_deltanv}
  372. ${cfg_indeltanv}
  373. cfg-pack-cpio -i PREPACK -p ${prepack_cpio}
  374. cfg-clear-nv
  375. #cfg-image -i BOOT -a ${CONFIG_BOOT_FLASH_ADDRESS} -s ${CONFIG_BOOT_FLASH_SIZE}
  376. # -p ${out_hex_dir}/boot.sign.img -n boot.sign.img # quectel modify
  377. ${cfg_spl} # quectel modify
  378. dep-gen --base ${BINARY_TOP_DIR} ${pac_file} ${pac_file}.d
  379. pac-gen ${pac_file}
  380. DEPFILE ${pac_file}.d
  381. #DEPENDS ${out_hex_dir}/norfdl.sign.img ${nvitem_bin} ${out_hex_dir}/boot.sign.img
  382. # ${out_hex_dir}/${BUILD_TARGET}.sign.img
  383. # ${cfg_spl_depends} ${cfg_tz_depends}
  384. ${cfg_pac_depends} # quectel modify
  385. WORKING_DIRECTORY ${SOURCE_TOP_DIR}
  386. )
  387. add_custom_target(${nvmvariant}_pacgen ALL DEPENDS ${pac_file})
  388. endforeach()
  389. endfunction()