Skip to content

Commit ab0d9c9

Browse files
author
David Betz
committed
Change the way that the flash filesystem base address is handled
in preparation for supporting 1MB or maybe even 512KB modules.
1 parent f6d8788 commit ab0d9c9

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

parallax/cgiprop.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ int ICACHE_FLASH_ATTR cgiPropInit()
8383
os_timer_arm(&resetButtonTimer, RESET_BUTTON_SAMPLE_INTERVAL, 1);
8484

8585
int ret;
86-
if ((ret = roffs_mount(FLASH_FILESYSTEM_BASE)) != 0) {
86+
if ((ret = roffs_mount(roffs_base_address())) != 0) {
8787
os_printf("Mounting flash filesystem failed: %d\n", ret);
8888
os_printf("Attempting to format...");
89-
if ((ret = roffs_format(FLASH_FILESYSTEM_BASE)) != 0) {
89+
if ((ret = roffs_format(roffs_base_address())) != 0) {
9090
os_printf("Error formatting filesystem: %d\n", ret);
9191
return -1;
9292
}
9393
os_printf("Flash filesystem formatted.\n");
94-
if ((ret = roffs_mount(FLASH_FILESYSTEM_BASE)) != 0) {
94+
if ((ret = roffs_mount(roffs_base_address())) != 0) {
9595
os_printf("Mounting newly formatted flash filesystem failed: %d\n", ret);
9696
return -1;
9797
}

parallax/httpdroffs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ int ICACHE_FLASH_ATTR cgiRoffsFormat(HttpdConnData *connData)
118118
{
119119
if (connData->conn == NULL)
120120
return HTTPD_CGI_DONE;
121-
if (roffs_format(FLASH_FILESYSTEM_BASE) != 0) {
121+
if (roffs_format(roffs_base_address()) != 0) {
122122
httpdSendResponse(connData, 400, "Error formatting filesystem\r\n", -1);
123123
return HTTPD_CGI_DONE;
124124
}
125-
if (roffs_mount(FLASH_FILESYSTEM_BASE) != 0) {
125+
if (roffs_mount(roffs_base_address()) != 0) {
126126
httpdSendResponse(connData, 400, "Error mounting newly formatted flash filesystem\r\n", -1);
127127
return HTTPD_CGI_DONE;
128128
}

parallax/roffs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Connector to let httpd use the espfs filesystem to serve the files in it.
2929

3030
#include "roffsformat.h"
3131

32+
// default filesystem base address in flash
33+
#define FLASH_FILESYSTEM_BASE 0x100000
34+
3235
// open file structure
3336
struct ROFFS_FILE_STRUCT {
3437
uint32_t header;
@@ -48,6 +51,11 @@ static int readFlash(uint32_t addr, void *buf, int size);
4851
static int writeFlash(uint32_t addr, void *buf, int size);
4952
static int updateFlash(uint32_t addr, void *buf, int size);
5053

54+
uint32_t roffs_base_address(void)
55+
{
56+
return FLASH_FILESYSTEM_BASE;
57+
}
58+
5159
int ICACHE_FLASH_ATTR roffs_mount(uint32_t flashAddress)
5260
{
5361
RoFsHeader testHeader;

parallax/roffs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ Connector to let httpd use the espfs filesystem to serve the files in it.
2222

2323
#include <esp8266.h>
2424

25-
#define FLASH_FILESYSTEM_BASE 0x100000
26-
2725
/* must match definitions in roffsformat.h */
2826
#define ROFFS_FLAG_GZIP (1<<1)
2927

3028
#include "roffsformat.h"
3129
typedef struct ROFFS_FILE_STRUCT ROFFS_FILE;
3230

31+
uint32_t roffs_base_address(void);
3332
int roffs_mount(uint32_t flashAddress);
3433
int roffs_format(uint32_t flashAddress);
3534
ROFFS_FILE *roffs_open(const char *fileName);

0 commit comments

Comments
 (0)