IDF release/v4.4 f23dcd3555 (#5996)

esp-dsp: master 6b25cbb
esp-face: master d141502
esp-rainmaker: f1b82c7
esp32-camera: master 61400bc
esp_littlefs: master 3c29afc
This commit is contained in:
Me No Dev
2021-12-14 16:38:06 +02:00
committed by GitHub
parent 7bb30b3cf8
commit 6d400df952
348 changed files with 2934 additions and 932 deletions

File diff suppressed because one or more lines are too long

View File

@ -81,7 +81,6 @@ env.Append(
"-Wl,--gc-sections", "-Wl,--gc-sections",
"-fno-rtti", "-fno-rtti",
"-fno-lto", "-fno-lto",
"-Wl,--wrap=mbedtls_mpi_exp_mod",
"-Wl,--wrap=longjmp", "-Wl,--wrap=longjmp",
"-Wl,--undefined=uxTopUsedPriority", "-Wl,--undefined=uxTopUsedPriority",
"-T", "esp32.rom.redefined.ld", "-T", "esp32.rom.redefined.ld",
@ -304,7 +303,7 @@ env.Append(
"UNITY_INCLUDE_CONFIG_H", "UNITY_INCLUDE_CONFIG_H",
"WITH_POSIX", "WITH_POSIX",
"_GNU_SOURCE", "_GNU_SOURCE",
("IDF_VER", '\\"v4.4-dev-3703-gddc44956bf\\"'), ("IDF_VER", '\\"v4.4-beta1-183-gf23dcd3555\\"'),
"ESP_PLATFORM", "ESP_PLATFORM",
"_POSIX_READER_WRITER_LOCKS", "_POSIX_READER_WRITER_LOCKS",
"ARDUINO_ARCH_ESP32", "ARDUINO_ARCH_ESP32",

View File

@ -81,7 +81,6 @@ env.Append(
"-Wl,--gc-sections", "-Wl,--gc-sections",
"-fno-rtti", "-fno-rtti",
"-fno-lto", "-fno-lto",
"-Wl,--wrap=mbedtls_mpi_exp_mod",
"-Wl,--undefined=uxTopUsedPriority", "-Wl,--undefined=uxTopUsedPriority",
"-Wl,--wrap=_Unwind_SetEnableExceptionFdeSorting", "-Wl,--wrap=_Unwind_SetEnableExceptionFdeSorting",
"-Wl,--wrap=__register_frame_info_bases", "-Wl,--wrap=__register_frame_info_bases",
@ -294,7 +293,7 @@ env.Append(
"UNITY_INCLUDE_CONFIG_H", "UNITY_INCLUDE_CONFIG_H",
"WITH_POSIX", "WITH_POSIX",
"_GNU_SOURCE", "_GNU_SOURCE",
("IDF_VER", '\\"v4.4-dev-3703-gddc44956bf\\"'), ("IDF_VER", '\\"v4.4-beta1-183-gf23dcd3555\\"'),
"ESP_PLATFORM", "ESP_PLATFORM",
"_POSIX_READER_WRITER_LOCKS", "_POSIX_READER_WRITER_LOCKS",
"ARDUINO_ARCH_ESP32", "ARDUINO_ARCH_ESP32",

View File

@ -290,7 +290,7 @@ env.Append(
"UNITY_INCLUDE_CONFIG_H", "UNITY_INCLUDE_CONFIG_H",
"WITH_POSIX", "WITH_POSIX",
"_GNU_SOURCE", "_GNU_SOURCE",
("IDF_VER", '\\"v4.4-dev-3703-gddc44956bf\\"'), ("IDF_VER", '\\"v4.4-beta1-183-gf23dcd3555\\"'),
"ESP_PLATFORM", "ESP_PLATFORM",
"_POSIX_READER_WRITER_LOCKS", "_POSIX_READER_WRITER_LOCKS",
"ARDUINO_ARCH_ESP32", "ARDUINO_ARCH_ESP32",

View File

@ -68,7 +68,7 @@ typedef struct {
*/ */
static inline void esp_apptrace_lock_init(esp_apptrace_lock_t *lock) static inline void esp_apptrace_lock_init(esp_apptrace_lock_t *lock)
{ {
vPortCPUInitializeMutex(&lock->mux); portMUX_INITIALIZE(&lock->mux);
lock->int_state = 0; lock->int_state = 0;
} }

View File

@ -291,6 +291,7 @@
#define CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0 1 #define CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0 1
#define CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN 752 #define CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN 752
#define CONFIG_ESP32_WIFI_MGMT_SBUF_NUM 32 #define CONFIG_ESP32_WIFI_MGMT_SBUF_NUM 32
#define CONFIG_ESP_WIFI_SOFTAP_SUPPORT 1
#define CONFIG_ESP_COREDUMP_ENABLE_TO_NONE 1 #define CONFIG_ESP_COREDUMP_ENABLE_TO_NONE 1
#define CONFIG_FATFS_CODEPAGE_850 1 #define CONFIG_FATFS_CODEPAGE_850 1
#define CONFIG_FATFS_CODEPAGE 850 #define CONFIG_FATFS_CODEPAGE 850
@ -676,5 +677,5 @@
#define CONFIG_ULP_COPROC_RESERVE_MEM CONFIG_ESP32_ULP_COPROC_RESERVE_MEM #define CONFIG_ULP_COPROC_RESERVE_MEM CONFIG_ESP32_ULP_COPROC_RESERVE_MEM
#define CONFIG_WARN_WRITE_STRINGS CONFIG_COMPILER_WARN_WRITE_STRINGS #define CONFIG_WARN_WRITE_STRINGS CONFIG_COMPILER_WARN_WRITE_STRINGS
#define CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP #define CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
#define CONFIG_ARDUINO_IDF_COMMIT "ddc44956bf" #define CONFIG_ARDUINO_IDF_COMMIT "f23dcd3555"
#define CONFIG_ARDUINO_IDF_BRANCH "release/v4.4" #define CONFIG_ARDUINO_IDF_BRANCH "release/v4.4"

View File

@ -48,6 +48,15 @@ namespace dl
output[2] = input & 0xF8; // red output[2] = input & 0xF8; // red
} }
/**
* @brief Convert RGB565 image to RGB888 image.
*
* @param image ptr of RGB565 image
* @param image_shape shape of the input image
* @return Tensor<uint8_t>* output RGB88 image
*/
Tensor<uint8_t> *convert_image_rgb565_to_rgb888(uint16_t *image, std::vector<int> &image_shape);
/** /**
* @brief Convert RGB565 pixel to Gray. * @brief Convert RGB565 pixel to Gray.
* *
@ -435,5 +444,48 @@ namespace dl
*/ */
Tensor<uint8_t> *rgb2hsv(Tensor<uint8_t> &image, bool bgr = false, bool fast = true); Tensor<uint8_t> *rgb2hsv(Tensor<uint8_t> &image, bool bgr = false, bool fast = true);
/**
* @brief resize an image to the target shape.
*
* @param image the input image Tensor
* @param target_shape the target shape of the resized image.
* @param resize_type one of IMAGE_RESIZE_BILINEAR or IMAGE_RESIZE_MEAN or IMAGE_RESIZE_NEAREST
* @return Tensor<uint8_t>* the pointer of the resized image Tensor
*/
Tensor<uint8_t> *resize_image(Tensor<uint8_t> &image, std::vector<int> target_shape, resize_type_t resize_type);
/**
* @brief resize an image to the target shape.
*
* @param image the input image Tensor
* @param resized_image the resized image Tensor
* @param resize_type one of IMAGE_RESIZE_BILINEAR or IMAGE_RESIZE_MEAN or IMAGE_RESIZE_NEAREST
*/
void resize_image(Tensor<uint8_t> &image, Tensor<uint8_t> &resized_image, resize_type_t resize_type);
/**
* @brief resize an image to the target shape with nearest method.
*
* @tparam T
* @param image the pointer of the input image
* @param input_shape the input shape of the image
* @param target_shape the target shape of the resized image
* @return T* the pointer of the resized image
*/
template <typename T>
T *resize_image_nearest(T *image, std::vector<int> input_shape, std::vector<int> target_shape);
/**
* @brief resize an image to the target shape with nearest method.
*
* @tparam T
* @param image the pointer of the input image
* @param input_shape the input shape of the image
* @param resized_image the pointer of the resized image
* @param target_shape the target shape of the resized image
*/
template <typename T>
void resize_image_nearest(T *image, std::vector<int> input_shape, T *resized_image, std::vector<int> target_shape);
} // namespace image } // namespace image
} // namespace dl } // namespace dl

View File

@ -57,10 +57,10 @@ namespace dl
const char *name = "AvgPool2D") : Layer(name), const char *name = "AvgPool2D") : Layer(name),
output_exponent(output_exponent), output_exponent(output_exponent),
filter_shape(filter_shape), filter_shape(filter_shape),
padding_type(padding_type),
padding(padding),
stride_y(stride_y), stride_y(stride_y),
stride_x(stride_x), stride_x(stride_x),
padding_type(padding_type),
padding(padding),
output_shape({}) output_shape({})
{ {
this->output = new Tensor<feature_t>; this->output = new Tensor<feature_t>;

View File

@ -36,7 +36,10 @@ namespace dl
* false: the output will store to a separate memory * false: the output will store to a separate memory
*/ */
ExpandDims(std::vector<int> axis, const char *name = "ExpandDims", bool inplace = false) : Layer(name), ExpandDims(std::vector<int> axis, const char *name = "ExpandDims", bool inplace = false) : Layer(name),
axis(axis), inplace(inplace), output_shape({}) output_shape({}),
axis(axis),
output(NULL),
inplace(inplace)
{ {
} }

View File

@ -32,7 +32,7 @@ namespace dl
* @param inplace true: the output will store to input0 * @param inplace true: the output will store to input0
* false: the output will store to a separate memory * false: the output will store to a separate memory
*/ */
Flatten(const char *name = "Flatten", bool inplace = false) : Layer(name), inplace(inplace), output_shape({}) Flatten(const char *name = "Flatten", bool inplace = false) : Layer(name), output(NULL), inplace(inplace), output_shape({})
{} {}
/** /**

View File

@ -53,10 +53,10 @@ namespace dl
const int stride_x = 1, const int stride_x = 1,
const char *name = "MaxPool2D") : Layer(name), const char *name = "MaxPool2D") : Layer(name),
filter_shape(filter_shape), filter_shape(filter_shape),
padding_type(padding_type),
padding(padding),
stride_y(stride_y), stride_y(stride_y),
stride_x(stride_x), stride_x(stride_x),
padding_type(padding_type),
padding(padding),
output_shape({}) output_shape({})
{ {
this->output = new Tensor<feature_t>; this->output = new Tensor<feature_t>;

View File

@ -18,7 +18,7 @@ namespace dl
* - int8_t: stands for operation in int8_t quantize * - int8_t: stands for operation in int8_t quantize
*/ */
template <typename feature_t> template <typename feature_t>
class ReLU : public Layer class Relu : public Layer
{ {
private: private:
Tensor<feature_t> *output; /*<! output ptr of relu >*/ Tensor<feature_t> *output; /*<! output ptr of relu >*/
@ -33,7 +33,7 @@ namespace dl
* @param inplace true: the output will store to input0 * @param inplace true: the output will store to input0
* false: the output will store to a separate memory * false: the output will store to a separate memory
*/ */
ReLU(const char *name = "ReLU", bool inplace = false) : Layer(name), Relu(const char *name = "Relu", bool inplace = false) : Layer(name),
output(NULL), inplace(inplace), output_shape({}) output(NULL), inplace(inplace), output_shape({})
{ {
} }
@ -42,7 +42,7 @@ namespace dl
* @brief Destroy the ReLU object * @brief Destroy the ReLU object
* *
*/ */
~ReLU() ~Relu()
{ {
if ((!this->inplace) && (this->output != NULL)) if ((!this->inplace) && (this->output != NULL))
{ {

View File

@ -35,7 +35,9 @@ namespace dl
* false: the output will store to a separate memory * false: the output will store to a separate memory
*/ */
Reshape(std::vector<int> shape, const char *name = "Reshape", bool inplace = false) : Layer(name), Reshape(std::vector<int> shape, const char *name = "Reshape", bool inplace = false) : Layer(name),
output_shape(shape), inplace(inplace) output(NULL),
inplace(inplace),
output_shape(shape)
{ {
} }

View File

@ -35,7 +35,11 @@ namespace dl
* @param inplace true: the output will store to input0 * @param inplace true: the output will store to input0
* false: the output will store to a separate memory * false: the output will store to a separate memory
*/ */
Squeeze(int axis = INT32_MAX, const char *name = "Squeeze", bool inplace = false) : Layer(name), axis(axis), inplace(inplace), output_shape({}) Squeeze(int axis = INT32_MAX, const char *name = "Squeeze", bool inplace = false) : Layer(name),
output(NULL),
inplace(inplace),
axis(axis),
output_shape({})
{ {
} }

View File

@ -38,7 +38,11 @@ namespace dl
* false: the output will store to a separate memory * false: the output will store to a separate memory
*/ */
Sub2D(const int output_exponent, const Activation<feature_t> *activation = NULL, const char *name = "Sub2D", bool inplace = false) : Layer(name), Sub2D(const int output_exponent, const Activation<feature_t> *activation = NULL, const char *name = "Sub2D", bool inplace = false) : Layer(name),
output_exponent(output_exponent), activation(activation), output(NULL), inplace(inplace), output_shape({}) output_exponent(output_exponent),
activation(activation),
output(NULL),
inplace(inplace),
output_shape({})
{ {
} }

View File

@ -33,7 +33,11 @@ namespace dl
* @param inplace true: the output will store to input * @param inplace true: the output will store to input
* false: the output will store to a separate memory * false: the output will store to a separate memory
*/ */
Transpose(std::vector<int> perm = {}, const char *name = "Transpose", bool inplace = false) : Layer(name), perm(perm), inplace(inplace), output_shape({}) Transpose(std::vector<int> perm = {}, const char *name = "Transpose", bool inplace = false) : Layer(name),
output(NULL),
inplace(inplace),
perm(perm),
output_shape({})
{ {
} }

View File

@ -7,46 +7,143 @@ typedef struct
int area; /*!< Area of connected domains >*/ int area; /*!< Area of connected domains >*/
std::vector<int> center; /*<! centroid of connected domains [x, y] >*/ std::vector<int> center; /*<! centroid of connected domains [x, y] >*/
std::vector<int> box; /*<! [left_up_x, left_up_y, right_down_x, right_down_y] >*/ std::vector<int> box; /*<! [left_up_x, left_up_y, right_down_x, right_down_y] >*/
} components_stats_t; } color_detect_result_t;
typedef struct
{
std::vector<int> start_col;
std::vector<int> end_col;
std::vector<int> row;
std::vector<int> index;
std::vector<int> area;
} color_segment_result_t;
typedef struct
{
std::vector<uint8_t> color_thresh; /*!< threshold of colors, The threshold of each color is composed of 6 numbers >*/
int area_thresh; /*!< the area threshold of each color,
the area that is smaller than the threshold is filtered >*/
std::string name; /*!<name of the color>*/
} color_info_t;
class ColorDetector class ColorDetector
{ {
private: private:
std::vector<std::vector<components_stats_t>> results; /*!< detection results >*/ std::vector<std::vector<color_detect_result_t>> detection_results; /*!< detection results >*/
std::vector<color_segment_result_t> segmentation_results; /*!< segmentation results >*/
public: std::vector<color_info_t> registered_colors; /*!< the infomation of registered colors >*/
std::vector<std::vector<uint8_t>> color_thresh; /*!< threshold of colors, The threshold of each color is composed of 6 numbers >*/ std::vector<uint8_t> color_thresh_offset; /*!< HSV offset of the registered colors>*/
std::vector<int> area_thresh; /*!< the area threshold of each color, std::vector<int> detection_shape; /*!< the inference shape of images, the input image will be resized to this shape.
the area that is smaller than the threshold is filtered >*/ if the shape == {}, the input image will not be resized >*/
bool bgr; /*!< true: the input image is in BGR format bool bgr; /*!< true: the input image is in BGR format
false: the input image is in RGB format >*/ false: the input image is in RGB format >*/
int id_nums; /*!< the number of registered colors in history>*/
float h_ratio;
float w_ratio;
void color_detection_forward(dl::Tensor<uint8_t> &bin, int area_thresh);
public:
/** /**
* @brief get the color threshold of rectangular region in the image * @brief get the color threshold of rectangular region in the image
* *
* @param image the input image * @param image the input image in RGB888 format.
* @param box the coordinates of the rectanglar region : [left_up_x, left_up_y, right_down_x, right_down_y] * @param box the coordinates of the rectanglar region : [left_up_x, left_up_y, right_down_x, right_down_y]
* @return std::vector<uint8_t> the threshold. * @return std::vector<uint8_t> the threshold.
*/ */
std::vector<uint8_t> cal_color_thresh(dl::Tensor<uint8_t> &image, std::vector<int> box); std::vector<uint8_t> cal_color_thresh(dl::Tensor<uint8_t> &image, std::vector<int> box);
/**
* @brief get the color threshold of rectangular region in the image
*
* @param input the ptr of RGB565 image.
* @param input_shape shape of the input image.
* @param box the coordinates of the rectanglar region : [left_up_x, left_up_y, right_down_x, right_down_y]
* @return std::vector<uint8_t> the threshold.
*/
std::vector<uint8_t> cal_color_thresh(uint16_t *input, std::vector<int> input_shape, std::vector<int> box);
/**
* @brief register a new color to the color detector
*
* @param image the input image in RGB888 format.
* @param box the coordinates of the rectanglar region : [left_up_x, left_up_y, right_down_x, right_down_y]
* @param area_thresh the area threshold of the color
* @param id the index of the color
* @return int the number of the registered colors. if the id is not valid, return -1.
*/
int register_color(dl::Tensor<uint8_t> &image, std::vector<int> box, int area_thresh = 256, std::string color_name = "", int id = -1);
/**
* @brief register a new color to the color detector
*
* @param input the ptr of RGB565 image.
* @param input_shape shape of the input image.
* @param box the coordinates of the rectanglar region : [left_up_x, left_up_y, right_down_x, right_down_y]
* @param area_thresh the area threshold of the color
* @param id the index of the color
* @return int the number of the registered colors. if the id is not valid, return -1.
*/
int register_color(uint16_t *input, std::vector<int> input_shape, std::vector<int> box, int area_thresh = 256, std::string color_name = "", int id = -1);
/**
* @brief register a new color to the color detector
*
* @param color_thresh the color threshold
* @param area_thresh the area threshold of the color
* @param id the index of the color
* @return int the number of the registered colors. if the id is not valid, return -1.
*/
int register_color(std::vector<uint8_t> color_thresh, int area_thresh = 256, std::string color_name = "", int id = -1);
/**
* @brief delete a registered color
*
* @param id the index of the color
* @return int the number of the registered colors. if the id is not valid, return -1.
*/
int delete_color(int id = -1);
/**
* @brief delete a registered color
*
* @param color_name name of the registered_color
* @return int the number of the registered colors. if the id is not valid, return -1.
*/
int delete_color(std::string color_name);
/**
* @brief delete all the registered colors
*
*/
void clear_color();
/** /**
* @brief detect the colors based on the color thresholds * @brief detect the colors based on the color thresholds
* *
* @param image the input image. * @param image the input image.
* @return std::vector<std::vector<components_stats_t>>& detection result. * @return std::vector<std::vector<color_detect_result_t>>& detection result.
*/ */
std::vector<std::vector<components_stats_t>> &detect(dl::Tensor<uint8_t> &image); std::vector<std::vector<color_detect_result_t>> &detect(dl::Tensor<uint8_t> &image, std::vector<int> color_ids = {});
/**
* @brief
*
* @param input
* @param input_shape
* @return std::vector<std::vector<color_detect_result_t>>&
*/
std::vector<std::vector<color_detect_result_t>> &detect(uint16_t *input_shape, std::vector<int> shape, std::vector<int> color_ids = {});
/** /**
* @brief Construct a new Color Detector object * @brief Construct a new Color Detector object
* *
* @param color_thresh threshold of colors, The threshold of each color is composed of 6 numbers * @param color_thresh_offset HSV offset of the registered colors>
* @param area_thresh the area threshold of each color,the area that is smaller than the threshold is filtered * @param detection_shape the inference shape of images, the input image will be resized to this shape
* @param bgr true: the input image is in BGR format * @param bgr true: the input image is in BGR format
* false: the input image is in RGB format * false: the input image is in RGB format
*/ */
ColorDetector(std::vector<std::vector<uint8_t>> color_thresh, std::vector<int> area_thresh, bool bgr = false) : color_thresh(color_thresh), area_thresh(area_thresh), bgr(bgr) ColorDetector(std::vector<uint8_t> color_thresh_offset = {}, std::vector<int> detection_shape = {}, bool bgr = true) : color_thresh_offset(color_thresh_offset),
detection_shape(detection_shape), bgr(bgr), id_nums(0)
{ {
} }
@ -57,12 +154,213 @@ public:
~ColorDetector() {} ~ColorDetector() {}
/** /**
* @brief Get the results object * @brief Get the detection results object
* *
* @return std::vector<std::vector<components_stats_t>>& the detection result. * @return std::vector<std::vector<color_detect_result_t>>& the detection result.
*/ */
std::vector<std::vector<components_stats_t>> &get_results() std::vector<std::vector<color_detect_result_t>> &get_detection_results()
{ {
return this->results; return this->detection_results;
} }
/**
* @brief Get the segmentation results object
*
* @return std::vector<color_segment_result_t>& the segmentation result.
*/
std::vector<color_segment_result_t> &get_segmentation_results()
{
return this->segmentation_results;
}
/**
* @brief Get the registered colors object
*
* @return std::vector<color_info_t> the information of resgistered colors
*/
std::vector<color_info_t> get_registered_colors()
{
return this->registered_colors;
}
/**
* @brief Set the color thresh offset object
*
* @param color_thresh_offset the offset of color thresh for registered colors
* @return ColorDetector&
*/
ColorDetector &set_color_thresh_offset(std::vector<uint8_t> color_thresh_offset)
{
assert(color_thresh_offset.size() == 3);
this->color_thresh_offset = color_thresh_offset;
return *this;
}
/**
* @brief Get the color thresh offset object
*
* @return std::vector<uint8_t> color_thresh_offset
*/
std::vector<uint8_t> get_color_thresh_offset()
{
return this->color_thresh_offset;
}
/**
* @brief Set the area thresh object
*
* @param area_thresh the area thresh for each registered colors
* @return ColorDetector&
*/
ColorDetector &set_area_thresh(std::vector<int> area_thresh)
{
assert((area_thresh.size() == this->registered_colors.size()) || (area_thresh.size() == 1));
if (area_thresh.size() == 1)
{
for (int i = 0; i < this->registered_colors.size(); ++i)
{
this->registered_colors[i].area_thresh = area_thresh[0];
}
}
else
{
for (int i = 0; i < this->registered_colors.size(); ++i)
{
this->registered_colors[i].area_thresh = area_thresh[i];
}
}
return *this;
}
/**
* @brief Set the area thresh object
*
* @param area_thresh the area thresh for each registered colors
* @param id index of the registered color
* @return ColorDetector&
*/
ColorDetector &set_area_thresh(int area_thresh, int id)
{
assert((id >= 0) && (id < this->registered_colors.size()));
this->registered_colors[id].area_thresh = area_thresh;
return *this;
}
/**
* @brief Set the bgr object
*
* @param bgr
* @return ColorDetector&
*/
ColorDetector &set_bgr(bool bgr)
{
this->bgr = bgr;
return *this;
}
/**
* @brief Get the bgr object
*
* @return bool bgr flag
*/
bool get_bgr()
{
return this->bgr;
}
/**
* @brief Get the detection shape object
*
* @return std::vector<int>
*/
std::vector<int> get_detection_shape()
{
return this->detection_shape;
}
/**
* @brief Set the detection shape object
*
* @param detection_shape the inference shape of images, the input image will be resized to this shape
* @return ColorDetector&
*/
ColorDetector &set_detection_shape(std::vector<int> detection_shape)
{
assert(detection_shape.size() == 3);
this->detection_shape = detection_shape;
return *this;
}
/**
* @brief Get the registered colors num
*
* @return int the registered colors num
*/
int get_registered_colors_num()
{
return this->registered_colors.size();
}
/**
* @brief print the detection detection results
*
* @param tag
*/
void print_detection_results(const char *tag = "RGB")
{
printf("\n%s | color detection result:\n", tag);
for (int i = 0; i < this->detection_results.size(); ++i)
{
printf("color %d: detected box :%d\n", i, this->detection_results[i].size());
for (int j = 0; j < this->detection_results[i].size(); ++j)
{
printf("center: (%d, %d)\n", this->detection_results[i][j].center[0], this->detection_results[i][j].center[1]);
printf("box: (%d, %d), (%d, %d)\n", this->detection_results[i][j].box[0], this->detection_results[i][j].box[1], this->detection_results[i][j].box[2], this->detection_results[i][j].box[3]);
printf("area: %d\n", this->detection_results[i][j].area);
}
printf("\n");
}
}
/**
* @brief print the segmentation results
*
* @param tag
*/
void print_segmentation_results(const char *tag = "RGB")
{
printf("\n%s | color segmentation result:\n", tag);
for (int i = 0; i < this->segmentation_results.size(); ++i)
{
printf("color %d: detected box :%d\n", i, this->detection_results[i].size());
for (int j = 0; j < this->segmentation_results[i].index.size(); ++j)
{
printf("box_index: %d, start col: %d, end col: %d, row: %d, area: %d\n",
this->segmentation_results[i].index[j], this->segmentation_results[i].start_col[j], this->segmentation_results[i].end_col[j],
this->segmentation_results[i].row[j], this->segmentation_results[i].area[j]);
}
printf("\n");
}
}
/**
* @brief draw the color segmentation result on the input image
*
* @param image the input RGB image
* @param draw_colors RGB values for each detected colors
* @param draw_backgound draw the background if it is true
* @param background_color RGB values for the background color
*/
void draw_segmentation_results(dl::Tensor<uint8_t> &image, std::vector<std::vector<uint8_t>> draw_colors, bool draw_backgound = true, std::vector<uint8_t> background_color = {0, 0, 0});
/**
* @brief draw the color segmentation result on the input image
*
* @param image the pointer of the input RGB565 image
* @param image_shape the shape of the input image
* @param draw_colors RGB565 values for each detected colors
* @param draw_backgound draw the background if it is true
* @param background_color RGB565 values for the background color
*/
void draw_segmentation_results(uint16_t *image, std::vector<int> image_shape, std::vector<uint16_t> draw_colors, bool draw_backgound = true, uint16_t background_color = 0x0000);
}; };

View File

@ -10,6 +10,7 @@
#include <algorithm> #include <algorithm>
#include <math.h> #include <math.h>
#include <string> #include <string>
#include "esp_partition.h"
/** /**
* @brief struct of face similarity * @brief struct of face similarity
@ -45,6 +46,13 @@ public:
*/ */
FaceID(int id, dl::Tensor<feature_t> &id_emb, std::string name = ""); FaceID(int id, dl::Tensor<feature_t> &id_emb, std::string name = "");
/**
* @brief Construct a new Face ID which is same as input face_id
*
* @param face_id input face_id
*/
FaceID(FaceID<feature_t> &face_id);
/** /**
* @brief Destroy the Face ID object * @brief Destroy the Face ID object
* *

View File

@ -148,7 +148,7 @@ class FaceRecognizer
* @param name name of the face id. * @param name name of the face id.
* @return int the face id index of the enrolled embedding. * @return int the face id index of the enrolled embedding.
*/ */
int enroll_id(uint16_t *image_input, std::vector<int> shape, std::vector<int> &landmarks, std::string name=""); int enroll_id(uint16_t *image_input, std::vector<int> shape, std::vector<int> &landmarks, std::string name="", bool update_flash = false);
/** /**
* @brief enroll face id * @brief enroll face id
@ -158,9 +158,11 @@ class FaceRecognizer
* @param aligned_face the Tensor to store the intermeidate aligned face. * @param aligned_face the Tensor to store the intermeidate aligned face.
* @param landmarks face landmarks coordinates * @param landmarks face landmarks coordinates
* @param name name of the face id. * @param name name of the face id.
* @param update_flash true: the enrolled ids will be stored to flash
* false: the enrolled ids will not be stored to flash
* @return int the face id index of the enrolled embedding. * @return int the face id index of the enrolled embedding.
*/ */
int enroll_id(uint16_t *image_input, std::vector<int> shape, Tensor<uint8_t> &aligned_face, std::vector<int> &landmarks, std::string name=""); int enroll_id(uint16_t *image_input, std::vector<int> shape, Tensor<uint8_t> &aligned_face, std::vector<int> &landmarks, std::string name="", bool update_flash = false);
/** /**
* @brief enroll face id * @brief enroll face id
@ -168,9 +170,11 @@ class FaceRecognizer
* @param image_input the Tensor of input image with format bgr888. * @param image_input the Tensor of input image with format bgr888.
* @param landmarks face landmarks coordinates * @param landmarks face landmarks coordinates
* @param name name of the face id. * @param name name of the face id.
* @param update_flash true: the enrolled ids will be stored to flash
* false: the enrolled ids will not be stored to flash
* @return int the face id index of the enrolled embedding. * @return int the face id index of the enrolled embedding.
*/ */
int enroll_id(Tensor<uint8_t> &image_input, std::vector<int> &landmarks, std::string name=""); int enroll_id(Tensor<uint8_t> &image_input, std::vector<int> &landmarks, std::string name="", bool update_flash = false);
/** /**
* @brief enroll face id * @brief enroll face id
@ -179,42 +183,114 @@ class FaceRecognizer
* @param aligned_face the Tensor to store the intermeidate aligned face. * @param aligned_face the Tensor to store the intermeidate aligned face.
* @param landmarks face landmarks coordinates * @param landmarks face landmarks coordinates
* @param name name of the face id. * @param name name of the face id.
* @param update_flash true: the enrolled ids will be stored to flash
* false: the enrolled ids will not be stored to flash
* @return int the face id index of the enrolled embedding. * @return int the face id index of the enrolled embedding.
*/ */
int enroll_id(Tensor<uint8_t> &image_input, Tensor<uint8_t> &aligned_face, std::vector<int> &landmarks, std::string name=""); int enroll_id(Tensor<uint8_t> &image_input, Tensor<uint8_t> &aligned_face, std::vector<int> &landmarks, std::string name="", bool update_flash = false);
/** /**
* @brief enroll face id * @brief enroll face id
* *
* @param aligned_face the Tensor of the input aligned face with format bgr888. * @param aligned_face the Tensor of the input aligned face with format bgr888.
* @param name name of the face id. * @param name name of the face id.
* @param update_flash true: the enrolled ids will be stored to flash
* false: the enrolled ids will not be stored to flash
* @return int the face id index of the enrolled embedding. * @return int the face id index of the enrolled embedding.
*/ */
int enroll_id(Tensor<uint8_t> &aligned_face, std::string name=""); int enroll_id(Tensor<uint8_t> &aligned_face, std::string name="", bool update_flash = false);
/** /**
* @brief enroll the normalzied face embedding. * @brief enroll the normalzied face embedding.
* *
* @param emb the normalized face embbeding. * @param emb the normalized face embbeding.
* @param name name of the face id. * @param name name of the face id.
* @param update_flash true: the enrolled ids will be stored to flash
* false: the enrolled ids will not be stored to flash
* @return int the face id index of the enrolled embedding. * @return int the face id index of the enrolled embedding.
*/ */
int enroll_id(Tensor<float> &emb, std::string name=""); int enroll_id(Tensor<float> &emb, std::string name="", bool update_flash = false);
/** /**
* @brief delete the last enrolled face id. * @brief delete the last enrolled face id.
* @param update_flash true: the ids will be updated to flash
* false: the ids will not be stored to flash
* *
* @return int the number of remained face ids. * @return int the number of remained face ids.
* if the face ids list is empty, return -1 * if the face ids list is empty, return -1
*/ */
int delete_id(); int delete_id(bool update_flash = false);
/** /**
* @brief delete the face id with id index. * @brief delete the face id with id index.
* *
* @param id face id index. * @param id face id index.
* @param update_flash true: the ids will be updated to flash
* false: the ids will not be stored to flash
* @return int the number of remained face ids. * @return int the number of remained face ids.
* if there is no matched id return -1 * if there is no matched id return -1
*/ */
int delete_id(int id); int delete_id(int id, bool update_flash = false);
/**
* @brief Set the enrolled ids
*
* @param ids the ids to be set
* @param update_flash true: the ids will be updated to flash
* false: the ids will not be stored to flash
* @return int the number of enrolled ids.
*/
int set_ids(std::vector<FaceID<float> *> &ids, bool update_flash = false);
/**
* @brief Set the enrolled ids from flash
*
* @return int the number of enrolled ids.
*/
int set_ids_from_flash();
/**
* @brief write the enrolled ids to flash
*
* @return int the number of enrolled ids.
*/
int write_ids_to_flash();
/**
* @brief Get the enrolled ids with name object
*
* @param name
* @return std::vector<face_info_t>
*/
std::vector<face_info_t> get_enrolled_ids_with_name(std::string name);
/**
* @brief Check whether the Flash partition is available
*
* @return int -2: the partition has not been set
* -1: the data in the flash does not match the current model.
* model_check_code: the Flash partition is available.
* number of ids in flash: The IDs in Flash and RAM does not sync.
*/
int check_partition();
/**
* @brief delete all the enrolled face ids.
* @param update_flash true: the ids will be updated to flash
* false: the ids will not be stored to flash
*
*/
void clear_id(bool update_flash = false);
/**
* @brief Set the partition for saving face ids to flash or reading face ids from flash.
*
* @param type esp_partition_type
* @param subtype esp_partition_subtype
* @param label the partition label
* @return int 0: set the partition failed
* 1: set the partition successfully
*/
int set_partition(esp_partition_type_t type, esp_partition_subtype_t subtype, const char *label);
}; };

View File

@ -2,6 +2,7 @@
#include "dl_define.hpp" #include "dl_define.hpp"
#include <vector> #include <vector>
#include <stdint.h>
namespace dl namespace dl
{ {
@ -48,7 +49,8 @@ namespace dl
/*<! - 2D: [dilation_in_height, dilation_in_width] >*/ /*<! - 2D: [dilation_in_height, dilation_in_width] >*/
std::vector<int> shape_with_dilation; /*<! - 1D: reserved >*/ std::vector<int> shape_with_dilation; /*<! - 1D: reserved >*/
/*<! - 2D: [filter_height_with_dilation, filter_width_with_dilation, input_channel, output_channel] >*/ /*<! - 2D: [filter_height_with_dilation, filter_width_with_dilation, input_channel, output_channel] >*/
std::vector<int> channel_exponent; /*<! exponent for per-channel >*/ const int8_t* channel_exponent; /*<! exponent for per-channel >*/
const int channel_exponent_size;
/** /**
* @brief Construct a new Filter object. * @brief Construct a new Filter object.
@ -66,16 +68,17 @@ namespace dl
Filter(const T *element, const int exponent, const std::vector<int> shape, const std::vector<int> dilation = {1, 1}); Filter(const T *element, const int exponent, const std::vector<int> shape, const std::vector<int> dilation = {1, 1});
/** /**
* @brief Construct a new Filter object. * @brief Construct a new Filter object. it is only avaliable to int16_t
* *
* @param element point to element * @param element point to element
* @param channel_exponent exponent for per-channel * @param channel_exponent exponent for per-channel
* @param channel_exponent_size size of exponent
* @param shape shape of element * @param shape shape of element
* @param dilation dilation of Filter * @param dilation dilation of Filter
* - 1D: reserved * - 1D: reserved
* - 2D: [dilation_in_height, dilation_in_width] * - 2D: [dilation_in_height, dilation_in_width]
*/ */
Filter(const T *element, const std::vector<int> channel_exponent, const std::vector<int> shape, const std::vector<int> dilation = {1, 1}); Filter(const T *element, const int8_t* channel_exponent, const int channel_exponent_size, const std::vector<int> shape, const std::vector<int> dilation = {1, 1});
/** /**
* @brief Print the n-th filter. * @brief Print the n-th filter.
@ -98,9 +101,6 @@ namespace dl
{ {
public: public:
using Constant<T>::Constant; using Constant<T>::Constant;
std::vector<int> channel_exponent; /*<! exponent for per-channel >*/
Bias(const T *element, const std::vector<int> channel_exponent, const std::vector<int> shape);
}; };
/** /**

View File

@ -344,6 +344,17 @@ esp_err_t esp_http_client_set_password(esp_http_client_handle_t client, const ch
*/ */
esp_err_t esp_http_client_set_authtype(esp_http_client_handle_t client, esp_http_client_auth_type_t auth_type); esp_err_t esp_http_client_set_authtype(esp_http_client_handle_t client, esp_http_client_auth_type_t auth_type);
/**
* @brief Get HTTP client session errno
*
* @param[in] client The esp_http_client handle
*
* @return
* - (-1) if invalid argument
* - errno
*/
int esp_http_client_get_errno(esp_http_client_handle_t client);
/** /**
* @brief Set http request method * @brief Set http request method
* *

View File

@ -52,6 +52,15 @@ static inline void __attribute__((always_inline)) spinlock_initialize(spinlock_t
/** /**
* @brief Top level spinlock acquire function, spins until get the lock * @brief Top level spinlock acquire function, spins until get the lock
*
* This function will:
* - Save current interrupt state, then disable interrupts
* - Spin until lock is acquired or until timeout occurs
* - Restore interrupt state
*
* @note Spinlocks alone do no constitute true critical sections (as this
* function reenables interrupts once the spinlock is acquired). For critical
* sections, use the interface provided by the operating system.
* @param lock - target spinlock object * @param lock - target spinlock object
* @param timeout - cycles to wait, passing SPINLOCK_WAIT_FOREVER blocs indefinitely * @param timeout - cycles to wait, passing SPINLOCK_WAIT_FOREVER blocs indefinitely
*/ */
@ -125,6 +134,15 @@ static inline bool __attribute__((always_inline)) spinlock_acquire(spinlock_t *l
/** /**
* @brief Top level spinlock unlock function, unlocks a previously locked spinlock * @brief Top level spinlock unlock function, unlocks a previously locked spinlock
*
* This function will:
* - Save current interrupt state, then disable interrupts
* - Release the spinlock
* - Restore interrupt state
*
* @note Spinlocks alone do no constitute true critical sections (as this
* function reenables interrupts once the spinlock is acquired). For critical
* sections, use the interface provided by the operating system.
* @param lock - target, locked before, spinlock object * @param lock - target, locked before, spinlock object
*/ */
static inline void __attribute__((always_inline)) spinlock_release(spinlock_t *lock) static inline void __attribute__((always_inline)) spinlock_release(spinlock_t *lock)

View File

@ -0,0 +1,54 @@
/*
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
/* Common LCD panel commands */
#define LCD_CMD_NOP 0x00 // This command is empty command
#define LCD_CMD_SWRESET 0x01 // Software reset registers (the built-in frame buffer is not affected)
#define LCD_CMD_RDDID 0x04 // Read 24-bit display ID
#define LCD_CMD_RDDST 0x09 // Read display status
#define LCD_CMD_RDDPM 0x0A // Read display power mode
#define LCD_CMD_RDD_MADCTL 0x0B // Read display MADCTL
#define LCD_CMD_RDD_COLMOD 0x0C // Read display pixel format
#define LCD_CMD_RDDIM 0x0D // Read display image mode
#define LCD_CMD_RDDSM 0x0E // Read display signal mode
#define LCD_CMD_RDDSR 0x0F // Read display self-diagnostic result
#define LCD_CMD_SLPIN 0x10 // Go into sleep mode (DC/DC, oscillator, scanning stopped, but memory keeps content)
#define LCD_CMD_SLPOUT 0x11 // Exit sleep mode
#define LCD_CMD_PTLON 0x12 // Turns on partial display mode
#define LCD_CMD_NORON 0x13 // Turns on normal display mode
#define LCD_CMD_INVOFF 0x20 // Recover from display inversion mode
#define LCD_CMD_INVON 0x21 // Go into display inversion mode
#define LCD_CMD_GAMSET 0x26 // Select Gamma curve for current display
#define LCD_CMD_DISPOFF 0x28 // Display off (disable frame buffer output)
#define LCD_CMD_DISPON 0x29 // Display on (enable frame buffer output)
#define LCD_CMD_CASET 0x2A // Set column address
#define LCD_CMD_RASET 0x2B // Set row address
#define LCD_CMD_RAMWR 0x2C // Write frame memory
#define LCD_CMD_RAMRD 0x2E // Read frame memory
#define LCD_CMD_PTLAR 0x30 // Define the partial area
#define LCD_CMD_VSCRDEF 0x33 // Vertical scrolling definition
#define LCD_CMD_TEOFF 0x34 // Turns of tearing effect
#define LCD_CMD_TEON 0x35 // Turns on tearing effect
#define LCD_CMD_MADCTL 0x36 // Memory data access control
#define LCD_CMD_MH_BIT (1 << 2) // Display data latch order, 0: refresh left to right, 1: refresh right to left
#define LCD_CMD_BGR_BIT (1 << 3) // RGB/BGR order, 0: RGB, 1: BGR
#define LCD_CMD_ML_BIT (1 << 4) // Line address order, 0: refresh top to bottom, 1: refresh bottom to top
#define LCD_CMD_MV_BIT (1 << 5) // Row/Column order, 0: normal mode, 1: reverse mode
#define LCD_CMD_MX_BIT (1 << 6) // Column address order, 0: left to right, 1: right to left
#define LCD_CMD_MY_BIT (1 << 7) // Row address order, 0: top to bottom, 1: bottom to top
#define LCD_CMD_VSCSAD 0x37 // Vertical scroll start address
#define LCD_CMD_IDMOFF 0x38 // Recover from IDLE mode
#define LCD_CMD_IDMON 0x39 // Fall into IDLE mode (8 color depth is displayed)
#define LCD_CMD_COLMOD 0x3A // Defines the format of RGB picture data
#define LCD_CMD_RAMWRC 0x3C // Memory write continue
#define LCD_CMD_RAMRDC 0x3E // Memory read continue
#define LCD_CMD_STE 0x44 // Set tear scanline, tearing effect output signal when display module reaches line N
#define LCD_CMD_GDCAN 0x45 // Get scanline
#define LCD_CMD_WRDISBV 0x51 // Write display brightness
#define LCD_CMD_RDDISBV 0x52 // Read display brightness value

View File

@ -18,10 +18,10 @@ extern "C" {
#if SOC_LCD_RGB_SUPPORTED #if SOC_LCD_RGB_SUPPORTED
/** /**
* @brief LCD RGB timing structure * @brief LCD RGB timing structure
* * @verbatim
* Total Width * Total Width
* <---------------------------------------------------> * <--------------------------------------------------->
* Hsync width HBP Active Width HFP * HSYNC width HBP Active Width HFP
* <---><--><--------------------------------------><---> * <---><--><--------------------------------------><--->
* ____ ____|_______________________________________|____| * ____ ____|_______________________________________|____|
* |___| | | | * |___| | | |
@ -36,7 +36,7 @@ extern "C" {
* | /|\ | | / / / / / / / / / / / / / / / / / / / | | * | /|\ | | / / / / / / / / / / / / / / / / / / / | |
* | | | |/ / / / / / / / / / / / / / / / / / / /| | * | | | |/ / / / / / / / / / / / / / / / / / / /| |
* Total | | | |/ / / / / / / / / / / / / / / / / / / /| | * Total | | | |/ / / / / / / / / / / / / / / / / / / /| |
* Heigh | | | |/ / / / / / / / / / / / / / / / / / / /| | * Height | | | |/ / / / / / / / / / / / / / / / / / / /| |
* |Active| | |/ / / / / / / / / / / / / / / / / / / /| | * |Active| | |/ / / / / / / / / / / / / / / / / / / /| |
* |Heigh | | |/ / / / / / Active Display Area / / / /| | * |Heigh | | |/ / / / / / Active Display Area / / / /| |
* | | | |/ / / / / / / / / / / / / / / / / / / /| | * | | | |/ / / / / / / / / / / / / / / / / / / /| |
@ -48,7 +48,7 @@ extern "C" {
* | /|\ | | * | /|\ | |
* | VFP | | | * | VFP | | |
* \|/ \|/_____|______________________________________________________| * \|/ \|/_____|______________________________________________________|
* * @endverbatim
*/ */
typedef struct { typedef struct {
unsigned int pclk_hz; /*!< Frequency of pixel clock */ unsigned int pclk_hz; /*!< Frequency of pixel clock */
@ -65,7 +65,7 @@ typedef struct {
unsigned int vsync_idle_low: 1; /*!< The vsync signal is low in IDLE state */ unsigned int vsync_idle_low: 1; /*!< The vsync signal is low in IDLE state */
unsigned int de_idle_high: 1; /*!< The de signal is high in IDLE state */ unsigned int de_idle_high: 1; /*!< The de signal is high in IDLE state */
unsigned int pclk_active_neg: 1; /*!< The display will write data lines when there's a falling edge on PCLK */ unsigned int pclk_active_neg: 1; /*!< The display will write data lines when there's a falling edge on PCLK */
unsigned int pclk_idle_low: 1; /*!< The PCLK stays at low level in IDLE phase */ unsigned int pclk_idle_high: 1; /*!< The PCLK stays at high level in IDLE phase */
} flags; } flags;
} esp_lcd_rgb_timing_t; } esp_lcd_rgb_timing_t;

View File

@ -1,16 +1,8 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _ESP_NETIF_DEFAULTS_H #ifndef _ESP_NETIF_DEFAULTS_H
#define _ESP_NETIF_DEFAULTS_H #define _ESP_NETIF_DEFAULTS_H
@ -37,6 +29,7 @@ extern "C" {
.route_prio = 100 \ .route_prio = 100 \
} \ } \
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
#define ESP_NETIF_INHERENT_DEFAULT_WIFI_AP() \ #define ESP_NETIF_INHERENT_DEFAULT_WIFI_AP() \
{ \ { \
.flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_SERVER | ESP_NETIF_FLAG_AUTOUP), \ .flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_SERVER | ESP_NETIF_FLAG_AUTOUP), \
@ -48,6 +41,7 @@ extern "C" {
.if_desc = "ap", \ .if_desc = "ap", \
.route_prio = 10 \ .route_prio = 10 \
}; };
#endif
#define ESP_NETIF_INHERENT_DEFAULT_ETH() \ #define ESP_NETIF_INHERENT_DEFAULT_ETH() \
{ \ { \
@ -108,6 +102,7 @@ extern "C" {
.stack = ESP_NETIF_NETSTACK_DEFAULT_ETH, \ .stack = ESP_NETIF_NETSTACK_DEFAULT_ETH, \
} }
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
/** /**
* @brief Default configuration reference of WIFI AP * @brief Default configuration reference of WIFI AP
*/ */
@ -117,6 +112,7 @@ extern "C" {
.driver = NULL, \ .driver = NULL, \
.stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP, \ .stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP, \
} }
#endif
/** /**
* @brief Default configuration reference of WIFI STA * @brief Default configuration reference of WIFI STA
@ -154,10 +150,12 @@ extern "C" {
*/ */
#define ESP_NETIF_BASE_DEFAULT_WIFI_STA &_g_esp_netif_inherent_sta_config #define ESP_NETIF_BASE_DEFAULT_WIFI_STA &_g_esp_netif_inherent_sta_config
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
/** /**
* @brief Default base config (esp-netif inherent) of WIFI AP * @brief Default base config (esp-netif inherent) of WIFI AP
*/ */
#define ESP_NETIF_BASE_DEFAULT_WIFI_AP &_g_esp_netif_inherent_ap_config #define ESP_NETIF_BASE_DEFAULT_WIFI_AP &_g_esp_netif_inherent_ap_config
#endif
/** /**
* @brief Default base config (esp-netif inherent) of ethernet interface * @brief Default base config (esp-netif inherent) of ethernet interface
@ -177,7 +175,9 @@ extern "C" {
#define ESP_NETIF_NETSTACK_DEFAULT_ETH _g_esp_netif_netstack_default_eth #define ESP_NETIF_NETSTACK_DEFAULT_ETH _g_esp_netif_netstack_default_eth
#define ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA _g_esp_netif_netstack_default_wifi_sta #define ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA _g_esp_netif_netstack_default_wifi_sta
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
#define ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP _g_esp_netif_netstack_default_wifi_ap #define ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP _g_esp_netif_netstack_default_wifi_ap
#endif
#define ESP_NETIF_NETSTACK_DEFAULT_PPP _g_esp_netif_netstack_default_ppp #define ESP_NETIF_NETSTACK_DEFAULT_PPP _g_esp_netif_netstack_default_ppp
#define ESP_NETIF_NETSTACK_DEFAULT_SLIP _g_esp_netif_netstack_default_slip #define ESP_NETIF_NETSTACK_DEFAULT_SLIP _g_esp_netif_netstack_default_slip
#define ESP_NETIF_NETSTACK_DEFAULT_OPENTHREAD _g_esp_netif_netstack_default_openthread #define ESP_NETIF_NETSTACK_DEFAULT_OPENTHREAD _g_esp_netif_netstack_default_openthread
@ -190,7 +190,9 @@ extern "C" {
// //
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_eth; extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_eth;
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_sta; extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_sta;
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_ap; extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_ap;
#endif
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_ppp; extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_ppp;
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_slip; extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_slip;
@ -200,12 +202,16 @@ extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_slip;
// common behavioural patterns for common interfaces such as STA, AP, ETH, PPP // common behavioural patterns for common interfaces such as STA, AP, ETH, PPP
// //
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_sta_config; extern const esp_netif_inherent_config_t _g_esp_netif_inherent_sta_config;
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ap_config; extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ap_config;
#endif
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_eth_config; extern const esp_netif_inherent_config_t _g_esp_netif_inherent_eth_config;
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ppp_config; extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ppp_config;
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_slip_config; extern const esp_netif_inherent_config_t _g_esp_netif_inherent_slip_config;
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
extern const esp_netif_ip_info_t _g_esp_netif_soft_ap_ip; extern const esp_netif_ip_info_t _g_esp_netif_soft_ap_ip;
#endif
#if CONFIG_OPENTHREAD_ENABLED #if CONFIG_OPENTHREAD_ENABLED
/** /**

View File

@ -1,16 +1,8 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef ESP_WIFI_OS_ADAPTER_H_ #ifndef ESP_WIFI_OS_ADAPTER_H_
#define ESP_WIFI_OS_ADAPTER_H_ #define ESP_WIFI_OS_ADAPTER_H_

View File

@ -1,16 +1,8 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/* Notes about WiFi Programming /* Notes about WiFi Programming
@ -275,7 +267,7 @@ esp_err_t esp_wifi_deinit(void);
* @brief Set the WiFi operating mode * @brief Set the WiFi operating mode
* *
* Set the WiFi operating mode as station, soft-AP or station+soft-AP, * Set the WiFi operating mode as station, soft-AP or station+soft-AP,
* The default mode is soft-AP mode. * The default mode is station mode.
* *
* @param mode WiFi operating mode * @param mode WiFi operating mode
* *

View File

@ -166,10 +166,19 @@
#define configSTACK_OVERHEAD_APPTRACE 0 #define configSTACK_OVERHEAD_APPTRACE 0
#endif #endif
/* Stack watchpoint decreases minimum usable stack size by up to 60 bytes.
See FreeRTOS FREERTOS_WATCHPOINT_END_OF_STACK option in Kconfig. */
#if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK
#define configSTACK_OVERHEAD_WATCHPOINT 60
#else
#define configSTACK_OVERHEAD_WATCHPOINT 0
#endif
#define configSTACK_OVERHEAD_TOTAL ( \ #define configSTACK_OVERHEAD_TOTAL ( \
configSTACK_OVERHEAD_CHECKER + \ configSTACK_OVERHEAD_CHECKER + \
configSTACK_OVERHEAD_OPTIMIZATION + \ configSTACK_OVERHEAD_OPTIMIZATION + \
configSTACK_OVERHEAD_APPTRACE \ configSTACK_OVERHEAD_APPTRACE + \
configSTACK_OVERHEAD_WATCHPOINT \
) )
#define configMINIMAL_STACK_SIZE (768 + configSTACK_OVERHEAD_TOTAL) #define configMINIMAL_STACK_SIZE (768 + configSTACK_OVERHEAD_TOTAL)

View File

@ -184,123 +184,107 @@ typedef spinlock_t portMUX_TYPE; /**< Spinlock ty
#define portMUX_FREE_VAL SPINLOCK_FREE /**< Spinlock is free. [refactor-todo] check if this is still required */ #define portMUX_FREE_VAL SPINLOCK_FREE /**< Spinlock is free. [refactor-todo] check if this is still required */
#define portMUX_NO_TIMEOUT SPINLOCK_WAIT_FOREVER /**< When passed for 'timeout_cycles', spin forever if necessary. [refactor-todo] check if this is still required */ #define portMUX_NO_TIMEOUT SPINLOCK_WAIT_FOREVER /**< When passed for 'timeout_cycles', spin forever if necessary. [refactor-todo] check if this is still required */
#define portMUX_TRY_LOCK SPINLOCK_NO_WAIT /**< Try to acquire the spinlock a single time only. [refactor-todo] check if this is still required */ #define portMUX_TRY_LOCK SPINLOCK_NO_WAIT /**< Try to acquire the spinlock a single time only. [refactor-todo] check if this is still required */
#define portMUX_INITIALIZE(mux) spinlock_initialize(mux) /*< Initialize a spinlock to its unlocked state */
/**
* @brief Initialize a spinlock
*
* - Initializes a spinlock that is used by FreeRTOS SMP critical sections
*
* @param[in] mux Spinlock
*/
static inline void __attribute__((always_inline)) vPortCPUInitializeMutex(portMUX_TYPE *mux);
/**
* @brief Acquire a spinlock
*
* @note [refactor-todo] check if we still need this
*
* @param[in] mux Spinlock
*/
static inline void __attribute__((always_inline)) vPortCPUAcquireMutex(portMUX_TYPE *mux);
/**
* @brief Acquire a spinlock but with a specified timeout
*
* @note [refactor-todo] check if we still need this
* @note [refactor-todo] Check if this function should be renamed (due to bool return type)
*
* @param[in] mux Spinlock
* @param timeout
* @return true Spinlock acquired
* @return false Timed out
*/
static inline bool __attribute__((always_inline)) vPortCPUAcquireMutexTimeout(portMUX_TYPE *mux, int timeout);
/**
* @brief Release a spinlock
*
* @note [refactor-todo] check if we still need this
*
* @param[in] mux Spinlock
*/
static inline void __attribute__((always_inline)) vPortCPUReleaseMutex(portMUX_TYPE *mux);
/**
* @brief Wrapper for atomic compare-and-set instruction
*
* This subroutine will atomically compare *addr to 'compare'. If *addr == compare, *addr is set to *set. *set is
* updated with the previous value of *addr (either 'compare' or some other value.)
*
* @warning From the ISA docs: in some (unspecified) cases, the s32c1i instruction may return the "bitwise inverse" of
* the old mem if the mem wasn't written. This doesn't seem to happen on the ESP32 (portMUX assertions would
* fail).
*
* @note [refactor-todo] check if we still need this
* @note [refactor-todo] Check if this function should be renamed (due to void return type)
*
* @param[inout] addr Pointer to target address
* @param[in] compare Compare value
* @param[inout] set Pointer to set value
*/
static inline void __attribute__((always_inline)) uxPortCompareSet(volatile uint32_t *addr, uint32_t compare, uint32_t *set);
/**
* @brief Wrapper for atomic compare-and-set instruction in external RAM
*
* Atomic compare-and-set but the target address is placed in external RAM
*
* @note [refactor-todo] check if we still need this
*
* @param[inout] addr Pointer to target address
* @param[in] compare Compare value
* @param[inout] set Pointer to set value
*/
static inline void uxPortCompareSetExtram(volatile uint32_t *addr, uint32_t compare, uint32_t *set);
// ------------------ Critical Sections -------------------- // ------------------ Critical Sections --------------------
/**
* @brief Enter a SMP critical section with a timeout
*
* This function enters an SMP critical section by disabling interrupts then
* taking a spinlock with a specified timeout.
*
* This function can be called in a nested manner.
*
* @note This function is made non-inline on purpose to reduce code size
* @param mux Spinlock
* @param timeout Timeout to wait for spinlock in number of CPU cycles.
* Use portMUX_NO_TIMEOUT to wait indefinitely
* Use portMUX_TRY_LOCK to only getting the spinlock a single time
* @retval pdPASS Critical section entered (spinlock taken)
* @retval pdFAIL If timed out waiting for spinlock (will not occur if using portMUX_NO_TIMEOUT)
*/
BaseType_t xPortEnterCriticalTimeout(portMUX_TYPE *mux, BaseType_t timeout);
/** /**
* @brief Enter a SMP critical section * @brief Enter a SMP critical section
* *
* - Disable interrupts * This function enters an SMP critical section by disabling interrupts then
* - Takes spinlock * taking a spinlock with an unlimited timeout.
* - Can be nested *
* This function can be called in a nested manner
* *
* @param[in] mux Spinlock * @param[in] mux Spinlock
*/ */
void vPortEnterCritical(portMUX_TYPE *mux); static inline void __attribute__((always_inline)) vPortEnterCritical(portMUX_TYPE *mux);
/** /**
* @brief Exit a SMP critical section * @brief Exit a SMP critical section
* *
* - Releases spinlock * This function can be called in a nested manner. On the outer most level of nesting, this function will:
* - Reenables interrupts
* - Can be nested
* *
* - Release the spinlock
* - Restore the previous interrupt level before the critical section was entered
*
* If still nesting, this function simply decrements a critical nesting count
*
* @note This function is made non-inline on purpose to reduce code size
* @param[in] mux Spinlock * @param[in] mux Spinlock
*/ */
void vPortExitCritical(portMUX_TYPE *mux); void vPortExitCritical(portMUX_TYPE *mux);
/** /**
* @brief FreeRTOS compliant version of enter critical * @brief FreeRTOS Compliant version of xPortEnterCriticalTimeout()
* *
* - Ensures that critical section is only entered from task context * Compliant version of xPortEnterCriticalTimeout() will ensure that this is
* called from a task context only. An abort is called otherwise.
*
* @note This function is made non-inline on purpose to reduce code size
*
* @param mux Spinlock
* @param timeout Timeout
* @return BaseType_t
*/
BaseType_t xPortEnterCriticalTimeoutCompliance(portMUX_TYPE *mux, BaseType_t timeout);
/**
* @brief FreeRTOS compliant version of vPortEnterCritical()
*
* Compliant version of vPortEnterCritical() will ensure that this is
* called from a task context only. An abort is called otherwise.
* *
* @param[in] mux Spinlock * @param[in] mux Spinlock
*/ */
static inline void __attribute__((always_inline)) vPortEnterCriticalCompliance(portMUX_TYPE *mux); static inline void __attribute__((always_inline)) vPortEnterCriticalCompliance(portMUX_TYPE *mux);
/** /**
* @brief FreeRTOS compliant version of exit critical * @brief FreeRTOS compliant version of vPortExitCritical()
* *
* Compliant version of vPortExitCritical() will ensure that this is
* called from a task context only. An abort is called otherwise.
*
* @note This function is made non-inline on purpose to reduce code size
* @param[in] mux Spinlock * @param[in] mux Spinlock
*/ */
static inline void __attribute__((always_inline)) vPortExitCriticalCompliance(portMUX_TYPE *mux); void vPortExitCriticalCompliance(portMUX_TYPE *mux);
/**
* @brief Safe version of enter critical timeout
*
* Safe version of enter critical will automatically select between
* portTRY_ENTER_CRITICAL() and portTRY_ENTER_CRITICAL_ISR()
*
* @param mux Spinlock
* @param timeout Timeout
* @return BaseType_t
*/
static inline BaseType_t __attribute__((always_inline)) xPortEnterCriticalTimeoutSafe(portMUX_TYPE *mux, BaseType_t timeout);
/** /**
* @brief Safe version of enter critical * @brief Safe version of enter critical
* *
* - This function can be used to enter a critical section from both task and ISR contexts * Safe version of enter critical will automatically select between
* portENTER_CRITICAL() and portENTER_CRITICAL_ISR()
* *
* @param[in] mux Spinlock * @param[in] mux Spinlock
*/ */
@ -309,6 +293,9 @@ static inline void __attribute__((always_inline)) vPortEnterCriticalSafe(portMUX
/** /**
* @brief Safe version of exit critical * @brief Safe version of exit critical
* *
* Safe version of enter critical will automatically select between
* portEXIT_CRITICAL() and portEXIT_CRITICAL_ISR()
*
* @param[in] mux Spinlock * @param[in] mux Spinlock
*/ */
static inline void __attribute__((always_inline)) vPortExitCriticalSafe(portMUX_TYPE *mux); static inline void __attribute__((always_inline)) vPortExitCriticalSafe(portMUX_TYPE *mux);
@ -397,6 +384,38 @@ void vPortSetStackWatchpoint( void *pxStackStart );
*/ */
static inline BaseType_t IRAM_ATTR xPortGetCoreID(void); static inline BaseType_t IRAM_ATTR xPortGetCoreID(void);
/**
* @brief Wrapper for atomic compare-and-set instruction
*
* This subroutine will atomically compare *addr to 'compare'. If *addr == compare, *addr is set to *set. *set is
* updated with the previous value of *addr (either 'compare' or some other value.)
*
* @warning From the ISA docs: in some (unspecified) cases, the s32c1i instruction may return the "bitwise inverse" of
* the old mem if the mem wasn't written. This doesn't seem to happen on the ESP32 (portMUX assertions would
* fail).
*
* @note [refactor-todo] Check if this can be deprecated
* @note [refactor-todo] Check if this function should be renamed (due to void return type)
*
* @param[inout] addr Pointer to target address
* @param[in] compare Compare value
* @param[inout] set Pointer to set value
*/
static inline void __attribute__((always_inline)) uxPortCompareSet(volatile uint32_t *addr, uint32_t compare, uint32_t *set);
/**
* @brief Wrapper for atomic compare-and-set instruction in external RAM
*
* Atomic compare-and-set but the target address is placed in external RAM
*
* @note [refactor-todo] Check if this can be deprecated
*
* @param[inout] addr Pointer to target address
* @param[in] compare Compare value
* @param[inout] set Pointer to set value
*/
static inline void __attribute__((always_inline)) uxPortCompareSetExtram(volatile uint32_t *addr, uint32_t compare, uint32_t *set);
/* ------------------------------------------- FreeRTOS Porting Interface ---------------------------------------------- /* ------------------------------------------- FreeRTOS Porting Interface ----------------------------------------------
@ -449,14 +468,20 @@ static inline BaseType_t IRAM_ATTR xPortGetCoreID(void);
* - Safe versions can be called from either contexts * - Safe versions can be called from either contexts
*/ */
#ifdef CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE #ifdef CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE
#define portTRY_ENTER_CRITICAL(mux, timeout) xPortEnterCriticalTimeoutCompliance(mux, timeout)
#define portENTER_CRITICAL(mux) vPortEnterCriticalCompliance(mux) #define portENTER_CRITICAL(mux) vPortEnterCriticalCompliance(mux)
#define portEXIT_CRITICAL(mux) vPortExitCriticalCompliance(mux) #define portEXIT_CRITICAL(mux) vPortExitCriticalCompliance(mux)
#else #else
#define portTRY_ENTER_CRITICAL(mux, timeout) xPortEnterCriticalTimeout(mux, timeout)
#define portENTER_CRITICAL(mux) vPortEnterCritical(mux) #define portENTER_CRITICAL(mux) vPortEnterCritical(mux)
#define portEXIT_CRITICAL(mux) vPortExitCritical(mux) #define portEXIT_CRITICAL(mux) vPortExitCritical(mux)
#endif /* CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE */ #endif /* CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE */
#define portTRY_ENTER_CRITICAL_ISR(mux, timeout) xPortEnterCriticalTimeout(mux, timeout)
#define portENTER_CRITICAL_ISR(mux) vPortEnterCritical(mux) #define portENTER_CRITICAL_ISR(mux) vPortEnterCritical(mux)
#define portEXIT_CRITICAL_ISR(mux) vPortExitCritical(mux) #define portEXIT_CRITICAL_ISR(mux) vPortExitCritical(mux)
#define portTRY_ENTER_CRITICAL_SAFE(mux, timeout) xPortEnterCriticalTimeoutSafe(mux)
#define portENTER_CRITICAL_SAFE(mux) vPortEnterCriticalSafe(mux) #define portENTER_CRITICAL_SAFE(mux) vPortEnterCriticalSafe(mux)
#define portEXIT_CRITICAL_SAFE(mux) vPortExitCriticalSafe(mux) #define portEXIT_CRITICAL_SAFE(mux) vPortExitCriticalSafe(mux)
@ -546,71 +571,32 @@ static inline void vPortClearInterruptMaskFromISR(UBaseType_t prev_level)
XTOS_RESTORE_JUST_INTLEVEL(prev_level); XTOS_RESTORE_JUST_INTLEVEL(prev_level);
} }
// ---------------------- Spinlocks ------------------------
static inline void __attribute__((always_inline)) vPortCPUInitializeMutex(portMUX_TYPE *mux)
{
spinlock_initialize(mux);
}
static inline void __attribute__((always_inline)) vPortCPUAcquireMutex(portMUX_TYPE *mux)
{
spinlock_acquire(mux, portMUX_NO_TIMEOUT);
}
static inline bool __attribute__((always_inline)) vPortCPUAcquireMutexTimeout(portMUX_TYPE *mux, int timeout)
{
return (spinlock_acquire(mux, timeout));
}
static inline void __attribute__((always_inline)) vPortCPUReleaseMutex(portMUX_TYPE *mux)
{
spinlock_release(mux);
}
static inline void __attribute__((always_inline)) uxPortCompareSet(volatile uint32_t *addr, uint32_t compare, uint32_t *set)
{
compare_and_set_native(addr, compare, set);
}
static inline void uxPortCompareSetExtram(volatile uint32_t *addr, uint32_t compare, uint32_t *set)
{
#ifdef CONFIG_SPIRAM
compare_and_set_extram(addr, compare, set);
#endif
}
// ------------------ Critical Sections -------------------- // ------------------ Critical Sections --------------------
static inline void __attribute__((always_inline)) vPortEnterCritical(portMUX_TYPE *mux)
{
xPortEnterCriticalTimeout(mux, portMUX_NO_TIMEOUT);
}
static inline void __attribute__((always_inline)) vPortEnterCriticalCompliance(portMUX_TYPE *mux) static inline void __attribute__((always_inline)) vPortEnterCriticalCompliance(portMUX_TYPE *mux)
{ {
if (!xPortInIsrContext()) { xPortEnterCriticalTimeoutCompliance(mux, portMUX_NO_TIMEOUT);
vPortEnterCritical(mux);
} else {
esp_rom_printf("%s:%d (%s)- port*_CRITICAL called from ISR context!\n",
__FILE__, __LINE__, __FUNCTION__);
abort();
}
} }
static inline void __attribute__((always_inline)) vPortExitCriticalCompliance(portMUX_TYPE *mux) static inline BaseType_t __attribute__((always_inline)) xPortEnterCriticalTimeoutSafe(portMUX_TYPE *mux, BaseType_t timeout)
{ {
if (!xPortInIsrContext()) { BaseType_t ret;
vPortExitCritical(mux); if (xPortInIsrContext()) {
ret = portTRY_ENTER_CRITICAL_ISR(mux, timeout);
} else { } else {
esp_rom_printf("%s:%d (%s)- port*_CRITICAL called from ISR context!\n", ret = portTRY_ENTER_CRITICAL(mux, timeout);
__FILE__, __LINE__, __FUNCTION__);
abort();
} }
return ret;
} }
static inline void __attribute__((always_inline)) vPortEnterCriticalSafe(portMUX_TYPE *mux) static inline void __attribute__((always_inline)) vPortEnterCriticalSafe(portMUX_TYPE *mux)
{ {
if (xPortInIsrContext()) { xPortEnterCriticalTimeoutSafe(mux, portMUX_NO_TIMEOUT);
portENTER_CRITICAL_ISR(mux);
} else {
portENTER_CRITICAL(mux);
}
} }
static inline void __attribute__((always_inline)) vPortExitCriticalSafe(portMUX_TYPE *mux) static inline void __attribute__((always_inline)) vPortExitCriticalSafe(portMUX_TYPE *mux)
@ -648,6 +634,18 @@ static inline BaseType_t IRAM_ATTR xPortGetCoreID(void)
return (uint32_t) cpu_hal_get_core_id(); return (uint32_t) cpu_hal_get_core_id();
} }
static inline void __attribute__((always_inline)) uxPortCompareSet(volatile uint32_t *addr, uint32_t compare, uint32_t *set)
{
compare_and_set_native(addr, compare, set);
}
static inline void __attribute__((always_inline)) uxPortCompareSetExtram(volatile uint32_t *addr, uint32_t compare, uint32_t *set)
{
#ifdef CONFIG_SPIRAM
compare_and_set_extram(addr, compare, set);
#endif
}
/* ------------------------------------------------------ Misc --------------------------------------------------------- /* ------------------------------------------------------ Misc ---------------------------------------------------------

View File

@ -32,3 +32,62 @@ static inline void __attribute__((deprecated)) portEXIT_CRITICAL_NESTED(UBaseTyp
{ {
portCLEAR_INTERRUPT_MASK_FROM_ISR(prev_level); portCLEAR_INTERRUPT_MASK_FROM_ISR(prev_level);
} }
/* ---------------------- Spinlocks --------------------- */
/**
* @brief Initialize a spinlock
*
* Does the exact same thing as spinlock_initialize();
*
* @deprecated This function is deprecated. Call spinlock_initialize() instead
* @param[in] mux Spinlock
*/
static inline void __attribute__((deprecated)) __attribute__((always_inline)) vPortCPUInitializeMutex(portMUX_TYPE *mux)
{
spinlock_initialize(mux);
}
/**
* @brief Acquire a spinlock
*
* Does the exact same thing as spinlock_acquire() with unlimited timeout
*
* @deprecated This function is deprecated. Call spinlock_acquire() instead
* @param[in] mux Spinlock
*/
static inline void __attribute__((deprecated)) __attribute__((always_inline)) vPortCPUAcquireMutex(portMUX_TYPE *mux)
{
spinlock_acquire(mux, portMUX_NO_TIMEOUT);
}
/**
* @brief Acquire a spinlock
*
* Does the exact same thing as spinlock_acquire() with a specified timeout
*
* @deprecated This function is deprecated. Call spinlock_acquire() instead
* @note Does not have deprecated attribute due to usage in app_trace_util.c
* @param[in] mux Spinlock
* @param timeout
* @return true Spinlock acquired
* @return false Timed out
*/
static inline bool __attribute__((always_inline)) vPortCPUAcquireMutexTimeout(portMUX_TYPE *mux, int timeout)
{
return (spinlock_acquire(mux, timeout));
}
/**
* @brief Release a spinlock
*
* Does the exact same thing as spinlock_release()
*
* @deprecated This function is deprecated. Call spinlock_release() instead
* @note Does not have deprecated attribute due to usage in app_trace_util.c
* @param[in] mux Spinlock
*/
static inline void __attribute__((always_inline)) vPortCPUReleaseMutex(portMUX_TYPE *mux)
{
spinlock_release(mux);
}

