Commit 6bdfa059 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Add basic ESP8266 support

parent 7b528402
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -7,13 +7,7 @@ CXXFLAGS = -std=c++14

TARGETS = src/os/main.cc

ifeq (${arch}, msp430fr5969lp)
include src/arch/msp430fr5969lp/Makefile.inc
endif

ifeq (${arch}, posix)
include src/arch/posix/Makefile.inc
endif
include src/arch/${arch}/Makefile.inc

clean: arch_clean
	rm -f build/system.elf
+18 −0
Original line number Diff line number Diff line
#ifndef GPIO_H
#define GPIO_H

class GPIO {
	private:
		GPIO(const GPIO &copy);

	public:
		GPIO () {}
		void setup();
		void led_on(unsigned char id);
		void led_off(unsigned char id);
		void led_toggle(unsigned char id);
};

extern GPIO gpio;

#endif
+5 −0
Original line number Diff line number Diff line
/*
 * required by ESP8266 SDK's osapi.h
 *
 * Intentionally left blank.
 */
+46 −0
Original line number Diff line number Diff line
# vim:ft=make

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
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

INCLUDES += -Iinclude/esp8266 -I${SDK_BASE}/include
COMMON_FLAGS += -nostdlib -mlongcalls
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

OBJECTS = ${TARGETS:.cc=.o}

.cc.o:
	${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}

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} \
		-Wl,--start-group -lc -lgcc -lhal -lpp -lphy -lnet80211 -llwip -lwpa \
		-lmain $< -Wl,--end-group -o $@

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} write_flash 0x00000 build/0x00000.bin 0x40000 build/0x40000.bin

arch_clean:
	rm -f ${OBJECTS}
	rm -f build/system.ar

.PHONY: arch_clean program
+30 −0
Original line number Diff line number Diff line
#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"
}

#define user_procTaskPrio        0
#define user_procTaskQueueLen    1

extern int main(void);

void Arch::setup(void)
{
}

void Arch::idle_loop(void)
{
}

extern "C" void user_init(void)
{
	main();
}

Arch arch;
Loading