luat_fs_air101.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // #include "luat_conf_bsp.h"
  2. #include "luat_base.h"
  3. #include "luat_fs.h"
  4. #define LUAT_LOG_TAG "fs"
  5. #include "luat_log.h"
  6. #include "lfs_port.h"
  7. #include "wm_include.h"
  8. #include "luat_timer.h"
  9. #include "stdio.h"
  10. #include "luat_ota.h"
  11. #include "wm_internal_flash.h"
  12. extern struct lfs_config lfs_cfg;
  13. extern lfs_t lfs;
  14. // 分区信息
  15. // KV -- 64k
  16. // luadb -- N k
  17. // lfs - (112 + 64 - N)k
  18. uint32_t kv_addr;
  19. uint32_t kv_size_kb = 64;
  20. uint32_t luadb_addr;
  21. uint32_t luadb_size_kb;
  22. uint32_t lfs_addr;
  23. uint32_t lfs_size_kb;
  24. extern const struct luat_vfs_filesystem vfs_fs_lfs2;
  25. extern const char luadb_inline_sys[];
  26. extern const struct luat_vfs_filesystem vfs_fs_luadb;
  27. extern const struct luat_vfs_filesystem vfs_fs_ram;
  28. extern size_t luat_luadb_act_size;
  29. #ifdef LUAT_USE_LVGL
  30. #include "lvgl.h"
  31. void luat_lv_fs_init(void);
  32. // void lv_bmp_init(void);
  33. // void lv_png_init(void);
  34. void lv_split_jpeg_init(void);
  35. #endif
  36. // 调整LUADB文件系统大小, 必须是 48+64*N, N为整数. 例如 48+64, 48+128
  37. #ifndef LUAT_FS_SIZE
  38. #define LUAT_FS_SIZE (48)
  39. #endif
  40. void luat_fs_update_addr(void) {
  41. //luat_timer_mdelay(1000);
  42. #if (defined(AIR103) || defined(AIR601))
  43. luadb_addr = 0x0E0000 - (LUAT_FS_SIZE + LUAT_SCRIPT_SIZE - 112) * 1024U;
  44. #else
  45. luadb_addr = 0x1E0000 - (LUAT_FS_SIZE + LUAT_SCRIPT_SIZE - 112) * 1024U;
  46. #endif
  47. //LLOGD("luadb_addr 0x%08X", luadb_addr);
  48. //LLOGD("luadb_addr ptr %p", ptr);
  49. #if (defined(AIR103) || defined(AIR601))
  50. lfs_addr = 0x0FC000 - (LUAT_FS_SIZE*1024);
  51. lfs_size_kb = LUAT_FS_SIZE;
  52. #else
  53. lfs_addr = 0x1FC000 - (LUAT_FS_SIZE*1024);
  54. lfs_size_kb = LUAT_FS_SIZE;
  55. #endif
  56. kv_addr = luadb_addr - kv_size_kb*1024U;
  57. // }
  58. //LLOGD("lfs addr4 %p", &lfs_addr);
  59. //LLOGD("lfs addr5 0x%08X", lfs_addr);
  60. //LLOGD("luadb_addr 0x%08X", luadb_addr);
  61. }
  62. int luat_fs_init(void) {
  63. uint8_t *ptr = (uint8_t*)(luadb_addr + 0x8000000); //0x80E0000
  64. LFS_Init();
  65. luat_vfs_reg(&vfs_fs_lfs2);
  66. luat_fs_conf_t conf = {
  67. .busname = &lfs,
  68. .type = "lfs2",
  69. .filesystem = "lfs2",
  70. .mount_point = "/"
  71. };
  72. luat_fs_mount(&conf);
  73. luat_vfs_reg(&vfs_fs_ram);
  74. luat_fs_conf_t conf3 = {
  75. .busname = NULL,
  76. .type = "ram",
  77. .filesystem = "ram",
  78. .mount_point = "/ram/"
  79. };
  80. luat_fs_mount(&conf3);
  81. luat_vfs_reg(&vfs_fs_luadb);
  82. luat_fs_conf_t conf2 = {
  83. .busname = (char*)(ptr),
  84. .type = "luadb",
  85. .filesystem = "luadb",
  86. .mount_point = "/luadb/",
  87. };
  88. luat_fs_mount(&conf2);
  89. luat_luadb_act_size = LUAT_SCRIPT_SIZE;
  90. #ifdef LUAT_USE_LVGL
  91. luat_lv_fs_init();
  92. // lv_bmp_init();
  93. // lv_png_init();
  94. lv_split_jpeg_init();
  95. #endif
  96. return 0;
  97. }