luat_fs_air101.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #ifndef FLASH_FS_REGION_SIZE
  25. #define FLASH_FS_REGION_SIZE 112
  26. #endif
  27. extern const struct luat_vfs_filesystem vfs_fs_lfs2;
  28. extern const char luadb_inline_sys[];
  29. extern const struct luat_vfs_filesystem vfs_fs_luadb;
  30. extern const struct luat_vfs_filesystem vfs_fs_ram;
  31. extern size_t luat_luadb_act_size;
  32. #ifdef LUAT_USE_LVGL
  33. #include "lvgl.h"
  34. void luat_lv_fs_init(void);
  35. // void lv_bmp_init(void);
  36. // void lv_png_init(void);
  37. void lv_split_jpeg_init(void);
  38. #endif
  39. // 调整LUADB文件系统大小, 必须是 48+64*N, N为整数. 例如 48+64, 48+128
  40. #ifndef LUAT_FS_SIZE
  41. #define LUAT_FS_SIZE (48)
  42. #endif
  43. void luat_fs_update_addr(void) {
  44. //luat_timer_mdelay(1000);
  45. #if (defined(AIR103) || defined(AIR601))
  46. luadb_addr = 0x0E0000 - (FLASH_FS_REGION_SIZE - 112) * 1024U;
  47. #else
  48. luadb_addr = 0x1E0000 - (FLASH_FS_REGION_SIZE - 112) * 1024U;
  49. #endif
  50. //LLOGD("luadb_addr 0x%08X", luadb_addr);
  51. //LLOGD("luadb_addr ptr %p", ptr);
  52. #if (defined(AIR103) || defined(AIR601))
  53. lfs_addr = 0x0FC000 - (LUAT_FS_SIZE*1024);
  54. lfs_size_kb = LUAT_FS_SIZE;
  55. #else
  56. lfs_addr = 0x1FC000 - (LUAT_FS_SIZE*1024);
  57. lfs_size_kb = LUAT_FS_SIZE;
  58. #endif
  59. kv_addr = luadb_addr - kv_size_kb*1024U;
  60. // }
  61. //LLOGD("lfs addr4 %p", &lfs_addr);
  62. //LLOGD("lfs addr5 0x%08X", lfs_addr);
  63. //LLOGD("luadb_addr 0x%08X", luadb_addr);
  64. }
  65. int luat_fs_init(void) {
  66. uint8_t *ptr = (uint8_t*)(luadb_addr + 0x8000000); //0x80E0000
  67. LFS_Init();
  68. luat_vfs_reg(&vfs_fs_lfs2);
  69. luat_fs_conf_t conf = {
  70. .busname = &lfs,
  71. .type = "lfs2",
  72. .filesystem = "lfs2",
  73. .mount_point = "/"
  74. };
  75. luat_fs_mount(&conf);
  76. luat_vfs_reg(&vfs_fs_ram);
  77. luat_fs_conf_t conf3 = {
  78. .busname = NULL,
  79. .type = "ram",
  80. .filesystem = "ram",
  81. .mount_point = "/ram/"
  82. };
  83. luat_fs_mount(&conf3);
  84. luat_vfs_reg(&vfs_fs_luadb);
  85. luat_fs_conf_t conf2 = {
  86. .busname = (char*)(ptr),
  87. .type = "luadb",
  88. .filesystem = "luadb",
  89. .mount_point = "/luadb/",
  90. };
  91. luat_fs_mount(&conf2);
  92. luat_luadb_act_size = (FLASH_FS_REGION_SIZE - 112);
  93. #ifdef LUAT_USE_LVGL
  94. luat_lv_fs_init();
  95. // lv_bmp_init();
  96. // lv_png_init();
  97. lv_split_jpeg_init();
  98. #endif
  99. return 0;
  100. }