stm32mp: stm32prog: Add CONFIG_CMD_STM32PROG_SERIAL and _USB
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>
This commit is contained in:
parent
2dc2216692
commit
5a05af87ef
|
@ -11,7 +11,7 @@ obj-y += bsec.o
|
|||
ifdef CONFIG_SPL_BUILD
|
||||
obj-y += spl.o
|
||||
else
|
||||
obj-$(CONFIG_CMD_STM32PROG) += cmd_stm32prog/
|
||||
obj-y += cmd_stm32prog/
|
||||
obj-$(CONFIG_CMD_STM32KEY) += cmd_stm32key.o
|
||||
obj-$(CONFIG_ARMV7_PSCI) += psci.o
|
||||
obj-$(CONFIG_TFABOOT) += boot_params.o
|
||||
|
|
|
@ -11,8 +11,24 @@ config CMD_STM32PROG
|
|||
imply DFU_MTD if MTD
|
||||
help
|
||||
activate a specific command stm32prog for STM32MP soc family
|
||||
witch update the device with the tools STM32CubeProgrammer,
|
||||
using UART with STM32 protocol or USB with DFU protocol
|
||||
witch update the device with the tools STM32CubeProgrammer
|
||||
NB: access to not volatile memory (NOR/NAND/SD/eMMC) is based
|
||||
on U-Boot DFU framework
|
||||
|
||||
config CMD_STM32PROG_USB
|
||||
bool "support stm32prog over USB"
|
||||
depends on CMD_STM32PROG
|
||||
default y
|
||||
help
|
||||
activate the command "stm32prog usb" for STM32MP soc family
|
||||
witch update the device with the tools STM32CubeProgrammer,
|
||||
using USB with DFU protocol
|
||||
|
||||
config CMD_STM32PROG_SERIAL
|
||||
bool "support stm32prog over UART"
|
||||
depends on CMD_STM32PROG
|
||||
default y
|
||||
help
|
||||
activate the command "stm32prog serial" for STM32MP soc family
|
||||
with the tools STM32CubeProgrammer using U-Boot serial device
|
||||
and UART protocol.
|
|
@ -3,7 +3,7 @@
|
|||
# Copyright (C) 2020, STMicroelectronics - All Rights Reserved
|
||||
#
|
||||
|
||||
obj-y += cmd_stm32prog.o
|
||||
obj-y += stm32prog.o
|
||||
obj-y += stm32prog_serial.o
|
||||
obj-y += stm32prog_usb.o
|
||||
obj-$(CONFIG_CMD_STM32PROG) += cmd_stm32prog.o
|
||||
obj-$(CONFIG_CMD_STM32PROG) += stm32prog.o
|
||||
obj-$(CONFIG_CMD_STM32PROG_SERIAL) += stm32prog_serial.o
|
||||
obj-$(CONFIG_CMD_STM32PROG_USB) += stm32prog_usb.o
|
||||
|
|
|
@ -50,9 +50,9 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
if (argc < 3 || argc > 5)
|
||||
return CMD_RET_USAGE;
|
||||
|
||||
if (!strcmp(argv[1], "usb"))
|
||||
if (IS_ENABLED(CONFIG_CMD_STM32PROG_USB) && !strcmp(argv[1], "usb"))
|
||||
link = LINK_USB;
|
||||
else if (!strcmp(argv[1], "serial"))
|
||||
else if (IS_ENABLED(CONFIG_CMD_STM32PROG_SERIAL) && !strcmp(argv[1], "serial"))
|
||||
link = LINK_SERIAL;
|
||||
|
||||
if (link == LINK_UNDEFINED) {
|
||||
|
|
|
@ -177,9 +177,30 @@ char *stm32prog_get_error(struct stm32prog_data *data);
|
|||
|
||||
/* Main function */
|
||||
int stm32prog_init(struct stm32prog_data *data, ulong addr, ulong size);
|
||||
int stm32prog_serial_init(struct stm32prog_data *data, int link_dev);
|
||||
bool stm32prog_serial_loop(struct stm32prog_data *data);
|
||||
bool stm32prog_usb_loop(struct stm32prog_data *data, int dev);
|
||||
void stm32prog_clean(struct stm32prog_data *data);
|
||||
|
||||
#ifdef CONFIG_CMD_STM32PROG_SERIAL
|
||||
int stm32prog_serial_init(struct stm32prog_data *data, int link_dev);
|
||||
bool stm32prog_serial_loop(struct stm32prog_data *data);
|
||||
#else
|
||||
static inline int stm32prog_serial_init(struct stm32prog_data *data, int link_dev)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline bool stm32prog_serial_loop(struct stm32prog_data *data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CMD_STM32PROG_USB
|
||||
bool stm32prog_usb_loop(struct stm32prog_data *data, int dev);
|
||||
#else
|
||||
static inline bool stm32prog_usb_loop(struct stm32prog_data *data, int dev)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -265,7 +265,8 @@ int arch_cpu_init(void)
|
|||
|
||||
boot_mode = get_bootmode();
|
||||
|
||||
if ((boot_mode & TAMP_BOOT_DEVICE_MASK) == BOOT_SERIAL_UART)
|
||||
if (IS_ENABLED(CONFIG_CMD_STM32PROG_SERIAL) &&
|
||||
(boot_mode & TAMP_BOOT_DEVICE_MASK) == BOOT_SERIAL_UART)
|
||||
gd->flags |= GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE;
|
||||
#if defined(CONFIG_DEBUG_UART) && \
|
||||
!defined(CONFIG_TFABOOT) && \
|
||||
|
@ -485,7 +486,7 @@ static void setup_boot_mode(void)
|
|||
env_set("boot_instance", cmd);
|
||||
|
||||
/* restore console on uart when not used */
|
||||
if (gd->cur_serial_dev != dev) {
|
||||
if (IS_ENABLED(CONFIG_CMD_STM32PROG_SERIAL) && gd->cur_serial_dev != dev) {
|
||||
gd->flags &= ~(GD_FLG_SILENT |
|
||||
GD_FLG_DISABLE_CONSOLE);
|
||||
printf("serial boot with console enabled!\n");
|
||||
|
|
|
@ -143,7 +143,8 @@ void set_dfu_alt_info(char *interface, char *devstr)
|
|||
board_get_alt_info_mtd(mtd, buf);
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_DFU_VIRT)) {
|
||||
if (IS_ENABLED(CONFIG_DFU_VIRT) &&
|
||||
IS_ENABLED(CMD_STM32PROG_USB)) {
|
||||
strncat(buf, "&virt 0=OTP", DFU_ALT_BUF_LEN);
|
||||
|
||||
if (IS_ENABLED(CONFIG_PMIC_STPMIC1))
|
||||
|
@ -217,7 +218,7 @@ int dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
|
|||
return dfu_pmic_read(offset, buf, len);
|
||||
}
|
||||
|
||||
if (CONFIG_IS_ENABLED(CMD_STM32PROG) &&
|
||||
if (IS_ENABLED(CONFIG_CMD_STM32PROG_USB) &&
|
||||
dfu->data.virt.dev_num >= STM32PROG_VIRT_FIRST_DEV_NUM)
|
||||
return stm32prog_read_medium_virt(dfu, offset, buf, len);
|
||||
|
||||
|
@ -228,7 +229,7 @@ int dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
|
|||
int dfu_write_medium_virt(struct dfu_entity *dfu, u64 offset,
|
||||
void *buf, long *len)
|
||||
{
|
||||
if (CONFIG_IS_ENABLED(CMD_STM32PROG) &&
|
||||
if (IS_ENABLED(CONFIG_CMD_STM32PROG_USB) &&
|
||||
dfu->data.virt.dev_num >= STM32PROG_VIRT_FIRST_DEV_NUM)
|
||||
return stm32prog_write_medium_virt(dfu, offset, buf, len);
|
||||
|
||||
|
@ -237,7 +238,7 @@ int dfu_write_medium_virt(struct dfu_entity *dfu, u64 offset,
|
|||
|
||||
int __weak dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size)
|
||||
{
|
||||
if (CONFIG_IS_ENABLED(CMD_STM32PROG) &&
|
||||
if (IS_ENABLED(CONFIG_CMD_STM32PROG_USB) &&
|
||||
dfu->data.virt.dev_num >= STM32PROG_VIRT_FIRST_DEV_NUM)
|
||||
return stm32prog_get_medium_size_virt(dfu, size);
|
||||
|
||||
|
|
Loading…
Reference in New Issue