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