View File

@ -13,12 +13,17 @@ extern "C" {
/** /**
* @brief LCD clock source * @brief LCD clock source
* @note User should select the clock source based on the real requirement: * @note User should select the clock source based on the real requirement:
* * @verbatim embed:rst:leading-asterisk
* +---------------------+-------------------------+----------------------------+
* | LCD clock source | Features | Power Management | * | LCD clock source | Features | Power Management |
* |---------------------|--------------------------|----------------------------| * +=====================+=========================+============================+
* | LCD_CLK_SRC_PLL160M | High resolution, fixed | ESP_PM_APB_FREQ_MAX lock | * | LCD_CLK_SRC_PLL160M | High resolution | ESP_PM_APB_FREQ_MAX lock |
* +---------------------+-------------------------+----------------------------+
* | LCD_CLK_SRC_APLL | Configurable resolution | ESP_PM_NO_LIGHT_SLEEP lock | * | LCD_CLK_SRC_APLL | Configurable resolution | ESP_PM_NO_LIGHT_SLEEP lock |
* | LCD_CLK_SRC_XTAL | Medium resolution, fixed | No PM lock | * +---------------------+-------------------------+----------------------------+
* | LCD_CLK_SRC_XTAL | Medium resolution | No PM lock |
* +---------------------+-------------------------+----------------------------+
* @endverbatim
*/ */
typedef enum { typedef enum {
LCD_CLK_SRC_PLL160M, /*!< Select PLL160M as the source clock */ LCD_CLK_SRC_PLL160M, /*!< Select PLL160M as the source clock */

View File

@ -1,16 +1,8 @@
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once #pragma once

View File

@ -1,23 +1,15 @@
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once #pragma once
#define IDF_PERFORMANCE_MIN_AES_CBC_THROUGHPUT_MBSEC 43 #define IDF_PERFORMANCE_MIN_AES_CBC_THROUGHPUT_MBSEC 43
// SHA256 hardware throughput at 240MHz, threshold set lower than worst case // SHA256 hardware throughput at 240MHz, threshold set lower than worst case
#define IDF_PERFORMANCE_MIN_SHA256_THROUGHPUT_MBSEC 19.8 #define IDF_PERFORMANCE_MIN_SHA256_THROUGHPUT_MBSEC 90
// esp_sha() time to process 32KB of input data from RAM // esp_sha() time to process 32KB of input data from RAM
#define IDF_PERFORMANCE_MAX_TIME_SHA1_32KB 1000 #define IDF_PERFORMANCE_MAX_TIME_SHA1_32KB 1000
#define IDF_PERFORMANCE_MAX_TIME_SHA512_32KB 900 #define IDF_PERFORMANCE_MAX_TIME_SHA512_32KB 900

View File

@ -8,7 +8,7 @@
*/ */
#ifndef IDF_PERFORMANCE_MAX_FREERTOS_SPINLOCK_CYCLES_PER_OP #ifndef IDF_PERFORMANCE_MAX_FREERTOS_SPINLOCK_CYCLES_PER_OP
#define IDF_PERFORMANCE_MAX_FREERTOS_SPINLOCK_CYCLES_PER_OP 200 #define IDF_PERFORMANCE_MAX_FREERTOS_SPINLOCK_CYCLES_PER_OP 250
#endif #endif
#ifndef IDF_PERFORMANCE_MAX_FREERTOS_SPINLOCK_CYCLES_PER_OP_PSRAM #ifndef IDF_PERFORMANCE_MAX_FREERTOS_SPINLOCK_CYCLES_PER_OP_PSRAM
#define IDF_PERFORMANCE_MAX_FREERTOS_SPINLOCK_CYCLES_PER_OP_PSRAM 300 #define IDF_PERFORMANCE_MAX_FREERTOS_SPINLOCK_CYCLES_PER_OP_PSRAM 300

View File

@ -1,16 +1,8 @@
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once #pragma once
#include_next "mbedtls/bignum.h" #include_next "mbedtls/bignum.h"
@ -77,4 +69,31 @@ void esp_mpi_release_hardware(void);
*/ */
int esp_mpi_mul_mpi_mod(mbedtls_mpi *Z, const mbedtls_mpi *X, const mbedtls_mpi *Y, const mbedtls_mpi *M); int esp_mpi_mul_mpi_mod(mbedtls_mpi *Z, const mbedtls_mpi *X, const mbedtls_mpi *Y, const mbedtls_mpi *M);
#if CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI
/**
* @brief Perform a sliding-window exponentiation: X = A^E mod N
*
* @param X The destination MPI. This must point to an initialized MPI.
* @param A The base of the exponentiation.
* This must point to an initialized MPI.
* @param E The exponent MPI. This must point to an initialized MPI.
* @param N The base for the modular reduction. This must point to an
* initialized MPI.
* @param _RR A helper MPI depending solely on \p N which can be used to
* speed-up multiple modular exponentiations for the same value
* of \p N. This may be \c NULL. If it is not \c NULL, it must
* point to an initialized MPI.
*
* @return \c 0 if successful.
* @return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed.
* @return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \c N is negative or
* even, or if \c E is negative.
* @return Another negative error code on different kinds of failures.
*
*/
int mbedtls_mpi_exp_mod_soft(mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *E, const mbedtls_mpi *N, mbedtls_mpi *_RR);
#endif // CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI
#endif // CONFIG_MBEDTLS_HARDWARE_MPI #endif // CONFIG_MBEDTLS_HARDWARE_MPI

View File

@ -153,15 +153,22 @@
#undef MBEDTLS_MD5_ALT #undef MBEDTLS_MD5_ALT
#endif #endif
/* The following MPI (bignum) functions have ESP32 hardware support. /* The following MPI (bignum) functions have hardware support.
For exponential mod, both software and hardware implementation * Uncommenting these macros will use the hardware-accelerated
will be compiled. If CONFIG_MBEDTLS_HARDWARE_MPI is enabled, mod APIs * implementations.
will be wrapped to use hardware implementation. */
*/
#undef MBEDTLS_MPI_EXP_MOD_ALT
#ifdef CONFIG_MBEDTLS_HARDWARE_MPI #ifdef CONFIG_MBEDTLS_HARDWARE_MPI
#ifdef CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI
/* Prefer hardware and fallback to software */
#define MBEDTLS_MPI_EXP_MOD_ALT_FALLBACK
#else
/* Hardware only mode */
#define MBEDTLS_MPI_EXP_MOD_ALT
#endif
#define MBEDTLS_MPI_MUL_MPI_ALT #define MBEDTLS_MPI_MUL_MPI_ALT
#else #else
#undef MBEDTLS_MPI_EXP_MOD_ALT_FALLBACK
#undef MBEDTLS_MPI_EXP_MOD_ALT
#undef MBEDTLS_MPI_MUL_MPI_ALT #undef MBEDTLS_MPI_MUL_MPI_ALT
#endif #endif

View File

@ -1,16 +1,8 @@
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __ESP_VFS_H__ #ifndef __ESP_VFS_H__
#define __ESP_VFS_H__ #define __ESP_VFS_H__
@ -410,7 +402,8 @@ int esp_vfs_utime(const char *path, const struct utimbuf *times);
* @param timeout If not NULL, then points to timeval structure which * @param timeout If not NULL, then points to timeval structure which
* specifies the time period after which the functions should * specifies the time period after which the functions should
* time-out and return. If it is NULL, then the function will * time-out and return. If it is NULL, then the function will
* not time-out. * not time-out. Note that the timeout period is rounded up to
* the system tick and incremented by one.
* *
* @return The number of descriptors set in the descriptor sets, or -1 * @return The number of descriptors set in the descriptor sets, or -1
* when an error (specified by errno) have occurred. * when an error (specified by errno) have occurred.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -322,7 +322,7 @@ SECTIONS
*libesp_system.a:esp_system.*(.literal.esp_system_abort .text.esp_system_abort) *libesp_system.a:esp_system.*(.literal.esp_system_abort .text.esp_system_abort)
*libesp_system.a:ubsan.*(.literal .literal.* .text .text.*) *libesp_system.a:ubsan.*(.literal .literal.* .text .text.*)
*libfreertos.a:(EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .literal EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .literal.* EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .text EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .text.*) *libfreertos.a:(EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .literal EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .literal.* EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .text EXCLUDE_FILE(*libfreertos.a:port.* *libfreertos.a:port_common.*) .text.*)
*libfreertos.a:port.*(.literal.pxPortInitialiseStack .literal.unlikely.vPortEndScheduler .literal.vApplicationStackOverflowHook .literal.vPortAssertIfInISR .literal.vPortEnterCritical .literal.vPortExitCritical .literal.vPortReleaseTaskMPUSettings .literal.vPortSetStackWatchpoint .literal.vPortYieldOtherCore .literal.xPortInIsrContext .literal.xPortStartScheduler .text .text.pxPortInitialiseStack .text.unlikely.vPortEndScheduler .text.vApplicationStackOverflowHook .text.vPortAssertIfInISR .text.vPortEnterCritical .text.vPortExitCritical .text.vPortReleaseTaskMPUSettings .text.vPortSetStackWatchpoint .text.vPortStoreTaskMPUSettings .text.vPortYieldOtherCore .text.xPortGetTickRateHz .text.xPortInIsrContext .text.xPortStartScheduler) *libfreertos.a:port.*(.literal.pxPortInitialiseStack .literal.unlikely.vPortEndScheduler .literal.vApplicationStackOverflowHook .literal.vPortAssertIfInISR .literal.vPortExitCritical .literal.vPortExitCriticalCompliance .literal.vPortReleaseTaskMPUSettings .literal.vPortSetStackWatchpoint .literal.vPortYieldOtherCore .literal.xPortEnterCriticalTimeout .literal.xPortEnterCriticalTimeoutCompliance .literal.xPortInIsrContext .literal.xPortStartScheduler .text .text.pxPortInitialiseStack .text.unlikely.vPortEndScheduler .text.vApplicationStackOverflowHook .text.vPortAssertIfInISR .text.vPortExitCritical .text.vPortExitCriticalCompliance .text.vPortReleaseTaskMPUSettings .text.vPortSetStackWatchpoint .text.vPortStoreTaskMPUSettings .text.vPortYieldOtherCore .text.xPortEnterCriticalTimeout .text.xPortEnterCriticalTimeoutCompliance .text.xPortGetTickRateHz .text.xPortInIsrContext .text.xPortStartScheduler)
*libfreertos.a:port_common.*(.literal.esp_startup_start_app_common .literal.vApplicationGetIdleTaskMemory .literal.vApplicationGetTimerTaskMemory .literal.xPortCheckValidTCBMem .literal.xPortcheckValidStackMem .text .text.esp_startup_start_app_common .text.vApplicationGetIdleTaskMemory .text.vApplicationGetTimerTaskMemory .text.xPortCheckValidTCBMem .text.xPortcheckValidStackMem) *libfreertos.a:port_common.*(.literal.esp_startup_start_app_common .literal.vApplicationGetIdleTaskMemory .literal.vApplicationGetTimerTaskMemory .literal.xPortCheckValidTCBMem .literal.xPortcheckValidStackMem .text .text.esp_startup_start_app_common .text.vApplicationGetIdleTaskMemory .text.vApplicationGetTimerTaskMemory .text.xPortCheckValidTCBMem .text.xPortcheckValidStackMem)
*libgcc.a:lib2funcs.*(.literal .literal.* .text .text.*) *libgcc.a:lib2funcs.*(.literal .literal.* .text .text.*)
*libgcov.a:(.literal .literal.* .text .text.*) *libgcov.a:(.literal .literal.* .text .text.*)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More