diff --git a/boards.txt b/boards.txt index 3faf8b2ba..e2b1c4384 100644 --- a/boards.txt +++ b/boards.txt @@ -1,7 +1,7 @@ ############################################################## esp01.name=ESP-01 -esp01.upload.tool=esptool +esp01.upload.tool=esptoolpy esp01.upload.speed=57600 esp01.upload.wait_for_upload_port=true diff --git a/cores/esp8266/HardwareSerial.cpp b/cores/esp8266/HardwareSerial.cpp index 9708f7d91..ca174b974 100644 --- a/cores/esp8266/HardwareSerial.cpp +++ b/cores/esp8266/HardwareSerial.cpp @@ -208,15 +208,25 @@ void serial_rx_handler(char c) { Serial._rx_complete_irq(c); } +extern "C" size_t ets_printf(const char*, ...); + +HardwareSerial::HardwareSerial() : + _rx_buffer_head(0), _rx_buffer_tail(0), + _tx_buffer_head(0), _tx_buffer_tail(0), + _uart(0) +{ +} void HardwareSerial::begin(unsigned long baud, byte config) { _uart = uart0_init(baud, &serial_rx_handler); + _written = false; } void HardwareSerial::end() { uart0_uninit(_uart); + _uart = 0; } int HardwareSerial::available(void) @@ -263,7 +273,7 @@ void HardwareSerial::flush() size_t HardwareSerial::write(uint8_t c) { - WRITE_PERI_REG(UART_FIFO(0), c); + uart0_transmit_char(_uart, c); // // If the buffer and the data register is empty, just write the byte // // to the data register and be done. This shortcut helps // // significantly improve the effective datarate at high (> @@ -294,9 +304,9 @@ size_t HardwareSerial::write(uint8_t c) // _tx_buffer_head = i; // sbi(*_ucsrb, UDRIE0); - // _written = true; + _written = true; - // return 1; + return 1; } void HardwareSerial::_rx_complete_irq(char c) diff --git a/cores/esp8266/HardwareSerial.h b/cores/esp8266/HardwareSerial.h index 8c4810fc3..1311c0939 100644 --- a/cores/esp8266/HardwareSerial.h +++ b/cores/esp8266/HardwareSerial.h @@ -80,7 +80,7 @@ class HardwareSerial : public Stream unsigned char _tx_buffer[SERIAL_TX_BUFFER_SIZE]; public: - HardwareSerial() : _uart(0) { } + HardwareSerial(); void begin(unsigned long baud) { begin(baud, 0); } void begin(unsigned long, uint8_t); diff --git a/cores/esp8266/main.cpp b/cores/esp8266/main.cpp index c77762656..7a2c26273 100644 --- a/cores/esp8266/main.cpp +++ b/cores/esp8266/main.cpp @@ -114,7 +114,7 @@ void user_init(void) g_loop_queue, LOOP_QUEUE_SIZE); - system_init_done_cb(&esp_schedule); + system_init_done_cb(&init_done); } } diff --git a/platform.txt b/platform.txt index 70c9f4a0f..0349451df 100644 --- a/platform.txt +++ b/platform.txt @@ -80,9 +80,9 @@ recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).* # ------------------------------ -tools.esptoolpy.cmd.path={runtime.ide.path}/hardware/tools/esptool.py +tools.esptoolpy.cmd.path={runtime.ide.path}/hardware/tools/esp8266/espflash tools.esptoolpy.program.params.verbose= tools.esptoolpy.program.params.quiet= -tools.esptoolpy.program.pattern="python {cmd.path}" --port={serial.port} write_flash 0x00000 "{build.path}/{build.project_name}._00000.bin" +tools.esptoolpy.program.pattern="{cmd.path}" --port={serial.port} write_flash 0x00000 "{build.path}/{build.project_name}_00000.bin" 0x40000 "{build.path}/{build.project_name}_40000.bin"