forked from espressif/esp-idf
feat(storage/vfs): move semihost to new vfs API
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_vfs.h"
|
#include "esp_vfs.h"
|
||||||
#include "esp_cpu.h"
|
#include "esp_cpu.h"
|
||||||
|
#include "include/esp_vfs.h"
|
||||||
#include "openocd_semihosting.h"
|
#include "openocd_semihosting.h"
|
||||||
|
|
||||||
#ifndef CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS
|
#ifndef CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS
|
||||||
@@ -419,20 +420,9 @@ static void vfs_semihost_seekdir(void* ctx, DIR* pdir, long offset)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
esp_err_t esp_vfs_semihost_register(const char* base_path)
|
|
||||||
{
|
|
||||||
assert(base_path);
|
|
||||||
|
|
||||||
const esp_vfs_t vfs = {
|
|
||||||
.flags = ESP_VFS_FLAG_CONTEXT_PTR,
|
|
||||||
.write_p = &vfs_semihost_write,
|
|
||||||
.open_p = &vfs_semihost_open,
|
|
||||||
.close_p = &vfs_semihost_close,
|
|
||||||
.read_p = &vfs_semihost_read,
|
|
||||||
.lseek_p = &vfs_semihost_lseek,
|
|
||||||
.fsync_p = &vfs_semihost_fsync,
|
|
||||||
.fstat_p = &vfs_semihost_fstat,
|
|
||||||
#ifdef CONFIG_VFS_SUPPORT_DIR
|
#ifdef CONFIG_VFS_SUPPORT_DIR
|
||||||
|
static const esp_vfs_dir_ops_t s_vfs_semihost_dir = {
|
||||||
.mkdir_p = &vfs_semihost_mkdir,
|
.mkdir_p = &vfs_semihost_mkdir,
|
||||||
.rmdir_p = &vfs_semihost_rmdir,
|
.rmdir_p = &vfs_semihost_rmdir,
|
||||||
.access_p = &vfs_semihost_access,
|
.access_p = &vfs_semihost_access,
|
||||||
@@ -448,8 +438,26 @@ esp_err_t esp_vfs_semihost_register(const char* base_path)
|
|||||||
.readdir_p = &vfs_semihost_readdir,
|
.readdir_p = &vfs_semihost_readdir,
|
||||||
.readdir_r_p = &vfs_semihost_readdir_r,
|
.readdir_r_p = &vfs_semihost_readdir_r,
|
||||||
.seekdir_p = &vfs_semihost_seekdir,
|
.seekdir_p = &vfs_semihost_seekdir,
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
static const esp_vfs_fs_ops_t s_vfs_semihost = {
|
||||||
|
.write_p = &vfs_semihost_write,
|
||||||
|
.open_p = &vfs_semihost_open,
|
||||||
|
.close_p = &vfs_semihost_close,
|
||||||
|
.read_p = &vfs_semihost_read,
|
||||||
|
.lseek_p = &vfs_semihost_lseek,
|
||||||
|
.fsync_p = &vfs_semihost_fsync,
|
||||||
|
.fstat_p = &vfs_semihost_fstat,
|
||||||
|
#ifdef CONFIG_VFS_SUPPORT_DIR
|
||||||
|
.dir = &s_vfs_semihost_dir,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
esp_err_t esp_vfs_semihost_register(const char* base_path)
|
||||||
|
{
|
||||||
|
assert(base_path);
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Register semihosting driver '%s'", base_path);
|
ESP_LOGD(TAG, "Register semihosting driver '%s'", base_path);
|
||||||
if (!esp_cpu_dbgr_is_attached()) {
|
if (!esp_cpu_dbgr_is_attached()) {
|
||||||
ESP_LOGE(TAG, "OpenOCD is not connected!");
|
ESP_LOGE(TAG, "OpenOCD is not connected!");
|
||||||
@@ -478,7 +486,7 @@ esp_err_t esp_vfs_semihost_register(const char* base_path)
|
|||||||
ESP_LOGE(TAG, "Incompatible OpenOCD version detected. Please follow the getting started guides to install the required version.");
|
ESP_LOGE(TAG, "Incompatible OpenOCD version detected. Please follow the getting started guides to install the required version.");
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_vfs_register(base_path, &vfs, &s_semhost_ctx[i]);
|
err = esp_vfs_register_fs(base_path, &s_vfs_semihost, ESP_VFS_FLAG_STATIC | ESP_VFS_FLAG_CONTEXT_PTR, &s_semhost_ctx[i]);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Can't register the semihosting! Error: %s", esp_err_to_name(err));
|
ESP_LOGE(TAG, "Can't register the semihosting! Error: %s", esp_err_to_name(err));
|
||||||
return err;
|
return err;
|
||||||
|
Reference in New Issue
Block a user