Skip to content

Commit

Permalink
move update api to sming core, choose rboot/standard build by variable
Browse files Browse the repository at this point in the history
  • Loading branch information
raburton committed Sep 10, 2015
1 parent 13327c9 commit eb7c055
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 44 deletions.
6 changes: 5 additions & 1 deletion Basic_rBoot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ $(error ESP_HOME is not set. Please configure it in Makefile-user.mk)
endif

# Include main Sming Makefile
include $(SMING_HOME)/Makefile-rboot.mk
ifeq ($(RBOOT_ENABLED), 1)
include $(SMING_HOME)/Makefile-rboot.mk
else
include $(SMING_HOME)/Makefile-project.mk
endif
42 changes: 27 additions & 15 deletions Basic_rBoot/Makefile-user.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,31 @@ MODULES = app
# Com port speed
# COM_SPEED = 115200

# overridable rBoot options
RBOOT_BIG_FLASH = 1
SPIFF_SIZE = 65536
SPI_SIZE = 4M
#RBOOT_ROM_0 = rom0
#RBOOT_LD_0 = rom0.ld
#RBOOT_TWO_ROMS = 1
# these next options only needed when using two rom mode
#RBOOT_ROM_1 = rom1
#RBOOT_LD_1 = rom1.ld
# flash offsets for spiffs, if using two rom mode or not on a 4mb flash
# (spiffs location defaults to the mb after the rom slot on 4mb flash)
#RBOOT_SPIFFS_0 = 0x100000
#RBOOT_SPIFFS_1 = 0x300000
# option to completely disable spiffs
#### overridable rBoot options ####
## use rboot build mode
RBOOT_ENABLED ?= 1
## enable big flash support (for multiple roms, each in separate 1mb block of flash)
RBOOT_BIG_FLASH ?= 1
## two rom mode (where two roms sit in the same 1mb block of flash)
#RBOOT_TWO_ROMS ?= 1
## size of the flash chip
SPI_SIZE ?= 4M
## output file for first rom (.bin will be appended)
#RBOOT_ROM_0 ?= rom0
## input linker file for first rom
#RBOOT_LD_0 ?= rom0.ld
## these next options only needed when using two rom mode
#RBOOT_ROM_1 ?= rom1
#RBOOT_LD_1 ?= rom1.ld
## size of the spiffs to create
SPIFF_SIZE ?= 65536
## option to completely disable spiffs
#DISABLE_SPIFFS = 1
## flash offsets for spiffs, set if using two rom mode or not on a 4mb flash
## (spiffs location defaults to the mb after the rom slot on 4mb flash)
#RBOOT_SPIFFS_0 ?= 0x100000
#RBOOT_SPIFFS_1 ?= 0x300000
## esptool2 path
#ESPTOOL2 ?= esptool2
## path to spiffy
#SPIFFY ?= spiffy
3 changes: 0 additions & 3 deletions Basic_rBoot/app/application.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#include <user_config.h>
#include <SmingCore/SmingCore.h>

#include <rboot-api.h>
#include <rBootHttpUpdate.h>

// If you want, you can define WiFi settings globally in Eclipse Environment Variables
#ifndef WIFI_SSID
#define WIFI_SSID "PleaseEnterSSID" // Put you SSID and Password here
Expand Down
18 changes: 10 additions & 8 deletions Basic_rBoot/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ want to use big flash support (e.g. for a device with smaller flash) see the
separate instructions below. You can easily take the ota files and add them to
your own project to add OTA support.

To build any project (in threory) with rBoot support edit the Makefile to
include Makefile-rboot.mk instead of Makefile-project.mk. Then add variables
to Makefile-user.mk as in this sample.
To build any Sming project (in threory) with rBoot support you should use
Makefile-rboot.mk instead of Makefile-project.mk. In the sample the correct mk
file is chosen automatically because of the setting RBOOT_ENABLED=1 in
Makefile-user.mk

Building
--------
Expand All @@ -36,11 +37,11 @@ Using the correct -fs parameter is important. This will be -fs 32m on an ESP12.

You can also flash rom0.bin to 0x202000, but booting and using OTA is quicker!

Notes
-----
Technical Notes
---------------
spiffs_mount_manual(address, length) must be called from init. The address must
be 0x40200000 + physical flash address. It does not use memory mapped flash so
the reason for this strange addressing is not clear.
be 0x40200000 + physical flash address. Sming does not use memory mapped flash
so the reason for this strange addressing is not clear.

Important compiler flags used:
BOOT_BIG_FLASH - when using big flash mode, ensures flash mapping code is built
Expand Down Expand Up @@ -71,7 +72,8 @@ how to use this sample without bigflash support.
- If using a very small flash (e.g. 512k) there may be no room for a spiffs
fileystem, disable it with DISABLE_SPIFFS = 1
- If you are using spiffs set RBOOT_SPIFFS_0 & RBOOT_SPIFFS_1 to indicate where
the filesystems are located on the flash.
the filesystems are located on the flash. This is the real flash offset, not
the address + 0x40200000 used in the mount call.
- After building copy all the rom*.bin files to the root of your web server.

If you want more than two roms you must be an advanced user and should be able
Expand Down
2 changes: 1 addition & 1 deletion Sming/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ TARGET = app

# which modules (subdirectories) of the project to include in compiling
MODULES = system system/helpers Wiring SmingCore appinit $(filter %/, $(wildcard SmingCore/*/)) $(filter %/, $(wildcard Services/*/)) $(filter %/, $(wildcard Libraries/*/))
EXTRA_INCDIR = include include system/include Wiring Libraries SmingCore $(SDK_BASE)/../include
EXTRA_INCDIR = include include system/include Wiring Libraries SmingCore $(SDK_BASE)/../include $(SMING_HOME)/rboot $(SMING_HOME)/rboot/appcode

# libraries used in this project, mainly provided by the SDK
USER_LIBDIR = compiler/lib
Expand Down
13 changes: 7 additions & 6 deletions Sming/Makefile-rboot.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

### Defaults ###

# rBoot options, overwrite then in the projects Makefile-user.mk
# rBoot options, overwrite them in the projects Makefile-user.mk
RBOOT_BIG_FLASH ?= 1
RBOOT_TWO_ROMS ?= 0
RBOOT_ROM_0 ?= rom0
Expand Down Expand Up @@ -256,7 +256,8 @@ APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT_0 := $(addprefix $(BUILD_BASE)/,$(TARGET)_0.out)
TARGET_OUT_1 := $(addprefix $(BUILD_BASE)/,$(TARGET)_1.out)

SPIFF_BIN_OUT := $(FW_BASE)/spiff_rom.bin
SPIFF_BIN_OUT ?= spiff_rom
SPIFF_BIN_OUT := $(FW_BASE)/$(SPIFF_BIN_OUT).bin
RBOOT_LD_0 := $(addprefix -T,$(RBOOT_LD_0))
RBOOT_LD_1 := $(addprefix -T,$(RBOOT_LD_1))

Expand Down Expand Up @@ -360,13 +361,13 @@ else
# Generating spiffs_bin
$(vecho) "Checking for spiffs files"
$(Q) if [ -d "$(SPIFF_FILES)" ]; then \
echo "$(SPIFF_FILES) directory exists. Creating spiff_rom.bin"; \
echo "$(SPIFF_FILES) directory exists. Creating $(SPIFF_BIN_OUT)"; \
$(SPIFFY) $(SPIFF_SIZE) $(SPIFF_FILES); \
mv spiff_rom.bin $(FW_BASE)/spiff_rom.bin; \
mv spiff_rom.bin $(SPIFF_BIN_OUT); \
else \
echo "No files found in ./$(SPIFF_FILES)."; \
echo "Creating empty spiff_rom.bin ($$($(GET_FILESIZE) $(SMING_HOME)/compiler/data/blankfs.bin) bytes)"; \
cp $(SMING_HOME)/compiler/data/blankfs.bin $(FW_BASE)/spiff_rom.bin; \
echo "Creating empty $(SPIFF_BIN_OUT) ($$($(GET_FILESIZE) $(SMING_HOME)/compiler/data/blankfs.bin) bytes)"; \
cp $(SMING_HOME)/compiler/data/blankfs.bin $(SPIFF_BIN_OUT); \
fi
endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
*/

#include "rBootHttpUpdate.h"

#include <Services/SpifFS/spiffs.h>
#include <Platform/System.h>
#include <Network/URL.h>
#include <Platform/WDT.h>
#include "../../Services/SpifFS/spiffs.h"
#include "../Platform/System.h"
#include "URL.h"
#include "../Platform/WDT.h"

rBootHttpUpdate::rBootHttpUpdate() {
currentItem = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* Author: Richard A Burton & Anakod
*/

#ifndef _rBootHttpUpdate_H_
#define _rBootHttpUpdate_H_
#ifndef SMINGCORE_NETWORK_RBOOTHTTPUPDATE_H_
#define SMINGCORE_NETWORK_RBOOTHTTPUPDATE_H_

#include <Network/HttpClient.h>
#include "HttpClient.h"
#include <Timer.h>

#include "rboot-api.h"
#include <rboot-api.h>

#define NO_ROM_SWITCH 0xff

Expand Down Expand Up @@ -48,4 +48,4 @@ class rBootHttpUpdate: private HttpClient {
otaCallback callback;
};

#endif /* _rBootHttpUpdate_H_ */
#endif /* SMINGCORE_NETWORK_RBOOTHTTPUPDATE_H_ */
1 change: 1 addition & 0 deletions Sming/SmingCore/SmingCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "Network/TcpConnection.h"
#include "Network/UdpConnection.h"
#include "Network/HttpFirmwareUpdate.h"
#include "Network/rBootHttpUpdate.h"
#include "Network/URL.h"

#include "../Services/ArduinoJson/ArduinoJson.h"
Expand Down

0 comments on commit eb7c055

Please sign in to comment.