Skip to content

Commit dc7653f

Browse files
authored
Merge pull request #41 from pennam/part_fix
UNO R4 WiFi: update partition table (2nd try)
2 parents e9bedb4 + c409560 commit dc7653f

File tree

5 files changed

+27
-21
lines changed

5 files changed

+27
-21
lines changed

UNOR4USBBridge/at_handler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class CAtHandler {
7474
std::unordered_map<std::string, std::function<chAT::CommandStatus(chAT::Server&, chAT::ATParser&)>> command_table;
7575
chAT::Server at_srv;
7676
HardwareSerial *serial;
77+
uint8_t* cert_in_flash_ptr = nullptr;
78+
spi_flash_mmap_handle_t cert_in_flash_handle;
7779

7880
CClientWrapper getClient(int sock);
7981

UNOR4USBBridge/cmds_wifi_SSL.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "incbin.h"
88
INCBIN(x509_crt_bundle, PATH_CERT_BUNDLE);
99
#else
10-
#define ROOT_CERTIFICATES_ADDRESS (0x3C0000)
10+
#define ROOT_CERTIFICATES_ADDRESS (0xB000)
1111
#endif
1212

1313
#include "at_handler.h"
@@ -101,10 +101,16 @@ void CAtHandler::add_cmds_wifi_SSL() {
101101
#ifdef BUNDLED_CA_ROOT_CRT
102102
the_client.sslclient->setCACertBundle((const uint8_t *)x509_crt_bundle_data);
103103
#else
104-
const uint8_t* cert_in_flash;
105-
static spi_flash_mmap_handle_t t;
106-
spi_flash_mmap(ROOT_CERTIFICATES_ADDRESS, 128*1024, SPI_FLASH_MMAP_DATA, (const void**)&cert_in_flash, &t);
107-
the_client.sslclient->setCACertBundle((const uint8_t *)cert_in_flash);
104+
if(cert_in_flash_ptr == nullptr) {
105+
const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "cert");
106+
if(partition != nullptr) {
107+
esp_partition_mmap(partition, 0, partition->size, SPI_FLASH_MMAP_DATA, (const void**)&cert_in_flash_ptr, &cert_in_flash_handle);
108+
}
109+
}
110+
111+
if(cert_in_flash_ptr != nullptr) {
112+
the_client.sslclient->setCACertBundle(cert_in_flash_ptr);
113+
}
108114
#endif
109115
srv.write_response_prompt();
110116
}

combine.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@
99
spiffsData = open("spiffs/spiffs.bin", "rb").read()
1010
certsData = open("UNOR4USBBridge/build/esp32-patched.esp32.arduino_unor4wifi_usb_bridge/x509_crt_bundle", "rb").read()
1111

12-
# 0x000000 bootloader
13-
# 0x008000 partitions
14-
# 0x009000 fws
15-
# 0x00E000 boot_app/otadata
16-
# 0x010000 certs
17-
# 0x050000 app0
18-
# 0x1E0000 app1
19-
# 0x370000 spiffs
20-
# 0x3F0000 nvs
21-
# 0x3F5000 coredump
12+
# Offset Size Name
13+
# 0x000000 0x008000 bootloader
14+
# 0x008000 0x001000 partitions
15+
# 0x009000 0x002000 boot_app/otadata
16+
# 0x00B000 0x045000 certs
17+
# 0x050000 0x190000 app0
18+
# 0x1E0000 0x190000 app1
19+
# 0x370000 0x080000 spiffs
20+
# 0x3F0000 0x010000 nvs
2221

2322
# calculate the output binary size included nvs
24-
outputSize = 0x3F5000
23+
outputSize = 0x400000
2524

2625
# allocate and init to 0xff
2726
outputData = bytearray(b'\xff') * outputSize
@@ -34,10 +33,10 @@
3433
outputData[0x8000 + i] = partitionData[i]
3534

3635
for i in range(0, len(bootApp)):
37-
outputData[0xE000 + i] = bootApp[i]
36+
outputData[0x9000 + i] = bootApp[i]
3837

3938
for i in range(0, len(certsData)):
40-
outputData[0x10000 + i] = certsData[i]
39+
outputData[0xB000 + i] = certsData[i]
4140

4241
for i in range(0, len(appData)):
4342
outputData[0x50000 + i] = appData[i]

export.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# modify esp32 platform.txt from g++11 to gcc+17
2-
rm -f UNOR4USBBridge/build/esp32-patched.esp32.arduino_unor4wifi_usb_bridge/S3.bin
3-
rm -f UNOR4USBBridge/build/esp32-patched.esp32.arduino_unor4wifi_usb_bridge/x509_crt_bundle
2+
rm -rf UNOR4USBBridge/build
43
echo "Build Sketch"
54
./compile.sh
65
echo "Build certificates bundle"

0 commit comments

Comments
 (0)