From 35a98377f52caf5ac37c2e932b9f2d4c9196c195 Mon Sep 17 00:00:00 2001
From: Daniel Friesel <derf@finalrewind.org>
Date: Sat, 25 Dec 2021 18:09:33 +0100
Subject: [PATCH] Remove esp8266 support in favor of ESP8266 RTOS SDK

---
 .gitlab-ci.yml                        |  10 -
 include/arch/esp8266/driver/counter.h |  46 -----
 include/arch/esp8266/driver/gpio.h    |  35 ----
 include/arch/esp8266/driver/stdin.h   |  29 ---
 include/arch/esp8266/driver/stdout.h  |  61 ------
 include/arch/esp8266/driver/uptime.h  |  34 ----
 include/arch/esp8266/user_config.h    |  10 -
 script/mkconfig                       |   2 +-
 src/arch/esp8266/Kconfig              |  14 --
 src/arch/esp8266/Makefile.inc         | 127 -------------
 src/arch/esp8266/arch.cc              |  74 --------
 src/arch/esp8266/driver/counter.cc    |   8 -
 src/arch/esp8266/driver/gpio.cc       | 199 -------------------
 src/arch/esp8266/driver/stdin.cc      |  82 --------
 src/arch/esp8266/driver/stdout.cc     | 264 --------------------------
 src/arch/esp8266/driver/uptime.cc     |   8 -
 src/arch/esp8266/prompt               |   1 -
 src/driver/Kconfig                    |   2 -
 src/driver/ccs811.cc                  |   4 -
 src/driver/soft_i2c.cc                |   4 +-
 tests/build-esp8266                   |   9 -
 21 files changed, 2 insertions(+), 1021 deletions(-)
 delete mode 100644 include/arch/esp8266/driver/counter.h
 delete mode 100644 include/arch/esp8266/driver/gpio.h
 delete mode 100644 include/arch/esp8266/driver/stdin.h
 delete mode 100644 include/arch/esp8266/driver/stdout.h
 delete mode 100644 include/arch/esp8266/driver/uptime.h
 delete mode 100644 include/arch/esp8266/user_config.h
 delete mode 100644 src/arch/esp8266/Kconfig
 delete mode 100644 src/arch/esp8266/Makefile.inc
 delete mode 100644 src/arch/esp8266/arch.cc
 delete mode 100644 src/arch/esp8266/driver/counter.cc
 delete mode 100644 src/arch/esp8266/driver/gpio.cc
 delete mode 100644 src/arch/esp8266/driver/stdin.cc
 delete mode 100644 src/arch/esp8266/driver/stdout.cc
 delete mode 100644 src/arch/esp8266/driver/uptime.cc
 delete mode 100644 src/arch/esp8266/prompt
 delete mode 100755 tests/build-esp8266

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3c0c96f..d963d4d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,16 +4,6 @@ stages:
   - build
   - test
 
-build_esp8266:
-  stage: build
-  before_script:
-  - export TOOLCHAIN_BASE=/opt/xtensa-lx106-elf/bin
-  - export SDK_BASE=/opt/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr
-  script:
-  - curl -s https://ess.cs.uos.de/static/.gitlab-ci/xtensa-lx106-elf.tar.xz | tar -C /opt -xJf -
-  - mkdir -p build
-  - sh -x tests/build-esp8266
-
 build_posix:
   stage: build
   script:
diff --git a/include/arch/esp8266/driver/counter.h b/include/arch/esp8266/driver/counter.h
deleted file mode 100644
index 8c2d22f..0000000
--- a/include/arch/esp8266/driver/counter.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2020 Daniel Friesel
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-#ifndef COUNTER_H
-#define COUNTER_H
-
-extern "C" {
-#include "osapi.h"
-#include "user_interface.h"
-}
-#include "c_types.h"
-
-typedef uint32_t counter_value_t;
-typedef uint32_t counter_overflow_t;
-
-class Counter {
-	private:
-		Counter(const Counter &copy);
-		uint32_t start_cycles;
-
-	public:
-		uint32_t value;
-		uint32_t overflow;
-
-		Counter() : start_cycles(0), value(0), overflow(0) {}
-
-		inline void start() {
-			asm volatile ("esync; rsr %0,ccount":"=a" (start_cycles));
-		}
-
-		inline void stop() {
-			uint32_t stop_cycles;
-			asm volatile ("esync; rsr %0,ccount":"=a" (stop_cycles));
-			if (stop_cycles > start_cycles) {
-				value = stop_cycles - start_cycles;
-			} else {
-				overflow = 1;
-			}
-		}
-};
-
-extern Counter counter;
-
-#endif
diff --git a/include/arch/esp8266/driver/gpio.h b/include/arch/esp8266/driver/gpio.h
deleted file mode 100644
index 29e7950..0000000
--- a/include/arch/esp8266/driver/gpio.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2020 Daniel Friesel
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-#ifndef GPIO_H
-#define GPIO_H
-
-class GPIO {
-	private:
-		GPIO(const GPIO &copy);
-
-	public:
-		GPIO () {}
-
-		enum Pin : unsigned char {
-			d3 = 0, tx, d4, rx, d2, d1,
-			d6 = 12, d7, d5, d8,
-			d0 = 16
-		};
-
-		void setup();
-		void led_on(unsigned char id = 0);
-		void led_off(unsigned char id = 0);
-		void led_toggle(unsigned char id = 0);
-		void input(unsigned char const pin);
-		void input(unsigned char const pin, bool pullup);
-		void output(unsigned char const pin);
-		unsigned char read(unsigned char const pin);
-		void write(unsigned char const pin, unsigned char value);
-};
-
-extern GPIO gpio;
-
-#endif
diff --git a/include/arch/esp8266/driver/stdin.h b/include/arch/esp8266/driver/stdin.h
deleted file mode 100644
index 1085111..0000000
--- a/include/arch/esp8266/driver/stdin.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2020 Daniel Friesel
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-#ifndef STANDARDINPUT_H
-#define STANDARDINPUT_H
-
-class StandardInput {
-	private:
-		StandardInput(const StandardInput &copy);
-		char buffer[8];
-		unsigned char write_pos, read_pos;
-
-	public:
-		StandardInput() : write_pos(0), read_pos(0) {}
-		void setup();
-		bool hasKey();
-		char getKey();
-
-		inline void addKey(char key) {
-			buffer[write_pos++] = key;
-			write_pos %= 8;
-		}
-};
-
-extern StandardInput kin;
-
-#endif
diff --git a/include/arch/esp8266/driver/stdout.h b/include/arch/esp8266/driver/stdout.h
deleted file mode 100644
index 2484cee..0000000
--- a/include/arch/esp8266/driver/stdout.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2020 Daniel Friesel
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-#ifndef STANDARDOUTPUT_H
-#define STANDARDOUTPUT_H
-
-class StandardOutput {
-	private:
-		StandardOutput(const StandardOutput &copy);
-		char digit_buffer[sizeof(long long) * 8];
-		unsigned char base;
-
-	public:
-		StandardOutput() : base(10) {};
-		void setup();
-
-		void put(char c);
-		void write(const char *s);
-		void flush() {}
-		void printf_uint8(unsigned char num);
-		void printf_float(float num);
-
-		StandardOutput & operator<<(char c);
-		StandardOutput & operator<<(unsigned char c);
-		StandardOutput & operator<<(unsigned short number);
-		StandardOutput & operator<<(short number);
-		StandardOutput & operator<<(unsigned int number);
-		StandardOutput & operator<<(int number);
-		StandardOutput & operator<<(unsigned long number);
-		StandardOutput & operator<<(long number);
-		StandardOutput & operator<<(unsigned long long number);
-		StandardOutput & operator<<(long long number);
-		StandardOutput & operator<<(float number);
-		StandardOutput & operator<<(double number);
-		StandardOutput & operator<<(void *pointer);
-		StandardOutput & operator<<(const char *text);
-		StandardOutput & operator<<(StandardOutput & (*fun) (StandardOutput &));
-
-		void setBase(unsigned char b);
-};
-
-
-StandardOutput & endl(StandardOutput & os);
-
-StandardOutput & bin(StandardOutput & os);
-
-StandardOutput & oct(StandardOutput & os);
-
-StandardOutput & dec(StandardOutput & os);
-
-StandardOutput & hex(StandardOutput & os);
-
-StandardOutput & flush(StandardOutput & os);
-
-StandardOutput & term(StandardOutput & os);
-
-extern StandardOutput kout;
-
-#endif
diff --git a/include/arch/esp8266/driver/uptime.h b/include/arch/esp8266/driver/uptime.h
deleted file mode 100644
index f3e2f23..0000000
--- a/include/arch/esp8266/driver/uptime.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2020 Daniel Friesel
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-#ifndef UPTIME_H
-#define UPTIME_H
-
-extern "C" {
-#include "osapi.h"
-#include "user_interface.h"
-}
-#include "c_types.h"
-
-class Uptime {
-	private:
-		Uptime(const Uptime &copy);
-
-	public:
-		Uptime () {}
-		inline uint32_t get_us() { return system_get_time(); }
-		inline uint32_t get_s() { return system_get_time() / 1000000; }
-
-		inline uint32_t get_cycles()
-		{
-			uint32_t ccount;
-			asm volatile ("esync; rsr %0,ccount":"=a" (ccount));
-			return ccount;
-		}
-};
-
-extern Uptime uptime;
-
-#endif
diff --git a/include/arch/esp8266/user_config.h b/include/arch/esp8266/user_config.h
deleted file mode 100644
index bbd7001..0000000
--- a/include/arch/esp8266/user_config.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * Copyright 2020 Daniel Friesel
- *
- * SPDX-License-Identifier: CC0-1.0
- */
-/*
- * required by ESP8266 SDK's osapi.h
- *
- * Intentionally left blank.
- */
diff --git a/script/mkconfig b/script/mkconfig
index 63dc302..7be8703 100755
--- a/script/mkconfig
+++ b/script/mkconfig
@@ -19,7 +19,7 @@ default n
 config ostream
 bool "C++ ostream support in stdout"
 default n
