Skip to content

Commit 0a56fe0

Browse files
Make spiffs build on 0.2.0 cross compile
1 parent 4b30c03 commit 0a56fe0

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

build

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ if [ ! -r arena/downloaded ]; then
239239
)
240240

241241
( cd dl/gcc-xtensa && git reset --hard && git checkout ${xtensa_branch} )
242-
( cd dl/mkspiffs && git checkout 0.2.0 && git submodule update )
242+
( cd dl/mkspiffs && git checkout 0.2.0 && git reset --hard && patch -p1 < ../../patches/mkspiffs/0.2.0-makefile.patch && git submodule update )
243243

244244
# download and put tools directly in gcc directory
245245
# let gcc's configure deal with them in place
@@ -310,6 +310,9 @@ EOF
310310
touch arena/patched
311311
fi
312312

313+
tool=mkspiffs CPPFLAGS="-DSPIFFS_USE_MAGIC_LENGTH=0 -DSPIFFS_ALIGNED_OBJECT_INDEX_TABLES=1" maketool
314+
tool=esptool extra_opts='' maketool
315+
exit
313316
# configure build install binutils
314317
if [ ! -r arena/binutils/jobdone ]; then
315318
echo "-------- gdb+binutils"

patches/mkspiffs/0.2.0-makefile.patch

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
diff --git a/Makefile b/Makefile
2+
index e21c970..edd1ac8 100644
3+
--- a/Makefile
4+
+++ b/Makefile
5+
@@ -1,5 +1,7 @@
6+
BUILD_CONFIG_NAME ?=
7+
8+
+ifndef TARGET_OS
9+
+
10+
ifeq ($(OS),Windows_NT)
11+
TARGET_OS := WINDOWS
12+
DIST_SUFFIX := windows
13+
@@ -36,6 +38,31 @@ else
14+
TARGET := mkspiffs
15+
endif
16+
17+
+endif
18+
+
19+
+# OS-specific settings and build flags
20+
+ifeq ($(TARGET_OS),windows)
21+
+ ARCHIVE ?= zip
22+
+ TARGET := mkspiffs.exe
23+
+ TARGET_CFLAGS = -mno-ms-bitfields
24+
+ TARGET_LDFLAGS = -Wl,-static -static-libgcc -static-libstdc++
25+
+else
26+
+ ARCHIVE ?= tar
27+
+ TARGET := mkspiffs
28+
+endif
29+
+
30+
+# Packaging into archive (for 'dist' target)
31+
+ifeq ($(ARCHIVE), zip)
32+
+ ARCHIVE_CMD := zip -r
33+
+ ARCHIVE_EXTENSION := zip
34+
+endif
35+
+ifeq ($(ARCHIVE), tar)
36+
+ ARCHIVE_CMD := tar czf
37+
+ ARCHIVE_EXTENSION := tar.gz
38+
+endif
39+
+
40+
+
41+
+
42+
VERSION ?= $(shell git describe --always)
43+
44+
OBJ := main.o \
45+
@@ -56,6 +83,8 @@ DIST_NAME := mkspiffs-$(VERSION)$(BUILD_CONFIG_NAME)-$(DIST_SUFFIX)
46+
DIST_DIR := $(DIST_NAME)
47+
DIST_ARCHIVE := $(DIST_NAME).$(ARCHIVE_EXTENSION)
48+
49+
+STRIP ?= strip
50+
+
51+
.PHONY: all clean dist
52+
53+
all: $(TARGET)
54+
@@ -68,7 +97,7 @@ $(DIST_ARCHIVE): $(TARGET) $(DIST_DIR)
55+
56+
$(TARGET): $(OBJ)
57+
$(CXX) $^ -o $@ $(LDFLAGS)
58+
- strip $(TARGET)
59+
+ $(STRIP) $(TARGET)
60+
61+
$(DIST_DIR):
62+
@mkdir -p $@
63+
diff --git a/main.cpp b/main.cpp
64+
index c82b91b..2f24829 100644
65+
--- a/main.cpp
66+
+++ b/main.cpp
67+
@@ -305,7 +305,7 @@ bool dirCreate(const char* path) {
68+
69+
// platform stuff...
70+
#if defined(_WIN32)
71+
- if (_mkdir(path) != 0) {
72+
+ if (mkdir(path) != 0) {
73+
#else
74+
if (mkdir(path, S_IRWXU | S_IXGRP | S_IRGRP | S_IROTH | S_IXOTH) != 0) {
75+
#endif

0 commit comments

Comments
 (0)