Re: [U-Boot] [PATCH] mmc: sdhci: Fixed timeout for sdhci_send_command()
Tested-by: Steve Rae s...@broadcom.com (does resolve the issue on our board!) On 14-06-27 02:37 AM, Pantelis Antoniou wrote: Hi Eli, On Jun 12, 2014, at 12:41 PM, Eli Billauer wrote: The current wait loop just reads the status 1 times, which makes the actual timeout period platform-dependent. The udelay() call within the loop makes the new timeout ~100 ms. Signed-off-by: Eli Billauer eli.billa...@gmail.com --- drivers/mmc/sdhci.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 3125d13..80f3a91 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -226,6 +226,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, break; if (--retry == 0) break; + udelay(10); } while ((stat mask) != mask); if (retry == 0) { -- 1.7.2.3 Looking at the linux sources is no good, cause linux is interrupt driven. This delay is used because the driver is not interrupt driven, so you have to wait until the interrupt indication is delivered. The only reference to interrupt latency I found is related to tuning and is set to 50ms which I supposed is very pessimistic. I think a timeout of 100ms would be fine. Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] arm: Fix armv8 compilation error
Albert, I don't think that there is any code currently submitted that triggers this error. (it is hidden inside inline functions...) However, you could add one line of code 'anywhere' to test this: test_and_set_bit(1, (volatile void *)0x12345678); Thanks, Steve PS. - using: gcc-linaro-aarch64-linux-gnu-4.8-2014.01_linux/bin/aarch64-linux-gnu- - and:./MAKEALL -a aarch64 On 14-07-04 02:41 PM, Albert ARIBAUD wrote: Hi Darwin, On Mon, 9 Jun 2014 13:25:52 -0700, Darwin Rambo dra...@broadcom.com wrote: From: Shaibal.Dutta shaibal.du...@broadcom.com Fix following compilation error when CONFIG_ARM64 is defined Error: unknown or missing system register name at operand 2 -- `mrs x0,daifmsr daifset,#3' Signed-off-by: Shaibal.Dutta shaibal.du...@broadcom.com Signed-off-by: Darwin Rambo dra...@broadcom.com Reviewed-by: Darwin Rambo dra...@broadcom.com --- I don't get any such error. Which board and which compiler does it appear for? Amicalement, ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 0/4] Introducing the Broadcom Cygnus and NSP boards.
This series adds the bcm958300k and the bcm958622hr boards which share the iproc architecture code. Scott Branden (4): arm: iproc: Initial commit of iproc architecture code arm: bcmcygnus: Add bcmcygnus u-architecture arm: bcmnsp: Add bcmnsp u-architecture arm: add Cygnus and NSP boards arch/arm/cpu/armv7/Makefile | 1 + arch/arm/cpu/armv7/bcmcygnus/Makefile | 7 + arch/arm/cpu/armv7/bcmcygnus/reset.c| 20 +++ arch/arm/cpu/armv7/bcmnsp/Makefile | 7 + arch/arm/cpu/armv7/bcmnsp/reset.c | 19 +++ arch/arm/cpu/armv7/iproc-common/Makefile| 9 ++ arch/arm/cpu/armv7/iproc-common/armpll.c| 170 arch/arm/cpu/armv7/iproc-common/hwinit-common.c | 16 +++ arch/arm/cpu/armv7/iproc-common/timer.c | 130 ++ arch/arm/include/asm/arch-bcmcygnus/configs.h | 25 arch/arm/include/asm/arch-bcmnsp/configs.h | 22 +++ arch/arm/include/asm/iproc-common/armpll.h | 14 ++ arch/arm/include/asm/iproc-common/configs.h | 20 +++ arch/arm/include/asm/iproc-common/sysmap.h | 47 +++ arch/arm/include/asm/iproc-common/timer.h | 37 ++ board/broadcom/bcm_ep/Makefile | 7 + board/broadcom/bcm_ep/board.c | 62 + boards.cfg | 2 + include/configs/bcm_ep_board.h | 111 19 files changed, 726 insertions(+) create mode 100644 arch/arm/cpu/armv7/bcmcygnus/Makefile create mode 100644 arch/arm/cpu/armv7/bcmcygnus/reset.c create mode 100644 arch/arm/cpu/armv7/bcmnsp/Makefile create mode 100644 arch/arm/cpu/armv7/bcmnsp/reset.c create mode 100644 arch/arm/cpu/armv7/iproc-common/Makefile create mode 100644 arch/arm/cpu/armv7/iproc-common/armpll.c create mode 100644 arch/arm/cpu/armv7/iproc-common/hwinit-common.c create mode 100644 arch/arm/cpu/armv7/iproc-common/timer.c create mode 100644 arch/arm/include/asm/arch-bcmcygnus/configs.h create mode 100644 arch/arm/include/asm/arch-bcmnsp/configs.h create mode 100644 arch/arm/include/asm/iproc-common/armpll.h create mode 100644 arch/arm/include/asm/iproc-common/configs.h create mode 100644 arch/arm/include/asm/iproc-common/sysmap.h create mode 100644 arch/arm/include/asm/iproc-common/timer.h create mode 100644 board/broadcom/bcm_ep/Makefile create mode 100644 board/broadcom/bcm_ep/board.c create mode 100644 include/configs/bcm_ep_board.h -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 3/4] arm: bcmnsp: Add bcmnsp u-architecture
From: Scott Branden sbran...@broadcom.com Base support for the Broadcom NSP SoC. Based on iproc-common and the SoC specific reset function. Signed-off-by: Scott Branden sbran...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- arch/arm/cpu/armv7/bcmnsp/Makefile | 7 +++ arch/arm/cpu/armv7/bcmnsp/reset.c | 19 +++ 2 files changed, 26 insertions(+) create mode 100644 arch/arm/cpu/armv7/bcmnsp/Makefile create mode 100644 arch/arm/cpu/armv7/bcmnsp/reset.c diff --git a/arch/arm/cpu/armv7/bcmnsp/Makefile b/arch/arm/cpu/armv7/bcmnsp/Makefile new file mode 100644 index 000..04afcf9 --- /dev/null +++ b/arch/arm/cpu/armv7/bcmnsp/Makefile @@ -0,0 +1,7 @@ +# +# Copyright 2014 Broadcom Corporation. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += reset.o diff --git a/arch/arm/cpu/armv7/bcmnsp/reset.c b/arch/arm/cpu/armv7/bcmnsp/reset.c new file mode 100644 index 000..d79d9aa --- /dev/null +++ b/arch/arm/cpu/armv7/bcmnsp/reset.c @@ -0,0 +1,19 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h + +#define CRU_RESET_OFFSET 0x1803F184 + +void reset_cpu(ulong ignored) +{ + /* Reset the cpu by setting software reset request bit */ + writel(0x1, CRU_RESET_OFFSET); + + while (1) + ; /* loop forever till reset */ +} -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 1/4] arm: iproc: Initial commit of iproc architecture code
From: Scott Branden sbran...@broadcom.com The iproc architecture code is present in several Broadcom chip architectures, including Cygnus and NSP. Signed-off-by: Scott Branden sbran...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- arch/arm/cpu/armv7/Makefile | 1 + arch/arm/cpu/armv7/iproc-common/Makefile| 9 ++ arch/arm/cpu/armv7/iproc-common/armpll.c| 170 arch/arm/cpu/armv7/iproc-common/hwinit-common.c | 16 +++ arch/arm/cpu/armv7/iproc-common/timer.c | 130 ++ arch/arm/include/asm/iproc-common/armpll.h | 14 ++ arch/arm/include/asm/iproc-common/sysmap.h | 47 +++ arch/arm/include/asm/iproc-common/timer.h | 37 ++ 8 files changed, 424 insertions(+) create mode 100644 arch/arm/cpu/armv7/iproc-common/Makefile create mode 100644 arch/arm/cpu/armv7/iproc-common/armpll.c create mode 100644 arch/arm/cpu/armv7/iproc-common/hwinit-common.c create mode 100644 arch/arm/cpu/armv7/iproc-common/timer.c create mode 100644 arch/arm/include/asm/iproc-common/armpll.h create mode 100644 arch/arm/include/asm/iproc-common/sysmap.h create mode 100644 arch/arm/include/asm/iproc-common/timer.h diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile index 232118d..d0cab8d 100644 --- a/arch/arm/cpu/armv7/Makefile +++ b/arch/arm/cpu/armv7/Makefile @@ -23,6 +23,7 @@ obj-y += nonsec_virt.o obj-y += virt-v7.o endif +obj-$(CONFIG_IPROC) += iproc-common/ obj-$(CONFIG_KONA) += kona-common/ obj-$(CONFIG_OMAP_COMMON) += omap-common/ obj-$(CONFIG_SYS_ARCH_TIMER) += arch_timer.o diff --git a/arch/arm/cpu/armv7/iproc-common/Makefile b/arch/arm/cpu/armv7/iproc-common/Makefile new file mode 100644 index 000..c071a17 --- /dev/null +++ b/arch/arm/cpu/armv7/iproc-common/Makefile @@ -0,0 +1,9 @@ +# +# Copyright 2014 Broadcom Corporation. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += armpll.o +obj-y += hwinit-common.o +obj-y += timer.o diff --git a/arch/arm/cpu/armv7/iproc-common/armpll.c b/arch/arm/cpu/armv7/iproc-common/armpll.c new file mode 100644 index 000..49b61bf --- /dev/null +++ b/arch/arm/cpu/armv7/iproc-common/armpll.c @@ -0,0 +1,170 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h +#include asm/iproc-common/armpll.h +#include asm/iproc-common/sysmap.h + +#define NELEMS(x) (sizeof(x) / sizeof(x[0])) + +struct armpll_parameters { + unsigned int mode; + unsigned int ndiv_int; + unsigned int ndiv_frac; + unsigned int pdiv; + unsigned int freqid; +}; + +struct armpll_parameters armpll_clk_tab[] = { + { 25, 64, 1, 1, 0}, + { 100, 64, 1, 1, 2}, + { 400, 64, 1, 1, 6}, + { 448, 71, 713050, 1, 6}, + { 500, 80, 1, 1, 6}, + { 560, 89, 629145, 1, 6}, + { 600, 96, 1, 1, 6}, + { 800, 64, 1, 1, 7}, + { 896, 71, 713050, 1, 7}, + { 1000, 80, 1, 1, 7}, + { 1100, 88, 1, 1, 7}, + { 1120, 89, 629145, 1, 7}, + { 1200, 96, 1, 1, 7}, +}; + +uint32_t armpll_config(uint32_t clkmhz) +{ + uint32_t freqid; + uint32_t ndiv_frac; + uint32_t pll; + uint32_t status = 1; + uint32_t timeout_countdown; + int i; + + for (i = 0; i NELEMS(armpll_clk_tab); i++) { + if (armpll_clk_tab[i].mode == clkmhz) { + status = 0; + break; + } + } + + if (status) { + printf(Error: Clock configuration not supported\n); + goto armpll_config_done; + } + + /* Enable write access */ + writel(IPROC_REG_WRITE_ACCESS, IHOST_PROC_CLK_WR_ACCESS); + + if (clkmhz == 25) + freqid = 0; + else + freqid = 2; + + /* Bypass ARM clock and run on sysclk */ + writel(1 IHOST_PROC_CLK_POLICY_FREQ__PRIV_ACCESS_MODE | + freqid IHOST_PROC_CLK_POLICY_FREQ__POLICY3_FREQ_R | + freqid IHOST_PROC_CLK_POLICY_FREQ__POLICY2_FREQ_R | + freqid IHOST_PROC_CLK_POLICY_FREQ__POLICY1_FREQ_R | + freqid IHOST_PROC_CLK_POLICY_FREQ__POLICY0_FREQ_R, + IHOST_PROC_CLK_POLICY_FREQ); + + writel(1 IHOST_PROC_CLK_POLICY_CTL__GO | + 1 IHOST_PROC_CLK_POLICY_CTL__GO_AC, + IHOST_PROC_CLK_POLICY_CTL); + + /* Poll CCU until operation complete */ + timeout_countdown = 0x10; + while (readl(IHOST_PROC_CLK_POLICY_CTL) + (1 IHOST_PROC_CLK_POLICY_CTL__GO)) { + timeout_countdown--; + if (timeout_countdown == 0) { + printf(CCU polling timedout\n); + status = 1; + goto armpll_config_done; + } + } + + if (clkmhz == 25 || clkmhz == 100
[U-Boot] [PATCH 2/4] arm: bcmcygnus: Add bcmcygnus u-architecture
From: Scott Branden sbran...@broadcom.com Base support for the Broadcom Cygnus SoC. Based on iproc-common and the SoC specific reset function. Signed-off-by: Scott Branden sbran...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- arch/arm/cpu/armv7/bcmcygnus/Makefile | 7 +++ arch/arm/cpu/armv7/bcmcygnus/reset.c | 20 2 files changed, 27 insertions(+) create mode 100644 arch/arm/cpu/armv7/bcmcygnus/Makefile create mode 100644 arch/arm/cpu/armv7/bcmcygnus/reset.c diff --git a/arch/arm/cpu/armv7/bcmcygnus/Makefile b/arch/arm/cpu/armv7/bcmcygnus/Makefile new file mode 100644 index 000..04afcf9 --- /dev/null +++ b/arch/arm/cpu/armv7/bcmcygnus/Makefile @@ -0,0 +1,7 @@ +# +# Copyright 2014 Broadcom Corporation. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += reset.o diff --git a/arch/arm/cpu/armv7/bcmcygnus/reset.c b/arch/arm/cpu/armv7/bcmcygnus/reset.c new file mode 100644 index 000..53ecc0c --- /dev/null +++ b/arch/arm/cpu/armv7/bcmcygnus/reset.c @@ -0,0 +1,20 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h + +#define CRMU_MAIL_BOX1 0x03024028 +#define CRMU_SOFT_RESET_CMD0x + +void reset_cpu(ulong ignored) +{ + /* Send soft reset command via Mailbox. */ + writel(CRMU_SOFT_RESET_CMD, CRMU_MAIL_BOX1); + + while (1) + ; /* loop forever till reset */ +} -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 4/4] arm: add Cygnus and NSP boards
From: Scott Branden sbran...@broadcom.com The bcm_ep board configuration is used by a number of boards including Cygnus and NSP. Add builds for the bcm958300k and the bcm958622hr boards. Signed-off-by: Scott Branden sbran...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- arch/arm/include/asm/arch-bcmcygnus/configs.h | 25 ++ arch/arm/include/asm/arch-bcmnsp/configs.h| 22 + arch/arm/include/asm/iproc-common/configs.h | 20 + board/broadcom/bcm_ep/Makefile| 7 ++ board/broadcom/bcm_ep/board.c | 62 ++ boards.cfg| 2 + include/configs/bcm_ep_board.h| 111 ++ 7 files changed, 249 insertions(+) create mode 100644 arch/arm/include/asm/arch-bcmcygnus/configs.h create mode 100644 arch/arm/include/asm/arch-bcmnsp/configs.h create mode 100644 arch/arm/include/asm/iproc-common/configs.h create mode 100644 board/broadcom/bcm_ep/Makefile create mode 100644 board/broadcom/bcm_ep/board.c create mode 100644 include/configs/bcm_ep_board.h diff --git a/arch/arm/include/asm/arch-bcmcygnus/configs.h b/arch/arm/include/asm/arch-bcmcygnus/configs.h new file mode 100644 index 000..5354637 --- /dev/null +++ b/arch/arm/include/asm/arch-bcmcygnus/configs.h @@ -0,0 +1,25 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef __ARCH_CONFIGS_H +#define __ARCH_CONFIGS_H + +#include asm/iproc-common/configs.h + +/* uArchitecture specifics */ + +/* Serial Info */ +/* Post pad 3 bytes after each reg addr */ +#define CONFIG_SYS_NS16550_REG_SIZE(-4) +#define CONFIG_SYS_NS16550_MEM32 + +#define CONFIG_SYS_NS16550_CLK 1 +#define CONFIG_SYS_NS16550_CLK_DIV 54 +#define CONFIG_SERIAL_MULTI +#define CONFIG_CONS_INDEX 3 +#define CONFIG_SYS_NS16550_COM30x18023000 + +#endif /* __ARCH_CONFIGS_H */ diff --git a/arch/arm/include/asm/arch-bcmnsp/configs.h b/arch/arm/include/asm/arch-bcmnsp/configs.h new file mode 100644 index 000..786deae --- /dev/null +++ b/arch/arm/include/asm/arch-bcmnsp/configs.h @@ -0,0 +1,22 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef __ARCH_CONFIGS_H +#define __ARCH_CONFIGS_H + +#include asm/iproc-common/configs.h + +/* uArchitecture specifics */ + +/* Serial Info */ +/* no padding */ +#define CONFIG_SYS_NS16550_REG_SIZE1 + +#define CONFIG_SYS_NS16550_CLK 0x03b9aca0 +#define CONFIG_CONS_INDEX 1 +#define CONFIG_SYS_NS16550_COM10x18000300 + +#endif /* __ARCH_CONFIGS_H */ diff --git a/arch/arm/include/asm/iproc-common/configs.h b/arch/arm/include/asm/iproc-common/configs.h new file mode 100644 index 000..c24de1f --- /dev/null +++ b/arch/arm/include/asm/iproc-common/configs.h @@ -0,0 +1,20 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef __IPROC_COMMON_CONFIGS_H +#define __IPROC_COMMON_CONFIGS_H + +#include linux/stringify.h + +/* Architecture, CPU, chip, etc */ +#define CONFIG_IPROC +#define CONFIG_SYS_ARM_CACHE_WRITETHROUGH + +/* Memory Info */ +#define CONFIG_SYS_TEXT_BASE 0x6100 +#define CONFIG_SYS_SDRAM_BASE 0x6100 + +#endif /* __IPROC_COMMON_CONFIGS_H */ diff --git a/board/broadcom/bcm_ep/Makefile b/board/broadcom/bcm_ep/Makefile new file mode 100644 index 000..8914e54 --- /dev/null +++ b/board/broadcom/bcm_ep/Makefile @@ -0,0 +1,7 @@ +# +# Copyright 2014 Broadcom Corporation. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += board.o diff --git a/board/broadcom/bcm_ep/board.c b/board/broadcom/bcm_ep/board.c new file mode 100644 index 000..df17f72 --- /dev/null +++ b/board/broadcom/bcm_ep/board.c @@ -0,0 +1,62 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h +#include config.h +#include asm/system.h +#include asm/iproc-common/armpll.h + +DECLARE_GLOBAL_DATA_PTR; + +/* + * board_init - early hardware init + */ +int board_init(void) +{ + /* Address of boot parameters passed to kernel +* Use default offset 0x100 +*/ + gd-bd-bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; + + return 0; +} + +/* + * misc_init_r - miscellaneous platform dependent initializations + */ +int misc_init_r(void) +{ + return 0; +} + +/* + * dram_init - sets u-boot's idea of sdram size + */ +int dram_init(void) +{ + gd-ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, + CONFIG_SYS_SDRAM_SIZE); + return 0; +} + +void dram_init_banksize(void) +{ + gd-bd-bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; + gd-bd-bi_dram[0].size = gd-ram_size; +} + +int board_early_init_f(void) +{ + uint32_t status = 0; + + /* Setup PLL if required */ +#if defined(CONFIG_ARMCLK
Re: [U-Boot] [PATCH 4/4] arm: add Cygnus and NSP boards
On 14-07-20 12:54 AM, Wolfgang Denk wrote: Dear Steve Rae, In message 1405733854-20194-5-git-send-email-s...@broadcom.com you wrote: The bcm_ep board configuration is used by a number of boards including Cygnus and NSP. Add builds for the bcm958300k and the bcm958622hr boards. ... +/* uArchitecture specifics */ ... +#define CONFIG_CONS_INDEX 3 +#define CONFIG_SYS_NS16550_COM30x18023000 Is the console inex really architecture specific and identical for all boards based on this? I would expect to find this in the board config header. Yes -- the bootrom code always uses 3 for this architecture +/* uArchitecture specifics */ ... +#define CONFIG_CONS_INDEX 1 +#define CONFIG_SYS_NS16550_COM10x18000300 Ditto here. Ditto -- the bootrom code always uses 1 for this architecture ... + /* Address of boot parameters passed to kernel +* Use default offset 0x100 +*/ Incorrect multiline comment style. Please check (and fix, if needed) globally. will fix in [v2] +/* + * misc_init_r - miscellaneous platform dependent initializations + */ +int misc_init_r(void) +{ + return 0; +} It makes no sense to add an empty function here. Just do not define CONFIG_MISC_INIT_R will fix in [v2] +#define CONFIG_SYS_MALLOC_LEN SZ_4M /* see armv7/start.S. */ +#define CONFIG_STACKSIZE SZ_256K Please do not use the SZ_ defines. They are deprecated. will fix in [v2] +/* Init functions */ +#define CONFIG_MISC_INIT_R /* board's misc_init_r function */ Unused, so remove. will fix in [v2] +#define CONFIG_ENV_SIZE0x1 Do you really, really need 64 kB of environmnt? I doubt that. will fix in [v2] Best regards, Wolfgang Denk ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/4] arm: iproc: Initial commit of iproc architecture code
On 14-07-20 12:46 AM, Wolfgang Denk wrote: Dear Steve Rae, In message 1405733854-20194-2-git-send-email-s...@broadcom.com you wrote: From: Scott Branden sbran...@broadcom.com The iproc architecture code is present in several Broadcom chip architectures, including Cygnus and NSP. ... + writel(IPROC_CLKCT_HDELAY_SW_EN, IHOST_PROC_CLK_CORE0_CLKGATE); + writel(IPROC_CLKCT_HDELAY_SW_EN, IHOST_PROC_CLK_CORE1_CLKGATE); + writel(IPROC_CLKCT_HDELAY_SW_EN, IHOST_PROC_CLK_ARM_SWITCH_CLKGATE); + writel(IPROC_CLKCT_HDELAY_SW_EN, IHOST_PROC_CLK_ARM_PERIPH_CLKGATE); + writel(IPROC_CLKCT_HDELAY_SW_EN, IHOST_PROC_CLK_APB0_CLKGATE); Instead of using #defines for IHOST_PROC_CLK_CORE0_CLKGATE etc. it would be better to use a C struct to describe the register map. In our situation, the register map is an automatically generated list of #defines (which actually comes directly from another department within the company)... It might be better to use a C struct, but to be able to use this generated file is more accurate. + count_h = readl(IPROC_PERIPH_GLB_TIM_REG_BASE + + TIMER_GLB_HI_OFFSET); + count_l = readl(IPROC_PERIPH_GLB_TIM_REG_BASE + + TIMER_GLB_LOW_OFFSET); + cur_tick = readl(IPROC_PERIPH_GLB_TIM_REG_BASE + +TIMER_GLB_HI_OFFSET); NAK. We do not support accessing device registers through a base address + offset notation. Please use a C struct instead. Please clarify -- does the readl() (and writel()) have issues with this base + offset notation? We have used this extensively (in the non-upstreamed code), and we would like to upstream this. ( ...looking at the existing U-Boot code, this notation is used elsewhere... ) Please fix globally. ... +#define IHOST_PROC_CLK_WR_ACCESS 0X1900 +#define IHOST_PROC_CLK_POLICY_FREQ 0X1908 ... +#define IHOST_PROC_CLK_POLICY_CTL 0X190C ... Make C struct? (automatically generated code) +/* ARM A9 Private Timer */ +#define TIMER_PVT_LOAD_OFFSET 0x +#define TIMER_PVT_COUNTER_OFFSET 0x0004 +#define TIMER_PVT_CTRL_OFFSET 0x0008 +#define TIMER_PVT_STATUS_OFFSET0x000C ... +#define TIMER_GLB_LOW_OFFSET 0x +#define TIMER_GLB_HI_OFFSET0x0004 +#define TIMER_GLB_CTRL_OFFSET 0x0008 Please make C struct !!! (automatically generated code) Best regards, Wolfgang Denk ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 0/4] Introducing the Broadcom Cygnus and NSP boards.
This series adds the bcm958300k and the bcm958622hr boards which share the iproc architecture code. Changes in v2: - remove unused include file - reformat multi-line comment(s) - remove deprecated SZ_ definitions - remove misc_init_r() - update CONFIG_ENV_SIZE Scott Branden (4): arm: iproc: Initial commit of iproc architecture code arm: bcmcygnus: Add bcmcygnus u-architecture arm: bcmnsp: Add bcmnsp u-architecture arm: add Cygnus and NSP boards arch/arm/cpu/armv7/Makefile | 1 + arch/arm/cpu/armv7/bcmcygnus/Makefile | 7 + arch/arm/cpu/armv7/bcmcygnus/reset.c| 20 +++ arch/arm/cpu/armv7/bcmnsp/Makefile | 7 + arch/arm/cpu/armv7/bcmnsp/reset.c | 19 +++ arch/arm/cpu/armv7/iproc-common/Makefile| 9 ++ arch/arm/cpu/armv7/iproc-common/armpll.c| 170 arch/arm/cpu/armv7/iproc-common/hwinit-common.c | 15 +++ arch/arm/cpu/armv7/iproc-common/timer.c | 130 ++ arch/arm/include/asm/arch-bcmcygnus/configs.h | 25 arch/arm/include/asm/arch-bcmnsp/configs.h | 22 +++ arch/arm/include/asm/iproc-common/armpll.h | 14 ++ arch/arm/include/asm/iproc-common/configs.h | 20 +++ arch/arm/include/asm/iproc-common/sysmap.h | 47 +++ arch/arm/include/asm/iproc-common/timer.h | 37 ++ board/broadcom/bcm_ep/Makefile | 7 + board/broadcom/bcm_ep/board.c | 55 boards.cfg | 2 + include/configs/bcm_ep_board.h | 107 +++ 19 files changed, 714 insertions(+) create mode 100644 arch/arm/cpu/armv7/bcmcygnus/Makefile create mode 100644 arch/arm/cpu/armv7/bcmcygnus/reset.c create mode 100644 arch/arm/cpu/armv7/bcmnsp/Makefile create mode 100644 arch/arm/cpu/armv7/bcmnsp/reset.c create mode 100644 arch/arm/cpu/armv7/iproc-common/Makefile create mode 100644 arch/arm/cpu/armv7/iproc-common/armpll.c create mode 100644 arch/arm/cpu/armv7/iproc-common/hwinit-common.c create mode 100644 arch/arm/cpu/armv7/iproc-common/timer.c create mode 100644 arch/arm/include/asm/arch-bcmcygnus/configs.h create mode 100644 arch/arm/include/asm/arch-bcmnsp/configs.h create mode 100644 arch/arm/include/asm/iproc-common/armpll.h create mode 100644 arch/arm/include/asm/iproc-common/configs.h create mode 100644 arch/arm/include/asm/iproc-common/sysmap.h create mode 100644 arch/arm/include/asm/iproc-common/timer.h create mode 100644 board/broadcom/bcm_ep/Makefile create mode 100644 board/broadcom/bcm_ep/board.c create mode 100644 include/configs/bcm_ep_board.h -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 1/4] arm: iproc: Initial commit of iproc architecture code
From: Scott Branden sbran...@broadcom.com The iproc architecture code is present in several Broadcom chip architectures, including Cygnus and NSP. Signed-off-by: Scott Branden sbran...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v2: - remove unused include file arch/arm/cpu/armv7/Makefile | 1 + arch/arm/cpu/armv7/iproc-common/Makefile| 9 ++ arch/arm/cpu/armv7/iproc-common/armpll.c| 170 arch/arm/cpu/armv7/iproc-common/hwinit-common.c | 15 +++ arch/arm/cpu/armv7/iproc-common/timer.c | 130 ++ arch/arm/include/asm/iproc-common/armpll.h | 14 ++ arch/arm/include/asm/iproc-common/sysmap.h | 47 +++ arch/arm/include/asm/iproc-common/timer.h | 37 ++ 8 files changed, 423 insertions(+) create mode 100644 arch/arm/cpu/armv7/iproc-common/Makefile create mode 100644 arch/arm/cpu/armv7/iproc-common/armpll.c create mode 100644 arch/arm/cpu/armv7/iproc-common/hwinit-common.c create mode 100644 arch/arm/cpu/armv7/iproc-common/timer.c create mode 100644 arch/arm/include/asm/iproc-common/armpll.h create mode 100644 arch/arm/include/asm/iproc-common/sysmap.h create mode 100644 arch/arm/include/asm/iproc-common/timer.h diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile index 232118d..d0cab8d 100644 --- a/arch/arm/cpu/armv7/Makefile +++ b/arch/arm/cpu/armv7/Makefile @@ -23,6 +23,7 @@ obj-y += nonsec_virt.o obj-y += virt-v7.o endif +obj-$(CONFIG_IPROC) += iproc-common/ obj-$(CONFIG_KONA) += kona-common/ obj-$(CONFIG_OMAP_COMMON) += omap-common/ obj-$(CONFIG_SYS_ARCH_TIMER) += arch_timer.o diff --git a/arch/arm/cpu/armv7/iproc-common/Makefile b/arch/arm/cpu/armv7/iproc-common/Makefile new file mode 100644 index 000..c071a17 --- /dev/null +++ b/arch/arm/cpu/armv7/iproc-common/Makefile @@ -0,0 +1,9 @@ +# +# Copyright 2014 Broadcom Corporation. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += armpll.o +obj-y += hwinit-common.o +obj-y += timer.o diff --git a/arch/arm/cpu/armv7/iproc-common/armpll.c b/arch/arm/cpu/armv7/iproc-common/armpll.c new file mode 100644 index 000..49b61bf --- /dev/null +++ b/arch/arm/cpu/armv7/iproc-common/armpll.c @@ -0,0 +1,170 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h +#include asm/iproc-common/armpll.h +#include asm/iproc-common/sysmap.h + +#define NELEMS(x) (sizeof(x) / sizeof(x[0])) + +struct armpll_parameters { + unsigned int mode; + unsigned int ndiv_int; + unsigned int ndiv_frac; + unsigned int pdiv; + unsigned int freqid; +}; + +struct armpll_parameters armpll_clk_tab[] = { + { 25, 64, 1, 1, 0}, + { 100, 64, 1, 1, 2}, + { 400, 64, 1, 1, 6}, + { 448, 71, 713050, 1, 6}, + { 500, 80, 1, 1, 6}, + { 560, 89, 629145, 1, 6}, + { 600, 96, 1, 1, 6}, + { 800, 64, 1, 1, 7}, + { 896, 71, 713050, 1, 7}, + { 1000, 80, 1, 1, 7}, + { 1100, 88, 1, 1, 7}, + { 1120, 89, 629145, 1, 7}, + { 1200, 96, 1, 1, 7}, +}; + +uint32_t armpll_config(uint32_t clkmhz) +{ + uint32_t freqid; + uint32_t ndiv_frac; + uint32_t pll; + uint32_t status = 1; + uint32_t timeout_countdown; + int i; + + for (i = 0; i NELEMS(armpll_clk_tab); i++) { + if (armpll_clk_tab[i].mode == clkmhz) { + status = 0; + break; + } + } + + if (status) { + printf(Error: Clock configuration not supported\n); + goto armpll_config_done; + } + + /* Enable write access */ + writel(IPROC_REG_WRITE_ACCESS, IHOST_PROC_CLK_WR_ACCESS); + + if (clkmhz == 25) + freqid = 0; + else + freqid = 2; + + /* Bypass ARM clock and run on sysclk */ + writel(1 IHOST_PROC_CLK_POLICY_FREQ__PRIV_ACCESS_MODE | + freqid IHOST_PROC_CLK_POLICY_FREQ__POLICY3_FREQ_R | + freqid IHOST_PROC_CLK_POLICY_FREQ__POLICY2_FREQ_R | + freqid IHOST_PROC_CLK_POLICY_FREQ__POLICY1_FREQ_R | + freqid IHOST_PROC_CLK_POLICY_FREQ__POLICY0_FREQ_R, + IHOST_PROC_CLK_POLICY_FREQ); + + writel(1 IHOST_PROC_CLK_POLICY_CTL__GO | + 1 IHOST_PROC_CLK_POLICY_CTL__GO_AC, + IHOST_PROC_CLK_POLICY_CTL); + + /* Poll CCU until operation complete */ + timeout_countdown = 0x10; + while (readl(IHOST_PROC_CLK_POLICY_CTL) + (1 IHOST_PROC_CLK_POLICY_CTL__GO)) { + timeout_countdown--; + if (timeout_countdown == 0) { + printf(CCU polling timedout\n); + status = 1; + goto armpll_config_done
[U-Boot] [PATCH v2 2/4] arm: bcmcygnus: Add bcmcygnus u-architecture
From: Scott Branden sbran...@broadcom.com Base support for the Broadcom Cygnus SoC. Based on iproc-common and the SoC specific reset function. Signed-off-by: Scott Branden sbran...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v2: None arch/arm/cpu/armv7/bcmcygnus/Makefile | 7 +++ arch/arm/cpu/armv7/bcmcygnus/reset.c | 20 2 files changed, 27 insertions(+) create mode 100644 arch/arm/cpu/armv7/bcmcygnus/Makefile create mode 100644 arch/arm/cpu/armv7/bcmcygnus/reset.c diff --git a/arch/arm/cpu/armv7/bcmcygnus/Makefile b/arch/arm/cpu/armv7/bcmcygnus/Makefile new file mode 100644 index 000..04afcf9 --- /dev/null +++ b/arch/arm/cpu/armv7/bcmcygnus/Makefile @@ -0,0 +1,7 @@ +# +# Copyright 2014 Broadcom Corporation. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += reset.o diff --git a/arch/arm/cpu/armv7/bcmcygnus/reset.c b/arch/arm/cpu/armv7/bcmcygnus/reset.c new file mode 100644 index 000..53ecc0c --- /dev/null +++ b/arch/arm/cpu/armv7/bcmcygnus/reset.c @@ -0,0 +1,20 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h + +#define CRMU_MAIL_BOX1 0x03024028 +#define CRMU_SOFT_RESET_CMD0x + +void reset_cpu(ulong ignored) +{ + /* Send soft reset command via Mailbox. */ + writel(CRMU_SOFT_RESET_CMD, CRMU_MAIL_BOX1); + + while (1) + ; /* loop forever till reset */ +} -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 3/4] arm: bcmnsp: Add bcmnsp u-architecture
From: Scott Branden sbran...@broadcom.com Base support for the Broadcom NSP SoC. Based on iproc-common and the SoC specific reset function. Signed-off-by: Scott Branden sbran...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v2: None arch/arm/cpu/armv7/bcmnsp/Makefile | 7 +++ arch/arm/cpu/armv7/bcmnsp/reset.c | 19 +++ 2 files changed, 26 insertions(+) create mode 100644 arch/arm/cpu/armv7/bcmnsp/Makefile create mode 100644 arch/arm/cpu/armv7/bcmnsp/reset.c diff --git a/arch/arm/cpu/armv7/bcmnsp/Makefile b/arch/arm/cpu/armv7/bcmnsp/Makefile new file mode 100644 index 000..04afcf9 --- /dev/null +++ b/arch/arm/cpu/armv7/bcmnsp/Makefile @@ -0,0 +1,7 @@ +# +# Copyright 2014 Broadcom Corporation. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += reset.o diff --git a/arch/arm/cpu/armv7/bcmnsp/reset.c b/arch/arm/cpu/armv7/bcmnsp/reset.c new file mode 100644 index 000..d79d9aa --- /dev/null +++ b/arch/arm/cpu/armv7/bcmnsp/reset.c @@ -0,0 +1,19 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h + +#define CRU_RESET_OFFSET 0x1803F184 + +void reset_cpu(ulong ignored) +{ + /* Reset the cpu by setting software reset request bit */ + writel(0x1, CRU_RESET_OFFSET); + + while (1) + ; /* loop forever till reset */ +} -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 4/4] arm: add Cygnus and NSP boards
From: Scott Branden sbran...@broadcom.com The bcm_ep board configuration is used by a number of boards including Cygnus and NSP. Add builds for the bcm958300k and the bcm958622hr boards. Signed-off-by: Scott Branden sbran...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v2: - reformat multi-line comment(s) - remove deprecated SZ_ definitions - remove misc_init_r() - update CONFIG_ENV_SIZE arch/arm/include/asm/arch-bcmcygnus/configs.h | 25 ++ arch/arm/include/asm/arch-bcmnsp/configs.h| 22 ++ arch/arm/include/asm/iproc-common/configs.h | 20 + board/broadcom/bcm_ep/Makefile| 7 ++ board/broadcom/bcm_ep/board.c | 55 + boards.cfg| 2 + include/configs/bcm_ep_board.h| 107 ++ 7 files changed, 238 insertions(+) create mode 100644 arch/arm/include/asm/arch-bcmcygnus/configs.h create mode 100644 arch/arm/include/asm/arch-bcmnsp/configs.h create mode 100644 arch/arm/include/asm/iproc-common/configs.h create mode 100644 board/broadcom/bcm_ep/Makefile create mode 100644 board/broadcom/bcm_ep/board.c create mode 100644 include/configs/bcm_ep_board.h diff --git a/arch/arm/include/asm/arch-bcmcygnus/configs.h b/arch/arm/include/asm/arch-bcmcygnus/configs.h new file mode 100644 index 000..5354637 --- /dev/null +++ b/arch/arm/include/asm/arch-bcmcygnus/configs.h @@ -0,0 +1,25 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef __ARCH_CONFIGS_H +#define __ARCH_CONFIGS_H + +#include asm/iproc-common/configs.h + +/* uArchitecture specifics */ + +/* Serial Info */ +/* Post pad 3 bytes after each reg addr */ +#define CONFIG_SYS_NS16550_REG_SIZE(-4) +#define CONFIG_SYS_NS16550_MEM32 + +#define CONFIG_SYS_NS16550_CLK 1 +#define CONFIG_SYS_NS16550_CLK_DIV 54 +#define CONFIG_SERIAL_MULTI +#define CONFIG_CONS_INDEX 3 +#define CONFIG_SYS_NS16550_COM30x18023000 + +#endif /* __ARCH_CONFIGS_H */ diff --git a/arch/arm/include/asm/arch-bcmnsp/configs.h b/arch/arm/include/asm/arch-bcmnsp/configs.h new file mode 100644 index 000..786deae --- /dev/null +++ b/arch/arm/include/asm/arch-bcmnsp/configs.h @@ -0,0 +1,22 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef __ARCH_CONFIGS_H +#define __ARCH_CONFIGS_H + +#include asm/iproc-common/configs.h + +/* uArchitecture specifics */ + +/* Serial Info */ +/* no padding */ +#define CONFIG_SYS_NS16550_REG_SIZE1 + +#define CONFIG_SYS_NS16550_CLK 0x03b9aca0 +#define CONFIG_CONS_INDEX 1 +#define CONFIG_SYS_NS16550_COM10x18000300 + +#endif /* __ARCH_CONFIGS_H */ diff --git a/arch/arm/include/asm/iproc-common/configs.h b/arch/arm/include/asm/iproc-common/configs.h new file mode 100644 index 000..c24de1f --- /dev/null +++ b/arch/arm/include/asm/iproc-common/configs.h @@ -0,0 +1,20 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef __IPROC_COMMON_CONFIGS_H +#define __IPROC_COMMON_CONFIGS_H + +#include linux/stringify.h + +/* Architecture, CPU, chip, etc */ +#define CONFIG_IPROC +#define CONFIG_SYS_ARM_CACHE_WRITETHROUGH + +/* Memory Info */ +#define CONFIG_SYS_TEXT_BASE 0x6100 +#define CONFIG_SYS_SDRAM_BASE 0x6100 + +#endif /* __IPROC_COMMON_CONFIGS_H */ diff --git a/board/broadcom/bcm_ep/Makefile b/board/broadcom/bcm_ep/Makefile new file mode 100644 index 000..8914e54 --- /dev/null +++ b/board/broadcom/bcm_ep/Makefile @@ -0,0 +1,7 @@ +# +# Copyright 2014 Broadcom Corporation. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += board.o diff --git a/board/broadcom/bcm_ep/board.c b/board/broadcom/bcm_ep/board.c new file mode 100644 index 000..e48cd3f --- /dev/null +++ b/board/broadcom/bcm_ep/board.c @@ -0,0 +1,55 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h +#include config.h +#include asm/system.h +#include asm/iproc-common/armpll.h + +DECLARE_GLOBAL_DATA_PTR; + +/* + * board_init - early hardware init + */ +int board_init(void) +{ + /* +* Address of boot parameters passed to kernel +* Use default offset 0x100 +*/ + gd-bd-bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; + + return 0; +} + +/* + * dram_init - sets u-boot's idea of sdram size + */ +int dram_init(void) +{ + gd-ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, + CONFIG_SYS_SDRAM_SIZE); + return 0; +} + +void dram_init_banksize(void) +{ + gd-bd-bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; + gd-bd-bi_dram[0].size = gd-ram_size; +} + +int board_early_init_f(void) +{ + uint32_t status = 0; + + /* Setup PLL if required */ +#if defined
[U-Boot] [PATCH] arm: bcm281xx: Add Ethernet Clock support
From: Jiandong Zheng jdzh...@broadcom.com Enable Ethernet clock when Broadcom StarFighter2 Ethernet block (CONFIG_BCM_SF2_ETH) is enabled. Signed-off-by: Jiandong Zheng jdzh...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- - added board with this feature enabled arch/arm/cpu/armv7/bcm281xx/Makefile| 1 + arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c | 34 +++ arch/arm/cpu/armv7/bcm281xx/clk-eth.c | 143 arch/arm/include/asm/arch-bcm281xx/sysmap.h | 3 + boards.cfg | 1 + 5 files changed, 182 insertions(+) create mode 100644 arch/arm/cpu/armv7/bcm281xx/clk-eth.c diff --git a/arch/arm/cpu/armv7/bcm281xx/Makefile b/arch/arm/cpu/armv7/bcm281xx/Makefile index 98f5aa5..bd867a2 100644 --- a/arch/arm/cpu/armv7/bcm281xx/Makefile +++ b/arch/arm/cpu/armv7/bcm281xx/Makefile @@ -9,3 +9,4 @@ obj-y += clk-core.o obj-y += clk-bcm281xx.o obj-y += clk-sdio.o obj-y += clk-bsc.o +obj-$(CONFIG_BCM_SF2_ETH) += clk-eth.o diff --git a/arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c b/arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c index bc8a170..d16b99f 100644 --- a/arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c +++ b/arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c @@ -118,6 +118,16 @@ unsigned long slave_apb_freq_tbl[8] = { 78 * CLOCK_1M }; +unsigned long esub_freq_tbl[8] = { + 78 * CLOCK_1M, + 156 * CLOCK_1M, + 156 * CLOCK_1M, + 156 * CLOCK_1M, + 208 * CLOCK_1M, + 208 * CLOCK_1M, + 208 * CLOCK_1M +}; + static struct bus_clk_data bsc1_apb_data = { .gate = HW_SW_GATE_AUTO(0x0458, 16, 0, 1), }; @@ -295,6 +305,27 @@ static struct ccu_clock kps_ccu_clk = { .freq_tbl = slave_axi_freq_tbl, }; +#ifdef CONFIG_BCM_SF2_ETH +static struct ccu_clock esub_ccu_clk = { + .clk = { + .name = esub_ccu_clk, + .ops = ccu_clk_ops, + .ccu_clk_mgr_base = ESUB_CLK_BASE_ADDR, + }, + .num_policy_masks = 1, + .policy_freq_offset = 0x0008, + .freq_bit_shift = 8, + .policy_ctl_offset = 0x000c, + .policy0_mask_offset = 0x0010, + .policy1_mask_offset = 0x0014, + .policy2_mask_offset = 0x0018, + .policy3_mask_offset = 0x001c, + .lvm_en_offset = 0x0034, + .freq_id = 2, + .freq_tbl = esub_freq_tbl, +}; +#endif + /* * Bus clocks */ @@ -517,6 +548,9 @@ struct clk_lookup arch_clk_tbl[] = { CLK_LK(bsc1_apb), CLK_LK(bsc2_apb), CLK_LK(bsc3_apb), +#ifdef CONFIG_BCM_SF2_ETH + CLK_LK(esub_ccu), +#endif }; /* public array size */ diff --git a/arch/arm/cpu/armv7/bcm281xx/clk-eth.c b/arch/arm/cpu/armv7/bcm281xx/clk-eth.c new file mode 100644 index 000..b0b92b9 --- /dev/null +++ b/arch/arm/cpu/armv7/bcm281xx/clk-eth.c @@ -0,0 +1,143 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h +#include asm/errno.h +#include asm/arch/sysmap.h +#include asm/kona-common/clk.h +#include clk-core.h + +#define WR_ACCESS_ADDR ESUB_CLK_BASE_ADDR +#define WR_ACCESS_PASSWORD 0xA5A500 + +#define PLLE_POST_RESETB_ADDR (ESUB_CLK_BASE_ADDR + 0x0C00) + +#define PLLE_RESETB_ADDR (ESUB_CLK_BASE_ADDR + 0x0C58) +#define PLLE_RESETB_I_PLL_RESETB_PLLE_MASK 0x0001 +#define PLLE_POST_RESETB_I_POST_RESETB_PLLE_MASK 0x0001 + +#define PLL_LOCK_ADDR (ESUB_CLK_BASE_ADDR + 0x0C38) +#define PLL_LOCK_PLL_LOCK_PLLE_MASK0x0001 + +#define ESW_SYS_DIV_ADDR (ESUB_CLK_BASE_ADDR + 0x0A04) +#define ESW_SYS_DIV_PLL_SELECT_MASK0x0300 +#define ESW_SYS_DIV_DIV_MASK 0x001C +#define ESW_SYS_DIV_PLL_VAR_208M_CLK_SELECT0x0100 +#define ESW_SYS_DIV_DIV_SELECT 0x4 +#define ESW_SYS_DIV_TRIGGER_MASK 0x0001 + +#define ESUB_AXI_DIV_DEBUG_ADDR(ESUB_CLK_BASE_ADDR + 0x0E04) +#define ESUB_AXI_DIV_DEBUG_PLL_SELECT_MASK 0x001C +#define ESUB_AXI_DIV_DEBUG_PLL_SELECT_OVERRIDE_MASK0x0040 +#define ESUB_AXI_DIV_DEBUG_PLL_VAR_208M_CLK_SELECT 0x0 +#define ESUB_AXI_DIV_DEBUG_TRIGGER_MASK0x0001 + +#define PLL_MAX_RETRY 100 + +/* Enable appropriate clocks for Ethernet */ +int clk_eth_enable(void) +{ + int rc = -1; + int retry_count = 0; + rc = clk_get_and_enable(esub_ccu_clk); + + /* Enable Access to CCU registers */ + writel((1 | WR_ACCESS_PASSWORD), WR_ACCESS_ADDR); + + writel(readl(PLLE_POST_RESETB_ADDR) + ~PLLE_POST_RESETB_I_POST_RESETB_PLLE_MASK, + PLLE_POST_RESETB_ADDR); + + /* Take PLL out of reset and put into normal mode */ + writel(readl(PLLE_RESETB_ADDR
Re: [U-Boot] [PATCH v2 0/4] Introducing the Broadcom Cygnus and NSP boards.
On 14-07-22 03:41 PM, Steve Rae wrote: This series adds the bcm958300k and the bcm958622hr boards which share the iproc architecture code. Changes in v2: - remove unused include file - reformat multi-line comment(s) - remove deprecated SZ_ definitions - remove misc_init_r() - update CONFIG_ENV_SIZE Scott Branden (4): arm: iproc: Initial commit of iproc architecture code arm: bcmcygnus: Add bcmcygnus u-architecture arm: bcmnsp: Add bcmnsp u-architecture arm: add Cygnus and NSP boards arch/arm/cpu/armv7/Makefile | 1 + arch/arm/cpu/armv7/bcmcygnus/Makefile | 7 + arch/arm/cpu/armv7/bcmcygnus/reset.c| 20 +++ arch/arm/cpu/armv7/bcmnsp/Makefile | 7 + arch/arm/cpu/armv7/bcmnsp/reset.c | 19 +++ arch/arm/cpu/armv7/iproc-common/Makefile| 9 ++ arch/arm/cpu/armv7/iproc-common/armpll.c| 170 arch/arm/cpu/armv7/iproc-common/hwinit-common.c | 15 +++ arch/arm/cpu/armv7/iproc-common/timer.c | 130 ++ arch/arm/include/asm/arch-bcmcygnus/configs.h | 25 arch/arm/include/asm/arch-bcmnsp/configs.h | 22 +++ arch/arm/include/asm/iproc-common/armpll.h | 14 ++ arch/arm/include/asm/iproc-common/configs.h | 20 +++ arch/arm/include/asm/iproc-common/sysmap.h | 47 +++ arch/arm/include/asm/iproc-common/timer.h | 37 ++ board/broadcom/bcm_ep/Makefile | 7 + board/broadcom/bcm_ep/board.c | 55 boards.cfg | 2 + include/configs/bcm_ep_board.h | 107 +++ 19 files changed, 714 insertions(+) create mode 100644 arch/arm/cpu/armv7/bcmcygnus/Makefile create mode 100644 arch/arm/cpu/armv7/bcmcygnus/reset.c create mode 100644 arch/arm/cpu/armv7/bcmnsp/Makefile create mode 100644 arch/arm/cpu/armv7/bcmnsp/reset.c create mode 100644 arch/arm/cpu/armv7/iproc-common/Makefile create mode 100644 arch/arm/cpu/armv7/iproc-common/armpll.c create mode 100644 arch/arm/cpu/armv7/iproc-common/hwinit-common.c create mode 100644 arch/arm/cpu/armv7/iproc-common/timer.c create mode 100644 arch/arm/include/asm/arch-bcmcygnus/configs.h create mode 100644 arch/arm/include/asm/arch-bcmnsp/configs.h create mode 100644 arch/arm/include/asm/iproc-common/armpll.h create mode 100644 arch/arm/include/asm/iproc-common/configs.h create mode 100644 arch/arm/include/asm/iproc-common/sysmap.h create mode 100644 arch/arm/include/asm/iproc-common/timer.h create mode 100644 board/broadcom/bcm_ep/Makefile create mode 100644 board/broadcom/bcm_ep/board.c create mode 100644 include/configs/bcm_ep_board.h Albert, I notice that this patchset is assigned to you: http://patchwork.ozlabs.org/patch/371767/ I have more features to submit, which are dependant on this patchset. Is the process to submit those changes, and to put in the commit note that this patchset is a prerequisite, or ??? Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 0/4] Implement fastboot flash for eMMC
On 14-06-26 01:13 PM, Steve Rae wrote: This series implements the fastboot flash command for eMMC devices. It supports both raw and sparse images. NOTES: - the support for the fastboot flash command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???) This has been tested on ARMv7. Changes in v3: - remove most references to 'mmc', which leaves only one mmc specific function: mmc_get_dev() Changes in v2: - split large function into three - improved handling of response messages - additional partition size checking when writing sparse image - update README.android-fastboot file - new in v2 Steve Rae (4): usb/gadget: fastboot: add sparse image definitions usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command usb/gadget: fastboot: minor cleanup README | 10 +++ common/Makefile | 5 ++ common/fb_mmc.c | 190 doc/README.android-fastboot | 5 +- drivers/usb/gadget/f_fastboot.c | 41 - include/fb_mmc.h| 8 ++ include/sparse_format.h | 58 7 files changed, 312 insertions(+), 5 deletions(-) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h create mode 100644 include/sparse_format.h Marek, I notice that this patchset is assigned to you: http://patchwork.ozlabs.org/patch/364705/ Has there been any progress? Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 0/4] Implement fastboot flash for eMMC
On 14-07-30 06:23 PM, Marek Vasut wrote: On Thursday, July 31, 2014 at 03:02:37 AM, Steve Rae wrote: On 14-06-26 01:13 PM, Steve Rae wrote: This series implements the fastboot flash command for eMMC devices. It supports both raw and sparse images. NOTES: - the support for the fastboot flash command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???) This has been tested on ARMv7. Changes in v3: - remove most references to 'mmc', which leaves only one mmc specific function: mmc_get_dev() Changes in v2: - split large function into three - improved handling of response messages - additional partition size checking when writing sparse image - update README.android-fastboot file - new in v2 Steve Rae (4): usb/gadget: fastboot: add sparse image definitions usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command usb/gadget: fastboot: minor cleanup README | 10 +++ common/Makefile | 5 ++ common/fb_mmc.c | 190 doc/README.android-fastboot | 5 +- drivers/usb/gadget/f_fastboot.c | 41 - include/fb_mmc.h| 8 ++ include/sparse_format.h | 58 7 files changed, 312 insertions(+), 5 deletions(-) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h create mode 100644 include/sparse_format.h Marek, I notice that this patchset is assigned to you: http://patchwork.ozlabs.org/patch/364705/ Has there been any progress? Hm, dang. I merrily ignored this patchset in the hope Lukasz will pick it up, but he was not in the loop. Sorry about delaying this so much. Given Lukasz is now on a vacation, I'll take a look later today. Thanks, Steve Best regards, Marek Vasut Thanks -- appreciate that And I'll work through your reviews; but I'll comment on one right now. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 1/4] usb/gadget: fastboot: add sparse image definitions
On 14-07-30 06:25 PM, Marek Vasut wrote: On Thursday, June 26, 2014 at 10:13:21 PM, Steve Rae wrote: - to prepare for the support of fastboot sparse images Signed-off-by: Steve Rae s...@broadcom.com --- This file is ASIS from: https://raw.githubusercontent.com/AOSB/android_system_core/master/libspars e/sparse_format.h (commit 28fa5bc347390480fe190294c6c385b6a9f0d68b) except for the __UBOOT__ conditional include. Changes in v3: None Changes in v2: None include/sparse_format.h | 58 + 1 file changed, 58 insertions(+) create mode 100644 include/sparse_format.h diff --git a/include/sparse_format.h b/include/sparse_format.h new file mode 100644 index 000..21fbd05 --- /dev/null +++ b/include/sparse_format.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. Please use the SPDX licence identifiers (pelase see Licenses/README)? + */ + +#ifndef _LIBSPARSE_SPARSE_FORMAT_H_ +#define _LIBSPARSE_SPARSE_FORMAT_H_ +#define __UBOOT__ +#ifndef __UBOOT__ +#include sparse_defs.h +#endif + +typedef struct sparse_header { + __le32 magic; /* 0xed26ff3a */ + __le16 major_version; /* (0x1) - reject images with higher major versions */ + __le16 minor_version; /* (0x0) - allow images with higer minor versions */ + __le16 file_hdr_sz;/* 28 bytes for first revision of the file format */ + __le16chunk_hdr_sz; /* 12 bytes for first revision of the file format */ + __le32 blk_sz; /* block size in bytes, must be a multiple of 4 (4096) */ + __le32 total_blks; /* total blocks in the non-sparse output image */ + __le32total_chunks; /* total chunks in the sparse input image */ + __le32 image_checksum; /* CRC32 checksum of the original data, counting don't care */ + /* as 0. Standard 802.3 polynomial, use a Public Domain */ + /* table implementation */ +} sparse_header_t; + +#define SPARSE_HEADER_MAGIC0xed26ff3a + +#define CHUNK_TYPE_RAW 0xCAC1 +#define CHUNK_TYPE_FILL0xCAC2 +#define CHUNK_TYPE_DONT_CARE 0xCAC3 +#define CHUNK_TYPE_CRC320xCAC4 + +typedef struct chunk_header { + __le16 chunk_type; /* 0xCAC1 - raw; 0xCAC2 - fill; 0xCAC3 - don't care */ + __le16 reserved1; + __le32 chunk_sz; /* in blocks in output image */ + __le32 total_sz; /* in bytes of chunk input file including chunk header and data */ +} chunk_header_t; + +/* Following a Raw or Fill or CRC32 chunk is data. The comment here is not aligned with coding style, I'll leave fixing it up to you, since the license header text needs revisiting. + * For a Raw chunk, it's the data in chunk_sz * blk_sz. + * For a Fill chunk, it's 4 bytes of the fill data. + * For a CRC32 chunk, it's 4 bytes of CRC32 + */ + +#endif To clarify: I am taking this file ASIS from the location stated in the commit message Do we _really_ want to modify _anything_ in this file (especially when the content is not changing); or do we want to leaving it pristine? ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 1/3] arm: bcm281xx: Add Ethernet Clock support
From: Jiandong Zheng jdzh...@broadcom.com Enable Ethernet clock when Broadcom StarFighter2 Ethernet block (CONFIG_BCM_SF2_ETH) is enabled. Signed-off-by: Jiandong Zheng jdzh...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- - with the changes to boards.cfg, the board with this feature will be added separately Changes in v2: - removed 'boards.cfg' from this commit - (no other changes) arch/arm/cpu/armv7/bcm281xx/Makefile| 1 + arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c | 34 +++ arch/arm/cpu/armv7/bcm281xx/clk-eth.c | 143 arch/arm/include/asm/arch-bcm281xx/sysmap.h | 3 + 4 files changed, 181 insertions(+) create mode 100644 arch/arm/cpu/armv7/bcm281xx/clk-eth.c diff --git a/arch/arm/cpu/armv7/bcm281xx/Makefile b/arch/arm/cpu/armv7/bcm281xx/Makefile index 98f5aa5..bd867a2 100644 --- a/arch/arm/cpu/armv7/bcm281xx/Makefile +++ b/arch/arm/cpu/armv7/bcm281xx/Makefile @@ -9,3 +9,4 @@ obj-y += clk-core.o obj-y += clk-bcm281xx.o obj-y += clk-sdio.o obj-y += clk-bsc.o +obj-$(CONFIG_BCM_SF2_ETH) += clk-eth.o diff --git a/arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c b/arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c index bc8a170..d16b99f 100644 --- a/arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c +++ b/arch/arm/cpu/armv7/bcm281xx/clk-bcm281xx.c @@ -118,6 +118,16 @@ unsigned long slave_apb_freq_tbl[8] = { 78 * CLOCK_1M }; +unsigned long esub_freq_tbl[8] = { + 78 * CLOCK_1M, + 156 * CLOCK_1M, + 156 * CLOCK_1M, + 156 * CLOCK_1M, + 208 * CLOCK_1M, + 208 * CLOCK_1M, + 208 * CLOCK_1M +}; + static struct bus_clk_data bsc1_apb_data = { .gate = HW_SW_GATE_AUTO(0x0458, 16, 0, 1), }; @@ -295,6 +305,27 @@ static struct ccu_clock kps_ccu_clk = { .freq_tbl = slave_axi_freq_tbl, }; +#ifdef CONFIG_BCM_SF2_ETH +static struct ccu_clock esub_ccu_clk = { + .clk = { + .name = esub_ccu_clk, + .ops = ccu_clk_ops, + .ccu_clk_mgr_base = ESUB_CLK_BASE_ADDR, + }, + .num_policy_masks = 1, + .policy_freq_offset = 0x0008, + .freq_bit_shift = 8, + .policy_ctl_offset = 0x000c, + .policy0_mask_offset = 0x0010, + .policy1_mask_offset = 0x0014, + .policy2_mask_offset = 0x0018, + .policy3_mask_offset = 0x001c, + .lvm_en_offset = 0x0034, + .freq_id = 2, + .freq_tbl = esub_freq_tbl, +}; +#endif + /* * Bus clocks */ @@ -517,6 +548,9 @@ struct clk_lookup arch_clk_tbl[] = { CLK_LK(bsc1_apb), CLK_LK(bsc2_apb), CLK_LK(bsc3_apb), +#ifdef CONFIG_BCM_SF2_ETH + CLK_LK(esub_ccu), +#endif }; /* public array size */ diff --git a/arch/arm/cpu/armv7/bcm281xx/clk-eth.c b/arch/arm/cpu/armv7/bcm281xx/clk-eth.c new file mode 100644 index 000..b0b92b9 --- /dev/null +++ b/arch/arm/cpu/armv7/bcm281xx/clk-eth.c @@ -0,0 +1,143 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h +#include asm/errno.h +#include asm/arch/sysmap.h +#include asm/kona-common/clk.h +#include clk-core.h + +#define WR_ACCESS_ADDR ESUB_CLK_BASE_ADDR +#define WR_ACCESS_PASSWORD 0xA5A500 + +#define PLLE_POST_RESETB_ADDR (ESUB_CLK_BASE_ADDR + 0x0C00) + +#define PLLE_RESETB_ADDR (ESUB_CLK_BASE_ADDR + 0x0C58) +#define PLLE_RESETB_I_PLL_RESETB_PLLE_MASK 0x0001 +#define PLLE_POST_RESETB_I_POST_RESETB_PLLE_MASK 0x0001 + +#define PLL_LOCK_ADDR (ESUB_CLK_BASE_ADDR + 0x0C38) +#define PLL_LOCK_PLL_LOCK_PLLE_MASK0x0001 + +#define ESW_SYS_DIV_ADDR (ESUB_CLK_BASE_ADDR + 0x0A04) +#define ESW_SYS_DIV_PLL_SELECT_MASK0x0300 +#define ESW_SYS_DIV_DIV_MASK 0x001C +#define ESW_SYS_DIV_PLL_VAR_208M_CLK_SELECT0x0100 +#define ESW_SYS_DIV_DIV_SELECT 0x4 +#define ESW_SYS_DIV_TRIGGER_MASK 0x0001 + +#define ESUB_AXI_DIV_DEBUG_ADDR(ESUB_CLK_BASE_ADDR + 0x0E04) +#define ESUB_AXI_DIV_DEBUG_PLL_SELECT_MASK 0x001C +#define ESUB_AXI_DIV_DEBUG_PLL_SELECT_OVERRIDE_MASK0x0040 +#define ESUB_AXI_DIV_DEBUG_PLL_VAR_208M_CLK_SELECT 0x0 +#define ESUB_AXI_DIV_DEBUG_TRIGGER_MASK0x0001 + +#define PLL_MAX_RETRY 100 + +/* Enable appropriate clocks for Ethernet */ +int clk_eth_enable(void) +{ + int rc = -1; + int retry_count = 0; + rc = clk_get_and_enable(esub_ccu_clk); + + /* Enable Access to CCU registers */ + writel((1 | WR_ACCESS_PASSWORD), WR_ACCESS_ADDR); + + writel(readl(PLLE_POST_RESETB_ADDR) + ~PLLE_POST_RESETB_I_POST_RESETB_PLLE_MASK, + PLLE_POST_RESETB_ADDR); + + /* Take PLL out of reset and put
[U-Boot] [PATCH v2 2/3] arm: bcm281xx: net: Add Ethernet Driver
From: Jiandong Zheng jdzh...@broadcom.com The Broadcom StarFighter2 Ethernet driver is used in multiple Broadcom SoC(s) and: - supports multiple MAC blocks, - provides support for the Broadcom GMAC. This driver requires MII and PHYLIB. Signed-off-by: Jiandong Zheng jdzh...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v2: - added Ethernet Driver drivers/net/Makefile | 2 + drivers/net/bcm-sf2-eth-gmac.c | 971 + drivers/net/bcm-sf2-eth-gmac.h | 224 ++ drivers/net/bcm-sf2-eth.c | 268 drivers/net/bcm-sf2-eth.h | 70 +++ include/netdev.h | 1 + 6 files changed, 1536 insertions(+) create mode 100644 drivers/net/bcm-sf2-eth-gmac.c create mode 100644 drivers/net/bcm-sf2-eth-gmac.h create mode 100644 drivers/net/bcm-sf2-eth.c create mode 100644 drivers/net/bcm-sf2-eth.h diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 7cc6b6f..14b5eb2 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -10,6 +10,8 @@ obj-$(CONFIG_ALTERA_TSE) += altera_tse.o obj-$(CONFIG_ARMADA100_FEC) += armada100_fec.o obj-$(CONFIG_DRIVER_AT91EMAC) += at91_emac.o obj-$(CONFIG_DRIVER_AX88180) += ax88180.o +obj-$(CONFIG_BCM_SF2_ETH) += bcm-sf2-eth.o +obj-$(CONFIG_BCM_SF2_ETH_GMAC) += bcm-sf2-eth-gmac.o obj-$(CONFIG_BFIN_MAC) += bfin_mac.o obj-$(CONFIG_CALXEDA_XGMAC) += calxedaxgmac.o obj-$(CONFIG_CS8900) += cs8900.o diff --git a/drivers/net/bcm-sf2-eth-gmac.c b/drivers/net/bcm-sf2-eth-gmac.c new file mode 100644 index 000..977feec --- /dev/null +++ b/drivers/net/bcm-sf2-eth-gmac.c @@ -0,0 +1,971 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifdef BCM_GMAC_DEBUG +#ifndef DEBUG +#define DEBUG +#endif +#endif + +#include config.h +#include common.h +#include malloc.h +#include net.h +#include asm/io.h +#include phy.h + +#include bcm-sf2-eth.h +#include bcm-sf2-eth-gmac.h + +#define SPINWAIT(exp, us) { \ + uint countdown = (us) + 9; \ + while ((exp) (countdown = 10)) {\ + udelay(10); \ + countdown -= 10; \ + } \ +} + +static int gmac_disable_dma(struct eth_dma *dma, int dir); +static int gmac_enable_dma(struct eth_dma *dma, int dir); + +/* DMA Descriptor */ +typedef struct { + /* misc control bits */ + uint32_tctrl1; + /* buffer count and address extension */ + uint32_tctrl2; + /* memory address of the date buffer, bits 31:0 */ + uint32_taddrlow; + /* memory address of the date buffer, bits 63:32 */ + uint32_taddrhigh; +} dma64dd_t; + +uint32_t g_dmactrlflags; + +static uint32_t dma_ctrlflags(uint32_t mask, uint32_t flags) +{ + debug(%s enter\n, __func__); + + g_dmactrlflags = ~mask; + g_dmactrlflags |= flags; + + /* If trying to enable parity, check if parity is actually supported */ + if (g_dmactrlflags DMA_CTRL_PEN) { + uint32_t control; + + control = readl(GMAC0_DMA_TX_CTRL_ADDR); + writel(control | D64_XC_PD, GMAC0_DMA_TX_CTRL_ADDR); + if (readl(GMAC0_DMA_TX_CTRL_ADDR) D64_XC_PD) { + /* +* We *can* disable it, therefore it is supported; +* restore control register +*/ + writel(control, GMAC0_DMA_TX_CTRL_ADDR); + } else { + /* Not supported, don't allow it to be enabled */ + g_dmactrlflags = ~DMA_CTRL_PEN; + } + } + + return g_dmactrlflags; +} + +static inline void reg32_clear_bits(uint32_t reg, uint32_t value) +{ + uint32_t v = readl(reg); + v = ~(value); + writel(v, reg); +} + +static inline void reg32_set_bits(uint32_t reg, uint32_t value) +{ + uint32_t v = readl(reg); + v |= value; + writel(v, reg); +} + +#ifdef BCM_GMAC_DEBUG +static void dma_tx_dump(struct eth_dma *dma) +{ + dma64dd_t *descp = NULL; + uint8_t *bufp; + int i; + + printf(TX DMA Register:\n); + printf(control:0x%x; ptr:0x%x; addrl:0x%x; addrh:0x%x; stat0:0x%x, stat1:0x%x\n, + readl(GMAC0_DMA_TX_CTRL_ADDR), + readl(GMAC0_DMA_TX_PTR_ADDR), + readl(GMAC0_DMA_TX_ADDR_LOW_ADDR), + readl(GMAC0_DMA_TX_ADDR_HIGH_ADDR), + readl(GMAC0_DMA_TX_STATUS0_ADDR), + readl(GMAC0_DMA_TX_STATUS1_ADDR)); + + printf(TX Descriptors:\n); + for (i = 0; i TX_BUF_NUM; i++) { + descp = (dma64dd_t *)(dma-tx_desc_aligned) + i; + printf(ctrl1:0x%08x; ctrl2:0x%08x; addr:0x%x 0x%08x\n, + descp-ctrl1, descp-ctrl2, + descp-addrhigh, descp-addrlow); + } + + printf(TX Buffers:\n); + /* Initialize TX DMA descriptor table */ + for (i = 0
[U-Boot] [PATCH v2 3/3] arm: bcm281xx: add board with Ethernet capability
Add board which has Broadcom StarFighter2 Ethernet capability. Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v2: - created from previous boards.cfg board/broadcom/bcm28155_w1d/MAINTAINERS | 6 ++ configs/bcm28155_w1d_defconfig | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 board/broadcom/bcm28155_w1d/MAINTAINERS create mode 100644 configs/bcm28155_w1d_defconfig diff --git a/board/broadcom/bcm28155_w1d/MAINTAINERS b/board/broadcom/bcm28155_w1d/MAINTAINERS new file mode 100644 index 000..a436490 --- /dev/null +++ b/board/broadcom/bcm28155_w1d/MAINTAINERS @@ -0,0 +1,6 @@ +BCM28155_W1D BOARD +M: Steve Rae s...@broadcom.com +S: Maintained +F: board/broadcom/bcm28155_ap/ +F: include/configs/bcm28155_ap.h +F: configs/bcm28155_w1d_defconfig diff --git a/configs/bcm28155_w1d_defconfig b/configs/bcm28155_w1d_defconfig new file mode 100644 index 000..94b791c --- /dev/null +++ b/configs/bcm28155_w1d_defconfig @@ -0,0 +1,3 @@ +CONFIG_SYS_EXTRA_OPTIONS=BCM_SF2_ETH,BCM_SF2_ETH_GMAC +CONFIG_ARM=y +CONFIG_TARGET_BCM28155_AP=y -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 1/4] usb/gadget: fastboot: add sparse image definitions
On 14-08-05 07:00 AM, Tom Rini wrote: On Thu, Jul 31, 2014 at 10:32:51AM -0700, Steve Rae wrote: On 14-07-30 06:25 PM, Marek Vasut wrote: On Thursday, June 26, 2014 at 10:13:21 PM, Steve Rae wrote: - to prepare for the support of fastboot sparse images Signed-off-by: Steve Rae s...@broadcom.com --- This file is ASIS from: https://raw.githubusercontent.com/AOSB/android_system_core/master/libspars e/sparse_format.h (commit 28fa5bc347390480fe190294c6c385b6a9f0d68b) except for the __UBOOT__ conditional include. Changes in v3: None Changes in v2: None include/sparse_format.h | 58 + 1 file changed, 58 insertions(+) create mode 100644 include/sparse_format.h diff --git a/include/sparse_format.h b/include/sparse_format.h new file mode 100644 index 000..21fbd05 --- /dev/null +++ b/include/sparse_format.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. Please use the SPDX licence identifiers (pelase see Licenses/README)? And again, the license itself _is_ a problem. [snip] To clarify: I am taking this file ASIS from the location stated in the commit message Do we _really_ want to modify _anything_ in this file (especially when the content is not changing); or do we want to leaving it pristine? I'd be fine with it being pristine if it was a GPL-compatible license. Any ideas on how can we proceed? How can we get past this license issue? IMO, the fastboot flash command is severely hampered if we cannot support the sparse format. Thanks in advance, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 3/4] usb/gadget: fastboot: add support for flash command
On 14-07-30 06:39 PM, Marek Vasut wrote: On Thursday, June 26, 2014 at 10:13:23 PM, Steve Rae wrote: - implement 'fastboot flash' for eMMC devices Signed-off-by: Steve Rae s...@broadcom.com Reviewed-by: Marek Vasut ma...@denx.de Thanks, Steve Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 4/4] usb/gadget: fastboot: minor cleanup
On 14-07-30 06:40 PM, Marek Vasut wrote: On Thursday, June 26, 2014 at 10:13:24 PM, Steve Rae wrote: - update static function - additional debugging statements Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v3: None Changes in v2: - new in v2 drivers/usb/gadget/f_fastboot.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 89c2d3e..3e6e47f 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -293,7 +293,7 @@ static int fastboot_add(struct usb_configuration *c) } DECLARE_GADGET_BIND_CALLBACK(usb_dnl_fastboot, fastboot_add); -int fastboot_tx_write(const char *buffer, unsigned int buffer_size) +static int fastboot_tx_write(const char *buffer, unsigned int buffer_size) { struct usb_request *in_req = fastboot_func-in_req; int ret; @@ -338,6 +338,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) strcpy(response, OKAY); strsep(cmd, :); if (!cmd) { + printf(%s: missing var\n, __func__); I'd spell it out completely -- variable -- but I'm not sure if you might need to maintain some kind of compatibility with the fastboot responses here or not. nope -- done in v4 Thanks, Steve [...] Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 2/4] usb/gadget: fastboot: add eMMC support for flash command
On 14-07-30 06:37 PM, Marek Vasut wrote: On Thursday, June 26, 2014 at 10:13:22 PM, Steve Rae wrote: [...] + +#include common.h +#include fb_mmc.h +#include part.h +#include sparse_format.h + +/* The 64 defined bytes plus \0 */ +#define RESPONSE_LEN (64 + 1) + +static char *response_str; I'd suggest to pass this response_str around instead of making it global. That would involve adding it to fastboot_resp(), which is called 11 times in this code, from 3 different functions (so would need to add this to two of the functions...). And as these evolve, there will likely be more nested functions, which would all require passing it around I think that this static global pointer is a cleaner implementation. +static void fastboot_resp(const char *s) +{ + strncpy(response_str, s, RESPONSE_LEN); + response_str[RESPONSE_LEN - 1] = '\0'; This could be shrunk to a single snprintf(response_str, RESPONSE_LENGTH, s); I think, but I'm not sure if the overhead won't grow. snprintf() is used very sparingling in U-Boot, and with the cautionary statements in README (line 852) and the fact that CONFIG_SYS_VSNPRINTF is not defined for armv7 builds, I am not going to use it +} + +static int is_sparse_image(void *buf) +{ + sparse_header_t *s_header = (sparse_header_t *)buf; + + if ((le32_to_cpu(s_header-magic) == SPARSE_HEADER_MAGIC) + (le16_to_cpu(s_header-major_version) == 1)) + return 1; + + return 0; +} + +static void write_sparse_image(block_dev_desc_t *dev_desc, + disk_partition_t *info, const char *part_name, + void *buffer, unsigned int download_bytes) +{ + lbaint_t blk; + lbaint_t blkcnt; + lbaint_t blks; + sparse_header_t *s_header = (sparse_header_t *)buffer; + chunk_header_t *c_header; + void *buf; + uint32_t blk_sz; + uint32_t remaining_chunks; + uint32_t bytes_written = 0; + + blk_sz = le32_to_cpu(s_header-blk_sz); + + /* verify s_header-blk_sz is exact multiple of info-blksz */ + if (blk_sz != (blk_sz ~(info-blksz - 1))) { + printf(%s: Sparse image block size issue [%u]\n, + __func__, blk_sz); + fastboot_resp(FAILsparse image block size issue); Can't you just make the fastboot_resp() function a variadic one AND move the printf() into the fastboot_resp() function? You could then even get consistent output on both the device and in the response if you snprintf() into the response_str first and then printf() the response_str . Generally, the printf() statements which are sent to the console, and the fastboot_resp() statements which are sent to the host running the fastboot application are not the same + return; + } [...] +static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, +const char *part_name, void *buffer, + unsigned int download_bytes) +{ + lbaint_t blkcnt; + lbaint_t blks; + + /* determine number of blocks to write */ + blkcnt = ((download_bytes + (info-blksz - 1)) ~(info-blksz - 1)); + blkcnt = blkcnt / info-blksz; + + if (blkcnt info-size) { + printf(%s: too large for partition: '%s'\n, __func__, + part_name); + fastboot_resp(FAILtoo large for partition); + return; + } + + printf(Flashing Raw Image\n); Use puts() here and everywhere where printf() is not taking any args please. done in v4 - Thanks! + blks = dev_desc-block_write(dev_desc-dev, info-start, blkcnt, +buffer); + if (blks != blkcnt) { + printf(%s: failed writing to device %d\n, __func__, + dev_desc-dev); + fastboot_resp(FAILfailed writing to device); + return; + } + + printf( wrote LBAFU bytes to '%s'\n, blkcnt * info-blksz, + part_name); + fastboot_resp(OKAY); +} [...] Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 0/5] Implement fastboot flash for eMMC
This series implements the fastboot flash command for eMMC devices. It supports both raw and sparse images. NOTES: - the support for the fastboot flash command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???) This has been tested on ARMv7. While we are struggling with the sparse_format copyright and licensing issues, can we accept the first three patches? Thanks, Steve Changes in v4: - rearranged this patchset so that sparse_format.h can be dropped (if we cannot resolve the copyright/licensing issues) - update mmc_get_dev(...) to get_dev(mmc,) - update printf() to puts() where applicable - update debug string as per feedback - rearranged sparse format support in this patchset, in order to isolate... Changes in v3: - remove most references to 'mmc', which leaves only one mmc specific function: mmc_get_dev() Changes in v2: - split large function into three - improved handling of response messages - additional partition size checking when writing sparse image - update README.android-fastboot file - new in v2 Steve Rae (5): usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command usb/gadget: fastboot: minor cleanup usb/gadget: fastboot: add sparse image definitions usb/gadget: fastboot: implement sparse format README | 10 +++ common/Makefile | 5 ++ common/cmd_fastboot.c | 7 +- common/fb_mmc.c | 191 doc/README.android-fastboot | 5 +- drivers/usb/gadget/f_fastboot.c | 44 - include/fb_mmc.h| 8 ++ include/sparse_format.h | 58 8 files changed, 319 insertions(+), 9 deletions(-) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h create mode 100644 include/sparse_format.h -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 1/5] usb/gadget: fastboot: add eMMC support for flash command
- add support for 'fastboot flash' command for eMMC devices Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v4: - rearranged this patchset so that sparse_format.h can be dropped (if we cannot resolve the copyright/licensing issues) - update mmc_get_dev(...) to get_dev(mmc,) - update printf() to puts() where applicable Changes in v3: - remove most references to 'mmc', which leaves only one mmc specific function: mmc_get_dev() Changes in v2: - split large function into three - improved handling of response messages - additional partition size checking when writing sparse image common/Makefile | 5 common/fb_mmc.c | 82 include/fb_mmc.h | 8 ++ 3 files changed, 95 insertions(+) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h diff --git a/common/Makefile b/common/Makefile index de5cce8..daebe39 100644 --- a/common/Makefile +++ b/common/Makefile @@ -266,4 +266,9 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o obj-y += memsize.o obj-y += stdio.o +# This option is not just y/n - it can have a numeric value +ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +obj-y += fb_mmc.o +endif + CFLAGS_env_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2/dev/null) diff --git a/common/fb_mmc.c b/common/fb_mmc.c new file mode 100644 index 000..f42a115 --- /dev/null +++ b/common/fb_mmc.c @@ -0,0 +1,82 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include fb_mmc.h +#include part.h + +/* The 64 defined bytes plus \0 */ +#define RESPONSE_LEN (64 + 1) + +static char *response_str; + +static void fastboot_resp(const char *s) +{ + strncpy(response_str, s, RESPONSE_LEN); + response_str[RESPONSE_LEN - 1] = '\0'; +} + +static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, + const char *part_name, void *buffer, + unsigned int download_bytes) +{ + lbaint_t blkcnt; + lbaint_t blks; + + /* determine number of blocks to write */ + blkcnt = ((download_bytes + (info-blksz - 1)) ~(info-blksz - 1)); + blkcnt = blkcnt / info-blksz; + + if (blkcnt info-size) { + printf(%s: too large for partition: '%s'\n, __func__, + part_name); + fastboot_resp(FAILtoo large for partition); + return; + } + + puts(Flashing Raw Image\n); + + blks = dev_desc-block_write(dev_desc-dev, info-start, blkcnt, +buffer); + if (blks != blkcnt) { + printf(%s: failed writing to device %d\n, __func__, + dev_desc-dev); + fastboot_resp(FAILfailed writing to device); + return; + } + + printf( wrote LBAFU bytes to '%s'\n, blkcnt * info-blksz, + part_name); + fastboot_resp(OKAY); +} + +void fb_mmc_flash_write(const char *cmd, void *download_buffer, + unsigned int download_bytes, char *response) +{ + int ret; + block_dev_desc_t *dev_desc; + disk_partition_t info; + + /* initialize the response buffer */ + response_str = response; + + dev_desc = get_dev(mmc, CONFIG_FASTBOOT_FLASH_MMC_DEV); + if (!dev_desc || dev_desc-type == DEV_TYPE_UNKNOWN) { + printf(%s: invalid mmc device\n, __func__); + fastboot_resp(FAILinvalid mmc device); + return; + } + + ret = get_partition_info_efi_by_name(dev_desc, cmd, info); + if (ret) { + printf(%s: cannot find partition: '%s'\n, __func__, cmd); + fastboot_resp(FAILcannot find partition); + return; + } + + write_raw_image(dev_desc, info, cmd, download_buffer, + download_bytes); +} diff --git a/include/fb_mmc.h b/include/fb_mmc.h new file mode 100644 index 000..1ad1d13 --- /dev/null +++ b/include/fb_mmc.h @@ -0,0 +1,8 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +void fb_mmc_flash_write(const char *cmd, void *download_buffer, + unsigned int download_bytes, char *response); -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 3/5] usb/gadget: fastboot: minor cleanup
- update static function - additional debugging statements - update fastboot command information - add missing include file - update spelling Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v4: - update debug string as per feedback Changes in v3: None Changes in v2: - new in v2 common/cmd_fastboot.c | 7 --- drivers/usb/gadget/f_fastboot.c | 13 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c index 83fa7bd..909616d 100644 --- a/common/cmd_fastboot.c +++ b/common/cmd_fastboot.c @@ -30,7 +30,8 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) } U_BOOT_CMD( - fastboot, 1, 1, do_fastboot, - fastboot - enter USB Fastboot protocol, - + fastboot, 1, 0, do_fastboot, + use USB Fastboot protocol, + \n + - run as a fastboot usb device ); diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index e2659fa..3b588a9 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -10,6 +10,7 @@ * * SPDX-License-Identifier:GPL-2.0+ */ +#include config.h #include common.h #include errno.h #include malloc.h @@ -41,7 +42,7 @@ struct f_fastboot { struct usb_function usb_function; - /* IN/OUT EP's and correspoinding requests */ + /* IN/OUT EP's and corresponding requests */ struct usb_ep *in_ep, *out_ep; struct usb_request *in_req, *out_req; }; @@ -293,7 +294,7 @@ static int fastboot_add(struct usb_configuration *c) } DECLARE_GADGET_BIND_CALLBACK(usb_dnl_fastboot, fastboot_add); -int fastboot_tx_write(const char *buffer, unsigned int buffer_size) +static int fastboot_tx_write(const char *buffer, unsigned int buffer_size) { struct usb_request *in_req = fastboot_func-in_req; int ret; @@ -341,6 +342,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) strsep(cmd, :); if (!cmd) { + printf(%s: missing variable\n, __func__); fastboot_tx_write_str(FAILmissing var); return; } @@ -361,6 +363,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) else strcpy(response, FAILValue not set); } else { + printf(%s: unknown variable: %s\n, __func__, cmd); strcpy(response, FAILVariable not implemented); } fastboot_tx_write_str(response); @@ -534,10 +537,12 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) } } - if (!func_cb) + if (!func_cb) { + printf(%s: unknown command: %s\n, __func__, cmdbuf); fastboot_tx_write_str(FAILunknown command); - else + } else { func_cb(ep, req); + } if (req-status == 0) { *cmdbuf = '\0'; -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 2/5] usb/gadget: fastboot: add support for flash command
- implement 'fastboot flash' for eMMC devices Signed-off-by: Steve Rae s...@broadcom.com Reviewed-by: Marek Vasut ma...@denx.de --- Changes in v4: None Changes in v3: None Changes in v2: - update README.android-fastboot file README | 10 ++ doc/README.android-fastboot | 5 +++-- drivers/usb/gadget/f_fastboot.c | 31 +++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/README b/README index 1d71359..ed26884 100644 --- a/README +++ b/README @@ -1623,6 +1623,16 @@ The following options need to be configured: downloads. This buffer should be as large as possible for a platform. Define this to the size available RAM for fastboot. + CONFIG_FASTBOOT_FLASH + The fastboot protocol includes a flash command for writing + the downloaded image to a non-volatile storage device. Define + this to enable the fastboot flash command. + + CONFIG_FASTBOOT_FLASH_MMC_DEV + The fastboot flash command requires addition information + regarding the non-volatile storage device. Define this to + the eMMC device that fastboot should use to store the image. + - Journaling Flash filesystem support: CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE, CONFIG_JFFS2_NAND_DEV diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot index f1d128c..430e29c 100644 --- a/doc/README.android-fastboot +++ b/doc/README.android-fastboot @@ -6,8 +6,9 @@ Overview The protocol that is used over USB is described in README.android-fastboot-protocol in same directory. -The current implementation does not yet support the flash and erase -commands. +The current implementation does not yet support the erase command or the +oem format command, and there is minimal support for the flash command; +it only supports eMMC devices. Client installation === diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 7a1acb9..e2659fa 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -19,6 +19,9 @@ #include linux/compiler.h #include version.h #include g_dnl.h +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#include fb_mmc.h +#endif #define FASTBOOT_VERSION 0.4 @@ -469,6 +472,28 @@ static void cb_boot(struct usb_ep *ep, struct usb_request *req) fastboot_tx_write_str(OKAY); } +#ifdef CONFIG_FASTBOOT_FLASH +static void cb_flash(struct usb_ep *ep, struct usb_request *req) +{ + char *cmd = req-buf; + char response[RESPONSE_LEN]; + + strsep(cmd, :); + if (!cmd) { + printf(%s: missing partition name\n, __func__); + fastboot_tx_write_str(FAILmissing partition name); + return; + } + + strcpy(response, FAILno flash device defined); +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV + fb_mmc_flash_write(cmd, (void *)CONFIG_USB_FASTBOOT_BUF_ADDR, + download_bytes, response); +#endif + fastboot_tx_write_str(response); +} +#endif + struct cmd_dispatch_info { char *cmd; void (*cb)(struct usb_ep *ep, struct usb_request *req); @@ -488,6 +513,12 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = { .cmd = boot, .cb = cb_boot, }, +#ifdef CONFIG_FASTBOOT_FLASH + { + .cmd = flash, + .cb = cb_flash, + }, +#endif }; static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 4/5] usb/gadget: fastboot: add sparse image definitions
- to prepare for the support of fastboot sparse images Signed-off-by: Steve Rae s...@broadcom.com --- This file is ASIS from: https://raw.githubusercontent.com/AOSB/android_system_core/master/libsparse/sparse_format.h (commit 28fa5bc347390480fe190294c6c385b6a9f0d68b) except for the __UBOOT__ conditional include. Changes in v4: None Changes in v3: None Changes in v2: None include/sparse_format.h | 58 + 1 file changed, 58 insertions(+) create mode 100644 include/sparse_format.h diff --git a/include/sparse_format.h b/include/sparse_format.h new file mode 100644 index 000..21fbd05 --- /dev/null +++ b/include/sparse_format.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _LIBSPARSE_SPARSE_FORMAT_H_ +#define _LIBSPARSE_SPARSE_FORMAT_H_ +#define __UBOOT__ +#ifndef __UBOOT__ +#include sparse_defs.h +#endif + +typedef struct sparse_header { + __le32 magic; /* 0xed26ff3a */ + __le16 major_version; /* (0x1) - reject images with higher major versions */ + __le16 minor_version; /* (0x0) - allow images with higer minor versions */ + __le16 file_hdr_sz;/* 28 bytes for first revision of the file format */ + __le16 chunk_hdr_sz; /* 12 bytes for first revision of the file format */ + __le32 blk_sz; /* block size in bytes, must be a multiple of 4 (4096) */ + __le32 total_blks; /* total blocks in the non-sparse output image */ + __le32 total_chunks; /* total chunks in the sparse input image */ + __le32 image_checksum; /* CRC32 checksum of the original data, counting don't care */ + /* as 0. Standard 802.3 polynomial, use a Public Domain */ + /* table implementation */ +} sparse_header_t; + +#define SPARSE_HEADER_MAGIC0xed26ff3a + +#define CHUNK_TYPE_RAW 0xCAC1 +#define CHUNK_TYPE_FILL0xCAC2 +#define CHUNK_TYPE_DONT_CARE 0xCAC3 +#define CHUNK_TYPE_CRC320xCAC4 + +typedef struct chunk_header { + __le16 chunk_type; /* 0xCAC1 - raw; 0xCAC2 - fill; 0xCAC3 - don't care */ + __le16 reserved1; + __le32 chunk_sz; /* in blocks in output image */ + __le32 total_sz; /* in bytes of chunk input file including chunk header and data */ +} chunk_header_t; + +/* Following a Raw or Fill or CRC32 chunk is data. + * For a Raw chunk, it's the data in chunk_sz * blk_sz. + * For a Fill chunk, it's 4 bytes of the fill data. + * For a CRC32 chunk, it's 4 bytes of CRC32 + */ + +#endif -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 5/5] usb/gadget: fastboot: implement sparse format
- add capability to fastboot flash with sparse format images Signed-off-by: Steve Rae s...@broadcom.com --- I suspect that the sparse image handling (ie. the while (remaining_chunks) loop) has been implemented elsewhere -- I need help finding the original code to determine any licensing issues Thanks, Steve Changes in v4: - rearranged sparse format support in this patchset, in order to isolate... Changes in v3: None Changes in v2: None common/fb_mmc.c | 115 ++-- 1 file changed, 112 insertions(+), 3 deletions(-) diff --git a/common/fb_mmc.c b/common/fb_mmc.c index f42a115..306c102 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -1,5 +1,6 @@ /* - * Copyright 2014 Broadcom Corporation. + * Copyright TODO + * Portions Copyright 2014 Broadcom Corporation. * * SPDX-License-Identifier:GPL-2.0+ */ @@ -7,6 +8,7 @@ #include common.h #include fb_mmc.h #include part.h +#include sparse_format.h /* The 64 defined bytes plus \0 */ #define RESPONSE_LEN (64 + 1) @@ -19,6 +21,108 @@ static void fastboot_resp(const char *s) response_str[RESPONSE_LEN - 1] = '\0'; } +static int is_sparse_image(void *buf) +{ + sparse_header_t *s_header = (sparse_header_t *)buf; + + if ((le32_to_cpu(s_header-magic) == SPARSE_HEADER_MAGIC) + (le16_to_cpu(s_header-major_version) == 1)) + return 1; + + return 0; +} + +static void write_sparse_image(block_dev_desc_t *dev_desc, + disk_partition_t *info, const char *part_name, + void *buffer, unsigned int download_bytes) +{ + lbaint_t blk; + lbaint_t blkcnt; + lbaint_t blks; + sparse_header_t *s_header = (sparse_header_t *)buffer; + chunk_header_t *c_header; + void *buf; + uint32_t blk_sz; + uint32_t remaining_chunks; + uint32_t bytes_written = 0; + + blk_sz = le32_to_cpu(s_header-blk_sz); + + /* verify s_header-blk_sz is exact multiple of info-blksz */ + if (blk_sz != (blk_sz ~(info-blksz - 1))) { + printf(%s: Sparse image block size issue [%u]\n, + __func__, blk_sz); + fastboot_resp(FAILsparse image block size issue); + return; + } + + if ((le32_to_cpu(s_header-total_blks) * blk_sz) + (info-size * info-blksz)) { + printf(%s: Sparse image is too large for the partition\n, + __func__); + fastboot_resp(FAILsparse image is too large); + return; + } + + puts(Flashing Sparse Image\n); + + remaining_chunks = le32_to_cpu(s_header-total_chunks); + c_header = (chunk_header_t *)(buffer + + le16_to_cpu(s_header-file_hdr_sz)); + blk = info-start; + while (remaining_chunks) { + blkcnt = + (le32_to_cpu(c_header-chunk_sz) * blk_sz) / info-blksz; + + switch (le16_to_cpu(c_header-chunk_type)) { + case CHUNK_TYPE_RAW: + buf = (void *)c_header + + le16_to_cpu(s_header-chunk_hdr_sz); + + if (blk + blkcnt info-start + info-size) { + printf( + %s: Request would exceed partition size!\n, + __func__); + fastboot_resp( + FAILRequest would exceed partition size!); + return; + } + + blks = dev_desc-block_write(dev_desc-dev, blk, blkcnt, + buf); + if (blks != blkcnt) { + printf(%s: Write failed LBAFU \n, + __func__, blks); + fastboot_resp(FAILwrite failure); + return; + } + + bytes_written += blkcnt * info-blksz; + break; + + case CHUNK_TYPE_FILL: + case CHUNK_TYPE_DONT_CARE: + case CHUNK_TYPE_CRC32: + /* do nothing */ + break; + + default: + /* error */ + printf(%s: Unknown chunk type\n, __func__); + fastboot_resp(FAILunknown chunk type in sparse image); + return; + } + + blk += blkcnt; + c_header = (chunk_header_t *)((void *)c_header + + le32_to_cpu(c_header-total_sz)); + remaining_chunks--; + } + + printf( wrote %u bytes to '%s'\n, bytes_written, part_name); + fastboot_resp(OKAY); +} + static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, const
Re: [U-Boot] [PATCH v3 2/4] usb/gadget: fastboot: add eMMC support for flash command
On 14-08-06 05:13 PM, Marek Vasut wrote: On Thursday, August 07, 2014 at 01:48:06 AM, Steve Rae wrote: On 14-07-30 06:37 PM, Marek Vasut wrote: On Thursday, June 26, 2014 at 10:13:22 PM, Steve Rae wrote: [...] + +#include common.h +#include fb_mmc.h +#include part.h +#include sparse_format.h + +/* The 64 defined bytes plus \0 */ +#define RESPONSE_LEN (64 + 1) + +static char *response_str; I'd suggest to pass this response_str around instead of making it global. That would involve adding it to fastboot_resp(), which is called 11 times in this code, from 3 different functions (so would need to add this to two of the functions...). And as these evolve, there will likely be more nested functions, which would all require passing it around I think that this static global pointer is a cleaner implementation. Eventually, the amount of these static variables in the code will grow and it will become increasingly difficult to weed them out. I believe it would be even better to pass around some kind of a structure with private data of the fastboot, which would cater for all possible variables which might come in the future. What do you think ? Yes -- if there is private data that the fastboot implementation requires, then a data structure is the way to go. However, I still think that this fastboot response string would even be an exception to that private data +static void fastboot_resp(const char *s) +{ + strncpy(response_str, s, RESPONSE_LEN); + response_str[RESPONSE_LEN - 1] = '\0'; This could be shrunk to a single snprintf(response_str, RESPONSE_LENGTH, s); I think, but I'm not sure if the overhead won't grow. snprintf() is used very sparingling in U-Boot This is not a reason to avoid it. true , and with the cautionary statements in README (line 852) Which statements? Can you please point them out? I fail to see them, sorry. I was referring to what you mention below... 852 - Safe printf() functions 853 Define CONFIG_SYS_VSNPRINTF to compile in safe versions of 854 the printf() functions. These are defined in 855 include/vsprintf.h and include snprintf(), vsnprintf() and 856 so on. Code size increase is approximately 300-500 bytes. 857 If this option is not given then these functions will 858 silently discard their buffer size argument - this means 859 you are not getting any overflow checking in this case. and the fact that CONFIG_SYS_VSNPRINTF is not defined for armv7 builds, I am not going to use it Is it a problem to define it? Also, even without CONFIG_SYS_VSNPRINTF , the functions are still available, see the README: 857 If this option is not given then these functions will 858 silently discard their buffer size argument - this means 859 you are not getting any overflow checking in this case. I have yet to see some hard-evidence against using safe printing functions here. I don't want to be the first to defined it for all of armv7 And I really don't want to define it only only my boards running so that they can run 'fastboot' What do you suggest? +} + +static int is_sparse_image(void *buf) +{ + sparse_header_t *s_header = (sparse_header_t *)buf; + + if ((le32_to_cpu(s_header-magic) == SPARSE_HEADER_MAGIC) + (le16_to_cpu(s_header-major_version) == 1)) + return 1; + + return 0; +} + +static void write_sparse_image(block_dev_desc_t *dev_desc, + disk_partition_t *info, const char *part_name, + void *buffer, unsigned int download_bytes) +{ + lbaint_t blk; + lbaint_t blkcnt; + lbaint_t blks; + sparse_header_t *s_header = (sparse_header_t *)buffer; + chunk_header_t *c_header; + void *buf; + uint32_t blk_sz; + uint32_t remaining_chunks; + uint32_t bytes_written = 0; + + blk_sz = le32_to_cpu(s_header-blk_sz); + + /* verify s_header-blk_sz is exact multiple of info-blksz */ + if (blk_sz != (blk_sz ~(info-blksz - 1))) { + printf(%s: Sparse image block size issue [%u]\n, + __func__, blk_sz); + fastboot_resp(FAILsparse image block size issue); Can't you just make the fastboot_resp() function a variadic one AND move the printf() into the fastboot_resp() function? You could then even get consistent output on both the device and in the response if you snprintf() into the response_str first and then printf() the response_str . Generally, the printf() statements which are sent to the console, and the fastboot_resp() statements which are sent to the host running the fastboot application are not the same OK, thanks! Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v4 0/5] Implement fastboot flash for eMMC
On 14-08-06 05:16 PM, Marek Vasut wrote: On Thursday, August 07, 2014 at 01:55:08 AM, Steve Rae wrote: This series implements the fastboot flash command for eMMC devices. It supports both raw and sparse images. NOTES: - the support for the fastboot flash command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???) This has been tested on ARMv7. I'll just wait for Tom's comments on 4/5 and 5/5 and will see then. The 1-3/5 look OK. Best regards, Marek Vasut THANKS! Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v4 4/5] usb/gadget: fastboot: add sparse image definitions
On 14-08-06 05:14 PM, Marek Vasut wrote: On Thursday, August 07, 2014 at 01:55:12 AM, Steve Rae wrote: - to prepare for the support of fastboot sparse images Signed-off-by: Steve Rae s...@broadcom.com --- Are we discussing the licensing issues here still ? Tom ? Best regards, Marek Vasut I hope so -- and I'm hoping that someone can help resolve this Thanks in advance, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v4 4/5] usb/gadget: fastboot: add sparse image definitions
On 14-08-07 06:51 AM, Sebastian Andrzej Siewior wrote: On 08/07/2014 03:45 PM, Marek Vasut wrote: I agree. Is there a version of this file with BSD license on it ? Then that'd be a problem solved, right ? Right. I don't recall the locations of the second tree but if Steve is going to search it, he should find it. I have not found anything other than the Apache 2 license (yet). If anyone can find anything, please let me know! Thanks in advance, Steve Best regards, Marek Vasut Sebastian ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 2/4] usb/gadget: fastboot: add eMMC support for flash command
On 14-08-07 06:23 AM, Marek Vasut wrote: On Thursday, August 07, 2014 at 02:28:13 AM, Steve Rae wrote: On 14-08-06 05:13 PM, Marek Vasut wrote: On Thursday, August 07, 2014 at 01:48:06 AM, Steve Rae wrote: On 14-07-30 06:37 PM, Marek Vasut wrote: On Thursday, June 26, 2014 at 10:13:22 PM, Steve Rae wrote: [...] + +#include common.h +#include fb_mmc.h +#include part.h +#include sparse_format.h + +/* The 64 defined bytes plus \0 */ +#define RESPONSE_LEN (64 + 1) + +static char *response_str; I'd suggest to pass this response_str around instead of making it global. That would involve adding it to fastboot_resp(), which is called 11 times in this code, from 3 different functions (so would need to add this to two of the functions...). And as these evolve, there will likely be more nested functions, which would all require passing it around I think that this static global pointer is a cleaner implementation. Eventually, the amount of these static variables in the code will grow and it will become increasingly difficult to weed them out. I believe it would be even better to pass around some kind of a structure with private data of the fastboot, which would cater for all possible variables which might come in the future. What do you think ? Yes -- if there is private data that the fastboot implementation requires, then a data structure is the way to go. However, I still think that this fastboot response string would even be an exception to that private data OK, let's leave it this way for now. +static void fastboot_resp(const char *s) +{ + strncpy(response_str, s, RESPONSE_LEN); + response_str[RESPONSE_LEN - 1] = '\0'; This could be shrunk to a single snprintf(response_str, RESPONSE_LENGTH, s); I think, but I'm not sure if the overhead won't grow. snprintf() is used very sparingling in U-Boot This is not a reason to avoid it. true , and with the cautionary statements in README (line 852) Which statements? Can you please point them out? I fail to see them, sorry. I was referring to what you mention below... 852 - Safe printf() functions 853 Define CONFIG_SYS_VSNPRINTF to compile in safe versions of 854 the printf() functions. These are defined in 855 include/vsprintf.h and include snprintf(), vsnprintf() and 856 so on. Code size increase is approximately 300-500 bytes. 857 If this option is not given then these functions will 858 silently discard their buffer size argument - this means 859 you are not getting any overflow checking in this case. I really don't see the cautionary statements here , no . I see that it discards the size checking if this CONFIG_SYS_VSNPRINTF is not enabled, but that does not obstruct the operation of those functions. I'm really confused: my code ensures that the buffer is not overflowed and that it is terminated properly. If snprintf() (without CONFIG_SYS_VSNPRINTF defined) doesn't provide any overflow checking, then why would I use it? and the fact that CONFIG_SYS_VSNPRINTF is not defined for armv7 builds, I am not going to use it Is it a problem to define it? Also, even without CONFIG_SYS_VSNPRINTF , the functions are still available, see the README: 857 If this option is not given then these functions will 858 silently discard their buffer size argument - this means 859 you are not getting any overflow checking in this case. I have yet to see some hard-evidence against using safe printing functions here. I don't want to be the first to defined it for all of armv7 Honestly, we should just enable this CONFIG_SYS_VSNPRINTF by default for the good of humanity and all the things, since this unbounded string handling is just evil (see how OpenSSL ended up, partly because of that ... and I am just starting to see the pattern in all the security code). I don't want to go down that road with U-Boot. So, would you please cook a separate patch to enable this by default, so it would spur the right kind of discussion on this matter ? I will apologize in advance, but I just don't know anything about SPL or TPL or any other boards (outside of my very limited armv7 and armv8 scope) I would be happy to review and test this suggested patch (on our boards), but would be uncomfortable with proposing this patch. Please go ahead and submit a patch, and I'll check it! Thanks, Steve And I really don't want to define it only only my boards running so that they can run 'fastboot' What do you suggest? See above, thanks ! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v4 4/5] usb/gadget: fastboot: add sparse image definitions
( Google agreed to submit a patch with BSD3 license stay tuned!!! ) On 14-08-09 05:48 AM, Marek Vasut wrote: On Friday, August 08, 2014 at 12:17:38 AM, Wolfgang Denk wrote: Dear Marek, In message 201408072343.58591.ma...@denx.de you wrote: OK, so we need a GPLv2-compatible header file. That's the conclusion. Well, GPLv2 compatible might be acceptable, but GPLv2+ compatible woould be best. I was talking to Hans about this yesterday (and who was dropped from the CC for some reason) and it turns out the easy way out here is to just reimplement the header. I would like him to take a look and express his opinion properly though. Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2 v2] fastboot: Flash command support
On 14-08-10 06:59 PM, Dileep Katta wrote: Flash command internally uses DFU, and Fastboot command initialization is modified to add DFU and partition initialization Added oem format functionality for GPT table creation partitioning code is added as disk/part_fastboot.c for better usability Fastboot flash command code is enabled and being tested on BeagleBone Black. OMAP3 Beagle configuration is modified to fix the build errors, but this configuration needs to be updated as per the flash functionality. Signed-off-by: Dileep Katta dileep.ka...@linaro.org --- Changes for v2: - Fixed coding style issues common/cmd_fastboot.c | 5 + common/cmd_mmc.c| 2 +- common/cmd_nvedit.c | 2 +- disk/Makefile | 1 + disk/part_fastboot.c| 379 doc/README.android-fastboot | 26 +++ drivers/usb/gadget/f_fastboot.c | 178 ++- include/configs/am335x_evm.h| 23 ++- include/configs/omap3_beagle.h | 12 ++ include/usb/fastboot.h | 182 +++ 10 files changed, 796 insertions(+), 14 deletions(-) create mode 100644 disk/part_fastboot.c create mode 100644 include/usb/fastboot.h diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c index 83fa7bd..6d0d0a4 100644 --- a/common/cmd_fastboot.c +++ b/common/cmd_fastboot.c @@ -10,11 +10,15 @@ #include common.h #include command.h #include g_dnl.h +#include dfu.h +#include usb/fastboot.h static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { int ret; + board_partition_init(); + dfu_init_env_entities(mmc, CONFIG_FB_MMCDEV); ret = g_dnl_register(usb_dnl_fastboot); if (ret) return ret; @@ -26,6 +30,7 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) } g_dnl_unregister(); + dfu_free_entities(); return CMD_RET_SUCCESS; } diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index 1e40983..dd7170d 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -612,7 +612,7 @@ static cmd_tbl_t cmd_mmc[] = { U_BOOT_CMD_MKENT(setdsr, 2, 0, do_mmc_setdsr, , ), }; -static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { cmd_tbl_t *cp; diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 855808c..a100109 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -686,7 +686,7 @@ ulong getenv_ulong(const char *name, int base, ulong default_val) #ifndef CONFIG_SPL_BUILD #if defined(CONFIG_CMD_SAVEENV) !defined(CONFIG_ENV_IS_NOWHERE) -static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, +int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { printf(Saving Environment to %s...\n, env_name_spec); diff --git a/disk/Makefile b/disk/Makefile index 6970cec..4b7a9ef 100644 --- a/disk/Makefile +++ b/disk/Makefile @@ -13,3 +13,4 @@ obj-$(CONFIG_DOS_PARTITION) += part_dos.o obj-$(CONFIG_ISO_PARTITION) += part_iso.o obj-$(CONFIG_AMIGA_PARTITION) += part_amiga.o obj-$(CONFIG_EFI_PARTITION) += part_efi.o +obj-$(CONFIG_CMD_FASTBOOT)+= part_fastboot.o diff --git a/disk/part_fastboot.c b/disk/part_fastboot.c new file mode 100644 index 000..4fa9f85 --- /dev/null +++ b/disk/part_fastboot.c @@ -0,0 +1,379 @@ +/* + * Copyright (C) 2013 Texas Instruments + * + * Author : Pankaj Bharadiya pankaj.bharad...@ti.com + * + * Tom Rix tom@windriver.com and Sitara 2011 u-boot by + * Mohammed Afzal M A af...@ti.com + * + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Copyright 2014 Linaro, Ltd. + * Dileep Katta dileep.ka...@linaro.org + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include command.h +#include usb/fastboot.h +#include linux/usb/ch9.h +#include linux/usb/gadget.h +#include environment.h +#include mmc.h +#include dfu.h + +#define EFI_VERSION 0x0001 +#define EFI_ENTRIES 128 +#define EFI_NAMELEN 36 + +struct partition_emmc { + const char *name; + unsigned size_kb; +}; + +/* eMMC partition layout (All sizes are in kB) + * Modify the below partition table to change the GPT configuration. + * The entry for each partition can be modified as per the requirement. + */ +static struct partition_emmc partitions[] = { + { -, 128 }, /* Master Boot Record and GUID Partition Table */ + { spl, 128 }, /* First stage bootloader */ + { bootloader, 512 },/* Second stage bootloader */ + { misc, 128 }, /* Rserved for internal purpose */ + { -, 128 }, /* Reserved */ + { recovery, 8*1024 }, /* Recovery partition */ + { boot, 8*1024 }, /* Partition contains kernel + ramdisk images */ + { system,
[U-Boot] [PATCH v3 1/5] arm: iproc: Initial commit of iproc architecture code
From: Scott Branden sbran...@broadcom.com The iproc architecture code is present in several Broadcom chip architectures, including Cygnus and NSP. Signed-off-by: Scott Branden sbran...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v3: None Changes in v2: - remove unused include file arch/arm/cpu/armv7/Makefile | 1 + arch/arm/cpu/armv7/iproc-common/Makefile| 9 ++ arch/arm/cpu/armv7/iproc-common/armpll.c| 170 arch/arm/cpu/armv7/iproc-common/hwinit-common.c | 15 +++ arch/arm/cpu/armv7/iproc-common/timer.c | 130 ++ arch/arm/include/asm/iproc-common/armpll.h | 14 ++ arch/arm/include/asm/iproc-common/sysmap.h | 47 +++ arch/arm/include/asm/iproc-common/timer.h | 37 ++ 8 files changed, 423 insertions(+) create mode 100644 arch/arm/cpu/armv7/iproc-common/Makefile create mode 100644 arch/arm/cpu/armv7/iproc-common/armpll.c create mode 100644 arch/arm/cpu/armv7/iproc-common/hwinit-common.c create mode 100644 arch/arm/cpu/armv7/iproc-common/timer.c create mode 100644 arch/arm/include/asm/iproc-common/armpll.h create mode 100644 arch/arm/include/asm/iproc-common/sysmap.h create mode 100644 arch/arm/include/asm/iproc-common/timer.h diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile index 703ce8c..afeed4d 100644 --- a/arch/arm/cpu/armv7/Makefile +++ b/arch/arm/cpu/armv7/Makefile @@ -28,6 +28,7 @@ ifneq ($(CONFIG_ARMV7_PSCI),) obj-y += psci.o endif +obj-$(CONFIG_IPROC) += iproc-common/ obj-$(CONFIG_KONA) += kona-common/ obj-$(CONFIG_OMAP_COMMON) += omap-common/ obj-$(CONFIG_SYS_ARCH_TIMER) += arch_timer.o diff --git a/arch/arm/cpu/armv7/iproc-common/Makefile b/arch/arm/cpu/armv7/iproc-common/Makefile new file mode 100644 index 000..c071a17 --- /dev/null +++ b/arch/arm/cpu/armv7/iproc-common/Makefile @@ -0,0 +1,9 @@ +# +# Copyright 2014 Broadcom Corporation. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += armpll.o +obj-y += hwinit-common.o +obj-y += timer.o diff --git a/arch/arm/cpu/armv7/iproc-common/armpll.c b/arch/arm/cpu/armv7/iproc-common/armpll.c new file mode 100644 index 000..49b61bf --- /dev/null +++ b/arch/arm/cpu/armv7/iproc-common/armpll.c @@ -0,0 +1,170 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h +#include asm/iproc-common/armpll.h +#include asm/iproc-common/sysmap.h + +#define NELEMS(x) (sizeof(x) / sizeof(x[0])) + +struct armpll_parameters { + unsigned int mode; + unsigned int ndiv_int; + unsigned int ndiv_frac; + unsigned int pdiv; + unsigned int freqid; +}; + +struct armpll_parameters armpll_clk_tab[] = { + { 25, 64, 1, 1, 0}, + { 100, 64, 1, 1, 2}, + { 400, 64, 1, 1, 6}, + { 448, 71, 713050, 1, 6}, + { 500, 80, 1, 1, 6}, + { 560, 89, 629145, 1, 6}, + { 600, 96, 1, 1, 6}, + { 800, 64, 1, 1, 7}, + { 896, 71, 713050, 1, 7}, + { 1000, 80, 1, 1, 7}, + { 1100, 88, 1, 1, 7}, + { 1120, 89, 629145, 1, 7}, + { 1200, 96, 1, 1, 7}, +}; + +uint32_t armpll_config(uint32_t clkmhz) +{ + uint32_t freqid; + uint32_t ndiv_frac; + uint32_t pll; + uint32_t status = 1; + uint32_t timeout_countdown; + int i; + + for (i = 0; i NELEMS(armpll_clk_tab); i++) { + if (armpll_clk_tab[i].mode == clkmhz) { + status = 0; + break; + } + } + + if (status) { + printf(Error: Clock configuration not supported\n); + goto armpll_config_done; + } + + /* Enable write access */ + writel(IPROC_REG_WRITE_ACCESS, IHOST_PROC_CLK_WR_ACCESS); + + if (clkmhz == 25) + freqid = 0; + else + freqid = 2; + + /* Bypass ARM clock and run on sysclk */ + writel(1 IHOST_PROC_CLK_POLICY_FREQ__PRIV_ACCESS_MODE | + freqid IHOST_PROC_CLK_POLICY_FREQ__POLICY3_FREQ_R | + freqid IHOST_PROC_CLK_POLICY_FREQ__POLICY2_FREQ_R | + freqid IHOST_PROC_CLK_POLICY_FREQ__POLICY1_FREQ_R | + freqid IHOST_PROC_CLK_POLICY_FREQ__POLICY0_FREQ_R, + IHOST_PROC_CLK_POLICY_FREQ); + + writel(1 IHOST_PROC_CLK_POLICY_CTL__GO | + 1 IHOST_PROC_CLK_POLICY_CTL__GO_AC, + IHOST_PROC_CLK_POLICY_CTL); + + /* Poll CCU until operation complete */ + timeout_countdown = 0x10; + while (readl(IHOST_PROC_CLK_POLICY_CTL) + (1 IHOST_PROC_CLK_POLICY_CTL__GO)) { + timeout_countdown--; + if (timeout_countdown == 0) { + printf(CCU polling timedout\n); + status = 1; + goto armpll_config_done
[U-Boot] [PATCH v3 0/5] Introducing the Broadcom Cygnus and NSP boards.
This series adds the bcm958300k and the bcm958622hr boards which share the iproc architecture code. Changes in v3: - remove boards.cfg - improve error checking of configs - add required files for Kconfig Changes in v2: - remove unused include file - reformat multi-line comment(s) - remove deprecated SZ_ definitions - remove misc_init_r() - update CONFIG_ENV_SIZE Scott Branden (4): arm: iproc: Initial commit of iproc architecture code arm: bcmcygnus: Add bcmcygnus u-architecture arm: bcmnsp: Add bcmnsp u-architecture arm: add Cygnus and NSP boards Steve Rae (1): arm: convert Cygnus and NSP boards to Kconfig arch/arm/Kconfig| 8 ++ arch/arm/cpu/armv7/Makefile | 1 + arch/arm/cpu/armv7/bcmcygnus/Makefile | 7 + arch/arm/cpu/armv7/bcmcygnus/reset.c| 20 +++ arch/arm/cpu/armv7/bcmnsp/Makefile | 7 + arch/arm/cpu/armv7/bcmnsp/reset.c | 19 +++ arch/arm/cpu/armv7/iproc-common/Makefile| 9 ++ arch/arm/cpu/armv7/iproc-common/armpll.c| 170 arch/arm/cpu/armv7/iproc-common/hwinit-common.c | 15 +++ arch/arm/cpu/armv7/iproc-common/timer.c | 130 ++ arch/arm/include/asm/arch-bcmcygnus/configs.h | 25 arch/arm/include/asm/arch-bcmnsp/configs.h | 22 +++ arch/arm/include/asm/iproc-common/armpll.h | 14 ++ arch/arm/include/asm/iproc-common/configs.h | 20 +++ arch/arm/include/asm/iproc-common/sysmap.h | 47 +++ arch/arm/include/asm/iproc-common/timer.h | 37 ++ board/broadcom/bcm958300k/Kconfig | 23 board/broadcom/bcm958300k/MAINTAINERS | 6 + board/broadcom/bcm958622hr/Kconfig | 23 board/broadcom/bcm958622hr/MAINTAINERS | 6 + board/broadcom/bcm_ep/Makefile | 7 + board/broadcom/bcm_ep/board.c | 55 configs/bcm958300k_defconfig| 3 + configs/bcm958622hr_defconfig | 3 + include/configs/bcm_ep_board.h | 115 25 files changed, 792 insertions(+) create mode 100644 arch/arm/cpu/armv7/bcmcygnus/Makefile create mode 100644 arch/arm/cpu/armv7/bcmcygnus/reset.c create mode 100644 arch/arm/cpu/armv7/bcmnsp/Makefile create mode 100644 arch/arm/cpu/armv7/bcmnsp/reset.c create mode 100644 arch/arm/cpu/armv7/iproc-common/Makefile create mode 100644 arch/arm/cpu/armv7/iproc-common/armpll.c create mode 100644 arch/arm/cpu/armv7/iproc-common/hwinit-common.c create mode 100644 arch/arm/cpu/armv7/iproc-common/timer.c create mode 100644 arch/arm/include/asm/arch-bcmcygnus/configs.h create mode 100644 arch/arm/include/asm/arch-bcmnsp/configs.h create mode 100644 arch/arm/include/asm/iproc-common/armpll.h create mode 100644 arch/arm/include/asm/iproc-common/configs.h create mode 100644 arch/arm/include/asm/iproc-common/sysmap.h create mode 100644 arch/arm/include/asm/iproc-common/timer.h create mode 100644 board/broadcom/bcm958300k/Kconfig create mode 100644 board/broadcom/bcm958300k/MAINTAINERS create mode 100644 board/broadcom/bcm958622hr/Kconfig create mode 100644 board/broadcom/bcm958622hr/MAINTAINERS create mode 100644 board/broadcom/bcm_ep/Makefile create mode 100644 board/broadcom/bcm_ep/board.c create mode 100644 configs/bcm958300k_defconfig create mode 100644 configs/bcm958622hr_defconfig create mode 100644 include/configs/bcm_ep_board.h -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 3/5] arm: bcmnsp: Add bcmnsp u-architecture
From: Scott Branden sbran...@broadcom.com Base support for the Broadcom NSP SoC. Based on iproc-common and the SoC specific reset function. Signed-off-by: Scott Branden sbran...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v3: None Changes in v2: None arch/arm/cpu/armv7/bcmnsp/Makefile | 7 +++ arch/arm/cpu/armv7/bcmnsp/reset.c | 19 +++ 2 files changed, 26 insertions(+) create mode 100644 arch/arm/cpu/armv7/bcmnsp/Makefile create mode 100644 arch/arm/cpu/armv7/bcmnsp/reset.c diff --git a/arch/arm/cpu/armv7/bcmnsp/Makefile b/arch/arm/cpu/armv7/bcmnsp/Makefile new file mode 100644 index 000..04afcf9 --- /dev/null +++ b/arch/arm/cpu/armv7/bcmnsp/Makefile @@ -0,0 +1,7 @@ +# +# Copyright 2014 Broadcom Corporation. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += reset.o diff --git a/arch/arm/cpu/armv7/bcmnsp/reset.c b/arch/arm/cpu/armv7/bcmnsp/reset.c new file mode 100644 index 000..d79d9aa --- /dev/null +++ b/arch/arm/cpu/armv7/bcmnsp/reset.c @@ -0,0 +1,19 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h + +#define CRU_RESET_OFFSET 0x1803F184 + +void reset_cpu(ulong ignored) +{ + /* Reset the cpu by setting software reset request bit */ + writel(0x1, CRU_RESET_OFFSET); + + while (1) + ; /* loop forever till reset */ +} -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 5/5] arm: convert Cygnus and NSP boards to Kconfig
Convert the bcm958300k and the bcm958622hr boards from boards.cfg to Kconfig. Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v3: - add required files for Kconfig Changes in v2: None arch/arm/Kconfig | 8 board/broadcom/bcm958300k/Kconfig | 23 +++ board/broadcom/bcm958300k/MAINTAINERS | 6 ++ board/broadcom/bcm958622hr/Kconfig | 23 +++ board/broadcom/bcm958622hr/MAINTAINERS | 6 ++ configs/bcm958300k_defconfig | 3 +++ configs/bcm958622hr_defconfig | 3 +++ 7 files changed, 72 insertions(+) create mode 100644 board/broadcom/bcm958300k/Kconfig create mode 100644 board/broadcom/bcm958300k/MAINTAINERS create mode 100644 board/broadcom/bcm958622hr/Kconfig create mode 100644 board/broadcom/bcm958622hr/MAINTAINERS create mode 100644 configs/bcm958300k_defconfig create mode 100644 configs/bcm958622hr_defconfig diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index e385eda..f528e0a 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -428,6 +428,12 @@ config TARGET_SAMA5D3XEK config TARGET_BCM28155_AP bool Support bcm28155_ap +config TARGET_BCM958300K + bool Support bcm958300k + +config TARGET_BCM958622HR + bool Support bcm958622hr + config TARGET_ARNDALE bool Support arndale @@ -823,6 +829,8 @@ source board/bluegiga/apx4devkit/Kconfig source board/bluewater/snapper9260/Kconfig source board/boundary/nitrogen6x/Kconfig source board/broadcom/bcm28155_ap/Kconfig +source board/broadcom/bcm958300k/Kconfig +source board/broadcom/bcm958622hr/Kconfig source board/buffalo/lsxl/Kconfig source board/calao/sbc35_a9g20/Kconfig source board/calao/tny_a9260/Kconfig diff --git a/board/broadcom/bcm958300k/Kconfig b/board/broadcom/bcm958300k/Kconfig new file mode 100644 index 000..165cee7 --- /dev/null +++ b/board/broadcom/bcm958300k/Kconfig @@ -0,0 +1,23 @@ +if TARGET_BCM958300K + +config SYS_CPU + string + default armv7 + +config SYS_BOARD + string + default bcm_ep + +config SYS_VENDOR + string + default broadcom + +config SYS_SOC + string + default bcmcygnus + +config SYS_CONFIG_NAME + string + default bcm_ep_board + +endif diff --git a/board/broadcom/bcm958300k/MAINTAINERS b/board/broadcom/bcm958300k/MAINTAINERS new file mode 100644 index 000..f75ee6e --- /dev/null +++ b/board/broadcom/bcm958300k/MAINTAINERS @@ -0,0 +1,6 @@ +Broadcom: Cygnus +M: Steve Rae s...@broadcom.com +S: Maintained +F: board/broadcom/bcm958300k/ +F: include/configs/bcm_ep_board.h +F: configs/bcm958300k_defconfig diff --git a/board/broadcom/bcm958622hr/Kconfig b/board/broadcom/bcm958622hr/Kconfig new file mode 100644 index 000..6d09592 --- /dev/null +++ b/board/broadcom/bcm958622hr/Kconfig @@ -0,0 +1,23 @@ +if TARGET_BCM958622HR + +config SYS_CPU + string + default armv7 + +config SYS_BOARD + string + default bcm_ep + +config SYS_VENDOR + string + default broadcom + +config SYS_SOC + string + default bcmnsp + +config SYS_CONFIG_NAME + string + default bcm_ep_board + +endif diff --git a/board/broadcom/bcm958622hr/MAINTAINERS b/board/broadcom/bcm958622hr/MAINTAINERS new file mode 100644 index 000..c34272f --- /dev/null +++ b/board/broadcom/bcm958622hr/MAINTAINERS @@ -0,0 +1,6 @@ +Broadcom: Northstar Plus +M: Steve Rae s...@broadcom.com +S: Maintained +F: board/broadcom/bcm958622hr/ +F: include/configs/bcm_ep_board.h +F: configs/bcm958622hr_defconfig diff --git a/configs/bcm958300k_defconfig b/configs/bcm958300k_defconfig new file mode 100644 index 000..066739d --- /dev/null +++ b/configs/bcm958300k_defconfig @@ -0,0 +1,3 @@ +CONFIG_SYS_EXTRA_OPTIONS=SYS_SDRAM_SIZE=0x2000 +CONFIG_ARM=y +CONFIG_TARGET_BCM958300K=y diff --git a/configs/bcm958622hr_defconfig b/configs/bcm958622hr_defconfig new file mode 100644 index 000..8a45e51 --- /dev/null +++ b/configs/bcm958622hr_defconfig @@ -0,0 +1,3 @@ +CONFIG_SYS_EXTRA_OPTIONS=SYS_SDRAM_SIZE=0x0100 +CONFIG_ARM=y +CONFIG_TARGET_BCM958622HR=y -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 2/5] arm: bcmcygnus: Add bcmcygnus u-architecture
From: Scott Branden sbran...@broadcom.com Base support for the Broadcom Cygnus SoC. Based on iproc-common and the SoC specific reset function. Signed-off-by: Scott Branden sbran...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v3: None Changes in v2: None arch/arm/cpu/armv7/bcmcygnus/Makefile | 7 +++ arch/arm/cpu/armv7/bcmcygnus/reset.c | 20 2 files changed, 27 insertions(+) create mode 100644 arch/arm/cpu/armv7/bcmcygnus/Makefile create mode 100644 arch/arm/cpu/armv7/bcmcygnus/reset.c diff --git a/arch/arm/cpu/armv7/bcmcygnus/Makefile b/arch/arm/cpu/armv7/bcmcygnus/Makefile new file mode 100644 index 000..04afcf9 --- /dev/null +++ b/arch/arm/cpu/armv7/bcmcygnus/Makefile @@ -0,0 +1,7 @@ +# +# Copyright 2014 Broadcom Corporation. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += reset.o diff --git a/arch/arm/cpu/armv7/bcmcygnus/reset.c b/arch/arm/cpu/armv7/bcmcygnus/reset.c new file mode 100644 index 000..53ecc0c --- /dev/null +++ b/arch/arm/cpu/armv7/bcmcygnus/reset.c @@ -0,0 +1,20 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h + +#define CRMU_MAIL_BOX1 0x03024028 +#define CRMU_SOFT_RESET_CMD0x + +void reset_cpu(ulong ignored) +{ + /* Send soft reset command via Mailbox. */ + writel(CRMU_SOFT_RESET_CMD, CRMU_MAIL_BOX1); + + while (1) + ; /* loop forever till reset */ +} -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 4/5] arm: add Cygnus and NSP boards
From: Scott Branden sbran...@broadcom.com The bcm_ep board configuration is used by a number of boards including Cygnus and NSP. Add builds for the bcm958300k and the bcm958622hr boards. Signed-off-by: Scott Branden sbran...@broadcom.com Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v3: - remove boards.cfg - improve error checking of configs Changes in v2: - reformat multi-line comment(s) - remove deprecated SZ_ definitions - remove misc_init_r() - update CONFIG_ENV_SIZE arch/arm/include/asm/arch-bcmcygnus/configs.h | 25 ++ arch/arm/include/asm/arch-bcmnsp/configs.h| 22 + arch/arm/include/asm/iproc-common/configs.h | 20 + board/broadcom/bcm_ep/Makefile| 7 ++ board/broadcom/bcm_ep/board.c | 55 include/configs/bcm_ep_board.h| 115 ++ 6 files changed, 244 insertions(+) create mode 100644 arch/arm/include/asm/arch-bcmcygnus/configs.h create mode 100644 arch/arm/include/asm/arch-bcmnsp/configs.h create mode 100644 arch/arm/include/asm/iproc-common/configs.h create mode 100644 board/broadcom/bcm_ep/Makefile create mode 100644 board/broadcom/bcm_ep/board.c create mode 100644 include/configs/bcm_ep_board.h diff --git a/arch/arm/include/asm/arch-bcmcygnus/configs.h b/arch/arm/include/asm/arch-bcmcygnus/configs.h new file mode 100644 index 000..5354637 --- /dev/null +++ b/arch/arm/include/asm/arch-bcmcygnus/configs.h @@ -0,0 +1,25 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef __ARCH_CONFIGS_H +#define __ARCH_CONFIGS_H + +#include asm/iproc-common/configs.h + +/* uArchitecture specifics */ + +/* Serial Info */ +/* Post pad 3 bytes after each reg addr */ +#define CONFIG_SYS_NS16550_REG_SIZE(-4) +#define CONFIG_SYS_NS16550_MEM32 + +#define CONFIG_SYS_NS16550_CLK 1 +#define CONFIG_SYS_NS16550_CLK_DIV 54 +#define CONFIG_SERIAL_MULTI +#define CONFIG_CONS_INDEX 3 +#define CONFIG_SYS_NS16550_COM30x18023000 + +#endif /* __ARCH_CONFIGS_H */ diff --git a/arch/arm/include/asm/arch-bcmnsp/configs.h b/arch/arm/include/asm/arch-bcmnsp/configs.h new file mode 100644 index 000..786deae --- /dev/null +++ b/arch/arm/include/asm/arch-bcmnsp/configs.h @@ -0,0 +1,22 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef __ARCH_CONFIGS_H +#define __ARCH_CONFIGS_H + +#include asm/iproc-common/configs.h + +/* uArchitecture specifics */ + +/* Serial Info */ +/* no padding */ +#define CONFIG_SYS_NS16550_REG_SIZE1 + +#define CONFIG_SYS_NS16550_CLK 0x03b9aca0 +#define CONFIG_CONS_INDEX 1 +#define CONFIG_SYS_NS16550_COM10x18000300 + +#endif /* __ARCH_CONFIGS_H */ diff --git a/arch/arm/include/asm/iproc-common/configs.h b/arch/arm/include/asm/iproc-common/configs.h new file mode 100644 index 000..c24de1f --- /dev/null +++ b/arch/arm/include/asm/iproc-common/configs.h @@ -0,0 +1,20 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef __IPROC_COMMON_CONFIGS_H +#define __IPROC_COMMON_CONFIGS_H + +#include linux/stringify.h + +/* Architecture, CPU, chip, etc */ +#define CONFIG_IPROC +#define CONFIG_SYS_ARM_CACHE_WRITETHROUGH + +/* Memory Info */ +#define CONFIG_SYS_TEXT_BASE 0x6100 +#define CONFIG_SYS_SDRAM_BASE 0x6100 + +#endif /* __IPROC_COMMON_CONFIGS_H */ diff --git a/board/broadcom/bcm_ep/Makefile b/board/broadcom/bcm_ep/Makefile new file mode 100644 index 000..8914e54 --- /dev/null +++ b/board/broadcom/bcm_ep/Makefile @@ -0,0 +1,7 @@ +# +# Copyright 2014 Broadcom Corporation. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += board.o diff --git a/board/broadcom/bcm_ep/board.c b/board/broadcom/bcm_ep/board.c new file mode 100644 index 000..e48cd3f --- /dev/null +++ b/board/broadcom/bcm_ep/board.c @@ -0,0 +1,55 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include asm/io.h +#include config.h +#include asm/system.h +#include asm/iproc-common/armpll.h + +DECLARE_GLOBAL_DATA_PTR; + +/* + * board_init - early hardware init + */ +int board_init(void) +{ + /* +* Address of boot parameters passed to kernel +* Use default offset 0x100 +*/ + gd-bd-bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; + + return 0; +} + +/* + * dram_init - sets u-boot's idea of sdram size + */ +int dram_init(void) +{ + gd-ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, + CONFIG_SYS_SDRAM_SIZE); + return 0; +} + +void dram_init_banksize(void) +{ + gd-bd-bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; + gd-bd-bi_dram[0].size = gd-ram_size; +} + +int board_early_init_f(void) +{ + uint32_t status = 0; + + /* Setup PLL if required
Re: [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT
On 14-05-05 03:50 AM, Przemyslaw Marczak wrote: Hello Steve, On 04/30/2014 12:31 AM, Steve Rae wrote: Check the Alternate GPT table if the Primary GPT table is invalid. Signed-off-by: Steve Rae s...@broadcom.com --- disk/part_efi.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 216a292..ad899fa 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -93,7 +93,15 @@ void print_part_efi(block_dev_desc_t * dev_desc) if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head, gpt_pte) != 1) { printf(%s: *** ERROR: Invalid GPT ***\n, __func__); -return; +if (is_gpt_valid(dev_desc, (dev_desc-lba - 1), + gpt_head, gpt_pte) != 1) { +printf(%s: *** ERROR: Invalid Alternate GPT ***\n, + __func__); +return; +} else { +printf(%s: ***Using Alternate GPT ***\n, + __func__); +} } debug(%s: gpt-entry at %p\n, __func__, gpt_pte); @@ -142,7 +150,15 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head, gpt_pte) != 1) { printf(%s: *** ERROR: Invalid GPT ***\n, __func__); -return -1; +if (is_gpt_valid(dev_desc, (dev_desc-lba - 1), + gpt_head, gpt_pte) != 1) { +printf(%s: *** ERROR: Invalid Alternate GPT ***\n, + __func__); +return -1; +} else { +printf(%s: ***Using Alternate GPT ***\n, + __func__); +} } if (part le32_to_cpu(gpt_head-num_partition_entries) || This looks ok, we can still use u-boot filesystem commands after gpt header block corruption, but the gpt is still...corrupted. Maybe we need additional gpt subcommand for restore gpt in case when backup of gpt header is valid? Actually we have only gpt write command but it needs proper environment variables. So I think that gpt restore is welcome. Thank you, Agree -- maybe I can find time to work on a gpt restore in the near future Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] MMC: proposal to support multiple physical partitions
Pantelis, As per comments below, I suspect that adding another argument to the callback function is unacceptable. Please clarify! Thanks, Steve On 14-04-29 11:08 AM, Steve Rae wrote: Thanks for the response, -Original Message- From: Pantelis Antoniou [mailto:pa...@antoniou-consulting.com] Sent: Tuesday, April 29, 2014 10:25 To: Steve Rae Cc: u-boot@lists.denx.de; tr...@ti.com; albert.u.b...@aribaud.net Subject: Re: MMC: proposal to support multiple physical partitions Hi Steve, On Apr 24, 2014, at 8:50 PM, Steve Rae wrote: [... snip ...] I have two different proposals: 1) overload the int dev_num argument with encoded dev_num and part_num fields - the dev_num in the [15:0] bits, - the part_num in the [30:16] bits, - a flag to indicate this encoding in [31] bit. - and modify mmc_bread() to handle this encoded argument, and implement the above code... 2) create a wrapper function to perform the above code, with an added argument int part_num, possibly named: - mmc_block_dev_block_read() -- so that it is similar to the original calling convention [mmc-block_dev.block_read], or - mmc_pbread() [PartitionBlockRead] -- so that it is similar to the mmc_bread() [which is the implementation of the callback function] I'd rather go with the wrapper function. Perhaps it's not even needed. The function called is part of the block_dev (block_read/write etc). Overwrite those with functions that implemented the switching first, and then call the original block* function. The callback function is: mmc-block_dev.block_read = mmc_bread and it accepts four arguments: include/part.h: unsigned long (*block_read)(int dev, include/part.h- lbaint_t start, include/part.h- lbaint_t blkcnt, include/part.h- void *buffer); Are you suggesting that I should add another argument to this callback? [...snip...] Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT
Hmmm - perhaps Secondary would be more accurate wording than Alternate (v2 coming...) On 14-05-05 09:12 AM, Steve Rae wrote: On 14-05-05 03:50 AM, Przemyslaw Marczak wrote: Hello Steve, On 04/30/2014 12:31 AM, Steve Rae wrote: Check the Alternate GPT table if the Primary GPT table is invalid. Signed-off-by: Steve Rae s...@broadcom.com --- disk/part_efi.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 216a292..ad899fa 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -93,7 +93,15 @@ void print_part_efi(block_dev_desc_t * dev_desc) if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head, gpt_pte) != 1) { printf(%s: *** ERROR: Invalid GPT ***\n, __func__); -return; +if (is_gpt_valid(dev_desc, (dev_desc-lba - 1), + gpt_head, gpt_pte) != 1) { +printf(%s: *** ERROR: Invalid Alternate GPT ***\n, + __func__); +return; +} else { +printf(%s: ***Using Alternate GPT ***\n, + __func__); +} } debug(%s: gpt-entry at %p\n, __func__, gpt_pte); @@ -142,7 +150,15 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head, gpt_pte) != 1) { printf(%s: *** ERROR: Invalid GPT ***\n, __func__); -return -1; +if (is_gpt_valid(dev_desc, (dev_desc-lba - 1), + gpt_head, gpt_pte) != 1) { +printf(%s: *** ERROR: Invalid Alternate GPT ***\n, + __func__); +return -1; +} else { +printf(%s: ***Using Alternate GPT ***\n, + __func__); +} } if (part le32_to_cpu(gpt_head-num_partition_entries) || This looks ok, we can still use u-boot filesystem commands after gpt header block corruption, but the gpt is still...corrupted. Maybe we need additional gpt subcommand for restore gpt in case when backup of gpt header is valid? Actually we have only gpt write command but it needs proper environment variables. So I think that gpt restore is welcome. Thank you, Agree -- maybe I can find time to work on a gpt restore in the near future Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2] disk: part_efi: add support for the Secondary GPT
Check the Secondary GPT table if the Primary GPT table is invalid. Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v2: - changed wording: Alternate to Secondary disk/part_efi.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 216a292..f909229 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -93,7 +93,15 @@ void print_part_efi(block_dev_desc_t * dev_desc) if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head, gpt_pte) != 1) { printf(%s: *** ERROR: Invalid GPT ***\n, __func__); - return; + if (is_gpt_valid(dev_desc, (dev_desc-lba - 1), +gpt_head, gpt_pte) != 1) { + printf(%s: *** ERROR: Invalid Secondary GPT ***\n, + __func__); + return; + } else { + printf(%s: ***Using Secondary GPT ***\n, + __func__); + } } debug(%s: gpt-entry at %p\n, __func__, gpt_pte); @@ -142,7 +150,15 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head, gpt_pte) != 1) { printf(%s: *** ERROR: Invalid GPT ***\n, __func__); - return -1; + if (is_gpt_valid(dev_desc, (dev_desc-lba - 1), +gpt_head, gpt_pte) != 1) { + printf(%s: *** ERROR: Invalid Secondary GPT ***\n, + __func__); + return -1; + } else { + printf(%s: ***Using Secondary GPT ***\n, + __func__); + } } if (part le32_to_cpu(gpt_head-num_partition_entries) || -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT
On 14-05-05 11:43 AM, Tom Rini wrote: On Mon, May 05, 2014 at 11:26:44AM -0700, Steve Rae wrote: Hmmm - perhaps Secondary would be more accurate wording than Alternate (v2 coming...) Is there any official name for this in the GPT spec? I proposed Secondary because it matched doc/README.gpt; and it is often called secondary GPT (for example: http://en.wikipedia.org/wiki/GUID_Partition_Table) However, the UEFI Specifaction (Version 2.3.1, Errata A) calls it backup GPT 18 times, and alternate GPT once (and never calls it secondary GPT) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT
On 14-05-05 12:41 PM, Tom Rini wrote: On Mon, May 05, 2014 at 12:22:18PM -0700, Steve Rae wrote: On 14-05-05 11:43 AM, Tom Rini wrote: On Mon, May 05, 2014 at 11:26:44AM -0700, Steve Rae wrote: Hmmm - perhaps Secondary would be more accurate wording than Alternate (v2 coming...) Is there any official name for this in the GPT spec? I proposed Secondary because it matched doc/README.gpt; and it is often called secondary GPT (for example: http://en.wikipedia.org/wiki/GUID_Partition_Table) However, the UEFI Specifaction (Version 2.3.1, Errata A) calls it backup GPT 18 times, and alternate GPT once (and never calls it secondary GPT) I would go with backup GPT and update the README.gpt too please. OK (v3 coming...) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3] disk: part_efi: add support for the Backup GPT
Check the Backup GPT table if the Primary GPT table is invalid. Renamed Secondary GPT to Backup GPT as per: UEFI Specification (Version 2.3.1, Errata A) Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v3: - renamed: Secondary GPT to Backup GPT Changes in v2: - changed wording: Alternate to Secondary disk/part_efi.c | 22 +++--- doc/README.gpt | 14 +++--- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 216a292..c74b7b9 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -93,7 +93,15 @@ void print_part_efi(block_dev_desc_t * dev_desc) if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head, gpt_pte) != 1) { printf(%s: *** ERROR: Invalid GPT ***\n, __func__); - return; + if (is_gpt_valid(dev_desc, (dev_desc-lba - 1), +gpt_head, gpt_pte) != 1) { + printf(%s: *** ERROR: Invalid Backup GPT ***\n, + __func__); + return; + } else { + printf(%s: ***Using Backup GPT ***\n, + __func__); + } } debug(%s: gpt-entry at %p\n, __func__, gpt_pte); @@ -142,7 +150,15 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head, gpt_pte) != 1) { printf(%s: *** ERROR: Invalid GPT ***\n, __func__); - return -1; + if (is_gpt_valid(dev_desc, (dev_desc-lba - 1), +gpt_head, gpt_pte) != 1) { + printf(%s: *** ERROR: Invalid Backup GPT ***\n, + __func__); + return -1; + } else { + printf(%s: ***Using Backup GPT ***\n, + __func__); + } } if (part le32_to_cpu(gpt_head-num_partition_entries) || @@ -252,7 +268,7 @@ int write_gpt_table(block_dev_desc_t *dev_desc, != pte_blk_cnt) goto err; - /* recalculate the values for the Second GPT Header */ + /* recalculate the values for the Backup GPT Header */ val = le64_to_cpu(gpt_h-my_lba); gpt_h-my_lba = gpt_h-alternate_lba; gpt_h-alternate_lba = cpu_to_le64(val); diff --git a/doc/README.gpt b/doc/README.gpt index f822894..ec0156d 100644 --- a/doc/README.gpt +++ b/doc/README.gpt @@ -66,14 +66,14 @@ GPT brief explanation: |Partition n | | | -- - LBA -34|Entry 1|Entry 2| Entry 3| Entry 4| Secondary - -- (bkp) - LBA -33|Entries 5 - 128 | GPT + LBA -34|Entry 1|Entry 2| Entry 3| Entry 4| Backup + -- GPT + LBA -33|Entries 5 - 128 | | | | | LBA -2 | | -- - LBA -1 |Secondary GPT Header | + LBA -1 |Backup GPT Header| -- For a legacy reasons, GPT's LBA 0 sector has a MBR structure. It is called @@ -86,7 +86,7 @@ It is possible to define 128 linearly placed partition entries. LBA -1 means the last addressable block (in the mmc subsystem: dev_desc-lba - 1) -Primary/Secondary GPT header: +Primary/Backup GPT header: Offset SizeDescription @@ -115,7 +115,7 @@ IMPORTANT: GPT headers and partition entries are protected by CRC32 (the POSIX CRC32). -Primary GPT header and Secondary GPT header have swapped values of Current LBA +Primary GPT header and Backup GPT header have swapped values of Current LBA and Backup LBA and therefore different CRC32 check-sum. CRC32 for GPT headers (field CRC of header) are calculated up till @@ -125,7 +125,7 @@ CRC32 for partition entries (field CRC32 of partition array) is calculated for the whole array entry ( Number_of_partition_entries * sizeof(partition_entry_size (usually 128))) -Observe, how Secondary GPT is placed in the memory. It is NOT a mirror reflect +Observe, how Backup GPT is placed in the memory. It is NOT a mirror reflect of the Primary. Partition Entry Format: -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman
[U-Boot] [PATCH] arm: bcm281xx: Add CONFIG_SYS_GENERIC_BOARD
convert to generic board Signed-off-by: Steve Rae s...@broadcom.com --- include/configs/bcm28155_ap.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/configs/bcm28155_ap.h b/include/configs/bcm28155_ap.h index e93b855..bf09939 100644 --- a/include/configs/bcm28155_ap.h +++ b/include/configs/bcm28155_ap.h @@ -14,6 +14,7 @@ #define CONFIG_ARMV7 #define CONFIG_KONA #define CONFIG_SKIP_LOWLEVEL_INIT +#define CONFIG_SYS_GENERIC_BOARD /* * Memory configuration -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 0/3] EFI Partition handling
This series focusses on the EFI Partition handling and provides: - fixes to endianness issues - cleanup of the lbaint_t handling - cleanup of a type that requires u64 - improved clarification of the code by cleaning up the casting - verified support of CONFIG_SYS_64BIT_LBA Also, added new feature: - get_partition_info_efi_by_name(): find a partition entry by name Tested on ARMv7 and ARMv8. (not tested on Big Endian...) Steve Rae (3): disk: part_efi: resolve endianness issues disk: part_efi: clarify lbaint_t usage disk: part_efi: add get_partition_info_efi_by_name() disk/part_dos.c| 5 ++-- disk/part_efi.c| 73 +++--- fs/fat/fat_write.c | 2 +- include/part.h | 11 4 files changed, 62 insertions(+), 29 deletions(-) -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 3/3] disk: part_efi: add get_partition_info_efi_by_name()
Add function to find a GPT table entry by name. Tested on little endian ARMv7 and ARMv8 configurations Signed-off-by: Steve Rae s...@broadcom.com --- disk/part_efi.c | 21 - include/part.h | 11 +++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 78a3782..612f092 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -181,7 +181,7 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, UUID_STR_FORMAT_GUID); #endif - debug(%s: start 0x LBAF , size 0x LBAF , name %s, __func__, + debug(%s: start 0x LBAF , size 0x LBAF , name %s\n, __func__, info-start, info-size, info-name); /* Remember to free pte */ @@ -189,6 +189,25 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, return 0; } +int get_partition_info_efi_by_name(block_dev_desc_t *dev_desc, + const char *name, disk_partition_t *info) +{ + int ret; + int i; + for (i = 1; i GPT_ENTRY_NUMBERS; i++) { + ret = get_partition_info_efi(dev_desc, i, info); + if (ret != 0) { + /* no more entries in table */ + return -1; + } + if (strcmp(name, (const char *)info-name) == 0) { + /* matched */ + return 0; + } + } + return -2; +} + int test_part_efi(block_dev_desc_t * dev_desc) { ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, dev_desc-blksz); diff --git a/include/part.h b/include/part.h index f2c8c64..a496a4a 100644 --- a/include/part.h +++ b/include/part.h @@ -180,6 +180,17 @@ int test_part_amiga (block_dev_desc_t *dev_desc); #include part_efi.h /* disk/part_efi.c */ int get_partition_info_efi (block_dev_desc_t * dev_desc, int part, disk_partition_t *info); +/** + * get_partition_info_efi_by_name() - Find the specified GPT partition table entry + * + * @param dev_desc - block device descriptor + * @param gpt_name - the specified table entry name + * @param info - returns the disk partition info + * + * @return - '0' on match, '-1' on no match, otherwise error + */ +int get_partition_info_efi_by_name(block_dev_desc_t *dev_desc, + const char *name, disk_partition_t *info); void print_part_efi (block_dev_desc_t *dev_desc); int test_part_efi (block_dev_desc_t *dev_desc); -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 2/3] disk: part_efi: clarify lbaint_t usage
- update the comments regarding lbaint_t usage - cleanup casting of values related to the lbaint_t type - cleanup of a type that requires a u64 Tested on little endian ARMv7 and ARMv8 configurations Signed-off-by: Steve Rae s...@broadcom.com --- disk/part_dos.c| 5 +++-- disk/part_efi.c| 51 ++- fs/fat/fat_write.c | 2 +- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/disk/part_dos.c b/disk/part_dos.c index 05c3933..b0c3af5 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -199,8 +199,9 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part (part_num == which_part) (is_extended(pt-sys_ind) == 0)) { info-blksz = 512; - info-start = ext_part_sector + le32_to_int (pt-start4); - info-size = le32_to_int (pt-size4); + info-start = (lbaint_t)(ext_part_sector + + le32_to_int(pt-start4)); + info-size = (lbaint_t)le32_to_int(pt-size4); switch(dev_desc-if_type) { case IF_TYPE_IDE: case IF_TYPE_SATA: diff --git a/disk/part_efi.c b/disk/part_efi.c index 8c89740..78a3782 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -6,13 +6,9 @@ */ /* - * Problems with CONFIG_SYS_64BIT_LBA: - * - * struct disk_partition.start in include/part.h is sized as ulong. - * When CONFIG_SYS_64BIT_LBA is activated, lbaint_t changes from ulong to uint64_t. - * For now, it is cast back to ulong at assignment. - * - * This limits the maximum size of addressable storage to 2 Terra Bytes + * NOTE: + * when CONFIG_SYS_64BIT_LBA is not defined, lbaint_t is 32 bits; this + * limits the maximum size of addressable storage to 2 Terra Bytes */ #include asm/unaligned.h #include common.h @@ -43,8 +39,8 @@ static inline u32 efi_crc32(const void *buf, u32 len) static int pmbr_part_valid(struct partition *part); static int is_pmbr_valid(legacy_mbr * mbr); -static int is_gpt_valid(block_dev_desc_t * dev_desc, unsigned long long lba, - gpt_header * pgpt_head, gpt_entry ** pgpt_pte); +static int is_gpt_valid(block_dev_desc_t *dev_desc, u64 lba, + gpt_header *pgpt_head, gpt_entry **pgpt_pte); static gpt_entry *alloc_read_gpt_entries(block_dev_desc_t * dev_desc, gpt_header * pgpt_head); static int is_pte_valid(gpt_entry * pte); @@ -169,10 +165,10 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, return -1; } - /* The ulong casting limits the maximum disk size to 2 TB */ - info-start = (u64)le64_to_cpu(gpt_pte[part - 1].starting_lba); + /* The 'lbaint_t' casting may limit the maximum disk size to 2 TB */ + info-start = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].starting_lba); /* The ending LBA is inclusive, to calculate size, add 1 to it */ - info-size = ((u64)le64_to_cpu(gpt_pte[part - 1].ending_lba) + 1) + info-size = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].ending_lba) + 1 - info-start; info-blksz = dev_desc-blksz; @@ -279,12 +275,14 @@ int write_gpt_table(block_dev_desc_t *dev_desc, gpt_h-header_crc32 = cpu_to_le32(calc_crc32); if (dev_desc-block_write(dev_desc-dev, - le32_to_cpu(gpt_h-last_usable_lba) + 1, + (lbaint_t)le64_to_cpu(gpt_h-last_usable_lba) + + 1, pte_blk_cnt, gpt_e) != pte_blk_cnt) goto err; if (dev_desc-block_write(dev_desc-dev, - le32_to_cpu(gpt_h-my_lba), 1, gpt_h) != 1) + (lbaint_t)le64_to_cpu(gpt_h-my_lba), 1, + gpt_h) != 1) goto err; debug(GPT successfully written to block device!\n); @@ -298,9 +296,10 @@ int write_gpt_table(block_dev_desc_t *dev_desc, int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e, disk_partition_t *partitions, int parts) { - u32 offset = (u32)le32_to_cpu(gpt_h-first_usable_lba); - ulong start; - u32 last_usable_lba = (u32)le32_to_cpu(gpt_h-last_usable_lba); + lbaint_t offset = (lbaint_t)le64_to_cpu(gpt_h-first_usable_lba); + lbaint_t start; + lbaint_t last_usable_lba = (lbaint_t) + le64_to_cpu(gpt_h-last_usable_lba); int i, k; size_t efiname_len, dosname_len; #ifdef CONFIG_PARTITION_UUIDS @@ -364,7 +363,8 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e, gpt_e[i].partition_name[k] = (efi_char16_t)(partitions[i].name[k]); - debug(%s
[U-Boot] [PATCH 1/3] disk: part_efi: resolve endianness issues
Tested on little endian ARMv7 and ARMv8 configurations Signed-off-by: Steve Rae s...@broadcom.com --- disk/part_efi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index c74b7b9..8c89740 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -279,7 +279,7 @@ int write_gpt_table(block_dev_desc_t *dev_desc, gpt_h-header_crc32 = cpu_to_le32(calc_crc32); if (dev_desc-block_write(dev_desc-dev, - le32_to_cpu(gpt_h-last_usable_lba + 1), + le32_to_cpu(gpt_h-last_usable_lba) + 1, pte_blk_cnt, gpt_e) != pte_blk_cnt) goto err; @@ -300,6 +300,7 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e, { u32 offset = (u32)le32_to_cpu(gpt_h-first_usable_lba); ulong start; + u32 last_usable_lba = (u32)le32_to_cpu(gpt_h-last_usable_lba); int i, k; size_t efiname_len, dosname_len; #ifdef CONFIG_PARTITION_UUIDS @@ -321,7 +322,7 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e, gpt_e[i].starting_lba = cpu_to_le64(offset); offset += partitions[i].size; } - if (offset = gpt_h-last_usable_lba) { + if (offset = last_usable_lba) { printf(Partitions layout exceds disk size\n); return -1; } -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] i2c: kona: Resolve Kona I2C driver issue
- i2c mw command hangs (with some compilers) Signed-off-by: Steve Rae s...@broadcom.com --- drivers/i2c/kona_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/kona_i2c.c b/drivers/i2c/kona_i2c.c index 0b1715a..5eab338 100644 --- a/drivers/i2c/kona_i2c.c +++ b/drivers/i2c/kona_i2c.c @@ -663,7 +663,7 @@ static int kona_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr, static int kona_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr, int alen, uchar *buffer, int len) { - struct i2c_msg msg[0]; + struct i2c_msg msg[1]; unsigned char msgbuf0[64]; unsigned int i; struct bcm_kona_i2c_dev *dev = kona_get_dev(adap); -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] mmc: add wrappers for MMC block_{read, write, erase}
Each wrapper function: - switches to the specified physical partition, then - performs the original function, and then - switches back to the original physical partition where the physical partition (aka HW partition) is 0=User, 1=Boot1, 2=Boot2, etc. Signed-off-by: Steve Rae s...@broadcom.com --- based on a discussion: http://lists.denx.de/pipermail/u-boot/2014-April/178171.html The original calling code is (for example): mmc-block_dev.block_read(dev_num, start, blkcnt, buffer) Therefore, these wrappers use the following naming convention: mmc_block_read_hwpart(dev_num, part_num, start, blkcnt, buffer) hwpart comes from: Stephen Warren swar...@nvidia.com drivers/mmc/Makefile | 1 + drivers/mmc/mmc_hwpart.c | 75 include/mmc.h| 10 +++ 3 files changed, 86 insertions(+) create mode 100644 drivers/mmc/mmc_hwpart.c diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index 4c6ab9e..04f87f9 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o obj-$(CONFIG_FTSDC010) += ftsdc010_mci.o obj-$(CONFIG_FTSDC021) += ftsdc021_sdhci.o obj-$(CONFIG_GENERIC_MMC) += mmc.o +obj-$(CONFIG_GENERIC_MMC) += mmc_hwpart.o obj-$(CONFIG_GENERIC_ATMEL_MCI) += gen_atmel_mci.o obj-$(CONFIG_MMC_SPI) += mmc_spi.o obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o diff --git a/drivers/mmc/mmc_hwpart.c b/drivers/mmc/mmc_hwpart.c new file mode 100644 index 000..1c29f8f --- /dev/null +++ b/drivers/mmc/mmc_hwpart.c @@ -0,0 +1,75 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include mmc.h + +static int switch_part(struct mmc *mmc, + int dev, + unsigned int chk_part_num, + unsigned int part_num) +{ + if (!mmc) + return -1; + + if (mmc-part_num != chk_part_num) { + if (mmc_switch_part(dev, part_num)) { + printf(MMC partition switch to %d failed [dev=%d]\n, + part_num, dev); + return -1; + } + } + return 0; +} + +unsigned long mmc_block_read_hwpart(int dev, + unsigned int part_num, + lbaint_t start, + lbaint_t blkcnt, + void *buffer) +{ + unsigned long rc = 0; + struct mmc *mmc = find_mmc_device(dev); + + if (switch_part(mmc, dev, part_num, part_num)) + return 0; + rc = mmc-block_dev.block_read(dev, start, blkcnt, buffer); + switch_part(mmc, dev, part_num, mmc-part_num); + + return rc; +} + +unsigned long mmc_block_write_hwpart(int dev, +unsigned int part_num, +lbaint_t start, +lbaint_t blkcnt, +const void *buffer) +{ + unsigned long rc = 0; + struct mmc *mmc = find_mmc_device(dev); + + if (switch_part(mmc, dev, part_num, part_num)) + return 0; + rc = mmc-block_dev.block_write(dev, start, blkcnt, buffer); + switch_part(mmc, dev, part_num, mmc-part_num); + + return rc; +} + +unsigned long mmc_block_erase_hwpart(int dev, +unsigned int part_num, +lbaint_t start, +lbaint_t blkcnt) +{ + unsigned long rc = -1; + struct mmc *mmc = find_mmc_device(dev); + + if (switch_part(mmc, dev, part_num, part_num)) + return -1; + rc = mmc-block_dev.block_erase(dev, start, blkcnt); + switch_part(mmc, dev, part_num, mmc-part_num); + + return rc; +} diff --git a/include/mmc.h b/include/mmc.h index a3a100b..4871c08 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -347,6 +347,16 @@ int mmc_rpmb_read(struct mmc *mmc, void *addr, unsigned short blk, unsigned short cnt, unsigned char *key); int mmc_rpmb_write(struct mmc *mmc, void *addr, unsigned short blk, unsigned short cnt, unsigned char *key); +/* Functions to read/write/erase from the specified HW partition */ +unsigned long mmc_block_read_hwpart(int dev, unsigned int part_num, + lbaint_t start, lbaint_t blkcnt, + void *buffer); +unsigned long mmc_block_write_hwpart(int dev, unsigned int part_num, +lbaint_t start, lbaint_t blkcnt, +const void *buffer); + +unsigned long mmc_block_erase_hwpart(int dev, unsigned int part_num, +lbaint_t start, lbaint_t blkcnt); /** * Start device initialization and return immediately; it does not block on * polling OCR (operation
Re: [U-Boot] [PATCH] mmc: add wrappers for MMC block_{read, write, erase}
On 14-05-29 11:51 AM, Stephen Warren wrote: On 05/29/2014 11:58 AM, Steve Rae wrote: Hi, Stephen On 14-05-29 09:25 AM, Stephen Warren wrote: On 05/28/2014 04:15 PM, Steve Rae wrote: Each wrapper function: - switches to the specified physical partition, then - performs the original function, and then - switches back to the original physical partition where the physical partition (aka HW partition) is 0=User, 1=Boot1, 2=Boot2, etc. This feels wrong; why wouldn't mmc_get_dev() return a block_dev_desc_t containing block_read/block_write functions that do the HW partition switching. That way, this is all completely hidden, and all client code only knows about block devices, rather than having to know about MMC-specific mmc_block_read/write/erase_hwpart() functions. This goes back to the initial discussion on this mailing list (which was never resolved): http://lists.denx.de/pipermail/u-boot/2014-April/178171.html This issue is that the three callback functions defined in 'block_desc_t' do not accept the partition number as an argument. It was suggested that we could overwrite those functions; but the partition number still needs to be passed in by: (1) overloading the int dev_num argument, or (2) adding another argument to the callback functions I assumed that neither of these was acceptable, so I have proposed these wrappers... Can't the data simply be stored in the block_desc_t itself? If I understand this suggestion, are you proposing: - add an unsigned int specified_hw_part to the block_desc_t Then the usage would become: mmc-block_dev.specified_hw_part = 1; /* specify Boot1 partition */ mmc-block_dev.block_read(0, 0, 1, buf); /* read first block (from Boot1 partition) */ mmc-block_dev.specified_hw_part = 0; /* specify User partition */ mmc-block_dev.block_read(0, 0, 1, buf); /* read first block (from User partition) */ I don't think this is a good idea... Please clarify! Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: add wrappers for MMC block_{read, write, erase}
On 14-05-29 01:30 PM, Stephen Warren wrote: On 05/29/2014 01:44 PM, Steve Rae wrote: On 14-05-29 11:51 AM, Stephen Warren wrote: On 05/29/2014 11:58 AM, Steve Rae wrote: Hi, Stephen On 14-05-29 09:25 AM, Stephen Warren wrote: On 05/28/2014 04:15 PM, Steve Rae wrote: Each wrapper function: - switches to the specified physical partition, then - performs the original function, and then - switches back to the original physical partition where the physical partition (aka HW partition) is 0=User, 1=Boot1, 2=Boot2, etc. This feels wrong; why wouldn't mmc_get_dev() return a block_dev_desc_t containing block_read/block_write functions that do the HW partition switching. That way, this is all completely hidden, and all client code only knows about block devices, rather than having to know about MMC-specific mmc_block_read/write/erase_hwpart() functions. This goes back to the initial discussion on this mailing list (which was never resolved): http://lists.denx.de/pipermail/u-boot/2014-April/178171.html This issue is that the three callback functions defined in 'block_desc_t' do not accept the partition number as an argument. It was suggested that we could overwrite those functions; but the partition number still needs to be passed in by: (1) overloading the int dev_num argument, or (2) adding another argument to the callback functions I assumed that neither of these was acceptable, so I have proposed these wrappers... Can't the data simply be stored in the block_desc_t itself? If I understand this suggestion, are you proposing: - add an unsigned int specified_hw_part to the block_desc_t Yes. Then the usage would become: mmc-block_dev.specified_hw_part = 1; /* specify Boot1 partition */ The only code that would need to assign that field is disk/part.c:get_dev() or something called from it. that is the function that's responsible for looking up or creating the block_dev_desc_t handle for a user-specified storage device, so it's exactly the place for this kind of object constructor code to execute. Sorry, but now I am totally confused... Doesn't the block_dev_desc_t contain the device information (not the partition information)? Isn't it only created once (effectively the first time mmc_init is called on that device)? So when I'm doing a block_read from the Boot1 partition, followed by a block_read from the User partition, I don't expect to see a constructor being executed (from a get_dev() or anything else...) mmc-block_dev.block_read(0, 0, 1, buf); /* read first block (from Boot1 partition) */ Yes. mmc-block_dev.specified_hw_part = 0; /* specify User partition */ mmc-block_dev.block_read(0, 0, 1, buf); /* read first block (from User partition) */ I don't think this is a good idea... Oh, but it is:-) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: add wrappers for MMC block_{read, write, erase}
Hi, Stephen On 14-05-29 09:25 AM, Stephen Warren wrote: On 05/28/2014 04:15 PM, Steve Rae wrote: Each wrapper function: - switches to the specified physical partition, then - performs the original function, and then - switches back to the original physical partition where the physical partition (aka HW partition) is 0=User, 1=Boot1, 2=Boot2, etc. This feels wrong; why wouldn't mmc_get_dev() return a block_dev_desc_t containing block_read/block_write functions that do the HW partition switching. That way, this is all completely hidden, and all client code only knows about block devices, rather than having to know about MMC-specific mmc_block_read/write/erase_hwpart() functions. This goes back to the initial discussion on this mailing list (which was never resolved): http://lists.denx.de/pipermail/u-boot/2014-April/178171.html This issue is that the three callback functions defined in 'block_desc_t' do not accept the partition number as an argument. It was suggested that we could overwrite those functions; but the partition number still needs to be passed in by: (1) overloading the int dev_num argument, or (2) adding another argument to the callback functions I assumed that neither of these was acceptable, so I have proposed these wrappers... Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: add wrappers for MMC block_{read, write, erase}
Hi, Jaehoon On 14-05-29 12:03 AM, Jaehoon Chung wrote: Hi, Steve. On 05/29/2014 07:15 AM, Steve Rae wrote: Each wrapper function: - switches to the specified physical partition, then - performs the original function, and then - switches back to the original physical partition where the physical partition (aka HW partition) is 0=User, 1=Boot1, 2=Boot2, etc. Signed-off-by: Steve Rae s...@broadcom.com --- based on a discussion: http://lists.denx.de/pipermail/u-boot/2014-April/178171.html The original calling code is (for example): mmc-block_dev.block_read(dev_num, start, blkcnt, buffer) Therefore, these wrappers use the following naming convention: mmc_block_read_hwpart(dev_num, part_num, start, blkcnt, buffer) hwpart comes from: Stephen Warren swar...@nvidia.com drivers/mmc/Makefile | 1 + drivers/mmc/mmc_hwpart.c | 75 include/mmc.h| 10 +++ 3 files changed, 86 insertions(+) create mode 100644 drivers/mmc/mmc_hwpart.c diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index 4c6ab9e..04f87f9 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o obj-$(CONFIG_FTSDC010) += ftsdc010_mci.o obj-$(CONFIG_FTSDC021) += ftsdc021_sdhci.o obj-$(CONFIG_GENERIC_MMC) += mmc.o +obj-$(CONFIG_GENERIC_MMC) += mmc_hwpart.o obj-$(CONFIG_GENERIC_ATMEL_MCI) += gen_atmel_mci.o obj-$(CONFIG_MMC_SPI) += mmc_spi.o obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o diff --git a/drivers/mmc/mmc_hwpart.c b/drivers/mmc/mmc_hwpart.c new file mode 100644 index 000..1c29f8f --- /dev/null +++ b/drivers/mmc/mmc_hwpart.c @@ -0,0 +1,75 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include mmc.h + +static int switch_part(struct mmc *mmc, + int dev, + unsigned int chk_part_num, + unsigned int part_num) +{ + if (!mmc) + return -1; + + if (mmc-part_num != chk_part_num) { + if (mmc_switch_part(dev, part_num)) { + printf(MMC partition switch to %d failed [dev=%d]\n, + part_num, dev); + return -1; + } + } + return 0; +} + +unsigned long mmc_block_read_hwpart(int dev, + unsigned int part_num, + lbaint_t start, + lbaint_t blkcnt, + void *buffer) +{ + unsigned long rc = 0; + struct mmc *mmc = find_mmc_device(dev); + + if (switch_part(mmc, dev, part_num, part_num)) + return 0; return 0 is right? The original function returns 0 on error (and blkcnt on success) + rc = mmc-block_dev.block_read(dev, start, blkcnt, buffer); + switch_part(mmc, dev, part_num, mmc-part_num); Didn't need to check whether switched partition or not? And if block_read is failed? The calling function needs to handle the situation where block_read failed... If switching back fails (after the previous switching to was successful, then there is not much we can do. Except that we should update mmc-part-num to point to the current partition - I'll add that for v2 (and in the next functions too) + + return rc; +} + +unsigned long mmc_block_write_hwpart(int dev, +unsigned int part_num, +lbaint_t start, +lbaint_t blkcnt, +const void *buffer) +{ + unsigned long rc = 0; + struct mmc *mmc = find_mmc_device(dev); + + if (switch_part(mmc, dev, part_num, part_num)) + return 0; ditto.. The original function returns 0 on error (and blkcnt on success) + rc = mmc-block_dev.block_write(dev, start, blkcnt, buffer); + switch_part(mmc, dev, part_num, mmc-part_num); + + return rc; +} + +unsigned long mmc_block_erase_hwpart(int dev, +unsigned int part_num, +lbaint_t start, +lbaint_t blkcnt) +{ + unsigned long rc = -1; Why did you assign to -1? this is the default error condition -- but it is not needed to be initialized in this function (or the others) - will fix in v2 + struct mmc *mmc = find_mmc_device(dev); +/blk_r + if (switch_part(mmc, dev, part_num, part_num)) + return -1; At here, return -1? The original function returns -1 on error (0 on timeout, otherwise, number of blocks erased) Best Regards, Jaehoon Chung + rc = mmc-block_dev.block_erase(dev, start, blkcnt); + switch_part(mmc, dev, part_num, mmc-part_num); + + return rc;otherwise +} diff --git a/include/mmc.h b/include/mmc.h index a3a100b..4871c08
Re: [U-Boot] [PATCH] mmc: add wrappers for MMC block_{read, write, erase}
On 14-05-30 08:58 AM, Stephen Warren wrote: On 05/29/2014 04:03 PM, Steve Rae wrote: On 14-05-29 01:30 PM, Stephen Warren wrote: On 05/29/2014 01:44 PM, Steve Rae wrote: On 14-05-29 11:51 AM, Stephen Warren wrote: On 05/29/2014 11:58 AM, Steve Rae wrote: Hi, Stephen On 14-05-29 09:25 AM, Stephen Warren wrote: On 05/28/2014 04:15 PM, Steve Rae wrote: Each wrapper function: - switches to the specified physical partition, then - performs the original function, and then - switches back to the original physical partition where the physical partition (aka HW partition) is 0=User, 1=Boot1, 2=Boot2, etc. This feels wrong; why wouldn't mmc_get_dev() return a block_dev_desc_t containing block_read/block_write functions that do the HW partition switching. That way, this is all completely hidden, and all client code only knows about block devices, rather than having to know about MMC-specific mmc_block_read/write/erase_hwpart() functions. This goes back to the initial discussion on this mailing list (which was never resolved): http://lists.denx.de/pipermail/u-boot/2014-April/178171.html This issue is that the three callback functions defined in 'block_desc_t' do not accept the partition number as an argument. It was suggested that we could overwrite those functions; but the partition number still needs to be passed in by: (1) overloading the int dev_num argument, or (2) adding another argument to the callback functions I assumed that neither of these was acceptable, so I have proposed these wrappers... Can't the data simply be stored in the block_desc_t itself? If I understand this suggestion, are you proposing: - add an unsigned int specified_hw_part to the block_desc_t Yes. Then the usage would become: mmc-block_dev.specified_hw_part = 1; /* specify Boot1 partition */ The only code that would need to assign that field is disk/part.c:get_dev() or something called from it. that is the function that's responsible for looking up or creating the block_dev_desc_t handle for a user-specified storage device, so it's exactly the place for this kind of object constructor code to execute. Sorry, but now I am totally confused... Doesn't the block_dev_desc_t contain the device information (not the partition information)? The eMMC HW partitions are separate block devices. So, get_device_and_partition() returns a block device that represents one of: a) eMMC boot0 HW partition b) eMMC boot1 HW partition c) eMMC main data/user area HW partition These HW partitions are entirely separate from (MBR/GPT) SW partitions, even though both are referred to as partitions. That's why I call the former HW partitions rather than partitions. Agree -- and sometimes called physical partitions Isn't it only created once (effectively the first time mmc_init is called on that device)? The block_dev_desc_t initialization/creation does call mmc_init, yes... So when I'm doing a block_read from the Boot1 partition, followed by a block_read from the User partition, I don't expect to see a constructor being executed (from a get_dev() or anything else...) Most U-Boot commands take a single device name (e.g. mmc 0) and act just on that. If you want to do something on different block devices, you'd need to run separate commands, or perhaps have one command take a list of devices, and initialize each one in turn. Agree - and can switch to different HW partitions with the existing mmc dev 0 1 command What code are you looking at that handles multiple devices sequentially under program control rather than user command control? Cannot go into too much detail here (yet) -- but imagine the situation where: - lookup the GPT partition name (in User, Boot1, Boot2) - do a block_write to the desired location... So after discussing with a colleague, we would propose the following. Does this implement what you were proposing?: Usage (example): mmc-part_num_next_block_op = 1; /* specify Boot1 partition */ mmc-block_dev.block_read(0, 0, 1, buf); /* read first block from Boot1 partition */ mmc-part_num_next_block_op = 0; /* specify User partition */ mmc-block_dev.block_read(0, 0, 1, buf); /* read first block from User partition */ Implementation: (1) The mmc-part_num_next_block_op needs to be initialized to -1. (2) Each existing mmc_{bread,bwrite,berase} function needs modification: if 0 = mmc-part_num_next_block_op mmc-part_num != mmc-part_num_next_block_op switch if switch failed mmc-part_num_next_block_op = -1 return error [... the original code ...] if 0 = mmc-part_num_next_block_op mmc-part_num != mmc-part_num_next_block_op switch_back if switch_back failed mmc-part_num = mmc-part_num_next_block_op mmc-part_num_next_block_op = -1 Many Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: add wrappers for MMC block_{read, write, erase}
On 14-05-30 10:07 AM, Stephen Warren wrote: On 05/30/2014 10:56 AM, Steve Rae wrote: On 14-05-30 08:58 AM, Stephen Warren wrote: ... What code are you looking at that handles multiple devices sequentially under program control rather than user command control? Cannot go into too much detail here (yet) -- but imagine the situation where: - lookup the GPT partition name (in User, Boot1, Boot2) - do a block_write to the desired location... So this is all to support some non-upstream code that you can't discuss? That doesn't sound good... So after discussing with a colleague, we would propose the following. Does this implement what you were proposing?: Usage (example): mmc-part_num_next_block_op = 1; /* specify Boot1 partition */ mmc-block_dev.block_read(0, 0, 1, buf); /* read first block from Boot1 partition */ mmc-part_num_next_block_op = 0; /* specify User partition */ mmc-block_dev.block_read(0, 0, 1, buf); /* read first block from User partition */ No. I would propose: get_device(mmc, 0.1, bdev_boot1); bdev_boot1-block_read(...); get_device(mmc, 0.0, bdev_user); bdev_user-block_read(...); That way, nothing needs to change in block_dev_desc_t, get_device(), etc. OK -- I can make this work... Therefore, abandoning this change. Many Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] arm: bcm281xx: Add CONFIG_SYS_GENERIC_BOARD
On 14-06-09 12:16 AM, Albert ARIBAUD wrote: Hi Steve, On Wed, 14 May 2014 14:18:09 -0700, Steve Raes...@broadcom.com wrote: convert to generic board Signed-off-by: Steve Raes...@broadcom.com --- Has this been tested on hardware, or just build-tested? This generic board change has been tested on hardware. Thanks, Steve Amicalement, -- Albert. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] arm: Allow u-boot to run from offset base address
On 14-06-09 03:23 AM, Albert ARIBAUD wrote: Hi Darwin, On Mon, 2 Jun 2014 17:37:25 -0700, Darwin Rambo dra...@broadcom.com wrote: On 14-06-02 12:26 AM, Albert ARIBAUD wrote: Hi Darwin, On Mon, 26 May 2014 09:11:35 -0700, Darwin Rambo dra...@broadcom.com wrote: Hi Albert, The previous stage bootloader (which I had no control over) wanted it's header to be aligned to a 512 byte MMC block boundary, presumably since this allowed DMA operations without copy/shifting. At the same time, I didn't want to hack a header into start.S because I didn't want to carry another downstream patch. So I investigated if I could shift u-boot's base address as a feature that would allow an aligned header to be used without the start.S patch. I know that a custom header patch to start.S would work, and that a header plus padding will also work. But I found out that you can align the base on certain smaller offsets if you keep the relocation offset at nice boundaries like 0x1000 and if the relocation offset is a multiple of the maximum alignment requirements of the image. The original patch I submitted didn't handle an end condition properly, was ARM64-specific (wasn't tested on other architectures), and because the patch was NAK'd, I didn't bother to submit a v2 patch and consider the idea to be dead. I'm happy to abandon the patch. I hope this helps. Thanks. If I understand correctly, your target has a requirement for storing the image on a 512-byte boundary. But how does this affect the loading of the image into RAM, where the requirement is only that the vectors table be 32-bytes aligned? I mean, if you store the image in MMC at offset 0x200 (thus satisfying the 512-byte boundary requirement) and load it to, say, offset 0x10020 in RAM, how is it a problem for your target? If my example above inadequately represents the issue, then can you please provide a similar but adequate example, a failure case scenario, so that I can hve a correct understanding of the problem? Hi Albert, The constraints I have that I can't change, are that - the 32 byte header is postprocessed and prepended to the image after the build is complete - the header is at a 512 byte alignment in MMC - the header and image are copied to SDRAM to an alignment like 0x8800. Thus the u-boot image is linked at and starts at 0x8820. - the vectors need to be 0x800 aligned for armv8 (.align 11 directive) So far, so good -- I understand that the link-time location of the vectors table is incorrect. So the failure case is that when the relocation happens, it relocates to a 0x1000 alignment, say something like 0xa000. The relocation offset is not a multiple of 0x1000 (0xa000 - 0x8820) and the relocation fails. What does relocation fails mean exactly, i.e., where and how exactly does the relocation code behave differently from expected? I'm asking because I don't understand why the relocation offset should be a multiple of 0x1000. Adjusting the relocation offset to a multiple of 0x1000 (by making the relocation address end in 0xN020) fixes the issues and allows u-boot to relocate and run from this address without failing. I hope this helps explain it a bit better. I do understand, however, that if the relocation offset must indeed be a multiple of 0x1000, then obviously the vectors table will end up as misaligned as it was before relocation. Also, personally I would like it if the vectors table was always aligned as it should, and there are at least three other boards which require a prefix/header before their vectors table, as Masahiro (cc:) indicated recently, so that makes the problem a generic one: how to properly integrate a header in-image (as opposed to an out-of-image one, which is just a matter of doing a 'cat', so to speak. Therefore I'd like a generic solution to this, where the header is prepended *and* aligned properly without breaking the start symbol alignment constraints. This /might/ be possible by cleverly adding a '.header' or '.signature' section to the linker script, possibly doing a two-stage link; but this should not require the source code to contain ad hoc relocation tricks. Let me tinker with it in the next few days; I'll try and come up with a clean and generic solution to this in-code header question. Thanks again for your explanation! Best regards, Darwin Amicalement, Perhaps an oversimplified example of the current code would help to explain this better: scenario #1: CONFIG_SYS_TEXT_BASE0x8800 vectors: .align 11 /* exception vectors need to be on a 0x800 byte boundary */ compile/linker produces (before relocation): _start symbol is at0x8800 vectors symbol is at0x88000800 the relocation offset is: 0x77f9b000 therefore, after relocation: _start symbol is at0xfff9b000 (0x8800+0xfff9b000) vectors symbol is at0xfff9b800 (0x88000800+0x77f9b000) scenario #2: CONFIG_SYS_TEXT_BASE
Re: [U-Boot] [PATCH] arm: Allow u-boot to run from offset base address
On 14-06-09 10:16 PM, Albert ARIBAUD wrote: Hi Steve, (sorry for the duplicate) On Mon, 9 Jun 2014 13:45:50 -0700, Steve Rae s...@broadcom.com wrote: On 14-06-09 03:23 AM, Albert ARIBAUD wrote: Hi Darwin, On Mon, 2 Jun 2014 17:37:25 -0700, Darwin Rambo dra...@broadcom.com wrote: On 14-06-02 12:26 AM, Albert ARIBAUD wrote: Hi Darwin, On Mon, 26 May 2014 09:11:35 -0700, Darwin Rambo dra...@broadcom.com wrote: Hi Albert, The previous stage bootloader (which I had no control over) wanted it's header to be aligned to a 512 byte MMC block boundary, presumably since this allowed DMA operations without copy/shifting. At the same time, I didn't want to hack a header into start.S because I didn't want to carry another downstream patch. So I investigated if I could shift u-boot's base address as a feature that would allow an aligned header to be used without the start.S patch. I know that a custom header patch to start.S would work, and that a header plus padding will also work. But I found out that you can align the base on certain smaller offsets if you keep the relocation offset at nice boundaries like 0x1000 and if the relocation offset is a multiple of the maximum alignment requirements of the image. The original patch I submitted didn't handle an end condition properly, was ARM64-specific (wasn't tested on other architectures), and because the patch was NAK'd, I didn't bother to submit a v2 patch and consider the idea to be dead. I'm happy to abandon the patch. I hope this helps. Thanks. If I understand correctly, your target has a requirement for storing the image on a 512-byte boundary. But how does this affect the loading of the image into RAM, where the requirement is only that the vectors table be 32-bytes aligned? I mean, if you store the image in MMC at offset 0x200 (thus satisfying the 512-byte boundary requirement) and load it to, say, offset 0x10020 in RAM, how is it a problem for your target? If my example above inadequately represents the issue, then can you please provide a similar but adequate example, a failure case scenario, so that I can hve a correct understanding of the problem? Hi Albert, The constraints I have that I can't change, are that - the 32 byte header is postprocessed and prepended to the image after the build is complete - the header is at a 512 byte alignment in MMC - the header and image are copied to SDRAM to an alignment like 0x8800. Thus the u-boot image is linked at and starts at 0x8820. - the vectors need to be 0x800 aligned for armv8 (.align 11 directive) So far, so good -- I understand that the link-time location of the vectors table is incorrect. So the failure case is that when the relocation happens, it relocates to a 0x1000 alignment, say something like 0xa000. The relocation offset is not a multiple of 0x1000 (0xa000 - 0x8820) and the relocation fails. What does relocation fails mean exactly, i.e., where and how exactly does the relocation code behave differently from expected? I'm asking because I don't understand why the relocation offset should be a multiple of 0x1000. Adjusting the relocation offset to a multiple of 0x1000 (by making the relocation address end in 0xN020) fixes the issues and allows u-boot to relocate and run from this address without failing. I hope this helps explain it a bit better. I do understand, however, that if the relocation offset must indeed be a multiple of 0x1000, then obviously the vectors table will end up as misaligned as it was before relocation. Also, personally I would like it if the vectors table was always aligned as it should, and there are at least three other boards which require a prefix/header before their vectors table, as Masahiro (cc:) indicated recently, so that makes the problem a generic one: how to properly integrate a header in-image (as opposed to an out-of-image one, which is just a matter of doing a 'cat', so to speak. Therefore I'd like a generic solution to this, where the header is prepended *and* aligned properly without breaking the start symbol alignment constraints. This /might/ be possible by cleverly adding a '.header' or '.signature' section to the linker script, possibly doing a two-stage link; but this should not require the source code to contain ad hoc relocation tricks. Let me tinker with it in the next few days; I'll try and come up with a clean and generic solution to this in-code header question. Thanks again for your explanation! Best regards, Darwin Amicalement, Perhaps an oversimplified example of the current code would help to explain this better: scenario #1: CONFIG_SYS_TEXT_BASE0x8800 vectors:.align 11 /* exception vectors need to be on a 0x800 byte boundary */ compile/linker produces (before relocation): _start symbol is at0x8800 vectors symbol is at0x88000800 the relocation offset is: 0x77f9b000 therefore, after relocation: _start symbol
Re: [U-Boot] [PATCH] arm: Allow u-boot to run from offset base address
On 14-06-10 11:13 AM, Wolfgang Denk wrote: Dear Steve, In message 539746c4.9040...@broadcom.com you wrote: There could be many reasons why the CONFIG_SYS_TEXT_BASE is not aligned on a 0x1000 byte boundary (Darwin has attempted to document his particular use-case...) We should be more precise here and ask for any _good_ reasons. I can think of many good reasons to keep the text base aligned. As for the reasons to use an unaligned address that were brought up here, I still think that it would have been better to use an aligned taxe base and do the rest with a customized linker script. But we think that the solution to support this is relatively straightforward: (1) after determining the relocation address (which will be on a 0x1000 byte boundary), (2) add CONFIG_SYS_TEXT_BASE % 4096 to that relocation address (which effectively makes the relocation offset a multiple of 0x1000 too...) So, in the scenario #1, (CONFIG_SYS_TEXT_BASE % 4096) = 0, so this algorithm changes nothing. And in scenario #2, (CONFIG_SYS_TEXT_BASE % 4096) = 0x20, therefore, we would now get the following: the relocation offset is: 0x77f9b000 therefore, after relocation: _start symbol is at0xfff9b020 (0x8820+0x77f9b000) vectors symbol is at0xfff9b800 (0x88000800+0x77f9b000) I still cannot understand why _start and CONFIG_SYS_TEXT_BASE would have to be the same. There is no such requirement. What exactly prevents you from assigning _start a location at offset 0x20 to the start of the text segment, i. e. CONFIG_SYS_TEXT_BASE ? Wolfgang et al. I agree that they do not need to be the same... So our issue is that basically for every ARMv7 board in the company, we are currently maintaining our own modified/customized version of arch/arm/cpu/armv7/start.S in order to add the appropriate 32 byte header... And we could choose to do it using other methods, but they all require us to maintain a customized version of linker scripts, or some other code, or The request here is that with the addition of some relatively straightforward (upstreamed) code, then this can be handled automatically by a post-processing step and we would be able to use a pristine version of the upstreamed code... Our desire is to get this into the beginnings of the ARMv8 boards, so that we can avoid the maintenance issues we have with the current ARMv7 boards. We appreciate your consideration of this request. Thanks, Steve Then everything should be still the same for you, and no voodoo coding would be needed. (3) HOWEVER, shifting the address UP may cause the end of the relocated code to run past the end of the available memory... So we could: This problem is void if you just use a poperly aligned text base in combination with a prope start.S resp. linker script to make sure _start is where you want it. I trust that everyone will find this explanation acceptable... No, I do not see a good reason to add such code. Best regards, Wolfgang Denk ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] arm: Allow u-boot to run from offset base address
On 14-06-10 01:35 PM, Wolfgang Denk wrote: Dear Steve, In message 53975ec2.1080...@broadcom.com you wrote: I still cannot understand why _start and CONFIG_SYS_TEXT_BASE would have to be the same. There is no such requirement. What exactly prevents you from assigning _start a location at offset 0x20 to the start of the text segment, i. e. CONFIG_SYS_TEXT_BASE ? Wolfgang et al. I agree that they do not need to be the same... So our issue is that basically for every ARMv7 board in the company, we are currently maintaining our own modified/customized version of arch/arm/cpu/armv7/start.S in order to add the appropriate 32 byte header... There should be more clever ways to implement this. If nothing else comes to mind, an #ifdef in arch/arm/cpu/armv7/start.S should be sufficient to condistionally insert / adjust any offset that might be needed for a specific board. And we could choose to do it using other methods, but they all require us to maintain a customized version of linker scripts, or some other code, or ... or a CONFIG setting in your board config file resp. your board's defconfig. The request here is that with the addition of some relatively straightforward (upstreamed) code, then this can be handled automatically by a post-processing step and we would be able to use a pristine version of the upstreamed code... I'm sorry, but I disagree especially on the straightforward part. Also, I see no reason to make the existing code unnecessarily complex, and add more disadvantages (like increased meory footprint etc.) when the same purpose can be implemented without adding any special code at all. Our desire is to get this into the beginnings of the ARMv8 boards, so that we can avoid the maintenance issues we have with the current ARMv7 boards. We appreciate your consideration of this request. These are two different things: implementing a clean and easy way to support a necessary feature is one thing; to do it in the suggested way by adding code where none is needed is another thing. I'm all for adding support for any features that are useful, even if only for a single user, as long as they don't hurt other users. All I'm asking is to chose another way to implement this feature. So far, I did not see any arguments that my alternative proposals would cause any problems to you? OK - I think that one of the alternate proposals would be to conditionally reserve a 32 byte block prior to the _start symbol (in arch/arm/cpu/armv8/start.S) which would then be filled in by a post-processing step... This could be implemented by: diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S index 4b11aa4..8fd72f1 100644 --- a/arch/arm/cpu/armv8/start.S +++ b/arch/arm/cpu/armv8/start.S @@ -18,6 +18,10 @@ * */ +#ifdef CONFIG_CUSTOM_HEADER_RESERVED_BYTES + .skip CONFIG_CUSTOM_HEADER_RESERVED_BYTES +#endif + .globl _start _start: b reset And then in our board config file: #define CONFIG_CUSTOM_HEADER_RESERVED_BYTES 32 And we could implement a similar algorithm in the armv7/start.S as you stated above. Are we understanding your proposals properly? Would this be an acceptable solution? Thanks, Steve Best regards, Wolfgang Denk ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] arm: Allow u-boot to run from offset base address
On 14-06-10 02:20 PM, Albert ARIBAUD wrote: Hi Steve, On Tue, 10 Jun 2014 12:38:42 -0700, Steve Rae s...@broadcom.com wrote: On 14-06-10 11:13 AM, Wolfgang Denk wrote: Dear Steve, In message 539746c4.9040...@broadcom.com you wrote: There could be many reasons why the CONFIG_SYS_TEXT_BASE is not aligned on a 0x1000 byte boundary (Darwin has attempted to document his particular use-case...) We should be more precise here and ask for any _good_ reasons. I can think of many good reasons to keep the text base aligned. As for the reasons to use an unaligned address that were brought up here, I still think that it would have been better to use an aligned taxe base and do the rest with a customized linker script. But we think that the solution to support this is relatively straightforward: (1) after determining the relocation address (which will be on a 0x1000 byte boundary), (2) add CONFIG_SYS_TEXT_BASE % 4096 to that relocation address (which effectively makes the relocation offset a multiple of 0x1000 too...) So, in the scenario #1, (CONFIG_SYS_TEXT_BASE % 4096) = 0, so this algorithm changes nothing. And in scenario #2, (CONFIG_SYS_TEXT_BASE % 4096) = 0x20, therefore, we would now get the following: the relocation offset is: 0x77f9b000 therefore, after relocation: _start symbol is at0xfff9b020 (0x8820+0x77f9b000) vectors symbol is at0xfff9b800 (0x88000800+0x77f9b000) I still cannot understand why _start and CONFIG_SYS_TEXT_BASE would have to be the same. There is no such requirement. What exactly prevents you from assigning _start a location at offset 0x20 to the start of the text segment, i. e. CONFIG_SYS_TEXT_BASE ? Wolfgang et al. I agree that they do not need to be the same... So our issue is that basically for every ARMv7 board in the company, we are currently maintaining our own modified/customized version of arch/arm/cpu/armv7/start.S in order to add the appropriate 32 byte header... That is not a good approach -- and I should know, as there are boards out there which already insist on having a header (mind you, a simple 4-byte constant) in start.S, and I am already trying to tackle this out of start.S. Your 32-byte header should not be in start.S, it should be linked in before start.o in the linker script. Then you would only have one start.S file and as many headers as you require. And we could choose to do it using other methods, but they all require us to maintain a customized version of linker scripts, or some other code, or Not necessarily. You'll need to configure your target, that's sure, because I guess different targets will have different (values in the bytes of their) headers, but you don't need to have different start.S files. The request here is that with the addition of some relatively straightforward (upstreamed) code, then this can be handled automatically by a post-processing step and we would be able to use a pristine version of the upstreamed code... Our desire is to get this into the beginnings of the ARMv8 boards, so that we can avoid the maintenance issues we have with the current ARMv7 boards. We appreciate your consideration of this request. Thanks, Steve I (believe I) understand the problem, and I am discussing here because I too want it solved. On the one hand I do agree with Wolfgang here: No, I do not see a good reason to add such code. ... because I don't want to allow a feature that is designed to counter a problem; but on the other hand I want the problem fixed. So Darwin, in order to find a satisfactory solution, let me try to recap the situation and then ask a few questions. Recap: 1. A typical ARM binary image is linked to a base address, defined by preprocessor macro (aka U-Boot config option) CONFIG_SYS_TEXT_BASE. OK 2. A typical ARM target defines CONFIG_SYS_TEXT_BASE so that the image, and especially its exception vectors table, is properly aligned upon loading the image in RAM. Nope, the vectors respect the .align directive independent of the CONFIG_SYS_TEXT_BASE setting. 3. When the ARM image relocates itself, it does so to a destination address which is computed so that the image and its vectors table are still properly aligned after relocation. Almost: the computed destination address is aligned on a 0x1000 byte boundary, so if the CONFIG_SYS_TEXT_BASE is also a multiple of 0x1000 bytes, then this statement is true. 4. Some targets require that the image stored in MMC be prepended with a 32-byte header (and aligned to a sector-related boundary). OK 5. For some targets (if not all) the header is not separate from the image, i.e., it will also be copied from MMC to RAM. Such headers must be prepended at the link stage or earlier, so that the link-time and run-time values of all image symbols are consistent. Yes - copied from MMC to RAM, but not really necessary to do this at link stage or earlier (we do
Re: [U-Boot] [PATCH] arm: Allow u-boot to run from offset base address
On 14-06-10 11:45 PM, Albert ARIBAUD wrote: Hi Wolfgang, On Wed, 11 Jun 2014 06:49:28 +0200, Wolfgang Denk w...@denx.de wrote: Dear Steve, In message 53979199.5010...@broadcom.com you wrote: OK - I think that one of the alternate proposals would be to conditionally reserve a 32 byte block prior to the _start symbol (in arch/arm/cpu/armv8/start.S) which would then be filled in by a post-processing step... This could be implemented by: Yes, that illustrates the idea. However, this implementation suffers from the use of an #ifdef where none is actually needed. Instead, you can create your own source file which defines the header; this could be then even in it's own segment, say: your_header.c: struct your_header { u_int32[8]; } your_header __attribute__ ((__section__ (.your_hdr))); All that is needed then is to make the linker place this segment in front of the text segment. This avoids an ugly #ifdef, and also modifications in the common code. Agreed and seconded. Plus, using a dedicated 'header' section and a separate C source file for the header makes it automatic that if no input 'header' section were provided then no output 'header' section would be emitted; IOW, we would not need two different linker scripts, a single one would be useable for both 'headerless' and 'headerful' image types. Also, the alignment constraint should be configurable. Best regards, Wolfgang Denk Amicalement, Albert, Wolfgang, et al. I didn't know about the automatic handling of conditional sections in the linker script file - Thanks!!! So if I add a your_header.c as above, then (1) I need to modify arch/arm/cpu/armv8/u-boot.lds: . = 0x; + . = ALIGN(8); + .your_hdr : { + KEEP(*(.your_hdr*)); + } + . = ALIGN(8); .text : { (2) then (I believe) I need to modify the Makefile to define the start address of this new section: +LDFLAGS_u-boot += --section-start=.your_hdr=CONFIG_YOUR_HEADER_ADDR (3) and (I believe) I need to modify the OBJCOPYFLAGS (somewhere) in order to include this new section in the u-boot.bin: +OBJCOPYFLAGS += -j .your_hdr (... I don't actually have this working yet; so I suspect more changes are required ...) And in the end, (I believe) I am just going to have a block (likely 4096 bytes) prepended to the original u-boot.bin; which I can do today with no code changes at all Remember that original design request was effectively a two line change: + gd-mon_len += CONFIG_SYS_TEXT_BASE % 4096; and + gd-relocaddr += CONFIG_SYS_TEXT_BASE % 4096; Regrettably, since this is not going to be accepted, I am abandoning this change. Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] i2c: kona: Resolve Kona I2C driver issue
On 14-05-26 12:33 PM, Steve Rae wrote: - i2c mw command hangs (with some compilers) Signed-off-by: Steve Rae s...@broadcom.com --- drivers/i2c/kona_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/kona_i2c.c b/drivers/i2c/kona_i2c.c index 0b1715a..5eab338 100644 --- a/drivers/i2c/kona_i2c.c +++ b/drivers/i2c/kona_i2c.c @@ -663,7 +663,7 @@ static int kona_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr, static int kona_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr, int alen, uchar *buffer, int len) { - struct i2c_msg msg[0]; + struct i2c_msg msg[1]; unsigned char msgbuf0[64]; unsigned int i; struct bcm_kona_i2c_dev *dev = kona_get_dev(adap); I am hoping to get this into v2014.07 Thanks in advance, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] arm: bcm281xx: Add CONFIG_SYS_GENERIC_BOARD
On 14-06-10 04:20 AM, Albert ARIBAUD wrote: Hi Steve, On Wed, 14 May 2014 14:18:09 -0700, Steve Rae s...@broadcom.com wrote: convert to generic board Signed-off-by: Steve Rae s...@broadcom.com --- include/configs/bcm28155_ap.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/configs/bcm28155_ap.h b/include/configs/bcm28155_ap.h index e93b855..bf09939 100644 --- a/include/configs/bcm28155_ap.h +++ b/include/configs/bcm28155_ap.h @@ -14,6 +14,7 @@ #define CONFIG_ARMV7 #define CONFIG_KONA #define CONFIG_SKIP_LOWLEVEL_INIT +#define CONFIG_SYS_GENERIC_BOARD /* * Memory configuration Applied to u-boot-arm/master, thanks! Amicalement, ( sorry - I am uncertain of the process... ) I am hoping this will get picked up in the u-boot/master branch (soon) !?!?!? Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [RFC PATCH 0/3] Implement fastboot flash for eMMC
This series implements the fastboot flash command for eMMC devices. It supports both raw and sparse images. NOTES: - the support for the fastboot flash command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???) - thus the proposal is to place the code in common/fb_mmc.c and (future) common/fb_nand.c(???), however, this may not be the appropriate location This has been tested on ARMv7. This is a WIP -- and I would appreciate some comments/advice... Thanks, Steve Steve Rae (3): usb/gadget: fastboot: add sparse image definitions usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command README | 10 +++ common/Makefile | 5 ++ common/fb_mmc.c | 144 doc/README.android-fastboot | 5 +- drivers/usb/gadget/f_fastboot.c | 31 + include/fb_mmc.h| 8 +++ include/sparse_format.h | 58 7 files changed, 259 insertions(+), 2 deletions(-) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h create mode 100644 include/sparse_format.h -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [RFC PATCH 1/3] usb/gadget: fastboot: add sparse image definitions
- to prepare for the support of fastboot sparse images Signed-off-by: Steve Rae s...@broadcom.com --- This file is ASIS from: https://raw.githubusercontent.com/AOSB/android_system_core/master/libsparse/sparse_format.h (commit 28fa5bc347390480fe190294c6c385b6a9f0d68b) except for the __UBOOT__ conditional include. include/sparse_format.h | 58 + 1 file changed, 58 insertions(+) create mode 100644 include/sparse_format.h diff --git a/include/sparse_format.h b/include/sparse_format.h new file mode 100644 index 000..21fbd05 --- /dev/null +++ b/include/sparse_format.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _LIBSPARSE_SPARSE_FORMAT_H_ +#define _LIBSPARSE_SPARSE_FORMAT_H_ +#define __UBOOT__ +#ifndef __UBOOT__ +#include sparse_defs.h +#endif + +typedef struct sparse_header { + __le32 magic; /* 0xed26ff3a */ + __le16 major_version; /* (0x1) - reject images with higher major versions */ + __le16 minor_version; /* (0x0) - allow images with higer minor versions */ + __le16 file_hdr_sz;/* 28 bytes for first revision of the file format */ + __le16 chunk_hdr_sz; /* 12 bytes for first revision of the file format */ + __le32 blk_sz; /* block size in bytes, must be a multiple of 4 (4096) */ + __le32 total_blks; /* total blocks in the non-sparse output image */ + __le32 total_chunks; /* total chunks in the sparse input image */ + __le32 image_checksum; /* CRC32 checksum of the original data, counting don't care */ + /* as 0. Standard 802.3 polynomial, use a Public Domain */ + /* table implementation */ +} sparse_header_t; + +#define SPARSE_HEADER_MAGIC0xed26ff3a + +#define CHUNK_TYPE_RAW 0xCAC1 +#define CHUNK_TYPE_FILL0xCAC2 +#define CHUNK_TYPE_DONT_CARE 0xCAC3 +#define CHUNK_TYPE_CRC320xCAC4 + +typedef struct chunk_header { + __le16 chunk_type; /* 0xCAC1 - raw; 0xCAC2 - fill; 0xCAC3 - don't care */ + __le16 reserved1; + __le32 chunk_sz; /* in blocks in output image */ + __le32 total_sz; /* in bytes of chunk input file including chunk header and data */ +} chunk_header_t; + +/* Following a Raw or Fill or CRC32 chunk is data. + * For a Raw chunk, it's the data in chunk_sz * blk_sz. + * For a Fill chunk, it's 4 bytes of the fill data. + * For a CRC32 chunk, it's 4 bytes of CRC32 + */ + +#endif -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [RFC PATCH 2/3] usb/gadget: fastboot: add eMMC support for flash command
- add support for 'fastboot flash' command for eMMC devices Signed-off-by: Steve Rae s...@broadcom.com --- I suspect that the sparse image handling (ie. the while (remaining_chunks) loop) has been implemented elsewhere -- I need help finding the original code to determine any licensing issues Thanks, Steve common/Makefile | 5 ++ common/fb_mmc.c | 144 +++ include/fb_mmc.h | 8 3 files changed, 157 insertions(+) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h diff --git a/common/Makefile b/common/Makefile index f6cd980..c825c2c 100644 --- a/common/Makefile +++ b/common/Makefile @@ -264,4 +264,9 @@ obj-$(CONFIG_FIT_SIGNATURE) += image-sig.o obj-y += memsize.o obj-y += stdio.o +# This option is not just y/n - it can have a numeric value +ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +obj-y += fb_mmc.o +endif + CFLAGS_env_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2/dev/null) diff --git a/common/fb_mmc.c b/common/fb_mmc.c new file mode 100644 index 000..de6a4c7 --- /dev/null +++ b/common/fb_mmc.c @@ -0,0 +1,144 @@ +/* + * Copyright TODO + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include fb_mmc.h +#include mmc.h +#include sparse_format.h + +void fb_mmc_flash_write(const char *cmd, void *download_buffer, + unsigned int download_bytes, char *response) +{ + int ret; + block_dev_desc_t *mmc_dev; + disk_partition_t info; + lbaint_t blk; + lbaint_t blkcnt; + ulong blks; + sparse_header_t *s_header = (sparse_header_t *)download_buffer; + chunk_header_t *c_header; + void *buffer; + uint32_t blk_sz; + uint32_t remaining_chunks; + uint32_t bytes_written = 0; + + mmc_dev = mmc_get_dev(CONFIG_FASTBOOT_FLASH_MMC_DEV); + if (!mmc_dev || mmc_dev-type == DEV_TYPE_UNKNOWN) { + printf(%s: invalid mmc device\n, __func__); + strcpy(response, FAILinvalid mmc device); + return; + } + + ret = get_partition_info_efi_by_name(mmc_dev, cmd, info); + if (ret) { + printf(%s: cannot find partition: '%s'\n, __func__, cmd); + strcpy(response, FAILcannot find partition); + return; + } + + if ((le32_to_cpu(s_header-magic) == SPARSE_HEADER_MAGIC) + (le16_to_cpu(s_header-major_version) == 1)) { + /* sparse image */ + + blk_sz = le32_to_cpu(s_header-blk_sz); + + /* verify s_header-blk_sz is exact multiple of info.blksz */ + if (blk_sz != (blk_sz ~(info.blksz - 1))) { + printf(%s: Sparse image block size issue [%u]\n, + __func__, blk_sz); + strcpy(response, FAILsparse image block size issue); + return; + } + + if ((le32_to_cpu(s_header-total_blks) * blk_sz) + (info.size * info.blksz)) { + printf(%s: Sparse image is too large for the partition\n, + __func__); + strcpy(response, FAILsparse image is too large); + return; + } + + printf(Flashing Sparse Image\n); + + blk = info.start; + remaining_chunks = le32_to_cpu(s_header-total_chunks); + c_header = (chunk_header_t *)(download_buffer + + le16_to_cpu(s_header-file_hdr_sz)); + while (remaining_chunks) { + switch (le16_to_cpu(c_header-chunk_type)) { + case CHUNK_TYPE_RAW: + blkcnt = + (le32_to_cpu(c_header-chunk_sz) * blk_sz) / + info.blksz; + buffer = + (void *)c_header + + le16_to_cpu(s_header-chunk_hdr_sz); + + blks = mmc_dev-block_write(mmc_dev-dev, blk, + blkcnt, buffer); + if (blks != blkcnt) { + printf(Write failed %lu\n, blks); + strcpy(response, + FAILmmc write failure); + return; + } + + bytes_written += blkcnt * info.blksz; + break; + + case CHUNK_TYPE_FILL: + case CHUNK_TYPE_DONT_CARE: + case CHUNK_TYPE_CRC32: + /* do nothing */ + break; + + default: + /* error
[U-Boot] [RFC PATCH 3/3] usb/gadget: fastboot: add support for flash command
- implement 'fastboot flash' for eMMC devices Signed-off-by: Steve Rae s...@broadcom.com --- README | 10 ++ doc/README.android-fastboot | 5 +++-- drivers/usb/gadget/f_fastboot.c | 31 +++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/README b/README index 7129df8..73071fc 100644 --- a/README +++ b/README @@ -1600,6 +1600,16 @@ The following options need to be configured: downloads. This buffer should be as large as possible for a platform. Define this to the size available RAM for fastboot. + CONFIG_FASTBOOT_FLASH + The fastboot protocol includes a flash command for writing + the downloaded image to a non-volatile storage device. Define + this to enable the fastboot flash command. + + CONFIG_FASTBOOT_FLASH_MMC_DEV + The fastboot flash command requires addition information + regarding the non-volatile storage device. Define this to + the eMMC device that fastboot should use to store the image. + - Journaling Flash filesystem support: CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE, CONFIG_JFFS2_NAND_DEV diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot index f1d128c..f00fd41 100644 --- a/doc/README.android-fastboot +++ b/doc/README.android-fastboot @@ -6,8 +6,9 @@ Overview The protocol that is used over USB is described in README.android-fastboot-protocol in same directory. -The current implementation does not yet support the flash and erase -commands. +The current implementation does not yet support the erase +command, and there is minimal support for the flash command; +it only supports eMMC devices. Client installation === diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 9dd85b6..89c2d3e 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -19,6 +19,9 @@ #include linux/compiler.h #include version.h #include g_dnl.h +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#include fb_mmc.h +#endif #define FASTBOOT_VERSION 0.4 @@ -466,6 +469,28 @@ static void cb_boot(struct usb_ep *ep, struct usb_request *req) fastboot_tx_write_str(OKAY); } +#ifdef CONFIG_FASTBOOT_FLASH +static void cb_flash(struct usb_ep *ep, struct usb_request *req) +{ + char *cmd = req-buf; + char response[RESPONSE_LEN]; + + strsep(cmd, :); + if (!cmd) { + printf(%s: missing partition name\n, __func__); + fastboot_tx_write_str(FAILmissing partition name); + return; + } + + strcpy(response, FAILno flash device defined); +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV + fb_mmc_flash_write(cmd, (void *)CONFIG_USB_FASTBOOT_BUF_ADDR, + download_bytes, response); +#endif + fastboot_tx_write_str(response); +} +#endif + struct cmd_dispatch_info { char *cmd; void (*cb)(struct usb_ep *ep, struct usb_request *req); @@ -485,6 +510,12 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = { .cmd = boot, .cb = cb_boot, }, +#ifdef CONFIG_FASTBOOT_FLASH + { + .cmd = flash, + .cb = cb_flash, + }, +#endif }; static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [RFC PATCH 0/3] Implement fastboot flash for eMMC
On 14-06-19 11:32 PM, Marek Vasut wrote: On Friday, June 20, 2014 at 08:18:42 AM, Lukasz Majewski wrote: Hi Steve, This series implements the fastboot flash command for eMMC devices. It supports both raw and sparse images. NOTES: - the support for the fastboot flash command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???) - thus the proposal is to place the code in common/fb_mmc.c and (future) common/fb_nand.c(???), however, this may not be the appropriate location Would you consider another approach for providing flashing backend for fastboot? I'd like to propose reusing of the dfu flashing code for this purpose. Such approach has been used successfully with USB thor downloading function. Since the fastboot is using gadget infrastructure (thanks to the effort of Rob Herring) I think that it would be feasible to reuse the same approach as thor does. In this way the low level code would be kept in one place and we could refine and test it more thoroughly. I'm all for this approach as well if possible. Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot I have briefly investigated this suggestion And have 'hacked' some code as follows: --- common/fb_mmc.c_000 2014-06-20 14:13:43.271158073 -0700 +++ common/fb_mmc.c_001 2014-06-20 14:17:48.688072764 -0700 while (remaining_chunks) { switch (le16_to_cpu(c_header-chunk_type)) { case CHUNK_TYPE_RAW: +#if 0 blkcnt = (le32_to_cpu(c_header-chunk_sz) * blk_sz) / info.blksz; buffer = (void *)c_header + le16_to_cpu(s_header-chunk_hdr_sz); blks = mmc_dev-block_write(mmc_dev-dev, blk, blkcnt, buffer); if (blks != blkcnt) { printf(Write failed %lu\n, blks); strcpy(response, FAILmmc write failure); return; } bytes_written += blkcnt * info.blksz; +#else + buffer = + (void *)c_header + + le16_to_cpu(s_header-chunk_hdr_sz); + + len = le32_to_cpu(c_header-chunk_sz) * blk_sz; + ret_dfu = dfu_write_medium_mmc(dfu, offset, + buffer, len); + if (ret_dfu) { + printf(Write failed %lu\n, len); + strcpy(response, + FAILmmc write failure); + return; + } + + + bytes_written += len; +#endif break; case CHUNK_TYPE_FILL: case CHUNK_TYPE_DONT_CARE: case CHUNK_TYPE_CRC32: /* do nothing */ break; default: /* error */ printf(Unknown chunk type\n); strcpy(response, FAILunknown chunk type in sparse image); return; } +#if 0 blk += (le32_to_cpu(c_header-chunk_sz) * blk_sz) / info.blksz; +#else + offset += le32_to_cpu(c_header-chunk_sz) * blk_sz; +#endif c_header = (chunk_header_t *)((void *)c_header + le32_to_cpu(c_header-total_sz)); remaining_chunks--; } --- common/fb_mmc.c_000 2014-06-20 14:13:43.271158073 -0700 +++ common/fb_mmc.c_001 2014-06-20 14:17:48.688072764 -0700 /* raw image */ +#if 0 /* determine number of blocks to write */ blkcnt = ((download_bytes + (info.blksz - 1)) ~(info.blksz - 1)); blkcnt = blkcnt / info.blksz; if (blkcnt info.size) { printf(%s: too large for partition: '%s'\n, __func__, cmd);
Re: [U-Boot] Running ARMv8 on fast model
On 14-06-23 12:01 AM, Youngmin Nam wrote: Hello expert. I'm trying to run ARMv8 u-boot on fast model. Exactly on Coretex-A57×4 In FVP_VE When I run command model_shell64 cadi_system_Linux64-Release-GCC-4.6.so u-boot.elf There isn't any pop up xterm terminal. My fast model version is 8.3 and I used vexpress_aemv8a configuration on denx u-boot mainline. Does any body test armv8 u-boot on fast model? Yes - but... (1) I am testing vexpress_aemv8a_semi; which is not in master yet -- see: http://patchwork.ozlabs.org/patch/357577/ (2) I have inherited a script which does everything... However, the fundamental piece is: ./Linux-Release-GCC-4.6/isim_system -C pctl.startup=0.0.0.0 -C bp.secure_memory=0 -C cache_state_modelled=0 -C bp.pl011_uart0.untimed_fifos=1 -C bp.secureflashloader.fname=bl1.bin Note: this process actually launches a bootloader (bl1.bin); which is then used to launch U-Boot... I hope this helps, Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [RFC PATCH 0/3] Implement fastboot flash for eMMC
Rob Sebastian I would appreciate your comments on this issue; I suspect that you had some ideas regarding the implementation of the fastboot flash and erase commands Thanks in advance, Steve On 14-06-23 05:58 AM, Lukasz Majewski wrote: Hi Steve, On 14-06-19 11:32 PM, Marek Vasut wrote: On Friday, June 20, 2014 at 08:18:42 AM, Lukasz Majewski wrote: Hi Steve, This series implements the fastboot flash command for eMMC devices. It supports both raw and sparse images. NOTES: - the support for the fastboot flash command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???) - thus the proposal is to place the code in common/fb_mmc.c and (future) common/fb_nand.c(???), however, this may not be the appropriate location Would you consider another approach for providing flashing backend for fastboot? I'd like to propose reusing of the dfu flashing code for this purpose. Such approach has been used successfully with USB thor downloading function. Since the fastboot is using gadget infrastructure (thanks to the effort of Rob Herring) I think that it would be feasible to reuse the same approach as thor does. In this way the low level code would be kept in one place and we could refine and test it more thoroughly. I'm all for this approach as well if possible. Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot I have briefly investigated this suggestion And have 'hacked' some code as follows: --- common/fb_mmc.c_000 2014-06-20 14:13:43.271158073 -0700 +++ common/fb_mmc.c_001 2014-06-20 14:17:48.688072764 -0700 while (remaining_chunks) { switch (le16_to_cpu(c_header-chunk_type)) { case CHUNK_TYPE_RAW: +#if 0 blkcnt = (le32_to_cpu(c_header-chunk_sz) * blk_sz) / info.blksz; buffer = (void *)c_header + le16_to_cpu(s_header-chunk_hdr_sz); blks = mmc_dev-block_write(mmc_dev-dev, blk, blkcnt, buffer); if (blks != blkcnt) { printf(Write failed %lu\n, blks); strcpy(response, FAILmmc write failure); return; } bytes_written += blkcnt * info.blksz; +#else + buffer = + (void *)c_header + + le16_to_cpu(s_header-chunk_hdr_sz); + + len = le32_to_cpu(c_header-chunk_sz) * blk_sz; + ret_dfu = dfu_write_medium_mmc(dfu, offset, + buffer, len); + if (ret_dfu) { + printf(Write failed %lu\n, len); + strcpy(response, + FAILmmc write failure); + return; + } + + + bytes_written += len; +#endif break; case CHUNK_TYPE_FILL: case CHUNK_TYPE_DONT_CARE: case CHUNK_TYPE_CRC32: /* do nothing */ break; default: /* error */ printf(Unknown chunk type\n); strcpy(response, FAILunknown chunk type in sparse image); return; } +#if 0 blk += (le32_to_cpu(c_header-chunk_sz) * blk_sz) / info.blksz; +#else + offset += le32_to_cpu(c_header-chunk_sz) * blk_sz; +#endif c_header = (chunk_header_t *)((void *)c_header + le32_to_cpu(c_header-total_sz)); remaining_chunks--; } --- common/fb_mmc.c_000 2014-06-20 14:13:43.271158073 -0700 +++ common/fb_mmc.c_001 2014-06-20 14:17:48.688072764 -0700 /* raw image */ +#if 0 /* determine number of blocks to write */ blkcnt = ((download_bytes + (info.blksz - 1)) ~(info.blksz - 1)); blkcnt = blkcnt / info.blksz; if (blkcnt info.size) { printf(%s: too large for partition: '%s'\n, __func__, cmd); strcpy(response, FAILtoo large for partition); return; } printf(Flashing Raw Image\n); blks =
Re: [U-Boot] [RFC PATCH 0/3] Implement fastboot flash for eMMC
Rob, On 14-06-25 06:59 AM, Rob Herring wrote: On Mon, Jun 23, 2014 at 1:37 PM, Steve Rae s...@broadcom.com wrote: Rob Sebastian I would appreciate your comments on this issue; I suspect that you had some ideas regarding the implementation of the fastboot flash and erase commands I agree with Lukasz's and Marek's comments unless there are good reasons not to use it which can't be fixed. Curiously, USB mass storage does not use the DFU backend, but I don't know why. Perhaps there are incompatibilities or converting it is on the todo list. Are your performance concerns measurable or it's just the fact you are adding another layer? The concern is not performance related -- just the amount of (overhead) code required to implement the DFU backend versus calling mmc_dev-block_write() (maybe someone can tell me where to interface into DFU: is it at dfu_write() or ) I'd really like to see the eMMC backend be a generic block device backend. There's no good reason for it to be eMMC/SD specific. As I understand it, the block_write callback function is in the block_dev_desc_t. Isn't this the part of the generic block device interface? Please explain... Don't you also need the ability to partition a disk with fastboot? yes: though fastboot oem format is outside of this RFC -- because I wanted to minimize this request to ensure that licensing wasn't going to kill it. Rob Thanks in advance, Steve On 14-06-23 05:58 AM, Lukasz Majewski wrote: Hi Steve, On 14-06-19 11:32 PM, Marek Vasut wrote: On Friday, June 20, 2014 at 08:18:42 AM, Lukasz Majewski wrote: Hi Steve, This series implements the fastboot flash command for eMMC devices. It supports both raw and sparse images. NOTES: - the support for the fastboot flash command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???) - thus the proposal is to place the code in common/fb_mmc.c and (future) common/fb_nand.c(???), however, this may not be the appropriate location Would you consider another approach for providing flashing backend for fastboot? I'd like to propose reusing of the dfu flashing code for this purpose. Such approach has been used successfully with USB thor downloading function. Since the fastboot is using gadget infrastructure (thanks to the effort of Rob Herring) I think that it would be feasible to reuse the same approach as thor does. In this way the low level code would be kept in one place and we could refine and test it more thoroughly. I'm all for this approach as well if possible. Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot I have briefly investigated this suggestion And have 'hacked' some code as follows: --- common/fb_mmc.c_000 2014-06-20 14:13:43.271158073 -0700 +++ common/fb_mmc.c_001 2014-06-20 14:17:48.688072764 -0700 while (remaining_chunks) { switch (le16_to_cpu(c_header-chunk_type)) { case CHUNK_TYPE_RAW: +#if 0 blkcnt = (le32_to_cpu(c_header-chunk_sz) * blk_sz) / info.blksz; buffer = (void *)c_header + le16_to_cpu(s_header-chunk_hdr_sz); blks = mmc_dev-block_write(mmc_dev-dev, blk, blkcnt, buffer); if (blks != blkcnt) { printf(Write failed %lu\n, blks); strcpy(response, FAILmmc write failure); return; } bytes_written += blkcnt * info.blksz; +#else + buffer = + (void *)c_header + + le16_to_cpu(s_header-chunk_hdr_sz); + + len = le32_to_cpu(c_header-chunk_sz) * blk_sz; + ret_dfu = dfu_write_medium_mmc(dfu, offset, + buffer, len); + if (ret_dfu) { + printf(Write failed %lu\n, len); + strcpy(response, + FAILmmc write failure); + return; + } + + + bytes_written += len; +#endif break; case CHUNK_TYPE_FILL: case CHUNK_TYPE_DONT_CARE: case CHUNK_TYPE_CRC32: /* do nothing */ break; default
Re: [U-Boot] [RFC PATCH 0/3] Implement fastboot flash for eMMC
On 14-06-26 06:20 AM, Rob Herring wrote: On Wed, Jun 25, 2014 at 7:16 PM, Steve Rae s...@broadcom.com wrote: Rob, On 14-06-25 06:59 AM, Rob Herring wrote: On Mon, Jun 23, 2014 at 1:37 PM, Steve Rae s...@broadcom.com wrote: Rob Sebastian I would appreciate your comments on this issue; I suspect that you had some ideas regarding the implementation of the fastboot flash and erase commands I agree with Lukasz's and Marek's comments unless there are good reasons not to use it which can't be fixed. Curiously, USB mass storage does not use the DFU backend, but I don't know why. Perhaps there are incompatibilities or converting it is on the todo list. Are your performance concerns measurable or it's just the fact you are adding another layer? The concern is not performance related -- just the amount of (overhead) code required to implement the DFU backend versus calling mmc_dev-block_write() (maybe someone can tell me where to interface into DFU: is it at dfu_write() or ) Yes, I believe it is dfu_write. I'd really like to see the eMMC backend be a generic block device backend. There's no good reason for it to be eMMC/SD specific. As I understand it, the block_write callback function is in the block_dev_desc_t. Isn't this the part of the generic block device interface? Please explain... There are commands for SATA, SCSI (also SATA), eMMC, IDE, etc. They are all pretty much the same set of sub-commands and duplicate the same functionality. Those could all be combined to a single implementation and/or command for block devices. That part is not DFU related, but this problem then proliferates to other areas as it has for DFU. The file drivers/dfu/dfu_mmc.c is mostly generic, but has some eMMC dependencies with find_mmc_device and mmc_switch_part. So read and write are already pretty much generic, but there's still some work to do around device addressing/selection. Rob While I agree in general that to make everything generic is ideal, IMO, I don't think that there is a design or a roadmap to get us there yet I would suggest that any generic interface would also need to support: - handling of multiple HW partitions (0=USER 1-BOOT1 2=BOOT2 etc.) which I already attempted to implement (and abandoned): http://lists.denx.de/pipermail/u-boot/2014-May/180468.html - handling of partition names for EFI Partitions, this did get accepted: http://lists.denx.de/pipermail/u-boot/2014-May/180292.html So now I would propose two phases: (1) short term - get fastboot flash working (and erase, and oem format, etc.) I have code that works for eMMC device (and potentially for NAMD...) (2) longer term - define the generic block device (probably enhance block_dev_desc_t ?!?!?) and move the short term solution into this new design. I will submit a v2 to see if it will get accepted as part of the short term solution. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 0/4] Implement fastboot flash for eMMC
This series implements the fastboot flash command for eMMC devices. It supports both raw and sparse images. NOTES: - the support for the fastboot flash command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???) This has been tested on ARMv7. Changes in v2: - split large function into three - improved handling of response messages - additional partition size checking when writing sparse image - update README.android-fastboot file - new in v2 Steve Rae (4): usb/gadget: fastboot: add sparse image definitions usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command usb/gadget: fastboot: minor cleanup README | 10 +++ common/Makefile | 5 ++ common/fb_mmc.c | 189 doc/README.android-fastboot | 5 +- drivers/usb/gadget/f_fastboot.c | 41 - include/fb_mmc.h| 8 ++ include/sparse_format.h | 58 7 files changed, 311 insertions(+), 5 deletions(-) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h create mode 100644 include/sparse_format.h -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 1/4] usb/gadget: fastboot: add sparse image definitions
- to prepare for the support of fastboot sparse images Signed-off-by: Steve Rae s...@broadcom.com --- This file is ASIS from: https://raw.githubusercontent.com/AOSB/android_system_core/master/libsparse/sparse_format.h (commit 28fa5bc347390480fe190294c6c385b6a9f0d68b) except for the __UBOOT__ conditional include. Changes in v2: None include/sparse_format.h | 58 + 1 file changed, 58 insertions(+) create mode 100644 include/sparse_format.h diff --git a/include/sparse_format.h b/include/sparse_format.h new file mode 100644 index 000..21fbd05 --- /dev/null +++ b/include/sparse_format.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _LIBSPARSE_SPARSE_FORMAT_H_ +#define _LIBSPARSE_SPARSE_FORMAT_H_ +#define __UBOOT__ +#ifndef __UBOOT__ +#include sparse_defs.h +#endif + +typedef struct sparse_header { + __le32 magic; /* 0xed26ff3a */ + __le16 major_version; /* (0x1) - reject images with higher major versions */ + __le16 minor_version; /* (0x0) - allow images with higer minor versions */ + __le16 file_hdr_sz;/* 28 bytes for first revision of the file format */ + __le16 chunk_hdr_sz; /* 12 bytes for first revision of the file format */ + __le32 blk_sz; /* block size in bytes, must be a multiple of 4 (4096) */ + __le32 total_blks; /* total blocks in the non-sparse output image */ + __le32 total_chunks; /* total chunks in the sparse input image */ + __le32 image_checksum; /* CRC32 checksum of the original data, counting don't care */ + /* as 0. Standard 802.3 polynomial, use a Public Domain */ + /* table implementation */ +} sparse_header_t; + +#define SPARSE_HEADER_MAGIC0xed26ff3a + +#define CHUNK_TYPE_RAW 0xCAC1 +#define CHUNK_TYPE_FILL0xCAC2 +#define CHUNK_TYPE_DONT_CARE 0xCAC3 +#define CHUNK_TYPE_CRC320xCAC4 + +typedef struct chunk_header { + __le16 chunk_type; /* 0xCAC1 - raw; 0xCAC2 - fill; 0xCAC3 - don't care */ + __le16 reserved1; + __le32 chunk_sz; /* in blocks in output image */ + __le32 total_sz; /* in bytes of chunk input file including chunk header and data */ +} chunk_header_t; + +/* Following a Raw or Fill or CRC32 chunk is data. + * For a Raw chunk, it's the data in chunk_sz * blk_sz. + * For a Fill chunk, it's 4 bytes of the fill data. + * For a CRC32 chunk, it's 4 bytes of CRC32 + */ + +#endif -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 3/4] usb/gadget: fastboot: add support for flash command
- implement 'fastboot flash' for eMMC devices Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v2: - update README.android-fastboot file README | 10 ++ doc/README.android-fastboot | 5 +++-- drivers/usb/gadget/f_fastboot.c | 31 +++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/README b/README index fe5cacb..984db6d 100644 --- a/README +++ b/README @@ -1623,6 +1623,16 @@ The following options need to be configured: downloads. This buffer should be as large as possible for a platform. Define this to the size available RAM for fastboot. + CONFIG_FASTBOOT_FLASH + The fastboot protocol includes a flash command for writing + the downloaded image to a non-volatile storage device. Define + this to enable the fastboot flash command. + + CONFIG_FASTBOOT_FLASH_MMC_DEV + The fastboot flash command requires addition information + regarding the non-volatile storage device. Define this to + the eMMC device that fastboot should use to store the image. + - Journaling Flash filesystem support: CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE, CONFIG_JFFS2_NAND_DEV diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot index f1d128c..430e29c 100644 --- a/doc/README.android-fastboot +++ b/doc/README.android-fastboot @@ -6,8 +6,9 @@ Overview The protocol that is used over USB is described in README.android-fastboot-protocol in same directory. -The current implementation does not yet support the flash and erase -commands. +The current implementation does not yet support the erase command or the +oem format command, and there is minimal support for the flash command; +it only supports eMMC devices. Client installation === diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 9dd85b6..89c2d3e 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -19,6 +19,9 @@ #include linux/compiler.h #include version.h #include g_dnl.h +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#include fb_mmc.h +#endif #define FASTBOOT_VERSION 0.4 @@ -466,6 +469,28 @@ static void cb_boot(struct usb_ep *ep, struct usb_request *req) fastboot_tx_write_str(OKAY); } +#ifdef CONFIG_FASTBOOT_FLASH +static void cb_flash(struct usb_ep *ep, struct usb_request *req) +{ + char *cmd = req-buf; + char response[RESPONSE_LEN]; + + strsep(cmd, :); + if (!cmd) { + printf(%s: missing partition name\n, __func__); + fastboot_tx_write_str(FAILmissing partition name); + return; + } + + strcpy(response, FAILno flash device defined); +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV + fb_mmc_flash_write(cmd, (void *)CONFIG_USB_FASTBOOT_BUF_ADDR, + download_bytes, response); +#endif + fastboot_tx_write_str(response); +} +#endif + struct cmd_dispatch_info { char *cmd; void (*cb)(struct usb_ep *ep, struct usb_request *req); @@ -485,6 +510,12 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = { .cmd = boot, .cb = cb_boot, }, +#ifdef CONFIG_FASTBOOT_FLASH + { + .cmd = flash, + .cb = cb_flash, + }, +#endif }; static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 2/4] usb/gadget: fastboot: add eMMC support for flash command
- add support for 'fastboot flash' command for eMMC devices Signed-off-by: Steve Rae s...@broadcom.com --- I suspect that the sparse image handling (ie. the while (remaining_chunks) loop) has been implemented elsewhere -- I need help finding the original code to determine any licensing issues Thanks, Steve Changes in v2: - split large function into three - improved handling of response messages - additional partition size checking when writing sparse image common/Makefile | 5 ++ common/fb_mmc.c | 189 +++ include/fb_mmc.h | 8 +++ 3 files changed, 202 insertions(+) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h diff --git a/common/Makefile b/common/Makefile index de5cce8..daebe39 100644 --- a/common/Makefile +++ b/common/Makefile @@ -266,4 +266,9 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o obj-y += memsize.o obj-y += stdio.o +# This option is not just y/n - it can have a numeric value +ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +obj-y += fb_mmc.o +endif + CFLAGS_env_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2/dev/null) diff --git a/common/fb_mmc.c b/common/fb_mmc.c new file mode 100644 index 000..4143070 --- /dev/null +++ b/common/fb_mmc.c @@ -0,0 +1,189 @@ +/* + * Copyright TODO + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include fb_mmc.h +#include mmc.h +#include sparse_format.h + +/* The 64 defined bytes plus \0 */ +#define RESPONSE_LEN (64 + 1) + +static char *response_str; + +static void fastboot_resp(const char *s) +{ + strncpy(response_str, s, RESPONSE_LEN); + response_str[RESPONSE_LEN - 1] = '\0'; +} + +static int is_sparse_image(void *buf) +{ + sparse_header_t *s_header = (sparse_header_t *)buf; + + if ((le32_to_cpu(s_header-magic) == SPARSE_HEADER_MAGIC) + (le16_to_cpu(s_header-major_version) == 1)) + return 1; + + return 0; +} + +static void write_sparse_image(block_dev_desc_t *mmc_dev, + disk_partition_t *info, const char *part_name, + void *buffer, unsigned int download_bytes) +{ + lbaint_t blk; + lbaint_t blkcnt; + lbaint_t blks; + sparse_header_t *s_header = (sparse_header_t *)buffer; + chunk_header_t *c_header; + void *buf; + uint32_t blk_sz; + uint32_t remaining_chunks; + uint32_t bytes_written = 0; + + blk_sz = le32_to_cpu(s_header-blk_sz); + + /* verify s_header-blk_sz is exact multiple of info-blksz */ + if (blk_sz != (blk_sz ~(info-blksz - 1))) { + printf(%s: Sparse image block size issue [%u]\n, + __func__, blk_sz); + fastboot_resp(FAILsparse image block size issue); + return; + } + + if ((le32_to_cpu(s_header-total_blks) * blk_sz) + (info-size * info-blksz)) { + printf(%s: Sparse image is too large for the partition\n, + __func__); + fastboot_resp(FAILsparse image is too large); + return; + } + + printf(Flashing Sparse Image\n); + + remaining_chunks = le32_to_cpu(s_header-total_chunks); + c_header = (chunk_header_t *)(buffer + + le16_to_cpu(s_header-file_hdr_sz)); + blk = info-start; + while (remaining_chunks) { + blkcnt = + (le32_to_cpu(c_header-chunk_sz) * blk_sz) / info-blksz; + + switch (le16_to_cpu(c_header-chunk_type)) { + case CHUNK_TYPE_RAW: + buf = (void *)c_header + + le16_to_cpu(s_header-chunk_hdr_sz); + + if (blk + blkcnt info-start + info-size) { + printf( + %s: Request would exceed partition size!\n, + __func__); + fastboot_resp( + FAILRequest would exceed partition size!); + return; + } + + blks = mmc_dev-block_write(mmc_dev-dev, blk, blkcnt, + buf); + if (blks != blkcnt) { + printf(%s: Write failed LBAFU \n, + __func__, blks); + fastboot_resp(FAILmmc write failure); + return; + } + + bytes_written += blkcnt * info-blksz; + break; + + case CHUNK_TYPE_FILL: + case CHUNK_TYPE_DONT_CARE: + case CHUNK_TYPE_CRC32: + /* do nothing */ + break; + + default: + /* error */ + printf(%s: Unknown chunk type\n, __func__
[U-Boot] [PATCH v2 4/4] usb/gadget: fastboot: minor cleanup
- update static function - additional debugging statements Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v2: - new in v2 drivers/usb/gadget/f_fastboot.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 89c2d3e..3e6e47f 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -293,7 +293,7 @@ static int fastboot_add(struct usb_configuration *c) } DECLARE_GADGET_BIND_CALLBACK(usb_dnl_fastboot, fastboot_add); -int fastboot_tx_write(const char *buffer, unsigned int buffer_size) +static int fastboot_tx_write(const char *buffer, unsigned int buffer_size) { struct usb_request *in_req = fastboot_func-in_req; int ret; @@ -338,6 +338,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) strcpy(response, OKAY); strsep(cmd, :); if (!cmd) { + printf(%s: missing var\n, __func__); fastboot_tx_write_str(FAILmissing var); return; } @@ -358,6 +359,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) else strcpy(response, FAILValue not set); } else { + printf(%s: unknown variable: %s\n, __func__, cmd); strcpy(response, FAILVariable not implemented); } fastboot_tx_write_str(response); @@ -531,10 +533,12 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) } } - if (!func_cb) + if (!func_cb) { + printf(%s: unknown command: %s\n, __func__, cmdbuf); fastboot_tx_write_str(FAILunknown command); - else + } else { func_cb(ep, req); + } if (req-status == 0) { *cmdbuf = '\0'; -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 1/4] usb/gadget: fastboot: add sparse image definitions
- to prepare for the support of fastboot sparse images Signed-off-by: Steve Rae s...@broadcom.com --- This file is ASIS from: https://raw.githubusercontent.com/AOSB/android_system_core/master/libsparse/sparse_format.h (commit 28fa5bc347390480fe190294c6c385b6a9f0d68b) except for the __UBOOT__ conditional include. Changes in v3: None Changes in v2: None include/sparse_format.h | 58 + 1 file changed, 58 insertions(+) create mode 100644 include/sparse_format.h diff --git a/include/sparse_format.h b/include/sparse_format.h new file mode 100644 index 000..21fbd05 --- /dev/null +++ b/include/sparse_format.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _LIBSPARSE_SPARSE_FORMAT_H_ +#define _LIBSPARSE_SPARSE_FORMAT_H_ +#define __UBOOT__ +#ifndef __UBOOT__ +#include sparse_defs.h +#endif + +typedef struct sparse_header { + __le32 magic; /* 0xed26ff3a */ + __le16 major_version; /* (0x1) - reject images with higher major versions */ + __le16 minor_version; /* (0x0) - allow images with higer minor versions */ + __le16 file_hdr_sz;/* 28 bytes for first revision of the file format */ + __le16 chunk_hdr_sz; /* 12 bytes for first revision of the file format */ + __le32 blk_sz; /* block size in bytes, must be a multiple of 4 (4096) */ + __le32 total_blks; /* total blocks in the non-sparse output image */ + __le32 total_chunks; /* total chunks in the sparse input image */ + __le32 image_checksum; /* CRC32 checksum of the original data, counting don't care */ + /* as 0. Standard 802.3 polynomial, use a Public Domain */ + /* table implementation */ +} sparse_header_t; + +#define SPARSE_HEADER_MAGIC0xed26ff3a + +#define CHUNK_TYPE_RAW 0xCAC1 +#define CHUNK_TYPE_FILL0xCAC2 +#define CHUNK_TYPE_DONT_CARE 0xCAC3 +#define CHUNK_TYPE_CRC320xCAC4 + +typedef struct chunk_header { + __le16 chunk_type; /* 0xCAC1 - raw; 0xCAC2 - fill; 0xCAC3 - don't care */ + __le16 reserved1; + __le32 chunk_sz; /* in blocks in output image */ + __le32 total_sz; /* in bytes of chunk input file including chunk header and data */ +} chunk_header_t; + +/* Following a Raw or Fill or CRC32 chunk is data. + * For a Raw chunk, it's the data in chunk_sz * blk_sz. + * For a Fill chunk, it's 4 bytes of the fill data. + * For a CRC32 chunk, it's 4 bytes of CRC32 + */ + +#endif -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 3/4] usb/gadget: fastboot: add support for flash command
- implement 'fastboot flash' for eMMC devices Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v3: None Changes in v2: - update README.android-fastboot file README | 10 ++ doc/README.android-fastboot | 5 +++-- drivers/usb/gadget/f_fastboot.c | 31 +++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/README b/README index fe5cacb..984db6d 100644 --- a/README +++ b/README @@ -1623,6 +1623,16 @@ The following options need to be configured: downloads. This buffer should be as large as possible for a platform. Define this to the size available RAM for fastboot. + CONFIG_FASTBOOT_FLASH + The fastboot protocol includes a flash command for writing + the downloaded image to a non-volatile storage device. Define + this to enable the fastboot flash command. + + CONFIG_FASTBOOT_FLASH_MMC_DEV + The fastboot flash command requires addition information + regarding the non-volatile storage device. Define this to + the eMMC device that fastboot should use to store the image. + - Journaling Flash filesystem support: CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE, CONFIG_JFFS2_NAND_DEV diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot index f1d128c..430e29c 100644 --- a/doc/README.android-fastboot +++ b/doc/README.android-fastboot @@ -6,8 +6,9 @@ Overview The protocol that is used over USB is described in README.android-fastboot-protocol in same directory. -The current implementation does not yet support the flash and erase -commands. +The current implementation does not yet support the erase command or the +oem format command, and there is minimal support for the flash command; +it only supports eMMC devices. Client installation === diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 9dd85b6..89c2d3e 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -19,6 +19,9 @@ #include linux/compiler.h #include version.h #include g_dnl.h +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#include fb_mmc.h +#endif #define FASTBOOT_VERSION 0.4 @@ -466,6 +469,28 @@ static void cb_boot(struct usb_ep *ep, struct usb_request *req) fastboot_tx_write_str(OKAY); } +#ifdef CONFIG_FASTBOOT_FLASH +static void cb_flash(struct usb_ep *ep, struct usb_request *req) +{ + char *cmd = req-buf; + char response[RESPONSE_LEN]; + + strsep(cmd, :); + if (!cmd) { + printf(%s: missing partition name\n, __func__); + fastboot_tx_write_str(FAILmissing partition name); + return; + } + + strcpy(response, FAILno flash device defined); +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV + fb_mmc_flash_write(cmd, (void *)CONFIG_USB_FASTBOOT_BUF_ADDR, + download_bytes, response); +#endif + fastboot_tx_write_str(response); +} +#endif + struct cmd_dispatch_info { char *cmd; void (*cb)(struct usb_ep *ep, struct usb_request *req); @@ -485,6 +510,12 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = { .cmd = boot, .cb = cb_boot, }, +#ifdef CONFIG_FASTBOOT_FLASH + { + .cmd = flash, + .cb = cb_flash, + }, +#endif }; static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 2/4] usb/gadget: fastboot: add eMMC support for flash command
- add support for 'fastboot flash' command for eMMC devices Signed-off-by: Steve Rae s...@broadcom.com --- I suspect that the sparse image handling (ie. the while (remaining_chunks) loop) has been implemented elsewhere -- I need help finding the original code to determine any licensing issues Thanks, Steve Changes in v3: - remove most references to 'mmc', which leaves only one mmc specific function: mmc_get_dev() Changes in v2: - split large function into three - improved handling of response messages - additional partition size checking when writing sparse image common/Makefile | 5 ++ common/fb_mmc.c | 190 +++ include/fb_mmc.h | 8 +++ 3 files changed, 203 insertions(+) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h diff --git a/common/Makefile b/common/Makefile index de5cce8..daebe39 100644 --- a/common/Makefile +++ b/common/Makefile @@ -266,4 +266,9 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o obj-y += memsize.o obj-y += stdio.o +# This option is not just y/n - it can have a numeric value +ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +obj-y += fb_mmc.o +endif + CFLAGS_env_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2/dev/null) diff --git a/common/fb_mmc.c b/common/fb_mmc.c new file mode 100644 index 000..9163d8c --- /dev/null +++ b/common/fb_mmc.c @@ -0,0 +1,190 @@ +/* + * Copyright TODO + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include common.h +#include fb_mmc.h +#include part.h +#include sparse_format.h + +/* The 64 defined bytes plus \0 */ +#define RESPONSE_LEN (64 + 1) + +static char *response_str; + +static void fastboot_resp(const char *s) +{ + strncpy(response_str, s, RESPONSE_LEN); + response_str[RESPONSE_LEN - 1] = '\0'; +} + +static int is_sparse_image(void *buf) +{ + sparse_header_t *s_header = (sparse_header_t *)buf; + + if ((le32_to_cpu(s_header-magic) == SPARSE_HEADER_MAGIC) + (le16_to_cpu(s_header-major_version) == 1)) + return 1; + + return 0; +} + +static void write_sparse_image(block_dev_desc_t *dev_desc, + disk_partition_t *info, const char *part_name, + void *buffer, unsigned int download_bytes) +{ + lbaint_t blk; + lbaint_t blkcnt; + lbaint_t blks; + sparse_header_t *s_header = (sparse_header_t *)buffer; + chunk_header_t *c_header; + void *buf; + uint32_t blk_sz; + uint32_t remaining_chunks; + uint32_t bytes_written = 0; + + blk_sz = le32_to_cpu(s_header-blk_sz); + + /* verify s_header-blk_sz is exact multiple of info-blksz */ + if (blk_sz != (blk_sz ~(info-blksz - 1))) { + printf(%s: Sparse image block size issue [%u]\n, + __func__, blk_sz); + fastboot_resp(FAILsparse image block size issue); + return; + } + + if ((le32_to_cpu(s_header-total_blks) * blk_sz) + (info-size * info-blksz)) { + printf(%s: Sparse image is too large for the partition\n, + __func__); + fastboot_resp(FAILsparse image is too large); + return; + } + + printf(Flashing Sparse Image\n); + + remaining_chunks = le32_to_cpu(s_header-total_chunks); + c_header = (chunk_header_t *)(buffer + + le16_to_cpu(s_header-file_hdr_sz)); + blk = info-start; + while (remaining_chunks) { + blkcnt = + (le32_to_cpu(c_header-chunk_sz) * blk_sz) / info-blksz; + + switch (le16_to_cpu(c_header-chunk_type)) { + case CHUNK_TYPE_RAW: + buf = (void *)c_header + + le16_to_cpu(s_header-chunk_hdr_sz); + + if (blk + blkcnt info-start + info-size) { + printf( + %s: Request would exceed partition size!\n, + __func__); + fastboot_resp( + FAILRequest would exceed partition size!); + return; + } + + blks = dev_desc-block_write(dev_desc-dev, blk, blkcnt, + buf); + if (blks != blkcnt) { + printf(%s: Write failed LBAFU \n, + __func__, blks); + fastboot_resp(FAILwrite failure); + return; + } + + bytes_written += blkcnt * info-blksz; + break; + + case CHUNK_TYPE_FILL: + case CHUNK_TYPE_DONT_CARE: + case CHUNK_TYPE_CRC32: + /* do nothing */ + break; + + default
[U-Boot] [PATCH v3 0/4] Implement fastboot flash for eMMC
This series implements the fastboot flash command for eMMC devices. It supports both raw and sparse images. NOTES: - the support for the fastboot flash command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???) This has been tested on ARMv7. Changes in v3: - remove most references to 'mmc', which leaves only one mmc specific function: mmc_get_dev() Changes in v2: - split large function into three - improved handling of response messages - additional partition size checking when writing sparse image - update README.android-fastboot file - new in v2 Steve Rae (4): usb/gadget: fastboot: add sparse image definitions usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command usb/gadget: fastboot: minor cleanup README | 10 +++ common/Makefile | 5 ++ common/fb_mmc.c | 190 doc/README.android-fastboot | 5 +- drivers/usb/gadget/f_fastboot.c | 41 - include/fb_mmc.h| 8 ++ include/sparse_format.h | 58 7 files changed, 312 insertions(+), 5 deletions(-) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h create mode 100644 include/sparse_format.h -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 4/4] usb/gadget: fastboot: minor cleanup
- update static function - additional debugging statements Signed-off-by: Steve Rae s...@broadcom.com --- Changes in v3: None Changes in v2: - new in v2 drivers/usb/gadget/f_fastboot.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 89c2d3e..3e6e47f 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -293,7 +293,7 @@ static int fastboot_add(struct usb_configuration *c) } DECLARE_GADGET_BIND_CALLBACK(usb_dnl_fastboot, fastboot_add); -int fastboot_tx_write(const char *buffer, unsigned int buffer_size) +static int fastboot_tx_write(const char *buffer, unsigned int buffer_size) { struct usb_request *in_req = fastboot_func-in_req; int ret; @@ -338,6 +338,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) strcpy(response, OKAY); strsep(cmd, :); if (!cmd) { + printf(%s: missing var\n, __func__); fastboot_tx_write_str(FAILmissing var); return; } @@ -358,6 +359,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) else strcpy(response, FAILValue not set); } else { + printf(%s: unknown variable: %s\n, __func__, cmd); strcpy(response, FAILVariable not implemented); } fastboot_tx_write_str(response); @@ -531,10 +533,12 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) } } - if (!func_cb) + if (!func_cb) { + printf(%s: unknown command: %s\n, __func__, cmdbuf); fastboot_tx_write_str(FAILunknown command); - else + } else { func_cb(ep, req); + } if (req-status == 0) { *cmdbuf = '\0'; -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v6 0/4] Implement fastboot flash for eMMC
Hi Tom, On 14-08-26 11:47 AM, Steve Rae wrote: This series implements the fastboot flash command for eMMC devices. It supports both raw and sparse images. NOTES: - the support for the fastboot flash command is enabled with CONFIG_FASTBOOT_FLASH - the support for eMMC is enabled with CONFIG_FASTBOOT_FLASH_MMC_DEV - (future) the support for NAND would be enabled with CONFIG_FASTBOOT_FLASH_NAND(???) This has been tested on ARMv7. This series depends on: http://patchwork.ozlabs.org/patch/382443/ (to 382446) (which is now accepted) Changes in v6: - printf() to error() - fix spelling - remove excess braces Changes in v5: - use the common/aboot.c for the sparse format handling Changes in v4: - rearranged this patchset so that sparse_format.h can be dropped (if we cannot resolve the copyright/licensing issues) - update mmc_get_dev(...) to get_dev(mmc,) - update printf() to puts() where applicable - update debug string as per feedback - rearranged sparse format support in this patchset, in order to isolate... Changes in v3: - remove most references to 'mmc', which leaves only one mmc specific function: mmc_get_dev() Changes in v2: - split large function into three - improved handling of response messages - additional partition size checking when writing sparse image - update README.android-fastboot file - new in v2 Steve Rae (4): usb/gadget: fastboot: add eMMC support for flash command usb/gadget: fastboot: add support for flash command usb/gadget: fastboot: minor cleanup usb/gadget: fastboot: implement sparse format README | 10 + common/Makefile | 6 +++ common/cmd_fastboot.c | 7 ++-- common/fb_mmc.c | 92 + doc/README.android-fastboot | 5 ++- drivers/usb/gadget/f_fastboot.c | 44 ++-- include/fb_mmc.h| 8 7 files changed, 163 insertions(+), 9 deletions(-) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h I assume that because of all the churn with the Android sparse image (BTW - thanks for accepting it...) it seems that this patchset got incorrectly marked as superseded in Patchwork. I have corrected its status (to NEW). Can this please be pulled ASAP! ?!?!? Thanks in advance, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v1] fastboot: handle flash write to GPT partition
Implement a feature to allow fastboot to write the downloaded image to the space reserved for the Protective MBR and the Primary GUID Partition Table. Signed-off-by: Steve Rae s...@broadcom.com --- This series depends on: http://patchwork.ozlabs.org/patch/383184/ (to 388186) README | 7 +++ common/fb_mmc.c | 19 --- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README b/README index e8341b7..2e4e0c4 100644 --- a/README +++ b/README @@ -1639,6 +1639,13 @@ The following options need to be configured: regarding the non-volatile storage device. Define this to the eMMC device that fastboot should use to store the image. + CONFIG_FASTBOOT_GPT_NAME + The fastboot flash command supports writing the downloaded + image to the Protective MBR and the Primary GUID Partition + Table. This occurs when the specified partition name on the + fastboot flash command line matches this value. + Default is GPT_ENTRY_NAME (currently gpt) if undefined. + - Journaling Flash filesystem support: CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE, CONFIG_JFFS2_NAND_DEV diff --git a/common/fb_mmc.c b/common/fb_mmc.c index fb06d8a..89fbf23 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -4,12 +4,17 @@ * SPDX-License-Identifier:GPL-2.0+ */ +#include config.h #include common.h #include fb_mmc.h #include part.h #include aboot.h #include sparse_format.h +#ifndef CONFIG_FASTBOOT_GPT_NAME +#define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME +#endif + /* The 64 defined bytes plus the '\0' */ #define RESPONSE_LEN (64 + 1) @@ -62,9 +67,9 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, void fb_mmc_flash_write(const char *cmd, void *download_buffer, unsigned int download_bytes, char *response) { - int ret; block_dev_desc_t *dev_desc; disk_partition_t info; + lbaint_t blksz; /* initialize the response buffer */ response_str = response; @@ -76,8 +81,16 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, return; } - ret = get_partition_info_efi_by_name(dev_desc, cmd, info); - if (ret) { + if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0) { + printf(%s: updating GUID Partition Table (including MBR)\n, + __func__); + /* start at Protective MBR */ + info.start = (GPT_PRIMARY_PARTITION_TABLE_LBA - 1); + blksz = dev_desc-blksz; + info.blksz = blksz; + /* assume that the Partition Entry Array starts in LBA 2 */ + info.size = (2 + (GPT_ENTRY_NUMBERS * GPT_ENTRY_SIZE) / blksz); + } else if (get_partition_info_efi_by_name(dev_desc, cmd, info)) { error(cannot find partition: '%s'\n, cmd); fastboot_fail(cannot find partition); return; -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/3] usb: gadget: fastboot: add max-download-size variable
On 14-09-30 12:05 PM, Eric Nelson wrote: Current Android Fastboot seems to use 'max-download-size' instead of 'downloadsize' variable to indicate the maximum size of sparse segments. See function get_target_sparse_limit() in file fastboot/fastboot.c in the AOSP: https://android.googlesource.com/platform/system/core/+/master Signed-off-by: Eric Nelson eric.nel...@boundarydevices.com --- drivers/usb/gadget/f_fastboot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 38c0965..f970f89 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -351,7 +351,8 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) strncat(response, FASTBOOT_VERSION, chars_left); } else if (!strcmp_l1(bootloader-version, cmd)) { strncat(response, U_BOOT_VERSION, chars_left); - } else if (!strcmp_l1(downloadsize, cmd)) { + } else if (!strcmp_l1(downloadsize, cmd) || + !strcmp_l1(max-download-size, cmd)) { char str_num[12]; sprintf(str_num, %08x, CONFIG_USB_FASTBOOT_BUF_SIZE); (the host version of fastboot that I'm using requires this change!) Tested-by: Steve Rae s...@broadcom.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/3] usb: gadget: fastboot: explicitly set radix of maximum download size
On 14-09-30 12:05 PM, Eric Nelson wrote: The processing of the max-download-size variable requires a radix specifier, or the fastboot host tool will interpret it as an octal number. See function get_target_sparse_limit() in file fastboot/fastboot.c in the AOSP: https://android.googlesource.com/platform/system/core/+/master Signed-off-by: Eric Nelson eric.nel...@boundarydevices.com --- drivers/usb/gadget/f_fastboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index f970f89..86700f5 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -355,7 +355,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) !strcmp_l1(max-download-size, cmd)) { char str_num[12]; - sprintf(str_num, %08x, CONFIG_USB_FASTBOOT_BUF_SIZE); + sprintf(str_num, 0x%08x, CONFIG_USB_FASTBOOT_BUF_SIZE); strncat(response, str_num, chars_left); } else if (!strcmp_l1(serialno, cmd)) { s = getenv(serial#); (the host version of fastboot that I'm using requires this change!) Tested-by: Steve Rae s...@broadcom.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 3/3] usb: gadget: fastboot: terminate commands with NULL
On 14-09-30 12:05 PM, Eric Nelson wrote: Without NULL termination, various commands will read past the end of input. In particular, this was noticed with error() calls in cb_getvar and simple_strtoul() in cb_download. Since the download callback happens elsewhere, the 4k buffer should always be sufficient to handle command arguments. Signed-off-by: Eric Nelson eric.nel...@boundarydevices.com --- drivers/usb/gadget/f_fastboot.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 86700f5..0950ea8 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -542,6 +542,13 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) error(unknown command: %s\n, cmdbuf); fastboot_tx_write_str(FAILunknown command); } else { + if (req-actual req-length) { + u8 *buf = (u8 *)req-buf; + buf[req-actual] = 0; + func_cb(ep, req); + } else { + error(buffer overflow\n); fastboot_tx_write_str(FAILbuffer overflow); ADD this line + } func_cb(ep, req); AND delete this line (otherwise the func_cb() is called twice!!!) } I have not experienced this issue, however, if it is to be accepted, then please update these two lines Afterwards: Tested-by: Steve Rae s...@broadcom.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/3] usb: gadget: fastboot miscellaneous patches
On 14-10-01 05:13 AM, Marek Vasut wrote: On Wednesday, October 01, 2014 at 04:03:21 AM, Eric Nelson wrote: Hi Marek, On 09/30/2014 04:59 PM, Marek Vasut wrote: On Tuesday, September 30, 2014 at 09:47:07 PM, Eric Nelson wrote: Hi Marek, On 09/30/2014 12:37 PM, Marek Vasut wrote: On Tuesday, September 30, 2014 at 09:05:39 PM, Eric Nelson wrote: While trying to configure Nitrogen6X boards to use Android Fastboot, I found a number of places where the implementation doesn't appear to match the latest host tools on AOSP. Eric Nelson (3): usb: gadget: fastboot: add max-download-size variable usb: gadget: fastboot: explicitly set radix of maximum download size usb: gadget: fastboot: terminate commands with NULL Just to make sure, are those fixes for 2014.10 or new stuff for next ? These patches are against master, but should apply against usb/next and dfu/next and next is fine for us. 3/3 looks like a bugfix though. Is that a bugfix ? I wasn't able to get fastboot to do much of anything without all three. -- lack of max-download-size simply stopped downloads -- the missing radix caused my host to think that the 0x0700 size (copied from Beagle) was 1.8 MiB instead of 100+ MiB. -- the lack of termination showed up as a request to download a **huge** image when I tried to send u-boot.imx. I think I got lucky that the next characters in the buffer looked like hex digits. I suspect that others are either holding on to some local patches or are perhaps using old versions of the Fastboot host program. After applying all three, I was able to configure for flashing on an MMC device, but I don't have anything configured to use EFI partitions, so there's no immediate route to usage for us. I'd really like to be able to fastboot flash bootloader u-boot.imx and program SPI-NOR and also be able to boot a kernel and RAM disk using fastboot boot uImage uramdisk.img, but neither of them seems very close. The first needs some more structure, and the latter seemed to decide its' own address for the kernel and simply ignore the RAM disk. I have the sense that this code is pretty much a work in progress, but I'd like to hear otherwise from those who have used it. OK, so let's wait for the others' opinions. Best regards, Marek Vasut I would recommend 1/3 2/3 for 2014.10 (I'm not certain about 3/3 because I don't think that it can actually occur on my boards) Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/3] usb: gadget: fastboot: add max-download-size variable
On 14-10-01 07:37 PM, Marek Vasut wrote: On Wednesday, October 01, 2014 at 10:38:57 PM, Steve Rae wrote: On 14-09-30 12:05 PM, Eric Nelson wrote: Current Android Fastboot seems to use 'max-download-size' instead of 'downloadsize' variable to indicate the maximum size of sparse segments. See function get_target_sparse_limit() in file fastboot/fastboot.c in the AOSP: https://android.googlesource.com/platform/system/core/+/master Signed-off-by: Eric Nelson eric.nel...@boundarydevices.com --- drivers/usb/gadget/f_fastboot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 38c0965..f970f89 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -351,7 +351,8 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) strncat(response, FASTBOOT_VERSION, chars_left); } else if (!strcmp_l1(bootloader-version, cmd)) { strncat(response, U_BOOT_VERSION, chars_left); - } else if (!strcmp_l1(downloadsize, cmd)) { + } else if (!strcmp_l1(downloadsize, cmd) || + !strcmp_l1(max-download-size, cmd)) { char str_num[12]; sprintf(str_num, %08x, CONFIG_USB_FASTBOOT_BUF_SIZE); (the host version of fastboot that I'm using requires this change!) Tested-by: Steve Rae s...@broadcom.com Wow, so the previous code that was accepted was broken ? Did you know about that breakage ? It wasn't broken; let me try to clarify It seems that different host versions of fastboot use either downloadsize or max-download-size (I am not certain about the history...) The original code has downloadsize, and with the host version of fastboot that I am testing with (which uses max-download-size), this reports as unknown variable - however, the download still occurs successfully (there must be some default size that it is using...) Therefore, it isn't broken (for me). However, Eric has reported that for his host version of fastboot, that it stops! So his changes (1/3 and 2/3) are required for his host version of fastboot (and they work properly with my version) Hope that clarifies it, Thanks, Steve PS. none of these host versions of fastboot have any version identification -- so it is really difficult to determine what host version we are actually talking about Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot