summaryrefslogtreecommitdiff
path: root/src/arch/esp8266
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2017-12-08 15:07:52 +0100
committerDaniel Friesel <derf@finalrewind.org>2017-12-08 15:07:52 +0100
commitdcf84169ae75b11c1656d45dbc6c626d93da6a10 (patch)
treed78ad84e6aba1f5f13037e40141013f3a3061d54 /src/arch/esp8266
parent56f2d90751f1c1b2db925da215a14721cf18d483 (diff)
Add output support (broken on esp8266)
Diffstat (limited to 'src/arch/esp8266')
-rw-r--r--src/arch/esp8266/Makefile.inc5
-rw-r--r--src/arch/esp8266/arch.cc5
-rw-r--r--src/arch/esp8266/driver/stdout.cc25
3 files changed, 34 insertions, 1 deletions
diff --git a/src/arch/esp8266/Makefile.inc b/src/arch/esp8266/Makefile.inc
index b0fc4ce..9a08678 100644
--- a/src/arch/esp8266/Makefile.inc
+++ b/src/arch/esp8266/Makefile.inc
@@ -9,6 +9,7 @@ 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
INCLUDES += -Iinclude/esp8266 -I${SDK_BASE}/include
COMMON_FLAGS += -nostdlib -mlongcalls -D__ets__ -DICACHE_FLASH
@@ -16,17 +17,19 @@ CXXFLAGS = -std=c++11
LDFLAGS += -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
TARGETS += src/arch/esp8266/arch.cc src/arch/esp8266/driver/gpio.cc
+TARGETS += src/arch/esp8266/driver/stdout.cc
OBJECTS = ${TARGETS:.cc=.o}
.cc.o:
${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
+ ${OBJCOPY} --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal $@
build/system.ar: ${OBJECTS}
${AR} cru $@ ${OBJECTS}
build/system.elf: build/system.ar
- ${CC} -L${SDK_BASE}/lib -T${SDK_BASE}/lib/eagle.app.v6.ld ${LDFLAGS} \
+ ${CC} -L${SDK_BASE}/lib -T${SDK_BASE}/lib/eagle.app.v6-derf.ld ${LDFLAGS} \
-Wl,--start-group -lc -lgcc -lhal -lpp -lphy -lnet80211 -llwip -lwpa \
-lmain $< -Wl,--end-group -o $@
diff --git a/src/arch/esp8266/arch.cc b/src/arch/esp8266/arch.cc
index 0e11f2d..f5d1c91 100644
--- a/src/arch/esp8266/arch.cc
+++ b/src/arch/esp8266/arch.cc
@@ -10,6 +10,8 @@ extern "C" {
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
@@ -30,6 +32,9 @@ 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 WITH_LOOP
os_timer_disarm(&loop_timer);
os_timer_setfn(&loop_timer, (os_timer_func_t *)jump_to_loop, (void *)0);
diff --git a/src/arch/esp8266/driver/stdout.cc b/src/arch/esp8266/driver/stdout.cc
new file mode 100644
index 0000000..b35275b
--- /dev/null
+++ b/src/arch/esp8266/driver/stdout.cc
@@ -0,0 +1,25 @@
+#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, ...);
+}
+
+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;