Commit 11701da8 authored by H. Nikolaus Schaller's avatar H. Nikolaus Schaller

Merge remote-tracking branch 'origin/work/kemnade/dfu_spl' into letux-2016.11

parents 05c555c5 ae07aed9
#!/bin/sh
set -e
if test $# -lt 1 -o "$1" = --help ; then
echo Usage: $0 'configname [parameters to make]'
echo e.g.
echo ./make-spl-dfu.sh letux_gta04 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
exit 0
fi
set -x
cd ..
rm -rf spl-dfu-build
mkdir spl-dfu-build
(
cat configs/$1_defconfig | grep -v CONFIG_SPL_
cat <<EOF
CONFIG_SPL_ENV_SUPPORT=y
CONFIG_SPL_YMODEM_SUPPORT=y
CONFIG_SPL_DFU_SUPPORT=y
CONFIG_SPL_HASH_SUPPORT=y
CONFIG_SPL_MUSB_NEW_SUPPORT=y
CONFIG_SPL_OS_BOOT=y
CONFIG_CMD_DFU=y
CONFIG_DFU_RAM=y
CONFIG_SPL_EXT_SUPPORT=n
CONFIG_SPL_FAT_SUPPORT=n
CONFIG_SPL_LIBDISK_SUPPORT=n
CONFIG_SPL_MMC_SUPPORT=n
CONFIG_SPL_NAND_SUPPORT=n
EOF
) > spl-dfu-build/.config
shift
make olddefconfig O=spl-dfu-build "$@"
make O=spl-dfu-build "$@"
cp spl-dfu-build/u-boot.img Letux/spl-dfu
cp spl-dfu-build/spl/u-boot-spl.bin Letux/spl-dfu/spl
Scripts and output files to boot a gta04 from usb
Required for all: dfu-util
The dfu-gta04.rules has to be copied into /etc/udev/rules.d
if it should work as ordinary user
usb-start-uboot.sh:
boots the device from usb. It requires additionally pusb.
No data is needed on mmc or nand
usb-start-kernel.sh:
expects an uboot waiting for dfu usb input and loads a kernel
optionally including a ramdisk
usb-flash-uboot-gta04.sh
flashes spl+uboot+images into nand
#!/bin/sh
if [ $# -lt 2 ]; then
echo Usage: $0 'nand|onenand' basedir
exit
fi
set -e
NAND=$1
if [ "$NAND" != nand -a "$NAND" != onenand ]; then
echo unknown nand "$1"
exit 1
fi
TMPFILE=$(tempfile)
dd if=/dev/zero bs=$((0x1000)) count=$((0x1c0+0x80)) | tr '\0' '\377' >"$TMPFILE"
if [ $NAND = nand ] ; then
dd if="$2/MLO" bs=$((0x1000)) of="$TMPFILE" conv=notrunc
dd if="$2/MLO" bs=$((0x1000)) seek=$((0x20)) of="$TMPFILE" conv=notrunc
dd if="$2/MLO" bs=$((0x1000)) seek=$((0x40)) of="$TMPFILE" conv=notrunc
dd if="$2/MLO" bs=$((0x1000)) seek=$((0x60)) of="$TMPFILE" conv=notrunc
else
SECTORS=`wc -c <"$2/MLO"`
SECTORS=$((SECTORS / 2048))
for COPIES in 0 1 2 3
do
for SEC in `seq 0 1 $SECTORS`
do
dd if="$2/MLO" bs=2048 skip=$SEC of="$TMPFILE" count=1 seek=$(($SEC*2+$COPIES*0x20000/2048)) conv=notrunc
done
done
fi
dd if="$2/u-boot.img" bs=$((0x1000)) seek=$((0x80)) of="$TMPFILE" conv=notrunc
dd if="$2/boot.scr" bs=$((0x1000)) seek=$((0x1b0)) of="$TMPFILE" conv=notrunc
dd if="$2/splash.rgb16z" bs=$((0x1000)) seek=$((0x1c0)) of="$TMPFILE" conv=notrunc
dd if="$2/menu.rgb16z" bs=$((0x1000)) seek=$((0x200)) of="$TMPFILE" conv=notrunc
dfu-util -a rd -D "$TMPFILE"
SCRIPT_CMD="$(tempfile)"
SCRIPT_SCR="$(tempfile)"
cat <<EOF >"$SCRIPT_CMD"
$NAND erase 0 240000
$NAND write \${loadaddrinitrd} 0 240000
poweroff
EOF
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'Boot Script' -d "$SCRIPT_CMD" "$SCRIPT_SCR"
dfu-util -a script -D "$SCRIPT_SCR"
rm "$SCRIPT_SCR" "$SCRIPT_CMD" "$TMPFILE"
sleep 0.5
dfu-util -a script -e
#!/bin/bash
set -e
if [ $# -lt 4 ] ; then
echo Usage $0 'uImage ramdisk|- fdt|- [args...]'
fi
KERNEL="$1"
INITRD="$2"
FDT="$3"
shift
shift
shift
dfu-util -a kernel -D "$KERNEL"
[ "$INITRD" != "-" ] && dfu-util -a rd -D "$INITRD"
[ "$FDT" != "-" ] && dfu-util -a fdt -D "$FDT"
SCRIPT_CMD="$(tempfile)"
(
echo setenv bootargs "$*"
echo -n 'bootm ${loadaddr}'
if [ "$INITRD" != "-" ] ; then
echo -n ' ${loadaddrinitrd}'
else
echo -n ' -'
fi
if [ "$FDT" != "-" ] ; then
echo ' ${loadaddrfdt}'
else
echo ' -'
fi
) >> "$SCRIPT_CMD"
SCRIPT_SCR="$(tempfile)"
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'Boot Script' -d "$SCRIPT_CMD" "$SCRIPT_SCR"
dfu-util -a script -D "$SCRIPT_SCR"
rm "$SCRIPT_SCR" "$SCRIPT_CMD"
sleep 0.5
dfu-util -a script -e
#!/bin/bash
UBOOT=u-boot.img
if [ $# -ge 1 ]; then
if [ "$1" = --help ]; then
echo Usage: $0 [u-boot.img]
exit 0
fi
UBOOT="$1"
fi
set -e
echo Power on you gta04 with aux button pressed
pusb -f spl -d 0xd00e
# wait for dfu to appear
sleep 1
dfu-util -a uboot -D "$UBOOT"
sleep 0.5
dfu-util -a uboot -e
......@@ -16,7 +16,14 @@
#define BOOT_DEVICE_XIPWAIT 0x07
#define BOOT_DEVICE_MMC2_2 0x08
#define BOOT_DEVICE_UART 0x10
#define BOOT_DEVICE_USB 0x11
/* according to DM3730 TRM, a boot in usb gadget mode is done,
* so it is not searching for e.g. usb storage devices,
* so better define it to DFU
*/
#define BOOT_DEVICE_DFU 0x11
/* dummy */
#define BOOT_DEVICE_RAM 0x22
#define MMC_BOOT_DEVICES_START BOOT_DEVICE_MMC2
#define MMC_BOOT_DEVICES_END BOOT_DEVICE_MMC1
......
......@@ -316,7 +316,14 @@ static struct musb_hdrc_platform_data musb_plat = {
.board_data = &musb_board_data,
};
#endif
#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_DFU_SUPPORT)
void spl_gadget_init(void)
{
#ifdef CONFIG_USB_MUSB_OMAP2PLUS
musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE);
#endif
}
#endif
/*
* Routine: misc_init_r
* Description: Configure board specific parts
......
......@@ -90,7 +90,6 @@ endif # !CONFIG_SPL_BUILD
ifdef CONFIG_SPL_BUILD
obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o
obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
......
......@@ -28,7 +28,7 @@ DECLARE_GLOBAL_DATA_PTR;
*/
int run_command(const char *cmd, int flag)
{
#ifndef CONFIG_HUSH_PARSER
#if !defined(CONFIG_HUSH_PARSER) || defined(CONFIG_SPL_BUILD)
/*
* cli_run_command can return 0 or 1 for success, so clean up
* its result.
......
......@@ -520,7 +520,7 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[],
if (argc > cmdtp->maxargs)
rc = CMD_RET_USAGE;
#if defined(CONFIG_CMD_BOOTD)
#if defined(CONFIG_CMD_BOOTD) && !defined(CONFIG_SPL_BUILD)
/* avoid "bootd" recursion */
else if (cmdtp->cmd == do_bootd) {
if (flag & CMD_FLAG_BOOTD) {
......
......@@ -204,8 +204,11 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
header = (struct image_header *)CONFIG_SPL_LOAD_FIT_ADDRESS;
#if defined(CONFIG_SPL_DFU_SUPPORT)
if (bootdev->boot_device == BOOT_DEVICE_DFU)
spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
if (bootdev->boot_device == BOOT_DEVICE_DFU) {
int ret = spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
if (ret)
return ret;
}
#endif
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
......@@ -224,6 +227,18 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
* the flash. For now, it will temporary fixed to address
* pointed by U-Boot.
*/
#if defined(CONFIG_SPL_DFU_SUPPORT)
if (bootdev->boot_device == BOOT_DEVICE_DFU) {
int ret = spl_parse_image_header(spl_image, header);
if (ret)
return ret;
memcpy((void *)spl_image->load_addr,
(void *)(CONFIG_SPL_LOAD_FIT_ADDRESS),
spl_image->size);
return 0;
}
#endif
header = (struct image_header *)
(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
......
......@@ -33,6 +33,10 @@ exit:
return ret;
}
__weak void spl_gadget_init(void)
{
}
int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr)
{
char *str_env;
......@@ -51,7 +55,7 @@ int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr)
error("unable to set env variable \"dfu_alt_info\"!\n");
return -EINVAL;
}
spl_gadget_init();
/* invoke dfu command */
return run_dfu(usbctrl, interface, devstr);
}
......@@ -5,9 +5,14 @@
# SPDX-License-Identifier: GPL-2.0+
#
ifdef CONFIG_SPL_BUILD
obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o
obj-$(CONFIG_SPL_DFU_RAM) += dfu_ram.o
else
obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o
obj-$(CONFIG_DFU_MMC) += dfu_mmc.o
obj-$(CONFIG_DFU_NAND) += dfu_nand.o
obj-$(CONFIG_DFU_RAM) += dfu_ram.o
obj-$(CONFIG_DFU_SF) += dfu_sf.o
obj-$(CONFIG_DFU_TFTP) += dfu_tftp.o
endif
......@@ -21,10 +21,13 @@ obj-$(CONFIG_USB_GADGET_DOWNLOAD) += g_dnl.o
obj-$(CONFIG_USB_FUNCTION_THOR) += f_thor.o
ifndef CONFIG_SPL_BUILD
obj-$(CONFIG_USB_FUNCTION_DFU) += f_dfu.o
endif
obj-$(CONFIG_USB_FUNCTION_MASS_STORAGE) += f_mass_storage.o
obj-$(CONFIG_USB_FUNCTION_FASTBOOT) += f_fastboot.o
else
obj-$(CONFIG_SPL_DFU_SUPPORT) += f_dfu.o
endif
endif
ifdef CONFIG_USB_ETHER
obj-y += ether.o
obj-$(CONFIG_USB_ETH_RNDIS) += rndis.o
......
......@@ -410,6 +410,15 @@ void musb_hnp_stop(struct musb *musb)
}
#endif
#ifdef CONFIG_CMD_DFU
static u8 last_int_usb;
bool dfu_usb_get_reset(void)
{
return !!(last_int_usb & MUSB_INTR_RESET);
}
#endif
/*
* Interrupt Service Routine to record USB "global" interrupts.
* Since these do not happen often and signify things of
......@@ -433,6 +442,11 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
dev_dbg(musb->controller, "<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl,
int_usb);
#ifdef CONFIG_CMD_DFU
last_int_usb = int_usb;
#endif
#ifndef __UBOOT__
/* in host mode, the peripheral may issue remote wakeup.
* in peripheral mode, the host may resume the link.
......
......@@ -432,8 +432,13 @@ static int omap2430_musb_enable(struct musb *musb)
#else
#ifdef CONFIG_TWL4030_USB
if (twl4030_usb_ulpi_init()) {
#ifdef CONFIG_SPL_BUILD
printf("ERROR: %s Could not initialize PHY\n",
__PRETTY_FUNCTION__);
#else
serial_printf("ERROR: %s Could not initialize PHY\n",
__PRETTY_FUNCTION__);
#endif
}
#endif
......
......@@ -30,7 +30,6 @@
* allow either NAND or OneNAND variant
* select by defining CONFIG_CMD_ONENAND in defconfig
*/
#undef MTDIDS_DEFAULT
#undef MTDPARTS_DEFAULT
......@@ -89,6 +88,46 @@
#endif /* CONFIG_CMD_ONENAND */
#ifdef CONFIG_SPL_DFU_SUPPORT
#define CONFIG_SPL_BOARD_INIT
/* place to store uboot image (can be fit or legacy,
* will be relocated
*/
#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x83000000
#undef CONFIG_SPL_NAND_SUPPORT
#undef CONFIG_ENV_IS_IN_NAND
#undef CONFIG_ENV_IS_IN_ONENAND
#define CONFIG_ENV_IS_NOWHERE
#undef CONFIG_EXTRA_ENV_SETTINGS
#undef CONFIG_SPL_TEXT_BASE
#define CONFIG_SPL_TEXT_BASE 0x40200000
#ifdef CONFIG_SPL_BUILD
/* define uboot dfu download section
* spl claims only 512KByte of SDRAM, so limit buffer
*/
#define CONFIG_EXTRA_ENV_SETTINGS "dfu_alt_info_ram="\
"uboot ram 0x83000000 0x800000\0"\
"dfu_bufsiz=0x20000"
#else
#define CONFIG_EXTRA_ENV_SETTINGS "loadaddr=0x82000000\0"\
"imgtempaddr=0x80800000\0"\
"bootaddr=0x81800000\0"\
"loadaddrfdt=0x81c00000\0"\
"loadaddrinitrd=0x83000000\0"\
"console=ttyO2,115200n8\0"\
"dfu_alt_info="\
"kernel ram 0x82000000 0x800000;"\
"fdt ram 0x81c00000 0x40000;"\
"rd ram 0x83000000 0x4000000;"\
"script ram 0x80800000 0x40000;"\
"bootscript ram 0x81800000 0x40000\0"
#endif
#undef CONFIG_BOOTCOMMAND
#define CONFIG_BOOTCOMMAND "charge auto;dfu 0 ram 0;source 0x80800000"
#endif /* CONFIG_SPL_DFU_SUPPORT */
#define CONFIG_CMD_UNZIP 1 /* for reducing size of splash image */
#undef CONFIG_SYS_PROMPT
......
......@@ -203,7 +203,7 @@ static inline void dfu_set_defer_flush(struct dfu_entity *dfu)
int dfu_write_from_mem_addr(struct dfu_entity *dfu, void *buf, int size);
/* Device specific */
#ifdef CONFIG_DFU_MMC
#if defined(CONFIG_DFU_MMC) && !defined(CONFIG_SPL_BUILD)
extern int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s);
#else
static inline int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr,
......@@ -214,7 +214,7 @@ static inline int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr,
}
#endif
#ifdef CONFIG_DFU_NAND
#if defined(CONFIG_DFU_NAND) && !defined(CONFIG_SPL_BUILD)
extern int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr, char *s);
#else
static inline int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr,
......@@ -236,7 +236,7 @@ static inline int dfu_fill_entity_ram(struct dfu_entity *dfu, char *devstr,
}
#endif
#ifdef CONFIG_DFU_SF
#if defined(CONFIG_DFU_SF) && !defined(CONFIG_SPL_BUILD)
extern int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s);
#else
static inline int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr,
......
......@@ -225,6 +225,11 @@ void spl_board_init(void);
*/
bool spl_was_boot_source(void);
/**
* spl_gadget_init() - do usb gadget initialization
*/
void spl_gadget_Init(void);
/**
* spl_dfu_cmd- run dfu command with chosen mmc device interface
* @param usb_index - usb controller number
......
......@@ -68,6 +68,7 @@ libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
libs-y += drivers/
libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/dfu/
libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/gadget/
libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/phy/
libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/gadget/udc/
libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/dwc3/
libs-y += dts/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment