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:
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

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

RJB

Active Member
Licensed User
Longtime User
Hi,
for what it's worth I managed to get the OTA working and the only file I download is src.ino.bin.
 
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.



SOLVED: https://www.b4x.com/android/forum/threads/esp32-ota-update-from-server-via-wifi-only.149206/
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…