Skip to content
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

MAVFTP: Check CRC after file upload #3308

Open
IamPete1 opened this issue Mar 8, 2024 · 6 comments
Open

MAVFTP: Check CRC after file upload #3308

IamPete1 opened this issue Mar 8, 2024 · 6 comments

Comments

@IamPete1
Copy link
Member

IamPete1 commented Mar 8, 2024

The FTP protocol has a option to get the CRC32 checksum of a file, this could be fetched after a file upload to confirm it was uploaded correctly.

This can be currently be done manually:

Grab the CRC from the file:
image

image

Then a online tool can be used to get the expected checksum from the local copy: https://www.lddgo.net/en/encrypt/crc

It needs a little custom setup to get the correct result:

image

If they don't match the file should be deleted and/or the upload give a failed warning.

@meee1
Copy link
Contributor

meee1 commented Mar 9, 2024

I used to do this. The issue is large files where taking to long to CRC, causing other issues

There would need to be a limit on the max size that's crc'd

@IamPete1
Copy link
Member Author

IamPete1 commented Mar 9, 2024

I guess we could add to the FTP protocol a "check CRC is x" so you would send the expected CRC and then leave the flight controller to deal with what to do if its wrong.

This all came about because of a report of scripts getting corrupted on upload . Its certainly not a common issue. https://discord.com/channels/674039678562861068/719466647710072832/1215451314700550144

I wonder if there was a bug that has now been fixed or something like that.

@hunter-hall
Copy link

hunter-hall commented Mar 11, 2024

Here is a tlog that should contain the crc error I was getting: https://drive.google.com/file/d/16BGuqd8N30H53Prg8PadIq1kyhnfnpw7/view?usp=sharing

Edit: Here are two more tlogs that are smaller in size with the same errors as the first tlog I posted above: https://drive.google.com/drive/folders/1pITjT7hwX8_a7NZpv9sovi_QU7MQGNxW?usp=sharing

@hunter-hall
Copy link

Update: Upon rolling back to plane v4.4.4 (with my modified lua bindings description file), it works perfectly fine and this error does not exist.

@tridge
Copy link
Contributor

tridge commented Mar 13, 2024

@hunter-hall i've tested uploading the plane_aerobatics.lua both with MAVProxy and MissionPlanner 1.3.81 on a Pixhawk6X on USB with no errors after 5 uploads

@hunter-hall
Copy link

hunter-hall commented Mar 13, 2024

@tridge Yeah, I'm not surprised you haven't seen this error... it seems weirdly non-deterministic. I'm sure it actually is indeed deterministic, but it only happens sometimes to me (even though I am uploading the same scripts every time). I'm thinking it might have something to do with the total number of kb of all the scripts combined... it seems to happen more often when I upload one or two large scripts vs one or two small ones (large being 4+ kb). However, it still happens sometimes when I upload 3-6 scripts that are all 1-2 kb in size. Again, I've only experienced this error in the plane 4.5.0-beta2 and the 4.6.0 dev build. The beta build was installed directly via Mission Planner and I tried a few different dev builds: one of the dev builds was my own (where I only changed one line in the lua binding descriptions file) and the others have been from builds I've done on this site: https://custom.ardupilot.org/

Also, once I do get the CRC error, my scripts will throw "syntax errors" and "unexpected symbol" errors in different lines every time I restart the board or restart scripting (even though the scripts themselves haven't changed). Eventually, I'll be able to get a good bootup/scripting restart and they work without issue, but it can take a dozen or more restarts before that happens.

This is all documented on this message (and below this message in the channel): https://discord.com/channels/674039678562861068/719466647710072832/1215451314700550144

As well as on this message (and below this message on this other channel): https://discord.com/channels/674039678562861068/797952826847920128/1217205074351095899

Edit: Also, this happens to me regardless of if I'm uploading scripts via USB, via telem radio, or via the SD card itself. This happened on two separate Pixhawk6Xs with two different SD cards and different telem radios and different USB cables.

Edit 2: Okay, I just put a new build on the board that has your crc32.py commit that you added a few hours ago on it. I haven't seen the same CRC error I was getting before (seen here: https://discord.com/channels/674039678562861068/719466647710072832/1216778004290732072) get thrown, however I am still getting all of the Lua behaviors as I was getting before as if the CRC error was thrown (i.e. seemingly random "syntax" errors and "unexpected symbol" errors that change every time I restart the board, even though the scripts themselves have not changed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants