mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-09-02 11:14:02 +00:00
68 lines
2.7 KiB
Diff
68 lines
2.7 KiB
Diff
diff --git a/drivers/flash/flash_simulator.c b/drivers/flash/flash_simulator.c
|
|
index bbc1e6e5af7..c13b0285dd1 100644
|
|
--- a/drivers/flash/flash_simulator.c
|
|
+++ b/drivers/flash/flash_simulator.c
|
|
@@ -438,7 +438,11 @@ static int flash_mock_init(const struct device *dev)
|
|
struct flash_simulator_data *dev_data = dev->data;
|
|
|
|
if (dev_data->flash_in_ram == false && dev_data->flash_file_path == NULL) {
|
|
- dev_data->flash_file_path = cfg->flash_file_default_path;
|
|
+ /* ZephCore: default to a per-node file (meshcore_settings_<host>.bin)
|
|
+ * so persistent settings are identifiable and survive restarts.
|
|
+ * cfg->flash_file_default_path ("flash.bin") is the upstream default;
|
|
+ * an explicit --flash=<path> still overrides (flash_file_path != NULL). */
|
|
+ dev_data->flash_file_path = flash_mock_default_path_native();
|
|
}
|
|
|
|
rc = flash_mock_init_native(dev_data->flash_in_ram, &dev_data->mock_flash, cfg->flash_size,
|
|
diff --git a/drivers/flash/flash_simulator_native.c b/drivers/flash/flash_simulator_native.c
|
|
index 03eb8269f58..73249b4fcdd 100644
|
|
--- a/drivers/flash/flash_simulator_native.c
|
|
+++ b/drivers/flash/flash_simulator_native.c
|
|
@@ -28,6 +28,31 @@
|
|
#include <string.h>
|
|
#include <nsi_tracing.h>
|
|
|
|
+/*
|
|
+ * ZephCore: build a per-node default flash backing-file name from the host
|
|
+ * name, so each node keeps its persistent settings in its own file
|
|
+ * (meshcore_settings_<hostname>.bin) rather than a generic flash.bin.
|
|
+ * Returns a pointer to a static buffer valid for the process lifetime.
|
|
+ */
|
|
+const char *flash_mock_default_path_native(void)
|
|
+{
|
|
+ static char path[128];
|
|
+ char host[64];
|
|
+
|
|
+ if (gethostname(host, sizeof(host)) != 0) {
|
|
+ host[0] = '\0';
|
|
+ }
|
|
+ host[sizeof(host) - 1] = '\0';
|
|
+
|
|
+ if (host[0] == '\0') {
|
|
+ snprintf(path, sizeof(path), "meshcore_settings.bin");
|
|
+ } else {
|
|
+ snprintf(path, sizeof(path), "meshcore_settings_%s.bin", host);
|
|
+ }
|
|
+
|
|
+ return path;
|
|
+}
|
|
+
|
|
/*
|
|
* Initialize the flash buffer.
|
|
* And, if the content is to be kept on disk map it to the buffer to the file.
|
|
diff --git a/drivers/flash/flash_simulator_native.h b/drivers/flash/flash_simulator_native.h
|
|
index a59136c1c20..efc69b7366e 100644
|
|
--- a/drivers/flash/flash_simulator_native.h
|
|
+++ b/drivers/flash/flash_simulator_native.h
|
|
@@ -15,6 +15,9 @@ int flash_mock_init_native(bool flash_in_ram, uint8_t **mock_flash, unsigned int
|
|
int *flash_fd, const char *flash_file_path,
|
|
unsigned int erase_value, bool flash_erase_at_start);
|
|
|
|
+/* ZephCore: per-node default backing-file path (meshcore_settings_<host>.bin). */
|
|
+const char *flash_mock_default_path_native(void);
|
|
+
|
|
void flash_mock_cleanup_native(bool flash_in_ram, int flash_fd, uint8_t *mock_flash,
|
|
unsigned int size, const char *flash_file_path,
|
|
bool flash_rm_at_exit);
|