Commit 17df207a authored by Johny Mattsson's avatar Johny Mattsson
Browse files

Port Terry's Lua 5.1 + 5.3 work from the esp8266 branch.

Changes have been kept to a minimum, but a serious chunk of work was
needed to move from 8266isms to IDFisms.

Some things got refactored into components/lua/common, in particular
the LFS location awareness.

As part of this work I also evicted our partition table manipulation
code, as with the current IDF it kept breaking checksums and rendering
things unbootable, which is the opposite of helpful (which was the
original intent behind it).

The uart module got relocated from base_nodemcu to the modules component
properly, after I worked out how to force its inclusion using Kconfig alone.
parent f123d462
......@@ -11,7 +11,7 @@
#define BUILD_DATE "unspecified"
#endif
#define SDK_VERSION "IDF"
#define SDK_VERSION IDF_VER
#endif /* __USER_VERSION_H__ */
......@@ -682,3 +682,10 @@ int platform_i2c_recv_byte( unsigned id, int ack ){
#endif
int platform_i2c_exists( unsigned id ) { return id < I2C_NUM_MAX; }
void platform_print_deprecation_note( const char *msg, const char *time_frame)
{
printf( "Warning, deprecated API! %s. It will be removed %s. See documentation for details.\n", msg, time_frame );
}
......@@ -56,7 +56,6 @@ The small 4KB sectors allow for greater flexibility in applications th
static bool get_spiffs_partition (spiffs_config *cfg)
{
platform_partition_t info;
uint32_t next_free_offs = 0;
uint8_t i = 0;
while (platform_partition_info (i, &info))
{
......@@ -68,34 +67,9 @@ static bool get_spiffs_partition (spiffs_config *cfg)
return true;
}
else
{
++i;
if ((info.offs + info.size) > next_free_offs)
next_free_offs = info.offs + info.size;
}
}
// Attempt to append a spiffs partition
NODE_ERR("No filesystem partition found, attempting to create it...\n");
info.type = PLATFORM_PARTITION_TYPE_NODEMCU;
info.subtype = PLATFORM_PARTITION_SUBTYPE_NODEMCU_SPIFFS;
strcpy ((char *)info.label, "spiffs");
info.offs = cfg->phys_addr = next_free_offs;
info.size = cfg->phys_size = flash_safe_get_size_byte () - info.offs;
if (info.size <= 0)
{
NODE_ERR("No space available at end of flash, can't add fs partition!\n");
return false;
}
if (platform_partition_add (&info))
{
NODE_ERR("Ok.\n");
return true;
}
else
{
NODE_ERR("Error rewriting partition table!\n");
return false;
}
}
......
......@@ -113,7 +113,7 @@ jmp_buf unwindAddr;
#ifdef __XTENSA__
#define RAM_COPY_BYTE_ARRAY(c,s,sl) uint8_t *c = alloca(sl); memcpy(c,s,(sl))
#else
#define RAM_COPY_BYTE_ARRAY(c,s,sl) uint8_t *c = s;
#define RAM_COPY_BYTE_ARRAY(c,s,sl) uint8_t *c = s; (void)sl
#endif
#define FREE(v) if (v) uz_free(v)
......@@ -200,7 +200,8 @@ static void genCodeRecs (const codeRecord *rec, uint16_t len,
if (*c == 0xFF)
b++, c++;
m += (*c & 0x80) ? 2 << (*c & 0x1F) : *c;
*p++ = (codeRecord) {i, b, last + 1, (last = m)};
*p++ = (codeRecord) {i, b, last + 1, m};
last = m;
}
}
......
......@@ -21,13 +21,6 @@ CONFIG_MQTT_TRANSPORT_SSL=n
CONFIG_MQTT_TRANSPORT_WEBSOCKET=n
CONFIG_MQTT_USE_CUSTOM_CONFIG=n
# Allow writing to dangerous regions to avoid boot loops when creating filesystem
# Symptom:
# Mounting flash filesystem...
# No filesystem partition found, attempting to create it...
# abort() was called at PC 0x400ecddd on core 0
CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED=y
# Enable address reuse for sockets in TIME_WAIT
# see https://github.com/nodemcu/nodemcu-firmware/pull/1838
CONFIG_LWIP_SO_REUSE=y
......
......@@ -35,12 +35,27 @@ fi
echo "LFS segment address ${LFS_ADDR}, length ${LFS_SIZE}"
${LUAC_CROSS} -a ${LFS_ADDR} -m ${LFS_SIZE} -o ${LUAC_OUTPUT} ${LUA_APP_SRC}
if ${LUAC_CROSS} -v | grep -q 'Lua 5.1'
then
echo "Generating Lua 5.1 LFS image..."
${LUAC_CROSS} -a ${LFS_ADDR} -m ${LFS_SIZE} -o ${LUAC_OUTPUT} ${LUA_APP_SRC}
else
set -e
echo "Generating intermediate Lua 5.3 LFS image..."
${LUAC_CROSS} -f -m ${LFS_SIZE} -o ${LUAC_OUTPUT}.tmp ${LUA_APP_SRC}
echo "Converting to absolute LFS image..."
${LUAC_CROSS} -F ${LUAC_OUTPUT}.tmp -a ${LFS_ADDR} -o ${LUAC_OUTPUT}
rm ${LUAC_OUTPUT}.tmp
fi
if [ $? != 0 ]; then
echo "Error: luac.cross failed"
exit 1
else
echo "Generated $(ls -l ${LUAC_OUTPUT} | cut -f5 -d' ') bytes of LFS data"
fi
# cmake depencies don't seem to pick up the change to luac.out?
rm -f build/lua.flash.store.reserved
make
echo "Re-linking nodemcu binary by invoking IDF build..."
make >/dev/null
echo "Done."
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment