Skip to content

Commit

Permalink
release R2404
Browse files Browse the repository at this point in the history
  • Loading branch information
maierkomor committed May 1, 2024
1 parent 748fed7 commit 5209413
Show file tree
Hide file tree
Showing 74 changed files with 6,216 additions and 14,030 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
components/memfiles/*.cpp
components/memfiles/memfiles.h
components/memfiles/CMakeLists.txt
main/binformats.cpp
main/binformats.h
main/version.h
main/versions.h
data/version.txt
settings.mk
bin/mkromfs
Expand Down
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
R2404:
======
- revert to IDF v5.1.1 (ESP32), due to console hang
- added support for full Latin1 character set
- fix SSD130x fillRect does not set dirty bits
- fix influx reinit
- fix relay persistency
- 1-wire updates
- more bugfixes

R2403:
======
- gracefully handle kiss-of-death packet of SNTP
Expand Down
39 changes: 4 additions & 35 deletions components/cyclic/cyclic.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2022, Thomas Maier-Komor
* Copyright (C) 2017-2024, Thomas Maier-Komor
* Atrium Firmware Package for ESP
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -33,7 +33,6 @@
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#include <freertos/task.h>
//#include <driver/gpio.h>

#include <vector>

Expand All @@ -43,14 +42,10 @@
#define CYCLIC_CPU_NUM APP_CPU_NUM
#endif

#ifndef CONFIG_CYCLIC_STACK_SIZE
#define CONFIG_CYCLIC_STACK_SIZE 4096
#endif

using namespace std;

#define TAG MODULE_CYCLIC
#define STATIC_TASK


struct SubTask
{
Expand Down Expand Up @@ -81,11 +76,6 @@ struct SubTaskCmp
{ return l.nextrun < r.nextrun; }
};

#if defined ESP32 && defined STATIC_TASK
static StackType_t CyclicStack[CONFIG_CYCLIC_STACK_SIZE];
static StaticTask_t CyclicTask;
#endif

static SubTask *SubTasks = 0;
static SemaphoreHandle_t Mtx = 0;
static uint64_t TimeSpent = 0;
Expand All @@ -109,7 +99,7 @@ int cyclic_add_task(const char *name, unsigned (*loop)(void*), void *arg, unsign
if (0 == strcmp(s->name,name)) {
xSemaphoreGive(Mtx);
delete n;
log_error(TAG,"subtask %s already exists",name);
log_warn(TAG,"subtask %s already exists",name);
return 1;
}
s = s->next;
Expand Down Expand Up @@ -182,31 +172,10 @@ unsigned cyclic_execute()
}


#ifdef ESP32
static void cyclic_task(void *)
{
for (;;) {
unsigned d = cyclic_execute();
vTaskDelay(d / portTICK_PERIOD_MS);
}
}
#endif


void cyclic_setup()
{
Mtx = xSemaphoreCreateMutex();
#ifdef ESP32
#ifdef STATIC_TASK
xTaskCreateStaticPinnedToCore(cyclic_task, "cyclic", sizeof(CyclicStack), (void*)0, 20, CyclicStack, &CyclicTask, CYCLIC_CPU_NUM);
#else
BaseType_t r = xTaskCreatePinnedToCore(cyclic_task, "cyclic", 8192, (void*)0, 20, NULL, 1);
if (r != pdPASS)
log_error(TAG,"create task: %d",r);
#endif // STATIC_TASK
#else
// cyclic_execute is called from the event task
#endif
// cyclic_execute is called from the event or startup task
}


Expand Down
7 changes: 4 additions & 3 deletions components/event/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using namespace std;
#define TAG MODULE_EVENT
#define STATIC_TASK

#if!defined APP_CPU_NUM || defined CONFIG_FREERTOS_UNICORE
#if !defined APP_CPU_NUM || defined CONFIG_FREERTOS_UNICORE
#define EVENT_CPU_NUM 0
#else
#define EVENT_CPU_NUM APP_CPU_NUM
Expand Down Expand Up @@ -535,11 +535,12 @@ void event_init(void)
int event_start(void)
{
#ifdef CONFIG_IDF_TARGET_ESP8266
// static task allocation support is missing
xTaskCreate(&event_task, "events", CONFIG_EVENT_STACK_SIZE, (void*)0, 9, 0);
#elif defined STATIC_TASK
xTaskCreateStaticPinnedToCore(&event_task, "events", sizeof(EventStack), (void*)0, 9, EventStack, &EventTask, EVENT_CPU_NUM);
xTaskCreateStatic(&event_task, "events", sizeof(EventStack), (void*)0, 9, EventStack, &EventTask);
#else
BaseType_t r = xTaskCreatePinnedToCore(&event_task, "events", 8*1024, (void*)0, 9, NULL, 1);
BaseType_t r = xTaskCreatePinnedToCore(&event_task, "events", 8*1024, (void*)0, 9, NULL, EVENT_CPU_NUM);
if (r != pdPASS) {
log_error(TAG,"create task: %d",r);
return 1;
Expand Down
52 changes: 34 additions & 18 deletions components/logging/logging.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2022, Thomas Maier-Komor
* Copyright (C) 2018-2024, Thomas Maier-Komor
* Atrium Firmware Package for ESP
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -94,9 +94,9 @@ extern void log_usb(const char *, size_t n);
uint8_t UsbDiag = 1;
static SemaphoreHandle_t UartLock;
#if CONFIG_CONSOLE_UART_NONE != 1
static uart_port_t LogUart = (uart_port_t) CONFIG_CONSOLE_UART_NUM;
static int LogUart = CONFIG_CONSOLE_UART_NUM;
#else
static uart_port_t LogUart = (uart_port_t) -1;
static int LogUart = -1;
#endif

#ifdef HAVE_FS
Expand Down Expand Up @@ -126,9 +126,12 @@ void con_print(const char *str)
if ((LogUart != -1) && (s != 0)) {
if (pdFALSE == xSemaphoreTake(UartLock,MUTEX_ABORT_TIMEOUT))
abort_on_mutex(UartLock,__FUNCTION__);
uart_write_bytes(LogUart,str,s);
uart_write_bytes(LogUart,"\r\n",2);
uart_wait_tx_done((uart_port_t)LogUart,portMAX_DELAY);
if (0 <= uart_write_bytes(LogUart,str,s)) {
uart_write_bytes(LogUart,"\r\n",2);
uart_wait_tx_done((uart_port_t)LogUart,portMAX_DELAY);
} else {
LogUart = -1;
}
xSemaphoreGive(UartLock);
}
#endif
Expand Down Expand Up @@ -161,9 +164,12 @@ void con_printv(const char *f, va_list val)
if (LogUart != -1) {
if (pdFALSE == xSemaphoreTake(UartLock,MUTEX_ABORT_TIMEOUT))
abort_on_mutex(UartLock,__FUNCTION__);
uart_write_bytes(LogUart,buf,n);
uart_write_bytes(LogUart,"\r\n",2);
uart_wait_tx_done((uart_port_t)LogUart,portMAX_DELAY);
if (0 <= uart_write_bytes(LogUart,buf,n)) {
uart_write_bytes(LogUart,"\r\n",2);
uart_wait_tx_done((uart_port_t)LogUart,portMAX_DELAY);
} else {
LogUart = -1;
}
xSemaphoreGive(UartLock);
}
#endif
Expand All @@ -179,7 +185,8 @@ void con_write(const char *str, ssize_t s)
#if CONFIG_CONSOLE_UART_NONE != 1
if ((LogUart != -1) && (s > 0)) {
xSemaphoreTake(UartLock,portMAX_DELAY);
uart_write_bytes(LogUart,str,s);
if (0 < uart_write_bytes(LogUart,str,s))
LogUart = -1;
xSemaphoreGive(UartLock);
}
#endif
Expand All @@ -199,12 +206,14 @@ void log_setup()
#endif

UartLock = xSemaphoreCreateMutex();
if (LogUart >= 0) {
#if CONFIG_UART_CONSOLE_NONE != 1 && CONFIG_CONSOLE_UART_NUM != -1
uart_driver_install((uart_port_t)CONFIG_CONSOLE_UART_NUM,UART_FIFO_LEN*2,UART_FIFO_LEN*2,0,DRIVER_ARG);
uart_driver_install((uart_port_t)LogUart,UART_FIFO_LEN*2,UART_FIFO_LEN*2,0,DRIVER_ARG);
#if (CONFIG_CONSOLE_UART_RX != -1) || (CONFIG_CONSOLE_UART_TX != -1)
uart_set_pin((uart_port_t)CONFIG_CONSOLE_UART_NUM, CONFIG_CONSOLE_UART_TX, CONFIG_CONSOLE_UART_RX , -1, -1);
uart_set_pin((uart_port_t)LogUart, CONFIG_CONSOLE_UART_TX, CONFIG_CONSOLE_UART_RX , -1, -1);
#endif
#endif
}

#if defined CONFIG_USB_DIAGLOG || defined CONFIG_USB_CONSOLE
usb_serial_jtag_driver_config_t cfg;
Expand Down Expand Up @@ -301,11 +310,14 @@ void log_common(log_level_t l, logmod_t m, const char *f, va_list val)
if (LogUart >= 0) {
if (pdTRUE != xSemaphoreTake(UartLock,MUTEX_ABORT_TIMEOUT))
abort_on_mutex(UartLock,__BASE_FILE__);
uart_write_bytes((uart_port_t)LogUart,buf,s);
if (0 <= uart_write_bytes((uart_port_t)LogUart,buf,s)) {
#ifndef CONFIG_DEVEL
if (l <= ll_warn)
if (l <= ll_warn)
#endif
uart_wait_tx_done((uart_port_t)LogUart,portMAX_DELAY);
uart_wait_tx_done((uart_port_t)LogUart,portMAX_DELAY);
} else {
LogUart = -1;
}
xSemaphoreGive(UartLock);
}
#ifdef HAVE_FS
Expand All @@ -316,7 +328,7 @@ void log_common(log_level_t l, logmod_t m, const char *f, va_list val)
}
#endif
#ifdef CONFIG_SYSLOG
if ((l != ll_local) && (m != MODULE_LOG) && (m != MODULE_LWTCP))
if ((m != MODULE_LOG) && (m != MODULE_LWTCP))
log_syslog(l,m,buf+p,s-p-2,&tv);
#endif
#ifdef CONFIG_USB_DIAGLOG
Expand Down Expand Up @@ -398,8 +410,12 @@ void log_info(logmod_t m, const char *f, ...)

void uart_print(const char *str)
{
uart_write_bytes(LogUart,str,strlen(str));
uart_write_bytes(LogUart,"\r\n",2);
if (LogUart >= 0) {
if (0 <= uart_write_bytes(LogUart,str,strlen(str)))
uart_write_bytes(LogUart,"\r\n",2);
else
LogUart = -1;
}
}


Expand Down
2 changes: 1 addition & 1 deletion components/logging/xlog.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021, Thomas Maier-Komor
* Copyright (C) 2020-2024, Thomas Maier-Komor
* Atrium Firmware Package for ESP
*
* This program is free software: you can redistribute it and/or modify
Expand Down
26 changes: 25 additions & 1 deletion components/nvm/nvm.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2021, Thomas Maier-Komor
* Copyright (C) 2017-2024, Thomas Maier-Komor
* Atrium Firmware Package for ESP
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <sdkconfig.h>

#include "log.h"
#include "nvm.h"
#include "profiling.h"
Expand All @@ -27,6 +29,9 @@

#define TAG MODULE_NVM

#ifdef CONFIG_ESPTOOLPY_FLASHSIZE_1MB
#define log_dbug(...)
#endif

static nvs_handle NVS;

Expand Down Expand Up @@ -56,16 +61,22 @@ uint8_t nvm_read_u8(const char *id, uint8_t d)
log_warn(TAG,"get %s: %s",id,esp_err_to_name(e));
return d;
}
log_dbug(TAG,"read %s: %u",id,v);
return v;
}


void nvm_store_u8(const char *id, uint8_t v)
{
uint8_t s;
if (esp_err_t e = nvs_set_u8(NVS,id,v))
log_warn(TAG,"set %s to %u: %s",id,(unsigned)v,esp_err_to_name(e));
else if (esp_err_t e = nvs_commit(NVS))
log_warn(TAG,"commit %s: %s",id,esp_err_to_name(e));
else if (esp_err_t e = nvs_get_u8(NVS,id,&s))
log_warn(TAG,"readback %s: %s",id,esp_err_to_name(e));
else
log_info(TAG,"stored %s: %u",id,s);
}


Expand All @@ -76,6 +87,7 @@ uint16_t nvm_read_u16(const char *id, uint16_t d)
log_warn(TAG,"get %s: %s",id,esp_err_to_name(e));
return d;
}
log_dbug(TAG,"read %s: %u",id,v);
return v;
}

Expand All @@ -86,6 +98,8 @@ void nvm_store_u16(const char *id, uint16_t v)
log_warn(TAG,"set %s to %u: %s",id,(unsigned)v,esp_err_to_name(e));
else if (esp_err_t e = nvs_commit(NVS))
log_warn(TAG,"commit %s: %s",id,esp_err_to_name(e));
else
log_dbug(TAG,"stored %s: %u",id,v);
}


Expand All @@ -96,6 +110,7 @@ uint32_t nvm_read_u32(const char *id, uint32_t d)
log_warn(TAG,"get %s: %s",id,esp_err_to_name(e));
return d;
}
log_dbug(TAG,"read %s: %u",id,v);
return v;
}

Expand All @@ -106,6 +121,8 @@ void nvm_store_u32(const char *id, uint32_t v)
log_warn(TAG,"set %s to %u: %s",id,(unsigned)v,esp_err_to_name(e));
else if (esp_err_t e = nvs_commit(NVS))
log_warn(TAG,"commit %s: %s",id,esp_err_to_name(e));
else
log_dbug(TAG,"stored %s: %u",id,v);
}


Expand All @@ -116,6 +133,7 @@ float nvm_read_float(const char *id, float d)
log_warn(TAG,"get %s: %s",id,esp_err_to_name(e));
return d;
}
log_dbug(TAG,"read %s: %g",id,v);
return v;
}

Expand All @@ -131,6 +149,8 @@ void nvm_store_float(const char *id, float v)
log_warn(TAG,"set %s to %f: %s",id,v,esp_err_to_name(e));
else if (esp_err_t e = nvs_commit(NVS))
log_warn(TAG,"commit %s: %s",id,esp_err_to_name(e));
else
log_dbug(TAG,"stored %s: %u",id,v);
}


Expand Down Expand Up @@ -194,13 +214,17 @@ void nvm_erase_key(const char *k)
{
if (esp_err_t e = nvs_erase_key(NVS,k))
log_warn(TAG,"erase %s: %s",k,esp_err_to_name(e));
else
log_dbug(TAG,"erased %s",k);
}


void nvm_erase_all()
{
if (esp_err_t e = nvs_erase_all(NVS))
log_warn(TAG,"erase all: %s",esp_err_to_name(e));
else
log_dbug(TAG,"reset NVM");
}


Loading

0 comments on commit 5209413

Please sign in to comment.