46
46
# MINISTM32_STRIVE=1
47
47
# MINISTM32_ANGLED_VE=1
48
48
# MINISTM32_ANGLED_VG=1
49
+ # ESP8266_BOARD=1 # ESP8266 from Espressif
49
50
# Or nothing for standard linux compile
50
51
#
51
52
# Also:
60
61
#
61
62
#
62
63
# WIZNET=1 # If compiling for a non-linux target that has internet support, use WIZnet support, not TI CC3000
63
-
64
64
ifndef SINGLETHREAD
65
65
MAKEFLAGS =-j5 # multicore
66
66
endif
@@ -417,6 +417,20 @@ BOARD=LCTECH_STM32F103RBT6
417
417
STLIB =STM32F10X_MD
418
418
PRECOMPILED_OBJS+ =$(ROOT ) /targetlibs/stm32f1/lib/startup_stm32f10x_md.o
419
419
OPTIMIZEFLAGS+ =-Os
420
+ else ifdef ESP8266_BOARD
421
+ USE_NET =1
422
+ EMBEDDED =1
423
+ BOARD =ESP8266_BOARD
424
+ OPTIMIZEFLAGS+ =-Os
425
+ LIBS += -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lmain
426
+ CFLAGS+=-std =gnu99 \
427
+ -Wno-maybe-uninitialized -Wno-old-style-declaration -Wno-conversion -Wno-unused-variable \
428
+ -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-discarded-qualifiers -Wno-float-conversion \
429
+ -Wno-parentheses -Wno-type-limits -Wno-unused-function -Wno-unused-value \
430
+ -fno-builtin -fno-strict-aliasing -fno-inline-functions \
431
+ -Wl,EL -nostdlib \
432
+ -mlongcalls -mtext-section-literals \
433
+ -D__ETS__ -DICACHE_FLASH
420
434
else
421
435
ifeq ($(shell uname -m) ,armv6l)
422
436
RASPBERRYPI =1 # just a guess
@@ -519,10 +533,14 @@ ifndef LINUX
519
533
ifdef WIZNET
520
534
USE_WIZNET =1
521
535
else
536
+ ifdef ESP8266_BOARD
537
+ USE_ESP8266_BOARD =1
538
+ else
522
539
USE_CC3000 =1
523
540
endif
524
541
endif
525
542
endif
543
+ endif
526
544
527
545
ifdef DEBUG
528
546
# OPTIMIZEFLAGS=-Os -g
@@ -777,6 +795,14 @@ libs/network/js/network_js.c
777
795
libs/network/wiznet/Ethernet/socket.c \
778
796
libs/network/wiznet/W5500/w5500.c
779
797
endif
798
+
799
+ ifdef USE_ESP8266
800
+ DEFINES += -DUSE_ESP8266
801
+ WRAPPERSOURCES += libs/network/esp8266/jswrap_esp8266.c
802
+ INCLUDE += -I$(ROOT ) /libs/network/esp8266
803
+ SOURCES += \
804
+ libs/network/esp8266/network_esp8266.c
805
+ endif
780
806
endif
781
807
782
808
ifdef USE_TV
@@ -1217,6 +1243,51 @@ ifdef NRF5X
1217
1243
LDFLAGS += --specs=nano.specs -lc -lnosys
1218
1244
endif # NRF5X
1219
1245
1246
+ #
1247
+ # Definitions for the build of the ESP8266
1248
+ #
1249
+ ifdef ESP8266_BOARD
1250
+ # The Root of the ESP8266_SDK distributed by Espressif
1251
+ # This must be supplied as a Make environment variable.
1252
+ ifndef ESP8266_SDK_ROOT
1253
+ $(error, "The ESP8266_SDK_ROOT variable must be set")
1254
+ endif
1255
+
1256
+ # The pefix for the xtensa toolchain
1257
+ CCPREFIX =xtensa-lx106-elf-
1258
+
1259
+ # Extra flags passed to the linker
1260
+ LDFLAGS += -L$(ESP8266_SDK_ROOT ) /lib \
1261
+ -Ttargets/esp8266/eagle.app.v6.0x10000.ld \
1262
+ -nostdlib \
1263
+ -Wl,--no-check-sections \
1264
+ -u call_user_start \
1265
+ -Wl,-static
1266
+
1267
+ # Extra source files specific to the ESP8266 board
1268
+ SOURCES += targets/esp8266/uart.c \
1269
+ targets/esp8266/user_main.c \
1270
+ targets/esp8266/jshardware.c \
1271
+ targets/esp8266/esp8266_board_utils.c \
1272
+ libs/network/esp8266/network_esp8266.c
1273
+
1274
+ # The tool used for building the firmware and flashing
1275
+ ESPTOOL_CK ?= esptool-ck
1276
+ ESPTOOL ?= esptool
1277
+
1278
+ # Extra include directories specific to the ESP8266
1279
+ INCLUDE += -I$(ESP8266_SDK_ROOT ) /include \
1280
+ -I$(ROOT ) /targets/esp8266 \
1281
+ -I$(ROOT ) /libs/network/esp8266
1282
+
1283
+ WRAPPERSOURCES += libs/network/esp8266/jswrap_esp8266.c
1284
+
1285
+ # Specify the defines
1286
+ DEFINES += -DXTENSA -DUSE_ESP8266_BOARD
1287
+
1288
+ # End of ESP8266 definitions
1289
+ endif # ESP8266_BOARD
1290
+
1220
1291
export CC =$(CCPREFIX ) gcc
1221
1292
export LD =$(CCPREFIX ) gcc
1222
1293
export AR =$(CCPREFIX ) ar
@@ -1263,7 +1334,11 @@ $(PLATFORM_CONFIG_FILE): boards/$(BOARD).py scripts/build_platform_config.py
1263
1334
$(Q ) python scripts/build_platform_config.py $(BOARD )
1264
1335
1265
1336
compile =$(CC ) $(CFLAGS ) $(DEFINES ) $< -o $@
1337
+ ifndef ESP8266_BOARD
1266
1338
link =$(LD ) $(LDFLAGS ) -o $@ $(OBJS ) $(LIBS )
1339
+ else
1340
+ link =$(LD ) $(LDFLAGS ) -o $@ -Wl,--start-group $(OBJS ) $(LIBS ) -Wl,--end-group
1341
+ endif
1267
1342
obj_dump =$(OBJDUMP ) -x -S $(PROJ_NAME ) .elf > $(PROJ_NAME ) .lst
1268
1343
obj_to_bin =$(OBJCOPY ) -O $1 $(PROJ_NAME ) .elf $(PROJ_NAME ) .$2
1269
1344
@@ -1275,6 +1350,9 @@ quiet_obj_to_bin= GEN $(PROJ_NAME).$2
1275
1350
% .o : % .c $(PLATFORM_CONFIG_FILE ) $(PININFOFILE ) .h
1276
1351
@echo $($(quiet_ ) compile)
1277
1352
@$(call compile)
1353
+ ifdef ESP8266_BOARD
1354
+ $(OBJCOPY) --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal $@
1355
+ endif
1278
1356
1279
1357
.cpp.o : $(PLATFORM_CONFIG_FILE ) $(PININFOFILE ) .h
1280
1358
@echo $($(quiet_ ) compile)
@@ -1316,7 +1394,16 @@ ifndef TRAVIS
1316
1394
bash scripts/check_size.sh $(PROJ_NAME).bin
1317
1395
endif
1318
1396
1397
+ ifndef ESP8266_BOARD
1319
1398
proj : $(PROJ_NAME ) .lst $(PROJ_NAME ) .bin $(PROJ_NAME ) .hex
1399
+ else
1400
+ proj : $(PROJ_NAME ) .elf
1401
+ endif
1402
+
1403
+ ifdef ARDUINO_AVR
1404
+ proj : $(PROJ_NAME ) .hex
1405
+ endif
1406
+
1320
1407
# proj: $(PROJ_NAME).lst $(PROJ_NAME).hex $(PROJ_NAME).srec $(PROJ_NAME).bin
1321
1408
1322
1409
flash : all
@@ -1330,6 +1417,16 @@ else ifdef OLIMEXINO_STM32_BOOTLOADER
1330
1417
else ifdef NUCLEO
1331
1418
if [ -d "/media/$(USER)/NUCLEO" ]; then cp $(PROJ_NAME).bin /media/$(USER)/NUCLEO;sync; fi
1332
1419
if [ -d "/media/NUCLEO" ]; then cp $(PROJ_NAME).bin /media/NUCLEO;sync; fi
1420
+ else ifdef ESP8266_BOARD
1421
+ ifndef COMPORT
1422
+ $(error, "In order to flash, we need to have the COMPORT variable defined")
1423
+ endif
1424
+ # Handle ESP8266 flashing
1425
+ @echo Disass: $(OBJDUMP) -d -l -x $(PROJ_NAME).elf
1426
+ -$(Q)$(ESPTOOL_CK) -eo $(PROJ_NAME).elf -bo ESP8266_0x00000.bin -bs .text -bs .data -bs .rodata -bs .iram0.text -bc -ec
1427
+ -$(Q)$(ESPTOOL_CK) -eo $(PROJ_NAME).elf -es .irom0.text ESP8266_0x10000.bin -ec
1428
+ -$(Q)$(ESPTOOL) --port $(COMPORT) --baud 115200 write_flash --flash_freq 40m --flash_mode qio --flash_size 4m 0x00000 ESP8266_0x00000.bin 0x10000 ESP8266_0x10000.bin
1429
+ # End of handle ESP8266 flashing
1333
1430
else
1334
1431
echo ST-LINK flash
1335
1432
st-flash --reset write $(PROJ_NAME).bin $(BASEADDRESS)
0 commit comments