Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,84 @@ jobs:
name: luac.cross_${{ matrix.lua_ver }}_${{ matrix.numbers }}
path: luac.cross

build_win_msys2:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- lua_ver: 51
numbers: float
- lua_ver: 51
numbers: integral
- lua_ver: 53
numbers: float
- lua_ver: 53
numbers: 64bit

env:
LUA: ${{ matrix.lua_ver }}
MSYSTEM: MINGW32
CHERE_INVOKING: 1

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Download ESP32 MSYS2 Toolchain
run: |
Invoke-WebRequest -Uri "https://media.githubusercontent.com/media/nodemcu/espressif-sdk-archive/refs/heads/master/esp32_win32_msys2_environment_and_toolchain-20181001.zip" -OutFile "esp32_toolchain.zip"

- name: Extract Toolchain
run: |
Expand-Archive -Path "esp32_toolchain.zip" -DestinationPath "D:\" -Force

- name: Setup Python venv
shell: D:\msys32\usr\bin\bash.exe --login {0}
run: |
python -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
pip install pyserial

- name: Build firmware
shell: D:\msys32\usr\bin\bash.exe --login {0}
run: |
. .venv/bin/activate

EXTRA_FLAGS=""
if [ "${{ matrix.numbers }}" = "integral" ]; then
EXTRA_FLAGS="-DLUA_NUMBER_INTEGRAL"
elif [ "${{ matrix.numbers }}" = "64bit" ]; then
EXTRA_FLAGS="-DLUA_NUMBER_64BITS"
fi
make EXTRA_CCFLAGS=$EXTRA_FLAGS

if [ "${{ matrix.numbers }}" = "integral" ]; then
mv -f luac.cross.int.exe luac.cross.exe
fi

- name: Copy required DLLs
shell: D:\msys32\usr\bin\bash.exe --login {0}
run: |
ldd luac.cross.exe | awk '{print $3}' | grep -vi "/c/windows" | xargs -I{} cp -v {} . || true
ls *.dll

- name: Check build items
shell: D:\msys32\usr\bin\bash.exe --login {0}
run: |
ls -ll bin/0x00000.bin bin/0x10000.bin luac.cross.exe

- name: Upload luac.cross
if: ${{ success() }}
uses: actions/upload-artifact@v4
with:
name: luac.cross_${{ matrix.lua_ver }}_${{ matrix.numbers }}_win
path: |
luac.cross.exe
*.dll

# The files in the 'msvc' folder would need to be updated to be compatible with VS 2022.
# Sample job (that failed): https://github.com/nodemcu/nodemcu-firmware/actions/runs/17306868602/job/49131917376#step:3:153
# => disable the Windows jobs for now
Expand Down Expand Up @@ -225,6 +303,54 @@ jobs:
# (if grep " ==> " log ; then exit 1 ; fi)
# shell: bash

NTest_win_msys2:

strategy:
fail-fast: false
matrix:
include:
- lua_ver: 51
numbers: 'float'
- lua_ver: 53
numbers: 'float'
- lua_ver: 51
numbers: 'integral'
- lua_ver: 53
numbers: '64bit'

needs: build_win_msys2
runs-on: windows-latest
env:
MSYSTEM: MINGW32
CHERE_INVOKING: 1

steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: false
- name: Download luac.cross
uses: actions/download-artifact@v4
with:
name: luac.cross_${{ matrix.lua_ver }}_${{ matrix.numbers }}_win
path: ./
- name: NTest selfcheck
run: |
cd tests/NTest
../../luac.cross.exe -e ../NTest/NTest_NTest.lua | tee log
if ((gc log | Select-String "failed: 0") -eq $null) {
Throw "Errors were found during tests";
}
shell: pwsh

- name: NTest hosttests
run: |
cd tests
cp NTest/NTest.lua .
../luac.cross.exe -e NTest_lua.lua | tee log
if ((gc log | Select-String " ==> ") -ne $null) {
Throw "Errors were found during tests";
}

luacheck:

Expand Down
49 changes: 24 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,7 @@ endif
# then please raise a GitHub issue on this work.
#

