Skip to content

Commit

Permalink
readme for api and added informative header to source files
Browse files Browse the repository at this point in the history
  • Loading branch information
raburton committed May 18, 2015
1 parent 17728c6 commit 602f75a
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 5 deletions.
13 changes: 9 additions & 4 deletions rboot-ota/rboot-ota.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
//////////////////////////////////////////////////
// API for OTA and rBoot config, for ESP8266.
// OTA code based on SDK sample from Espressif.
// [email protected]
//////////////////////////////////////////////////

#include <c_types.h>
#include <user_interface.h>
#include <espconn.h>
#include <mem.h>
#include <osapi.h>

#include "include\rboot-ota.h"
#include "include\missingdefs.h"
#include "rboot-ota.h"

// structure to hold our internal update state
typedef struct {
Expand Down Expand Up @@ -196,8 +201,8 @@ static void ICACHE_FLASH_ATTR rboot_ota_deinit() {
}

// call user call back
if (ota->check_cb) {
ota->check_cb(ota);
if (ota->callback) {
ota->callback(ota);
}

}
Expand Down
8 changes: 7 additions & 1 deletion rboot-ota/rboot-ota.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef __RBOOT_OTA_H__
#define __RBOOTOTA_H__

//////////////////////////////////////////////////
// API for OTA and rBoot config, for ESP8266.
// OTA code based on SDK sample from Espressif.
// [email protected]
//////////////////////////////////////////////////

#include "rboot.h"

#define UPGRADE_FLAG_IDLE 0x00
Expand All @@ -14,8 +20,8 @@ typedef struct {
uint16 port;
uint8 *request;
uint8 rom_slot;
ota_callback callback;
bool result;
ota_callback check_cb;
} rboot_ota;

bool rboot_ota_start(rboot_ota *ota);
Expand Down
47 changes: 47 additions & 0 deletions rboot-ota/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
rBoot - User API and OTA support for rBoot on the ESP8266
---------------------------------------------------------
by Richard A Burton, [email protected]
http://richard.burtons.org/

See rBoot readme.txt for how to create suitable rom to flash OTA.

This provides a couple of simple APIs for getting rBoot config and one for over
the air updates (OTA):

rboot_config rboot_get_config();
Returns rboot_config (defined in rboot.h) allowing you to modify any values
in it, including the rom layout.

bool rboot_set_config(rboot_config *conf);
Saves the rboot_config structure back to sector 2 of the eeprom, while
maintaining the contents of the rest of the sector. You can use the rest of
this sector for your app settings, as long as protect this structure when
you do so.

uint8 rboot_get_current_rom();
Get the currently selected boot rom (the currently running rom, as long as
you haven't changed it since boot).

bool rboot_set_current_rom(uint8 rom);
Set the current boot rom, which will be used when next restarted.

bool rboot_ota_start(rboot_ota *ota);
Starts an OTA. Pass it an rboot_ota structure with appropriate options. This
function works very much like the SDK libupgrade code you may already be
using, very few changes will be needed to switch to this.

typedef struct {
uint8 ip[4];
uint16 port;
uint8 *request;
uint8 rom_slot;
bool result;
ota_callback callback;
} rboot_ota;

- ip is the ip of the OTA http server.
- port is the server port (e.g. 80).
- request is the http request to send.
- rom_slot is the rom to flash (numbered from zero).
- call back is the user code function to call on completion of OTA.
- result can be checked in the callback to see if OTA was successful or not.
5 changes: 5 additions & 0 deletions rboot/rboot-private.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#ifndef __RBOOT_PRIVATE_H__
#define __RBOOT_PRIVATE_H__

//////////////////////////////////////////////////
// rBoot open source boot loader for ESP8266.
// [email protected]
//////////////////////////////////////////////////

typedef int int32;
typedef unsigned int uint32;
typedef unsigned char uint8;
Expand Down
5 changes: 5 additions & 0 deletions rboot/rboot-stage2a.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//////////////////////////////////////////////////
// rBoot open source boot loader for ESP8266.
// [email protected]
//////////////////////////////////////////////////

#include "rboot-private.h"

usercode* NOINLINE call_user_start2(uint32 readpos) {
Expand Down
5 changes: 5 additions & 0 deletions rboot/rboot.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//////////////////////////////////////////////////
// rBoot open source boot loader for ESP8266.
// [email protected]
//////////////////////////////////////////////////

#include "rboot-private.h"
#include "rboot-hex2a.h"

Expand Down
5 changes: 5 additions & 0 deletions rboot/rboot.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#ifndef __RBOOT_H__
#define __RBOOT_H__

//////////////////////////////////////////////////
// rBoot open source boot loader for ESP8266.
// [email protected]
//////////////////////////////////////////////////

#define SECTOR_SIZE 0x1000
#define BOOT_CONFIG_SECTOR 1

Expand Down

0 comments on commit 602f75a

Please sign in to comment.