B4R Question ESP32 OTA update - what .bin file ?

peacemaker

Expert
Licensed User
Longtime User
Hi, All

I'm trying to make OTA update of ESP32 module https://www.b4x.com/android/forum/threads/esp32-simple-ota-update-via-webserver.130576/.
.bin file is made by merging .bin files https://www.b4x.com/android/forum/threads/esp32-bin-merging-and-flashing.149181/ and this file is correctly re-flashed from 0x0 address by esptool.
SPIFFS file system is even pre-formatted (!!11)
This merged existing "update.bin" file is deleted before downloading OK.
File is downloaded from server OK into SPIFFS file system:
B4X:
Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
 
    For i=1 To 10
        Log("Connecting to WiFi...")
        Log(i)
     
    If wifi.Connect2("wifi","password") Then
    Log("Connected to wireless network.")
    Log("My ip: ", wifi.LocalIp)
            InitFS
            bc.ArrayCopy("http://pmaker.ru/update.bin", FullPath)
            bc.ArrayCopy("/update.bin", SaveAs) '/ is important!
            fs.Remove(bc.StringFromBytes(SaveAs))
            Log("Old update.bin - deleted")
            ListFiles
            DownloadFile
            ListFiles
            RunNative("updateFromFS", Null)
            Exit
        Else
            Log("Failed to connect...")
        End If
    Next
 
End Sub

Sub DownloadFile
    RunNative("downloadfile", Null) 
End Sub

Sub InitFS
    Log("Initializing Filesystem...")
 
    If(fs.Initialize())=False Then
        Log("Formatting Filesystem. This may take some time")
        fs.Format
        If(fs.Initialize())=True Then
            Log("Formatting succesful...")
         
        Else
            Log("Error formatting Filesystem...")
        End If
    End If
    fs.Format
    ListFiles
End Sub

Sub ListFiles
    Log("Files:")
    For Each f As File In fs.ListFiles("/")
        Log("     ",f.Name," Size: ",f.Size)
    Next
    Log("Total size: ", fs.TotalSize, " B")
    Log("Used size: ", fs.UsedSize, " B")
End Sub


but the flashing always gives error #8:
E (231) psram: PSRAM ID read error: 0xffffffff
AppStart
Connecting to WiFi...
1
Connected to wireless network.
My ip: 10.1.30.45
Initializing Filesystem...
Files:
Total size: 1318001 B
Used size: 0 B
Old update.bin - deleted
Files:
Total size: 1318001 B
Used size: 0 B
Downloading from http://pmaker.ru/update.bin...
Saving as /update.bin...
[HTTP] GET...
Connected...
Filesize is 1135136
Writing File...
Total Bytes downloaded: 1135136
Files:
update.bin Size: 1135136
Total size: 1318001 B
Used size: 1144560 B
Try to start update
Written only : 0/1135136. Retry?
Error Occurred. Error #: 8
BTW the SDK is installed the fresh recent v.2.0.11.
How to debug ?
What correct .bin must be ?
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x140000,
app1, app, ota_1, 0x150000,0x140000,
spiffs, data, spiffs, 0x290000,0x160000,
coredump, data, coredump,0x3F0000,0x10000,

Partitions are the same for 2 ESP32 board families.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
is src.ino.bin
Oh, God.... indeed! Only one "ota" partition is a new one !!11
Started to work, but only after 2 times - always error of chesum - wrong file downloading from the server.

AppStart
Connecting to WiFi...
1
Connected to wireless network.
My ip: 10.1.30.45
Initializing Filesystem...
Files:
Total size: 1318001 B
Used size: 0 B
Old update.bin - deleted
Files:
Total size: 1318001 B
Used size: 0 B
Downloading from http://pmaker.ru/update.bin...
Saving as /update.bin...
[HTTP] GET...
Connected...
Filesize is 1069600
Writing File...
Total Bytes downloaded: 1026475
Files:
update.bin Size: 1026475
Total size: 1318001 B
Used size: 1035124 B
Try to start update
Written : 1026475 successfully
E (45250) esp_image: Checksum failed. Calculated 0xe5 read 0xff
Error Occurred. Error #: 9


SOLVED: https://www.b4x.com/android/forum/threads/esp32-ota-update-from-server-via-wifi-only.149206/
 
Last edited:
Upvote 0
Top