Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility with Espressif SDK 2.1.0 published in git repository #1153

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Sming/Libraries/Adafruit_ILI9341/Adafruit_ILI9341.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ void Adafruit_ILI9341::begin(void) {
transmitCmdData(0xE1, data, 15); //Set Gamma

transmitCmd(0x11); //Exit Sleep
os_delay_us(120000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avr39-ripe Can you remove that change from the PR. As far as I can see it has nothing to do with SDK 2.1.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is mandatory change. without this this library do not compile any more. Old os_delay_us declaration was uint32_t and new, from esp sdk 2.1.0 is uint16_t, so I made such "strange" change here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More code should be reviewed then to check if delays do not excede 65,535 limit.

os_delay_us(60000);
os_delay_us(60000);

transmitCmd(0x29); //Display on
transmitCmd(0x2c);
Expand Down
4 changes: 2 additions & 2 deletions Sming/SmingCore/HardwareTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ static void IRAM_ATTR hw_timer_isr_cb(void *arg)

Hardware_Timer::Hardware_Timer()
{
ETS_FRC_TIMER1_INTR_ATTACH((void*)hw_timer_isr_cb, (void *)this);
ETS_FRC_TIMER1_INTR_ATTACH((ets_isr_t)hw_timer_isr_cb, (void *)this);
}

Hardware_Timer::~Hardware_Timer()
{
ETS_FRC_TIMER1_INTR_ATTACH((void*)hw_timer_isr_cb, null);
ETS_FRC_TIMER1_INTR_ATTACH((ets_isr_t)hw_timer_isr_cb, null);
stop();
}

Expand Down
2 changes: 1 addition & 1 deletion Sming/SmingCore/Interrupts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void attachInterruptHandler(uint8_t pin, GPIO_INT_TYPE mode)

if (!_gpioInterruptsInitialied)
{
ETS_GPIO_INTR_ATTACH((void*)interruptHandler, NULL); // Register interrupt handler
ETS_GPIO_INTR_ATTACH((ets_isr_t)interruptHandler, NULL); // Register interrupt handler
_gpioInterruptsInitialied = true;
}

Expand Down
3 changes: 1 addition & 2 deletions Sming/SmingCore/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
#include <stdlib.h>
#include "eagle_soc.h"
#include "espinc/spi_register.h"
#include "espinc/c_types_compatible.h"

#include "c_types.h"
// define the static singleton
SPIClass SPI;

Expand Down
8 changes: 3 additions & 5 deletions Sming/include/user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ extern "C" {
#include <limits.h>
#include <stdint.h>

// Override c_types.h include and remove buggy espconn
#define _C_TYPES_H_
// Remove buggy espconn
#define _NO_ESPCON_

// Updated, compatible version of c_types.h
// Just removed types declared in <stdint.h>
#include <espinc/c_types_compatible.h>
// Now ESP SDK provide proper c_types.h by itself
#include "c_types.h"

// System API declarations
#include <esp_systemapi.h>
Expand Down
55 changes: 5 additions & 50 deletions Sming/system/include/esp_systemapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef __ESP_SYSTEM_API_H__
#define __ESP_SYSTEM_API_H__

#include <ets_sys.h>
#include "ets_sys.h"
#include <osapi.h>
#include <gpio.h>
#include <os_type.h>
Expand Down Expand Up @@ -43,62 +43,17 @@
#endif
#define assert(condition) if (!(condition)) SYSTEM_ERROR("ASSERT: %s %d", __FUNCTION__, __LINE__)
#define SYSTEM_ERROR(fmt, ...) m_printf("ERROR: " fmt "\r\n", ##__VA_ARGS__)

extern void ets_timer_arm_new(ETSTimer *ptimer, uint32_t milliseconds, bool repeat_flag, int isMstimer);
extern void ets_timer_disarm(ETSTimer *a);
extern void ets_timer_setfn(ETSTimer *t, ETSTimerFunc *pfunction, void *parg);

//extern void ets_wdt_init(uint32_t val); // signature?
extern void ets_wdt_enable(void);
extern void ets_wdt_disable(void);
extern void wdt_feed(void);
//extern void wd_reset_cnt(void);
extern void ets_delay_us(uint32_t us);

extern void ets_isr_mask(unsigned intr);
extern void ets_isr_unmask(unsigned intr);
extern void ets_isr_attach(int intr, void *handler, void *arg);

extern int ets_memcmp(const void *s1, const void *s2, size_t n);
extern void *ets_memcpy(void *dest, const void *src, size_t n);
extern void *ets_memset(void *s, int c, size_t n);

extern void ets_install_putc1(void *routine);
extern int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
extern int ets_str2macaddr(void *, void *);
extern int ets_strcmp(const char *s1, const char *s2);
extern char *ets_strcpy(char *dest, const char *src);
//extern int os_random();
//extern char *ets_strdup(const char *str); // :(
const char * ets_strrchr(const char *str, int character);
extern size_t ets_strlen(const char *s);
extern int ets_strncmp(const char *s1, const char *s2, int len);
extern char *ets_strncpy(char *dest, const char *src, size_t n);
extern char *ets_strstr(const char *haystack, const char *needle);
extern int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
extern int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
extern int ets_vsnprintf(char * s, size_t n, const char * format, va_list arg) __attribute__ ((format (printf, 3, 0)));

extern void *pvPortMalloc(size_t xWantedSize, const char *file, uint32 line);
extern void *pvPortZalloc(size_t xWantedSize, const char *file, uint32 line);
extern void pvPortFree(void *ptr);
extern void vPortFree(void *ptr, const char *file, uint32 line);
extern void *vPortMalloc(size_t xWantedSize);

extern void uart_div_modify(int no, unsigned int freq);
extern int ets_uart_printf(const char *fmt, ...);
extern void uart_tx_one_char(char ch);

extern void ets_intr_lock();
extern void ets_intr_unlock();

// CPU Frequency
extern void ets_update_cpu_frequency(uint32_t frq);
extern uint32_t ets_get_cpu_frequency();

extern void xt_disable_interrupts();
extern void xt_enable_interrupts();

extern void uart_tx_one_char(char ch);
extern void ets_isr_mask(unsigned intr);
extern void ets_isr_unmask(unsigned intr);

typedef signed short file_t;

#endif
8 changes: 4 additions & 4 deletions Sming/system/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void uart_start_isr(uart_t* uart)
USIC(uart->uart_nr) = 0xffff;
USIE(uart->uart_nr) = (1 << UIFF) | (1 << UIFR) | (1 << UITO);
// ETS_UART_INTR_ATTACH(uart_isr, (void *)uart);
ETS_UART_INTR_ATTACH((void *)uart_isr, (void *)uart);
ETS_UART_INTR_ATTACH((ets_isr_t)uart_isr, (void *)uart);
ETS_UART_INTR_ENABLE();
}

Expand Down Expand Up @@ -492,16 +492,16 @@ void uart_set_debug(int uart_nr)
switch(s_uart_debug_nr) {
case UART0:
system_set_os_print(1);
ets_install_putc1((void *) &uart0_write_char);
ets_install_putc1((void (*)(char)) &uart0_write_char);
break;
case UART1:
system_set_os_print(1);
ets_install_putc1((void *) &uart1_write_char);
ets_install_putc1((void (*)(char)) &uart1_write_char);
break;
case UART_NO:
default:
system_set_os_print(0);
ets_install_putc1((void *) &uart_ignore_char);
ets_install_putc1((void (*)(char)) &uart_ignore_char);
break;
}
}
Expand Down
157 changes: 73 additions & 84 deletions Sming/third-party/.patches/esp-open-lwip.patch
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
diff --git a/include/user_config.h b/include/user_config.h
index e69de29..0c5dff9 100644
--- a/include/user_config.h
+++ b/include/user_config.h
@@ -0,0 +1,20 @@
+#ifndef _USER_CONFIG_LWIP_
+#define _USER_CONFIG_LWIP_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef signed short sint16_t;
+
+void *ets_bzero(void *block, size_t size);
+bool ets_post(uint32_t prio, ETSSignal sig, ETSParam par);
+void ets_task(ETSTask task, uint32_t prio, ETSEvent * queue, uint8 qlen);
+
+void system_pp_recycle_rx_pkt(void *eb);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_USER_CONFIG_LWIP_*/
diff --git a/Makefile.open b/Makefile.open
index 1bc584f..0bfc424 100644
index 1bc584f..e4af916 100644
--- a/Makefile.open
+++ b/Makefile.open
@@ -1,8 +1,10 @@
Expand Down Expand Up @@ -75,44 +50,38 @@ index 1bc584f..0bfc424 100644
$(LIB): $(OBJS)
$(AR) rcs $@ $^
diff --git a/include/arch/cc.h b/include/arch/cc.h
index ff03b30..fde6567 100644
index ff03b30..e86ae57 100644
--- a/include/arch/cc.h
+++ b/include/arch/cc.h
@@ -38,8 +38,25 @@
@@ -34,12 +34,18 @@
#ifndef __ARCH_CC_H__
#define __ARCH_CC_H__

-//#include <string.h>
#include "c_types.h"
#include "ets_sys.h"
#include "osapi.h"
+#include "mem.h"
+#include <stdarg.h>
+
#define EFAULT 14

+//Extra symbols to avoid implicit declaration warnings
+extern void *ets_memset(void *s, int c, size_t n);
+extern void *ets_memcpy(void *dest, const void *src, size_t n);
+
+extern size_t ets_strlen(const char *s);
+extern int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
+extern int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+extern void ets_timer_arm_new(ETSTimer *ptimer, uint32_t milliseconds, bool repeat_flag, int isMstimer);
+extern void ets_timer_disarm(ETSTimer *a);
+extern void ets_timer_setfn(ETSTimer *t, ETSTimerFunc *pfunction, void *parg);
+extern uint32 r_rand(void);
+extern int ets_memcmp(const void *s1, const void *s2, size_t n);
+
+struct netif * eagle_lwip_getif(uint8 index);
+
//#define LWIP_PROVIDE_ERRNO

#if (1)
@@ -56,6 +73,7 @@ typedef signed short s16_t;
@@ -56,6 +62,7 @@ typedef signed short s16_t;
typedef unsigned long u32_t;
typedef signed long s32_t;
typedef unsigned long mem_ptr_t;
+typedef signed short sint16_t;

#define S16_F "d"
#define U16_F "d"
@@ -73,11 +91,12 @@ typedef unsigned long mem_ptr_t;
@@ -73,11 +80,12 @@ typedef unsigned long mem_ptr_t;
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_END

Expand All @@ -129,6 +98,48 @@ index ff03b30..fde6567 100644
#else
#define LWIP_PLATFORM_DIAG(x)
#define LWIP_PLATFORM_ASSERT(x)
diff --git a/include/lwip/ip_addr.h b/include/lwip/ip_addr.h
index 1e46ee5..cfc10f8 100644
--- a/include/lwip/ip_addr.h
+++ b/include/lwip/ip_addr.h
@@ -210,7 +210,7 @@ u8_t ip4_addr_netmask_valid(u32_t netmask)ICACHE_FLASH_ATTR;
#define ip_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL))

#define ip_addr_debug_print(debug, ipaddr) \
- LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \
+ LWIP_DEBUGF(debug, ("%" U16_F ".%" U16_F ".%" U16_F ".%" U16_F, \
ipaddr != NULL ? ip4_addr1_16(ipaddr) : 0, \
ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0, \
ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0, \
diff --git a/include/lwip/mem.h b/include/lwip/mem.h
index af6e360..6d8cabd 100644
--- a/include/lwip/mem.h
+++ b/include/lwip/mem.h
@@ -52,19 +52,19 @@ typedef size_t mem_size_t;
*/
#ifndef MEMLEAK_DEBUG
#ifndef mem_free
-#define mem_free vPortFree
+#define mem_free(s) vPortFree(s, "", 0)
#endif
#ifndef mem_malloc
-#define mem_malloc pvPortMalloc
+#define mem_malloc(s) pvPortMalloc(s, "", 0)
#endif
#ifndef mem_calloc
-#define mem_calloc pvPortCalloc
+#define mem_calloc(s) pvPortCalloc(s, "", 0);
#endif
#ifndef mem_realloc
-#define mem_realloc pvPortRealloc
+#define mem_realloc(p, s) pvPortRealloc(p, s, "", 0)
#endif
#ifndef mem_zalloc
-#define mem_zalloc pvPortZalloc
+#define mem_zalloc(s) pvPortZalloc(s, "", 0)
#endif
#else
#ifndef mem_free
diff --git a/include/lwipopts.h b/include/lwipopts.h
index eaa8dd6..6568657 100644
--- a/include/lwipopts.h
Expand Down Expand Up @@ -205,49 +216,27 @@ index eaa8dd6..6568657 100644
#endif

/**
diff --git a/include/lwip/ip_addr.h b/include/lwip/ip_addr.h
index 1e46ee5..cfc10f8 100644
--- a/include/lwip/ip_addr.h
+++ b/include/lwip/ip_addr.h
@@ -210,7 +210,7 @@ u8_t ip4_addr_netmask_valid(u32_t netmask)ICACHE_FLASH_ATTR;
#define ip_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL))

#define ip_addr_debug_print(debug, ipaddr) \
- LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \
+ LWIP_DEBUGF(debug, ("%" U16_F ".%" U16_F ".%" U16_F ".%" U16_F, \
ipaddr != NULL ? ip4_addr1_16(ipaddr) : 0, \
ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0, \
ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0, \
diff --git a/include/lwip/mem.h b/include/lwip/mem.h
index af6e360..6d8cabd 100644
--- a/include/lwip/mem.h
+++ b/include/lwip/mem.h
@@ -52,19 +52,19 @@ typedef size_t mem_size_t;
*/
#ifndef MEMLEAK_DEBUG
#ifndef mem_free
-#define mem_free vPortFree
+#define mem_free(s) vPortFree(s, "", 0)
#endif
#ifndef mem_malloc
-#define mem_malloc pvPortMalloc
+#define mem_malloc(s) pvPortMalloc(s, "", 0)
#endif
#ifndef mem_calloc
-#define mem_calloc pvPortCalloc
+#define mem_calloc(s) pvPortCalloc(s, "", 0);
#endif
#ifndef mem_realloc
-#define mem_realloc pvPortRealloc
+#define mem_realloc(p, s) pvPortRealloc(p, s, "", 0)
#endif
#ifndef mem_zalloc
-#define mem_zalloc pvPortZalloc
+#define mem_zalloc(s) pvPortZalloc(s, "", 0)
#endif
#else
#ifndef mem_free
diff --git a/lwip/app/dhcpserver.c b/lwip/app/dhcpserver.c
diff --git a/include/user_config.h b/include/user_config.h
index e69de29..07768eb 100644
--- a/include/user_config.h
+++ b/include/user_config.h
@@ -0,0 +1,15 @@
+#ifndef _USER_CONFIG_LWIP_
+#define _USER_CONFIG_LWIP_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "c_types.h"
+void system_pp_recycle_rx_pkt(void *eb);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_USER_CONFIG_LWIP_*/
diff --git a/lwip/app/dhcpserver.c b/lwip/app/dhcpserver.c
index ddb5984..fb677c6 100644
--- a/lwip/app/dhcpserver.c
+++ b/lwip/app/dhcpserver.c
Expand Down