luat_fs_air101.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. void luat_fs_update_addr(void) {
  37. LLOGD("可读写文件系统大小 %d kb", LUAT_FS_SIZE);
  38. #if (defined(AIR103) || defined(AIR601))
  39. luadb_addr = 0x0E0000 - (LUAT_FS_SIZE + LUAT_SCRIPT_SIZE - 112) * 1024U;
  40. #else
  41. luadb_addr = 0x1E0000 - (LUAT_FS_SIZE + LUAT_SCRIPT_SIZE - 112) * 1024U;
  42. #endif
  43. //LLOGD("luadb_addr 0x%08X", luadb_addr);
  44. //LLOGD("luadb_addr ptr %p", ptr);
  45. #if (defined(AIR103) || defined(AIR601))
  46. lfs_addr = 0x0FC000 - (LUAT_FS_SIZE*1024);
  47. lfs_size_kb = LUAT_FS_SIZE;
  48. #else
  49. lfs_addr = 0x1FC000 - (LUAT_FS_SIZE*1024);
  50. lfs_size_kb = LUAT_FS_SIZE;
  51. #endif
  52. kv_addr = luadb_addr - kv_size_kb*1024U;
  53. // }
  54. //LLOGD("lfs addr4 %p", &lfs_addr);
  55. //LLOGD("lfs addr5 0x%08X", lfs_addr);
  56. //LLOGD("luadb_addr 0x%08X", luadb_addr);
  57. }
  58. int luat_fs_init(void) {
  59. uint8_t *ptr = (uint8_t*)(luadb_addr + 0x8000000); //0x80E0000
  60. LFS_Init();
  61. luat_vfs_reg(&vfs_fs_lfs2);
  62. luat_fs_conf_t conf = {
  63. .busname = &lfs,
  64. .type = "lfs2",
  65. .filesystem = "lfs2",
  66. .mount_point = "/"
  67. };
  68. luat_fs_mount(&conf);
  69. luat_vfs_reg(&vfs_fs_ram);
  70. luat_fs_conf_t conf3 = {
  71. .busname = NULL,
  72. .type = "ram",
  73. .filesystem = "ram",
  74. .mount_point = "/ram/"
  75. };
  76. luat_fs_mount(&conf3);
  77. luat_vfs_reg(&vfs_fs_luadb);
  78. luat_fs_conf_t conf2 = {
  79. .busname = (char*)(ptr),
  80. .type = "luadb",
  81. .filesystem = "luadb",
  82. .mount_point = "/luadb/",
  83. };
  84. luat_fs_mount(&conf2);
  85. luat_luadb_act_size = LUAT_SCRIPT_SIZE;
  86. #ifdef LUAT_USE_LVGL
  87. luat_lv_fs_init();
  88. // lv_bmp_init();
  89. // lv_png_init();
  90. lv_split_jpeg_init();
  91. #endif
  92. return 0;
  93. }