Skip to content

Commit

Permalink
Add support for LFS
Browse files Browse the repository at this point in the history
Contribution from @TerryE, fixes #29
  • Loading branch information
marcelstoer committed Jul 7, 2018
1 parent aa5928e commit 1eb4c0e
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 59 deletions.
38 changes: 19 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ cache:
- cache
before_install:
- cat build.config
- export X_EMAIL=$(grep -E 'email=(.*)' build.config | cut -c 7-)
- export X_BRANCH=$(grep -E 'branch=(.*)' build.config | cut -c 8-)
- export X_MODULES=$(grep -E 'modules=(.*)' build.config | cut -c 9-)
- export X_U8G_FONTS=$(grep -E 'u8g-fonts=(.*)' build.config | cut -c 11-)
- export X_U8G_DISPLAY_I2C=$(grep -E 'u8g-display-i2c=(.*)' build.config | cut -c 17-)
- export X_U8G_DISPLAY_SPI=$(grep -E 'u8g-display-spi=(.*)' build.config | cut -c 17-)
- export X_UCG_DISPLAY_SPI=$(grep -E 'ucg-display-spi=(.*)' build.config | cut -c 17-)
- export X_SSL_ENABLED=$(grep -E 'ssl-enabled=(.*)' build.config | cut -c 13-)
- export X_DEBUG_ENABLED=$(grep -E 'debug-enabled=(.*)' build.config | cut -c 15-)
- export X_FATFS_ENABLED=$(grep -E 'fatfs-enabled=(.*)' build.config | cut -c 15-)
# count ',' in the string and add +1
- export X_NUMBER_OF_MODULES=$((`echo $X_MODULES | tr -d -c ',' | wc -m`+1))
- env | grep 'X_'

- export X_EMAIL=$(grep -E '^email=' build.config | cut -f 2- -d '=')
- export X_BRANCH=$(grep -E '^branch=' build.config | cut -f 2- -d '=')
- export X_MODULES=$(grep -E '^modules=' build.config | cut -f 2- -d '=')
- export X_U8G_FONTS=$(grep -E '^u8g-fonts=' build.config | cut -f 2- -d '=')
- export X_U8G_DISPLAY_I2C=$(grep -E '^u8g-display-i2c=' build.config | cut -f 2- -d '=')
- export X_U8G_DISPLAY_SPI=$(grep -E '^u8g-display-spi=' build.config | cut -f 2- -d '=')
- export X_UCG_DISPLAY_SPI=$(grep -E '^ucg-display-spi=' build.config | cut -f 2- -d '=')
- export X_LUA_FLASH_STORE=$(grep -E '^lfs-size=' build.config | cut -f 2- -d '=')
- export X_SPIFFS_FIXED_LOCATION=$(grep -E '^spiffs-base=' build.config | cut -f 2- -d '=')
- export X_SPIFFS_MAX_FILESYSTEM_SIZE=$(grep -E '^spiffs-size=' build.config | cut -f 2- -d '=')
- export X_SSL_ENABLED=$(grep -E '^ssl-enabled=' build.config | cut -f 2- -d '=')
- export X_DEBUG_ENABLED=$(grep -E '^debug-enabled=' build.config | cut -f 2- -d '=')
- export X_FATFS_ENABLED=$(grep -E '^fatfs-enabled=' build.config | cut -f 2- -d '=')
- export X_NUMBER_OF_MODULES=$(echo $X_MODULES | awk -F\, '{print NF}')
- export -p | grep " X_"

