Skip to content

Commit

Permalink
Added review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
slav-at-attachix committed May 25, 2021
1 parent f5636b2 commit c91b5f0
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 41 deletions.
27 changes: 13 additions & 14 deletions Sming/Arch/Esp32/spiffs-two-roms.hw
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
"name": "Two ROM slots with single SPIFFS",
"base_config": "spiffs",
"partitions": {
"factory": {
"address": "0x10000",
"size": "1M"
},
"factory": {
"size": "1M"
},
"rom0": {
"address": "0x110000",
"size": "960K",
"type": "app",
"address": "0x110000",
"size": "960K",
"type": "app",
"subtype": "ota_0",
"filename": "$(TARGET_BIN)"
},
"ota": { // Ota Table
"address": "0x00200000",
"size": "8K",
"type" : "data",
"subtype": "ota"
"ota": {
"address": "0x00200000",
"size": "8K",
"type": "data",
"subtype": "ota"
},
"rom1": {
"address": "0x210000",
Expand All @@ -27,8 +26,8 @@
"filename": ""
},
"spiffs0": {
"address": "0x300000",
"size": "1M"
"address": "0x300000",
"size": "1M"
}
}
}
8 changes: 4 additions & 4 deletions Sming/Components/Ota/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Introduction

This architecture-agnostic component adds support for Over-The-Air upgrades.

Usaging
-------
Usage
-----
1. Add ``COMPONENT_DEPENDS += Ota`` to your application componenent.mk file.
2. Add these lines to your application::

Expand All @@ -24,9 +24,9 @@ After that you will have access to a global ``OtaManager`` instance that can be
{

// ...
auto part = OtaManager.getRunningPartition();
auto partition = OtaManager.getRunningPartition();

Serial.printf(_F("\r\nCurrently running rom %s@%x.\r\n"), part.name().c_str(), part.address());
Serial.printf("\r\nCurrently running %s @ 0x%08x.\r\n", partition.name().c_str(), partition.address());

}

Expand Down
2 changes: 1 addition & 1 deletion Sming/Components/Ota/src/Arch/Esp32/IdfUpgrader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bool IdfUpgrader::begin(Partition partition, size_t size)
writtenSoFar = 0;
maxSize = size ?: partition.size();

esp_err_t result = esp_ota_begin(convertToIdfPartition(partition), size ? size : partition.size(), &handle);
esp_err_t result = esp_ota_begin(convertToIdfPartition(partition), size ?: partition.size(), &handle);

return result == ESP_OK;
}
Expand Down
7 changes: 2 additions & 5 deletions Sming/Components/Ota/src/Arch/Esp32/include/Ota/IdfUpgrader.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ namespace Ota
class IdfUpgrader : public UpgraderBase
{
public:
/**
* @brief Prepare the partition for
*/
bool begin(Partition partition, size_t size = 0) override;
size_t write(const uint8_t* buffer, size_t size) override;

Expand All @@ -40,12 +37,12 @@ class IdfUpgrader : public UpgraderBase
return esp_ota_set_boot_partition(convertToIdfPartition(partition)) == ESP_OK;
}

Partition getBootPartition(void) override
Partition getBootPartition() override
{
return convertFromIdfPartition(esp_ota_get_boot_partition());
}

Partition getRunningPartition(void) override
Partition getRunningPartition() override
{
return convertFromIdfPartition(esp_ota_get_running_partition());
}
Expand Down
2 changes: 1 addition & 1 deletion Sming/Components/Ota/src/Arch/Esp8266/RbootUpgrader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* http://github.com/SmingHub/Sming
* All files of the Sming Core are provided under the LGPL v3 license.
*
* Ota.cpp
* RbootUpgrader.cpp
*
****/

Expand Down
4 changes: 2 additions & 2 deletions Sming/Components/Ota/src/include/Ota/UpgraderBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ class UpgraderBase
* @brief Gets information about the parition that is set as the default one to boot.
* @note The returned parition can be different than the current running partition.
*/
virtual Partition getBootPartition(void) = 0;
virtual Partition getBootPartition() = 0;

/**
* @brief Gets information about the parition from which the current application is running.
* @note The returned parition can be different than the default boot partition.
*/
virtual Partition getRunningPartition(void) = 0;
virtual Partition getRunningPartition() = 0;

/**
* @brief Gets the next bootable partition that can be used after successful OTA upgrade
Expand Down
12 changes: 6 additions & 6 deletions Sming/Components/OtaNetwork/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Introduction

This architecture-agnostic component adds support for Over-The-Air upgrades.

Usaging
-------
Usage
-----
1. Add ``COMPONENT_DEPENDS += Ota`` to your application componenent.mk file.
2. Add these lines to your application::

Expand All @@ -24,9 +24,9 @@ After that you will have access to a global ``OtaManager`` instance that can be
{

// ...
auto part = OtaManager.getRunningPartition();
auto partition = OtaManager.getRunningPartition();

Serial.printf(_F("\r\nCurrently running rom %s@%x.\r\n"), part.name().c_str(), part.address());
Serial.printf("\r\nCurrently running %s @ 0x%08x.\r\n", partition.name().c_str(), partition.address());

}

Expand All @@ -40,9 +40,9 @@ After that you will have access to a global ``OtaManager`` instance that can be

OtaUpgrader ota;

auto part = ota.getNextBootPartition();
auto partition = ota.getNextBootPartition();

ota.begin(part);
ota.begin(partition);

// ... write all the data to the partition

Expand Down
16 changes: 8 additions & 8 deletions samples/Basic_Ota/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Storage::Partition findSpiffsPartition(Storage::Partition partition)
return part;
}

void otaUpdateCallBack(Ota::Network::HttpUpgrader& client, bool result)
void upgradeCallback(Ota::Network::HttpUpgrader& client, bool result)
{
Serial.println("In callback...");
if(result == true) {
Expand All @@ -44,7 +44,7 @@ void otaUpdateCallBack(Ota::Network::HttpUpgrader& client, bool result)
}
}

void OtaUpdate()
void doUpgrade()
{
Serial.println("Updating...");

Expand Down Expand Up @@ -76,13 +76,13 @@ void OtaUpdate()
// request switch and reboot on success
//otaUpdater->switchToRom(slot);
// and/or set a callback (called on failure or success without switching requested)
otaUpdater->setCallback(otaUpdateCallBack);
otaUpdater->setCallback(upgradeCallback);

// start update
otaUpdater->start();
}

void Switch()
void doSwitch()
{
auto before = ota.getRunningPartition();
auto after = ota.getNextBootPartition();
Expand All @@ -97,7 +97,7 @@ void Switch()
}
}

void ShowInfo()
void showInfo()
{
Serial.printf("\r\nSDK: v%s\r\n", system_get_sdk_version());
Serial.printf("Free Heap: %d\r\n", system_get_free_heap_size());
Expand Down Expand Up @@ -136,9 +136,9 @@ void serialCallBack(Stream& stream, char arrivedChar, unsigned short availableCh
Serial.print(" mac: ");
Serial.println(WifiStation.getMacAddress());
} else if(!strcmp(str, "ota")) {
OtaUpdate();
doUpgrade();
} else if(!strcmp(str, "switch")) {
Switch();
doSwitch();
} else if(!strcmp(str, "restart")) {
System.restart();
} else if(!strcmp(str, "ls")) {
Expand All @@ -164,7 +164,7 @@ void serialCallBack(Stream& stream, char arrivedChar, unsigned short availableCh
Serial.println("Empty spiffs!");
}
} else if(!strcmp(str, "info")) {
ShowInfo();
showInfo();
} else if(!strcmp(str, "help")) {
Serial.println();
Serial.println("available commands:");
Expand Down

0 comments on commit c91b5f0

Please sign in to comment.