luat_fs_air101.c 2.4 KB

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