-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
nvs_tool.py extracts strings wrongly in json format (IDFGH-14504) #15274
Comments
Hi @taliesin, I tried your issue and yes instead of actual value of string, it outputs the CRC of string(as mentioned in nvs_parser.py). In the nvs_parser string, blob_data and blob are spanned over multiple nvs pages, that's why CRC is outputted than it's actual value. But, when you flash your .csv file on device and try to retrieve the string data using nvs apis, the actual value will be retrieved. |
You're perfectly right, strings work in NVS. The intention of nvs_tool.py from my point of view is to retrieve values from an existing partition image. For each other (fixed size) type JSON output contains the actual value, there is no reason to output the size and CRC for a string value, which has a perfect representation in JSON. My use case was to fetch binary partition data from the device (factory partition), replace some of the values and store it back to the device. This is useful for data that changes like calibration data (re-calibration), repair information etc. while other information hardware version, production date ... remain the same. The partition is read-only for the firmware, the partition is marked as such. |
Hi @taliesin, Is your requirement requires only json format or any format. For text format you can do minimal dump for generating key value pairs. command -
|
I would have preferred JSON, but you're right the output of -d minimal -f text can be parsed quite easily. In my case using JSON would have generated all information to re-create the modified CSV file, with the text output I'll have to parse both the original CSV file (for the types) and the text output to generate the new CSV file. I don't want to push it, but I still think the behaviour of -f json for strings is wrong. |
Hi, we are about to fix the output of json format, which will print the required and proper information. Once it is done I will provide the pointer for the code. |
Great news, thanks for the effort. |
Answers checklist.
General issue report
I created a CSV file containing some factory data:
and used
python3 /components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py generate factory_data_0.15.2.csv factory_data.bin 0x4000
to create a NVS binary image
Then used
python3 /components/nvs_flash/nvs_partition_tool/nvs_tool.py factory_data.bin -f text
which says (emtpy stuff not shown):
Then I tried using the JSON output, which I piped to jq to filter stuff:
python3 nvs_tool.py -f json factory_data.bin | jq '.pages[].entries[]|select(.key == "hw_version")'
which returns:
Obviously the data.value entry is wrong. I checked the nvs_parser.py code to find:
... which is exactly what I get, but that is obviously wrong!
The text was updated successfully, but these errors were encountered: