[esp_rom]: Partially buildable for linux
The following files have been ported: * esp_rom_crc.h * esp_rom_sys.h * esp_rom_efuse.h (mostly no-ops) * esp_rom_md5.h Integrated Linux-based rom implementation into log and NVS component. Added brief host tests for ROM to ensure basic consistency on Linux. Added ROM printf host unit tests. Temporarily added reset reason for Linux in ROM.
This commit is contained in:
@@ -22,18 +22,12 @@
|
||||
#include <functional>
|
||||
#include "nvs_handle_simple.hpp"
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef LINUX_TARGET
|
||||
#include "crc.h"
|
||||
#define ESP_LOGD(...)
|
||||
#else // LINUX_TARGET
|
||||
#include <esp32/rom/crc.h>
|
||||
#include <esp_rom_crc.h>
|
||||
|
||||
// Uncomment this line to force output from this module
|
||||
// #define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
||||
#include "esp_log.h"
|
||||
static const char* TAG = "nvs";
|
||||
#endif // ! LINUX_TARGET
|
||||
|
||||
class NVSHandleEntry : public intrusive_list_node<NVSHandleEntry> {
|
||||
public:
|
||||
@@ -311,7 +305,7 @@ extern "C" esp_err_t nvs_open(const char* name, nvs_open_mode_t open_mode, nvs_h
|
||||
extern "C" void nvs_close(nvs_handle_t handle)
|
||||
{
|
||||
Lock lock;
|
||||
ESP_LOGD(TAG, "%s %d", __func__, handle);
|
||||
ESP_LOGD(TAG, "%s %d", __func__, static_cast<int>(handle));
|
||||
auto it = find_if(begin(s_nvs_handles), end(s_nvs_handles), [=](NVSHandleEntry& e) -> bool {
|
||||
return e.mHandle == handle;
|
||||
});
|
||||
@@ -352,7 +346,7 @@ template<typename T>
|
||||
static esp_err_t nvs_set(nvs_handle_t c_handle, const char* key, T value)
|
||||
{
|
||||
Lock lock;
|
||||
ESP_LOGD(TAG, "%s %s %d %d", __func__, key, sizeof(T), (uint32_t) value);
|
||||
ESP_LOGD(TAG, "%s %s %d %ld", __func__, key, static_cast<int>(sizeof(T)), static_cast<long int>(value));
|
||||
NVSHandleSimple *handle;
|
||||
auto err = nvs_find_ns_handle(c_handle, &handle);
|
||||
if (err != ESP_OK) {
|
||||
@@ -429,7 +423,7 @@ extern "C" esp_err_t nvs_set_str(nvs_handle_t c_handle, const char* key, const c
|
||||
extern "C" esp_err_t nvs_set_blob(nvs_handle_t c_handle, const char* key, const void* value, size_t length)
|
||||
{
|
||||
Lock lock;
|
||||
ESP_LOGD(TAG, "%s %s %d", __func__, key, length);
|
||||
ESP_LOGD(TAG, "%s %s %d", __func__, key, static_cast<int>(length));
|
||||
NVSHandleSimple *handle;
|
||||
auto err = nvs_find_ns_handle(c_handle, &handle);
|
||||
if (err != ESP_OK) {
|
||||
@@ -443,7 +437,7 @@ template<typename T>
|
||||
static esp_err_t nvs_get(nvs_handle_t c_handle, const char* key, T* out_value)
|
||||
{
|
||||
Lock lock;
|
||||
ESP_LOGD(TAG, "%s %s %d", __func__, key, sizeof(T));
|
||||
ESP_LOGD(TAG, "%s %s %ld", __func__, key, static_cast<long int>(sizeof(T)));
|
||||
NVSHandleSimple *handle;
|
||||
auto err = nvs_find_ns_handle(c_handle, &handle);
|
||||
if (err != ESP_OK) {
|
||||
@@ -629,8 +623,8 @@ extern "C" esp_err_t nvs_flash_generate_keys(const esp_partition_t* partition, n
|
||||
return err;
|
||||
}
|
||||
|
||||
uint32_t crc_calc = crc32_le(0xffffffff, cfg->eky, NVS_KEY_SIZE);
|
||||
crc_calc = crc32_le(crc_calc, cfg->tky, NVS_KEY_SIZE);
|
||||
uint32_t crc_calc = esp_rom_crc32_le(0xffffffff, cfg->eky, NVS_KEY_SIZE);
|
||||
crc_calc = esp_rom_crc32_le(crc_calc, cfg->tky, NVS_KEY_SIZE);
|
||||
|
||||
uint8_t crc_wr[16];
|
||||
memset(crc_wr, 0xff, sizeof(crc_wr));
|
||||
@@ -702,8 +696,8 @@ extern "C" esp_err_t nvs_flash_read_security_cfg(const esp_partition_t* partitio
|
||||
return err;
|
||||
}
|
||||
|
||||
crc_calc = crc32_le(0xffffffff, cfg->eky, NVS_KEY_SIZE);
|
||||
crc_calc = crc32_le(crc_calc, cfg->tky, NVS_KEY_SIZE);
|
||||
crc_calc = esp_rom_crc32_le(0xffffffff, cfg->eky, NVS_KEY_SIZE);
|
||||
crc_calc = esp_rom_crc32_le(crc_calc, cfg->tky, NVS_KEY_SIZE);
|
||||
|
||||
if(crc_calc != crc_read) {
|
||||
if(!check_if_initialized(cfg->eky, cfg->tky, crc_read)) {
|
||||
|
||||
Reference in New Issue
Block a user