From 1de4e8213d3084aead0ebd3529bd148d07117474 Mon Sep 17 00:00:00 2001 From: Thomas Maier-Komor Date: Sun, 28 Jul 2024 16:50:20 +0200 Subject: [PATCH] release R2407 --- ChangeLog | 4 ++++ main/fs.cpp | 40 +++++++++++++++++++++++++++++++++++++--- main/romfs.cpp | 26 ++++++++++++-------------- 3 files changed, 53 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index df43c45..7ac7b5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +R2407: +====== +- fix ROMFS missing on 1MB builds + R2406: ====== - fix mDNS regression caused by IDF update diff --git a/main/fs.cpp b/main/fs.cpp index fb3acd4..2d2daa1 100644 --- a/main/fs.cpp +++ b/main/fs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023, 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 @@ -118,6 +118,34 @@ static struct dirent *rootfs_vfs_readdir(DIR *d) return r; return 0; } + + +#if 0 // not needed, as stat is directed to child filesystem +static int rootfs_vfs_stat(const char *fn, struct stat *st) +{ + log_dbug(TAG,"rootfs_vfs_stat(%s,...)",fn); + if ((0 == fn) || (0 == st)) + return EINVAL; + for (int e = 0; e < (sizeof(RootEntr)/sizeof(RootEntr[0])); ++e) { + if ((0 != RootEntr[e]) && (0 == strcmp(fn,RootEntr[e]))) { + st->st_mode = S_IFDIR; + return 0; + } + } + return -1; +} + + +static int rootfs_vfs_fstat(int fd, struct stat *st) +{ + log_dbug(TAG,"rootfs_vfs_fstat(%d,...)",fd); + if (0 == st) + return EINVAL; + abort(); + // TODO + return 0; +} +#endif // no stat/fstat #endif @@ -147,6 +175,10 @@ void rootfs_init() vfs.opendir = rootfs_vfs_opendir; vfs.readdir = rootfs_vfs_readdir; vfs.readdir_r = rootfs_vfs_readdir_r; +#if 0 // not needed, as stat is directed to child filesystem + vfs.fstat = rootfs_vfs_fstat; + vfs.stat = rootfs_vfs_stat; +#endif if (esp_err_t e = esp_vfs_register("",&vfs,0)) log_warn(TAG,"VFS register rootfs: %s",esp_err_to_name(e)); else @@ -287,7 +319,9 @@ static void init_hwconf() static void romfs_init() { -#ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB +#ifdef CONFIG_ESPTOOLPY_FLASHSIZE_1MB + romfs_setup(); +#else if (const char *r = romfs_setup()) { rootfs_add(r); } @@ -315,7 +349,7 @@ const char *shell_format(Terminal &term, int argc, const char *args[]) } #else if (argc != 2) - return "Missing argument."; + return "Invalid number of arguments."; #if defined CONFIG_SPIFFS return shell_format_spiffs(term,args[1]) ? "Failed." : 0; #endif diff --git a/main/romfs.cpp b/main/romfs.cpp index bba54da..4e23428 100644 --- a/main/romfs.cpp +++ b/main/romfs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023, 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 @@ -411,18 +411,16 @@ const char *romfs_setup() log_dbug(TAG,"looking for " ROMFS_MAGIC); while (pi != 0) { p = esp_partition_get(pi); - uint8_t magic[8]; -#if IDF_VERSION >= 50 - esp_partition_read_raw(p,0,(char *)magic,sizeof(magic)); -#else - spi_flash_read(p->address,magic,sizeof(magic)); -#endif - log_hex(TAG,magic,sizeof(magic),"partition %s",p->label); - if (0 == memcmp(magic,ROMFS_MAGIC,sizeof(magic))) { - log_info(TAG,"%s has ROMFS",p->label); - break; + uint8_t magic[8] = { 0 }; + if (esp_err_t e = esp_partition_read(p,0,(char *)magic,sizeof(magic))) { + log_warn(TAG,"read partition %s: %s",p->label,esp_err_to_name(e)); + } else { + log_hex(TAG,magic,sizeof(magic),"partition %s",p->label); + if (0 == memcmp(magic,ROMFS_MAGIC,sizeof(magic))) { + break; + } + log_dbug(TAG,"%s has no ROMFS",p->label); } - log_dbug(TAG,"%s has no ROMFS",p->label); pi = esp_partition_next(pi); p = 0; } @@ -446,10 +444,10 @@ const char *romfs_setup() } #endif if (p == 0) { - log_dbug(TAG,"no romfs found"); + log_info(TAG,"no romfs found"); return 0; } - log_dbug(TAG,"using partition %s",p->label); + log_info(TAG,"ROMFS on partition %s",p->label); RomfsBaseAddr = p->address; RomfsSpace = p->size;