diff options
author | Patrick Delaunay | 2020-03-18 09:24:49 +0100 |
---|---|---|
committer | Patrick Delaunay | 2020-05-14 09:02:12 +0200 |
commit | 954bd1a923a686089c62195781616768f52eacc7 (patch) | |
tree | 86c5c5092c2e1e83ee6ffa8bf18b6e5e6e7525d2 /board/st/common | |
parent | 7802a4495f3c2db09b125a4963f4328b95a38429 (diff) |
stm32mp: add the command stm32prog
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>
Diffstat (limited to 'board/st/common')
-rw-r--r-- | board/st/common/stm32mp_dfu.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c index e129f8c8b5b..3bd005bb04a 100644 --- a/board/st/common/stm32mp_dfu.c +++ b/board/st/common/stm32mp_dfu.c @@ -11,6 +11,7 @@ #include <misc.h> #include <mtd.h> #include <mtd_node.h> +#include <asm/arch/stm32prog.h> #define DFU_ALT_BUF_LEN SZ_1K @@ -211,12 +212,31 @@ int dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset, case 0x1: return dfu_pmic_read(offset, buf, len); } + + if (CONFIG_IS_ENABLED(CMD_STM32PROG) && + dfu->data.virt.dev_num >= STM32PROG_VIRT_FIRST_DEV_NUM) + return stm32prog_read_medium_virt(dfu, offset, buf, len); + *len = 0; return 0; } +int dfu_write_medium_virt(struct dfu_entity *dfu, u64 offset, + void *buf, long *len) +{ + if (CONFIG_IS_ENABLED(CMD_STM32PROG) && + dfu->data.virt.dev_num >= STM32PROG_VIRT_FIRST_DEV_NUM) + return stm32prog_write_medium_virt(dfu, offset, buf, len); + + return -EOPNOTSUPP; +} + int __weak dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size) { + if (CONFIG_IS_ENABLED(CMD_STM32PROG) && + dfu->data.virt.dev_num >= STM32PROG_VIRT_FIRST_DEV_NUM) + return stm32prog_get_medium_size_virt(dfu, size); + *size = SZ_1K; return 0; |