Переглянути джерело

add: 把fdb适配加上,但libgnss竟然依赖uart,我是没忘记了的-_-

Wendal Chen 3 роки тому
батько
коміт
92f1470540

+ 6 - 0
luatos/components/luat/CMakeLists.txt

@@ -9,6 +9,9 @@ idf_component_register(SRC_DIRS ${LUATOS_ROOT}/luat/modules
                                 ${LUATOS_ROOT}/components/miniz
                                 ${LUATOS_ROOT}/components/serialization/protobuf
                                 ${LUATOS_ROOT}/components/coremark
+                                ${LUATOS_ROOT}/components/fal/src
+                                ${LUATOS_ROOT}/components/flashdb/src
+                                ${LUATOS_ROOT}/components/minmea
                     EXCLUDE_SRCS
                                 ${LUATOS_ROOT}/luat/modules/luat_lib_http.c
                     INCLUDE_DIRS ../../include
@@ -22,6 +25,9 @@ idf_component_register(SRC_DIRS ${LUATOS_ROOT}/luat/modules
                                 ${LUATOS_ROOT}/components/miniz
                                 ${LUATOS_ROOT}/components/serialization/protobuf
                                 ${LUATOS_ROOT}/components/coremark
+                                ${LUATOS_ROOT}/components/fal/inc
+                                ${LUATOS_ROOT}/components/flashdb/inc
+                                ${LUATOS_ROOT}/components/minmea
                     REQUIRES esp-tls lwip esp_http_client mbedtls spiffs driver heap
                     )
 

+ 1 - 0
luatos/components/luat/port/luat_base_idf5.c

@@ -181,6 +181,7 @@ static const luaL_Reg loadedlibs[] = {
 #ifdef LUAT_USE_IOTAUTH
   {"iotauth", luaopen_iotauth},
 #endif
+  {"http2", luaopen_http},
   {NULL, NULL}
 };
 

+ 48 - 0
luatos/components/luat/port/luat_sfd_idf5_onchip.c

@@ -0,0 +1,48 @@
+#include "luat_base.h"
+#include "luat_sfd.h"
+
+#include "esp_err.h"
+#include "esp_system.h"
+#include "esp_partition.h"
+
+#define LUAT_LOG_TAG "sfd"
+#include "luat_log.h"
+
+// 存放fdb分区的引用
+static const esp_partition_t * fdb_partition;
+
+// 初始化, 把分区读出来就行
+int sfd_onchip_init (void* userdata) {
+    fdb_partition = esp_partition_find_first(0x5A, 0x5B, "fdb");
+    if (fdb_partition == NULL) {
+        LLOGE("fdb partition NOT Found");
+        return -1;
+    }
+    return 0;
+}
+
+// 读取状态
+int sfd_onchip_status (void* userdata) {
+    return fdb_partition == NULL ? -1 : 0;
+}
+
+// 下面就是flash的常规操作了, read/write/erase/ioctl
+int sfd_onchip_read (void* userdata, char* buff, size_t offset, size_t len) {
+    int ret = esp_partition_read(fdb_partition,  offset, buff, len);
+    return ret >= 0 ? len : -1;
+}
+
+int sfd_onchip_write (void* userdata, const char* buff, size_t offset, size_t len) {
+    int ret = esp_partition_write(fdb_partition, offset, buff, len);
+    return ret >= 0 ? len : -1;
+}
+
+int sfd_onchip_erase (void* userdata, size_t offset, size_t len) {
+    int ret = esp_partition_erase_range(fdb_partition, offset, len);
+    return ret >= 0 ? len : -1;
+}
+
+int sfd_onchip_ioctl (void* userdata, size_t cmd, void* buff) {
+    // 不支持, 也用不到
+    return 0;
+}

+ 2 - 2
luatos/include/luat_conf_bsp.h

@@ -46,7 +46,7 @@
 #define LUAT_USE_ZBUFF  1
 #define LUAT_USE_PACK  1
 // #define LUAT_USE_LIBGNSS  1
-// #define LUAT_USE_FS  1
+#define LUAT_USE_FS  1
 // #define LUAT_USE_SENSOR  1
 // #define LUAT_USE_SFUD  1
 // #define LUAT_USE_STATEM 1
@@ -55,7 +55,7 @@
 // #define LUAT_USE_ZLIB 1 
 // #define LUAT_USE_IR 1
 // FDB 提供kv数据库, 与nvm库类似
-// #define LUAT_USE_FDB 1
+#define LUAT_USE_FDB 1
 // #define LUAT_USE_OTA 1
 // #define LUAT_USE_I2CTOOLS 1
 // #define LUAT_USE_LORA 1