Commit 224788b6 authored by Johny Mattsson's avatar Johny Mattsson
Browse files

Make NodeMCU compile and link for ESP32.

A fair bit of reshuffling with include paths and overrides was necessary, as
the two RTOS SDKs (ESP8266 and ESP32) don't have the same header structure
(or even libraries for that matter). Uses the xtensa-esp108-elf toolchain
to build.

Completely untested beyond linking, as I still can't flash the ESP32 module
I have :(  I'd be most surprised if it does anything useful at this point
considering I've spent almost no time on the linker script or UART setup.

Anything using espconn has been ifdef'd out since espconn is not (and
probably will not be) available. Notably this includes the entire net module
as well as coap, mqtt and enduser_setup.

Many (most?) hardware bus drivers and related modules are also ifdef'd
out for now due to hardware differences. Functions surrounding sleep,
rtc and RF modes have also been hit by the ifdef hammer. Grep'ing for
__ESP8266__ and/or FIXME is a quick way of finding these places. With
time I hope all of these will be reinstated.
parent 0df2eda6
../../esp32-rtos-sdk/include
\ No newline at end of file
#ifndef _SDK_OVERRIDES_ETS_SYS_H_
#define _SDK_OVERRIDES_ETS_SYS_H_
#include_next <ets_sys.h>
#include <freertos/xtensa_api.h>
#define ETS_UART_INTR_ATTACH(fn,arg) xt_set_interrupt_handler(ETS_UART_INUM, fn, arg)
#define ETS_UART_INTR_ENABLE() xt_ints_on(1 << ETS_UART_INUM)
#define ETS_UART_INTR_DISABLE() xt_ints_off(1 << ETS_UART_INUM)
#define ETS_SPI_INTR_ATTACH(fn,arg) xt_set_interrupt_handler(ETS_SPI_INUM, fn, arg)
#define ETS_SPI_INTR_ENABLE() xt_ints_on(1 << ETS_SPI_INUM)
#define ETS_SPI_INTR_DISABLE() xt_ints_off(1 << ETS_SPI_INUM)
#define ETS_GPIO_INTR_ATTACH(fn,arg) xt_set_interrupt_handler(ETS_GPIO_INUM, fn, arg)
#define ETS_GPIO_INTR_ENABLE() xt_ints_on(1 << ETS_GPIO_INUM)
#define ETS_GPIO_INTR_DISABLE() xt_ints_off(1 << ETS_GPIO_INUM)
#define ETS_FRC_TIMER1_INTR_ATTACH(fn,arg) xt_set_interrupt_handler(ETS_FRC_TIMER1_INUM, fn, arg)
#define ETS_FRC1_INTR_ENABLE() xt_ints_on(1 << ETS_FRC_TIMER1_INUM)
#define ETS_FRC1_INTR_DISABLE() xt_ints_off(1 << ETS_FRC_TIMER1_INUM)
// FIXME: double-check this is the correct bit!
#define TM1_EDGE_INT_ENABLE() SET_PERI_REG_MASK(EDGE_INT_ENABLE_REG, BIT1)
#define TM1_EDGE_INT_DISABLE() CLEAR_PERI_REG_MASK(EDGE_INT_ENABLE_REG, BIT1)
#endif
#ifndef _SDK_OVERRIDES_GPIO_H_
#define _SDK_OVERRIDES_GPIO_H_
#include_next <gpio.h>
#define GPIO_STATUS_W1TC_ADDRESS GPIO_STATUS_W1TC
#define GPIO_STATUS_ADDRESS GPIO_STATUS
#define GPIO_OUT_W1TS_ADDRESS GPIO_OUT_W1TS
#define GPIO_OUT_W1TC_ADDRESS GPIO_OUT_W1TC
#define GPIO_ENABLE_W1TC_ADDRESS GPIO_ENABLE_W1TC
#define GPIO_ENABLE_ADDRESS GPIO_ENABLE
// FIXME: how does this apply to the ESP32?
#define GPIO_PIN_SOURCE_SET(x) 0
#define GPIO_PIN_SOURCE_MASK 0
#endif
......@@ -5,14 +5,8 @@
#include "os_type.h"
#include "espressif/esp_timer.h"
// FIXME, these need to change/go together with the task implementation
typedef uint32_t os_signal_t;
typedef uint32_t os_event_t;
typedef uint32_t os_param_t;
#include "freertos/portmacro.h"
#include_next "esp8266/ets_sys.h"
#include_next "ets_sys.h"
#define ets_vsprintf vsprintf
......
......@@ -2,7 +2,7 @@
#define _SDK_OVERRIDE_EAGLE_SOC_H_
#include_next "esp8266/eagle_soc.h"
#include_next "eagle_soc.h"
#define GPIO_AS_PIN_SOURCE 0
#define SIGMA_AS_PIN_SOURCE (~GPIO_AS_PIN_SOURCE)
......
#ifndef _SDK_OVERRIDES_OS_TYPE_H_
#define _SDK_OVERRIDES_OS_TYPE_H_
#define ETSTimer os_timer_t
#define ETSTimerFunc os_timer_func_t
//#define ETSTimer os_timer_t
//#define ETSTimerFunc os_timer_func_t
#endif
#ifndef _SDK_OVERRIDE_OSAPI_H_
#define _SDK_OVERRIDE_OSAPI_H_
#include "rom.h"
#include "user_interface.h"
#include "user_config.h"
void call_user_start(void);
......
#ifndef SDK_OVERRIDES_INCLUDE_USER_INTERFACE_H_
#define SDK_OVERRIDES_INCLUDE_USER_INTERFACE_H_
#define ets_timer_arm_new(tmr, ms, rpt, isms) os_timer_arm(tmr,ms,rpt)
#include <espressif/esp_system.h>
#include "espressif/esp_system.h"
#include "espressif/esp_misc.h"
#include "espressif/esp_wifi.h"
#include "espressif/esp_sta.h"
#include "espressif/esp_softap.h"
#include "espressif/esp_timer.h"
/* The SDKs claim ets_delay_us only takes a uint16_t, not a uint32_t. Until
* we have cleaned up our act and stopped using excessive hard-delays, we
* need our own prototype for it.
*
* Also, our ets_printf() prototype is better.
*/
#define ets_delay_us ets_delay_us_sdk
#define ets_printf ets_print_sdk
#include <espressif/esp_misc.h>
#undef ets_printf
#undef ets_delay_us
#include "rom.h"
#include <espressif/esp_wifi.h>
#include <espressif/esp_sta.h>
#include <espressif/esp_softap.h>
#include <espressif/esp_timer.h>
static inline void system_set_os_print(uint8_t onoff) {
extern uint8_t os_printf_enabled;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment