Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
nexboot
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
nexboot
Commits
3584165e
Commit
3584165e
authored
May 24, 2018
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add gpio26 as "force enter bootloader" gpio
parent
65b53caa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
7 deletions
+47
-7
Makefile
components/bootloader/subproject/Makefile
+2
-2
bootloader_start.c
components/bootloader/subproject/main/bootloader_start.c
+32
-4
Kconfig.projbuild
main/Kconfig.projbuild
+7
-1
nexboot.c
main/nexboot.c
+6
-0
No files found.
components/bootloader/subproject/Makefile
View file @
3584165e
components/bootloader/subproject/main/bootloader_start.c
View file @
3584165e
...
@@ -17,12 +17,19 @@
...
@@ -17,12 +17,19 @@
#include "esp_log.h"
#include "esp_log.h"
#include "rom/gpio.h"
#include "rom/gpio.h"
#include "soc/gpio_reg.h"
#include "bootloader_config.h"
#include "bootloader_config.h"
#include "bootloader_init.h"
#include "bootloader_init.h"
#include "bootloader_utility.h"
#include "bootloader_utility.h"
#include "bootloader_common.h"
#include "bootloader_common.h"
#include "sdkconfig.h"
#include "sdkconfig.h"
#include "esp_image_format.h"
#include "esp_image_format.h"
#include "soc/rtc_io_reg.h"
#include "soc/io_mux_reg.h"
#define GPIO_PIN_REG_26 IO_MUX_GPIO26_REG
#define BOOT_GPIO26 CONFIG_ESP_BOOT_GPIO26
static
const
char
*
TAG
=
"boot"
;
static
const
char
*
TAG
=
"boot"
;
...
@@ -40,6 +47,24 @@ void call_start_cpu0()
...
@@ -40,6 +47,24 @@ void call_start_cpu0()
return
;
return
;
}
}
#if BOOT_GPIO26
// SET GPIO26 as input
// REG_CLR_BIT(GPIO_ENABLE_REG, BIT26);
// rtc_gpio_deinit(GPIO_NUM_26);
CLEAR_PERI_REG_MASK
(
RTC_IO_TOUCH_PAD3_REG
,
RTC_IO_TOUCH_PAD3_MUX_SEL_M
);
//gpio_pad_select_gpio(GPIO_NUM_26);
PIN_FUNC_SELECT
(
GPIO_PIN_REG_26
,
PIN_FUNC_GPIO
);
//gpio_set_direction(GPIO_NUM_26, GPIO_MODE_INPUT);
PIN_INPUT_ENABLE
(
GPIO_PIN_REG_26
);
REG_WRITE
(
GPIO_ENABLE_W1TC_REG
,
BIT26
);
//gpio_set_pull_mode(GPIO_NUM_26, GPIO_PULLUP_ONLY);
REG_CLR_BIT
(
GPIO_PIN_REG_26
,
FUN_PD
);
REG_SET_BIT
(
GPIO_PIN_REG_26
,
FUN_PU
);
#endif
// 2. Select image to boot
// 2. Select image to boot
esp_image_metadata_t
image_data
;
esp_image_metadata_t
image_data
;
if
(
select_image
(
&
image_data
)
!=
ESP_OK
){
if
(
select_image
(
&
image_data
)
!=
ESP_OK
){
...
@@ -83,11 +108,14 @@ static int selected_boot_partition(const bootloader_state_t *bs)
...
@@ -83,11 +108,14 @@ static int selected_boot_partition(const bootloader_state_t *bs)
if
(
boot_index
==
INVALID_INDEX
)
{
if
(
boot_index
==
INVALID_INDEX
)
{
return
boot_index
;
// Unrecoverable failure (not due to corrupt ota data or bad partition contents)
return
boot_index
;
// Unrecoverable failure (not due to corrupt ota data or bad partition contents)
}
else
{
}
else
{
#if BOOT_GPIO26
// Check for reset to the factory firmware or for launch OTA[x] firmware.
// Check for reset to the factory firmware or for launch OTA[x] firmware.
// Customer implementation.
// Customer implementation.
// if (gpio_pin_1 == true && ...){
if
(
REG_GET_BIT
(
GPIO_IN_REG
,
BIT26
)
==
BIT26
)
{
// boot_index = required_boot_partition;
ESP_LOGE
(
TAG
,
"GPIO 26 PRESSED: Booting on FACTORY_INDEX
\n
"
);
// } ...
boot_index
=
FACTORY_INDEX
;
}
#endif
}
}
return
boot_index
;
return
boot_index
;
}
}
main/Kconfig.projbuild
View file @
3584165e
menu "Nexboot Configuration"
menu "Nexboot Configuration"
config ESP_BOOT_GPIO26
bool "Enable GPIO26 force bootloader"
default y
help
Whether or not GPIO26 is enabled during boot to force bootloader mode
choice ESP_WIFI_MODE
choice ESP_WIFI_MODE
prompt "AP or STA"
prompt "AP or STA"
default ESP_WIFI_IS_STATION
default ESP_WIFI_IS_STATION
...
...
main/nexboot.c
View file @
3584165e
...
@@ -209,6 +209,8 @@ static void mg_ev_handler(struct mg_connection *nc, int ev, void *p) {
...
@@ -209,6 +209,8 @@ static void mg_ev_handler(struct mg_connection *nc, int ev, void *p) {
data
->
bytes_written
+=
mp
->
data
.
len
;
data
->
bytes_written
+=
mp
->
data
.
len
;
ESP_LOGI
(
TAG
,
"MG_EV_HTTP_PART_DATA %p len %d
\n
"
,
nc
,
mp
->
data
.
len
);
ESP_LOGI
(
TAG
,
"MG_EV_HTTP_PART_DATA %p len %d
\n
"
,
nc
,
mp
->
data
.
len
);
ESP_ERROR_CHECK
(
esp_ota_write
(
data
->
update_handle
,
(
void
*
)
mp
->
data
.
p
,
mp
->
data
.
len
));
ESP_ERROR_CHECK
(
esp_ota_write
(
data
->
update_handle
,
(
void
*
)
mp
->
data
.
p
,
mp
->
data
.
len
));
break
;
break
;
}
}
case
MG_EV_HTTP_PART_END
:
{
case
MG_EV_HTTP_PART_END
:
{
...
@@ -221,6 +223,10 @@ static void mg_ev_handler(struct mg_connection *nc, int ev, void *p) {
...
@@ -221,6 +223,10 @@ static void mg_ev_handler(struct mg_connection *nc, int ev, void *p) {
nc
->
flags
|=
MG_F_SEND_AND_CLOSE
;
nc
->
flags
|=
MG_F_SEND_AND_CLOSE
;
free
(
data
);
free
(
data
);
nc
->
user_data
=
NULL
;
nc
->
user_data
=
NULL
;
ESP_ERROR_CHECK
(
esp_ota_end
(
data
->
update_handle
));
ESP_ERROR_CHECK
(
esp_ota_set_boot_partition
(
data
->
update_partition
));
ESP_LOGI
(
TAG
,
"Booting update... "
);
esp_restart
();
break
;
break
;
}
}
case
MG_EV_CLOSE
:
{
case
MG_EV_CLOSE
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment