diff options
Diffstat (limited to 'esp8266')
-rw-r--r-- | esp8266/Makefile | 10 | ||||
-rw-r--r-- | esp8266/axtls_helpers.c | 3 | ||||
-rw-r--r-- | esp8266/eagle.rom.addr.v6.ld | 1 | ||||
-rw-r--r-- | esp8266/esp8266.ld | 3 | ||||
-rw-r--r-- | esp8266/esp_mphal.c | 5 | ||||
-rw-r--r-- | esp8266/esp_mphal.h | 6 | ||||
-rw-r--r-- | esp8266/espapa102.c | 5 | ||||
-rw-r--r-- | esp8266/espneopixel.c | 14 | ||||
-rw-r--r-- | esp8266/etshal.h | 7 | ||||
-rw-r--r-- | esp8266/main.c | 2 | ||||
-rw-r--r-- | esp8266/makeimg.py | 27 | ||||
-rw-r--r-- | esp8266/modesp.c | 23 | ||||
-rw-r--r-- | esp8266/modmachine.c | 15 | ||||
-rw-r--r-- | esp8266/modpybuart.c | 2 | ||||
-rw-r--r-- | esp8266/modules/_boot.py | 1 | ||||
-rw-r--r-- | esp8266/modules/flashbdev.py | 8 | ||||
-rw-r--r-- | esp8266/moduos.c | 6 | ||||
-rw-r--r-- | esp8266/modutime.c | 3 | ||||
-rw-r--r-- | esp8266/mpconfigport.h | 6 | ||||
-rw-r--r-- | esp8266/scripts/inisetup.py | 2 | ||||
-rw-r--r-- | esp8266/scripts/port_diag.py | 2 | ||||
-rw-r--r-- | esp8266/uart.h | 10 |
22 files changed, 129 insertions, 32 deletions
diff --git a/esp8266/Makefile b/esp8266/Makefile index 00826cfe46..ea9c7eb871 100644 --- a/esp8266/Makefile +++ b/esp8266/Makefile @@ -4,6 +4,8 @@ include ../py/mkenv.mk QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h MICROPY_PY_USSL = 1 +MICROPY_SSL_AXTLS = 1 +MICROPY_PY_BTREE = 1 # include py core make definitions include ../py/py.mk @@ -87,6 +89,7 @@ SRC_C = \ $(BUILD)/frozen.c \ fatfs_port.c \ axtls_helpers.c \ + $(SRC_MOD) STM_SRC_C = $(addprefix stmhal/,\ pybstdio.c \ @@ -153,7 +156,7 @@ SRC_QSTR += $(SRC_C) $(STM_SRC_C) $(EXTMOD_SRC_C) $(DRIVERS_SRC_C) # Append any auto-generated sources that are needed by sources listed in SRC_QSTR SRC_QSTR_AUTO_DEPS += -all: $(BUILD)/firmware-combined.bin +all: $(BUILD)/libaxtls.a $(BUILD)/firmware-combined.bin CONFVARS_FILE = $(BUILD)/confvars @@ -229,8 +232,11 @@ $(BUILD)/firmware.elf: $(OBJ) include ../py/mkrules.mk -axtls: +axtls: $(BUILD)/libaxtls.a + +$(BUILD)/libaxtls.a: cd ../lib/axtls; cp config/upyconfig config/.config cd ../lib/axtls; make oldconfig -B cd ../lib/axtls; make clean cd ../lib/axtls; make all CC="$(CC)" LD="$(LD)" AR="$(AR)" CFLAGS_EXTRA="$(CFLAGS_XTENSA) -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=3072" + cp ../lib/axtls/_stage/libaxtls.a $@ diff --git a/esp8266/axtls_helpers.c b/esp8266/axtls_helpers.c index 097d9ed4c3..6d508fdeb1 100644 --- a/esp8266/axtls_helpers.c +++ b/esp8266/axtls_helpers.c @@ -43,9 +43,6 @@ void *calloc(size_t nmemb, size_t size) { void *realloc(void *ptr, size_t size) { return gc_realloc(ptr, size, true); } -void abort_(void) { - printf("Aborted\n"); -} #define PLATFORM_HTONL(_n) ((uint32_t)( (((_n) & 0xff) << 24) | (((_n) & 0xff00) << 8) | (((_n) >> 8) & 0xff00) | (((_n) >> 24) & 0xff) )) #undef htonl diff --git a/esp8266/eagle.rom.addr.v6.ld b/esp8266/eagle.rom.addr.v6.ld index ce071a3bb9..1b3ce55d01 100644 --- a/esp8266/eagle.rom.addr.v6.ld +++ b/esp8266/eagle.rom.addr.v6.ld @@ -20,6 +20,7 @@ PROVIDE ( SPI_read_status = 0x400043c8 ); PROVIDE ( SPI_write_status = 0x40004400 ); PROVIDE ( SPI_write_enable = 0x4000443c ); PROVIDE ( Wait_SPI_Idle = 0x4000448c ); +PROVIDE ( Enable_QMode = 0x400044c0 ); PROVIDE ( SPIEraseArea = 0x40004b44 ); PROVIDE ( SPIEraseBlock = 0x400049b4 ); PROVIDE ( SPIEraseChip = 0x40004984 ); diff --git a/esp8266/esp8266.ld b/esp8266/esp8266.ld index 79bdf87f71..a55aff52e5 100644 --- a/esp8266/esp8266.ld +++ b/esp8266/esp8266.ld @@ -5,7 +5,7 @@ MEMORY dport0_0_seg : org = 0x3ff00000, len = 0x10 dram0_0_seg : org = 0x3ffe8000, len = 0x14000 iram1_0_seg : org = 0x40100000, len = 0x8000 - irom0_0_seg : org = 0x40209000, len = 0x80000 + irom0_0_seg : org = 0x40209000, len = 0x87000 } /* define the top of RAM */ @@ -121,6 +121,7 @@ SECTIONS *lib/fatfs/*.o*(.literal*, .text*) */libaxtls.a:(.literal*, .text*) + *lib/berkeley-db-1.xx/*.o(.literal*, .text*) *lib/libm/*.o*(.literal*, .text*) *lib/mp-readline/*.o(.literal*, .text*) *lib/netutils/*.o*(.literal*, .text*) diff --git a/esp8266/esp_mphal.c b/esp8266/esp_mphal.c index 3cc4610825..a2710af2e6 100644 --- a/esp8266/esp_mphal.c +++ b/esp8266/esp_mphal.c @@ -259,3 +259,8 @@ int ets_esf_free_bufs(int idx) { } return cnt; } + +extern int mp_stream_errno; +int *__errno() { + return &mp_stream_errno; +} diff --git a/esp8266/esp_mphal.h b/esp8266/esp_mphal.h index 91fee21198..fa52ae53a2 100644 --- a/esp8266/esp_mphal.h +++ b/esp8266/esp_mphal.h @@ -47,6 +47,12 @@ void mp_hal_init(void); void mp_hal_rtc_init(void); uint32_t mp_hal_ticks_us(void); +__attribute__((always_inline)) static inline uint32_t mp_hal_ticks_cpu(void) { + uint32_t ccount; + __asm__ __volatile__("rsr %0,ccount":"=a" (ccount)); + return ccount; +} + void mp_hal_delay_us(uint32_t); void mp_hal_set_interrupt_char(int c); uint32_t mp_hal_get_cpu_freq(void); diff --git a/esp8266/espapa102.c b/esp8266/espapa102.c index e5f3024b10..4295fe42d8 100644 --- a/esp8266/espapa102.c +++ b/esp8266/espapa102.c @@ -24,6 +24,9 @@ * THE SOFTWARE. */ +#include "py/mpconfig.h" +#if MICROPY_ESP8266_APA102 + #include <stdio.h> #include "c_types.h" #include "eagle_soc.h" @@ -108,3 +111,5 @@ void esp_apa102_write(uint8_t clockPin, uint8_t dataPin, uint8_t *pixels, uint32 _esp_apa102_append_additionial_cycles(clockPinMask, dataPinMask, numBytes); _esp_apa102_end_frame(clockPinMask, dataPinMask); } + +#endif diff --git a/esp8266/espneopixel.c b/esp8266/espneopixel.c index 26776f025e..0f12f4c820 100644 --- a/esp8266/espneopixel.c +++ b/esp8266/espneopixel.c @@ -9,16 +9,10 @@ #include "eagle_soc.h" #include "user_interface.h" #include "espneopixel.h" +#include "esp_mphal.h" #define NEO_KHZ400 (1) -static uint32_t _getCycleCount(void) __attribute__((always_inline)); -static inline uint32_t _getCycleCount(void) { - uint32_t ccount; - __asm__ __volatile__("rsr %0,ccount":"=a" (ccount)); - return ccount; -} - void /*ICACHE_RAM_ATTR*/ esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32_t numBytes, bool is800KHz) { uint8_t *p, *end, pix, mask; @@ -49,10 +43,10 @@ void /*ICACHE_RAM_ATTR*/ esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32 for(t = time0;; t = time0) { if(pix & mask) t = time1; // Bit high duration - while(((c = _getCycleCount()) - startTime) < period); // Wait for bit start + while(((c = mp_hal_ticks_cpu()) - startTime) < period); // Wait for bit start GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinMask); // Set high startTime = c; // Save start time - while(((c = _getCycleCount()) - startTime) < t); // Wait high duration + while(((c = mp_hal_ticks_cpu()) - startTime) < t); // Wait high duration GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinMask); // Set low if(!(mask >>= 1)) { // Next bit/byte if(p >= end) break; @@ -60,5 +54,5 @@ void /*ICACHE_RAM_ATTR*/ esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32 mask = 0x80; } } - while((_getCycleCount() - startTime) < period); // Wait for last bit + while((mp_hal_ticks_cpu() - startTime) < period); // Wait for last bit } diff --git a/esp8266/etshal.h b/esp8266/etshal.h index 0185a9e22c..dd61ddec93 100644 --- a/esp8266/etshal.h +++ b/esp8266/etshal.h @@ -20,6 +20,13 @@ void ets_timer_arm_new(os_timer_t *tim, uint32_t millis, bool repeat, bool is_mi void ets_timer_setfn(os_timer_t *tim, ETSTimerFunc callback, void *cb_data); void ets_timer_disarm(os_timer_t *tim); +// Opaque structure +typedef char MD5_CTX[64]; + +void MD5Init(MD5_CTX *context); +void MD5Update(MD5_CTX *context, const void *data, unsigned int len); +void MD5Final(unsigned char digest[16], MD5_CTX *context); + // These prototypes are for recent SDKs with "malloc tracking" void *pvPortMalloc(unsigned sz, const char *fname, int line); void vPortFree(void *p, const char *fname, int line); diff --git a/esp8266/main.c b/esp8266/main.c index 21bb6e0e0f..71dfeb2ac6 100644 --- a/esp8266/main.c +++ b/esp8266/main.c @@ -60,6 +60,7 @@ STATIC void mp_reset(void) { MP_STATE_PORT(dupterm_arr_obj) = MP_OBJ_NULL; pin_init0(); readline_init0(); + dupterm_task_init(); #if MICROPY_MODULE_FROZEN pyexec_frozen_module("_boot.py"); pyexec_file("boot.py"); @@ -85,7 +86,6 @@ void init_done(void) { #if MICROPY_REPL_EVENT_DRIVEN pyexec_event_repl_init(); #endif - dupterm_task_init(); #if !MICROPY_REPL_EVENT_DRIVEN soft_reset: diff --git a/esp8266/makeimg.py b/esp8266/makeimg.py index e63f956bdd..091854fa4d 100644 --- a/esp8266/makeimg.py +++ b/esp8266/makeimg.py @@ -1,23 +1,40 @@ import sys +import struct +import hashlib SEGS_MAX_SIZE = 0x9000 assert len(sys.argv) == 4 +md5 = hashlib.md5() + with open(sys.argv[3], 'wb') as fout: with open(sys.argv[1], 'rb') as f: data_flash = f.read() fout.write(data_flash) + # First 4 bytes include flash size, etc. which may be changed + # by esptool.py, etc. + md5.update(data_flash[4:]) print('flash ', len(data_flash)) + with open(sys.argv[2], 'rb') as f: + data_rom = f.read() + pad = b'\xff' * (SEGS_MAX_SIZE - len(data_flash)) - fout.write(pad) + assert len(pad) >= 4 + fout.write(pad[:-4]) + md5.update(pad[:-4]) + len_data = struct.pack("I", SEGS_MAX_SIZE + len(data_rom)) + fout.write(len_data) + md5.update(len_data) print('padding ', len(pad)) - with open(sys.argv[2], 'rb') as f: - data_rom = f.read() - fout.write(data_rom) - print('irom0text', len(data_rom)) + fout.write(data_rom) + md5.update(data_rom) + print('irom0text', len(data_rom)) + + fout.write(md5.digest()) print('total ', SEGS_MAX_SIZE + len(data_rom)) + print('md5 ', md5.hexdigest()) diff --git a/esp8266/modesp.c b/esp8266/modesp.c index 99f063a756..39cc514afc 100644 --- a/esp8266/modesp.c +++ b/esp8266/modesp.c @@ -633,6 +633,24 @@ STATIC mp_obj_t esp_flash_size(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_flash_size_obj, esp_flash_size); +STATIC mp_obj_t esp_check_fw(void) { + MD5_CTX ctx; + uint32_t *sz_p = (uint32_t*)0x40208ffc; + printf("size: %d\n", *sz_p); + MD5Init(&ctx); + MD5Update(&ctx, (char*)0x40200004, *sz_p - 4); + unsigned char digest[16]; + MD5Final(digest, &ctx); + printf("md5: "); + for (int i = 0; i < 16; i++) { + printf("%02x", digest[i]); + } + printf("\n"); + return mp_obj_new_bool(memcmp(digest, (void*)(0x40200000 + *sz_p), sizeof(digest)) == 0); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_check_fw_obj, esp_check_fw); + + STATIC mp_obj_t esp_neopixel_write_(mp_obj_t pin, mp_obj_t buf, mp_obj_t is800k) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ); @@ -642,6 +660,7 @@ STATIC mp_obj_t esp_neopixel_write_(mp_obj_t pin, mp_obj_t buf, mp_obj_t is800k) } STATIC MP_DEFINE_CONST_FUN_OBJ_3(esp_neopixel_write_obj, esp_neopixel_write_); +#if MICROPY_ESP8266_APA102 STATIC mp_obj_t esp_apa102_write_(mp_obj_t clockPin, mp_obj_t dataPin, mp_obj_t buf) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ); @@ -651,6 +670,7 @@ STATIC mp_obj_t esp_apa102_write_(mp_obj_t clockPin, mp_obj_t dataPin, mp_obj_t return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(esp_apa102_write_obj, esp_apa102_write_); +#endif STATIC mp_obj_t esp_freemem() { return MP_OBJ_NEW_SMALL_INT(system_get_free_heap_size()); @@ -695,10 +715,13 @@ STATIC const mp_map_elem_t esp_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_getaddrinfo), (mp_obj_t)&esp_getaddrinfo_obj }, #endif { MP_OBJ_NEW_QSTR(MP_QSTR_neopixel_write), (mp_obj_t)&esp_neopixel_write_obj }, + #if MICROPY_ESP8266_APA102 { MP_OBJ_NEW_QSTR(MP_QSTR_apa102_write), (mp_obj_t)&esp_apa102_write_obj }, + #endif { MP_OBJ_NEW_QSTR(MP_QSTR_dht_readinto), (mp_obj_t)&dht_readinto_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_freemem), (mp_obj_t)&esp_freemem_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_meminfo), (mp_obj_t)&esp_meminfo_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_check_fw), (mp_obj_t)&esp_check_fw_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_info), (mp_obj_t)&pyb_info_obj }, // TODO delete/rename/move elsewhere { MP_OBJ_NEW_QSTR(MP_QSTR_malloc), (mp_obj_t)&esp_malloc_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_free), (mp_obj_t)&esp_free_obj }, diff --git a/esp8266/modmachine.c b/esp8266/modmachine.c index 80ae7ac2a0..b3a42618e5 100644 --- a/esp8266/modmachine.c +++ b/esp8266/modmachine.c @@ -26,6 +26,7 @@ */ #include <stdint.h> +#include <stdio.h> #include "py/obj.h" #include "py/runtime.h" @@ -82,6 +83,18 @@ STATIC mp_obj_t machine_unique_id(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_unique_id_obj, machine_unique_id); +STATIC mp_obj_t machine_idle(void) { + asm("waiti 0"); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_idle_obj, machine_idle); + +STATIC mp_obj_t machine_sleep(void) { + printf("Warning: not yet implemented\n"); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_sleep_obj, machine_sleep); + STATIC mp_obj_t machine_deepsleep(void) { // default to sleep forever uint32_t sleep_us = 0; @@ -222,6 +235,8 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_reset_cause), MP_ROM_PTR(&machine_reset_cause_obj) }, { MP_ROM_QSTR(MP_QSTR_unique_id), MP_ROM_PTR(&machine_unique_id_obj) }, + { MP_ROM_QSTR(MP_QSTR_idle), MP_ROM_PTR(&machine_idle_obj) }, + { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&machine_sleep_obj) }, { MP_ROM_QSTR(MP_QSTR_deepsleep), MP_ROM_PTR(&machine_deepsleep_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) }, diff --git a/esp8266/modpybuart.c b/esp8266/modpybuart.c index f27ee4e2d2..25320fa1e7 100644 --- a/esp8266/modpybuart.c +++ b/esp8266/modpybuart.c @@ -112,9 +112,11 @@ STATIC void pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const mp_o if (args[ARG_parity].u_obj != MP_OBJ_NULL) { if (args[ARG_parity].u_obj == mp_const_none) { UartDev.parity = UART_NONE_BITS; + UartDev.exist_parity = UART_STICK_PARITY_DIS; self->parity = 0; } else { mp_int_t parity = mp_obj_get_int(args[ARG_parity].u_obj); + UartDev.exist_parity = UART_STICK_PARITY_EN; if (parity & 1) { UartDev.parity = UART_ODD_BITS; self->parity = 1; diff --git a/esp8266/modules/_boot.py b/esp8266/modules/_boot.py index 2cacb56760..c200b3d3f9 100644 --- a/esp8266/modules/_boot.py +++ b/esp8266/modules/_boot.py @@ -1,4 +1,5 @@ import gc +gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4) import uos from flashbdev import bdev diff --git a/esp8266/modules/flashbdev.py b/esp8266/modules/flashbdev.py index 07ed966020..98b0208fb6 100644 --- a/esp8266/modules/flashbdev.py +++ b/esp8266/modules/flashbdev.py @@ -3,8 +3,8 @@ import esp class FlashBdev: SEC_SIZE = 4096 - START_SEC = 0x89000 // SEC_SIZE - NUM_BLK = 0x73 + START_SEC = 0x90000 // SEC_SIZE + NUM_BLK = 0x6b def __init__(self, blocks=NUM_BLK): self.blocks = blocks @@ -64,5 +64,5 @@ size = esp.flash_size() if size < 1024*1024: bdev = None else: - # 16K at the flash end is reserved for SDK params storage - bdev = FlashBdev((size - 16384) // FlashBdev.SEC_SIZE - FlashBdev.START_SEC) + # 20K at the flash end is reserved for SDK params storage + bdev = FlashBdev((size - 20480) // FlashBdev.SEC_SIZE - FlashBdev.START_SEC) diff --git a/esp8266/moduos.c b/esp8266/moduos.c index 74262d86b1..af149625d6 100644 --- a/esp8266/moduos.c +++ b/esp8266/moduos.c @@ -95,6 +95,11 @@ STATIC mp_obj_t os_mkdir(mp_obj_t path_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_mkdir_obj, os_mkdir); +STATIC mp_obj_t os_rmdir(mp_obj_t path_in) { + return vfs_proxy_call(MP_QSTR_rmdir, 1, &path_in); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_rmdir_obj, os_rmdir); + STATIC mp_obj_t os_chdir(mp_obj_t path_in) { return vfs_proxy_call(MP_QSTR_chdir, 1, &path_in); } @@ -155,6 +160,7 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) }, { MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&os_listdir_obj) }, { MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&os_mkdir_obj) }, + { MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&os_rmdir_obj) }, { MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&os_chdir_obj) }, { MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&os_getcwd_obj) }, { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&os_remove_obj) }, diff --git a/esp8266/modutime.c b/esp8266/modutime.c index 356785d3a9..bf56feb5ce 100644 --- a/esp8266/modutime.c +++ b/esp8266/modutime.c @@ -134,8 +134,7 @@ STATIC mp_obj_t time_ticks_us(void) { STATIC MP_DEFINE_CONST_FUN_OBJ_0(time_ticks_us_obj, time_ticks_us); STATIC mp_obj_t time_ticks_cpu(void) { - // TODO - return MP_OBJ_NEW_SMALL_INT(0 & MP_SMALL_INT_POSITIVE_MASK); + return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_cpu() & MP_SMALL_INT_POSITIVE_MASK); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(time_ticks_cpu_obj, time_ticks_cpu); diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h index 90dbc00098..7b3558ffc2 100644 --- a/esp8266/mpconfigport.h +++ b/esp8266/mpconfigport.h @@ -72,7 +72,10 @@ #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) +#define MICROPY_WARNINGS (1) +#define MICROPY_PY_STR_BYTES_CMP_WARN (1) #define MICROPY_STREAMS_NON_BLOCK (1) +#define MICROPY_STREAMS_POSIX_API (1) #define MICROPY_MODULE_FROZEN_STR (1) #define MICROPY_MODULE_FROZEN_MPY (1) #define MICROPY_MODULE_FROZEN_LEXER mp_lexer_new_from_str32 @@ -85,6 +88,7 @@ #define MICROPY_FATFS_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */ #define MICROPY_FSUSERMOUNT (1) #define MICROPY_VFS_FAT (1) +#define MICROPY_ESP8266_APA102 (1) #define MICROPY_EVENT_POLL_HOOK {ets_event_poll();} #define MICROPY_VM_HOOK_COUNT (10) @@ -114,6 +118,8 @@ typedef void *machine_ptr_t; // must be of pointer size typedef const void *machine_const_ptr_t; // must be of pointer size typedef long mp_off_t; typedef uint32_t sys_prot_t; // for modlwip +// ssize_t, off_t as required by POSIX-signatured functions in stream.h +#include <sys/types.h> #define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len) diff --git a/esp8266/scripts/inisetup.py b/esp8266/scripts/inisetup.py index 7d8f6fa0a8..1cb9f0dd95 100644 --- a/esp8266/scripts/inisetup.py +++ b/esp8266/scripts/inisetup.py @@ -40,6 +40,8 @@ def setup(): with open("/boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) +#import esp +#esp.osdebug(None) import gc #import webrepl #webrepl.start() diff --git a/esp8266/scripts/port_diag.py b/esp8266/scripts/port_diag.py index aa696b1abb..f2abd8066d 100644 --- a/esp8266/scripts/port_diag.py +++ b/esp8266/scripts/port_diag.py @@ -17,6 +17,8 @@ def main(): FREQ_MAP = {0: "40MHZ", 1: "26MHZ", 2: "20MHz", 0xf: "80MHz"} print("Byte @2: %02x" % ROM[2]) print("Byte @3: %02x (Flash size: %s Flash freq: %s)" % (ROM[3], SZ_MAP.get(ROM[3] >> 4, "?"), FREQ_MAP.get(ROM[3] & 0xf))) + print("Firmware checksum:") + print(esp.check_fw()) print("\nNetworking:") print("STA ifconfig:", network.WLAN(network.STA_IF).ifconfig()) diff --git a/esp8266/uart.h b/esp8266/uart.h index 21894d3fa6..2b97683ff8 100644 --- a/esp8266/uart.h +++ b/esp8266/uart.h @@ -1,6 +1,8 @@ #ifndef _INCLUDED_UART_H_ #define _INCLUDED_UART_H_ +#include <eagle_soc.h> + #define UART0 (0) #define UART1 (1) @@ -18,14 +20,14 @@ typedef enum { } UartStopBitsNum; typedef enum { - UART_NONE_BITS = 0, - UART_ODD_BITS = 0, - UART_EVEN_BITS = BIT4 + UART_NONE_BITS = 0, + UART_ODD_BITS = BIT0, + UART_EVEN_BITS = 0 } UartParityMode; typedef enum { UART_STICK_PARITY_DIS = 0, - UART_STICK_PARITY_EN = BIT3 | BIT5 + UART_STICK_PARITY_EN = BIT1 } UartExistParity; typedef enum { |