ifndef $(OS)
# Assume Windows if MAKE_HOST contains "indows" and Linux otherwise
ifneq (,$(findstring indows,$(MAKE_HOST)))
OS := windows
else
OS := linux
endif
endif

ifneq (,$(findstring indows,$(OS)))
ifeq ($(OS),Windows_NT)
#------------ BEGIN UNTESTED ------------ We are not under Linux, e.g.under windows.
ifeq ($(XTENSA_CORE),lx106)
# It is xcc
Expand All @@ -109,38 +100,43 @@ ifneq (,$(findstring indows,$(OS)))
else
# It is gcc, may be cygwin
# Can we use -fdata-sections?
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections -fpack-struct=4
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections -fpack-struct=4 -Wno-error=implicit-function-declaration -Dstricmp=strcasecmp -DWIN32
AR = xtensa-lx106-elf-ar
CC = xtensa-lx106-elf-gcc
CXX = xtensa-lx106-elf-g++
NM = xtensa-lx106-elf-nm
CPP = xtensa-lx106-elf-cpp
OBJCOPY = xtensa-lx106-elf-objcopy
TOOLCHAIN_VERSION = 2020r3
GCCTOOLCHAIN = xtensa-lx106-elf-gcc8_4_0-esp-$(TOOLCHAIN_VERSION)-win32
TOOLCHAIN_ROOT = $(TOP_DIR)/tools/toolchains/esp8266-$(GCCTOOLCHAIN)
ESPRESSIF_URL = https://media.githubusercontent.com/media/nodemcu/espressif-sdk-archive/refs/heads/master
TOOLCHAIN_EXT = zip
TOOLCHAIN_URL = $(ESPRESSIF_URL)/$(GCCTOOLCHAIN).$(TOOLCHAIN_EXT)
WGET = wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused
export PATH := $(PATH):$(TOOLCHAIN_ROOT)/bin
endif
FIRMWAREDIR = ..\\bin\\
ifndef COMPORT
ESPPORT = com1
else
ESPPORT = $(COMPORT)
endif
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
# ->AMD64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
# ->IA32
endif

#---------------- END UNTESTED ---------------- We are under windows.
else
# We are under other system, may be Linux. Assume using gcc.

UNAME_S := $(shell uname -s)
UNAME_P := $(shell uname -p)
ifeq ($(OS),linux)
ifeq ($(UNAME_S),Linux)
ifndef TOOLCHAIN_ROOT
TOOLCHAIN_VERSION = 20190731.0
GCCTOOLCHAIN = linux-x86_64-$(TOOLCHAIN_VERSION)
TOOLCHAIN_ROOT = $(TOP_DIR)/tools/toolchains/esp8266-$(GCCTOOLCHAIN)
GITHUB_TOOLCHAIN = https://github.com/jmattsson/esp-toolchains
TOOLCHAIN_EXT = tar.xz
TOOLCHAIN_URL = $(GITHUB_TOOLCHAIN)/releases/download/$(GCCTOOLCHAIN)/toolchain-esp8266-$(GCCTOOLCHAIN).$(TOOLCHAIN_EXT)
export PATH:=$(PATH):$(TOOLCHAIN_ROOT)/bin
endif
endif
Expand Down Expand Up @@ -286,21 +282,24 @@ endif
sdk_extracted: $(TOP_DIR)/sdk/.extracted-$(SDK_VER)
sdk_pruned: sdk_extracted toolchain $(TOP_DIR)/sdk/.pruned-$(SDK_VER)

ifdef GITHUB_TOOLCHAIN
TOOLCHAIN_ROOT := $(TOP_DIR)/tools/toolchains/esp8266-linux-x86_64-$(TOOLCHAIN_VERSION)

ifdef TOOLCHAIN_URL
toolchain: $(TOOLCHAIN_ROOT)/bin $(ESPTOOL)

$(TOOLCHAIN_ROOT)/bin: $(TOP_DIR)/cache/toolchain-esp8266-$(GCCTOOLCHAIN).tar.xz
$(TOOLCHAIN_ROOT)/bin: $(TOP_DIR)/cache/toolchain-esp8266-$(GCCTOOLCHAIN).$(TOOLCHAIN_EXT)
mkdir -p $(TOP_DIR)/tools/toolchains/
$(summary) EXTRACT $(patsubst $(TOP_DIR)/%,%,$<)
tar -xJf $< -C $(TOP_DIR)/tools/toolchains/
ifeq ($(TOOLCHAIN_EXT),tar.xz)
tar -xJf $< -C $(TOP_DIR)/tools/toolchains/
else ifeq ($(TOOLCHAIN_EXT),zip)
unzip -q $< -d $(TOP_DIR)/tools/toolchains/
mv $(TOP_DIR)/tools/toolchains/xtensa-lx106-elf $(TOOLCHAIN_ROOT)
endif
touch $@

$(TOP_DIR)/cache/toolchain-esp8266-$(GCCTOOLCHAIN).tar.xz:
$(TOP_DIR)/cache/toolchain-esp8266-$(GCCTOOLCHAIN).$(TOOLCHAIN_EXT):
mkdir -p $(TOP_DIR)/cache
$(summary) WGET $(patsubst $(TOP_DIR)/%,%,$@)
$(WGET) $(GITHUB_TOOLCHAIN)/releases/download/$(GCCTOOLCHAIN)/toolchain-esp8266-$(GCCTOOLCHAIN).tar.xz -O $@ \
$(WGET) $(TOOLCHAIN_URL) -O $@ \
|| { rm -f "$@"; exit 1; }
else
toolchain: $(ESPTOOL)
Expand Down
2 changes: 2 additions & 0 deletions app/include/arch/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@

//#define LWIP_PROVIDE_ERRNO

#ifndef BYTE_ORDER
#if (1)
#define BYTE_ORDER LITTLE_ENDIAN
#else
#define BYTE_ORDER BIG_ENDIAN
#endif
#endif


typedef uint8_t u8_t;
Expand Down
3 changes: 3 additions & 0 deletions app/include/sys/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,13 @@ typedef uint32 socklen_t;
#define O_NDELAY 1 /* same as O_NONBLOCK, for compatibility */
#endif

#ifndef _SYS__TIMEVAL_H_
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
#endif

/* Flags for struct netconn.flags (u8_t) */
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
this temporarily stores whether to wake up the original application task
Expand Down
80 changes: 80 additions & 0 deletions app/include/xtensa/config/specreg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Xtensa Special Register symbolic names
*/

/* $Id: //depot/rel/Boreal/Xtensa/SWConfig/hal/specreg.h.tpp#2 $ */

/* Copyright (c) 1998-2002 Tensilica Inc.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */

#ifndef XTENSA_SPECREG_H
#define XTENSA_SPECREG_H

/* Include these special register bitfield definitions, for historical reasons: */
#include <xtensa/corebits.h>


/* Special registers: */
#define SAR 3
#define LITBASE 5
#define IBREAKENABLE 96
#define DDR 104
#define IBREAKA_0 128
#define DBREAKA_0 144
#define DBREAKC_0 160
#define EPC_1 177
#define EPC_2 178
#define EPC_3 179
#define DEPC 192
#define EPS_2 194
#define EPS_3 195
#define EXCSAVE_1 209
#define EXCSAVE_2 210
#define EXCSAVE_3 211
#define INTERRUPT 226
#define INTENABLE 228
#define PS 230
#define VECBASE 231
#define EXCCAUSE 232
#define DEBUGCAUSE 233
#define CCOUNT 234
#define PRID 235
#define ICOUNT 236
#define ICOUNTLEVEL 237
#define EXCVADDR 238
#define CCOMPARE_0 240

/* Special cases (bases of special register series): */
#define IBREAKA 128
#define DBREAKA 144
#define DBREAKC 160
#define EPC 176
#define EPS 192
#define EXCSAVE 208
#define CCOMPARE 240

/* Special names for read-only and write-only interrupt registers: */
#define INTREAD 226
#define INTSET 226
#define INTCLEAR 227

#endif /* XTENSA_SPECREG_H */

Loading
Loading