-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LFS used/free size (Feature requires) #2939
Comments
+1 for this, also seeking a way of properly hashing lfs images to make some auto-lfs-ota trough http/https. |
This would be really useful if there was a way to extract this timestamp from an image file as well. That way I can easily decide whether I have the latest image installed or not. |
For Lua 5.3, the timestamp is the last integer in the image. See function getTS(image)
local f=file.open(image)
if f and f:seek('end',-5) > 0 then
local t = f:read(1):byte()&0xf
for i = 1,4 do t = (t<<7) + (f:read(1):byte()&0x7f) end
f:close()
return t
end
end Note this is Lua 5.3 code. It's more difficult for Lua 5.1 since the image is gzipped.
I've optimised the load process somewhat. The Lua runtime just closes and restarts rather doing a CPU restart for the intermediate step and does a fast restart for the last restart. Simple failures (e.g. the file doesn't exist) don't restart at all, but rather just return an error. I can look into this further if you raise a specific test case and issue. |
Thanks for the sample code for retrieving the timestamp. Will use it once I switched to 5.3. The failing flash I observe on Lua 51. When I can find a testcase I will post an issue. It always worked on the second try so far. Maybe it is also connected to a not freshly booted system. |
Reading the original request, the above Lua sample to get the timestamp just mentioned in this issue feels incomplete. @TerryE I leave it to you if you want to reopen this issue. |
@HHHartmann, I am about to start the issue / PR for adding a second LFS and the ability (in Lua 5.3) to build LFS incrementally on ESP. Part of this understanding the dump format and its grammar. This an encoded byte stream that has a left-to-right grammar and must to be parsed start to end. For historic convenience, the timestamp is the last integer value in the file, and the only way I can quickly decode this is a botch; anything else with the current format would be a full parse of the file ignoring anything but the timestamp. This just isn't worth it in terms of effort. What I suspect is that introducing this incremental build capability is going to introduce a break in LFS image format anyway, (that is will require any images to be recompiled to be loadable with the new loader). I feel that using the Unix timestamp is not a portable ID when doing builds on the ESP, and that the functional requirement is that you should be able to specify some form of unique ID or equivalent for the image and the ID should be in the image header, and also the image should have a CRC (as is the case implicitly with the gzipped Lua 5.1 format). We should be able to do some form of I would also note that my provisioning strategy (see this gist) fetches images from a (local) web service and it uses the file's Etag as a unique ID. There is nothing to stop you implementing a workaround using a similar strategy and that adds the timestamp to the image filename. (You can rename a plain |
@TerryE The problem with the proposed workaround is, that I can only read the The problem is that I cannot know if a certain file is the one which is flashed or not.
That sounds perfect! |
The text was updated successfully, but these errors were encountered: