Skip to content

Commit

Permalink
Merge branch 'feat/version_debugfs_hostedng' into 'master'
Browse files Browse the repository at this point in the history
esp_hosted_ng: Add version support in debugfs

See merge request app-frameworks/esp_hosted!488
  • Loading branch information
mantriyogesh committed Aug 23, 2024
2 parents 5f85029 + 01a9eae commit 70de43a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
7 changes: 5 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ check_version:
- export HOSTED_NG_PATH=$PWD/esp_hosted_ng
- .gitlab/ci/check_hosted_ng_version.sh
rules:
- changes:
- esp_hosted_ng/esp/esp_driver/network_adapter/**/*
- when: always
tags:
- linux510
#- changes:
# - esp_hosted_ng/**/*

build_fw_esp32_sdio:
stage: build
Expand Down
23 changes: 21 additions & 2 deletions esp_hosted_ng/host/esp_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#define DEBUGFS_DIR_NAME "esp32"
#define LOG_LEVEL "log_level"
#define VERSION "version"

#define DEBUGFS_TODO 0

Expand All @@ -21,7 +22,7 @@
struct esp32_debugfs {
struct dentry *debugfs_dir;
struct dentry *log_level_file; /* log level for host dmesg */

struct dentry *version;
#if DEBUGFS_TODO
struct dentry *host_log_level_file; /* log level for host logs in debugfs logger */
struct dentry *host_log_file; /* debugfs host logger */
Expand All @@ -43,7 +44,10 @@ static char log_buffer[LOG_BUFFER_SIZE] = "";
static size_t log_length = 0;
static size_t write_pos = 0;
#endif

#ifndef VERSION_BUFFER_SIZE
#define VERSION_BUFFER_SIZE 50
#endif
extern char version_str[VERSION_BUFFER_SIZE];

// Read operation for the debugfs file
static ssize_t log_level_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
Expand All @@ -56,6 +60,11 @@ static ssize_t log_level_read(struct file *file, char __user *buf, size_t count,
return simple_read_from_buffer(buf, count, ppos, level_str, strlen(level_str));
}

static ssize_t version_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{
return simple_read_from_buffer(buf, count, ppos, version_str, strlen(version_str));
}

// Write operation for the debugfs file
static ssize_t log_level_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
{
Expand Down Expand Up @@ -187,6 +196,10 @@ static const struct file_operations log_level_ops = {
.write = log_level_write,
};

static const struct file_operations version_ops = {
.read = version_read,
};

// Module initialization function
int debugfs_init(void)
{
Expand All @@ -207,6 +220,12 @@ int debugfs_init(void)
goto cleanup;
}

debugfs->version = debugfs_create_file(VERSION, 0644, debugfs->debugfs_dir, NULL, &version_ops);
if (!debugfs->version) {
esp_err("Failed to create debugfs %s file\n", VERSION);
goto cleanup;
}

#if DEBUGFS_TODO
debugfs->host_log_level_file = debugfs_create_file(DEBUGFS_LOG_LEVEL, 0644, debugfs_dir, NULL, &debugfs_log_level_ops);
if (!debugfs->debugfs_log_level_file) {
Expand Down
7 changes: 3 additions & 4 deletions esp_hosted_ng/host/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ extern u8 ap_bssid[MAC_ADDR_LEN];
extern volatile u8 host_sleep;
u32 raw_tp_mode = 0;
int log_level = ESP_INFO;
#define VERSION_BUFFER_SIZE 50
char version_str[VERSION_BUFFER_SIZE];


module_param(resetpin, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
MODULE_PARM_DESC(resetpin, "Host's GPIO pin number which is connected to ESP32's EN to reset ESP32 device");
Expand Down Expand Up @@ -231,12 +234,8 @@ void init_bt(struct esp_adapter *adapter)
}
}

#define VERSION_BUFFER_SIZE 50

static int check_esp_version(struct fw_version *ver)
{
char version_str[VERSION_BUFFER_SIZE] = {0};

snprintf(version_str, VERSION_BUFFER_SIZE, "%s-%u.%u.%u.%u.%u",
ver->project_name, ver->major1, ver->major2, ver->minor, ver->revision_patch_1, ver->revision_patch_2);

Expand Down

0 comments on commit 70de43a

Please sign in to comment.