mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 19:11:53 +00:00
stm32mp: stm32prog: adapt the MTD partitions
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>
This commit is contained in:
parent
eb845d6f8b
commit
8f035f7b48
5 changed files with 52 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <dfu.h>
|
#include <dfu.h>
|
||||||
|
#include <asm/arch/stm32prog.h>
|
||||||
#include "stm32prog.h"
|
#include "stm32prog.h"
|
||||||
|
|
||||||
struct stm32prog_data *stm32prog_data;
|
struct stm32prog_data *stm32prog_data;
|
||||||
|
@ -94,3 +95,19 @@ U_BOOT_CMD(stm32prog, 5, 0, do_stm32prog,
|
||||||
"<addr> = address of flashlayout\n"
|
"<addr> = address of flashlayout\n"
|
||||||
"<size> = size of flashlayout\n"
|
"<size> = size of flashlayout\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
bool stm32prog_get_tee_partitions(void)
|
||||||
|
{
|
||||||
|
if (stm32prog_data)
|
||||||
|
return stm32prog_data->tee_detected;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool stm32prog_get_fsbl_nor(void)
|
||||||
|
{
|
||||||
|
if (stm32prog_data)
|
||||||
|
return stm32prog_data->fsbl_nor_detected;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -762,6 +762,8 @@ static int treat_partition_list(struct stm32prog_data *data)
|
||||||
INIT_LIST_HEAD(&data->dev[j].part_list);
|
INIT_LIST_HEAD(&data->dev[j].part_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data->tee_detected = false;
|
||||||
|
data->fsbl_nor_detected = false;
|
||||||
for (i = 0; i < data->part_nb; i++) {
|
for (i = 0; i < data->part_nb; i++) {
|
||||||
part = &data->part_array[i];
|
part = &data->part_array[i];
|
||||||
part->alt_id = -1;
|
part->alt_id = -1;
|
||||||
|
@ -806,6 +808,21 @@ static int treat_partition_list(struct stm32prog_data *data)
|
||||||
stm32prog_err("Layout: too many device");
|
stm32prog_err("Layout: too many device");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
switch (part->target) {
|
||||||
|
case STM32PROG_NOR:
|
||||||
|
if (!data->fsbl_nor_detected &&
|
||||||
|
!strncmp(part->name, "fsbl", 4))
|
||||||
|
data->fsbl_nor_detected = true;
|
||||||
|
/* fallthrough */
|
||||||
|
case STM32PROG_NAND:
|
||||||
|
case STM32PROG_SPI_NAND:
|
||||||
|
if (!data->tee_detected &&
|
||||||
|
!strncmp(part->name, "tee", 3))
|
||||||
|
data->tee_detected = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
part->dev = &data->dev[j];
|
part->dev = &data->dev[j];
|
||||||
if (!IS_SELECT(part))
|
if (!IS_SELECT(part))
|
||||||
part->dev->full_update = false;
|
part->dev->full_update = false;
|
||||||
|
|
|
@ -107,6 +107,8 @@ struct stm32prog_data {
|
||||||
struct stm32prog_dev_t dev[STM32PROG_MAX_DEV]; /* array of device */
|
struct stm32prog_dev_t dev[STM32PROG_MAX_DEV]; /* array of device */
|
||||||
int part_nb; /* nb of partition */
|
int part_nb; /* nb of partition */
|
||||||
struct stm32prog_part_t *part_array; /* array of partition */
|
struct stm32prog_part_t *part_array; /* array of partition */
|
||||||
|
bool tee_detected;
|
||||||
|
bool fsbl_nor_detected;
|
||||||
|
|
||||||
/* command internal information */
|
/* command internal information */
|
||||||
unsigned int phase;
|
unsigned int phase;
|
||||||
|
|
|
@ -10,3 +10,7 @@ int stm32prog_write_medium_virt(struct dfu_entity *dfu, u64 offset,
|
||||||
int stm32prog_read_medium_virt(struct dfu_entity *dfu, u64 offset,
|
int stm32prog_read_medium_virt(struct dfu_entity *dfu, u64 offset,
|
||||||
void *buf, long *len);
|
void *buf, long *len);
|
||||||
int stm32prog_get_medium_size_virt(struct dfu_entity *dfu, u64 *size);
|
int stm32prog_get_medium_size_virt(struct dfu_entity *dfu, u64 *size);
|
||||||
|
|
||||||
|
bool stm32prog_get_tee_partitions(void);
|
||||||
|
|
||||||
|
bool stm32prog_get_fsbl_nor(void);
|
||||||
|
|
|
@ -4,12 +4,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#include <dfu.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <env.h>
|
#include <env.h>
|
||||||
#include <env_internal.h>
|
#include <env_internal.h>
|
||||||
#include <mtd.h>
|
#include <mtd.h>
|
||||||
#include <mtd_node.h>
|
#include <mtd_node.h>
|
||||||
#include <tee.h>
|
#include <tee.h>
|
||||||
|
#include <asm/arch/stm32prog.h>
|
||||||
#include <asm/arch/sys_proto.h>
|
#include <asm/arch/sys_proto.h>
|
||||||
|
|
||||||
#define MTDPARTS_LEN 256
|
#define MTDPARTS_LEN 256
|
||||||
|
@ -66,7 +68,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
|
||||||
static char parts[3 * MTDPARTS_LEN + 1];
|
static char parts[3 * MTDPARTS_LEN + 1];
|
||||||
static char ids[MTDIDS_LEN + 1];
|
static char ids[MTDIDS_LEN + 1];
|
||||||
static bool mtd_initialized;
|
static bool mtd_initialized;
|
||||||
bool tee, nor, nand, spinand;
|
bool tee, nor, nand, spinand, serial;
|
||||||
|
|
||||||
if (mtd_initialized) {
|
if (mtd_initialized) {
|
||||||
*mtdids = ids;
|
*mtdids = ids;
|
||||||
|
@ -78,10 +80,18 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
|
||||||
nor = false;
|
nor = false;
|
||||||
nand = false;
|
nand = false;
|
||||||
spinand = false;
|
spinand = false;
|
||||||
|
serial = false;
|
||||||
|
|
||||||
switch (get_bootmode() & TAMP_BOOT_DEVICE_MASK) {
|
switch (get_bootmode() & TAMP_BOOT_DEVICE_MASK) {
|
||||||
case BOOT_SERIAL_UART:
|
case BOOT_SERIAL_UART:
|
||||||
case BOOT_SERIAL_USB:
|
case BOOT_SERIAL_USB:
|
||||||
|
serial = true;
|
||||||
|
if (CONFIG_IS_ENABLED(CMD_STM32PROG)) {
|
||||||
|
tee = stm32prog_get_tee_partitions();
|
||||||
|
nor = stm32prog_get_fsbl_nor();
|
||||||
|
}
|
||||||
|
nand = true;
|
||||||
|
spinand = true;
|
||||||
break;
|
break;
|
||||||
case BOOT_FLASH_NAND:
|
case BOOT_FLASH_NAND:
|
||||||
nand = true;
|
nand = true;
|
||||||
|
@ -96,7 +106,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CONFIG_IS_ENABLED(OPTEE) &&
|
if (!serial && CONFIG_IS_ENABLED(OPTEE) &&
|
||||||
tee_find_device(NULL, NULL, NULL, NULL))
|
tee_find_device(NULL, NULL, NULL, NULL))
|
||||||
tee = true;
|
tee = true;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue