mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-10 14:53:26 +09:00
usb: gadget: f_sdp: Allow SPL to load and boot FIT via SDP
Add support for loading u-boot FIT images over the USB SDP protocol in the SPL. Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de> [Various build fixes] Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> Tested-by: Fabio Estevam <festevam@gmail.com>
This commit is contained in:
parent
eb04b16e4b
commit
5b2541355b
@ -25,10 +25,14 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This command typically does not return but jumps to an image */
|
/*
|
||||||
sdp_handle(controller_index);
|
* This command either loads a legacy image, jumps and never returns,
|
||||||
pr_err("SDP ended\n");
|
* or it loads a FIT image and returns it to be handled by the SPL
|
||||||
|
* code.
|
||||||
|
*/
|
||||||
|
ret = spl_sdp_handle(controller_index, spl_image);
|
||||||
|
debug("SDP ended\n");
|
||||||
|
|
||||||
return -EINVAL;
|
return ret;
|
||||||
}
|
}
|
||||||
SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
|
SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
|
||||||
|
@ -638,7 +638,20 @@ static u32 sdp_jump_imxheader(void *address)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdp_handle_in_ep(void)
|
#ifdef CONFIG_SPL_BUILD
|
||||||
|
#ifdef CONFIG_SPL_LOAD_FIT
|
||||||
|
static ulong sdp_fit_read(struct spl_load_info *load, ulong sector,
|
||||||
|
ulong count, void *buf)
|
||||||
|
{
|
||||||
|
debug("%s: sector %lx, count %lx, buf %lx\n",
|
||||||
|
__func__, sector, count, (ulong)buf);
|
||||||
|
memcpy(buf, (void *)(load->dev + sector), count);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void sdp_handle_in_ep(struct spl_image_info *spl_image)
|
||||||
{
|
{
|
||||||
u8 *data = sdp_func->in_req->buf;
|
u8 *data = sdp_func->in_req->buf;
|
||||||
u32 status;
|
u32 status;
|
||||||
@ -690,10 +703,25 @@ static void sdp_handle_in_ep(void)
|
|||||||
/* If imx header fails, try some U-Boot specific headers */
|
/* If imx header fails, try some U-Boot specific headers */
|
||||||
if (status) {
|
if (status) {
|
||||||
#ifdef CONFIG_SPL_BUILD
|
#ifdef CONFIG_SPL_BUILD
|
||||||
|
image_header_t *header =
|
||||||
|
sdp_ptr(sdp_func->jmp_address);
|
||||||
|
#ifdef CONFIG_SPL_LOAD_FIT
|
||||||
|
if (image_get_magic(header) == FDT_MAGIC) {
|
||||||
|
struct spl_load_info load;
|
||||||
|
|
||||||
|
debug("Found FIT\n");
|
||||||
|
load.dev = header;
|
||||||
|
load.bl_len = 1;
|
||||||
|
load.read = sdp_fit_read;
|
||||||
|
spl_load_simple_fit(spl_image, &load, 0,
|
||||||
|
header);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* In SPL, allow jumps to U-Boot images */
|
/* In SPL, allow jumps to U-Boot images */
|
||||||
struct spl_image_info spl_image = {};
|
struct spl_image_info spl_image = {};
|
||||||
spl_parse_image_header(&spl_image,
|
spl_parse_image_header(&spl_image, header);
|
||||||
(struct image_header *)sdp_func->jmp_address);
|
|
||||||
jump_to_image_no_args(&spl_image);
|
jump_to_image_no_args(&spl_image);
|
||||||
#else
|
#else
|
||||||
/* In U-Boot, allow jumps to scripts */
|
/* In U-Boot, allow jumps to scripts */
|
||||||
@ -715,19 +743,32 @@ static void sdp_handle_in_ep(void)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdp_handle(int controller_index)
|
#ifndef CONFIG_SPL_BUILD
|
||||||
|
int sdp_handle(int controller_index)
|
||||||
|
#else
|
||||||
|
int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
printf("SDP: handle requests...\n");
|
printf("SDP: handle requests...\n");
|
||||||
while (1) {
|
while (1) {
|
||||||
if (ctrlc()) {
|
if (ctrlc()) {
|
||||||
puts("\rCTRL+C - Operation aborted.\n");
|
puts("\rCTRL+C - Operation aborted.\n");
|
||||||
return;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SPL_BUILD
|
||||||
|
if (spl_image->flags & SPL_FIT_FOUND)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
WATCHDOG_RESET();
|
WATCHDOG_RESET();
|
||||||
usb_gadget_handle_interrupts(controller_index);
|
usb_gadget_handle_interrupts(controller_index);
|
||||||
|
|
||||||
sdp_handle_in_ep();
|
#ifdef CONFIG_SPL_BUILD
|
||||||
|
sdp_handle_in_ep(spl_image);
|
||||||
|
#else
|
||||||
|
sdp_handle_in_ep(NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,13 @@
|
|||||||
#define __SDP_H_
|
#define __SDP_H_
|
||||||
|
|
||||||
int sdp_init(int controller_index);
|
int sdp_init(int controller_index);
|
||||||
void sdp_handle(int controller_index);
|
|
||||||
|
#ifdef CONFIG_SPL_BUILD
|
||||||
|
#include <spl.h>
|
||||||
|
|
||||||
|
int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image);
|
||||||
|
#else
|
||||||
|
int sdp_handle(int controller_index);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __SDP_H_ */
|
#endif /* __SDP_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user