Commit 65c96757fe9ab3bd451674ac12271a5e3703153a

Authored by Alex Kiernan
Committed by Marek Vasut
1 parent 3845b9065f

usb: fastboot: Convert USB f_fastboot to shared fastboot

Convert USB fastboot code to use shared fastboot protocol.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

Showing 39 changed files with 156 additions and 363 deletions Side-by-side Diff

configs/A13-OLinuXino_defconfig
... ... @@ -22,6 +22,7 @@
22 22 # CONFIG_SPL_DOS_PARTITION is not set
23 23 # CONFIG_SPL_PARTITION_UUIDS is not set
24 24 CONFIG_DFU_RAM=y
  25 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
25 26 CONFIG_AXP_ALDO3_VOLT=3300
26 27 CONFIG_CONS_INDEX=2
27 28 CONFIG_USB_EHCI_HCD=y
configs/A20-OLinuXino-Lime2-eMMC_defconfig
... ... @@ -20,6 +20,7 @@
20 20 # CONFIG_SPL_PARTITION_UUIDS is not set
21 21 CONFIG_SCSI_AHCI=y
22 22 CONFIG_DFU_RAM=y
  23 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
23 24 CONFIG_ETH_DESIGNWARE=y
24 25 CONFIG_RGMII=y
25 26 CONFIG_SUN7I_GMAC=y
configs/A20-OLinuXino-Lime2_defconfig
... ... @@ -19,6 +19,7 @@
19 19 # CONFIG_SPL_PARTITION_UUIDS is not set
20 20 CONFIG_SCSI_AHCI=y
21 21 CONFIG_DFU_RAM=y
  22 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
22 23 CONFIG_ETH_DESIGNWARE=y
23 24 CONFIG_RGMII=y
24 25 CONFIG_SUN7I_GMAC=y
configs/A20-Olimex-SOM204-EVB-eMMC_defconfig
... ... @@ -18,6 +18,7 @@
18 18 # CONFIG_SPL_DOS_PARTITION is not set
19 19 # CONFIG_SPL_PARTITION_UUIDS is not set
20 20 CONFIG_SCSI_AHCI=y
  21 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
21 22 CONFIG_PHY_ADDR=3
22 23 CONFIG_PHY_MICREL=y
23 24 CONFIG_PHY_MICREL_KSZ90X1=y
configs/A20-Olimex-SOM204-EVB_defconfig
... ... @@ -17,6 +17,7 @@
17 17 # CONFIG_SPL_DOS_PARTITION is not set
18 18 # CONFIG_SPL_PARTITION_UUIDS is not set
19 19 CONFIG_SCSI_AHCI=y
  20 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
20 21 CONFIG_PHY_ADDR=3
21 22 CONFIG_PHY_MICREL=y
22 23 CONFIG_PHY_MICREL_KSZ90X1=y
configs/Bananapi_m2m_defconfig
... ... @@ -13,6 +13,7 @@
13 13 # CONFIG_CMD_FLASH is not set
14 14 # CONFIG_SPL_DOS_PARTITION is not set
15 15 # CONFIG_SPL_PARTITION_UUIDS is not set
  16 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
16 17 CONFIG_USB_EHCI_HCD=y
17 18 CONFIG_USB_MUSB_GADGET=y
18 19 CONFIG_USB_FUNCTION_MASS_STORAGE=y
configs/Cubietruck_defconfig
... ... @@ -21,6 +21,7 @@
21 21 # CONFIG_SPL_PARTITION_UUIDS is not set
22 22 CONFIG_SCSI_AHCI=y
23 23 CONFIG_DFU_RAM=y
  24 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
24 25 CONFIG_ETH_DESIGNWARE=y
25 26 CONFIG_RGMII=y
26 27 CONFIG_SUN7I_GMAC=y
configs/Sinlinx_SinA33_defconfig
... ... @@ -18,6 +18,7 @@
18 18 # CONFIG_SPL_DOS_PARTITION is not set
19 19 # CONFIG_SPL_PARTITION_UUIDS is not set
20 20 CONFIG_DFU_RAM=y
  21 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
21 22 CONFIG_USB_EHCI_HCD=y
22 23 CONFIG_USB_MUSB_GADGET=y
23 24 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
configs/am335x_boneblack_defconfig
... ... @@ -16,9 +16,6 @@
16 16 CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
17 17 CONFIG_AUTOBOOT_DELAY_STR="d"
18 18 CONFIG_AUTOBOOT_STOP_STR=" "
19   -CONFIG_USB_FUNCTION_FASTBOOT=y
20   -CONFIG_FASTBOOT_FLASH=y
21   -CONFIG_FASTBOOT_FLASH_MMC_DEV=1
22 19 CONFIG_CMD_SPL=y
23 20 # CONFIG_CMD_FLASH is not set
24 21 # CONFIG_CMD_SETEXPR is not set
... ... @@ -28,6 +25,10 @@
28 25 CONFIG_DFU_TFTP=y
29 26 CONFIG_DFU_MMC=y
30 27 CONFIG_DFU_RAM=y
  28 +CONFIG_USB_FUNCTION_FASTBOOT=y
  29 +CONFIG_FASTBOOT_FLASH=y
  30 +CONFIG_FASTBOOT_FLASH_MMC_DEV=1
  31 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
31 32 CONFIG_MMC_OMAP_HS=y
32 33 CONFIG_SPI_FLASH=y
33 34 CONFIG_SPI_FLASH_WINBOND=y
configs/am57xx_evm_defconfig
... ... @@ -24,12 +24,6 @@
24 24 CONFIG_SPL_DMA_SUPPORT=y
25 25 CONFIG_SPL_OS_BOOT=y
26 26 CONFIG_SPL_SPI_LOAD=y
27   -CONFIG_USB_FUNCTION_FASTBOOT=y
28   -CONFIG_FASTBOOT_BUF_ADDR=0x82000000
29   -CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
30   -CONFIG_FASTBOOT_USB_DEV=1
31   -CONFIG_FASTBOOT_FLASH=y
32   -CONFIG_FASTBOOT_FLASH_MMC_DEV=1
33 27 CONFIG_CMD_SPL=y
34 28 # CONFIG_CMD_FLASH is not set
35 29 # CONFIG_CMD_SETEXPR is not set
... ... @@ -45,6 +39,13 @@
45 39 # CONFIG_BLK is not set
46 40 CONFIG_DFU_MMC=y
47 41 CONFIG_DFU_RAM=y
  42 +CONFIG_USB_FUNCTION_FASTBOOT=y
  43 +CONFIG_FASTBOOT_BUF_ADDR=0x82000000
  44 +CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
  45 +CONFIG_FASTBOOT_USB_DEV=1
  46 +CONFIG_FASTBOOT_FLASH=y
  47 +CONFIG_FASTBOOT_FLASH_MMC_DEV=1
  48 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
48 49 CONFIG_DM_GPIO=y
49 50 CONFIG_DM_I2C=y
50 51 CONFIG_DM_MMC=y
configs/am57xx_hs_evm_defconfig
... ... @@ -29,12 +29,6 @@
29 29 CONFIG_SPL_SEPARATE_BSS=y
30 30 CONFIG_SPL_DMA_SUPPORT=y
31 31 CONFIG_SPL_SPI_LOAD=y
32   -CONFIG_USB_FUNCTION_FASTBOOT=y
33   -CONFIG_FASTBOOT_BUF_ADDR=0x82000000
34   -CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
35   -CONFIG_FASTBOOT_USB_DEV=1
36   -CONFIG_FASTBOOT_FLASH=y
37   -CONFIG_FASTBOOT_FLASH_MMC_DEV=1
38 32 # CONFIG_CMD_FLASH is not set
39 33 # CONFIG_CMD_SETEXPR is not set
40 34 CONFIG_OF_CONTROL=y
... ... @@ -48,6 +42,13 @@
48 42 # CONFIG_BLK is not set
49 43 CONFIG_DFU_MMC=y
50 44 CONFIG_DFU_RAM=y
  45 +CONFIG_USB_FUNCTION_FASTBOOT=y
  46 +CONFIG_FASTBOOT_BUF_ADDR=0x82000000
  47 +CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
  48 +CONFIG_FASTBOOT_USB_DEV=1
  49 +CONFIG_FASTBOOT_FLASH=y
  50 +CONFIG_FASTBOOT_FLASH_MMC_DEV=1
  51 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
51 52 CONFIG_DM_GPIO=y
52 53 CONFIG_DM_I2C=y
53 54 CONFIG_DM_MMC=y
configs/chromebit_mickey_defconfig
... ... @@ -16,8 +16,6 @@
16 16 CONFIG_SPL_STACK_R=y
17 17 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
18 18 CONFIG_SPL_SPI_LOAD=y
19   -CONFIG_FASTBOOT_FLASH=y
20   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
21 19 CONFIG_CMD_GPIO=y
22 20 CONFIG_CMD_GPT=y
23 21 CONFIG_CMD_I2C=y
... ... @@ -44,6 +42,9 @@
44 42 # CONFIG_SPL_SIMPLE_BUS is not set
45 43 CONFIG_CLK=y
46 44 CONFIG_SPL_CLK=y
  45 +CONFIG_FASTBOOT_FLASH=y
  46 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  47 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
47 48 CONFIG_ROCKCHIP_GPIO=y
48 49 CONFIG_I2C_CROS_EC_TUNNEL=y
49 50 CONFIG_SYS_I2C_ROCKCHIP=y
configs/chromebook_jerry_defconfig
... ... @@ -18,8 +18,6 @@
18 18 CONFIG_SPL_STACK_R=y
19 19 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
20 20 CONFIG_SPL_SPI_LOAD=y
21   -CONFIG_FASTBOOT_FLASH=y
22   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
23 21 CONFIG_CMD_GPIO=y
24 22 CONFIG_CMD_GPT=y
25 23 CONFIG_CMD_I2C=y
... ... @@ -46,6 +44,9 @@
46 44 # CONFIG_SPL_SIMPLE_BUS is not set
47 45 CONFIG_CLK=y
48 46 CONFIG_SPL_CLK=y
  47 +CONFIG_FASTBOOT_FLASH=y
  48 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  49 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
49 50 CONFIG_ROCKCHIP_GPIO=y
50 51 CONFIG_I2C_CROS_EC_TUNNEL=y
51 52 CONFIG_SYS_I2C_ROCKCHIP=y
configs/chromebook_minnie_defconfig
... ... @@ -17,8 +17,6 @@
17 17 CONFIG_SPL_STACK_R=y
18 18 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
19 19 CONFIG_SPL_SPI_LOAD=y
20   -CONFIG_FASTBOOT_FLASH=y
21   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
22 20 CONFIG_CMD_GPIO=y
23 21 CONFIG_CMD_GPT=y
24 22 CONFIG_CMD_I2C=y
... ... @@ -45,6 +43,9 @@
45 43 # CONFIG_SPL_SIMPLE_BUS is not set
46 44 CONFIG_CLK=y
47 45 CONFIG_SPL_CLK=y
  46 +CONFIG_FASTBOOT_FLASH=y
  47 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  48 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
48 49 CONFIG_ROCKCHIP_GPIO=y
49 50 CONFIG_I2C_CROS_EC_TUNNEL=y
50 51 CONFIG_SYS_I2C_ROCKCHIP=y
configs/dra7xx_evm_defconfig
... ... @@ -25,11 +25,6 @@
25 25 CONFIG_SPL_DMA_SUPPORT=y
26 26 CONFIG_SPL_OS_BOOT=y
27 27 CONFIG_SPL_SPI_LOAD=y
28   -CONFIG_USB_FUNCTION_FASTBOOT=y
29   -CONFIG_FASTBOOT_BUF_ADDR=0x82000000
30   -CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
31   -CONFIG_FASTBOOT_FLASH=y
32   -CONFIG_FASTBOOT_FLASH_MMC_DEV=1
33 28 CONFIG_CMD_SPL=y
34 29 # CONFIG_CMD_FLASH is not set
35 30 # CONFIG_CMD_SETEXPR is not set
... ... @@ -50,6 +45,12 @@
50 45 CONFIG_DFU_MMC=y
51 46 CONFIG_DFU_RAM=y
52 47 CONFIG_DFU_SF=y
  48 +CONFIG_USB_FUNCTION_FASTBOOT=y
  49 +CONFIG_FASTBOOT_BUF_ADDR=0x82000000
  50 +CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
  51 +CONFIG_FASTBOOT_FLASH=y
  52 +CONFIG_FASTBOOT_FLASH_MMC_DEV=1
  53 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
53 54 CONFIG_DM_GPIO=y
54 55 CONFIG_PCF8575_GPIO=y
55 56 CONFIG_DM_I2C=y
configs/dra7xx_hs_evm_defconfig
... ... @@ -30,11 +30,6 @@
30 30 CONFIG_SPL_SEPARATE_BSS=y
31 31 CONFIG_SPL_DMA_SUPPORT=y
32 32 CONFIG_SPL_SPI_LOAD=y
33   -CONFIG_USB_FUNCTION_FASTBOOT=y
34   -CONFIG_FASTBOOT_BUF_ADDR=0x82000000
35   -CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
36   -CONFIG_FASTBOOT_FLASH=y
37   -CONFIG_FASTBOOT_FLASH_MMC_DEV=1
38 33 # CONFIG_CMD_FLASH is not set
39 34 # CONFIG_CMD_SETEXPR is not set
40 35 CONFIG_OF_CONTROL=y
... ... @@ -50,6 +45,12 @@
50 45 CONFIG_DFU_MMC=y
51 46 CONFIG_DFU_RAM=y
52 47 CONFIG_DFU_SF=y
  48 +CONFIG_USB_FUNCTION_FASTBOOT=y
  49 +CONFIG_FASTBOOT_BUF_ADDR=0x82000000
  50 +CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
  51 +CONFIG_FASTBOOT_FLASH=y
  52 +CONFIG_FASTBOOT_FLASH_MMC_DEV=1
  53 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
53 54 CONFIG_DM_GPIO=y
54 55 CONFIG_PCF8575_GPIO=y
55 56 CONFIG_DM_I2C=y
configs/evb-rk3036_defconfig
... ... @@ -15,8 +15,6 @@
15 15 CONFIG_DISPLAY_BOARDINFO_LATE=y
16 16 # CONFIG_SPL_FRAMEWORK is not set
17 17 CONFIG_SPL_STACK_R=y
18   -CONFIG_FASTBOOT_FLASH=y
19   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
20 18 CONFIG_CMD_GPT=y
21 19 CONFIG_CMD_I2C=y
22 20 CONFIG_CMD_MMC=y
... ... @@ -31,6 +29,9 @@
31 29 CONFIG_REGMAP=y
32 30 CONFIG_SYSCON=y
33 31 CONFIG_CLK=y
  32 +CONFIG_FASTBOOT_FLASH=y
  33 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  34 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
34 35 CONFIG_ROCKCHIP_GPIO=y
35 36 CONFIG_SYS_I2C_ROCKCHIP=y
36 37 CONFIG_LED=y
configs/evb-rk3128_defconfig
... ... @@ -7,10 +7,6 @@
7 7 CONFIG_FIT=y
8 8 # CONFIG_DISPLAY_CPUINFO is not set
9 9 CONFIG_DISPLAY_BOARDINFO_LATE=y
10   -CONFIG_FASTBOOT_BUF_ADDR=0x60800800
11   -CONFIG_FASTBOOT_BUF_SIZE=0x04000000
12   -CONFIG_FASTBOOT_FLASH=y
13   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
14 10 CONFIG_CMD_GPT=y
15 11 CONFIG_CMD_MMC=y
16 12 CONFIG_CMD_USB=y
... ... @@ -20,6 +16,11 @@
20 16 CONFIG_REGMAP=y
21 17 CONFIG_SYSCON=y
22 18 CONFIG_CLK=y
  19 +CONFIG_FASTBOOT_BUF_ADDR=0x60800800
  20 +CONFIG_FASTBOOT_BUF_SIZE=0x04000000
  21 +CONFIG_FASTBOOT_FLASH=y
  22 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  23 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
23 24 CONFIG_ROCKCHIP_GPIO=y
24 25 CONFIG_SYS_I2C_ROCKCHIP=y
25 26 CONFIG_MMC_DW=y
configs/evb-rk3229_defconfig
... ... @@ -14,8 +14,6 @@
14 14 CONFIG_DISPLAY_BOARDINFO_LATE=y
15 15 CONFIG_SPL_STACK_R=y
16 16 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x200
17   -CONFIG_FASTBOOT_FLASH=y
18   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
19 17 CONFIG_CMD_GPT=y
20 18 CONFIG_CMD_MMC=y
21 19 # CONFIG_CMD_SETEXPR is not set
... ... @@ -30,6 +28,9 @@
30 28 CONFIG_SPL_SYSCON=y
31 29 CONFIG_CLK=y
32 30 CONFIG_SPL_CLK=y
  31 +CONFIG_FASTBOOT_FLASH=y
  32 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  33 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
33 34 CONFIG_ROCKCHIP_GPIO=y
34 35 CONFIG_SYS_I2C_ROCKCHIP=y
35 36 CONFIG_MMC_DW=y
configs/evb-rk3288_defconfig
... ... @@ -14,8 +14,6 @@
14 14 CONFIG_DISPLAY_BOARDINFO_LATE=y
15 15 CONFIG_SPL_STACK_R=y
16 16 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
17   -CONFIG_FASTBOOT_FLASH=y
18   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
19 17 CONFIG_CMD_GPIO=y
20 18 CONFIG_CMD_GPT=y
21 19 CONFIG_CMD_I2C=y
... ... @@ -41,6 +39,9 @@
41 39 CONFIG_SPL_SYSCON=y
42 40 CONFIG_CLK=y
43 41 CONFIG_SPL_CLK=y
  42 +CONFIG_FASTBOOT_FLASH=y
  43 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  44 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
44 45 CONFIG_ROCKCHIP_GPIO=y
45 46 CONFIG_SYS_I2C_ROCKCHIP=y
46 47 CONFIG_LED=y
configs/evb-rk3328_defconfig
... ... @@ -8,9 +8,6 @@
8 8 CONFIG_FIT=y
9 9 # CONFIG_DISPLAY_CPUINFO is not set
10 10 CONFIG_DISPLAY_BOARDINFO_LATE=y
11   -CONFIG_FASTBOOT_BUF_ADDR=0x800800
12   -CONFIG_FASTBOOT_FLASH=y
13   -CONFIG_FASTBOOT_FLASH_MMC_DEV=1
14 11 CONFIG_CMD_BOOTZ=y
15 12 CONFIG_CMD_GPT=y
16 13 CONFIG_CMD_MMC=y
... ... @@ -23,6 +20,10 @@
23 20 CONFIG_REGMAP=y
24 21 CONFIG_SYSCON=y
25 22 CONFIG_CLK=y
  23 +CONFIG_FASTBOOT_BUF_ADDR=0x800800
  24 +CONFIG_FASTBOOT_FLASH=y
  25 +CONFIG_FASTBOOT_FLASH_MMC_DEV=1
  26 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
26 27 CONFIG_ROCKCHIP_GPIO=y
27 28 CONFIG_SYS_I2C_ROCKCHIP=y
28 29 CONFIG_MMC_DW=y
configs/fennec-rk3288_defconfig
... ... @@ -15,8 +15,6 @@
15 15 CONFIG_DISPLAY_BOARDINFO_LATE=y
16 16 CONFIG_SPL_STACK_R=y
17 17 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
18   -CONFIG_FASTBOOT_FLASH=y
19   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
20 18 CONFIG_CMD_GPIO=y
21 19 CONFIG_CMD_GPT=y
22 20 CONFIG_CMD_I2C=y
... ... @@ -42,6 +40,9 @@
42 40 # CONFIG_SPL_SIMPLE_BUS is not set
43 41 CONFIG_CLK=y
44 42 CONFIG_SPL_CLK=y
  43 +CONFIG_FASTBOOT_FLASH=y
  44 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  45 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
45 46 CONFIG_ROCKCHIP_GPIO=y
46 47 CONFIG_SYS_I2C_ROCKCHIP=y
47 48 CONFIG_MMC_DW=y
configs/firefly-rk3288_defconfig
... ... @@ -14,8 +14,6 @@
14 14 CONFIG_DISPLAY_BOARDINFO_LATE=y
15 15 CONFIG_SPL_STACK_R=y
16 16 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
17   -CONFIG_FASTBOOT_FLASH=y
18   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
19 17 CONFIG_CMD_GPIO=y
20 18 CONFIG_CMD_GPT=y
21 19 CONFIG_CMD_I2C=y
... ... @@ -42,6 +40,9 @@
42 40 # CONFIG_SPL_SIMPLE_BUS is not set
43 41 CONFIG_CLK=y
44 42 CONFIG_SPL_CLK=y
  43 +CONFIG_FASTBOOT_FLASH=y
  44 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  45 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
45 46 CONFIG_ROCKCHIP_GPIO=y
46 47 CONFIG_SYS_I2C_ROCKCHIP=y
47 48 CONFIG_DM_KEYBOARD=y
configs/kylin-rk3036_defconfig
... ... @@ -14,8 +14,6 @@
14 14 CONFIG_DISPLAY_BOARDINFO_LATE=y
15 15 # CONFIG_SPL_FRAMEWORK is not set
16 16 CONFIG_SPL_STACK_R=y
17   -CONFIG_FASTBOOT_FLASH=y
18   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
19 17 CONFIG_CMD_GPT=y
20 18 CONFIG_CMD_I2C=y
21 19 CONFIG_CMD_MMC=y
... ... @@ -31,6 +29,9 @@
31 29 CONFIG_REGMAP=y
32 30 CONFIG_SYSCON=y
33 31 CONFIG_CLK=y
  32 +CONFIG_FASTBOOT_FLASH=y
  33 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  34 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
34 35 CONFIG_ROCKCHIP_GPIO=y
35 36 CONFIG_SYS_I2C_ROCKCHIP=y
36 37 CONFIG_LED=y
configs/miqi-rk3288_defconfig
... ... @@ -14,8 +14,6 @@
14 14 CONFIG_DISPLAY_BOARDINFO_LATE=y
15 15 CONFIG_SPL_STACK_R=y
16 16 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
17   -CONFIG_FASTBOOT_FLASH=y
18   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
19 17 CONFIG_CMD_GPIO=y
20 18 CONFIG_CMD_GPT=y
21 19 CONFIG_CMD_I2C=y
... ... @@ -42,6 +40,9 @@
42 40 # CONFIG_SPL_SIMPLE_BUS is not set
43 41 CONFIG_CLK=y
44 42 CONFIG_SPL_CLK=y
  43 +CONFIG_FASTBOOT_FLASH=y
  44 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  45 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
45 46 CONFIG_ROCKCHIP_GPIO=y
46 47 CONFIG_SYS_I2C_ROCKCHIP=y
47 48 CONFIG_MMC_DW=y
configs/parrot_r16_defconfig
... ... @@ -15,6 +15,7 @@
15 15 # CONFIG_CMD_FLASH is not set
16 16 # CONFIG_SPL_DOS_PARTITION is not set
17 17 # CONFIG_SPL_PARTITION_UUIDS is not set
  18 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
18 19 CONFIG_CONS_INDEX=5
19 20 CONFIG_USB_EHCI_HCD=y
20 21 CONFIG_USB_MUSB_GADGET=y
configs/phycore-rk3288_defconfig
... ... @@ -17,8 +17,6 @@
17 17 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
18 18 CONFIG_SPL_I2C_SUPPORT=y
19 19 CONFIG_SPL_POWER_SUPPORT=y
20   -CONFIG_FASTBOOT_FLASH=y
21   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
22 20 CONFIG_CMD_GPIO=y
23 21 CONFIG_CMD_GPT=y
24 22 CONFIG_CMD_I2C=y
... ... @@ -44,6 +42,9 @@
44 42 # CONFIG_SPL_SIMPLE_BUS is not set
45 43 CONFIG_CLK=y
46 44 CONFIG_SPL_CLK=y
  45 +CONFIG_FASTBOOT_FLASH=y
  46 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  47 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
47 48 CONFIG_ROCKCHIP_GPIO=y
48 49 CONFIG_SYS_I2C_ROCKCHIP=y
49 50 CONFIG_MISC=y
configs/popmetal-rk3288_defconfig
... ... @@ -15,8 +15,6 @@
15 15 CONFIG_DISPLAY_BOARDINFO_LATE=y
16 16 CONFIG_SPL_STACK_R=y
17 17 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
18   -CONFIG_FASTBOOT_FLASH=y
19   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
20 18 CONFIG_CMD_GPIO=y
21 19 CONFIG_CMD_GPT=y
22 20 CONFIG_CMD_I2C=y
... ... @@ -42,6 +40,9 @@
42 40 # CONFIG_SPL_SIMPLE_BUS is not set
43 41 CONFIG_CLK=y
44 42 CONFIG_SPL_CLK=y
  43 +CONFIG_FASTBOOT_FLASH=y
  44 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  45 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
45 46 CONFIG_ROCKCHIP_GPIO=y
46 47 CONFIG_SYS_I2C_ROCKCHIP=y
47 48 CONFIG_MMC_DW=y
configs/rock2_defconfig
... ... @@ -14,8 +14,6 @@
14 14 CONFIG_DISPLAY_BOARDINFO_LATE=y
15 15 CONFIG_SPL_STACK_R=y
16 16 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
17   -CONFIG_FASTBOOT_FLASH=y
18   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
19 17 CONFIG_CMD_GPIO=y
20 18 CONFIG_CMD_GPT=y
21 19 CONFIG_CMD_I2C=y
... ... @@ -42,6 +40,9 @@
42 40 # CONFIG_SPL_SIMPLE_BUS is not set
43 41 CONFIG_CLK=y
44 42 CONFIG_SPL_CLK=y
  43 +CONFIG_FASTBOOT_FLASH=y
  44 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  45 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
45 46 CONFIG_ROCKCHIP_GPIO=y
46 47 CONFIG_SYS_I2C_ROCKCHIP=y
47 48 CONFIG_MMC_DW=y
configs/stih410-b2260_defconfig
... ... @@ -10,11 +10,6 @@
10 10 CONFIG_BOOTARGS="console=ttyAS1,115200 CONSOLE=/dev/ttyAS1 consoleblank=0 root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait mem=992M@0x40000000 vmalloc=256m"
11 11 # CONFIG_DISPLAY_CPUINFO is not set
12 12 CONFIG_SYS_PROMPT="stih410-b2260 => "
13   -CONFIG_USB_FUNCTION_FASTBOOT=y
14   -CONFIG_FASTBOOT_BUF_ADDR=0x40000000
15   -CONFIG_FASTBOOT_BUF_SIZE=0x3DF00000
16   -CONFIG_FASTBOOT_FLASH=y
17   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
18 13 CONFIG_CMD_GPT=y
19 14 CONFIG_CMD_MMC=y
20 15 CONFIG_CMD_USB=y
... ... @@ -26,6 +21,12 @@
26 21 CONFIG_REGMAP=y
27 22 CONFIG_SYSCON=y
28 23 CONFIG_CLK=y
  24 +CONFIG_USB_FUNCTION_FASTBOOT=y
  25 +CONFIG_FASTBOOT_BUF_ADDR=0x40000000
  26 +CONFIG_FASTBOOT_BUF_SIZE=0x3DF00000
  27 +CONFIG_FASTBOOT_FLASH=y
  28 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  29 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
29 30 CONFIG_MISC=y
30 31 CONFIG_MMC_SDHCI=y
31 32 CONFIG_MMC_SDHCI_STI=y
configs/tbs_a711_defconfig
... ... @@ -16,6 +16,7 @@
16 16 # CONFIG_CMD_FLASH is not set
17 17 # CONFIG_SPL_DOS_PARTITION is not set
18 18 # CONFIG_SPL_EFI_PARTITION is not set
  19 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
19 20 CONFIG_AXP_DCDC5_VOLT=1200
20 21 CONFIG_USB_EHCI_HCD=y
21 22 CONFIG_USB_MUSB_GADGET=y
configs/tinker-rk3288_defconfig
... ... @@ -16,8 +16,6 @@
16 16 CONFIG_SPL_STACK_R=y
17 17 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
18 18 CONFIG_SPL_I2C_SUPPORT=y
19   -CONFIG_FASTBOOT_FLASH=y
20   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
21 19 CONFIG_CMD_GPIO=y
22 20 CONFIG_CMD_GPT=y
23 21 CONFIG_CMD_I2C=y
... ... @@ -43,6 +41,9 @@
43 41 # CONFIG_SPL_SIMPLE_BUS is not set
44 42 CONFIG_CLK=y
45 43 CONFIG_SPL_CLK=y
  44 +CONFIG_FASTBOOT_FLASH=y
  45 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  46 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
46 47 CONFIG_ROCKCHIP_GPIO=y
47 48 CONFIG_SYS_I2C_ROCKCHIP=y
48 49 CONFIG_MISC=y
configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig
... ... @@ -19,9 +19,6 @@
19 19 CONFIG_SPL_RAM_DEVICE=y
20 20 CONFIG_SPL_ATF=y
21 21 CONFIG_SYS_PROMPT="ZynqMP> "
22   -CONFIG_USB_FUNCTION_FASTBOOT=y
23   -CONFIG_FASTBOOT_FLASH=y
24   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
25 22 CONFIG_CMD_THOR_DOWNLOAD=y
26 23 CONFIG_CMD_MEMTEST=y
27 24 CONFIG_SYS_ALT_MEMTEST=y
... ... @@ -47,6 +44,10 @@
47 44 CONFIG_SPL_DM_SEQ_ALIAS=y
48 45 CONFIG_CLK_ZYNQMP=y
49 46 CONFIG_DFU_RAM=y
  47 +CONFIG_USB_FUNCTION_FASTBOOT=y
  48 +CONFIG_FASTBOOT_FLASH=y
  49 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  50 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
50 51 CONFIG_FPGA_XILINX=y
51 52 CONFIG_FPGA_ZYNQMPPL=y
52 53 CONFIG_DM_GPIO=y
configs/xilinx_zynqmp_zcu102_rev1_0_defconfig
... ... @@ -19,9 +19,6 @@
19 19 CONFIG_SPL_RAM_DEVICE=y
20 20 CONFIG_SPL_ATF=y
21 21 CONFIG_SYS_PROMPT="ZynqMP> "
22   -CONFIG_USB_FUNCTION_FASTBOOT=y
23   -CONFIG_FASTBOOT_FLASH=y
24   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
25 22 CONFIG_CMD_THOR_DOWNLOAD=y
26 23 CONFIG_CMD_EEPROM=y
27 24 CONFIG_CMD_MEMTEST=y
... ... @@ -50,6 +47,10 @@
50 47 CONFIG_SATA_CEVA=y
51 48 CONFIG_CLK_ZYNQMP=y
52 49 CONFIG_DFU_RAM=y
  50 +CONFIG_USB_FUNCTION_FASTBOOT=y
  51 +CONFIG_FASTBOOT_FLASH=y
  52 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  53 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
