Add SD Update

This commit is contained in:
Just Call Me Koko
2020-03-09 20:37:45 -04:00
parent 7abc67242b
commit 9ed469d914
12 changed files with 145 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
<!---[![Build Status](https://travis-ci.com/justcallmekoko/ESP32Marauder.svg?branch=master)](https://travis-ci.com/justcallmekoko/ESP32Marauder)--->
<!---Shields/Badges https://shields.io/--->
# ESP32 Marauder v0.5.2
# ESP32 Marauder v0.5.3
<p align="center"><img alt="Marauder logo" src="https://github.com/justcallmekoko/ESP32Marauder/blob/master/pictures/marauder3L.jpg?raw=true" width="300"></p>
<p align="center">
<b>A suite of WiFi/Bluetooth offensive and defensive tools for the ESP32</b>

View File

@@ -117,7 +117,19 @@ PROGMEM static const unsigned char menu_icons[][66] = {
0xFF, 0xFF, 0x3F, 0x7F, 0xF0, 0x3F, 0xFF, 0xF1, 0x3F, 0xFF, 0xF1, 0x3F,
0xFF, 0xF1, 0x3F, 0xFF, 0xF1, 0x3F, 0xFF, 0xF1, 0x3F, 0xFF, 0xF1, 0x3F,
0xFF, 0xF1, 0x3F, 0x7F, 0xC0, 0x3F, 0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F,
0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F}
0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F},
{0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F, 0xFF, 0x00, 0x3C, 0x7F, 0xFF, 0x3D, // SD Update: 19
0xBF, 0xFF, 0x3D, 0xDF, 0xFF, 0x3D, 0xEF, 0xFF, 0x3D, 0x6F, 0xC4, 0x3D,
0xAF, 0xB7, 0x3D, 0xAF, 0xB7, 0x3D, 0x6F, 0xB6, 0x3D, 0xEF, 0xB5, 0x3D,
0xEF, 0xB5, 0x3D, 0x2F, 0xC6, 0x3D, 0xEF, 0xFF, 0x3D, 0xEF, 0xFF, 0x3D,
0xEF, 0xFF, 0x3D, 0xEF, 0xFF, 0x3D, 0xEF, 0xFF, 0x3D, 0x0F, 0x00, 0x3C,
0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F},
{0xFF, 0xFF, 0x3F, 0xFF, 0xC0, 0x3F, 0x3F, 0x23, 0x3F, 0xDF, 0x94, 0x3E, // Web Update: 20
0x6F, 0x55, 0x3D, 0xB7, 0xB6, 0x3A, 0x03, 0x00, 0x30, 0xDB, 0xB6, 0x35,
0xDD, 0xB6, 0x2D, 0xED, 0xB6, 0x2B, 0xED, 0xB6, 0x2B, 0x01, 0x00, 0x20,
0xED, 0xB6, 0x2B, 0xDD, 0xB6, 0x2D, 0xDB, 0xB6, 0x35, 0xDB, 0x96, 0x35,
0x07, 0x00, 0x38, 0x6F, 0x55, 0x3D, 0xDF, 0x94, 0x3E, 0x3F, 0x23, 0x3F,
0xFF, 0xC0, 0x3F, 0xFF, 0xFF, 0x3F}
};

View File

@@ -56,7 +56,7 @@ class Display
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite img = TFT_eSprite(&tft);
TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
String version_number = "v0.5.2";
String version_number = "v0.5.3";
bool printing = false;
bool loading = false;

View File

