sysparam: rework.
Adds a semaphore used by readers are writers. Fixes writing to the flash from constant data stored in the flash, using a bounce buffer. Handle reading into unaligned value buffers. Removed memory allocation from most read and write paths. Only read paths that return a blob of data allocate memory now, and the iterator. Store small integers as binary values, avoiding parsing and formatting in these paths.
This commit is contained in:
parent
762eced543
commit
ace6870c51
3 changed files with 194 additions and 218 deletions
|
|
@ -6,6 +6,8 @@
|
|||
#include <sysparam.h>
|
||||
|
||||
#include <espressif/spi_flash.h>
|
||||
#include "espressif/esp_common.h"
|
||||
#include "esp/uart.h"
|
||||
|
||||
#define CMD_BUF_SIZE 5000
|
||||
|
||||
|
|
@ -30,6 +32,7 @@ void usage(void) {
|
|||
" <key>:<hexdata> -- Set <key> to binary value represented as hex\n"
|
||||
" dump -- Show all currently set keys/values\n"
|
||||
" reformat -- Reinitialize (clear) the sysparam area\n"
|
||||
" echo -- Toggle input echo\n"
|
||||
" help -- Show this help screen\n"
|
||||
);
|
||||
}
|
||||
|
|
@ -150,6 +153,7 @@ void sysparam_editor_task(void *pvParameters) {
|
|||
size_t len;
|
||||
uint8_t *data;
|
||||
uint32_t base_addr, num_sectors;
|
||||
bool echo = true;
|
||||
|
||||
if (!cmd_buffer) {
|
||||
printf("ERROR: Cannot allocate command buffer!\n");
|
||||
|
|
@ -171,7 +175,7 @@ void sysparam_editor_task(void *pvParameters) {
|
|||
}
|
||||
while (true) {
|
||||
printf("==> ");
|
||||
len = tty_readline(cmd_buffer, CMD_BUF_SIZE, true);
|
||||
len = tty_readline(cmd_buffer, CMD_BUF_SIZE, echo);
|
||||
status = 0;
|
||||
if (!len) continue;
|
||||
if (cmd_buffer[len - 1] == '?') {
|
||||
|
|
@ -214,6 +218,9 @@ void sysparam_editor_task(void *pvParameters) {
|
|||
// using.
|
||||
status = sysparam_init(base_addr, 0);
|
||||
}
|
||||
} else if (!strcmp(cmd_buffer, "echo")) {
|
||||
echo = !echo;
|
||||
printf("Echo: %s\n", echo ? "on" : "off");
|
||||
} else if (!strcmp(cmd_buffer, "help")) {
|
||||
usage();
|
||||
} else {
|
||||
|
|
@ -229,5 +236,7 @@ void sysparam_editor_task(void *pvParameters) {
|
|||
|
||||
void user_init(void)
|
||||
{
|
||||
uart_set_baud(0, 115200);
|
||||
|
||||
xTaskCreate(sysparam_editor_task, (signed char *)"sysparam_editor_task", 512, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue