rboot.h
Go to the documentation of this file.
1 #ifndef __RBOOT_H__
2 #define __RBOOT_H__
3 
5 // rBoot open source boot loader for ESP8266.
6 // Copyright 2015 Richard A Burton
7 // richardaburton@gmail.com
8 // See license.txt for license terms.
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include <stdint.h>
16 
17 // uncomment to use only c code
18 // if you aren't using gcc you may need to do this
19 //#define BOOT_NO_ASM
20 
21 // uncomment to have a checksum on the boot config
22 //#define BOOT_CONFIG_CHKSUM
23 
24 // uncomment to enable big flash support (>1MB)
25 //#define BOOT_BIG_FLASH
26 
27 // uncomment to enable 2 way communication between
28 // rBoot and the user app via the esp rtc data area
29 //#define BOOT_RTC_ENABLED
30 
31 // uncomment to enable GPIO booting of specific rom
32 // (specified in rBoot config block)
33 // cannot be used at same time as BOOT_GPIO_SKIP_ENABLED
34 //#define BOOT_GPIO_ENABLED
35 
36 // uncomment to enable GPIO rom skip mode, trigger
37 // GPIO at boot time to skip to next rom
38 // cannot be used at same time as BOOT_GPIO_ENABLED
39 //#define BOOT_GPIO_SKIP_ENABLED
40 
41 // set the GPIO pin used by GPIO modes above (will default
42 // to 16 if not manually set), only applicable when
43 // BOOT_GPIO_ENABLED or BOOT_GPIO_SKIP_ENABLED is enabled
44 //#define BOOT_GPIO_NUM 16
45 
46 // uncomment to include .irom0.text section in the checksum
47 // roms must be built with esptool2 using -iromchksum option
48 //#define BOOT_IROM_CHKSUM
49 
50 // uncomment to add a boot delay, allows you time to connect
51 // a terminal before rBoot starts to run and output messages
52 // value is in microseconds
53 //#define BOOT_DELAY_MICROS 2000000
54 
55 // max number of roms in the config (defaults to 4), higher
56 // values will use more ram at run time
57 //#define MAX_ROMS 4
58 
59 
60 // you should not need to modify anything below this line
61 
62 
63 #define CHKSUM_INIT 0xef
64 
65 #define SECTOR_SIZE 0x1000
66 #define BOOT_CONFIG_SECTOR 1
67 
68 #define BOOT_CONFIG_MAGIC 0xe1
69 #define BOOT_CONFIG_VERSION 0x01
70 
71 #define MODE_STANDARD 0x00
72 #define MODE_GPIO_ROM 0x01
73 #define MODE_TEMP_ROM 0x02
74 #define MODE_GPIO_ERASES_SDKCONFIG 0x04
75 #define MODE_GPIO_SKIP 0x08
76 
77 #define RBOOT_RTC_MAGIC 0x2334ae68
78 #define RBOOT_RTC_READ 1
79 #define RBOOT_RTC_WRITE 0
80 #define RBOOT_RTC_ADDR 64
81 
82 // defaults for unset user options
83 #ifndef BOOT_GPIO_NUM
84 #define BOOT_GPIO_NUM 16
85 #endif
86 
87 #ifndef MAX_ROMS
88 #define MAX_ROMS 4
89 #endif
90 
101 typedef struct {
102  uint8_t magic;
103  uint8_t version;
104  uint8_t mode;
105  uint8_t current_rom;
106  uint8_t gpio_rom;
107  uint8_t count;
108  uint8_t unused[2];
109  uint32_t roms[MAX_ROMS];
110 #ifdef BOOT_CONFIG_CHKSUM
111  uint8_t chksum;
112 #endif
113 } rboot_config;
114 
115 #ifdef BOOT_RTC_ENABLED
121 typedef struct {
122  uint32_t magic;
123  uint8_t next_mode;
124  uint8_t last_mode;
125  uint8_t last_rom;
126  uint8_t temp_rom;
127  uint8_t chksum;
128 } rboot_rtc_data;
129 #endif
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif
#define MAX_ROMS
Definition: rboot.h:88
Structure containing rBoot configuration.
Definition: rboot.h:101
uint8_t version
Version of configuration structure - should be BOOT_CONFIG_VERSION.
Definition: rboot.h:103
uint8_t mode
Boot loader mode (MODE_STANDARD | MODE_GPIO_ROM | MODE_GPIO_SKIP)
Definition: rboot.h:104
uint8_t count
Quantity of ROMs available to boot.
Definition: rboot.h:107
uint8_t current_rom
Currently selected ROM (will be used for next standard boot)
Definition: rboot.h:105
uint8_t magic
Our magic, identifies rBoot configuration - should be BOOT_CONFIG_MAGIC.
Definition: rboot.h:102
uint8_t gpio_rom
ROM to use for GPIO boot (hardware switch) with mode set to MODE_GPIO_ROM.
Definition: rboot.h:106