Merge branch 'experiments/posix_fs' into feature/spiffs
This commit is contained in:
commit
6484c57737
5 changed files with 71 additions and 6 deletions
4
.gitmodules
vendored
4
.gitmodules
vendored
|
@ -10,7 +10,9 @@
|
||||||
[submodule "bootloader/rboot"]
|
[submodule "bootloader/rboot"]
|
||||||
path = bootloader/rboot
|
path = bootloader/rboot
|
||||||
url = https://github.com/raburton/rboot.git
|
url = https://github.com/raburton/rboot.git
|
||||||
|
|
||||||
[submodule "extras/spiffs/spiffs"]
|
[submodule "extras/spiffs/spiffs"]
|
||||||
path = extras/spiffs/spiffs
|
path = extras/spiffs/spiffs
|
||||||
url = https://github.com/pellepl/spiffs.git
|
url = https://github.com/pellepl/spiffs.git
|
||||||
|
[submodule "examples/posix_fs/fs-test"]
|
||||||
|
path = examples/posix_fs/fs-test
|
||||||
|
url = https://github.com/sheinz/fs-test
|
||||||
|
|
|
@ -41,7 +41,7 @@ IRAM caddr_t _sbrk_r (struct _reent *r, int incr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* syscall implementation for stdio write to UART */
|
/* syscall implementation for stdio write to UART */
|
||||||
long _write_r(struct _reent *r, int fd, const char *ptr, int len )
|
__attribute__((weak)) long _write_r(struct _reent *r, int fd, const char *ptr, int len )
|
||||||
{
|
{
|
||||||
if(fd != r->_stdout->_file) {
|
if(fd != r->_stdout->_file) {
|
||||||
r->_errno = EBADF;
|
r->_errno = EBADF;
|
||||||
|
@ -79,10 +79,20 @@ __attribute__((weak)) long _read_r( struct _reent *r, int fd, char *ptr, int len
|
||||||
/* Stub syscall implementations follow, to allow compiling newlib functions that
|
/* Stub syscall implementations follow, to allow compiling newlib functions that
|
||||||
pull these in via various codepaths
|
pull these in via various codepaths
|
||||||
*/
|
*/
|
||||||
__attribute__((alias("syscall_returns_enosys"))) int _open_r(struct _reent *r, const char *pathname, int flags, int mode);
|
__attribute__((weak, alias("syscall_returns_enosys")))
|
||||||
__attribute__((alias("syscall_returns_enosys"))) int _fstat_r(struct _reent *r, int fd, void *buf);
|
int _open_r(struct _reent *r, const char *pathname, int flags, int mode);
|
||||||
__attribute__((alias("syscall_returns_enosys"))) int _close_r(struct _reent *r, int fd);
|
|
||||||
__attribute__((alias("syscall_returns_enosys"))) off_t _lseek_r(struct _reent *r, int fd, off_t offset, int whence);
|
__attribute__((weak, alias("syscall_returns_enosys")))
|
||||||
|
int _close_r(struct _reent *r, int fd);
|
||||||
|
|
||||||
|
__attribute__((weak, alias("syscall_returns_enosys")))
|
||||||
|
int _unlink_r(struct _reent *r, const char *path);
|
||||||
|
|
||||||
|
__attribute__((alias("syscall_returns_enosys")))
|
||||||
|
int _fstat_r(struct _reent *r, int fd, void *buf);
|
||||||
|
|
||||||
|
__attribute__((alias("syscall_returns_enosys")))
|
||||||
|
off_t _lseek_r(struct _reent *r, int fd, off_t offset, int whence);
|
||||||
|
|
||||||
/* Generic stub for any newlib syscall that fails with errno ENOSYS
|
/* Generic stub for any newlib syscall that fails with errno ENOSYS
|
||||||
("Function not implemented") and a return value equivalent to
|
("Function not implemented") and a return value equivalent to
|
||||||
|
|
11
examples/posix_fs/Makefile
Normal file
11
examples/posix_fs/Makefile
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
PROGRAM=posix_fs_example
|
||||||
|
PROGRAM_EXTRA_SRC_FILES=./fs-test/fs_test.c
|
||||||
|
|
||||||
|
EXTRA_COMPONENTS = extras/spiffs
|
||||||
|
FLASH_SIZE = 32
|
||||||
|
|
||||||
|
# spiffs configuration
|
||||||
|
SPIFFS_BASE_ADDR = 0x200000
|
||||||
|
SPIFFS_SIZE = 0x100000
|
||||||
|
|
||||||
|
include ../../common.mk
|
1
examples/posix_fs/fs-test
Submodule
1
examples/posix_fs/fs-test
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 218c5235584429f407d619e5e35f90732ad505f3
|
41
examples/posix_fs/posix_fs_example.c
Normal file
41
examples/posix_fs/posix_fs_example.c
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#include "espressif/esp_common.h"
|
||||||
|
#include "esp/uart.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "esp8266.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "esp_spiffs.h"
|
||||||
|
#include "spiffs.h"
|
||||||
|
|
||||||
|
#include "fs-test/fs_test.h"
|
||||||
|
|
||||||
|
|
||||||
|
void test_task(void *pvParameters)
|
||||||
|
{
|
||||||
|
esp_spiffs_mount();
|
||||||
|
esp_spiffs_unmount(); // FS must be unmounted before formating
|
||||||
|
if (SPIFFS_format(&fs) == SPIFFS_OK) {
|
||||||
|
printf("Format complete\n");
|
||||||
|
} else {
|
||||||
|
printf("Format failed\n");
|
||||||
|
}
|
||||||
|
esp_spiffs_mount();
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
vTaskDelay(5000 / portTICK_RATE_MS);
|
||||||
|
|
||||||
|
if (fs_test_run(1000)) {
|
||||||
|
printf("PASS\n");
|
||||||
|
} else {
|
||||||
|
printf("FAIL\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void user_init(void)
|
||||||
|
{
|
||||||
|
uart_set_baud(0, 115200);
|
||||||
|
|
||||||
|
xTaskCreate(test_task, (signed char *)"test_task", 1024, NULL, 2, NULL);
|
||||||
|
}
|
Loading…
Reference in a new issue