53 54 CONFIG_FPGA_XILINX=y
54 55 CONFIG_FPGA_ZYNQMPPL=y
55 56 CONFIG_DM_GPIO=y
configs/xilinx_zynqmp_zcu102_revA_defconfig
... ... @@ -19,9 +19,6 @@
19 19 CONFIG_SPL_RAM_DEVICE=y
20 20 CONFIG_SPL_ATF=y
21 21 CONFIG_SYS_PROMPT="ZynqMP> "
22   -CONFIG_USB_FUNCTION_FASTBOOT=y
23   -CONFIG_FASTBOOT_FLASH=y
24   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
25 22 CONFIG_CMD_THOR_DOWNLOAD=y
26 23 CONFIG_CMD_EEPROM=y
27 24 CONFIG_CMD_MEMTEST=y
... ... @@ -50,6 +47,10 @@
50 47 CONFIG_SATA_CEVA=y
51 48 CONFIG_CLK_ZYNQMP=y
52 49 CONFIG_DFU_RAM=y
  50 +CONFIG_USB_FUNCTION_FASTBOOT=y
  51 +CONFIG_FASTBOOT_FLASH=y
  52 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  53 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
53 54 CONFIG_FPGA_XILINX=y
54 55 CONFIG_FPGA_ZYNQMPPL=y
55 56 CONFIG_DM_GPIO=y
configs/xilinx_zynqmp_zcu102_revB_defconfig
... ... @@ -19,9 +19,6 @@
19 19 CONFIG_SPL_RAM_DEVICE=y
20 20 CONFIG_SPL_ATF=y
21 21 CONFIG_SYS_PROMPT="ZynqMP> "
22   -CONFIG_USB_FUNCTION_FASTBOOT=y
23   -CONFIG_FASTBOOT_FLASH=y
24   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
25 22 CONFIG_CMD_THOR_DOWNLOAD=y
26 23 CONFIG_CMD_EEPROM=y
27 24 CONFIG_CMD_MEMTEST=y
... ... @@ -50,6 +47,10 @@
50 47 CONFIG_SATA_CEVA=y
51 48 CONFIG_CLK_ZYNQMP=y
52 49 CONFIG_DFU_RAM=y
  50 +CONFIG_USB_FUNCTION_FASTBOOT=y
  51 +CONFIG_FASTBOOT_FLASH=y
  52 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  53 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
53 54 CONFIG_FPGA_XILINX=y
54 55 CONFIG_FPGA_ZYNQMPPL=y
55 56 CONFIG_DM_GPIO=y
configs/xilinx_zynqmp_zcu106_revA_defconfig
... ... @@ -18,9 +18,6 @@
18 18 CONFIG_SPL_RAM_DEVICE=y
19 19 CONFIG_SPL_ATF=y
20 20 CONFIG_SYS_PROMPT="ZynqMP> "
21   -CONFIG_USB_FUNCTION_FASTBOOT=y
22   -CONFIG_FASTBOOT_FLASH=y
23   -CONFIG_FASTBOOT_FLASH_MMC_DEV=0
24 21 CONFIG_CMD_THOR_DOWNLOAD=y
25 22 CONFIG_CMD_EEPROM=y
26 23 CONFIG_CMD_MEMTEST=y
... ... @@ -48,6 +45,10 @@
48 45 CONFIG_SATA_CEVA=y
49 46 CONFIG_CLK_ZYNQMP=y
50 47 CONFIG_DFU_RAM=y
  48 +CONFIG_USB_FUNCTION_FASTBOOT=y
  49 +CONFIG_FASTBOOT_FLASH=y
  50 +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
  51 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
51 52 CONFIG_FPGA_XILINX=y
52 53 CONFIG_FPGA_ZYNQMPPL=y
53 54 CONFIG_DM_GPIO=y
drivers/fastboot/Makefile
1 1 # SPDX-License-Identifier: GPL-2.0+
2 2  
3 3 obj-y += fb_common.o
4   -obj-$(CONFIG_UDP_FUNCTION_FASTBOOT) += fb_getvar.o
5   -obj-$(CONFIG_UDP_FUNCTION_FASTBOOT) += fb_command.o
  4 +obj-y += fb_getvar.o
  5 +obj-y += fb_command.o
6 6 obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o
7 7 obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o
drivers/usb/gadget/f_fastboot.c
... ... @@ -18,14 +18,7 @@
18 18 #include <linux/usb/gadget.h>
19 19 #include <linux/usb/composite.h>
20 20 #include <linux/compiler.h>
21   -#include <version.h>
22 21 #include <g_dnl.h>
23   -#ifdef CONFIG_FASTBOOT_FLASH_MMC
24   -#include <fb_mmc.h>
25   -#endif
26   -#ifdef CONFIG_FASTBOOT_FLASH_NAND
27   -#include <fb_nand.h>
28   -#endif
29 22  
30 23 #define FASTBOOT_INTERFACE_CLASS 0xff
31 24 #define FASTBOOT_INTERFACE_SUB_CLASS 0x42
... ... @@ -56,8 +49,6 @@
56 49 }
57 50  
58 51 static struct f_fastboot *fastboot_func;
59   -static unsigned int download_size;
60   -static unsigned int download_bytes;
61 52  
62 53 static struct usb_endpoint_descriptor fs_ep_in = {
63 54 .bLength = USB_DT_ENDPOINT_SIZE,
... ... @@ -145,7 +136,6 @@
145 136 };
146 137  
147 138 static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
148   -static int strcmp_l1(const char *s1, const char *s2);
149 139  
150 140 static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
151 141 {
152 142  
... ... @@ -355,85 +345,9 @@
355 345 do_reset(NULL, 0, 0, NULL);
356 346 }
357 347  
358   -static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
359   -{
360   - char *cmd = req->buf;
361   - if (!strcmp_l1("reboot-bootloader", cmd)) {
362   - if (fastboot_set_reboot_flag()) {
363   - fastboot_tx_write_str("FAILCannot set reboot flag");
364   - return;
365   - }
366   - }
367   - fastboot_func->in_req->complete = compl_do_reset;
368   - fastboot_tx_write_str("OKAY");
369   -}
370   -
371   -static int strcmp_l1(const char *s1, const char *s2)
372   -{
373   - if (!s1 || !s2)
374   - return -1;
375   - return strncmp(s1, s2, strlen(s1));
376   -}
377   -
378   -static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
379   -{
380   - char *cmd = req->buf;
381   - char response[FASTBOOT_RESPONSE_LEN];
382   - const char *s;
383   - size_t chars_left;
384   -
385   - strcpy(response, "OKAY");
386   - chars_left = sizeof(response) - strlen(response) - 1;
387   -
388   - strsep(&cmd, ":");
389   - if (!cmd) {
390   - pr_err("missing variable");
391   - fastboot_tx_write_str("FAILmissing var");
392   - return;
393   - }
394   -
395   - if (!strcmp_l1("version", cmd)) {
396   - strncat(response, FASTBOOT_VERSION, chars_left);
397   - } else if (!strcmp_l1("bootloader-version", cmd)) {
398   - strncat(response, U_BOOT_VERSION, chars_left);
399   - } else if (!strcmp_l1("downloadsize", cmd) ||
400   - !strcmp_l1("max-download-size", cmd)) {
401   - char str_num[12];
402   -
403   - sprintf(str_num, "0x%08x", CONFIG_FASTBOOT_BUF_SIZE);
404   - strncat(response, str_num, chars_left);
405   - } else if (!strcmp_l1("serialno", cmd)) {
406   - s = env_get("serial#");
407   - if (s)
408   - strncat(response, s, chars_left);
409   - else
410   - strcpy(response, "FAILValue not set");
411   - } else {
412   - char *envstr;
413   -
414   - envstr = malloc(strlen("fastboot.") + strlen(cmd) + 1);
415   - if (!envstr) {
416   - fastboot_tx_write_str("FAILmalloc error");
417   - return;
418   - }
419   -
420   - sprintf(envstr, "fastboot.%s", cmd);
421   - s = env_get(envstr);
422   - if (s) {
423   - strncat(response, s, chars_left);
424   - } else {
425   - printf("WARNING: unknown variable: %s\n", cmd);
426   - strcpy(response, "FAILVariable not implemented");
427   - }
428   -
429   - free(envstr);
430   - }
431   - fastboot_tx_write_str(response);
432   -}
433   -
434 348 static unsigned int rx_bytes_expected(struct usb_ep *ep)
435 349 {
436   - int rx_remain = download_size - download_bytes;
  350 + int rx_remain = fastboot_data_remaining();
437 351 unsigned int rem;
438 352 unsigned int maxpacket = ep->maxpacket;
439 353  
440 354  
441 355  
... ... @@ -455,14 +369,12 @@
455 369 return rx_remain;
456 370 }
457 371  
458   -#define BYTES_PER_DOT 0x20000
459 372 static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req)
460 373 {
461   - char response[FASTBOOT_RESPONSE_LEN];
462   - unsigned int transfer_size = download_size - download_bytes;
  374 + char response[FASTBOOT_RESPONSE_LEN] = {0};
  375 + unsigned int transfer_size = fastboot_data_remaining();
463 376 const unsigned char *buffer = req->buf;
464 377 unsigned int buffer_size = req->actual;
465   - unsigned int pre_dot_num, now_dot_num;
466 378  
467 379 if (req->status != 0) {
468 380 printf("Bad status: %d\n", req->status);
469 381  
470 382  
471 383  
472 384  
473 385  
... ... @@ -472,33 +384,19 @@
472 384 if (buffer_size < transfer_size)
473 385 transfer_size = buffer_size;
474 386  
475   - memcpy((void *)CONFIG_FASTBOOT_BUF_ADDR + download_bytes,
476   - buffer, transfer_size);
  387 + fastboot_data_download(buffer, transfer_size, response);
  388 + if (response[0]) {
  389 + fastboot_tx_write_str(response);
  390 + } else if (!fastboot_data_remaining()) {
  391 + fastboot_data_complete(response);
477 392  
478   - pre_dot_num = download_bytes / BYTES_PER_DOT;
479   - download_bytes += transfer_size;
480   - now_dot_num = download_bytes / BYTES_PER_DOT;
481   -
482   - if (pre_dot_num != now_dot_num) {
483   - putc('.');
484   - if (!(now_dot_num % 74))
485   - putc('\n');
486   - }
487   -
488   - /* Check if transfer is done */
489   - if (download_bytes >= download_size) {
490 393 /*
491   - * Reset global transfer variable, keep download_bytes because
492   - * it will be used in the next possible flashing command
  394 + * Reset global transfer variable
493 395 */
494   - download_size = 0;
495 396 req->complete = rx_handler_command;
496 397 req->length = EP_BUFFER_SIZE;
497 398  
498   - strcpy(response, "OKAY");
499 399 fastboot_tx_write_str(response);
500   -
501   - printf("\ndownloading of %d bytes finished\n", download_bytes);
502 400 } else {
503 401 req->length = rx_bytes_expected(ep);
504 402 }
505 403  
506 404  
507 405  
508 406  
509 407  
510 408  
511 409  
512 410  
513 411  
514 412  
515 413  
516 414  
517 415  
518 416  
519 417  
... ... @@ -507,197 +405,55 @@
507 405 usb_ep_queue(ep, req, 0);
508 406 }
509 407  
510   -static void cb_download(struct usb_ep *ep, struct usb_request *req)
511   -{
512   - char *cmd = req->buf;
513   - char response[FASTBOOT_RESPONSE_LEN];
514   -
515   - strsep(&cmd, ":");
516   - download_size = simple_strtoul(cmd, NULL, 16);
517   - download_bytes = 0;
518   -
519   - printf("Starting download of %d bytes\n", download_size);
520   -
521   - if (0 == download_size) {
522   - strcpy(response, "FAILdata invalid size");
523   - } else if (download_size > CONFIG_FASTBOOT_BUF_SIZE) {
524   - download_size = 0;
525   - strcpy(response, "FAILdata too large");
526   - } else {
527   - sprintf(response, "DATA%08x", download_size);
528   - req->complete = rx_handler_dl_image;
529   - req->length = rx_bytes_expected(ep);
530   - }
531   - fastboot_tx_write_str(response);
532   -}
533   -
534   -static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
535   -{
536   - char boot_addr_start[12];
537   - char *bootm_args[] = { "bootm", boot_addr_start, NULL };
538   -
539   - puts("Booting kernel..\n");
540   -
541   - sprintf(boot_addr_start, "0x%lx", (long)CONFIG_FASTBOOT_BUF_ADDR);
542   - do_bootm(NULL, 0, 2, bootm_args);
543   -
544   - /* This only happens if image is somehow faulty so we start over */
545   - do_reset(NULL, 0, 0, NULL);
546   -}
547   -
548   -static void cb_boot(struct usb_ep *ep, struct usb_request *req)
549   -{
550   - fastboot_func->in_req->complete = do_bootm_on_complete;
551   - fastboot_tx_write_str("OKAY");
552   -}
553   -
554 408 static void do_exit_on_complete(struct usb_ep *ep, struct usb_request *req)
555 409 {
556 410 g_dnl_trigger_detach();
557 411 }
558 412  
559   -static void cb_continue(struct usb_ep *ep, struct usb_request *req)
  413 +static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
560 414 {
561   - fastboot_func->in_req->complete = do_exit_on_complete;
562   - fastboot_tx_write_str("OKAY");
  415 + fastboot_boot();
  416 + do_exit_on_complete(ep, req);
563 417 }
564 418  
565   -#ifdef CONFIG_FASTBOOT_FLASH
566   -static void cb_flash(struct usb_ep *ep, struct usb_request *req)
  419 +static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
567 420 {
568   - char *cmd = req->buf;
569   - char response[FASTBOOT_RESPONSE_LEN];
  421 + char *cmdbuf = req->buf;
  422 + char response[FASTBOOT_RESPONSE_LEN] = {0};
  423 + int cmd = -1;
570 424  
571   - strsep(&cmd, ":");
572   - if (!cmd) {
573   - pr_err("missing partition name");
574   - fastboot_tx_write_str("FAILmissing partition name");
  425 + if (req->status != 0 || req->length == 0)
575 426 return;
576   - }
577 427  
578   - fastboot_fail("no flash device defined", response);
579   -#ifdef CONFIG_FASTBOOT_FLASH_MMC
580   - fastboot_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
581   - download_bytes, response);
582   -#endif
583   -#ifdef CONFIG_FASTBOOT_FLASH_NAND
584   - fastboot_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
585   - download_bytes, response);
586   -#endif
587   - fastboot_tx_write_str(response);
588   -}
589   -#endif
590   -
591   -static void cb_oem(struct usb_ep *ep, struct usb_request *req)
592   -{
593   - char *cmd = req->buf;
594   -#ifdef CONFIG_FASTBOOT_FLASH_MMC
595   - if (strncmp("format", cmd + 4, 6) == 0) {
596   - char cmdbuf[32];
597   - sprintf(cmdbuf, "gpt write mmc %x $partitions",
598   - CONFIG_FASTBOOT_FLASH_MMC_DEV);
599   - if (run_command(cmdbuf, 0))
600   - fastboot_tx_write_str("FAIL");
601   - else
602   - fastboot_tx_write_str("OKAY");
603   - } else
604   -#endif
605   - if (strncmp("unlock", cmd + 4, 8) == 0) {
606   - fastboot_tx_write_str("FAILnot implemented");
  428 + if (req->actual < req->length) {
  429 + cmdbuf[req->actual] = '\0';
  430 + cmd = fastboot_handle_command(cmdbuf, response);
  431 + } else {
  432 + pr_err("buffer overflow");
  433 + fastboot_fail("buffer overflow", response);
607 434 }
608   - else {
609   - fastboot_tx_write_str("FAILunknown oem command");
610   - }
611   -}
612 435  
613   -#ifdef CONFIG_FASTBOOT_FLASH
614   -static void cb_erase(struct usb_ep *ep, struct usb_request *req)
615   -{
616   - char *cmd = req->buf;
617   - char response[FASTBOOT_RESPONSE_LEN];
618   -
619   - strsep(&cmd, ":");
620   - if (!cmd) {
621   - pr_err("missing partition name");
622   - fastboot_tx_write_str("FAILmissing partition name");
623   - return;
  436 + if (!strncmp("DATA", response, 4)) {
  437 + req->complete = rx_handler_dl_image;
  438 + req->length = rx_bytes_expected(ep);
624 439 }
625 440  
626   - fastboot_fail("no flash device defined", response);
627   -#ifdef CONFIG_FASTBOOT_FLASH_MMC
628   - fastboot_mmc_erase(cmd, response);
629   -#endif
630   -#ifdef CONFIG_FASTBOOT_FLASH_NAND
631   - fastboot_nand_erase(cmd, response);
632   -#endif
633 441 fastboot_tx_write_str(response);
634   -}
635   -#endif
636 442  
637   -struct cmd_dispatch_info {
638   - char *cmd;
639   - void (*cb)(struct usb_ep *ep, struct usb_request *req);
640   -};
  443 + if (!strncmp("OKAY", response, 4)) {
  444 + switch (cmd) {
  445 + case FASTBOOT_COMMAND_BOOT:
  446 + fastboot_func->in_req->complete = do_bootm_on_complete;
  447 + break;
641 448  
642   -static const struct cmd_dispatch_info cmd_dispatch_info[] = {
643   - {
644   - .cmd = "reboot",
645   - .cb = cb_reboot,
646   - }, {
647   - .cmd = "getvar:",
648   - .cb = cb_getvar,
649   - }, {
650   - .cmd = "download:",
651   - .cb = cb_download,
652   - }, {
653   - .cmd = "boot",
654   - .cb = cb_boot,
655   - }, {
656   - .cmd = "continue",
657   - .cb = cb_continue,
658   - },
659   -#ifdef CONFIG_FASTBOOT_FLASH
660   - {
661   - .cmd = "flash",
662   - .cb = cb_flash,
663   - }, {
664   - .cmd = "erase",
665   - .cb = cb_erase,
666   - },
667   -#endif
668   - {
669   - .cmd = "oem",
670   - .cb = cb_oem,
671   - },
672   -};
673   -
674   -static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
675   -{
676   - char *cmdbuf = req->buf;
677   - void (*func_cb)(struct usb_ep *ep, struct usb_request *req) = NULL;
678   - int i;
679   -
680   - if (req->status != 0 || req->length == 0)
681   - return;
682   -
683   - for (i = 0; i < ARRAY_SIZE(cmd_dispatch_info); i++) {
684   - if (!strcmp_l1(cmd_dispatch_info[i].cmd, cmdbuf)) {
685   - func_cb = cmd_dispatch_info[i].cb;
  449 + case FASTBOOT_COMMAND_CONTINUE:
  450 + fastboot_func->in_req->complete = do_exit_on_complete;
686 451 break;
687   - }
688   - }
689 452  
690   - if (!func_cb) {
691   - pr_err("unknown command: %.*s", req->actual, cmdbuf);
692   - fastboot_tx_write_str("FAILunknown command");
693   - } else {
694   - if (req->actual < req->length) {
695   - u8 *buf = (u8 *)req->buf;
696   - buf[req->actual] = 0;
697   - func_cb(ep, req);
698   - } else {
699   - pr_err("buffer overflow");
700   - fastboot_tx_write_str("FAILbuffer overflow");
  453 + case FASTBOOT_COMMAND_REBOOT:
  454 + case FASTBOOT_COMMAND_REBOOT_BOOTLOADER:
  455 + fastboot_func->in_req->complete = compl_do_reset;
  456 + break;
701 457 }
702 458 }
703 459