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

EmbeddedPkg:Application:AndroidFastboot Request data length clearly #61

Open
wants to merge 1 commit into
base: hikey970_v1.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

#define FILL_BUF_SIZE 1024

#define RECEIVE_CMD_LEN 512

#define IS_DEVICE_PATH_NODE(node,type,subtype) (((node)->Type == (type)) && ((node)->SubType == (subtype)))

#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
Expand Down Expand Up @@ -160,15 +162,15 @@ HandleDownload (
SEND_LITERAL ("FAILNot enough memory");
} else {
ZeroMem (Response, sizeof Response);
if (mTransport->RequestReceive) {
mTransport->RequestReceive (mNumDataBytes);
}
AsciiSPrint (Response, sizeof Response, "DATA%x",
(UINT32)mNumDataBytes);
mTransport->Send (sizeof Response - 1, Response, &mFatalSendErrorEvent);

mState = ExpectDataState;
mBytesReceivedSoFar = 0;
if (mTransport->RequestReceive) {
mTransport->RequestReceive (mNumDataBytes);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenyu56 Your comments didn't hit the point. You change the sequence at here. You give a response first before receiving data. Could you explain the reason?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving these codes after sending response to host and set "mBytesReceivedSoFar = 0" is more reasonable.

}
}

Expand Down Expand Up @@ -433,6 +435,10 @@ AcceptCmd (
} else {
HandleOemCommand (Command);
}

if (mTransport->RequestReceive && mState == ExpectCmdState) {
mTransport->RequestReceive (RECEIVE_CMD_LEN);
}
}

STATIC
Expand Down Expand Up @@ -477,6 +483,16 @@ AcceptData (
SEND_LITERAL ("OKAY");
mState = ExpectCmdState;
}

if (mTransport->RequestReceive) {
if (mState == ExpectCmdState) {
mTransport->RequestReceive (RECEIVE_CMD_LEN);
} else if (mState == ExpectDataState) {
mTransport->RequestReceive (RemainingBytes - Size);
} else {
ASSERT (FALSE);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to move the code? If not, what happen?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the patchs in OpenPlatformPkg/Drivers/Usb/DwUsb3Dxe,we need to call "mTransport->RequestReceive" every time we want to start a receiving which was doing in OpenPlatformPkg/Drivers/Usb/DwUsb3Dxe before.

Copy link

@hzhuang1 hzhuang1 Apr 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenyu56 AndroidFastbootApp is a common application. HiKey, HiKey960 and ArmVExpress are also using AndroidFastbootApp. Do they need to update code when your patch is merged?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HiKey and ArmVExpress need to update code if you apply the patch to their branch.
Hikey960 do not need to update code because it share code of OpenPlatformPkg/Drivers/Usb/DwUsb3Dxe with Hikey970.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it's a problem to merge this patch. Our goal is to upstream everything. If it blocks other platform, it can't be upstream. Please help to prepare patches for other platform.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for replying late, I need some time to have a look at the code of Hikey and ArmVExpress. And I want to know how to verify the code of Hikey and ArmVExpress?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can follow it to build the firmware on HiKey (https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/plat/hikey.rst). There're some HiKey boards in Hisilicon lab. Since the document is for latest code, you could get a similar one from the same directory in your HiKey970 code base.
I'm not sure whether you have ArmVExpress. Maybe I can help to verify it on ArmVExpress.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenyu56 Any update?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently I look at the OpenPlatformPkg/Drivers/Usb/DwUsb3Dxe/DwUsbDxe.c of HiKey, and found that my patch need to be modified to adjust HiKey. I can do adjusting and verifying and HiKey, but I do not have ArmVExpress and I don't know where is the code of ArmVExpres.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EmbeddedPkg/Drivers/Isp1761UsbDxe/

}

/*
Expand All @@ -497,12 +513,6 @@ DataReady (
EFI_STATUS Status;

do {
// Indicate lower layer driver that how much bytes are expected.
if (mState == ExpectDataState) {
Size = mNumDataBytes;
} else {
Size = 0;
}
Status = mTransport->Receive (&Size, &Data);
if (!EFI_ERROR (Status)) {
if (mState == ExpectCmdState) {
Expand All @@ -512,7 +522,6 @@ DataReady (
} else {
ASSERT (FALSE);
}
FreePool (Data);
}
} while (!EFI_ERROR (Status));

Expand Down