i2c-vr: xdpe1x2xx fix CRLF type handling issue
1.Neglecting file format problem, image files using Windows will use
CRLF. Therefore, if a file has 39 valid characters on a line, adding
CRLF will reach 41.
Therefore, this should support both CRLF and LF.
Tested on the Yosemite5 platform.
```
$target=$(curl -k ${creds} --silent -X GET https://${bmc}/redfish/v1/UpdateService/FirmwareInventory/ | jq -r '.Members[] | select(.["@odata.id"] | contains("MB_VR_CPU0")) | .["@odata.id"]')
$ curl -k ${creds} -X GET https://${bmc}${target}
{
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/Yosemite5_MB_VR_CPU0_4377",
"@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory",
"Description": "Other image",
"Id": "Yosemite5_MB_VR_CPU0_4377",
"Name": "Software Inventory",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
},
"Updateable": true,
"Version": "3C7938BB"
$ fwpath="/media/leo/data/yv5/mb_vr_sni/yosemite5-mb-vr-cpu0-sni-1009-140B21B9.pldm"
$ curl -k ${creds} -H "Content-Type:multipart/form-data" -X POST -F UpdateParameters="{\"Targets\":[\"${target}\"],\"@Redfish.OperationApplyTime\":\"OnReset\"};type=application/json" -F "UpdateFile=@${fwpath};type=application/octet-stream" https://${bmc}/redfish/v1/UpdateService/update-multipart
{
"@odata.id": "/redfish/v1/TaskService/Tasks/0",
"@odata.type": "#Task.v1_4_3.Task",
"HidePayload": false,
"Id": "0",
"Messages": [
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The task with Id '0' has started.",
"MessageArgs": [
"0"
],
"MessageId": "TaskEvent.1.0.TaskStarted",
"MessageSeverity": "OK",
"Resolution": "None."
}
],
"Name": "Task 0",
"Payload": {
"HttpHeaders": [],
"HttpOperation": "POST",
"TargetUri": "/redfish/v1/UpdateService/update-multipart"
},
"PercentComplete": 0,
"StartTime": "2025-11-06T11:20:49+00:00",
"TaskMonitor": "/redfish/v1/TaskService/TaskMonitors/0",
"TaskState": "Running",
"TaskStatus": "OK"
}
$
$
============= ac cycle =============
$ target=$(curl -k ${creds} --silent -X GET https://${bmc}/redfish/v1/UpdateService/FirmwareInventory/ | jq -r '.Members[] | select(.["@odata.id"] | contains("MB_VR_CPU0")) | .["@odata.id"]')
$ curl -k ${creds} -X GET https://${bmc}${target}
{
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/Yosemite5_MB_VR_CPU0_5170",
"@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory",
"Description": "Other image",
"Id": "Yosemite5_MB_VR_CPU0_5170",
"Name": "Software Inventory",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
},
"Updateable": true,
"Version": "140B21B9"
}
```
Change-Id: I4ea7e7bdd30903c62af92868e643f7f0812b1fdb
Signed-off-by: Leo Yang <Leo-Yang@quantatw.com>
diff --git a/i2c-vr/xdpe1x2xx/xdpe1x2xx.cpp b/i2c-vr/xdpe1x2xx/xdpe1x2xx.cpp
index 1247bbe..206aef3 100644
--- a/i2c-vr/xdpe1x2xx/xdpe1x2xx.cpp
+++ b/i2c-vr/xdpe1x2xx/xdpe1x2xx.cpp
@@ -488,10 +488,14 @@
{
if (image[i] == '\n')
{
- const size_t lineLength = i - start;
+ size_t lineLength = i - start;
+ if (i > start && image[i - 1] == '\r')
+ {
+ lineLength--;
+ }
if (lineLength >= maxLineLength)
{
- error("line length exceeded 40, please check image file.");
+ error("line length >= 40, please check image file.");
return false;
}
std::memcpy(line, image + start, lineLength);