Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of settings. Store setting on the sd card. Access settings t… #15

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
To implement the settings storage on the SD card, replace the 'mkdir_for_file' with the following function that can be found in the Zephyr core file - `settings_file.c`, located at `zephyr/subsys/settings/src/settings_file.c`.


static int mkdir_for_file(const char *file_path)
{
char dir_path[SETTINGS_FILE_NAME_MAX];
int err;

for (size_t i = 0; file_path[i] != '\0'; i++) {
if (i > 0 && file_path[i] == '/') {
dir_path[i] = '\0';

// Skip mkdir for FatFS root directories (ending with ':')
if (strrchr(dir_path, ':') == &dir_path[strlen(dir_path) - 1]) {
LOG_DBG("FatFS root directory detected, skipping mkdir for path: %s",
dir_path);
} else {
err = mkdir_if_not_exists(dir_path);
if (err) {
return err;
}
}
}
dir_path[i] = file_path[i];
}

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,16 @@
&gpioc {
status = "okay";
};

&spi1 {
sdhc0: sdhc@0 {
compatible = "zephyr,sdhc-spi-slot";
reg = <0>;
status = "okay";
mmc {
compatible = "zephyr,sdmmc-disk";
status = "okay";
};
spi-max-frequency = <4000000>;
};
};
23 changes: 13 additions & 10 deletions app/debug.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,33 @@ CONFIG_APP_LOG_LEVEL_DBG=y

# Enable stack sentinel to detect stack overflows
#CONFIG_STACK_SENTINEL=y

CONFIG_HEAP_MEM_POOL_SIZE=16384
#CONFIG_HW_STACK_PROTECTION=y

# Shell Related Configs
# Enable Shell for GPIO
CONFIG_GPIO=y
CONFIG_GPIO_SHELL=y

#Enable UART console
CONFIG_UART_CONSOLE=y

# Enable Shell for I2C
CONFIG_I2C=y
CONFIG_I2C_SHELL=y

#Enables settings on shell
CONFIG_SETTINGS_SHELL=y

#ENABLE TO USE SYSTEM VIEW TRACE
#***********************************************************************************
CONFIG_STDOUT_CONSOLE=y
# enable to use thread names
CONFIG_THREAD_NAME=y
CONFIG_SEGGER_SYSTEMVIEW=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_TRACING=y
# enable for post-mortem tracing
CONFIG_SEGGER_SYSVIEW_POST_MORTEM_MODE=n
# CONFIG_STDOUT_CONSOLE=y
# # enable to use thread names
# CONFIG_THREAD_NAME=y
# CONFIG_SEGGER_SYSTEMVIEW=y
# CONFIG_USE_SEGGER_RTT=y
# CONFIG_TRACING=y
# # enable for post-mortem tracing
# CONFIG_SEGGER_SYSVIEW_POST_MORTEM_MODE=n
#***********************************************************************************

# #ENABLE ALL BELOW PERCEPIO CONFIGURATION TO WORK WITH PERCEPIO TRACELIZER SOFTWARE
Expand Down
20 changes: 20 additions & 0 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#
# This file contains selected Kconfig options for the application.

# Heap and stack sizes
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_MAIN_STACK_SIZE=4096

CONFIG_SENSOR=y
CONFIG_BLINK=y

Expand All @@ -25,3 +29,19 @@ CONFIG_SHELL_HISTORY=y
# Disable log redirection to shell to separate it
CONFIG_SHELL_LOG_BACKEND=n

#SD card configurations
CONFIG_DISK_ACCESS=y
CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_MAIN_STACK_SIZE=2048

CONFIG_SPI=y
CONFIG_DISK_DRIVER_SDMMC=y
CONFIG_SPI_STM32=y

#Settings configuations
CONFIG_SETTINGS=y
CONFIG_SETTINGS_RUNTIME=y

CONFIG_SETTINGS_FILE=y
CONFIG_SETTINGS_FILE_PATH="/SD:/settings/settings.txt"
Loading
Loading