Skip to content

Commit

Permalink
use luac.cross directly and check size
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-klein committed Sep 1, 2020
1 parent 729b084 commit 9693e64
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions firmware/nodemcu-firmware-overlay/app/include/user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
// a maximum 256Kb.

#define LUA_FLASH_STORE 0x10000

//#define LUA_FLASH_STORE 0x40000 max LFS size

// By default Lua executes the file init.lua at start up. The following
// define allows you to replace this with an alternative startup. Warning:
Expand Down Expand Up @@ -118,10 +118,10 @@
// management, using internal timer callbacks. Whilst many Lua developers
// prefer to implement equivalent features in Lua, others will prefer the
// Wifi module to do this for them. Uncomment the following to enable
// this functionality. See the relevant WiFi module documentation for
// this functionality. See the relevant WiFi module documentation for
// further details, as the scope of these changes is not obvious.

// Enable the wifi.startsmart() and wifi.stopsmart()
// Enable the wifi.startsmart() and wifi.stopsmart()
//#define WIFI_SMART_ENABLE

// Enable wifi.sta.config() event callbacks
Expand Down
19 changes: 12 additions & 7 deletions scripts/build-firmware
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function usage() {
echo "usage: $0 <version>"
echo
echo ' version should be formatted <major>-<minor>-<patch>'
echo
echo
echo 'Execute from the root dir of the repo. Upon successful completion the release will be created in firmware/releases/<version>'
echo " ex: '$0 2-3-0'"
exit 1
Expand All @@ -20,10 +20,12 @@ if ! [[ "${VERSION}" =~ ^[0-9]+-[0-9]+-[0-9]+ ]] ; then
usage
fi

set -e
FIRMWARE_PATH="${PWD}/../nodemcu-firmware"
FIRMWARE_OVERLAY_PATH="firmware/nodemcu-firmware-overlay"
BUILD_PATH="firmware/builds/${VERSION}"
IMAGE_NAME="konnected-firmware-${VERSION}"
LFS_BASE="${PWD}/src/lfs"

# Copy firmware configuration from this repository to the nodemcu-firmware repo
cp "${FIRMWARE_OVERLAY_PATH}"/app/include/* "${FIRMWARE_PATH}/app/include/"
Expand All @@ -36,20 +38,23 @@ docker run -e "INTEGER_ONLY=1" \
--rm -ti -v "${FIRMWARE_PATH}:/opt/nodemcu-firmware" marcelstoer/nodemcu-build build

# Build LFS image with application files
docker run -e "IMAGE_NAME=lfs" \
--rm -ti -v "${FIRMWARE_PATH}:/opt/nodemcu-firmware" \
-v "${PWD}/src/lfs:/opt/lua" marcelstoer/nodemcu-build lfs-image
LUA_FILES=$(find ${LFS_BASE} -iname "*.lua" | sed "s|${LFS_BASE}|/lfs|g")

mv src/lfs/LFS_integer_lfs.img src/lfs/lfs.img
rm -f src/lfs/LFS_float_lfs.img
echo Adding files to LFS:
echo ${LUA_FILES}
docker run --rm -ti \
-v ${FIRMWARE_PATH}:/tools \
-v ${LFS_BASE}:/lfs \
marcelstoer/nodemcu-build /tools/luac.cross.int -m 0x10000 -f -o "/lfs/lfs.img" ${LUA_FILES}
echo

# Build SPIFFS image
docker run \
--rm -ti -v "${FIRMWARE_PATH}:/opt/nodemcu-firmware" \
-v "${PWD}/scripts:/scripts" \
-v "${PWD}/src:/opt/lua" marcelstoer/nodemcu-build bash /scripts/build-spiffs

# Create or clear the output directory and transfer files
# Create or clear the output directory and transfer files
mkdir -p "${BUILD_PATH}"
rm -rf "${BUILD_PATH}/*"
cp "${FIRMWARE_PATH}/bin/nodemcu_integer_${IMAGE_NAME}.bin" "${BUILD_PATH}/${IMAGE_NAME}.bin"
Expand Down
2 changes: 1 addition & 1 deletion scripts/cross-compile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

for fname in /opt/nodemcu-firmware/local/fs/*.lua ; do
/opt/nodemcu-firmware/luac.cross -o /opt/nodemcu-firmware/local/fs/$(basename "$fname" .lua).{lc,lua}
/opt/nodemcu-firmware/luac.cross.int -o /opt/nodemcu-firmware/local/fs/$(basename "$fname" .lua).{lc,lua}
done

0 comments on commit 9693e64

Please sign in to comment.