-depends on arch_esp8266 || arch_msp430fr5969lp || arch_msp430fr5994lp || arch_posix
+depends on arch_msp430fr5969lp || arch_msp430fr5994lp || arch_posix
 
 config aspectc
 bool "Build with AspectC++"
diff --git a/src/arch/esp8266/Kconfig b/src/arch/esp8266/Kconfig
deleted file mode 100644
index 5c2137c..0000000
--- a/src/arch/esp8266/Kconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2020 Daniel Friesel
-#
-# SPDX-License-Identifier: CC0-1.0
-config arch_esp8266_driver_counter
-bool "Cycle Counter"
-select meta_driver_counter
-
-config arch_esp8266_driver_stdin
-bool "UART Input"
-select meta_driver_stdin
-
-config arch_esp8266_driver_uptime
-bool "Uptime Counter"
-select meta_driver_uptime
diff --git a/src/arch/esp8266/Makefile.inc b/src/arch/esp8266/Makefile.inc
deleted file mode 100644
index 51106b1..0000000
--- a/src/arch/esp8266/Makefile.inc
+++ /dev/null
@@ -1,127 +0,0 @@
-# vim:ft=make
-#
-# Copyright 2020 Daniel Friesel
-#
-# SPDX-License-Identifier: BSD-2-Clause
-
-TOOLCHAIN_BASE ?= /home/derf/var/projects/esp8266/toolchain/xtensa-lx106-elf/bin
-SDK_BASE ?= /home/derf/var/projects/esp8266/toolchain/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr
-ESPTOOL ?= esptool
-SERIAL_PORT ?= /dev/ttyUSB0
-
-CC = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-gcc
-CXX = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-g++
-AR = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-ar
-LD = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-gcc
-OBJCOPY = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-objcopy
-OBJDUMP = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-objdump
-SIZE = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-size
-
-ifdef CONFIG_aspectc
-	CXX = ag++ -r build/repo.acp -v 0 --c_compiler ${TOOLCHAIN_BASE}/xtensa-lx106-elf-g++ -p . --Xcompiler
-endif
-
-INCLUDES += -I${SDK_BASE}/include
-COMMON_FLAGS += -nostdlib -mlongcalls -flto -D__ets__ -DICACHE_FLASH -DMULTIPASS_ARCH_esp8266
-CXXFLAGS = -std=c++11 -fno-rtti -fno-threadsafe-statics
-LDFLAGS += -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
-
-CXX_TARGETS += src/arch/esp8266/arch.cc src/arch/esp8266/driver/gpio.cc
-CXX_TARGETS += src/arch/esp8266/driver/stdout.cc
-
-OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o}
-
-ifeq (${esp8266_led2}, 1)
-	COMMON_FLAGS += -DLED_ON_GPIO16
-endif
-
-# Commandline
-
-ifneq ($(findstring counter,${arch_drivers}), )
-	CONFIG_arch_esp8266_driver_counter = y
-endif
-
-ifneq ($(findstring stdin,${arch_drivers}), )
-	CONFIG_arch_esp8266_driver_stdin = y
-endif
-
-ifeq (${timer_s}, 1)
-	CONFIG_arch_esp8266_driver_uptime = y
-endif
-
-# Kconfig
-
-ifdef CONFIG_arch_esp8266_driver_counter
-	CXX_TARGETS += src/arch/esp8266/driver/counter.cc
-endif
-
-ifdef CONFIG_arch_esp8266_driver_stdin
-	CXX_TARGETS += src/arch/esp8266/driver/stdin.cc
-endif
-
-ifdef CONFIG_arch_esp8266_driver_uptime
-	COMMON_FLAGS += -DTIMER_S
-	CXX_TARGETS += src/arch/esp8266/driver/uptime.cc
-endif
-
-%.o : %.cc | include/config.h
-	${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
-	${QUIET}${OBJCOPY} --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal $@
-
-%.o : %.c | include/config.h
-	${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c}
-	${QUIET}${OBJCOPY} --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal $@
-
-build/system.elf: build/system.ar
-	${QUIET}${CC} -L${SDK_BASE}/lib -T${SDK_BASE}/lib/eagle.app.v6-derf.ld ${LDFLAGS} \
-		-Wl,--gc-sections \
-		-Wl,--start-group -lc -lgcc -lhal -lpp -lphy -lnet80211 -llwip -lwpa \
-		-lmain $< -Wl,--end-group -o $@
-	${QUIET}${SIZE} build/system.elf | tail -n1 | awk '{ print "  ROM: " ($$1+$$2) " (" int(($$1+$$2)*100/4194304) "%)     RAM: " ($$2 + $$3) " (" int(($$2+$$3)*100/81920) "%)" }'
-
-build/system.ar: ${OBJECTS}
-	${QUIET}mkdir -p build
-	${QUIET}${AR} cru $@ ${OBJECTS}
-
-build/0x00000.bin: build/system.elf
-	${ESPTOOL} --chip esp8266 elf2image -o build/ $<
-
-build/0x40000.bin: build/0x00000.bin
-	# also created by commandline for 0x00000.bin
-
-program: build/0x00000.bin build/0x40000.bin
-	${ESPTOOL} -p ${SERIAL_PORT} write_flash 0x00000 build/0x00000.bin 0x40000 build/0x40000.bin #-fm dout
-
-arch_clean:
-	${QUIET}rm -f ${OBJECTS} build/system.ar
-
-monitor:
-	screen ${SERIAL_PORT} 115200
-
-cat:
-	${QUIET}script/cat.py ${SERIAL_PORT} 115200 80000000 0
-
-arch_help:
-	@echo "esp8266 coding advice:"
-	@echo "    The ESP8266 SDK does not give full hardware control."
-	@echo "    Applications must release control every hundred or so milliseconds."
-	@echo "    It is strongly recommended to only use loop=1"
-	@echo
-	@echo "esp8266 specific flags:"
-	@echo "    esp8266_led2 = 0 (enable if you are using a NodeMCU dev board with two LEDs)"
-	@echo "    TOOLCHAIN_BASE = /home/derf/var/projects/esp8266/toolchain/xtensa-lx106-elf/bin"
-	@echo "    SDK_BASE = /home/derf/var/projects/esp8266/toolchain/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr"
-	@echo "    ESPTOOL = esptool"
-	@echo "    SERIAL_PORT = /dev/ttyUSB0"
-
-arch_info:
-	@echo "Counter Overflow: 4294967296/0"
-	@echo "Monitor: ${SERIAL_PORT} 115200"
-
-attributes: build/system.elf
-	${QUIET}script/size.py ${SIZE} text,irom0.text data,bss
-
-nfpvalues: build/system.elf
-	${QUIET}script/nfpvalues.py ${SIZE} text,irom0.text data,bss
-
-.PHONY: arch_clean arch_help arch_info attributes cat monitor program
diff --git a/src/arch/esp8266/arch.cc b/src/arch/esp8266/arch.cc
deleted file mode 100644
index 656a700..0000000
--- a/src/arch/esp8266/arch.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2020 Daniel Friesel
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-#include "arch.h"
-
-extern "C" {
-#include "ets_sys.h"
-#include "osapi.h"
-#include "os_type.h"
-#include "user_interface.h"
-#include "gpio.h"
-#include "mem.h"
-void ets_timer_arm_new(os_timer_t *ptimer, uint32_t milliseconds, bool repeat_flag, bool us_flag);
-void ets_timer_disarm(os_timer_t *ptimer);
-void ets_timer_setfn(os_timer_t *ptimer, os_timer_func_t *pfunction, void *parg);
-extern void (*__init_array_start)();
-extern void (*__init_array_end)();
-}
-
-#define user_procTaskPrio        0
-#define user_procTaskQueueLen    1
-
-#ifdef CONFIG_loop
-LOCAL os_timer_t loop_timer;
-
-extern void loop(void);
-static void ICACHE_FLASH_ATTR jump_to_loop(void *arg)
-{
-	loop();
-}
-
-#endif
-
-extern int main(void);
-
-void ICACHE_FLASH_ATTR jump_to_main(void)
-{
-	for (void (**p)() = &__init_array_start; p != &__init_array_start; p++) {
-		(*p)();
-	}
-#ifdef CONFIG_loop
-	os_timer_disarm(&loop_timer);
-	os_timer_setfn(&loop_timer, (os_timer_func_t *)jump_to_loop, (void *)0);
-	os_timer_arm(&loop_timer, 1000, 1);
-#endif
-	// Disable Wi-Fi
-	wifi_station_disconnect();
-	wifi_set_opmode_current(NULL_MODE);
-	wifi_fpm_set_sleep_type(MODEM_SLEEP_T);
-	wifi_fpm_open();
-	wifi_fpm_do_sleep(0xFFFFFFF);
-	main();
-}
-
-void Arch::setup(void)
-{
-}
-
-void Arch::idle_loop(void)
-{
-}
-
-void Arch::idle(void)
-{
-}
-
-extern "C" void user_init(void)
-{
-	system_init_done_cb(jump_to_main);
-}
-
-Arch arch;
diff --git a/src/arch/esp8266/driver/counter.cc b/src/arch/esp8266/driver/counter.cc
deleted file mode 100644
index dd6196a..0000000
--- a/src/arch/esp8266/driver/counter.cc
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * Copyright 2020 Daniel Friesel
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-#include "driver/counter.h"
-
-Counter counter;
diff --git a/src/arch/esp8266/driver/gpio.cc b/src/arch/esp8266/driver/gpio.cc
deleted file mode 100644
index d6c92a4..0000000
--- a/src/arch/esp8266/driver/gpio.cc
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright 2020 Daniel Friesel
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-#include "driver/gpio.h"
-extern "C" {
-#include "osapi.h"
-#include "user_interface.h"
-#include "gpio.h"
-}
-
-void ICACHE_FLASH_ATTR GPIO::setup()
-{
-	gpio_init();
-
-	// Enable GPIO2 (ESP8266 on-board LED) as output
-	PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
-
-#ifdef LED_ON_GPIO16
-	// Enable GPIO16 (RTC out / NodeMCU on-board LED) as output
-	WRITE_PERI_REG(PAD_XPD_DCDC_CONF, (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1);
-	WRITE_PERI_REG(RTC_GPIO_CONF, (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0);
-	WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe) | (uint32)0x1);
-	// Turn the GPIO on to make sure the LED is off by default
-	WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe) | (uint32)(1));
-#endif
-}
-
-void ICACHE_FLASH_ATTR GPIO::led_on(unsigned char const id)
-{
-#ifdef LED_ON_GPIO16
-	if (id == 0) {
-		gpio_output_set(0, BIT2, BIT2, 0);
-	} else {
-		WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe) | (uint32)(0));
-	}
-#else
-	gpio_output_set(0, BIT2, BIT2, 0);
-#endif
-}
-
-void ICACHE_FLASH_ATTR GPIO::led_off(unsigned char const id)
-{
-#ifdef LED_ON_GPIO16
-	if (id == 0) {
-		gpio_output_set(BIT2, 0, BIT2, 0);
-	} else {
-		WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe) | (uint32)(0));
-	}
-#else
-	gpio_output_set(BIT2, 0, BIT2, 0);
-#endif
-}
-
-void ICACHE_FLASH_ATTR GPIO::led_toggle(unsigned char const id)
-{
-#ifdef LED_ON_GPIO16
-	if (id == 0) {
-		if (gpio_input_get() & BIT2) {
-			led_on(0);
-		} else {
-			led_off(0);
-		}
-	} else {
-		WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) ^ BIT0));
-	}
-#else
-	if (gpio_input_get() & BIT2) {
-		led_on(0);
-	} else {
-		led_off(0);
-	}
-#endif
-}
-
-void ICACHE_FLASH_ATTR GPIO::input(unsigned char const pin)
-{
-	if (pin == d0) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
-	} else if (pin == tx) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_GPIO1);
-	} else if (pin == d4) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
-	} else if (pin == rx) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_GPIO3);
-	} else if (pin == d2) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4);
-	} else if (pin == d1) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5);
-	} else if (pin == d6) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12);
-	} else if (pin == d7) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);
-	} else if (pin == d5) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14);
-	} else if (pin == d8) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15);
-	} else if (pin == d0) {
-		// TODO this sets it as output, not input
-		WRITE_PERI_REG(PAD_XPD_DCDC_CONF, (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1);
-		WRITE_PERI_REG(RTC_GPIO_CONF, (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0);
-		WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe) | (uint32)0x1);
-	}
-	if (pin < d0) {
-		gpio_output_set(0, 0, 0, (1 << pin));
-	}
-}
-
-void ICACHE_FLASH_ATTR GPIO::input(unsigned char const pin, bool pullup)
-{
-	if (pin == d0) {
-		if (pullup) {
-			PIN_PULLUP_EN(PERIPHS_IO_MUX_GPIO0_U);
-		} else {
-			PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO0_U);
-		}
-	} else if (pin == tx) {
-		if (pullup) {
-			PIN_PULLUP_EN(PERIPHS_IO_MUX_U0TXD_U);
-		} else {
-			PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U);
-		}
-	} else if (pin == d4) {
-		if (pullup) {
-			PIN_PULLUP_EN(PERIPHS_IO_MUX_GPIO2_U);
-		} else {
-			PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO2_U);
-		}
-	} else if (pin == rx) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_GPIO3);
-	} else if (pin == d2) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4);
-	} else if (pin == d1) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5);
-	} else if (pin == d6) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12);
-	} else if (pin == d7) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);
-	} else if (pin == d5) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14);
-	} else if (pin == d8) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15);
-	} else if (pin == d0) {
-		// TODO this sets it as output, not input
-		WRITE_PERI_REG(PAD_XPD_DCDC_CONF, (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1);
-		WRITE_PERI_REG(RTC_GPIO_CONF, (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0);
-		WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe) | (uint32)0x1);
-	}
-	input(pin);
-}
-
-void ICACHE_FLASH_ATTR GPIO::output(unsigned char const pin)
-{
-	if (pin == d0) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
-	} else if (pin == tx) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_GPIO1);
-	} else if (pin == d4) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
-	} else if (pin == rx) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_GPIO3);
-	} else if (pin == d2) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4);
-	} else if (pin == d1) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5);
-	} else if (pin == d6) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12);
-	} else if (pin == d7) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);
-	} else if (pin == d5) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14);
-	} else if (pin == d8) {
-		PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15);
-	} else if (pin == d0) {
-		WRITE_PERI_REG(PAD_XPD_DCDC_CONF, (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1);
-		WRITE_PERI_REG(RTC_GPIO_CONF, (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0);
-		WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe) | (uint32)0x1);
-	}
-	if (pin < d0) {
-		gpio_output_set(0, 0, (1 << pin), 0);
-	}
-}
-
-unsigned char ICACHE_FLASH_ATTR GPIO::read(unsigned char const pin)
-{
-	return (gpio_input_get() & (1 << pin));
-}
-
-void ICACHE_FLASH_ATTR GPIO::write(unsigned char const pin, unsigned char value)
-{
-	if (value) {
-		gpio_output_set(1 << pin, 0, 0, 0);
-	} else {
-		gpio_output_set(0, 1 << pin, 0, 0);
-	}
-}
-
-GPIO gpio;
diff --git a/src/arch/esp8266/driver/stdin.cc b/src/arch/esp8266/driver/stdin.cc
deleted file mode 100644
index 7032d81..0000000
--- a/src/arch/esp8266/driver/stdin.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2020 Daniel Friesel
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-#include "driver/stdin.h"
-#include "driver/gpio.h"
-extern "C" {
-#include "osapi.h"
-#include "user_interface.h"
-#include "gpio.h"
-#include "ets_sys.h"
-void ets_isr_attach(uint16_t idx, void func(), void *arg);
-void ets_isr_unmask(uint16_t idx);
-}
-
-#define USF  *((volatile uint32_t *)(0x60000000))
-#define USIR *((volatile uint32_t *)(0x60000004))
-#define USIS *((volatile uint32_t *)(0x60000008))
-#define USIE *((volatile uint32_t *)(0x6000000c))
-#define USIC *((volatile uint32_t *)(0x60000010))
-#define USS  *((volatile uint32_t *)(0x6000001c))
-#define USC1 *((volatile uint32_t *)(0x60000024))
-
-#define UIFF 0
-#define UIFE 1
-#define UIPE 2
-#define UIFR 3
-#define UIOF 4
-#define UIDSR 5
-#define UICTS 6
-#define UIBD 7
-#define UITO 8
-
-#define USRXC 0
-#define UCFFT 0
-#define UCTOT 24
-#define UCTOE 31
-
-
-#ifdef CONFIG_wakeup
-void wakeup();
-#endif
-
-void uart_isr()
-{
-	if (USIS & ((1 << UIFF) | (1 << UITO))) {
-		while ((USS >> USRXC) & 0x7f) {
-			kin.addKey(USF);
-		}
-	}
-	USIC = USIS;
-#ifdef CONFIG_wakeup
-	wakeup();
-#endif
-}
-
-void StandardInput::setup()
-{
-	//USC1 = (0x7f << UCFFT) | (0x02 << UCTOT) | (1 << UCTOE );
-	USIC = 0xffff;
-	USIE = (1 << UIFF) | (1 << UIFR) | (1 << UITO);
-	ETS_UART_INTR_ATTACH(&uart_isr, NULL);
-	ETS_UART_INTR_ENABLE();
-}
-
-bool StandardInput::hasKey()
-{
-	if (write_pos != read_pos) {
-		return true;
-	}
-	return false;
-}
-
-char StandardInput::getKey()
-{
-	char ret = buffer[read_pos++];
-	read_pos %= 8;
-	return ret;
-}
-
-StandardInput kin;
diff --git a/src/arch/esp8266/driver/stdout.cc b/src/arch/esp8266/driver/stdout.cc
deleted file mode 100644
index 09a893f..0000000
--- a/src/arch/esp8266/driver/stdout.cc
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright 2020 Daniel Friesel
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-#include "driver/stdout.h"
-extern "C" {
-#include "osapi.h"
-#include "user_interface.h"
-#include "gpio.h"
-void uart_div_modify(uint8_t uart_no, uint32 DivLatchValue);
-void os_printf_plus(const char *s, ...);
-}
-
-StandardOutput & StandardOutput::operator<<(unsigned char c)
-{
-	if (base == 16) {
-		os_printf("%02x", c);
-	} else {
-		os_printf("%d", c);
-	}
-	return *this;
-}
-
-StandardOutput & StandardOutput::operator<<(char c)
-{
-	put(c);
-	return *this;
-}
-
-StandardOutput & StandardOutput::operator<<(unsigned short number)
-{
-	os_printf("%u", number);
-	return *this;
-}
-
-StandardOutput & StandardOutput::operator<<(short number)
-{
-	os_printf("%d", number);
-	return *this;
-}
-
-StandardOutput & StandardOutput::operator<<(unsigned int number)
-{
-	if (base == 16) {
-		os_printf("%08x", number);
-	} else {
-		os_printf("%u", number);
-	}
-	return *this;
-}
-
-StandardOutput & StandardOutput::operator<<(int number)
-{
-	if (base == 16) {
-		os_printf("%08x", number);
-	} else {
-		os_printf("%d", number);
-	}
-	return *this;
-}
-
-StandardOutput & StandardOutput::operator<<(unsigned long number)
-{
-	os_printf("%lu", number);
-	return *this;
-}
-
-StandardOutput & StandardOutput::operator<<(long number)
-{
-	os_printf("%ld", number);
-	return *this;
-}
-
-StandardOutput & StandardOutput::operator<<(float number)
-{
-	printf_float(number);
-	return *this;
-}
-
-StandardOutput & StandardOutput::operator<<(double number)
-{
-	printf_float(number);
-	return *this;
-}
-
-ICACHE_FLASH_ATTR StandardOutput & StandardOutput::operator<<(unsigned long long number)
-{
-	switch (base) {
-	case 2:
-		put('0');
-		put('b');
-		break;
-	case 8:
-		put('0');
-		break;
-	case 16:
-		put('0');
-		put('x');
-		break;
-	}
-
-	if (number == 0) {
-		put('0');
-		return *this;
-	}
-
-	signed int i = 0;
-	while (number > 0) {
-		if (base == 16 && number % base > 9) {
-			digit_buffer[i] = 'a' + (number % base) - 10;
-		} else {
-			digit_buffer[i] = '0' + (number % base);
-		}
-		number /= base;
-		i++;
-	}
-	i--;
-	for (; i >= 0; i--) {
-		put(digit_buffer[i]);
-	}
-	return *this;
-
-}
-
-StandardOutput & StandardOutput::operator<<(long long number)
-{
-	if (number < 0) {
-		put('-');
-		number *= -1;
-	}
-	*this << (unsigned long long)number;
-
-	return *this;
-}
-
-StandardOutput & StandardOutput::operator<<(void *pointer)
-{
-	unsigned short temp_base = base;
-	*this << hex << (long)pointer;
-	switch (temp_base) {
-	case 2:
-		*this << bin; break;
-	case 8:
-		*this << oct; break;
-	case 10:
-		*this << dec; break;
-	}
-	return *this;
-}
-
-StandardOutput & StandardOutput::operator<<(const char *text)
-{
-	write(text);
-	return *this;
-}
-
-StandardOutput & StandardOutput::operator<<(StandardOutput & (*fkt) (StandardOutput &))
-{
-	return fkt(*this);
-}
-
-void StandardOutput::setBase(uint8_t b)
-{
-	if (b == 2 || b == 8 || b == 10 || b == 16) {
-		base = b;
-	}
-}
-
-static inline char format_hex_nibble(uint8_t num)
-{
-	if (num > 9) {
-		return 'a' + num - 10;
-	}
-	return '0' + num;
-}
-
-void StandardOutput::printf_uint8(uint8_t num)
-{
-	put(format_hex_nibble(num / 16));
-	put(format_hex_nibble(num % 16));
-}
-
-ICACHE_FLASH_ATTR void StandardOutput::printf_float(float num)
-{
-	if (num < 0) {
-		put('-');
-		num *= -1;
-	}
-	if (num > 1000) {
-		put('0' + (((int)num % 10000) / 1000));
-	}
-	if (num > 100) {
-		put('0' + (((int)num % 1000) / 100));
-	}
-	if (num > 10) {
-		put('0' + (((int)num % 100) / 10));
-	}
-	put('0' + ((int)num % 10));
-	put('.');
-	put('0' + ((int)(num * 10) % 10));
-	put('0' + ((int)(num * 100) % 10));
-}
-
-StandardOutput & flush(StandardOutput & os)
-{
-	os.flush();
-	return os;
-}
-
-StandardOutput & endl(StandardOutput & os)
-{
-	os.put('\n');
-	os.flush();
-	return os;
-}
-
-StandardOutput & bin(StandardOutput & os)
-{
-	os.setBase(2);
-	return os;
-}
-
-StandardOutput & oct(StandardOutput & os)
-{
-	os.setBase(8);
-	return os;
-}
-
-StandardOutput & dec(StandardOutput & os)
-{
-	os.setBase(10);
-	return os;
-}
-
-StandardOutput & hex(StandardOutput & os)
-{
-	os.setBase(16);
-	return os;
-}
-
-StandardOutput & term(StandardOutput & os)
-{
-	os.put('\0');
-	os.flush();
-	return os;
-}
-
-void StandardOutput::setup()
-{
-	uart_div_modify(0, UART_CLK_FREQ / 115200);
-}
-
-void StandardOutput::put(char c)
-{
-	os_printf("%c", c);
-}
-
-void StandardOutput::write(const char *s)
-{
-	os_printf("%s", s);
-}
-
-StandardOutput kout;
diff --git a/src/arch/esp8266/driver/uptime.cc b/src/arch/esp8266/driver/uptime.cc
deleted file mode 100644
index 621ec91..0000000
--- a/src/arch/esp8266/driver/uptime.cc
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * Copyright 2020 Daniel Friesel
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-#include "driver/uptime.h"
-
-Uptime uptime;
diff --git a/src/arch/esp8266/prompt b/src/arch/esp8266/prompt
deleted file mode 100644
index 3428bc3..0000000
--- a/src/arch/esp8266/prompt
+++ /dev/null
@@ -1 +0,0 @@
-ESP8266
diff --git a/src/driver/Kconfig b/src/driver/Kconfig
index 4c87474..5fe4bad 100644
--- a/src/driver/Kconfig
+++ b/src/driver/Kconfig
@@ -135,7 +135,6 @@ default "i2c"
 
 config driver_softi2c_scl
 string "SCL Pin"