@@ -184,6 +184,8 @@ void MenuFunctions::RunSetup()
deviceMenu.list = new LinkedList<MenuNode>();
// Device menu stuff
whichUpdateMenu.list = new LinkedList<MenuNode>();
confirmMenu.list = new LinkedList<MenuNode>();
updateMenu.list = new LinkedList<MenuNode>();
infoMenu.list = new LinkedList<MenuNode>();
@@ -201,6 +203,8 @@ void MenuFunctions::RunSetup()
wifiMenu.name = " WiFi ";
deviceMenu.name = " Device ";
generalMenu.name = " General Apps ";
whichUpdateMenu.name = "Select Method ";
confirmMenu.name = " Confirm Update ";
updateMenu.name = " Update Firmware ";
infoMenu.name = " Device Info ";
bluetoothMenu.name = " Bluetooth ";
@@ -259,18 +263,36 @@ void MenuFunctions::RunSetup()
addNodes(&bluetoothScannerMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(bluetoothScannerMenu.parentMenu);});
addNodes(&bluetoothScannerMenu, "Detect Card Skimmers", TFT_MAGENTA, NULL, CC_SKIMMERS, [this](){wifi_scan_obj.StartScan(BT_SCAN_SKIMMERS, TFT_MAGENTA);});
// General apps menu
generalMenu.parentMenu = &mainMenu;
addNodes(&generalMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){display_obj.draw_tft = false; changeMenu(generalMenu.parentMenu);});
addNodes(&generalMenu, "Draw", TFT_WHITE, NULL, DRAW, [this](){display_obj.clearScreen(); display_obj.draw_tft = true;});
// Device menu
deviceMenu.parentMenu = &mainMenu;
addNodes(&deviceMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(deviceMenu.parentMenu);});
addNodes(&deviceMenu, "Update Firmware", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&updateMenu); web_obj.setupOTAupdate();});
//addNodes(&deviceMenu, "Update Firmware", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&updateMenu); web_obj.setupOTAupdate();});
addNodes(&deviceMenu, "Update Firmware", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&whichUpdateMenu);});
addNodes(&deviceMenu, "Device Info", TFT_WHITE, NULL, DEVICE_INFO, [this](){wifi_scan_obj.currentScanMode = SHOW_INFO; changeMenu(&infoMenu); wifi_scan_obj.RunInfo();});
// Select update
whichUpdateMenu.parentMenu = &deviceMenu;
addNodes(&whichUpdateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(whichUpdateMenu.parentMenu);});
addNodes(&whichUpdateMenu, "Web Update", TFT_GREEN, NULL, WEB_UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&updateMenu); web_obj.setupOTAupdate();});
addNodes(&whichUpdateMenu, "SD Update", TFT_MAGENTA, NULL, SD_UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&confirmMenu);});
// Confirm SD update menu
confirmMenu.parentMenu = &whichUpdateMenu;
addNodes(&confirmMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){changeMenu(confirmMenu.parentMenu);});
//addNodes(&confirmMenu, "Yes", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; changeMenu(&updateMenu); sd_obj.runUpdate();});
addNodes(&confirmMenu, "Yes", TFT_ORANGE, NULL, UPDATE, [this](){wifi_scan_obj.currentScanMode = OTA_UPDATE; sd_obj.runUpdate();});
// Web Update
updateMenu.parentMenu = &deviceMenu;
addNodes(&updateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(updateMenu.parentMenu); WiFi.softAPdisconnect(true); web_obj.shutdownServer();});
//addNodes(&updateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(updateMenu.parentMenu);});
// Device info menu
infoMenu.parentMenu = &deviceMenu;
addNodes(&infoMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(infoMenu.parentMenu);});

View File

@@ -44,6 +44,8 @@ extern Web web_obj;
#define UPDATE 16
#define DEVICE 17
#define DEVICE_INFO 18
#define SD_UPDATE 19
#define WEB_UPDATE 20
struct Menu;
@@ -80,6 +82,8 @@ class MenuFunctions
Menu deviceMenu;
// Device menu stuff
Menu whichUpdateMenu;
Menu confirmMenu;
Menu updateMenu;
Menu infoMenu;

View File

@@ -68,6 +68,86 @@ void SDInterface::openCapture() {
buffer_obj.open(&SD);
}
void SDInterface::runUpdate() {
display_obj.clearScreen();
display_obj.tft.setTextWrap(false);
display_obj.tft.setFreeFont(NULL);
display_obj.tft.setCursor(0, 0);
display_obj.tft.setTextSize(1);
display_obj.tft.setTextColor(TFT_MAGENTA);
display_obj.tft.println("Opening /update.bin...");
File updateBin = SD.open("/update.bin");
if (updateBin) {
if(updateBin.isDirectory()){
display_obj.tft.println("Error, could not find update.bin");
Serial.println("Error, update.bin is not a file");
updateBin.close();
return;
}
size_t updateSize = updateBin.size();
if (updateSize > 0) {
display_obj.tft.println("Starting SD Update...");
Serial.println("Try to start update");
this->performUpdate(updateBin, updateSize);
}
else {
display_obj.tft.println("Error, update.bin is empty");
Serial.println("Error, file is empty");
}
updateBin.close();
// whe finished remove the binary from sd card to indicate end of the process
display_obj.tft.println("Exiting update process...");
Serial.println("Exiting update process...");
//SD.remove("/update.bin");
}
else {
display_obj.tft.println("Could not load update.bin from /");
Serial.println("Could not load update.bin from sd root");
}
}
void SDInterface::performUpdate(Stream &updateSource, size_t updateSize) {
if (Update.begin(updateSize)) {
display_obj.tft.println("File size: " + String(updateSize));
display_obj.tft.println("Writing file to partition...");
size_t written = Update.writeStream(updateSource);
if (written == updateSize) {
display_obj.tft.println("Written: " + String(written) + " successfully");
Serial.println("Written : " + String(written) + " successfully");
}
else {
display_obj.tft.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
}
if (Update.end()) {
Serial.println("OTA done!");
if (Update.isFinished()) {
display_obj.tft.println("Update complete");
Serial.println("Update successfully completed. Rebooting.");
}
else {
display_obj.tft.println("Update could not complete");
Serial.println("Update not finished? Something went wrong!");
}
}
else {
display_obj.tft.println("Error Occurred. Error #: " + String(Update.getError()));
Serial.println("Error Occurred. Error #: " + String(Update.getError()));
}
}
else
{
display_obj.tft.println("Not enough space to begin OTA");
Serial.println("Not enough space to begin OTA");
}
}
void SDInterface::main() {
if ((this->supported) && (this->do_save)) {
//Serial.println("Saving packet...");

View File

@@ -3,8 +3,11 @@
#include "SD.h"
#include "Buffer.h"
#include "Display.h"
#include <Update.h>
extern Buffer buffer_obj;
extern Display display_obj;
#define SD_CS 12
@@ -27,6 +30,8 @@ class SDInterface {
void addPacket(uint8_t* buf, uint32_t len);
void openCapture();
void runUpdate();
void performUpdate(Stream &updateSource, size_t updateSize);
void main();
//void savePacket(uint8_t* buf, uint32_t len);
};

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,9 @@
#define 1583800096004_width 22
#define 1583800096004_height 22
static char 1583800096004_bits[] = {
0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F, 0xFF, 0x00, 0x3C, 0x7F, 0xFF, 0x3D,
0xBF, 0xFF, 0x3D, 0xDF, 0xFF, 0x3D, 0xEF, 0xFF, 0x3D, 0x6F, 0xC4, 0x3D,
0xAF, 0xB7, 0x3D, 0xAF, 0xB7, 0x3D, 0x6F, 0xB6, 0x3D, 0xEF, 0xB5, 0x3D,
0xEF, 0xB5, 0x3D, 0x2F, 0xC6, 0x3D, 0xEF, 0xFF, 0x3D, 0xEF, 0xFF, 0x3D,
0xEF, 0xFF, 0x3D, 0xEF, 0xFF, 0x3D, 0xEF, 0xFF, 0x3D, 0x0F, 0x00, 0x3C,
0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F, };

View File

@@ -0,0 +1,9 @@
#define 1583800128954_width 22
#define 1583800128954_height 22
static char 1583800128954_bits[] = {
0xFF, 0xFF, 0x3F, 0xFF, 0xC0, 0x3F, 0x3F, 0x23, 0x3F, 0xDF, 0x94, 0x3E,
0x6F, 0x55, 0x3D, 0xB7, 0xB6, 0x3A, 0x03, 0x00, 0x30, 0xDB, 0xB6, 0x35,
0xDD, 0xB6, 0x2D, 0xED, 0xB6, 0x2B, 0xED, 0xB6, 0x2B, 0x01, 0x00, 0x20,
0xED, 0xB6, 0x2B, 0xDD, 0xB6, 0x2D, 0xDB, 0xB6, 0x35, 0xDB, 0x96, 0x35,
0x07, 0x00, 0x38, 0x6F, 0x55, 0x3D, 0xDF, 0x94, 0x3E, 0x3F, 0x23, 0x3F,
0xFF, 0xC0, 0x3F, 0xFF, 0xFF, 0x3F, };