Update LVGL, Fixes.

Replace libc with libg, fixes #98

Add telnet server

Increase factory partition to accomodate larger LVGL
This commit is contained in:
Amir Gonnen 2020-10-13 00:06:04 +03:00
parent 61103f4c3d
commit 59334c0731
4 changed files with 115 additions and 6 deletions

@ -1 +1 @@
Subproject commit 8e1b1864cdebf1f76768318de90d5b94cfd0157c
Subproject commit 3b4a908cb489cd32682c5b4ba6f79112ce3c44a1

View File

@ -300,7 +300,7 @@ LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
LIBSTDCXX_FILE_NAME = $(shell $(CXX) $(CXXFLAGS) -print-file-name=libstdc++.a)
# Debugging/Optimization
CFLAGS += -g
CFLAGS += -ggdb
ifeq ($(DEBUG), 1)
COPT = -O0
else
@ -315,7 +315,7 @@ MPY_CROSS_FLAGS += -march=xtensawin
# Enable SPIRAM support if CONFIG_ESP32_SPIRAM_SUPPORT=y in sdkconfig
ifeq ($(CONFIG_ESP32_SPIRAM_SUPPORT),y)
CFLAGS_COMMON += -mfix-esp32-psram-cache-issue
LIBC_LIBM = $(ESPCOMP)/newlib/lib/libc-psram-workaround.a $(ESPCOMP)/newlib/lib/libm-psram-workaround.a
LIBC_LIBM = $(ESPCOMP)/newlib/lib/libg-psram-workaround.a $(ESPCOMP)/newlib/lib/libm-psram-workaround.a
else
# Additional newlib symbols that can only be used with spiram disabled.
ifeq ($(ESPIDF_CURHASH),$(ESPIDF_SUPHASH_V4))
@ -325,7 +325,7 @@ LDFLAGS += -T esp32.rom.newlib-data.ld
else
LDFLAGS += -T esp32.rom.spiram_incompatible_fns.ld
endif
LIBC_LIBM = $(ESPCOMP)/newlib/lib/libc.a $(ESPCOMP)/newlib/lib/libm.a
LIBC_LIBM = $(ESPCOMP)/newlib/lib/libg.a $(ESPCOMP)/newlib/lib/libm.a
endif
################################################################################

View File

@ -0,0 +1,109 @@
import socket
import network
import uos
import errno
from uio import IOBase
last_client_socket = None
server_socket = None
# Provide necessary functions for dupterm and replace telnet control characters that come in.
class TelnetWrapper(IOBase):
def __init__(self, socket):
self.socket = socket
self.discard_count = 0
def readinto(self, b):
readbytes = 0
for i in range(len(b)):
try:
byte = 0
# discard telnet control characters and
# null bytes
while(byte == 0):
byte = self.socket.recv(1)[0]
if byte == 0xFF:
self.discard_count = 2
byte = 0
elif self.discard_count > 0:
self.discard_count -= 1
byte = 0
b[i] = byte
readbytes += 1
except (IndexError, OSError) as e:
if type(e) == IndexError or len(e.args) > 0 and e.args[0] == errno.EAGAIN:
if readbytes == 0:
return None
else:
return readbytes
else:
raise
return readbytes
def write(self, data):
# we need to write all the data but it's a non-blocking socket
# so loop until it's all written eating EAGAIN exceptions
while len(data) > 0:
try:
written_bytes = self.socket.write(data)
data = data[written_bytes:]
except OSError as e:
if len(e.args) > 0 and e.args[0] == errno.EAGAIN:
# can't write yet, try again
pass
else:
# something else...propagate the exception
raise
def close(self):
self.socket.close()
# Attach new clients to dupterm and
# send telnet control characters to disable line mode
# and stop local echoing
def accept_telnet_connect(telnet_server):
global last_client_socket
if last_client_socket:
# close any previous clients
uos.dupterm(None)
last_client_socket.close()
last_client_socket, remote_addr = telnet_server.accept()
print("Telnet connection from:", remote_addr)
last_client_socket.setblocking(False)
last_client_socket.setsockopt(socket.SOL_SOCKET, 20, uos.dupterm_notify)
last_client_socket.sendall(bytes([255, 252, 34])) # dont allow line mode
last_client_socket.sendall(bytes([255, 251, 1])) # turn off local echo
uos.dupterm(TelnetWrapper(last_client_socket))
def stop():
global server_socket, last_client_socket
uos.dupterm(None)
if server_socket:
server_socket.close()
if last_client_socket:
last_client_socket.close()
# start listening for telnet connections on port 23
def start(port=23):
stop()
global server_socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
ai = socket.getaddrinfo("0.0.0.0", port)
addr = ai[0][4]
server_socket.bind(addr)
server_socket.listen(1)
server_socket.setsockopt(socket.SOL_SOCKET, 20, accept_telnet_connect)
for i in (network.AP_IF, network.STA_IF):
wlan = network.WLAN(i)
if wlan.active():
print("Telnet server started on {}:{}".format(wlan.ifconfig()[0], port))

View File

@ -4,5 +4,5 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 0x220000,
vfs, data, fat, 0x230000, 0x1d0000,
factory, app, factory, 0x10000, 0x230000,
vfs, data, fat, 0x240000, 0x1c0000,

1 # Notes: the offset of the partition table itself is set in
4 # Name, Type, SubType, Offset, Size, Flags
5 nvs, data, nvs, 0x9000, 0x6000,
6 phy_init, data, phy, 0xf000, 0x1000,
7 factory, app, factory, 0x10000, 0x220000, factory, app, factory, 0x10000, 0x230000,
8 vfs, data, fat, 0x230000, 0x1d0000, vfs, data, fat, 0x240000, 0x1c0000,