Skip to content

Commit

Permalink
Merge pull request #2 from esp8266/esp8266
Browse files Browse the repository at this point in the history
merged
  • Loading branch information
Makuna committed May 29, 2015
2 parents 63f9129 + 5465f70 commit bca0997
Show file tree
Hide file tree
Showing 42 changed files with 1,113 additions and 195 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ Libraries that don't rely on low-level access to AVR registers should work well.
- [NeoPixelBus](https://github.com/Makuna/NeoPixelBus) - Arduino NeoPixel library compatible with esp8266.
- [RTC](https://github.com/Makuna/Rtc) - Arduino Library for Ds1307 & Ds3231 compatible with esp8266.
- [Blynk](https://github.com/blynkkk/blynk-library) - easy IoT framework for Makers (check out the [Kickstarter page](http://tiny.cc/blynk-kick)).
- [arduinoWebSockets](https://github.com/Links2004/arduinoWebSockets) - WebSocket Server and Client compatible with esp8266 (RFC6455)

#### Upload via serial port ####
Pick the correct serial port.
Expand Down
70 changes: 56 additions & 14 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ generic.name=Generic ESP8266 Module
generic.upload.tool=esptool
generic.upload.speed=115200
generic.upload.resetmethod=ck
generic.upload.maximum_size=372736
generic.upload.maximum_size=434160
generic.upload.maximum_data_size=81920
generic.upload.wait_for_upload_port=true
generic.serial.disableDTR=true
Expand Down Expand Up @@ -59,55 +59,55 @@ generic.menu.FlashSize.512K.build.flash_ld=eagle.flash.512k.ld
generic.menu.FlashSize.512K.build.spiffs_start=0x6B000
generic.menu.FlashSize.512K.build.spiffs_end=0x7B000
generic.menu.FlashSize.512K.build.spiffs_blocksize=4096
generic.menu.FlashSize.512K.upload.maximum_size=372736
generic.menu.FlashSize.512K.upload.maximum_size=434160

generic.menu.FlashSize.1M512=1M (512K SPIFFS)
generic.menu.FlashSize.1M512.build.flash_size=1M
generic.menu.FlashSize.1M512.build.flash_ld=eagle.flash.1m512.ld
generic.menu.FlashSize.1M512.build.spiffs_start=0x6B000
generic.menu.FlashSize.1M512.build.spiffs_start=0x7B000
generic.menu.FlashSize.1M512.build.spiffs_end=0xFB000
generic.menu.FlashSize.1M512.build.spiffs_blocksize=8192
generic.menu.FlashSize.1M512.upload.maximum_size=438272
generic.menu.FlashSize.1M512.upload.maximum_size=499696

generic.menu.FlashSize.1M256=1M (256K SPIFFS)
generic.menu.FlashSize.1M256.build.flash_size=1M
generic.menu.FlashSize.1M256.build.flash_ld=eagle.flash.1m256.ld
generic.menu.FlashSize.1M256.build.spiffs_start=0xAB000
generic.menu.FlashSize.1M256.build.spiffs_start=0xBB000
generic.menu.FlashSize.1M256.build.spiffs_end=0xFB000
generic.menu.FlashSize.1M256.build.spiffs_blocksize=4096
generic.menu.FlashSize.1M256.upload.maximum_size=700416
generic.menu.FlashSize.1M256.upload.maximum_size=761840

generic.menu.FlashSize.1M128=1M (128K SPIFFS)
generic.menu.FlashSize.1M128.build.flash_size=1M
generic.menu.FlashSize.1M128.build.flash_ld=eagle.flash.1m128.ld
generic.menu.FlashSize.1M128.build.spiffs_start=0xCB000
generic.menu.FlashSize.1M128.build.spiffs_start=0xDB000
generic.menu.FlashSize.1M128.build.spiffs_end=0xFB000
generic.menu.FlashSize.1M128.build.spiffs_blocksize=4096
generic.menu.FlashSize.1M128.upload.maximum_size=831488
generic.menu.FlashSize.1M128.upload.maximum_size=892912

generic.menu.FlashSize.1M64=1M (64K SPIFFS)
generic.menu.FlashSize.1M64.build.flash_size=1M
generic.menu.FlashSize.1M64.build.flash_ld=eagle.flash.1m64.ld
generic.menu.FlashSize.1M64.build.spiffs_start=0xEB000
generic.menu.FlashSize.1M64.build.spiffs_end=0xFB000
generic.menu.FlashSize.1M64.build.spiffs_blocksize=4096
generic.menu.FlashSize.1M64.upload.maximum_size=897024
generic.menu.FlashSize.1M64.upload.maximum_size=958448

generic.menu.FlashSize.2M=2M (1M SPIFFS)
generic.menu.FlashSize.2M.build.flash_size=2M
generic.menu.FlashSize.2M.build.flash_ld=eagle.flash.2m.ld
generic.menu.FlashSize.2M.build.spiffs_start=0x100000
generic.menu.FlashSize.2M.build.spiffs_end=0x1FB000
generic.menu.FlashSize.2M.build.spiffs_blocksize=8192
generic.menu.FlashSize.2M.upload.maximum_size=983040
generic.menu.FlashSize.2M.upload.maximum_size=1044464

generic.menu.FlashSize.4M=4M (3M SPIFFS)
generic.menu.FlashSize.4M.build.flash_size=4M
generic.menu.FlashSize.4M.build.flash_ld=eagle.flash.4m.ld
generic.menu.FlashSize.4M.build.spiffs_start=0x100000
generic.menu.FlashSize.4M.build.spiffs_end=0x3FB000
generic.menu.FlashSize.4M.build.spiffs_blocksize=8192
generic.menu.FlashSize.4M.upload.maximum_size=983040
generic.menu.FlashSize.4M.upload.maximum_size=1044464

# disabled because espressif's bootloader refuses to write above 4M
# generic.menu.FlashSize.8M=8M (7M SPIFFS)
Expand All @@ -134,7 +134,7 @@ modwifi.name=Olimex MOD-WIFI-ESP8266(-DEV)
modwifi.upload.tool=esptool
modwifi.upload.speed=115200
modwifi.upload.resetmethod=ck
modwifi.upload.maximum_size=983040
modwifi.upload.maximum_size=1044464
modwifi.upload.maximum_data_size=81920
modwifi.upload.wait_for_upload_port=true
modwifi.serial.disableDTR=true
Expand Down Expand Up @@ -186,7 +186,7 @@ nodemcu.name=NodeMCU 0.9 (ESP-12 Module)
nodemcu.upload.tool=esptool
nodemcu.upload.speed=115200
nodemcu.upload.resetmethod=ck
nodemcu.upload.maximum_size=983040
nodemcu.upload.maximum_size=1044464
nodemcu.upload.maximum_data_size=81920
nodemcu.upload.wait_for_upload_port=true
nodemcu.serial.disableDTR=true
Expand Down Expand Up @@ -237,7 +237,7 @@ nodemcuv2.name=NodeMCU 1.0 (ESP-12E Module)
nodemcuv2.upload.tool=esptool
nodemcuv2.upload.speed=115200
nodemcuv2.upload.resetmethod=ck
nodemcuv2.upload.maximum_size=983040
nodemcuv2.upload.maximum_size=1044464
nodemcuv2.upload.maximum_data_size=81920
nodemcuv2.upload.wait_for_upload_port=true
nodemcuv2.serial.disableDTR=true
Expand Down Expand Up @@ -282,6 +282,48 @@ nodemcuv2.menu.UploadSpeed.512000.upload.speed=512000
nodemcuv2.menu.UploadSpeed.921600=921600
nodemcuv2.menu.UploadSpeed.921600.upload.speed=921600

##############################################################
huzzah.name=Adafruit HUZZAH ESP8266

huzzah.upload.tool=esptool
huzzah.upload.speed=115200
huzzah.upload.resetmethod=ck
huzzah.upload.maximum_size=1044464
huzzah.upload.maximum_data_size=81920
huzzah.upload.wait_for_upload_port=true
huzzah.serial.disableDTR=true
huzzah.serial.disableRTS=true

huzzah.build.mcu=esp8266
huzzah.build.f_cpu=80000000L
huzzah.build.board=ESP8266_ESP12
huzzah.build.core=esp8266
huzzah.build.variant=adafruit
huzzah.build.flash_mode=qio
huzzah.build.flash_size=4M
huzzah.build.flash_freq=40
huzzah.build.flash_ld=eagle.flash.4m.ld
huzzah.build.spiffs_start=0x100000
huzzah.build.spiffs_end=0x3FB000
huzzah.build.spiffs_pagesize=256
huzzah.build.spiffs_blocksize=8192

huzzah.menu.CpuFrequency.80=80 MHz
huzzah.menu.CpuFrequency.80.build.f_cpu=80000000L
huzzah.menu.CpuFrequency.160=160 MHz
huzzah.menu.CpuFrequency.160.build.f_cpu=160000000L

huzzah.menu.UploadSpeed.115200=115200
huzzah.menu.UploadSpeed.115200.upload.speed=115200
huzzah.menu.UploadSpeed.9600=9600
huzzah.menu.UploadSpeed.9600.upload.speed=9600
huzzah.menu.UploadSpeed.57600=57600
huzzah.menu.UploadSpeed.57600.upload.speed=57600
huzzah.menu.UploadSpeed.256000=256000
huzzah.menu.UploadSpeed.256000.upload.speed=256000
huzzah.menu.UploadSpeed.921600=921600
huzzah.menu.UploadSpeed.921600.upload.speed=921600

##############################################################
# wifio.name=Wifio
#
Expand Down
26 changes: 26 additions & 0 deletions bootloaders/eboot/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2015 Ivan Grokhotkov
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The name of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.

Authors: Ivan Grokhotkov
50 changes: 50 additions & 0 deletions bootloaders/eboot/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
XTENSA_TOOCHAIN ?=

BIN_DIR := ./
TARGET_DIR := ./

TARGET_OBJ_FILES := \
eboot.o \

TARGET_OBJ_PATHS := $(addprefix $(TARGET_DIR)/,$(TARGET_OBJ_FILES))

CC := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-gcc
CXX := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-g++
AR := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-ar
LD := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-gcc
OBJDUMP := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-objdump


CFLAGS += -std=gnu99

CFLAGS += -O0 -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mno-text-section-literals

LDFLAGS += -nostdlib -Wl,--no-check-sections -umain

LD_SCRIPT := -Teboot.ld

APP_OUT:= eboot.elf
APP_AR := eboot.a
APP_FW := eboot.bin

all: $(APP_FW)

$(APP_AR): $(TARGET_OBJ_PATHS)
$(AR) cru $@ $^


$(APP_OUT): $(APP_AR)
$(LD) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group -Wl,--whole-archive $(APP_AR) -Wl,--end-group -o $@

$(APP_FW): $(APP_OUT)
$(ESPTOOL) -vvv -eo $(APP_OUT) -bo $@ -bs .text -bs .data -bs .rodata -bc -ec || true


clean:
rm -f *.o
rm -f $(APP_AR)
rm -f $(APP_OUT)


.PHONY: all clean default

86 changes: 86 additions & 0 deletions bootloaders/eboot/eboot.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
* This file is part of eboot bootloader.
*
* Redistribution and use is permitted according to the conditions of the
* 3-clause BSD license to be found in the LICENSE file.
*/


#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "eboot.h"
extern void* flashchip;

#define SWRST do { (*((volatile uint32_t*) 0x60000700)) |= 0x80000000; } while(0);


int load_app_from_flash_raw(const uint32_t flash_addr)
{
image_header_t image_header;
uint32_t pos = flash_addr + APP_START_OFFSET;

if (SPIRead(pos, &image_header, sizeof(image_header))) {
return 1;
}
pos += sizeof(image_header);


for (uint32_t section_index = 0;
section_index < image_header.num_segments;
++section_index)
{
section_header_t section_header = {0};
if (SPIRead(pos, &section_header, sizeof(section_header))) {
return 2;
}
pos += sizeof(section_header);

const uint32_t address = section_header.address;

bool load = false;

if (address < 0x40000000) {
load = true;
}

if (address >= 0x40100000 && address < 0x40108000) {
load = true;
}

if (address >= 0x60000000) {
load = true;
}

if (!load) {
pos += section_header.size;
continue;
}

if (SPIRead(pos, (void*)address, section_header.size))
return 3;

pos += section_header.size;
}

register uint32_t sp asm("a1") = 0x3ffffff0;
register uint32_t pc asm("a3") = image_header.entry;
__asm__ __volatile__ ("jx a3");

return 0;
}


void main()
{
int res = load_app_from_flash_raw(0);
if (res) {
ets_putc('\n');
ets_putc('#');
ets_putc('0' + res);
ets_putc('\n');
SWRST;
}

while(true){}
}
Binary file added bootloaders/eboot/eboot.elf
Binary file not shown.
41 changes: 41 additions & 0 deletions bootloaders/eboot/eboot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
* This file is part of eboot bootloader.
*
* Redistribution and use is permitted according to the conditions of the
* 3-clause BSD license to be found in the LICENSE file.
*/

#ifndef EBOOT_H
#define EBOOT_H


int SPIEraseBlock(uint32_t block);
int SPIEraseSector(uint32_t sector);
int SPIRead(uint32_t addr, void *dest, size_t size);
int SPIWrite(uint32_t addr, void *src, size_t size);

#define APP_START_OFFSET 0x1000

typedef struct {
unsigned char magic;
unsigned char num_segments;

/* SPI Flash Interface (0 = QIO, 1 = QOUT, 2 = DIO, 0x3 = DOUT) */
unsigned char flash_mode;

/* High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M,
Low four bits: 0 = 40MHz, 1= 26MHz, 2 = 20MHz, 0xf = 80MHz */
unsigned char flash_size_freq;

uint32_t entry;
} image_header_t;


typedef struct {
uint32_t address;
uint32_t size;
} section_header_t;



#endif //EBOOT_H
Loading

0 comments on commit bca0997

Please sign in to comment.