summaryrefslogtreecommitdiff
path: root/arch/arm/mach-stm32mp/cmd_stm32prog
AgeCommit message (Collapse)AuthorFilesLines
2021-08-16stm32mp1: stm32prog: remove stm32prog_get_tee_partitions with FIPPatrick Delaunay3-0/+8
The MTD tee partitions used to save the OP-TEE binary are needed when TF-A doesn't use the FIP container to load binaries. This patch puts under CONFIG_STM32MP15x_STM32IMAGE flag the associated code in U-Boot binary and prepare the code cleanup when CONFIG_STM32MP15x_STM32IMAGE support will be removed after TF-A migration to FIP support. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-08-02global: Convert simple_strtoul() with decimal to dectoul()Simon Glass2-2/+2
It is a pain to have to specify the value 10 in each call. Add a new dectoul() function and update the code to use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-08-02global: Convert simple_strtoul() with hex to hextoul()Simon Glass1-2/+2
It is a pain to have to specify the value 16 in each call. Add a new hextoul() function and update the code to use it. Add a proper comment to simple_strtoul() while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-16stm32mp: stm32prog: use defines for virtual partition sizePatrick Delaunay3-4/+5
Use the existing defines PMIC_SIZE and OTP_SIZE and a new define CMD_SIZE for virtual partition size. This patch corrects the size for OTP partition in alternate name (1024 instead of 512) and avoids other alignment issues. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-07-16stm32mp: stm32prog: fix the content of short help messagePatrick Delaunay1-5/+5
Reduce the content of short help message for stm32prog command and removed the carriage return to fix the display of 'help' command when this command is activated. Fixes: 954bd1a923a6 ("stm32mp: add the command stm32prog") Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-06-18stm32mp: stm32prog: handle dfu errorPatrick Delaunay1-0/+14
Handle DFU stack error in STM32CubeProgrammer protocol. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-06-18stm32mp: stm32prog: change one message level to debugPatrick Delaunay1-1/+1
Move the message "Invalid or missing layout file." to debug level as it is a normal behavior and not an error and add the missing '\n'. This patch avoids the strange trace : Boot over usb0! Invalid or missing layout file.DFU alt info setting: done Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-06-18stm32mp: stm32prog: use get_cpu_dev for GetID commandPatrick Delaunay1-4/+6
Use get_cpu_dev() in uart getID command and remove the defines DEVICE_ID_BYTE1 and 2 defines. This patch prepare the support for new SOC family. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-06-18stm32mp: stm32prog: correctly handle DM_PMICPatrick Delaunay1-1/+4
Correctly handle number of alternate when DM_PMIC is not activated. This patch remove the last UNKNOWN partition in this case. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
2021-06-18stm32mp: stm32prog: handle the next phase after USB re-enumerationPatrick Delaunay1-5/+2
Handle the second USB enumeration only when the flashlayout is received and when phase is PHASE_FLASHLAYOUT. This patch removes the call of stm32prog_next_phase as it is already done in stm32prog_dfu_init(). Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-06-18stm32mp: stm32prog: solve compilation with CONFIG_FIT_SIGNATUREPatrick Delaunay1-0/+2
When CONFIG_FIT_SIGNATURE is activated, CONFIG_LEGACY_IMAGE_FORMAT is deactivated and the define IMAGE_FORMAT_LEGACY don't exist with include/image.h: #if defined(CONFIG_LEGACY_IMAGE_FORMAT) #define IMAGE_FORMAT_LEGACY 0x01 /* legacy image_header based format */ #endif This patch adds the needed check on compilation flag CONFIG_LEGACY_IMAGE_FORMAT to avoid the compilation error for command stm32prog: cmd_stm32prog.c:81:8: error: ‘IMAGE_FORMAT_LEGACY’ undeclared (first use in this function); did you mean ‘IMAGE_FORMAT_FIT’? 81 | if (IMAGE_FORMAT_LEGACY == | ^~~~~~~~~~~~~~~~~~~ | IMAGE_FORMAT_FIT Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-06-18stm32mp: stm32prog: add support of initrd in flashlayoutPatrick Delaunay3-10/+24
Add the support in command stm32prog of kernel load and start with initrd file, identify by the partition Type "Binary" in the flashlayout.tsv, for example: - 0x01 fsbl Binary none 0x0 tfa.stm32 - 0x03 fip Binary none 0x0 fip.bin P 0x10 kernel System ram0 0xC2000000 uImage.bin P 0x11 dtb FileSystem ram0 0xC4000000 board.dtb P 0x12 initrd Binary ram0 0xC4400000 <initrd> The <initrd> file can be a legacy image "uInitrd", generated with mkimage, or a RAW initrd image "initrd.gz". After a DFU detach the bootm command with be executed with the associated address, for example: $> bootm 0xC2000000 0xC4400000:<size> 0xC4000000 When the "Binary" partition type is absent, the 'bootm' command starts the kernel without ramdisk, for example: $> bootm 0xC2000000 - 0xC4000000 With this paths, it is no more mandatory to generate FIT including the kernel, DT and initrd: - 0x01 fsbl Binary none 0x0 tfa.stm32 - 0x03 fip Binary none 0x0 fip.bin P 0x10 fit System ram0 0xC2000000 fit.bin Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-06-18stm32mp: stm32prog: add timeout in stm32prog_serial_get_bufferPatrick Delaunay1-2/+10
Handle timeout in stm32prog_serial_get_buffer to sent NACK to STM32CubeProgrammer when the buffer is not fully received. This patch avoids to reach the STM32CubeProgrammer timeout and the associated unrecoverable error. Timeout error occurred while waiting for acknowledgment. Error: Write Operation fails at packet number 4165 at address 0x1044FF Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-06-18stm32mp: stm32prog: remove all the header check for UART downloadPatrick Delaunay3-148/+22
This patch removes the header check for UART download; the check of checksum is not mandatory with even parity and chuck checksum for each 256 received bytes and it is only done for STM32 image (FSBL = TF-A BL2), not for FIT image. This patch solve issue of duplicated 0x100 byte written with FIP header. Fixes: 4fb7b3e10891 ("stm32mp: stm32prog: add FIP header support") Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-04-09stm32mp: stm32prog: add FIP header supportPatrick Delaunay4-37/+64
Add support of TF-A FIP header in command stm32prog for all the boot partition and not only the STM32IMAGE. This patch is a preliminary patch to support FIP as second boot stage after TF-A BL2 when CONFIG_TFABOOT is activated for trusted boot chain. The FIP is archive binary loaded by TF-A BL2, which contains the secure OS = OP-TEE and the non secure firmware and device tree = U-Boot. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-03-11stm32mp: stm32prog: replace alias by serial device sequence numberPatrick Delaunay1-23/+6
The command "stm32prog serial <dev>" can directly use the device sequence number of serial uclass as this sequence number is egual to alias when it exist; this assumption simplify the code and avoid access to gd->fdt_blob and the device tree parsing. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-03-11stm32mp: stm32prog: Add CONFIG_CMD_STM32PROG_SERIAL and _USBPatrick Delaunay4-9/+46
Add CONFIG_CMD_STM32PROG_SERIAL and CONFIG_CMD_STM32PROG_USB to independently select the support of UART or USB communication for STM32CubeProgrammer. For serial boot over UART, user can deactivate CONFIG_CMD_STM32PROG_SERIAL to use U-Boot console of binary loaded by UART (for board bring-up for example). Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-03-11stm32mp: stm32prog: Add Kconfig file for stm32prog commandPatrick Delaunay1-0/+18
Move CONFIG_CMD_STM32PROG in a specific Kconfig file for stm32prog command. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-02-02common: Drop asm/global_data.h from common headerSimon Glass2-0/+2
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2021-01-13arm: stm32mp: stm32prog: always flush DFU on start command for uartPatrick Delaunay1-7/+6
Remove the test on data->dfu_seq, because dfu_seq=0 not only when the DFU is not started (mask with 0xffff). This flush is mandatory as the final treatment, common with USB, is done in DFU callback. This patch avoids issue if the received length is a multiple of the DFU packet. For example if size of bootfs partition is egual to 0x4000000, data->dfu_seq=0 at the end of the partition, the flush it not requested and the phase is not increased in the callback. U-Boot continue to request the bootfs in the next GetPhase command. Fixes: 468f0508b58b ("stm32mp: stm32prog: add serial link support") Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-01-13arm: stm32mp: migrate cmd_stm32prog to log macroPatrick Delaunay5-78/+78
Change debug and pr_ macro to log macro. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2021-01-05dm: Rename DM_GET_DRIVER() to DM_DRIVER_GET()Simon Glass1-3/+3
In the spirit of using the same base name for all of these related macros, rename this to have the operation at the end. This is not widely used so the impact is fairly small. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-21stm32mp: stm32prog: accept device without partitionPatrick Delaunay1-2/+1
When partitions are not available on a device the command stm32prog raises an error but a device can have no partition to check in init_device() and the command need to continue to the next part_id. This patch correct an issue for ram0 target, when block_dev and mtd are NULL. For example with the simple flashlayout file: Opt Part Name Type Device Offset Binary - 0x01 fsbl Binary none 0x0 tf-a-serialboot.stm32 - 0x03 ssbl Binary none 0x0 u-boot.stm32 P 0x10 kernel System ram0 0xC2000000 uImage.bin P 0x11 dtb FileSytem ram0 0xC4000000 stm32mp157f-ev1.dtb Fixes: ffc405e63b94 ("stm32mp: stm32prog: add upport of partial update") Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-08-13arm: stm32mp: stm32prog: use IS_ENABLED to prevent ifdefPatrick Delaunay2-47/+58
Use IS_ENABLED to prevent ifdef in stm32prog command. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-08-04sf: Drop dm.h header file from spi_flash.hSimon Glass1-0/+1
This header file should not be included in other header files. Remove it and use a forward declaration instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-28arm: stm32mp: stm32prog: check result of find_mmc_devicePatrick Delaunay1-1/+1
Check result of find_mmc_device() before calling mmc_init(). This patch avoid a data abort when the command try to acces to sd/mmc device deactivated in device tree. Fixes: aff4c5dd8265 ("stm32mp: stm32prog: add MMC device") Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-07-09arm: cmd_stm32prog: Fix the CONFIG_IS_ENABLED() usageBin Meng1-1/+1
Add parentheses around CONFIG_IS_ENABLED() in the if statement, to fix potential build failures. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
2020-07-07arm: stm32mp: stm32prog: add "Device Name" in iproduct during DFU USB ↵Patrick Delaunay1-2/+4
enumeration Add "Device Name" in iproduct during DFU USB enumeration to have this information in STM32CubeProgrammer trace (this tools is compatible with @Name since v2.3) Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-19common: Drop linux/delay.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19command: Remove the cmd_tbl_t typedefSimon Glass2-2/+2
We should not use typedefs in U-Boot. They cannot be used as forward declarations which means that header files must include the full header to access them. Drop the typedef and rename the struct to remove the _s suffix which is now not useful. This requires quite a few header-file additions. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19part: Drop disk_partition_t typedefSimon Glass1-1/+1
We should not be using typedefs and these make it harder to use forward declarations (to reduce header file inclusions). Drop the typedef. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-14stm32mp: stm32prog: add support of RAM targetPatrick Delaunay3-2/+62
Add support of RAM target in flashlayout to load kernel image ("system") and device tree ("filesystem") in DDR with DFU and start these images. The flashlayout.tsv is: - 0x01 fsbl Binary none 0x00000000 tf-a.stm32 - 0x03 ssbl Binary none 0x00000000 u-boot.stm32 P 0x10 kernel System ram0 0xC2000000 uImage.bin P 0x11 dtb FileSystem ram0 0xC4000000 dtb.bin Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: support for scriptPatrick Delaunay1-0/+14
Support an U-Boot script included in uimage instead of flashlayout file (text file in tsv format). This feature is used to execute this script directly when U-Boot is loaded in DDR (for update without STM32CubeProgrammer for example). A simple example with dfu-util only is: $> echo "dfu 0" > script.cmd $> mkimage -C none -A arm -T script -d script.cmd script.uimg $> mkimage -T stm32image -a 0xC0000000 -e 0xC0000000 -d script.uimg \ script.stm32 $> dfu-util -d 0483:df11 -a 1 -D tf-a.stm32 $> dfu-util -d 0483:df11 -a 0 -D script.stm32 $> dfu-util -d 0483:df11 -a 0 -D u-boot.stm32 $> dfu-util -d 0483:df11 -a 0 -e Then you can used dfu-utils to update your device To increase speed, you can also switch to fastboot protocol with: echo "fastboot 0" > script.cmd Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: enable videoconsolePatrick Delaunay1-0/+28
Enable the videoconsole during the stm32prog command execution to have information without UART. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: add serial link supportPatrick Delaunay6-1/+1021
Add a support of UART, using the same protocol than MCU STM32. See "AN5275: USB DFU/USART protocols used in STM32MP1 Series bootloaders" for details. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: add pmic NVM update supportPatrick Delaunay3-1/+115
Add a virtual partition to update the pmic non volatile memory. (on ST board, STPMIC1). Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: add otp update supportPatrick Delaunay3-1/+151
Add a virtual partition to update the STM32MP15x OTP based on SMC service provided by TF-A. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: add support for delete option in flashlayoutPatrick Delaunay1-0/+105
Add support for delete option 'D' in flashlayout for full device or for partitions Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: add support of ssbl copyPatrick Delaunay2-5/+94
For reliability of boot from NAND/SPI-NAND (with read-disturb issue) the SSBL can be present several time, when it is indicated in the flashlayout with "Binary(X)". The received binary is copied X times by U-Boot on the target. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: adapt the MTD partitionsPatrick Delaunay3-0/+36
Dynamically adapt the MTD partitions in NOR/NAND/SPI-NAND when stm32prog command detects in the parsed flash layout files: - a fsbl partition in NOR. - a tee partition in NOR/NAND/SPI-NAND Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: add MTD devices supportPatrick Delaunay2-3/+115
Add support of MTD device (DFU_MTD backend) for NOR, NAND or SPI-NAND target. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: add upport of partial updatePatrick Delaunay2-0/+70
Add support of partial update, update only some partitions, and check the coherence of the layout with the existing GPT partitions (offset and size). Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: add support of boot partition for eMMC devicePatrick Delaunay2-36/+90
Add support of eMMC device boot partition with part_id = -1 for offset="boot1" or = -2 for offset="boot2" The stm32prog command configures the MMC DFU backend with "mmcpart" and configure the eMMC (command "mmc bootbus" and "mmc partconf") when the update is done. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: add MMC devicePatrick Delaunay2-1/+206
Add support of MMC device (based on DFU_MMC backend) for SD card and eMMC update. Create a GPT partitioning on the device. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: stm32prog: add flash layout parsingPatrick Delaunay1-1/+371
Build the list of device and of partition with a tab separated value file with a stm32 header: the FlashLayout.tsv (https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer_flashlayout) Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-05-14stm32mp: add the command stm32progPatrick Delaunay5-0/+927
Add a specific command stm32prog for STM32MP soc family witch allows to program the boot devices with the tool STM32CubeProgrammer (http://www.st.com/STM32CubeProg). This command uses the same UART STM32 protocol than MCU STM32 with or USB with DFU protocol v1.1 (ithe MCU ST extension are no supported). The executed actions are based on a tab separated value file with a stm32 header, the FlashLayout file (https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer_flashlayout). This file is parsed by the U-Boot command to: - initialize the devices - create the partition table on each device - initialize the DFU backend to access to not volatile memory (NOR/NAND/SD/eMMC) or to virtual device (OTP/PMIC) Up to STM32PROG_MAX_DEV (5) devices can be updated with a FlashLayout. The communication between U-Boot and STM32CubeProgrammer is done with the specific alternate configuration (see "AN5275: USB DFU/USART protocols used in STM32MP1 Series bootloaders" for details). The command stm32prog is executed when a boot from USB is detected (selected with bootpins) and we can program the boot devices with a simple command (on Windows or Linux): PC $> STM32_Programmer_CLI -c port=usb1 -w flaslayout.tsv 1/ the ROM code loads TF-A in embedded RAM (DFU or uart) 2/ TF-A loads flashlayout file and U-Boot in DDR (DFU or uart) 3/ U-Boot executes the stm32prog command (DFU or uart) Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>