-default "d7" if arch_esp8266
 default "pc5" if arch_arduino_nano
 default "p1_7" if arch_msp430fr5969lp
 default "p5_1" if arch_msp430fr5994lp
@@ -144,7 +143,6 @@ depends on driver_softi2c
 
 config driver_softi2c_sda
 string "SDA Pin"
-default "d6" if arch_esp8266
 default "pc4" if arch_arduino_nano
 default "p1_6" if arch_msp430fr5969lp
 default "p5_0" if arch_msp430fr5994lp
diff --git a/src/driver/ccs811.cc b/src/driver/ccs811.cc
index 531dadb..0206a96 100644
--- a/src/driver/ccs811.cc
+++ b/src/driver/ccs811.cc
@@ -11,10 +11,6 @@
 #include "driver/soft_i2c.h"
 #endif
 
-#ifdef MULTIPASS_ARCH_esp8266
-#define nWAKE GPIO::d5
-#endif
-
 void CCS811::init()
 {
 	startFirmware();
diff --git a/src/driver/soft_i2c.cc b/src/driver/soft_i2c.cc
index 83aa20c..ada0481 100644
--- a/src/driver/soft_i2c.cc
+++ b/src/driver/soft_i2c.cc
@@ -246,9 +246,7 @@ SoftI2C i2c(GPIO::p5_0, GPIO::p5_1, GPIO::p8_2, GPIO::p8_3);
 #error "softi2c_pullup = external not supported on this architecture"
 #endif /* MULTIPASS_ARCH_* */
 #else
-#ifdef MULTIPASS_ARCH_esp8266
-SoftI2C i2c(GPIO::d6, GPIO::d7);
-#elif MULTIPASS_ARCH_arduino_nano
+#if MULTIPASS_ARCH_arduino_nano
 SoftI2C i2c(GPIO::pc4, GPIO::pc5);
 #elif MULTIPASS_ARCH_blinkenrocket
 SoftI2C i2c(GPIO::pc4, GPIO::pc5);
diff --git a/tests/build-esp8266 b/tests/build-esp8266
deleted file mode 100755
index 3cf9bd6..0000000
--- a/tests/build-esp8266
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-set -e
-
-touch .config
-
-for app in deflatetest donothing ledblink sysinfo; do
-	make -B arch=esp8266 app=$app build/system.elf
-done
-- 
GitLab