- wget -d -v -O/dev/null --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused --no-check-certificate 'https://nodemcu-build.com/hook.php?event=start&recipient='${X_EMAIL//+/%2B}
- git clone --depth=1 --branch=$X_BRANCH git://github.com/nodemcu/nodemcu-firmware.git nodemcu-firmware
Expand All @@ -33,12 +36,8 @@ before_install:

# replace modules in user_modules.h by the selected ones
- bash $TRAVIS_BUILD_DIR/set-modules.sh
# comment the SSL flag in user_config.h if not enabled
- bash $TRAVIS_BUILD_DIR/set-ssl.sh
# set the NODE_DEBUG and COAP_DEBUG flags in user_config.h
- bash $TRAVIS_BUILD_DIR/set-debug.sh
# set the BUILD_FATFS flag in user_config.h
- bash $TRAVIS_BUILD_DIR/set-fatfs.sh
# set defines in user_config.h according to X_* variables
- bash $TRAVIS_BUILD_DIR/set-config.sh
# replace fonts in u8g_config.h by the selected ones
- bash $TRAVIS_BUILD_DIR/set-fonts.sh
# set I2C/SPI displays in u8g_config.h and ucg_config.h
Expand Down Expand Up @@ -101,3 +100,4 @@ branches:
only:
- builds
- master

6 changes: 5 additions & 1 deletion build.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ [email protected]
branch=dev
modules=node,file,gpio,wifi,net,tmr,uart,mqtt,spi,http,ucg,u8g
ssl-enabled=true
debug-enabled=false
debug-enabled=true
fatfs-enabled=true
u8g-fonts=font_6x10,font_chikita
u8g-display-i2c=uc1611_dogm240_i2c
u8g-display-spi=pcf8812_96x65_hw_spi
ucg-display-spi=seps225_16x128x128_uvis_hw_spi, ucg_dev_seps225_16x128x128_univision, ucg_ext_seps225_16
lfs-size=0x20000
spiffs-base=0
spiffs-size=0x200000
66 changes: 66 additions & 0 deletions set-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash
#
# user_config.h has a number of defines the are replaced according to their
# corresponding env X_???? variable.
#
# Define Uncomment if param Set to param
# LUA_FLASH_STORE >0 Y
# SPIFFS_FIXED_LOCATION >0 Y
# SPIFFS_MAX_FILESYSTEM_SIZE >0 Y
# BUILD_FATFS "true"
# DEVELOP_VERSION "true"
# SSL_ENABLED "true"
#
set -e

# What is carried in the following variables is the sed replacement expression.
# It makes all #defines commented by default.
declare lfs="// #\\1"
declare spiffs_base="// #\\1"
declare spiffs_size="// #\\1"
declare fatfs="// #\\1"
declare debug="// #\\1"
declare ssl="// #\\1"

#if env var exists and is not "0"
if [ ! -z "${X_LUA_FLASH_STORE}" ] && [ "${X_LUA_FLASH_STORE}" != "0" ]; then
printf "Enabling LFS, size = %s\\n" "${X_LUA_FLASH_STORE}"
lfs="#\\1 ${X_LUA_FLASH_STORE}"
fi

if [ ! -z "${X_SPIFFS_FIXED_LOCATION}" ] && [ "${X_SPIFFS_FIXED_LOCATION}" != "0" ]; then
printf "SPIFFS location offset = %s\\n" "${X_SPIFFS_FIXED_LOCATION}"
spiffs_base="#\\1 ${X_SPIFFS_FIXED_LOCATION}"
fi

if [ ! -z "${X_SPIFFS_MAX_FILESYSTEM_SIZE}" ] && [ "${X_SPIFFS_MAX_FILESYSTEM_SIZE}" != "0" ]; then
printf "SPIFFS size = %s\\n" "${X_SPIFFS_MAX_FILESYSTEM_SIZE}"
spiffs_size="#\\1 ${X_SPIFFS_MAX_FILESYSTEM_SIZE}"
fi

if [ "${X_DEBUG_ENABLED}" == "true" ]; then
echo "Enabling debug mode"
debug="#\\1"
fi

if [ "${X_FATFS_ENABLED}" == "true" ]; then
echo "Enabling FatFS"
fatfs="#\\1"
fi

if [ "${X_SSL_ENABLED}" == "true" ]; then
echo "Enabling SSL"
ssl="#\\1"
fi

# There's no option for sed in-place editing that works on both Unix and macOS
# -> pipe to new file, then rename it
sed -e "s!^.*\\(define *LUA_FLASH_STORE\\).*!$lfs!" \
-e "s!^.*\\(define *SPIFFS_FIXED_LOCATION\\).*!$spiffs_base!" \
-e "s!^.*\\(define *SPIFFS_MAX_FILESYSTEM_SIZE\\).*!$spiffs_size!" \
-e "s!^.*\\(define *BUILD_FATFS\\).*!$fatfs!" \
-e "s!^.*\\(define *CLIENT_SSL_ENABLE\\).*!$ssl!" \
-e "s!^.*\\(define *DEVELOP_VERSION\\).*!$debug!" \
user_config.h > user_config.h.new;

mv user_config.h.new user_config.h;
11 changes: 0 additions & 11 deletions set-debug.sh

This file was deleted.

14 changes: 0 additions & 14 deletions set-fatfs.sh

This file was deleted.

14 changes: 0 additions & 14 deletions set-ssl.sh

This file was deleted.

0 comments on commit 1eb4c0e

Please sign in to comment.