Skip to content

Commit

Permalink
fix: components isolation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nullptr committed Oct 11, 2023
1 parent 4ce15e2 commit 38f84c9
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 39 deletions.
4 changes: 2 additions & 2 deletions core/data/el_data_models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

#include "el_data_models.h"

#include <algorithm>

#ifdef CONFIG_EL_MODEL

#include <algorithm>

namespace edgelab {

Models::Models()
Expand Down
11 changes: 6 additions & 5 deletions core/data/el_data_models.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
#ifndef _EL_DATA_MODELS_H_
#define _EL_DATA_MODELS_H_

#include <cstdint>
#include <forward_list>

#include "core/el_config_internal.h"
#include "core/el_debug.h"
#include "core/el_types.h"

#ifdef CONFIG_EL_MODEL

#include <cstdint>
#include <forward_list>

#include "core/el_debug.h"
#include "core/el_types.h"
#include "porting/el_flash.h"

namespace edgelab {
Expand Down
30 changes: 16 additions & 14 deletions core/data/el_data_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,25 @@
#ifndef _EL_DATA_STORAGE_HPP_
#define _EL_DATA_STORAGE_HPP_

#include <algorithm>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <forward_list>
#include <iterator>
#include <type_traits>
#include <utility>

#include "core/el_config_internal.h"
#include "core/el_debug.h"
#include "core/el_types.h"
#include "core/synchronize/el_guard.hpp"
#include "core/synchronize/el_mutex.hpp"

#ifdef CONFIG_EL_STORAGE

#include <algorithm>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <forward_list>
#include <iterator>
#include <type_traits>
#include <utility>

#include "core/el_debug.h"
#include "core/el_types.h"
#include "core/synchronize/el_guard.hpp"
#include "core/synchronize/el_mutex.hpp"

#ifdef CONFIG_EL_LIB_FLASHDB
#include "third_party/FlashDB/flashdb.h"
#endif
Expand Down
4 changes: 0 additions & 4 deletions core/el_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
#ifndef _EL_CONFIG_H_
#define _EL_CONFIG_H_

/* optional */
// #define CONFIG_EL_MODEL
// #define CONFIG_EL_STORAGE

/* thirdparty */
// #define CONFIG_EL_LIB_FLASHDB
// #define CONFIG_EL_LIB_JPEGENC
Expand Down
18 changes: 4 additions & 14 deletions core/el_config_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,16 @@
#endif

/* model related config */
#ifdef CONFIG_EL_MODEL
#ifndef CONFIG_EL_MODEL
#define CONFIG_EL_MODEL
#define CONFIG_EL_MODEL_TFLITE_MAGIC 0x54464C33
#define CONFIG_EL_MODEL_HEADER_MAGIC 0x4C4854
#define CONFIG_EL_MODEL_PARTITION_NAME "models"
#else
#define CONFIG_EL_MODEL_TFLITE_MAGIC 0xFFFFFFFF
#define CONFIG_EL_MODEL_HEADER_MAGIC 0xFFFFFF
#define CONFIG_EL_MODEL_PARTITION_NAME ""
#endif

/* storage related config */
#ifdef CONFIG_EL_STORAGE
#ifndef CONFIG_EL_STORAGE
#define CONFIG_EL_STORAGE
#ifndef CONFIG_EL_LIB_FLASHDB
#warning "Storage depends on FlashDB."
#endif
Expand All @@ -106,14 +104,6 @@
#define CONFIG_EL_STORAGE_PARTITION_FS_NAME_0 "kvdb0"
#define CONFIG_EL_STORAGE_PARTITION_FS_SIZE_0 (192 * 1024)
#define CONFIG_EL_STORAGE_KEY_SIZE_MAX (64)
#else
#define CONFIG_EL_STORAGE_NAME ""
#define CONFIG_EL_STORAGE_PATH ""
#define CONFIG_EL_STORAGE_PARTITION_NAME ""
#define CONFIG_EL_STORAGE_PARTITION_MOUNT_POINT ""
#define CONFIG_EL_STORAGE_PARTITION_FS_NAME_0 ""
#define CONFIG_EL_STORAGE_PARTITION_FS_SIZE_0 (192 * 1024)
#define CONFIG_EL_STORAGE_KEY_SIZE_MAX (64)
#endif

#endif
4 changes: 4 additions & 0 deletions porting/espressif/el_flash_esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

namespace edgelab {

#ifdef CONFIG_EL_MODEL

el_err_code_t el_model_partition_mmap_init(const char* partition_name,
uint32_t* partition_start_addr,
uint32_t* partition_size,
Expand All @@ -55,6 +57,8 @@ el_err_code_t el_model_partition_mmap_init(const char* partition_na

void el_model_partition_mmap_deinit(spi_flash_mmap_handle_t* mmap_handler) { spi_flash_munmap(*mmap_handler); }

#endif

#ifdef CONFIG_EL_LIB_FLASHDB

static Mutex el_flash_db_lock;
Expand Down
4 changes: 4 additions & 0 deletions porting/espressif/el_flash_esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ namespace edgelab {
extern "C" {
#endif

#ifdef CONFIG_EL_MODEL

typedef spi_flash_mmap_handle_t el_model_mmap_handler_t;

el_err_code_t el_model_partition_mmap_init(const char* partition_name,
Expand All @@ -47,6 +49,8 @@ el_err_code_t el_model_partition_mmap_init(const char* partition_na

void el_model_partition_mmap_deinit(el_model_mmap_handler_t* mmap_handler);

#endif

#ifdef CONFIG_EL_LIB_FLASHDB
#include "third_party/FlashDB/fal_def.h"

Expand Down
4 changes: 4 additions & 0 deletions porting/himax/el_flash_himax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

namespace edgelab {

#ifdef CONFIG_EL_MODEL

el_err_code_t el_model_partition_mmap_init(const char* partition_name,
uint32_t* partition_start_addr,
uint32_t* partition_size,
Expand All @@ -41,6 +43,8 @@ el_err_code_t el_model_partition_mmap_init(const char* partition_na

void el_model_partition_mmap_deinit(el_model_mmap_handler_t* mmap_handler) {}

#endif

#ifdef CONFIG_EL_LIB_FLASHDB

static int el_flash_db_init(void) { return 1; }
Expand Down
5 changes: 5 additions & 0 deletions porting/himax/el_flash_himax.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ extern "C" {
namespace edgelab {
#endif

#ifdef CONFIG_EL_MODEL

typedef int8_t el_model_mmap_handler_t;

el_err_code_t el_model_partition_mmap_init(const char* partition_name,
Expand All @@ -44,7 +46,10 @@ el_err_code_t el_model_partition_mmap_init(const char* partition_na

void el_model_partition_mmap_deinit(el_model_mmap_handler_t* mmap_handler);

#endif

#ifdef CONFIG_EL_LIB_FLASHDB

#include "third_party/FlashDB/fal_def.h"

#define NOR_FLASH_DEV_NAME CONFIG_EL_STORAGE_PARTITION_MOUNT_POINT
Expand Down

0 comments on commit 38f84c9

Please sign in to comment.