buildx.lua 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. function chip()
  2. local conf_data = io.readfile("$(projectdir)/app/port/luat_conf_bsp.h")
  3. local LUAT_FS_SIZE = tonumber(conf_data:match("#define LUAT_FS_SIZE%s+(%d+)"))
  4. LUAT_SCRIPT_SIZE = tonumber(conf_data:match("#define LUAT_SCRIPT_SIZE%s+(%d+)"))
  5. AIR10X_FLASH_FS_REGION_SIZE = LUAT_FS_SIZE + LUAT_SCRIPT_SIZE
  6. -- print(AIR10X_FLASH_FS_REGION_SIZE,LUAT_FS_SIZE , LUAT_SCRIPT_SIZE)
  7. AIR10X_VERSION = conf_data:match("#define LUAT_BSP_VERSION \"(%w+)\"")
  8. local LVGL_CONF = conf_data:find("\r#define LUAT_USE_LVGL") or conf_data:find("\n#define LUAT_USE_LVGL")
  9. VM_64BIT = conf_data:find("\r#define LUAT_CONF_VM_64bit") or conf_data:find("\n#define LUAT_CONF_VM_64bit")
  10. local custom_data = io.readfile("$(projectdir)/app/port/luat_conf_bsp.h")
  11. local FDB_CONF = conf_data:find("\r#define LUAT_USE_FDB") or conf_data:find("\n#define LUAT_USE_FDB") or conf_data:find("\r#define LUAT_USE_FSKV") or conf_data:find("\n#define LUAT_USE_FSKV")
  12. local FOTA_CONF = conf_data:find("\r#define LUAT_USE_FOTA") or conf_data:find("\n#define LUAT_USE_FOTA")
  13. local WLAN_CONF = conf_data:find("\r#define LUAT_USE_WLAN") or conf_data:find("\n#define LUAT_USE_WLAN")
  14. local NIMBLE_CONF = conf_data:find("\r#define LUAT_USE_NIMBLE") or conf_data:find("\n#define LUAT_USE_NIMBLE")
  15. local TLS_CONF = conf_data:find("\r#define LUAT_USE_TLS") or conf_data:find("\n#define LUAT_USE_TLS")
  16. -- 根据型号判断flash大小
  17. local is_air101 = custom_data:find("\r#define AIR101") or custom_data:find("\n#define AIR101")
  18. local is_air103 = custom_data:find("\r#define AIR103") or custom_data:find("\n#define AIR103")
  19. local is_air601 = custom_data:find("\r#define AIR601") or custom_data:find("\n#define AIR601")
  20. local is_air690 = custom_data:find("\r#define AIR690") or custom_data:find("\n#define AIR690")
  21. local flash_size = 1*1024*1024
  22. if is_air101 or is_air690 then
  23. flash_size = 2*1024*1024
  24. end
  25. -- 如果是air601/690,那么wlan肯定是开启的
  26. if is_air601 or is_air690 then
  27. WLAN_CONF = true
  28. end
  29. -- 然后, 根据flash大小, 计算flash的分区
  30. local flash_fs_size = LUAT_FS_SIZE * 1024 -- 这个直接取宏定义的值
  31. local flash_script_size = LUAT_SCRIPT_SIZE * 1024 -- 这个直接取宏定义的值
  32. local flash_kv_size = FDB_CONF and 64*1024 or 0 -- 如果是FDB, 则需要预留64k
  33. local flash_fota_size = 4 * 1024
  34. -- APP区域大小 = 剩余flash大小 - fs分区大小 - script分区大小 - kv分区大小 - secboot区域大小 - 末尾分区64k - OTA区域大小(按比例)
  35. local flash_app_size = flash_size - (flash_fs_size + flash_script_size + flash_kv_size) - 16*1024 - 64*1024
  36. if FOTA_CONF then
  37. flash_fota_size = (flash_app_size + flash_script_size // 4 * 3) // 2 // 5 * 4
  38. flash_fota_size = flash_fota_size // 4096
  39. flash_fota_size = flash_fota_size * 4096
  40. end
  41. flash_app_size = flash_app_size - flash_fota_size - 1024 -- 末尾还需要加1k的image head
  42. local flash_app_offset = 64*1024 + flash_fota_size + 0x08000000 + 1024
  43. local ISRAM = string.format("I-SRAM : ORIGIN = 0x%x , LENGTH = 0x%x", flash_app_offset, flash_app_size)
  44. print("文件系统大小", flash_fs_size // 1024, "kb")
  45. print("脚本区大小", flash_script_size // 1024, "kb")
  46. print("KV区大小", flash_kv_size // 1024, "kb")
  47. print("底层固件区大小", flash_app_size // 1024, "kb")
  48. print("FOTA区大小", flash_fota_size // 1024, "kb")
  49. print("ISRAM", ISRAM)
  50. if is_air101 then TARGET_NAME = "AIR101"
  51. elseif is_air103 then TARGET_NAME = "AIR103"
  52. elseif is_air601 then TARGET_NAME = "AIR601"
  53. elseif is_air690 then TARGET_NAME = "AIR690"
  54. else TARGET_NAME = "AIR10X" end
  55. -- 处理内存大小
  56. local ram_end = 0x20028000
  57. if WLAN_CONF and NIMBLE_CONF and TLS_CONF then
  58. ram_end = ram_end + 32 * 1024
  59. end
  60. local result = {}
  61. result.target_name = TARGET_NAME
  62. result.flash_size = flash_size
  63. result.flash_fs_size = flash_fs_size
  64. result.flash_script_size = flash_script_size
  65. result.flash_kv_size = flash_kv_size
  66. result.flash_app_size = flash_app_size
  67. result.flash_app_offset = flash_app_offset
  68. result.flash_fota_size = flash_fota_size
  69. result.flash_app_offset = flash_app_offset
  70. result.ISRAM = ISRAM
  71. result.is_air101 = is_air101
  72. result.is_air103 = is_air103
  73. result.is_air601 = is_air601
  74. result.is_air690 = is_air690
  75. result.use_lvgl = LVGL_CONF
  76. result.use_fota = FOTA_CONF
  77. result.use_fdb = FDB_CONF
  78. result.bsp_version = AIR10X_VERSION
  79. result.use_64bit = VM_64BIT
  80. result.use_wlan = WLAN_CONF
  81. result.use_nimble = NIMBLE_CONF
  82. result.use_tls = TLS_CONF
  83. result.ram_end = ram_end
  84. return result
  85. end