Hi,
I sent the last patchset of Marvell Armada 70x0 support. It is v2 of the firmware update shell command (v1 was in the very first big patchset of basic support). After long discussions, executing external shell commands was removed, as it's not proper (nor supported) solution in EDK2.
Command's code was cleaned-up and massively reworked in order to be independent from tftp and sf commands. Now 'fupdate' command performs updating firmware from file placed on local filesystem. It consumes MARVELL_SPI_FLASH_PROTOCOL and MARVELL_SPI_MASTER_PROTOCOL in order to handle SPI transfer of the image. Command also verifies image data correctness before burning to flash.
The code can be also found in github: https://github.com/MarvellEmbeddedProcessors/edk2-open-platform/commits/opp-...
Any comments or remarks would be welcome.
Best regards, Marcin
Changelog: v1 -> v2
* Remove executing external shell commands from commandline - now only local files can be burnt to flash * Add MARVELL_SPI_FLASH_PROTOCOL and MARVELL_SPI_MASTER_PROTOCOL usage * In order to be standalone command, enable detecting and configuring SPI flash * Style cleanup and new comments
Jan Dąbroś (2): Applications/FirmwareUpdate: Add 'fupdate' comand to shell Platforms/Marvell: Enable 'fupdate' command on Armada70x0 platform
Applications/FirmwareUpdate/FUpdate.c | 430 ++++++++++++++++++++++++++++++++ Applications/FirmwareUpdate/FUpdate.inf | 75 ++++++ Applications/FirmwareUpdate/FUpdate.uni | Bin 0 -> 5838 bytes Platforms/Marvell/Armada/Armada.dsc.inc | 1 + Platforms/Marvell/Marvell.dec | 1 + 5 files changed, 507 insertions(+) create mode 100644 Applications/FirmwareUpdate/FUpdate.c create mode 100644 Applications/FirmwareUpdate/FUpdate.inf create mode 100644 Applications/FirmwareUpdate/FUpdate.uni
From: Jan Dąbroś jsd@semihalf.com
'fupdate' command performs updating firmware from file placed on local filesystem. It consumes MARVELL_SPI_FLASH_PROTOCOL and MARVELL_SPI_MASTER_PROTOCOL in order to handle SPI transfer of the image. Command also verifies image data correctness before burning to flash.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com --- Applications/FirmwareUpdate/FUpdate.c | 430 ++++++++++++++++++++++++++++++++ Applications/FirmwareUpdate/FUpdate.inf | 75 ++++++ Applications/FirmwareUpdate/FUpdate.uni | Bin 0 -> 5838 bytes Platforms/Marvell/Marvell.dec | 1 + 4 files changed, 506 insertions(+) create mode 100644 Applications/FirmwareUpdate/FUpdate.c create mode 100644 Applications/FirmwareUpdate/FUpdate.inf create mode 100644 Applications/FirmwareUpdate/FUpdate.uni
diff --git a/Applications/FirmwareUpdate/FUpdate.c b/Applications/FirmwareUpdate/FUpdate.c new file mode 100644 index 0000000..f04f2e3 --- /dev/null +++ b/Applications/FirmwareUpdate/FUpdate.c @@ -0,0 +1,430 @@ +/******************************************************************************* +Copyright (C) 2016 Marvell International Ltd. + +Marvell BSD License Option + +If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name of Marvell nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*******************************************************************************/ +#include <ShellBase.h> +#include <Uefi.h> + +#include <Library/BaseLib.h> +#include <Library/BaseMemoryLib.h> +#include <Library/DebugLib.h> +#include <Library/FileHandleLib.h> +#include <Library/HiiLib.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/PrintLib.h> +#include <Library/ShellCEntryLib.h> +#include <Library/ShellCommandLib.h> +#include <Library/ShellLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/UefiLib.h> + +#include <Protocol/Spi.h> +#include <Protocol/SpiFlash.h> + +#define CMD_NAME_STRING L"fupdate" + +#define MAIN_HDR_MAGIC 0xB105B002 + +STATIC MARVELL_SPI_FLASH_PROTOCOL *SpiFlashProtocol; +STATIC MARVELL_SPI_MASTER_PROTOCOL *SpiMasterProtocol; + +CONST CHAR16 gShellFUpdateFileName[] = L"ShellCommand"; +EFI_HANDLE gShellFUpdateHiiHandle = NULL; + +STATIC CONST SHELL_PARAM_ITEM ParamList[] = { + {L"help", TypeFlag}, + {NULL , TypeMax} + }; + +typedef struct { + UINT32 Magic; // 0-3 + UINT32 PrologSize; // 4-7 + UINT32 PrologChecksum; // 8-11 + UINT32 BootImageSize; // 12-15 + UINT32 BootImageChecksum; // 16-19 + UINT32 Reserved0; // 20-23 + UINT32 LoadAddr; // 24-27 + UINT32 ExecAddr; // 28-31 + UINT8 UartConfig; // 32 + UINT8 Baudrate; // 33 + UINT8 ExtCount; // 34 + UINT8 AuxFlags; // 35 + UINT32 IoArg0; // 36-39 + UINT32 IoArg1; // 40-43 + UINT32 IoArg2; // 43-47 + UINT32 IoArg3; // 48-51 + UINT32 Reserved1; // 52-55 + UINT32 Reserved2; // 56-59 + UINT32 Reserved3; // 60-63 +} MV_IMAGE_HEADER; + +STATIC +EFI_STATUS +SpiFlashProbe ( + IN SPI_DEVICE *Slave + ) +{ + EFI_STATUS Status; + UINT8 IdBuffer[4]; + UINT32 Id, RefId; + + Id = PcdGet32 (PcdSpiFlashId); + + IdBuffer[0] = CMD_READ_ID; + + // Read 4 bytes of SPI flash ID + SpiFlashProtocol->ReadId (Slave, 4, IdBuffer); + + RefId = (IdBuffer[0] << 16) + (IdBuffer[1] << 8) + IdBuffer[2]; + + if (RefId == 0) { + Print (L"%s: No SPI flash detected"); + return EFI_DEVICE_ERROR; + } else if (RefId != Id) { + Print (L"%s: Unsupported SPI flash detected with ID=%2x\n", CMD_NAME_STRING, RefId); + return EFI_DEVICE_ERROR; + } + + Print (L"%s: Detected supported SPI flash with ID=%3x\n", CMD_NAME_STRING, RefId); + + Status = SpiFlashProtocol->Init (SpiFlashProtocol, Slave); + if (EFI_ERROR(Status)) { + Print (L"%s: Cannot initialize flash device\n", CMD_NAME_STRING); + return EFI_DEVICE_ERROR; + } + + return EFI_SUCCESS; +} + +STATIC +UINT32 +CountChecksum ( + UINT32 *Start, + UINT32 Length + ) +{ + UINT32 Sum = 0; + UINT32 *Startp = Start; + + do { + Sum += *Startp; + Startp++; + Length -= 4; + } while (Length > 0); + + return Sum; +} + +STATIC +EFI_STATUS +CheckImageHeader ( + IN OUT UINTN *ImageHeader + ) +{ + MV_IMAGE_HEADER *Header; + UINT32 HeaderLength, Checksum, ChecksumBackup; + + Header = (MV_IMAGE_HEADER *) ImageHeader; + HeaderLength = Header->PrologSize; + ChecksumBackup = Header->PrologChecksum; + + // Compare magic number + if (Header->Magic != MAIN_HDR_MAGIC) { + Print (L"%s: Bad Image magic 0x%08x != 0x%08x\n", CMD_NAME_STRING, Header->Magic, MAIN_HDR_MAGIC); + return EFI_DEVICE_ERROR; + } + + // The checksum field is discarded from calculation + Header->PrologChecksum = 0; + + Checksum = CountChecksum((UINT32 *)Header, HeaderLength); + if (Checksum != ChecksumBackup) { + Print (L"%s: Bad Image checksum. 0x%x != 0x%x\n", CMD_NAME_STRING, Checksum, ChecksumBackup); + return EFI_DEVICE_ERROR; + } + + // Restore checksum backup + Header->PrologChecksum = ChecksumBackup; + + return 0; +} + +STATIC +EFI_STATUS +PrepareFirmwareImage ( + IN LIST_ENTRY *CheckPackage, + IN OUT SHELL_FILE_HANDLE *FileHandle, + IN OUT UINTN **FileBuffer, + IN OUT UINTN *FileSize + ) +{ + CONST CHAR16 *FileStr; + EFI_STATUS Status; + UINT64 OpenMode; + UINTN *Buffer; + + // Parse string from commandline + FileStr = ShellCommandLineGetRawValue (CheckPackage, 1); + if (FileStr == NULL) { + Print (L"%s: Lack of image path\n", CMD_NAME_STRING); + return EFI_INVALID_PARAMETER; + } else { + Status = ShellIsFile (FileStr); + if (EFI_ERROR(Status)) { + Print (L"%s: Incorrect image path\n", CMD_NAME_STRING); + return EFI_INVALID_PARAMETER; + } + } + + // Obtain file size + OpenMode = EFI_FILE_MODE_READ; + + Status = ShellOpenFileByName (FileStr, FileHandle, OpenMode, 0); + if (EFI_ERROR (Status)) { + Print (L"%s: Cannot open Image file\n", CMD_NAME_STRING); + return EFI_DEVICE_ERROR; + } + + Status = FileHandleGetSize (*FileHandle, FileSize); + if (EFI_ERROR (Status)) { + Print (L"%s: Cannot get Image file size\n", CMD_NAME_STRING); + } + + // Read Image header into buffer + Buffer = AllocateZeroPool (*FileSize); + + Status = FileHandleRead (*FileHandle, FileSize, Buffer); + if (EFI_ERROR (Status)) { + Print (L"%s: Cannot read Image file header\n", CMD_NAME_STRING); + ShellCloseFile (FileHandle); + FreePool (Buffer); + return EFI_DEVICE_ERROR; + } + + *FileBuffer = Buffer; + + return EFI_SUCCESS; +} + +/** + Return the file name of the help text file if not using HII. + + @return The string pointer to the file name. +**/ +CONST CHAR16* +EFIAPI +ShellCommandGetManFileNameFUpdate ( + VOID + ) +{ + + return gShellFUpdateFileName; +} + +VOID +FUpdateUsage ( + VOID + ) +{ + Print (L"\nFirmware update command\n" + "fupdate <LocalFilePath>\n\n" + "LocalFilePath - path to local firmware image file\n" + "Example:\n" + "Update firmware from file fs2:flash-image.bin\n" + " fupdate fs2:flash-image.bin\n" + ); +} + +SHELL_STATUS +EFIAPI +ShellCommandRunFUpdate ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + IN SHELL_FILE_HANDLE FileHandle; + SPI_DEVICE *Slave; + UINTN FileSize; + UINTN *FileBuffer = NULL; + CHAR16 *ProblemParam; + LIST_ENTRY *CheckPackage; + EFI_STATUS Status; + + // Locate SPI protocols + Status = gBS->LocateProtocol ( + &gMarvellSpiFlashProtocolGuid, + NULL, + (VOID **)&SpiFlashProtocol + ); + + if (EFI_ERROR(Status)) { + Print (L"%s: Cannot locate SpiFlash protocol\n", CMD_NAME_STRING); + return SHELL_ABORTED; + } + + Status = gBS->LocateProtocol ( + &gMarvellSpiMasterProtocolGuid, + NULL, + (VOID **)&SpiMasterProtocol + ); + + if (EFI_ERROR(Status)) { + Print (L"%s: Cannot locate SpiMaster protocol\n", CMD_NAME_STRING); + return SHELL_ABORTED; + } + + // Parse command line + Status = ShellInitialize (); + if (EFI_ERROR (Status)) { + Print (L"%s: Error while initializing Shell\n", CMD_NAME_STRING); + ASSERT_EFI_ERROR (Status); + return SHELL_ABORTED; + } + + Status = ShellCommandLineParse (ParamList, &CheckPackage, &ProblemParam, TRUE); + if (EFI_ERROR (Status)) { + Print (L"%s: Invalid parameter\n", CMD_NAME_STRING); + return SHELL_ABORTED; + } + + if (ShellCommandLineGetFlag (CheckPackage, L"help")) { + FUpdateUsage(); + return EFI_SUCCESS; + } + + // Prepare local file to be burned into flash + Status = PrepareFirmwareImage (CheckPackage, &FileHandle, &FileBuffer, &FileSize); + if (EFI_ERROR(Status)) { + return SHELL_ABORTED; + } + + // Check image checksum and magic + Status = CheckImageHeader (FileBuffer); + if (EFI_ERROR(Status)) { + goto HeaderError; + } + + // Setup and probe SPI flash + Slave = SpiMasterProtocol->SetupDevice (SpiMasterProtocol, 0, 0); + if (Slave == NULL) { + Print(L"%s: Cannot allocate SPI device!\n", CMD_NAME_STRING); + goto HeaderError; + } + + Status = SpiFlashProbe (Slave); + if (EFI_ERROR(Status)) { + Print (L"%s: Error while performing SPI flash probe\n", CMD_NAME_STRING); + goto FlashProbeError; + } + + // Update firmware image in flash at offset 0x0 + Status = SpiFlashProtocol->Update (Slave, 0, FileSize, (UINT8 *)FileBuffer); + + // Release resources + SpiMasterProtocol->FreeDevice(Slave); + FreePool (FileBuffer); + ShellCloseFile (&FileHandle); + + if (EFI_ERROR(Status)) { + Print (L"%s: Error while performing flash update\n", CMD_NAME_STRING); + return SHELL_ABORTED; + } + + Print (L"%s: Update %d bytes at offset 0x0 succeeded!\n", CMD_NAME_STRING, FileSize); + + return EFI_SUCCESS; + +FlashProbeError: + SpiMasterProtocol->FreeDevice(Slave); +HeaderError: + FreePool (FileBuffer); + ShellCloseFile (&FileHandle); + + return SHELL_ABORTED; +} + +EFI_STATUS +EFIAPI +ShellFUpdateCommandConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + gShellFUpdateHiiHandle = NULL; + + gShellFUpdateHiiHandle = HiiAddPackages ( + &gShellFUpdateHiiGuid, + gImageHandle, + UefiShellFUpdateCommandLibStrings, + NULL + ); + + if (gShellFUpdateHiiHandle == NULL) { + Print (L"%s: Cannot add Hii package\n", CMD_NAME_STRING); + return EFI_DEVICE_ERROR; + } + + Status = ShellCommandRegisterCommandName ( + CMD_NAME_STRING, + ShellCommandRunFUpdate, + ShellCommandGetManFileNameFUpdate, + 0, + CMD_NAME_STRING, + TRUE, + gShellFUpdateHiiHandle, + STRING_TOKEN (STR_GET_HELP_FUPDATE) + ); + + if (EFI_ERROR(Status)) { + Print (L"%s: Error while registering command\n", CMD_NAME_STRING); + return SHELL_ABORTED; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +ShellFUpdateCommandDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + + if (gShellFUpdateHiiHandle != NULL) { + HiiRemovePackages (gShellFUpdateHiiHandle); + } + + return EFI_SUCCESS; +} diff --git a/Applications/FirmwareUpdate/FUpdate.inf b/Applications/FirmwareUpdate/FUpdate.inf new file mode 100644 index 0000000..4d4b97e --- /dev/null +++ b/Applications/FirmwareUpdate/FUpdate.inf @@ -0,0 +1,75 @@ +# +# Marvell BSD License Option +# +# If you received this File from Marvell, you may opt to use, redistribute +# and/or modify this File under the following licensing terms. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Marvell nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +[Defines] + INF_VERSION = 0x00010019 + BASE_NAME = UefiShellFUpdateCommandLib + FILE_GUID = 470292b2-926b-4ed8-8080-be7a260db627 + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 0.1 + LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER + CONSTRUCTOR = ShellFUpdateCommandConstructor + DESTRUCTOR = ShellFUpdateCommandDestructor + +[Sources] + FUpdate.c + FUpdate.uni + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + OpenPlatformPkg/Platforms/Marvell/Marvell.dec + ShellPkg/ShellPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + FileHandleLib + HiiLib + MemoryAllocationLib + PcdLib + ShellCommandLib + ShellLib + UefiBootServicesTableLib + UefiLib + UefiLib + UefiRuntimeServicesTableLib + +[Pcd] + gMarvellTokenSpaceGuid.PcdSpiFlashId + +[Protocols] + gMarvellSpiFlashProtocolGuid + gMarvellSpiMasterProtocolGuid + +[Guids] + gShellFUpdateHiiGuid diff --git a/Applications/FirmwareUpdate/FUpdate.uni b/Applications/FirmwareUpdate/FUpdate.uni new file mode 100644 index 0000000000000000000000000000000000000000..6143c0580f1d1ef8ce4fe619a1df1ce380adf2c0 GIT binary patch literal 5838 zcmd6r?N1v=5XSd&rTz~m@+FOuK&z@BXdB5G6OhbHeI_(&s)*P?EX6>LDdL}R`}}4Y z_Fim)B2|h`_TBEy&OY<Z%kJL4|E#8GU-k8E`X+VLMY>G4X_hAGEPYJ#RHUcs{Z98E z(pvgH{iLVebS#O#(@FZIt4KTPT#_g1JJ*}J#$MPH@A_(w)60Z*e$BBPsZ5(DH%TMu zI8RslFVenngr*p~lTP*KR@$$1pGl4p6GJjq&s>Nn8egO>-9MS0Q^{SVsru?OKUYs^ znhN!;+Src8b3GNB10={X)7Ui6^*l)*^bUIqjXT$yRmsoHx~ZO!JT-lb@LbynxN^K` zIn^kbyht}1doJb+wK5;k=NwOk%lRBE#O3S<wy>ix&4tFo-prWGG9T<MUW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$<bBU=9YU^87}oEdC(K*Aj0od2E5>-sRWMZ zNblhn9*8MgUOOV6qBc<l+)_Lm7Dv@^zN)=wg0E)Hg^|ck=D^1t#Rb(DByjF*hHkF` z;HuY_9BtH}dYtDK`s+R&t{O-1w3>cRPwrb!Y%j@~g;kdG85b+{3yV!w6Iy3>qPfzZ zX{9ojT`eo5pLsm0-dh|D(|hxLUpeqz+>;BQS42nq$~dmIf}d&5CJLW-MHLu-u?x7? zdOVi2?;F<Cx1yOQLNu-H0}g9a>}aO8dtoo~QX}3;{+%qy`l;i@HPx)wdSBPauAx3( z>^nf%KE)1&a40S~$+4?pPs1L58H!T5z)Evq`BJvzidIjPmp|l5{Q8S>lszr`Qdr`A zePHZ;Os~?Pl0b59lG~ERx38?lX)E?;i$*TP4(h0Xk3mjUJT#X_%?n8_X0gin<(*~h zvDtgF@4S(hIi(+~mG|D+OX0buJ?&^+)>Dm0=76ngbhQ19reJ%S)<S+^oo4sxJJnmY zGY6%`kVg`g?m$uXqa?6%tocvmOTIZQvTJ!v1RCa!I0-gk(Id$@uiD7@iqnDTaIo8+ zyV>(n7Ls@DKFB<FqO7V-xpu@iN36HTd@g76i6Zb~*Ok7Rt*dfT7boHmyUtp=;i;K( zo^g-W@FnOXzE@lLs*zExG5O1n$4E0i3Vj`1la=w~d*Rw6t)*%#8qJA``utI=&gXax z|FhF$H#bn-d!tC;obk9gsE#aZW7`pd*NC^C^!K$wv6t-H-o^KX5&g~k(7qbL-AH!% z2@qzF6)k>Vp2}uwYkVd1H)P>oTCvDQf3r9rtC-mFvyX}sR8P6g7q^*ax)F|8UHrt% QHyJ;b`f6NX>FQbZ9}*T`00000
literal 0 HcmV?d00001
diff --git a/Platforms/Marvell/Marvell.dec b/Platforms/Marvell/Marvell.dec index f1d2def..9e95976 100644 --- a/Platforms/Marvell/Marvell.dec +++ b/Platforms/Marvell/Marvell.dec @@ -54,6 +54,7 @@
gShellEepromHiiGuid = { 0xb2f4c714, 0x147f, 0x4ff7, { 0x82, 0x1b, 0xce, 0x7b, 0x91, 0x7f, 0x5f, 0x2f } } gShellSfHiiGuid = { 0x03a67756, 0x8cde, 0x4638, { 0x82, 0x34, 0x4a, 0x0f, 0x6d, 0x58, 0x81, 0x39 } } + gShellFUpdateHiiGuid = { 0x9b5d2176, 0x590a, 0x49db, { 0x89, 0x5d, 0x4a, 0x70, 0xfe, 0xad, 0xbe, 0x24 } }
[PcdsFixedAtBuild.common] #MPP
On Wed, Nov 30, 2016 at 09:11:03AM +0100, Marcin Wojtas wrote:
From: Jan Dąbroś jsd@semihalf.com
'fupdate' command performs updating firmware from file placed on local filesystem. It consumes MARVELL_SPI_FLASH_PROTOCOL and MARVELL_SPI_MASTER_PROTOCOL in order to handle SPI transfer of the image. Command also verifies image data correctness before burning to flash.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com
Applications/FirmwareUpdate/FUpdate.c | 430 ++++++++++++++++++++++++++++++++ Applications/FirmwareUpdate/FUpdate.inf | 75 ++++++ Applications/FirmwareUpdate/FUpdate.uni | Bin 0 -> 5838 bytes Platforms/Marvell/Marvell.dec | 1 + 4 files changed, 506 insertions(+) create mode 100644 Applications/FirmwareUpdate/FUpdate.c create mode 100644 Applications/FirmwareUpdate/FUpdate.inf create mode 100644 Applications/FirmwareUpdate/FUpdate.uni
diff --git a/Applications/FirmwareUpdate/FUpdate.c b/Applications/FirmwareUpdate/FUpdate.c new file mode 100644 index 0000000..f04f2e3 --- /dev/null +++ b/Applications/FirmwareUpdate/FUpdate.c @@ -0,0 +1,430 @@ +/******************************************************************************* +Copyright (C) 2016 Marvell International Ltd.
+Marvell BSD License Option
+If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+* Neither the name of Marvell nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************/ +#include <ShellBase.h> +#include <Uefi.h>
+#include <Library/BaseLib.h> +#include <Library/BaseMemoryLib.h> +#include <Library/DebugLib.h> +#include <Library/FileHandleLib.h> +#include <Library/HiiLib.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/PrintLib.h> +#include <Library/ShellCEntryLib.h> +#include <Library/ShellCommandLib.h> +#include <Library/ShellLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/UefiLib.h>
+#include <Protocol/Spi.h> +#include <Protocol/SpiFlash.h>
+#define CMD_NAME_STRING L"fupdate"
+#define MAIN_HDR_MAGIC 0xB105B002
+STATIC MARVELL_SPI_FLASH_PROTOCOL *SpiFlashProtocol; +STATIC MARVELL_SPI_MASTER_PROTOCOL *SpiMasterProtocol;
+CONST CHAR16 gShellFUpdateFileName[] = L"ShellCommand"; +EFI_HANDLE gShellFUpdateHiiHandle = NULL;
These can still be STATIC, right?
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"help", TypeFlag},
- {NULL , TypeMax}
- };
+typedef struct {
- UINT32 Magic; // 0-3
I guess you're counting bytes in the comments, but could you be explicit about this? (I.e.: // Bytes 0-3 // 4-7 // ... )
- UINT32 PrologSize; // 4-7
- UINT32 PrologChecksum; // 8-11
- UINT32 BootImageSize; // 12-15
- UINT32 BootImageChecksum; // 16-19
- UINT32 Reserved0; // 20-23
- UINT32 LoadAddr; // 24-27
- UINT32 ExecAddr; // 28-31
- UINT8 UartConfig; // 32
- UINT8 Baudrate; // 33
- UINT8 ExtCount; // 34
- UINT8 AuxFlags; // 35
- UINT32 IoArg0; // 36-39
- UINT32 IoArg1; // 40-43
- UINT32 IoArg2; // 43-47
- UINT32 IoArg3; // 48-51
- UINT32 Reserved1; // 52-55
- UINT32 Reserved2; // 56-59
- UINT32 Reserved3; // 60-63
+} MV_IMAGE_HEADER;
MV_FIRMWARE_IMAGE_HEADER?
+STATIC +EFI_STATUS +SpiFlashProbe (
- IN SPI_DEVICE *Slave
- )
+{
- EFI_STATUS Status;
- UINT8 IdBuffer[4];
- UINT32 Id, RefId;
- Id = PcdGet32 (PcdSpiFlashId);
- IdBuffer[0] = CMD_READ_ID;
- // Read 4 bytes of SPI flash ID
Why 4 bytes?
(Or could this be reworded as "Read SPI flash id - 4 bytes"? If so, please do. And preferably add something like SPI_ID_SIZE instead of the 4.)
- SpiFlashProtocol->ReadId (Slave, 4, IdBuffer);
- RefId = (IdBuffer[0] << 16) + (IdBuffer[1] << 8) + IdBuffer[2];
Read into an UINT32 instead, SwapBytes32 & ~0xff000000U ?
- if (RefId == 0) {
- Print (L"%s: No SPI flash detected");
- return EFI_DEVICE_ERROR;
- } else if (RefId != Id) {
- Print (L"%s: Unsupported SPI flash detected with ID=%2x\n", CMD_NAME_STRING, RefId);
- return EFI_DEVICE_ERROR;
- }
- Print (L"%s: Detected supported SPI flash with ID=%3x\n", CMD_NAME_STRING, RefId);
- Status = SpiFlashProtocol->Init (SpiFlashProtocol, Slave);
- if (EFI_ERROR(Status)) {
- Print (L"%s: Cannot initialize flash device\n", CMD_NAME_STRING);
- return EFI_DEVICE_ERROR;
- }
- return EFI_SUCCESS;
+}
+STATIC +UINT32 +CountChecksum (
Use CalculateSum32 instead?
- UINT32 *Start,
- UINT32 Length
- )
+{
- UINT32 Sum = 0;
- UINT32 *Startp = Start;
- do {
- Sum += *Startp;
- Startp++;
- Length -= 4;
- } while (Length > 0);
- return Sum;
+}
+STATIC +EFI_STATUS +CheckImageHeader (
- IN OUT UINTN *ImageHeader
- )
+{
- MV_IMAGE_HEADER *Header;
- UINT32 HeaderLength, Checksum, ChecksumBackup;
- Header = (MV_IMAGE_HEADER *) ImageHeader;
- HeaderLength = Header->PrologSize;
- ChecksumBackup = Header->PrologChecksum;
- // Compare magic number
- if (Header->Magic != MAIN_HDR_MAGIC) {
- Print (L"%s: Bad Image magic 0x%08x != 0x%08x\n", CMD_NAME_STRING, Header->Magic, MAIN_HDR_MAGIC);
- return EFI_DEVICE_ERROR;
- }
- // The checksum field is discarded from calculation
- Header->PrologChecksum = 0;
- Checksum = CountChecksum((UINT32 *)Header, HeaderLength);
Don't forget the space before (.
- if (Checksum != ChecksumBackup) {
- Print (L"%s: Bad Image checksum. 0x%x != 0x%x\n", CMD_NAME_STRING, Checksum, ChecksumBackup);
- return EFI_DEVICE_ERROR;
- }
- // Restore checksum backup
- Header->PrologChecksum = ChecksumBackup;
- return 0;
+}
+STATIC +EFI_STATUS +PrepareFirmwareImage (
- IN LIST_ENTRY *CheckPackage,
- IN OUT SHELL_FILE_HANDLE *FileHandle,
- IN OUT UINTN **FileBuffer,
- IN OUT UINTN *FileSize
- )
+{
- CONST CHAR16 *FileStr;
- EFI_STATUS Status;
- UINT64 OpenMode;
- UINTN *Buffer;
- // Parse string from commandline
- FileStr = ShellCommandLineGetRawValue (CheckPackage, 1);
- if (FileStr == NULL) {
- Print (L"%s: Lack of image path\n", CMD_NAME_STRING);
To tied to the internals - how about just "No image specified"?
- return EFI_INVALID_PARAMETER;
- } else {
- Status = ShellIsFile (FileStr);
- if (EFI_ERROR(Status)) {
Print (L"%s: Incorrect image path\n", CMD_NAME_STRING);
"File not found"?
return EFI_INVALID_PARAMETER;
- }
- }
- // Obtain file size
- OpenMode = EFI_FILE_MODE_READ;
- Status = ShellOpenFileByName (FileStr, FileHandle, OpenMode, 0);
- if (EFI_ERROR (Status)) {
Print (L"%s: Cannot open Image file\n", CMD_NAME_STRING);
return EFI_DEVICE_ERROR;
- }
- Status = FileHandleGetSize (*FileHandle, FileSize);
- if (EFI_ERROR (Status)) {
Print (L"%s: Cannot get Image file size\n", CMD_NAME_STRING);
- }
- // Read Image header into buffer
- Buffer = AllocateZeroPool (*FileSize);
- Status = FileHandleRead (*FileHandle, FileSize, Buffer);
- if (EFI_ERROR (Status)) {
- Print (L"%s: Cannot read Image file header\n", CMD_NAME_STRING);
- ShellCloseFile (FileHandle);
- FreePool (Buffer);
- return EFI_DEVICE_ERROR;
- }
- *FileBuffer = Buffer;
- return EFI_SUCCESS;
+}
+/**
- Return the file name of the help text file if not using HII.
It returns the string L"ShellCommand". If you're not actually providing anything, NULL is fine to pass to ShellCommandRegisterCommandName, at which point this function is not needed at all.
If you want to look for a file that could hypothetically contain the usage information, use L"ShellCommands" instead, like all but one shell command in edk2 does.
I guess you glanced at UefiShellTftpCommandLib for inspiration ... which looks like it has missed the point somewhat.
- @return The string pointer to the file name.
+**/
STATIC?
+CONST CHAR16* +EFIAPI +ShellCommandGetManFileNameFUpdate (
- VOID
- )
+{
No need for the blank line.
- return gShellFUpdateFileName;
+}
STATIC?
+VOID +FUpdateUsage (
- VOID
- )
+{
- Print (L"\nFirmware update command\n"
"fupdate <LocalFilePath>\n\n"
"LocalFilePath - path to local firmware image file\n"
"Example:\n"
"Update firmware from file fs2:flash-image.bin\n"
" fupdate fs2:flash-image.bin\n"
- );
+}
STATIC?
+SHELL_STATUS +EFIAPI +ShellCommandRunFUpdate (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+{
- IN SHELL_FILE_HANDLE FileHandle;
- SPI_DEVICE *Slave;
- UINTN FileSize;
- UINTN *FileBuffer = NULL;
- CHAR16 *ProblemParam;
- LIST_ENTRY *CheckPackage;
- EFI_STATUS Status;
- // Locate SPI protocols
- Status = gBS->LocateProtocol (
&gMarvellSpiFlashProtocolGuid,
NULL,
(VOID **)&SpiFlashProtocol
);
- if (EFI_ERROR(Status)) {
- Print (L"%s: Cannot locate SpiFlash protocol\n", CMD_NAME_STRING);
- return SHELL_ABORTED;
- }
- Status = gBS->LocateProtocol (
&gMarvellSpiMasterProtocolGuid,
NULL,
(VOID **)&SpiMasterProtocol
);
- if (EFI_ERROR(Status)) {
- Print (L"%s: Cannot locate SpiMaster protocol\n", CMD_NAME_STRING);
- return SHELL_ABORTED;
- }
- // Parse command line
- Status = ShellInitialize ();
- if (EFI_ERROR (Status)) {
- Print (L"%s: Error while initializing Shell\n", CMD_NAME_STRING);
- ASSERT_EFI_ERROR (Status);
- return SHELL_ABORTED;
- }
- Status = ShellCommandLineParse (ParamList, &CheckPackage, &ProblemParam, TRUE);
- if (EFI_ERROR (Status)) {
- Print (L"%s: Invalid parameter\n", CMD_NAME_STRING);
- return SHELL_ABORTED;
- }
- if (ShellCommandLineGetFlag (CheckPackage, L"help")) {
- FUpdateUsage();
- return EFI_SUCCESS;
- }
- // Prepare local file to be burned into flash
- Status = PrepareFirmwareImage (CheckPackage, &FileHandle, &FileBuffer, &FileSize);
- if (EFI_ERROR(Status)) {
- return SHELL_ABORTED;
- }
- // Check image checksum and magic
- Status = CheckImageHeader (FileBuffer);
- if (EFI_ERROR(Status)) {
- goto HeaderError;
- }
- // Setup and probe SPI flash
- Slave = SpiMasterProtocol->SetupDevice (SpiMasterProtocol, 0, 0);
- if (Slave == NULL) {
- Print(L"%s: Cannot allocate SPI device!\n", CMD_NAME_STRING);
- goto HeaderError;
- }
- Status = SpiFlashProbe (Slave);
- if (EFI_ERROR(Status)) {
- Print (L"%s: Error while performing SPI flash probe\n", CMD_NAME_STRING);
- goto FlashProbeError;
- }
- // Update firmware image in flash at offset 0x0
- Status = SpiFlashProtocol->Update (Slave, 0, FileSize, (UINT8 *)FileBuffer);
- // Release resources
- SpiMasterProtocol->FreeDevice(Slave);
- FreePool (FileBuffer);
- ShellCloseFile (&FileHandle);
- if (EFI_ERROR(Status)) {
- Print (L"%s: Error while performing flash update\n", CMD_NAME_STRING);
- return SHELL_ABORTED;
- }
- Print (L"%s: Update %d bytes at offset 0x0 succeeded!\n", CMD_NAME_STRING, FileSize);
- return EFI_SUCCESS;
+FlashProbeError:
- SpiMasterProtocol->FreeDevice(Slave);
+HeaderError:
- FreePool (FileBuffer);
- ShellCloseFile (&FileHandle);
- return SHELL_ABORTED;
+}
+EFI_STATUS +EFIAPI +ShellFUpdateCommandConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+{
- EFI_STATUS Status;
- gShellFUpdateHiiHandle = NULL;
- gShellFUpdateHiiHandle = HiiAddPackages (
&gShellFUpdateHiiGuid,
gImageHandle,
UefiShellFUpdateCommandLibStrings,
NULL
);
- if (gShellFUpdateHiiHandle == NULL) {
- Print (L"%s: Cannot add Hii package\n", CMD_NAME_STRING);
- return EFI_DEVICE_ERROR;
- }
- Status = ShellCommandRegisterCommandName (
CMD_NAME_STRING,
ShellCommandRunFUpdate,
ShellCommandGetManFileNameFUpdate,
0,
CMD_NAME_STRING,
TRUE,
gShellFUpdateHiiHandle,
STRING_TOKEN (STR_GET_HELP_FUPDATE)
);
- if (EFI_ERROR(Status)) {
- Print (L"%s: Error while registering command\n", CMD_NAME_STRING);
- return SHELL_ABORTED;
- }
- return EFI_SUCCESS;
+}
+EFI_STATUS +EFIAPI +ShellFUpdateCommandDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+{
- if (gShellFUpdateHiiHandle != NULL) {
- HiiRemovePackages (gShellFUpdateHiiHandle);
- }
- return EFI_SUCCESS;
+} diff --git a/Applications/FirmwareUpdate/FUpdate.inf b/Applications/FirmwareUpdate/FUpdate.inf new file mode 100644 index 0000000..4d4b97e --- /dev/null +++ b/Applications/FirmwareUpdate/FUpdate.inf @@ -0,0 +1,75 @@ +# +# Marvell BSD License Option +# +# If you received this File from Marvell, you may opt to use, redistribute +# and/or modify this File under the following licensing terms. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Marvell nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#
+[Defines]
- INF_VERSION = 0x00010019
- BASE_NAME = UefiShellFUpdateCommandLib
- FILE_GUID = 470292b2-926b-4ed8-8080-be7a260db627
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 0.1
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = ShellFUpdateCommandConstructor
- DESTRUCTOR = ShellFUpdateCommandDestructor
+[Sources]
- FUpdate.c
- FUpdate.uni
+[Packages]
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- OpenPlatformPkg/Platforms/Marvell/Marvell.dec
- ShellPkg/ShellPkg.dec
+[LibraryClasses]
- BaseLib
- BaseMemoryLib
- DebugLib
- FileHandleLib
- HiiLib
- MemoryAllocationLib
- PcdLib
- ShellCommandLib
- ShellLib
- UefiBootServicesTableLib
- UefiLib
- UefiLib
- UefiRuntimeServicesTableLib
+[Pcd]
- gMarvellTokenSpaceGuid.PcdSpiFlashId
+[Protocols]
- gMarvellSpiFlashProtocolGuid
- gMarvellSpiMasterProtocolGuid
+[Guids]
- gShellFUpdateHiiGuid
diff --git a/Applications/FirmwareUpdate/FUpdate.uni b/Applications/FirmwareUpdate/FUpdate.uni new file mode 100644 index 0000000000000000000000000000000000000000..6143c0580f1d1ef8ce4fe619a1df1ce380adf2c0 GIT binary patch literal 5838 zcmd6r?N1v=5XSd&rTz~m@+FOuK&z@BXdB5G6OhbHeI_(&s)*P?EX6>LDdL}R`}}4Y z_Fim)B2|h`_TBEy&OY<Z%kJL4|E#8GU-k8E`X+VLMY>G4X_hAGEPYJ#RHUcs{Z98E z(pvgH{iLVebS#O#(@FZIt4KTPT#_g1JJ*}J#$MPH@A_(w)60Z*e$BBPsZ5(DH%TMu zI8RslFVenngr*p~lTP*KR@$$1pGl4p6GJjq&s>Nn8egO>-9MS0Q^{SVsru?OKUYs^ znhN!;+Src8b3GNB10={X)7Ui6^*l)*^bUIqjXT$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ec +++ b/Platforms/Marvell/Marvell.dec @@ -54,6 +54,7 @@ gShellEepromHiiGuid = { 0xb2f4c714, 0x147f, 0x4ff7, { 0x82, 0x1b, 0xce, 0x7b, 0x91, 0x7f, 0x5f, 0x2f } } gShellSfHiiGuid = { 0x03a67756, 0x8cde, 0x4638, { 0x82, 0x34, 0x4a, 0x0f, 0x6d, 0x58, 0x81, 0x39 } }
- gShellFUpdateHiiGuid = { 0x9b5d2176, 0x590a, 0x49db, { 0x89, 0x5d, 0x4a, 0x70, 0xfe, 0xad, 0xbe, 0x24 } }
Insert sorted? :)
/ Leif
[PcdsFixedAtBuild.common]
#MPP
1.8.3.1
Hi Leif,
Thanks a lot. Reworking immediately.
Best regards, Marcin
2016-11-30 16:13 GMT+01:00 Leif Lindholm leif.lindholm@linaro.org:
On Wed, Nov 30, 2016 at 09:11:03AM +0100, Marcin Wojtas wrote:
From: Jan Dąbroś jsd@semihalf.com
'fupdate' command performs updating firmware from file placed on local filesystem. It consumes MARVELL_SPI_FLASH_PROTOCOL and MARVELL_SPI_MASTER_PROTOCOL in order to handle SPI transfer of the image. Command also verifies image data correctness before burning to flash.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com
Applications/FirmwareUpdate/FUpdate.c | 430 ++++++++++++++++++++++++++++++++ Applications/FirmwareUpdate/FUpdate.inf | 75 ++++++ Applications/FirmwareUpdate/FUpdate.uni | Bin 0 -> 5838 bytes Platforms/Marvell/Marvell.dec | 1 + 4 files changed, 506 insertions(+) create mode 100644 Applications/FirmwareUpdate/FUpdate.c create mode 100644 Applications/FirmwareUpdate/FUpdate.inf create mode 100644 Applications/FirmwareUpdate/FUpdate.uni
diff --git a/Applications/FirmwareUpdate/FUpdate.c b/Applications/FirmwareUpdate/FUpdate.c new file mode 100644 index 0000000..f04f2e3 --- /dev/null +++ b/Applications/FirmwareUpdate/FUpdate.c @@ -0,0 +1,430 @@ +/******************************************************************************* +Copyright (C) 2016 Marvell International Ltd.
+Marvell BSD License Option
+If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+* Neither the name of Marvell nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************/ +#include <ShellBase.h> +#include <Uefi.h>
+#include <Library/BaseLib.h> +#include <Library/BaseMemoryLib.h> +#include <Library/DebugLib.h> +#include <Library/FileHandleLib.h> +#include <Library/HiiLib.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/PrintLib.h> +#include <Library/ShellCEntryLib.h> +#include <Library/ShellCommandLib.h> +#include <Library/ShellLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/UefiLib.h>
+#include <Protocol/Spi.h> +#include <Protocol/SpiFlash.h>
+#define CMD_NAME_STRING L"fupdate"
+#define MAIN_HDR_MAGIC 0xB105B002
+STATIC MARVELL_SPI_FLASH_PROTOCOL *SpiFlashProtocol; +STATIC MARVELL_SPI_MASTER_PROTOCOL *SpiMasterProtocol;
+CONST CHAR16 gShellFUpdateFileName[] = L"ShellCommand"; +EFI_HANDLE gShellFUpdateHiiHandle = NULL;
These can still be STATIC, right?
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"help", TypeFlag},
- {NULL , TypeMax}
- };
+typedef struct {
- UINT32 Magic; // 0-3
I guess you're counting bytes in the comments, but could you be explicit about this? (I.e.: // Bytes 0-3 // 4-7 // ... )
- UINT32 PrologSize; // 4-7
- UINT32 PrologChecksum; // 8-11
- UINT32 BootImageSize; // 12-15
- UINT32 BootImageChecksum; // 16-19
- UINT32 Reserved0; // 20-23
- UINT32 LoadAddr; // 24-27
- UINT32 ExecAddr; // 28-31
- UINT8 UartConfig; // 32
- UINT8 Baudrate; // 33
- UINT8 ExtCount; // 34
- UINT8 AuxFlags; // 35
- UINT32 IoArg0; // 36-39
- UINT32 IoArg1; // 40-43
- UINT32 IoArg2; // 43-47
- UINT32 IoArg3; // 48-51
- UINT32 Reserved1; // 52-55
- UINT32 Reserved2; // 56-59
- UINT32 Reserved3; // 60-63
+} MV_IMAGE_HEADER;
MV_FIRMWARE_IMAGE_HEADER?
+STATIC +EFI_STATUS +SpiFlashProbe (
- IN SPI_DEVICE *Slave
- )
+{
- EFI_STATUS Status;
- UINT8 IdBuffer[4];
- UINT32 Id, RefId;
- Id = PcdGet32 (PcdSpiFlashId);
- IdBuffer[0] = CMD_READ_ID;
- // Read 4 bytes of SPI flash ID
Why 4 bytes?
(Or could this be reworded as "Read SPI flash id - 4 bytes"? If so, please do. And preferably add something like SPI_ID_SIZE instead of the 4.)
- SpiFlashProtocol->ReadId (Slave, 4, IdBuffer);
- RefId = (IdBuffer[0] << 16) + (IdBuffer[1] << 8) + IdBuffer[2];
Read into an UINT32 instead, SwapBytes32 & ~0xff000000U ?
- if (RefId == 0) {
- Print (L"%s: No SPI flash detected");
- return EFI_DEVICE_ERROR;
- } else if (RefId != Id) {
- Print (L"%s: Unsupported SPI flash detected with ID=%2x\n", CMD_NAME_STRING, RefId);
- return EFI_DEVICE_ERROR;
- }
- Print (L"%s: Detected supported SPI flash with ID=%3x\n", CMD_NAME_STRING, RefId);
- Status = SpiFlashProtocol->Init (SpiFlashProtocol, Slave);
- if (EFI_ERROR(Status)) {
- Print (L"%s: Cannot initialize flash device\n", CMD_NAME_STRING);
- return EFI_DEVICE_ERROR;
- }
- return EFI_SUCCESS;
+}
+STATIC +UINT32 +CountChecksum (
Use CalculateSum32 instead?
- UINT32 *Start,
- UINT32 Length
- )
+{
- UINT32 Sum = 0;
- UINT32 *Startp = Start;
- do {
- Sum += *Startp;
- Startp++;
- Length -= 4;
- } while (Length > 0);
- return Sum;
+}
+STATIC +EFI_STATUS +CheckImageHeader (
- IN OUT UINTN *ImageHeader
- )
+{
- MV_IMAGE_HEADER *Header;
- UINT32 HeaderLength, Checksum, ChecksumBackup;
- Header = (MV_IMAGE_HEADER *) ImageHeader;
- HeaderLength = Header->PrologSize;
- ChecksumBackup = Header->PrologChecksum;
- // Compare magic number
- if (Header->Magic != MAIN_HDR_MAGIC) {
- Print (L"%s: Bad Image magic 0x%08x != 0x%08x\n", CMD_NAME_STRING, Header->Magic, MAIN_HDR_MAGIC);
- return EFI_DEVICE_ERROR;
- }
- // The checksum field is discarded from calculation
- Header->PrologChecksum = 0;
- Checksum = CountChecksum((UINT32 *)Header, HeaderLength);
Don't forget the space before (.
- if (Checksum != ChecksumBackup) {
- Print (L"%s: Bad Image checksum. 0x%x != 0x%x\n", CMD_NAME_STRING, Checksum, ChecksumBackup);
- return EFI_DEVICE_ERROR;
- }
- // Restore checksum backup
- Header->PrologChecksum = ChecksumBackup;
- return 0;
+}
+STATIC +EFI_STATUS +PrepareFirmwareImage (
- IN LIST_ENTRY *CheckPackage,
- IN OUT SHELL_FILE_HANDLE *FileHandle,
- IN OUT UINTN **FileBuffer,
- IN OUT UINTN *FileSize
- )
+{
- CONST CHAR16 *FileStr;
- EFI_STATUS Status;
- UINT64 OpenMode;
- UINTN *Buffer;
- // Parse string from commandline
- FileStr = ShellCommandLineGetRawValue (CheckPackage, 1);
- if (FileStr == NULL) {
- Print (L"%s: Lack of image path\n", CMD_NAME_STRING);
To tied to the internals - how about just "No image specified"?
- return EFI_INVALID_PARAMETER;
- } else {
- Status = ShellIsFile (FileStr);
- if (EFI_ERROR(Status)) {
Print (L"%s: Incorrect image path\n", CMD_NAME_STRING);
"File not found"?
return EFI_INVALID_PARAMETER;
- }
- }
- // Obtain file size
- OpenMode = EFI_FILE_MODE_READ;
- Status = ShellOpenFileByName (FileStr, FileHandle, OpenMode, 0);
- if (EFI_ERROR (Status)) {
Print (L"%s: Cannot open Image file\n", CMD_NAME_STRING);
return EFI_DEVICE_ERROR;
- }
- Status = FileHandleGetSize (*FileHandle, FileSize);
- if (EFI_ERROR (Status)) {
Print (L"%s: Cannot get Image file size\n", CMD_NAME_STRING);
- }
- // Read Image header into buffer
- Buffer = AllocateZeroPool (*FileSize);
- Status = FileHandleRead (*FileHandle, FileSize, Buffer);
- if (EFI_ERROR (Status)) {
- Print (L"%s: Cannot read Image file header\n", CMD_NAME_STRING);
- ShellCloseFile (FileHandle);
- FreePool (Buffer);
- return EFI_DEVICE_ERROR;
- }
- *FileBuffer = Buffer;
- return EFI_SUCCESS;
+}
+/**
- Return the file name of the help text file if not using HII.
It returns the string L"ShellCommand". If you're not actually providing anything, NULL is fine to pass to ShellCommandRegisterCommandName, at which point this function is not needed at all.
If you want to look for a file that could hypothetically contain the usage information, use L"ShellCommands" instead, like all but one shell command in edk2 does.
I guess you glanced at UefiShellTftpCommandLib for inspiration ... which looks like it has missed the point somewhat.
- @return The string pointer to the file name.
+**/
STATIC?
+CONST CHAR16* +EFIAPI +ShellCommandGetManFileNameFUpdate (
- VOID
- )
+{
No need for the blank line.
- return gShellFUpdateFileName;
+}
STATIC?
+VOID +FUpdateUsage (
- VOID
- )
+{
- Print (L"\nFirmware update command\n"
"fupdate <LocalFilePath>\n\n"
"LocalFilePath - path to local firmware image file\n"
"Example:\n"
"Update firmware from file fs2:flash-image.bin\n"
" fupdate fs2:flash-image.bin\n"
- );
+}
STATIC?
+SHELL_STATUS +EFIAPI +ShellCommandRunFUpdate (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+{
- IN SHELL_FILE_HANDLE FileHandle;
- SPI_DEVICE *Slave;
- UINTN FileSize;
- UINTN *FileBuffer = NULL;
- CHAR16 *ProblemParam;
- LIST_ENTRY *CheckPackage;
- EFI_STATUS Status;
- // Locate SPI protocols
- Status = gBS->LocateProtocol (
&gMarvellSpiFlashProtocolGuid,
NULL,
(VOID **)&SpiFlashProtocol
);
- if (EFI_ERROR(Status)) {
- Print (L"%s: Cannot locate SpiFlash protocol\n", CMD_NAME_STRING);
- return SHELL_ABORTED;
- }
- Status = gBS->LocateProtocol (
&gMarvellSpiMasterProtocolGuid,
NULL,
(VOID **)&SpiMasterProtocol
);
- if (EFI_ERROR(Status)) {
- Print (L"%s: Cannot locate SpiMaster protocol\n", CMD_NAME_STRING);
- return SHELL_ABORTED;
- }
- // Parse command line
- Status = ShellInitialize ();
- if (EFI_ERROR (Status)) {
- Print (L"%s: Error while initializing Shell\n", CMD_NAME_STRING);
- ASSERT_EFI_ERROR (Status);
- return SHELL_ABORTED;
- }
- Status = ShellCommandLineParse (ParamList, &CheckPackage, &ProblemParam, TRUE);
- if (EFI_ERROR (Status)) {
- Print (L"%s: Invalid parameter\n", CMD_NAME_STRING);
- return SHELL_ABORTED;
- }
- if (ShellCommandLineGetFlag (CheckPackage, L"help")) {
- FUpdateUsage();
- return EFI_SUCCESS;
- }
- // Prepare local file to be burned into flash
- Status = PrepareFirmwareImage (CheckPackage, &FileHandle, &FileBuffer, &FileSize);
- if (EFI_ERROR(Status)) {
- return SHELL_ABORTED;
- }
- // Check image checksum and magic
- Status = CheckImageHeader (FileBuffer);
- if (EFI_ERROR(Status)) {
- goto HeaderError;
- }
- // Setup and probe SPI flash
- Slave = SpiMasterProtocol->SetupDevice (SpiMasterProtocol, 0, 0);
- if (Slave == NULL) {
- Print(L"%s: Cannot allocate SPI device!\n", CMD_NAME_STRING);
- goto HeaderError;
- }
- Status = SpiFlashProbe (Slave);
- if (EFI_ERROR(Status)) {
- Print (L"%s: Error while performing SPI flash probe\n", CMD_NAME_STRING);
- goto FlashProbeError;
- }
- // Update firmware image in flash at offset 0x0
- Status = SpiFlashProtocol->Update (Slave, 0, FileSize, (UINT8 *)FileBuffer);
- // Release resources
- SpiMasterProtocol->FreeDevice(Slave);
- FreePool (FileBuffer);
- ShellCloseFile (&FileHandle);
- if (EFI_ERROR(Status)) {
- Print (L"%s: Error while performing flash update\n", CMD_NAME_STRING);
- return SHELL_ABORTED;
- }
- Print (L"%s: Update %d bytes at offset 0x0 succeeded!\n", CMD_NAME_STRING, FileSize);
- return EFI_SUCCESS;
+FlashProbeError:
- SpiMasterProtocol->FreeDevice(Slave);
+HeaderError:
- FreePool (FileBuffer);
- ShellCloseFile (&FileHandle);
- return SHELL_ABORTED;
+}
+EFI_STATUS +EFIAPI +ShellFUpdateCommandConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+{
- EFI_STATUS Status;
- gShellFUpdateHiiHandle = NULL;
- gShellFUpdateHiiHandle = HiiAddPackages (
&gShellFUpdateHiiGuid,
gImageHandle,
UefiShellFUpdateCommandLibStrings,
NULL
);
- if (gShellFUpdateHiiHandle == NULL) {
- Print (L"%s: Cannot add Hii package\n", CMD_NAME_STRING);
- return EFI_DEVICE_ERROR;
- }
- Status = ShellCommandRegisterCommandName (
CMD_NAME_STRING,
ShellCommandRunFUpdate,
ShellCommandGetManFileNameFUpdate,
0,
CMD_NAME_STRING,
TRUE,
gShellFUpdateHiiHandle,
STRING_TOKEN (STR_GET_HELP_FUPDATE)
);
- if (EFI_ERROR(Status)) {
- Print (L"%s: Error while registering command\n", CMD_NAME_STRING);
- return SHELL_ABORTED;
- }
- return EFI_SUCCESS;
+}
+EFI_STATUS +EFIAPI +ShellFUpdateCommandDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+{
- if (gShellFUpdateHiiHandle != NULL) {
- HiiRemovePackages (gShellFUpdateHiiHandle);
- }
- return EFI_SUCCESS;
+} diff --git a/Applications/FirmwareUpdate/FUpdate.inf b/Applications/FirmwareUpdate/FUpdate.inf new file mode 100644 index 0000000..4d4b97e --- /dev/null +++ b/Applications/FirmwareUpdate/FUpdate.inf @@ -0,0 +1,75 @@ +# +# Marvell BSD License Option +# +# If you received this File from Marvell, you may opt to use, redistribute +# and/or modify this File under the following licensing terms. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Marvell nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#
+[Defines]
- INF_VERSION = 0x00010019
- BASE_NAME = UefiShellFUpdateCommandLib
- FILE_GUID = 470292b2-926b-4ed8-8080-be7a260db627
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 0.1
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = ShellFUpdateCommandConstructor
- DESTRUCTOR = ShellFUpdateCommandDestructor
+[Sources]
- FUpdate.c
- FUpdate.uni
+[Packages]
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- OpenPlatformPkg/Platforms/Marvell/Marvell.dec
- ShellPkg/ShellPkg.dec
+[LibraryClasses]
- BaseLib
- BaseMemoryLib
- DebugLib
- FileHandleLib
- HiiLib
- MemoryAllocationLib
- PcdLib
- ShellCommandLib
- ShellLib
- UefiBootServicesTableLib
- UefiLib
- UefiLib
- UefiRuntimeServicesTableLib
+[Pcd]
- gMarvellTokenSpaceGuid.PcdSpiFlashId
+[Protocols]
- gMarvellSpiFlashProtocolGuid
- gMarvellSpiMasterProtocolGuid
+[Guids]
- gShellFUpdateHiiGuid
diff --git a/Applications/FirmwareUpdate/FUpdate.uni b/Applications/FirmwareUpdate/FUpdate.uni new file mode 100644 index 0000000000000000000000000000000000000000..6143c0580f1d1ef8ce4fe619a1df1ce380adf2c0 GIT binary patch literal 5838 zcmd6r?N1v=5XSd&rTz~m@+FOuK&z@BXdB5G6OhbHeI_(&s)*P?EX6>LDdL}R`}}4Y z_Fim)B2|h`_TBEy&OY<Z%kJL4|E#8GU-k8E`X+VLMY>G4X_hAG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z2@qzF6)k>Vp2}uwYkVd1H)P>oTCvDQf3r9rtC-mFvyX}sR8P6g7q^*ax)F|8UHrt% QHyJ;b`f6NX>FQbZ9}*T`00000
literal 0 HcmV?d00001
diff --git a/Platforms/Marvell/Marvell.dec b/Platforms/Marvell/Marvell.dec index f1d2def..9e95976 100644 --- a/Platforms/Marvell/Marvell.dec +++ b/Platforms/Marvell/Marvell.dec @@ -54,6 +54,7 @@
gShellEepromHiiGuid = { 0xb2f4c714, 0x147f, 0x4ff7, { 0x82, 0x1b, 0xce, 0x7b, 0x91, 0x7f, 0x5f, 0x2f } } gShellSfHiiGuid = { 0x03a67756, 0x8cde, 0x4638, { 0x82, 0x34, 0x4a, 0x0f, 0x6d, 0x58, 0x81, 0x39 } }
- gShellFUpdateHiiGuid = { 0x9b5d2176, 0x590a, 0x49db, { 0x89, 0x5d, 0x4a, 0x70, 0xfe, 0xad, 0xbe, 0x24 } }
Insert sorted? :)
/ Leif
[PcdsFixedAtBuild.common]
#MPP
1.8.3.1
From: Jan Dąbroś jsd@semihalf.com
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jan Dabros jsd@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com Reviewed-by: Leif Lindholm leif.lindholm@linaro.org --- Platforms/Marvell/Armada/Armada.dsc.inc | 1 + 1 file changed, 1 insertion(+)
diff --git a/Platforms/Marvell/Armada/Armada.dsc.inc b/Platforms/Marvell/Armada/Armada.dsc.inc index 74d0645..e47f886 100644 --- a/Platforms/Marvell/Armada/Armada.dsc.inc +++ b/Platforms/Marvell/Armada/Armada.dsc.inc @@ -481,6 +481,7 @@ NULL|ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf NULL|OpenPlatformPkg/Applications/EepromCmd/EepromCmd.inf NULL|OpenPlatformPkg/Applications/SpiTool/SpiFlashCmd.inf + NULL|OpenPlatformPkg/Applications/FirmwareUpdate/FUpdate.inf HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf