Re: [U-Boot] [PATCH 2/4] usb: add 'bcm_udc_otg' support
On 15-01-27 03:00 PM, Marek Vasut wrote: On Monday, January 26, 2015 at 06:44:14 PM, Steve Rae wrote: [...] No, unless there's a convincing technical argument that the currently mainline DWC2 gadget driver (the s3c one) can absolutelly not be used for the broadcom SoC, I want to avoid having two drivers for the same IP core in mainline, sorry. [...] Sorry, at this point I have to push back a little. OK -- Thanks for this information Hi! do you plan to rework the series on top of the dwc2 (s3c) driver by any chance please ? Best regards, Marek Vasut I have it on my TODO list, but I am not going to be able to work on it (for weeks; if not months...) Sorry. But if someone else would rework the code, I can probably find some time to test it Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] fastboot: Add USB cable detect check
On 15-01-26 01:14 PM, Rob Herring wrote: Add a check for USB cable attached and only enter fastboot when a cable is attached. Signed-off-by: Rob Herring --- common/cmd_fastboot.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c index b72f4f3..346ab80 100644 --- a/common/cmd_fastboot.c +++ b/common/cmd_fastboot.c @@ -20,6 +20,12 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (ret) return ret; + if (!g_dnl_board_usb_cable_connected()) { + puts("\rUSB cable not detected.\n" \ +"Command exit.\n"); + return CMD_RET_FAILURE; + } + while (1) { if (g_dnl_detach()) break; (question: the leading "\r" ?!?!) Reviewed-by: Steve Rae Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] fastboot: add "fastboot oem" command support
On 15-01-26 01:49 PM, Rob Herring wrote: From: Michael Scott Add code stub to handle "fastboot oem __" command. As unlock is a common fastboot command, distinguish that it is not implemented. Signed-off-by: Michael Scott Signed-off-by: Rob Herring --- drivers/usb/gadget/f_fastboot.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 310175a..e2fda86 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -513,6 +513,17 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) } #endif +static void cb_oem(struct usb_ep *ep, struct usb_request *req) +{ + char *cmd = req->buf; + if (strncmp("unlock", cmd + 4, 8) == 0) { + fastboot_tx_write_str("FAILnot implemented"); + } + else { + fastboot_tx_write_str("FAILunknown oem command"); + } +} + struct cmd_dispatch_info { char *cmd; void (*cb)(struct usb_ep *ep, struct usb_request *req); @@ -541,6 +552,10 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = { .cb = cb_flash, }, #endif + { + .cmd = "oem", + .cb = cb_oem, + }, }; static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) Tested-by: Steve Rae ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] fastboot: add support for "oem format" command
On 15-01-26 01:49 PM, Rob Herring wrote: Add "oem format" command to write partition table. This relies on the env variable partitions to contain the list of partitions as required by the gpt command. Note that this does not erase any data other than the partition table. Signed-off-by: Rob Herring --- drivers/usb/gadget/f_fastboot.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index e2fda86..f7d84bf 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -516,6 +516,17 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) static void cb_oem(struct usb_ep *ep, struct usb_request *req) { char *cmd = req->buf; +#ifdef CONFIG_FASTBOOT_FLASH + if (strncmp("format", cmd + 4, 6) == 0) { + char cmdbuf[32]; +sprintf(cmdbuf, "gpt write mmc %x $partitions", + CONFIG_FASTBOOT_FLASH_MMC_DEV); +if (run_command(cmdbuf, 0)) + fastboot_tx_write_str("FAIL"); +else + fastboot_tx_write_str("OKAY"); + } else +#endif if (strncmp("unlock", cmd + 4, 8) == 0) { fastboot_tx_write_str("FAILnot implemented"); } Reviewed-by: Steve Rae ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 1/1] usb: gadget: fastboot: Add fastboot erase
Hi, Dileep On 15-02-10 12:49 AM, Dileep Katta wrote: Adds the fastboot erase functionality, to erase a partition specified by name. The erase is performed based on erase group size, to avoid erasing other partitions. The start address and the size is aligned to the erase group size for this. Currently only supports erasing from eMMC. Signed-off-by: Dileep Katta --- Note: The changes are on top of oem command support added by r...@kernel.org common/fb_mmc.c | 58 + drivers/usb/gadget/f_fastboot.c | 23 include/fb_mmc.h| 1 + 3 files changed, 82 insertions(+) diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 6ea3938..3911989 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -10,6 +10,7 @@ #include #include #include +#include #ifndef CONFIG_FASTBOOT_GPT_NAME #define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME @@ -110,3 +111,60 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, write_raw_image(dev_desc, &info, cmd, download_buffer, download_bytes); } + +void fb_mmc_erase(const char *cmd, char *response) +{ + int ret; + block_dev_desc_t *dev_desc; + disk_partition_t info; + lbaint_t blks, blks_start, blks_size, grp_size; + struct mmc *mmc = find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV); + + if (mmc == NULL) { + error("invalid mmc device\n"); no newline with error() + fastboot_fail("invalid mmc device"); + return; + } + + /* 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) { + error("invalid mmc device\n"); no newline with error() + fastboot_fail("invalid mmc device"); + return; + } + + ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); + if (ret) { + error("cannot find partition: '%s'\n", cmd); no newline with error() + fastboot_fail("cannot find partition"); + return; + } + + puts("Erasing partition\n"); + + /* Align blocks to erase group size to avoid erasing other partitions */ + grp_size = mmc->erase_grp_size; + blks_start = (info.start + grp_size - 1) & ~(grp_size - 1); + if (info.size >= grp_size) + blks_size = (info.size - (blks_start - info.start)) & + (~(grp_size - 1)); + else + blks_size = 0; Is this logic correct??? Isn't the "erase_grp_size" in bytes? and the info.start & info.size in LBA's? + + printf("Erasing blocks " LBAFU " to " LBAFU " due to alignment\n", + blks_start, blks_start + blks_size); + + blks = dev_desc->block_erase(dev_desc->dev, blks_start, blks_size); + if (blks != blks_size) { + error("failed erasing from device %d\n", dev_desc->dev); no newline with error() + fastboot_fail("failed erasing from device"); + return; + } + + printf(" erased " LBAFU " bytes from '%s'\n", + blks_size * info.blksz, cmd); + fastboot_okay(""); +} diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index f7d84bf..a8d8205 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -535,6 +535,26 @@ static void cb_oem(struct usb_ep *ep, struct usb_request *req) } } +static void cb_erase(struct usb_ep *ep, struct usb_request *req) +{ + char *cmd = req->buf; + char response[RESPONSE_LEN]; + + strsep(&cmd, ":"); + if (!cmd) { + error("missing partition name\n"); no newline with error() + fastboot_tx_write_str("FAILmissing partition name"); + return; + } + + strcpy(response, "FAILno flash device defined"); + +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV + fb_mmc_erase(cmd, response); +#endif + fastboot_tx_write_str(response); +} + struct cmd_dispatch_info { char *cmd; void (*cb)(struct usb_ep *ep, struct usb_request *req); @@ -566,6 +586,9 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = { { .cmd = "oem", .cb = cb_oem, + }, { + .cmd = "erase", + .cb = cb_erase, }, }; diff --git a/include/fb_mmc.h b/include/fb_mmc.h index 1ad1d13..402ba9b 100644 --- a/include/fb_mmc.h +++ b/include/fb_mmc.h @@ -6,3 +6,4 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, unsigned int download_bytes, char *response); +void fb_mmc_erase(const char *cmd, char *response); ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.d
Re: [U-Boot] [PATCH 2/2] fastboot: add support for "oem format" command
On 15-01-26 01:49 PM, Rob Herring wrote: Add "oem format" command to write partition table. This relies on the env variable partitions to contain the list of partitions as required by the gpt command. Note that this does not erase any data other than the partition table. Signed-off-by: Rob Herring --- drivers/usb/gadget/f_fastboot.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index e2fda86..f7d84bf 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -516,6 +516,17 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) static void cb_oem(struct usb_ep *ep, struct usb_request *req) { char *cmd = req->buf; +#ifdef CONFIG_FASTBOOT_FLASH + if (strncmp("format", cmd + 4, 6) == 0) { + char cmdbuf[32]; +sprintf(cmdbuf, "gpt write mmc %x $partitions", + CONFIG_FASTBOOT_FLASH_MMC_DEV); +if (run_command(cmdbuf, 0)) + fastboot_tx_write_str("FAIL"); +else + fastboot_tx_write_str("OKAY"); + } else +#endif if (strncmp("unlock", cmd + 4, 8) == 0) { fastboot_tx_write_str("FAILnot implemented"); } Please clarify the "partitions" env variable. For example, if I have (snippet from the 'mmc part' command): 3 0x00011000 0x000117ff "u-boot" attrs: 0x type: ebcf4a1c-b9e7-8f06-9885-3bd8b4a46cff guid: d5b495eb-57aa-fc70-23bb-d1897fa4e840 7 0x0001c000 0x00023fff "kernel" attrs: 0x type: 3c3ea4a6-5eaa-7f7c-1cb7-9374b8191c5d guid: 43b9c433-a106-68bf-aff4-890416fc87d7 what would the corresponding "partitions" env variable look like? Thanks, Steve PS. from doc/README.gpt: 148 Creating GPT partitions in U-Boot: 149 == 150 151 To restore GUID partition table one needs to: 152 1. Define partition layout in the environment. 153Format of partitions layout: 154 "partitions=uuid_disk=...;name=u-boot,size=60MiB,uuid=...; 155 name=kernel,size=60MiB,uuid=...;" 156 or 157 "partitions=uuid_disk=${uuid_gpt_disk};name=${uboot_name}, 158 size=${uboot_size},uuid=${uboot_uuid};" 159 160Fields 'name', 'size' and 'uuid' are mandatory for every partition. 161The field 'start' is optional. 162 163option: CONFIG_RANDOM_UUID 164If any partition "UUID" no exists then it is randomly generated. 165 166 2. Define 'CONFIG_EFI_PARTITION' and 'CONFIG_CMD_GPT' 167 168 2. From u-boot prompt type: 169gpt write mmc 0 $partitions How can dump the current "uuid_disk=" (not in the 'mmc part' command?) Is the "uuid=" parameter the 'type:' or the 'guid:' in the 'mmc part' command? ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 1/1] usb: gadget: fastboot: Add fastboot erase
On 15-02-12 01:21 AM, Dileep Katta wrote: Hi Rob, On 12 February 2015 at 14:35, Rob Herring wrote: On Tue, Feb 10, 2015 at 2:49 AM, Dileep Katta wrote: Adds the fastboot erase functionality, to erase a partition specified by name. The erase is performed based on erase group size, to avoid erasing other partitions. The start address and the size is aligned to the erase group size for this. Currently only supports erasing from eMMC. Signed-off-by: Dileep Katta --- Note: The changes are on top of oem command support added by r...@kernel.org common/fb_mmc.c | 58 + drivers/usb/gadget/f_fastboot.c | 23 include/fb_mmc.h| 1 + 3 files changed, 82 insertions(+) diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 6ea3938..3911989 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -10,6 +10,7 @@ #include #include #include +#include #ifndef CONFIG_FASTBOOT_GPT_NAME #define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME @@ -110,3 +111,60 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, write_raw_image(dev_desc, &info, cmd, download_buffer, download_bytes); } + +void fb_mmc_erase(const char *cmd, char *response) +{ + int ret; + block_dev_desc_t *dev_desc; + disk_partition_t info; + lbaint_t blks, blks_start, blks_size, grp_size; + struct mmc *mmc = find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV); + + if (mmc == NULL) { + error("invalid mmc device\n"); + fastboot_fail("invalid mmc device"); Perhaps fastboot_fail should also call error(). There is error() before every fastboot_fail(). You mean to move error() inside fastboot_fail()? If yes, I will do it. I disagree - most of the error() report more information about the issue; and the fastboot_fail() just informs the host that it was unsuccessful -- I don't think that we should force these to be the same Thanks, Steve + return; + } + + /* 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) { + error("invalid mmc device\n"); + fastboot_fail("invalid mmc device"); + return; + } + + ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); + if (ret) { + error("cannot find partition: '%s'\n", cmd); + fastboot_fail("cannot find partition"); + return; + } + + puts("Erasing partition\n"); This can probably be dropped since you have a print below. Will remove. + + /* Align blocks to erase group size to avoid erasing other partitions */ The partitioning could should probably enforce optimal alignment, but I guess that's a separate patch. Fine. Will do it as a separate patch. + grp_size = mmc->erase_grp_size; + blks_start = (info.start + grp_size - 1) & ~(grp_size - 1); + if (info.size >= grp_size) + blks_size = (info.size - (blks_start - info.start)) & + (~(grp_size - 1)); + else + blks_size = 0; + + printf("Erasing blocks " LBAFU " to " LBAFU " due to alignment\n", + blks_start, blks_start + blks_size); + + blks = dev_desc->block_erase(dev_desc->dev, blks_start, blks_size); + if (blks != blks_size) { + error("failed erasing from device %d\n", dev_desc->dev); + fastboot_fail("failed erasing from device"); + return; + } + + printf(" erased " LBAFU " bytes from '%s'\n", + blks_size * info.blksz, cmd); + fastboot_okay(""); +} diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index f7d84bf..a8d8205 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -535,6 +535,26 @@ static void cb_oem(struct usb_ep *ep, struct usb_request *req) } } +static void cb_erase(struct usb_ep *ep, struct usb_request *req) This should be conditional on CONFIG_FASTBOOT_FLASH Will make it conditional as in cb_oem(). +{ + char *cmd = req->buf; + char response[RESPONSE_LEN]; + + strsep(&cmd, ":"); + if (!cmd) { + error("missing partition name\n"); + fastboot_tx_write_str("FAILmissing partition name"); + return; + } + + strcpy(response, "FAILno flash device defined"); + +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV + fb_mmc_erase(cmd, response); +#endif + fastboot_tx_write_str(response); +} + struct cmd_dispatch_info { char *cmd; void (*cb)(struct usb_ep *ep, struct usb_request *req); @@ -566,6 +586,9 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = { {
Re: [U-Boot] [PATCH v1 2/3] fastboot: Correct fastboot_fail and fastboot_okay strings
On 15-02-12 10:33 PM, Dileep Katta wrote: If the string is copied without NULL termination using strncpy(), then strncat() on the next line, may concatenate the string after some stale (or random) data, if the response string was not zero-initialized. Signed-off-by: Dileep Katta --- common/fb_mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 3911989..73055cc 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -23,13 +23,13 @@ static char *response_str; void fastboot_fail(const char *s) { - strncpy(response_str, "FAIL", 4); + strncpy(response_str, "FAIL\0", 5); strncat(response_str, s, RESPONSE_LEN - 4 - 1); } void fastboot_okay(const char *s) { - strncpy(response_str, "OKAY", 4); + strncpy(response_str, "OKAY\0", 5); strncat(response_str, s, RESPONSE_LEN - 4 - 1); } THANKS! Reviewed-by: Steve Rae ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 3/3] usb: gadget: fastboot: Set the Serial Number for Fastboot Gadget
On 15-02-12 10:33 PM, Dileep Katta wrote: Configure the serial number using the serial# environment variable during the fastboot bind. This enables "fastboot devices" to return the serial number for the attached devices. Signed-off-by: Dileep Katta --- drivers/usb/gadget/f_fastboot.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 0d53a61..d114c07 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -136,6 +136,7 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f) int id; struct usb_gadget *gadget = c->cdev->gadget; struct f_fastboot *f_fb = func_to_fastboot(f); + const char *s; /* DYNAMIC interface numbers assignments */ id = usb_interface_id(c, f); @@ -161,6 +162,10 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f) hs_ep_out.bEndpointAddress = fs_ep_out.bEndpointAddress; + s = getenv("serial#"); + if (s) + g_dnl_set_serialnumber((char *)s); + return 0; } Acked-by: Steve Rae ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 1/3] fastboot: OUT transaction length must be aligned to wMaxPacketSize
On 15-02-13 09:59 AM, Dileep Katta wrote: OUT transactions must be aligned to wMaxPacketSize for each transfer, or else transfer will not complete successfully. This patch modifies rx_bytes_expected to return a transfer length that is aligned to wMaxPacketSize. Note that the value of wMaxPacketSize and ep->maxpacket may not be the same value, and it is the value of wMaxPacketSize that should be used for alignment. Signed-off-by: Dileep Katta --- Changes from v1: - Corrected source of wMaxPacketSize drivers/usb/gadget/f_fastboot.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index a8d8205..b18452e 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -370,13 +370,20 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) fastboot_tx_write_str(response); } -static unsigned int rx_bytes_expected(void) +static unsigned int rx_bytes_expected(unsigned maxpacket) { int rx_remain = download_size - download_bytes; + int rem = 0; if (rx_remain < 0) return 0; if (rx_remain > EP_BUFFER_SIZE) return EP_BUFFER_SIZE; + if (rx_remain < maxpacket) { + rx_remain = maxpacket; + } else if (rx_remain % maxpacket != 0) { + rem = rx_remain % maxpacket; + rx_remain = rx_remain + (maxpacket - rem); + } return rx_remain; } @@ -425,7 +432,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req) printf("\ndownloading of %d bytes finished\n", download_bytes); } else { - req->length = rx_bytes_expected(); + req->length = rx_bytes_expected(fs_ep_out.wMaxPacketSize); if (req->length < ep->maxpacket) req->length = ep->maxpacket; } @@ -453,7 +460,7 @@ static void cb_download(struct usb_ep *ep, struct usb_request *req) } else { sprintf(response, "DATA%08x", download_size); req->complete = rx_handler_dl_image; - req->length = rx_bytes_expected(); + req->length = rx_bytes_expected(fs_ep_out.wMaxPacketSize); if (req->length < ep->maxpacket) req->length = ep->maxpacket; } I don't understand... Why are we always limiting this to the "Full Speed" size? ( see fs_ep_out versus hs_ep_out defined previously in this file... ) Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 1/1] usb: gadget: fastboot: Add fastboot erase
On 15-02-12 12:29 AM, Dileep Katta wrote: Hi Steve, On 11 February 2015 at 05:25, Steve Rae wrote: Hi, Dileep On 15-02-10 12:49 AM, Dileep Katta wrote: Adds the fastboot erase functionality, to erase a partition specified by name. The erase is performed based on erase group size, to avoid erasing other partitions. The start address and the size is aligned to the erase group size for this. Currently only supports erasing from eMMC. Signed-off-by: Dileep Katta --- Note: The changes are on top of oem command support added by r...@kernel.org common/fb_mmc.c | 58 + drivers/usb/gadget/f_fastboot.c | 23 include/fb_mmc.h| 1 + 3 files changed, 82 insertions(+) diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 6ea3938..3911989 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -10,6 +10,7 @@ #include #include #include +#include #ifndef CONFIG_FASTBOOT_GPT_NAME #define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME @@ -110,3 +111,60 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, write_raw_image(dev_desc, &info, cmd, download_buffer, download_bytes); } + +void fb_mmc_erase(const char *cmd, char *response) +{ + int ret; + block_dev_desc_t *dev_desc; + disk_partition_t info; + lbaint_t blks, blks_start, blks_size, grp_size; + struct mmc *mmc = find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV); + + if (mmc == NULL) { + error("invalid mmc device\n"); no newline with error() Will remove + fastboot_fail("invalid mmc device"); + return; + } + + /* 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) { + error("invalid mmc device\n"); no newline with error() Will remove + fastboot_fail("invalid mmc device"); + return; + } + + ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); + if (ret) { + error("cannot find partition: '%s'\n", cmd); no newline with error() Will remove + fastboot_fail("cannot find partition"); + return; + } + + puts("Erasing partition\n"); + + /* Align blocks to erase group size to avoid erasing other partitions */ + grp_size = mmc->erase_grp_size; + blks_start = (info.start + grp_size - 1) & ~(grp_size - 1); + if (info.size >= grp_size) + blks_size = (info.size - (blks_start - info.start)) & + (~(grp_size - 1)); + else + blks_size = 0; Is this logic correct??? Isn't the "erase_grp_size" in bytes? and the info.start & info.size in LBA's? Yes, the math will take care of it. Ref: mmc_berase() So, I have a partition: 2 0x0300 0x03ff "test" attrs: 0x type: 9e312af1-18fe-fa41-45f3-37b3bb1d1061 guid: 18a5d0db-d23a-aac1-0d4c-692c7ba9ab1c and 'fastboot erase test' produces: Erasing blocks 1024 to 1024 due to alignment erased 0 bytes from 'test' which is not correct! Furthermore, doesn't the mmc_berase() already handle the "erase_grp_size" If I remove your alignment logic, then it produces: Erasing blocks 768 to 1024 due to alignment Caution! Your devices Erase group is 0x400 The erase range would be change to 0x0~0x7ff erased 131072 bytes from 'test' which looks correct (except for the "Caution" message) Thanks, Steve + + printf("Erasing blocks " LBAFU " to " LBAFU " due to alignment\n", + blks_start, blks_start + blks_size); + + blks = dev_desc->block_erase(dev_desc->dev, blks_start, blks_size); + if (blks != blks_size) { + error("failed erasing from device %d\n", dev_desc->dev); no newline with error() Will remove + fastboot_fail("failed erasing from device"); + return; + } + + printf(" erased " LBAFU " bytes from '%s'\n", + blks_size * info.blksz, cmd); + fastboot_okay(""); +} diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index f7d84bf..a8d8205 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -535,6 +535,26 @@ static void cb_oem(struct usb_ep *ep, struct usb_request *req) } } +static void cb_erase(struct usb_ep *ep,
Re: [U-Boot] [PATCH v1 1/1] usb: gadget: fastboot: Add fastboot erase
On 15-02-16 12:40 PM, Dileep Katta wrote: Hi Steve, On 14 February 2015 at 02:15, Steve Rae wrote: On 15-02-12 12:29 AM, Dileep Katta wrote: Hi Steve, On 11 February 2015 at 05:25, Steve Rae wrote: Hi, Dileep On 15-02-10 12:49 AM, Dileep Katta wrote: Adds the fastboot erase functionality, to erase a partition specified by name. The erase is performed based on erase group size, to avoid erasing other partitions. The start address and the size is aligned to the erase group size for this. Currently only supports erasing from eMMC. Signed-off-by: Dileep Katta --- Note: The changes are on top of oem command support added by r...@kernel.org common/fb_mmc.c | 58 ++ +++ drivers/usb/gadget/f_fastboot.c | 23 include/fb_mmc.h| 1 + 3 files changed, 82 insertions(+) diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 6ea3938..3911989 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -10,6 +10,7 @@ #include #include #include +#include #ifndef CONFIG_FASTBOOT_GPT_NAME #define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME @@ -110,3 +111,60 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, write_raw_image(dev_desc, &info, cmd, download_buffer, download_bytes); } + +void fb_mmc_erase(const char *cmd, char *response) +{ + int ret; + block_dev_desc_t *dev_desc; + disk_partition_t info; + lbaint_t blks, blks_start, blks_size, grp_size; + struct mmc *mmc = find_mmc_device(CONFIG_ FASTBOOT_FLASH_MMC_DEV); + + if (mmc == NULL) { + error("invalid mmc device\n"); no newline with error() Will remove + fastboot_fail("invalid mmc device"); + return; + } + + /* 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) { + error("invalid mmc device\n"); no newline with error() Will remove + fastboot_fail("invalid mmc device"); + return; + } + + ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); + if (ret) { + error("cannot find partition: '%s'\n", cmd); no newline with error() Will remove + fastboot_fail("cannot find partition"); + return; + } + + puts("Erasing partition\n"); + + /* Align blocks to erase group size to avoid erasing other partitions */ + grp_size = mmc->erase_grp_size; + blks_start = (info.start + grp_size - 1) & ~(grp_size - 1); + if (info.size >= grp_size) + blks_size = (info.size - (blks_start - info.start)) & + (~(grp_size - 1)); + else + blks_size = 0; Is this logic correct??? Isn't the "erase_grp_size" in bytes? and the info.start & info.size in LBA's? Yes, the math will take care of it. Ref: mmc_berase() So, I have a partition: 2 0x0300 0x03ff "test" attrs: 0x type: 9e312af1-18fe-fa41-45f3-37b3bb1d1061 guid: 18a5d0db-d23a-aac1-0d4c-692c7ba9ab1c and 'fastboot erase test' produces: Erasing blocks 1024 to 1024 due to alignment erased 0 bytes from 'test' which is not correct! Furthermore, doesn't the mmc_berase() already handle the "erase_grp_size" It does handle it, in a way, but the way it handles it is to erase more blocks than requested if the request isn't aligned. In your example, you requested the "test" partition to be erased (0x300 to 0x3ff), but what was actually erased (as printed in the "Caution" message from mmc_berase) was 0x0 to 0x7ff. If I remove your alignment logic, then it produces: Erasing blocks 768 to 1024 due to alignment Caution! Your devices Erase group is 0x400 The erase range would be change to 0x0~0x7ff erased 131072 bytes from 'test' which looks correct (except for the "Caution" message) Thanks, Steve Except that this one has now erased 0x0 to 0x300 and 0x400 to 0x7ff also, which you did not want to erase, right? Aligning the start address is meant to protect this data from being erased unintentionally. The trade-off is that some small partitions won't get erased at all, if they are too small and not aligned. Regards, Dileep I'm sorry, but I am really confused -- 131072 bytes agrees with 0x300 to 0x3ff... -- I'm suspicious that the Caution message and the actual erased bytes do not match -- I'm not
Re: [U-Boot] [PATCH] usb: gadget: fastboot: make high-speed work
Hi Matt: On 15-02-19 10:25 AM, Matt Reimer wrote: Make fastboot work in high-speed mode by specifying separate sets of usb_descriptor_headers for full-speed and high-speed. Tested on s5p_ds5. Signed-off-by: Matt Reimer --- drivers/usb/gadget/f_fastboot.c | 27 --- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 310175a..024ef20 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -74,6 +74,15 @@ static struct usb_endpoint_descriptor fs_ep_out = { .bInterval = 0x00, }; +static struct usb_endpoint_descriptor hs_ep_in = { + .bLength= USB_DT_ENDPOINT_SIZE, + .bDescriptorType= USB_DT_ENDPOINT, + .bEndpointAddress = USB_DIR_IN, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = RX_ENDPOINT_MAXIMUM_PACKET_SIZE_2_0, + .bInterval = 0x00, +}; + Are you certain that you have the "in" and "out" correct? Looking at the three existing "usb_endpoint_descriptors" fs_ep_in fs_ep_out hs_ep_out The "in" is for sending data from the device TO the host, and the "out" is for receiving data FROM the host. The maximum packet size changes between 1.1 and 2.0 for receiving packets (on the "out" endpoint), but AFAIK the maximum packet size is the same for 1.1 and 2.0 (hence the fs_ep_in is used for both fs AND hs) This change suggests that the maximum packet size for sending packets TO the host has changed as well - if it has, then the define in hs_ep_in (above) needs to be: .wMaxPacketSize = TX_ENDPOINT_MAXIMUM_PACKET_SIZE_2_0, in order to avoid confusion Thanks, Steve static struct usb_endpoint_descriptor hs_ep_out = { .bLength= USB_DT_ENDPOINT_SIZE, .bDescriptorType= USB_DT_ENDPOINT, @@ -94,9 +103,16 @@ static struct usb_interface_descriptor interface_desc = { .bInterfaceProtocol = FASTBOOT_INTERFACE_PROTOCOL, }; -static struct usb_descriptor_header *fb_runtime_descs[] = { +static struct usb_descriptor_header *fb_fs_runtime_descs[] = { (struct usb_descriptor_header *)&interface_desc, (struct usb_descriptor_header *)&fs_ep_in, + (struct usb_descriptor_header *)&fs_ep_out, + NULL, +}; + +static struct usb_descriptor_header *fb_hs_runtime_descs[] = { + (struct usb_descriptor_header *)&interface_desc, + (struct usb_descriptor_header *)&hs_ep_in, (struct usb_descriptor_header *)&hs_ep_out, NULL, }; @@ -160,6 +176,7 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f) f_fb->out_ep->driver_data = c->cdev; hs_ep_out.bEndpointAddress = fs_ep_out.bEndpointAddress; + hs_ep_in.bEndpointAddress = fs_ep_in.bEndpointAddress; return 0; } @@ -236,7 +253,10 @@ static int fastboot_set_alt(struct usb_function *f, } f_fb->out_req->complete = rx_handler_command; - ret = usb_ep_enable(f_fb->in_ep, &fs_ep_in); + if (gadget->speed == USB_SPEED_HIGH) + ret = usb_ep_enable(f_fb->in_ep, &hs_ep_in); + else + ret = usb_ep_enable(f_fb->in_ep, &fs_ep_in); if (ret) { puts("failed to enable in ep\n"); goto err; @@ -277,7 +297,8 @@ static int fastboot_add(struct usb_configuration *c) } f_fb->usb_function.name = "f_fastboot"; - f_fb->usb_function.hs_descriptors = fb_runtime_descs; + f_fb->usb_function.descriptors = fb_fs_runtime_descs; + f_fb->usb_function.hs_descriptors = fb_hs_runtime_descs; f_fb->usb_function.bind = fastboot_bind; f_fb->usb_function.unbind = fastboot_unbind; f_fb->usb_function.set_alt = fastboot_set_alt; ___ 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 Base support for the Broadcom NSP SoC. Based on iproc-common and the SoC specific reset function. Signed-off-by: Scott Branden Signed-off-by: Steve Rae --- 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 +#include + +#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 The iproc architecture code is present in several Broadcom chip architectures, including Cygnus and NSP. Signed-off-by: Scott Branden Signed-off-by: Steve Rae --- 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 +#include +#include +#include + +#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) { + status = 0
[U-Boot] [PATCH 2/4] arm: bcmcygnus: Add bcmcygnus u-architecture
From: Scott Branden Base support for the Broadcom Cygnus SoC. Based on iproc-common and the SoC specific reset function. Signed-off-by: Scott Branden Signed-off-by: Steve Rae --- 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 +#include + +#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 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 Signed-off-by: Steve Rae --- 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 + +/* 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 + +/* 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 + +/* 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 +#include +#include +#include +#include + +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) + armpll_config(CONFIG_ARMCLK); +#endif + + return status; +} diff --git a/boards.cfg b/boards.cfg index 1ba2081..25eaaee 100644 --- a/boards.cfg +++
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 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 The iproc architecture code is present in several Broadcom chip architectures, including Cygnus and NSP. Signed-off-by: Scott Branden Signed-off-by: Steve Rae --- 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 +#include +#include +#include + +#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
[U-Boot] [PATCH v2 2/4] arm: bcmcygnus: Add bcmcygnus u-architecture
From: Scott Branden Base support for the Broadcom Cygnus SoC. Based on iproc-common and the SoC specific reset function. Signed-off-by: Scott Branden Signed-off-by: Steve Rae --- 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 +#include + +#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 Base support for the Broadcom NSP SoC. Based on iproc-common and the SoC specific reset function. Signed-off-by: Scott Branden Signed-off-by: Steve Rae --- 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 +#include + +#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 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 Signed-off-by: Steve Rae --- 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 + +/* 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 + +/* 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 + +/* 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 +#include +#include +#include +#include + +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(CONFIG_ARMCLK) + armpll_config(CONFIG_ARMCLK); +#endif + + return status; +} diff --git a/boards.cfg b/boards.cfg index 4b2bc19..b06bb32 1
[U-Boot] [PATCH] arm: bcm281xx: Add Ethernet Clock support
From: Jiandong Zheng Enable Ethernet clock when Broadcom StarFighter2 Ethernet block (CONFIG_BCM_SF2_ETH) is enabled. Signed-off-by: Jiandong Zheng Signed-off-by: Steve Rae --- - 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 +#include +#include +#include +#include +#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) | PLLE_RESETB_I_PLL_RESETB_PLLE_MASK, + 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 --- 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 Enable Ethernet clock when Broadcom StarFighter2 Ethernet block (CONFIG_BCM_SF2_ETH) is enabled. Signed-off-by: Jiandong Zheng Signed-off-by: Steve Rae --- - 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 +#include +#include +#include +#include +#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_R
[U-Boot] [PATCH v2 2/3] arm: bcm281xx: net: Add Ethernet Driver
From: Jiandong Zheng 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 Signed-off-by: Steve Rae --- 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 +#include +#include +#include +#include +#include + +#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"
[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 --- 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: 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 --- 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 Reviewed-by: Marek Vasut 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 --- 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 +#include +#include +#include + +/* 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 --- 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 +#include +#include + +/* 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 --- 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 #include #include #include @@ -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 Reviewed-by: Marek Vasut --- 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 #include #include +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#include +#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 --- 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 --- 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 #include #include +#include /* 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->
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 +#include +#include +#include + +/* 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 --- 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 +#include +#include +#include + +/* 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 --- 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 #include #include +#include +#include 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 + * + * Tom Rix and Sitara 2011 u-boot by + * Mohammed Afzal M A + * + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Copyright 2014 Linaro, Ltd. + * Dileep Katta + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#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", 256*1024 }, /* Android file system */ + { "cache", 256*1024 },/* Store Application Cache */ + { "userdata", 256*1024 }, /* User data */ + { "media", 0 },
[U-Boot] [PATCH v3 1/5] arm: iproc: Initial commit of iproc architecture code
From: Scott Branden The iproc architecture code is present in several Broadcom chip architectures, including Cygnus and NSP. Signed-off-by: Scott Branden Signed-off-by: Steve Rae --- 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 +#include +#include +#include + +#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 Base support for the Broadcom NSP SoC. Based on iproc-common and the SoC specific reset function. Signed-off-by: Scott Branden Signed-off-by: Steve Rae --- 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 +#include + +#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 --- 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: 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: 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 Base support for the Broadcom Cygnus SoC. Based on iproc-common and the SoC specific reset function. Signed-off-by: Scott Branden Signed-off-by: Steve Rae --- 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 +#include + +#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 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 Signed-off-by: Steve Rae --- 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 + +/* 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 + +/* 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 + +/* 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 +#include +#include +#include +#include + +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(CONFIG_ARMCLK) + armpll_config(CONFIG_ARMCLK); +#endif + + return status; +} diff --git a/include/configs/bcm_ep_board.h b/
[U-Boot] [PATCH v1 0/4] Implement "sparse format" for fastboot
This series implements the "sparse format" file handling for fastboot. - [1/4] brings in the pristine file "aboot.c" - [2/4] deletes all unnecessary functions in "aboot.c" - [3/4] is a simple cleanup of "aboot.c" - [4/4] provides the implementation of "aboot.c" suitable for U-Boot NOTE: The original license in "aboot.c" does not exactly match the wording in the BSD-3-Clause. I propose adding BSD-3L-Clause to solve this issue. This series depends on: http://patchwork.ozlabs.org/patch/379438/ Steve Rae (4): add code to handle Android sparse image format update code which handles Android sparse image format cleanup code which handles the Android sparse image format implement the Android sparse image format Licenses/bsd-3L-clause.txt | 24 + common/aboot.c | 217 + include/aboot.h| 28 ++ include/sparse_defs.h | 7 ++ 4 files changed, 276 insertions(+) create mode 100644 Licenses/bsd-3L-clause.txt create mode 100644 common/aboot.c create mode 100644 include/aboot.h create mode 100644 include/sparse_defs.h -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v1 2/4] update code which handles Android sparse image format
- remove unnecessary functions Signed-off-by: Steve Rae --- common/aboot.c | 2438 1 file changed, 2438 deletions(-) diff --git a/common/aboot.c b/common/aboot.c index 3b5092d..a302c92 100644 --- a/common/aboot.c +++ b/common/aboot.c @@ -30,1819 +30,6 @@ * */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if DEVICE_TREE -#include -#include -#endif - -#include "image_verify.h" -#include "recovery.h" -#include "bootimg.h" -#include "fastboot.h" -#include "sparse_format.h" -#include "mmc.h" -#include "devinfo.h" -#include "board.h" -#include "scm.h" - -extern bool target_use_signed_kernel(void); -extern void platform_uninit(void); -extern void target_uninit(void); -extern int get_target_boot_params(const char *cmdline, const char *part, - char *buf, int buflen); - -void write_device_info_mmc(device_info *dev); -void write_device_info_flash(device_info *dev); - -#define EXPAND(NAME) #NAME -#define TARGET(NAME) EXPAND(NAME) - -#ifdef MEMBASE -#define EMMC_BOOT_IMG_HEADER_ADDR (0xFF000+(MEMBASE)) -#else -#define EMMC_BOOT_IMG_HEADER_ADDR 0xFF000 -#endif - -#ifndef MEMSIZE -#define MEMSIZE 1024*1024 -#endif - -#define MAX_TAGS_SIZE 1024 - -#define RECOVERY_MODE 0x77665502 -#define FASTBOOT_MODE 0x77665500 - -/* make 4096 as default size to ensure EFS,EXT4's erasing */ -#define DEFAULT_ERASE_SIZE 4096 -#define MAX_PANEL_BUF_SIZE 128 - -#define UBI_MAGIC "UBI#" -#define DISPLAY_DEFAULT_PREFIX "mdss_mdp" -#define UBI_MAGIC_SIZE 0x04 -#define BOOT_DEV_MAX_LEN 64 - -#define IS_ARM64(ptr) (ptr->magic_64 == KERNEL64_HDR_MAGIC) ? true : false - -#define ADD_OF(a, b) (UINT_MAX - b > a) ? (a + b) : UINT_MAX - -#if UFS_SUPPORT -static const char *emmc_cmdline = " androidboot.bootdevice="; -#else -static const char *emmc_cmdline = " androidboot.emmc=true"; -#endif -static const char *usb_sn_cmdline = " androidboot.serialno="; -static const char *androidboot_mode = " androidboot.mode="; -static const char *loglevel = " quiet"; -static const char *battchg_pause = " androidboot.mode=charger"; -static const char *auth_kernel = " androidboot.authorized_kernel=true"; -static const char *secondary_gpt_enable = " gpt"; - -static const char *baseband_apq = " androidboot.baseband=apq"; -static const char *baseband_msm = " androidboot.baseband=msm"; -static const char *baseband_csfb= " androidboot.baseband=csfb"; -static const char *baseband_svlte2a = " androidboot.baseband=svlte2a"; -static const char *baseband_mdm = " androidboot.baseband=mdm"; -static const char *baseband_mdm2= " androidboot.baseband=mdm2"; -static const char *baseband_sglte = " androidboot.baseband=sglte"; -static const char *baseband_dsda= " androidboot.baseband=dsda"; -static const char *baseband_dsda2 = " androidboot.baseband=dsda2"; -static const char *baseband_sglte2 = " androidboot.baseband=sglte2"; -static const char *warmboot_cmdline = " qpnp-power-on.warm_boot=1"; - -static unsigned page_size = 0; -static unsigned page_mask = 0; -static char ffbm_mode_string[FFBM_MODE_BUF_SIZE]; -static bool boot_into_ffbm; -static char target_boot_params[64]; - -/* Assuming unauthorized kernel image by default */ -static int auth_kernel_img = 0; - -static device_info device = {DEVICE_MAGIC, 0, 0, 0, 0}; - -struct atag_ptbl_entry -{ - char name[16]; - unsigned offset; - unsigned size; - unsigned flags; -}; - -/* - * Partition info, required to be published - * for fastboot - */ -struct getvar_partition_info { - const char part_name[MAX_GPT_NAME_SIZE]; /* Partition name */ - char getvar_size[MAX_GET_VAR_NAME_SIZE]; /* fastboot get var name for size */ - char getvar_type[MAX_GET_VAR_NAME_SIZE]; /* fastboot get var name for type */ - char size_response[MAX_RSP_SIZE];/* fastboot response for size */ - char type_response[MAX_RSP_SIZE];/* fastboot response for type */ -}; - -/* - * Right now, we are publishing the info for only - * three partitions - */ -struct getvar_partition_info part_info[] = -{ - { "system" , "partition-size:", "partition-type:", "", "ext4" }, - { "userdata", "partition-size:", "partition-type:", "", "ext4" }, - { "cache" , "partition-size:", "partition-type:", "&q
[U-Boot] [PATCH v1 1/4] add code to handle Android sparse image format
Add original file (pristine) from : https://www.codeaurora.org/cgit/quic/la/kernel/lk/plain/app/aboot/aboot.c?h=master [3b5092d20bd15a7a2879c13e9f64acc48d04af2d] Signed-off-by: Steve Rae --- common/aboot.c | 2643 1 file changed, 2643 insertions(+) create mode 100644 common/aboot.c diff --git a/common/aboot.c b/common/aboot.c new file mode 100644 index 000..3b5092d --- /dev/null +++ b/common/aboot.c @@ -0,0 +1,2643 @@ +/* + * Copyright (c) 2009, Google Inc. + * All rights reserved. + * + * Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of The Linux Foundation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if DEVICE_TREE +#include +#include +#endif + +#include "image_verify.h" +#include "recovery.h" +#include "bootimg.h" +#include "fastboot.h" +#include "sparse_format.h" +#include "mmc.h" +#include "devinfo.h" +#include "board.h" +#include "scm.h" + +extern bool target_use_signed_kernel(void); +extern void platform_uninit(void); +extern void target_uninit(void); +extern int get_target_boot_params(const char *cmdline, const char *part, + char *buf, int buflen); + +void write_device_info_mmc(device_info *dev); +void write_device_info_flash(device_info *dev); + +#define EXPAND(NAME) #NAME +#define TARGET(NAME) EXPAND(NAME) + +#ifdef MEMBASE +#define EMMC_BOOT_IMG_HEADER_ADDR (0xFF000+(MEMBASE)) +#else +#define EMMC_BOOT_IMG_HEADER_ADDR 0xFF000 +#endif + +#ifndef MEMSIZE +#define MEMSIZE 1024*1024 +#endif + +#define MAX_TAGS_SIZE 1024 + +#define RECOVERY_MODE 0x77665502 +#define FASTBOOT_MODE 0x77665500 + +/* make 4096 as default size to ensure EFS,EXT4's erasing */ +#define DEFAULT_ERASE_SIZE 4096 +#define MAX_PANEL_BUF_SIZE 128 + +#define UBI_MAGIC "UBI#" +#define DISPLAY_DEFAULT_PREFIX "mdss_mdp" +#define UBI_MAGIC_SIZE 0x04 +#define BOOT_DEV_MAX_LEN 64 + +#define IS_ARM64(ptr) (ptr->magic_64 == KERNEL64_HDR_MAGIC) ? true : false + +#define ADD_OF(a, b) (UINT_MAX - b > a) ? (a + b) : UINT_MAX + +#if UFS_SUPPORT +static const char *emmc_cmdline = " androidboot.bootdevice="; +#else +static const char *emmc_cmdline = " androidboot.emmc=true"; +#endif +static const char *usb_sn_cmdline = " androidboot.serialno="; +static const char *androidboot_mode = " androidboot.mode="; +static const char *loglevel = " quiet"; +static const char *battchg_pause = " androidboot.mode=charger"; +static const char *auth_kernel = " androidboot.authorized_kernel=true"; +static const char *secondary_gpt_enable = " gpt"; + +static const char *baseband_apq = " androidboot.baseband=apq"; +static const char *baseband_msm = " androidboot.baseband=msm"; +static const char *baseband_csfb= " androidboot.baseband=csfb"; +static const char *baseband_svlte2a = " androidboot.baseband=svlte2a"; +static const char *baseband_mdm = " androidboot.baseband=mdm"; +static const char *base
[U-Boot] [PATCH v1 3/4] cleanup code which handles the Android sparse image format
- update license format - port dprintf() to debug() - update formatting Signed-off-by: Steve Rae --- Licenses/bsd-3L-clause.txt | 24 + common/aboot.c | 120 + 2 files changed, 79 insertions(+), 65 deletions(-) create mode 100644 Licenses/bsd-3L-clause.txt diff --git a/Licenses/bsd-3L-clause.txt b/Licenses/bsd-3L-clause.txt new file mode 100644 index 000..3a08ce4 --- /dev/null +++ b/Licenses/bsd-3L-clause.txt @@ -0,0 +1,24 @@ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of The Linux Foundation nor + the names of its contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/common/aboot.c b/common/aboot.c index a302c92..f38fc95 100644 --- a/common/aboot.c +++ b/common/aboot.c @@ -3,31 +3,9 @@ * All rights reserved. * * Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. + * Portions Copyright 2014 Broadcom Corporation. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of The Linux Foundation nor - * the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * SPDX-License-Identifier:BSD-3L-Clause */ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) @@ -70,23 +48,24 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) } data += sparse_header->file_hdr_sz; - if(sparse_header->file_hdr_sz > sizeof(sparse_header_t)) + if (sparse_header->file_hdr_sz > sizeof(sparse_header_t)) { - /* Skip the remaining bytes in a header that is longer than + /* +* Skip the remaining bytes in a header that is longer than * we expected. */ data += (sparse_header->file_hdr_sz - sizeof(sparse_header_t)); } - dprintf (SPEW, "=== Sparse Image Header ===\n"); - dprintf (SPEW, "magic: 0x%x\n", sparse_header->magic); - dprintf (SPEW, "major_version: 0x%x\n", sparse_header->major_version); - dprintf (SPEW, "minor_version: 0x%x\n", sparse_header->minor_version); - dprintf (SPEW, "
[U-Boot] [PATCH v1 4/4] implement the Android sparse image format
update to provide usable implementation to U-Boot Signed-off-by: Steve Rae --- common/aboot.c| 128 +- include/aboot.h | 28 +++ include/sparse_defs.h | 7 +++ 3 files changed, 110 insertions(+), 53 deletions(-) create mode 100644 include/aboot.h create mode 100644 include/sparse_defs.h diff --git a/common/aboot.c b/common/aboot.c index f38fc95..053be49 100644 --- a/common/aboot.c +++ b/common/aboot.c @@ -8,44 +8,32 @@ * SPDX-License-Identifier:BSD-3L-Clause */ -void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) +#include +#include +#include +#include +#include +#include + +void write_sparse_image(block_dev_desc_t *dev_desc, + disk_partition_t *info, const char *part_name, + void *data, unsigned sz) { + lbaint_t blk; + lbaint_t blkcnt; + lbaint_t blks; + uint32_t bytes_written = 0; unsigned int chunk; unsigned int chunk_data_sz; uint32_t *fill_buf = NULL; uint32_t fill_val; - uint32_t chunk_blk_cnt = 0; sparse_header_t *sparse_header; chunk_header_t *chunk_header; uint32_t total_blocks = 0; - unsigned long long ptn = 0; - unsigned long long size = 0; - int index = INVALID_PTN; int i; - uint8_t lun = 0; - - index = partition_get_index(arg); - ptn = partition_get_offset(index); - if(ptn == 0) { - fastboot_fail("partition table doesn't exist"); - return; - } - - size = partition_get_size(index); - if (ROUND_TO_PAGE(sz,511) > size) { - fastboot_fail("size too large"); - return; - } - - lun = partition_get_lun(index); - mmc_set_lun(lun); /* Read and skip over sparse image header */ sparse_header = (sparse_header_t *) data; - if ((sparse_header->total_blks * sparse_header->blk_sz) > size) { - fastboot_fail("size too large"); - return; - } data += sparse_header->file_hdr_sz; if (sparse_header->file_hdr_sz > sizeof(sparse_header_t)) @@ -67,17 +55,31 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) debug("total_blks: %d\n", sparse_header->total_blks); debug("total_chunks: %d\n", sparse_header->total_chunks); + /* verify sparse_header->blk_sz is an exact multiple of info->blksz */ + if (sparse_header->blk_sz != + (sparse_header->blk_sz & ~(info->blksz - 1))) { + printf("%s: Sparse image block size issue [%u]\n", + __func__, sparse_header->blk_sz); + fastboot_fail("sparse image block size issue"); + return; + } + + puts("Flashing Sparse Image\n"); + /* Start processing chunks */ + blk = info->start; for (chunk=0; chunktotal_chunks; chunk++) { /* Read and skip over chunk header */ chunk_header = (chunk_header_t *) data; data += sizeof(chunk_header_t); - debug("=== Chunk Header ===\n"); - debug("chunk_type: 0x%x\n", chunk_header->chunk_type); - debug("chunk_data_sz: 0x%x\n", chunk_header->chunk_sz); - debug("total_size: 0x%x\n", chunk_header->total_sz); + if (chunk_header->chunk_type != CHUNK_TYPE_RAW) { + debug("=== Chunk Header ===\n"); + debug("chunk_type: 0x%x\n", chunk_header->chunk_type); + debug("chunk_data_sz: 0x%x\n", chunk_header->chunk_sz); + debug("total_size: 0x%x\n", chunk_header->total_sz); + } if (sparse_header->chunk_hdr_sz > sizeof(chunk_header_t)) { @@ -90,6 +92,7 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) } chunk_data_sz = sparse_header->blk_sz * chunk_header->chunk_sz; + blkcnt = chunk_data_sz / info->blksz; switch (chunk_header->chunk_type) { case CHUNK_TYPE_RAW: @@ -101,14 +104,25 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) return; } - if (mmc_write(ptn + - ((uint64_t)total_blocks * -sparse_header->blk_sz), - chunk_data_sz, (unsigned int *)data)) - { + if
[U-Boot] [PATCH v5 1/4] usb/gadget: fastboot: add eMMC support for flash command
- add support for 'fastboot flash' command for eMMC devices Signed-off-by: Steve Rae --- Changes in v5: None 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..e559e2a --- /dev/null +++ b/common/fb_mmc.c @@ -0,0 +1,82 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include + +/* The 64 defined bytes plus the '\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 v5 3/4] 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 --- Changes in v5: None 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 #include #include #include @@ -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 v5 4/4] usb/gadget: fastboot: implement sparse format
- add capability to "fastboot flash" with sparse format images Signed-off-by: Steve Rae --- Changes in v5: - use the common/aboot.c for the "sparse format" handling Changes in v4: - rearranged "sparse format" support in this patchset, in order to isolate... Changes in v3: None Changes in v2: None common/Makefile | 1 + common/fb_mmc.c | 33 +++-- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/common/Makefile b/common/Makefile index daebe39..bc53078 100644 --- a/common/Makefile +++ b/common/Makefile @@ -268,6 +268,7 @@ 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 += aboot.o obj-y += fb_mmc.o endif diff --git a/common/fb_mmc.c b/common/fb_mmc.c index e559e2a..c2e896f 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -7,16 +7,24 @@ #include #include #include +#include +#include /* The 64 defined bytes plus the '\0' */ #define RESPONSE_LEN (64 + 1) static char *response_str; -static void fastboot_resp(const char *s) +void fastboot_fail(const char *s) { - strncpy(response_str, s, RESPONSE_LEN); - response_str[RESPONSE_LEN - 1] = '\0'; + strncpy(response_str, "FAIL", 4); + strncat(response_str, s, RESPONSE_LEN - 4 - 1); +} + +void fastboot_okay(const char *s) +{ + strncpy(response_str, "OKAY", 4); + strncat(response_str, s, RESPONSE_LEN - 4 - 1); } static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, @@ -33,7 +41,7 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, if (blkcnt > info->size) { printf("%s: too large for partition: '%s'\n", __func__, part_name); - fastboot_resp("FAILtoo large for partition"); + fastboot_fail("too large for partition"); return; } @@ -44,13 +52,13 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, if (blks != blkcnt) { printf("%s: failed writing to device %d\n", __func__, dev_desc->dev); - fastboot_resp("FAILfailed writing to device"); + fastboot_fail("failed writing to device"); return; } printf(" wrote " LBAFU " bytes to '%s'\n", blkcnt * info->blksz, part_name); - fastboot_resp("OKAY"); + fastboot_okay(""); } void fb_mmc_flash_write(const char *cmd, void *download_buffer, @@ -66,17 +74,22 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, 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"); + fastboot_fail("invalid 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"); + fastboot_fail("cannot find partition"); return; } - write_raw_image(dev_desc, &info, cmd, download_buffer, - download_bytes); + if (is_sparse_image(download_buffer)) { + write_sparse_image(dev_desc, &info, cmd, download_buffer, + download_bytes); + } else { + write_raw_image(dev_desc, &info, cmd, download_buffer, + download_bytes); + } } -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] patman: implement 'reverse' in LogCmd()
- add missing capability 'git log --reverse' Signed-off-by: Steve Rae - a recent change (cda2a61) broke patman, the "Changes in v?" tags are being applied to the wrong commits! END --- tools/patman/gitutil.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index 735c8dd..6af6c2a 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -36,6 +36,8 @@ def LogCmd(commit_range, git_dir=None, oneline=False, reverse=False, cmd += ['log', '--no-color'] if oneline: cmd.append('--oneline') +if reverse: +cmd.append('--reverse') if use_no_decorate: cmd.append('--no-decorate') if count is not None: -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v5 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. This series depends on: http://patchwork.ozlabs.org/patch/379438/ http://patchwork.ozlabs.org/patch/382443/ (to 382446) 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 | 95 + doc/README.android-fastboot | 5 ++- drivers/usb/gadget/f_fastboot.c | 44 +-- include/fb_mmc.h| 8 7 files changed, 166 insertions(+), 9 deletions(-) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v5 2/4] usb/gadget: fastboot: add support for flash command
- implement 'fastboot flash' for eMMC devices Signed-off-by: Steve Rae Reviewed-by: Marek Vasut --- Changes in v5: None 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 4045727..1677609 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 #include #include +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#include +#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
Re: [U-Boot] [PATCH v5 0/4] Implement "fastboot flash" for eMMC
On 14-08-25 07:57 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(???) This has been tested on ARMv7. This series depends on: http://patchwork.ozlabs.org/patch/379438/ This patch is already applied. Correct (But it wasn't when I was preparing this) http://patchwork.ozlabs.org/patch/382443/ (to 382446) Could you resend the above patch series one more time? From the links it seems that in PATCH 1/4 you add the ./common/aboot.c file and at PATCH 2/4 you remove it. Is this done on purpose? yes: done on purpose (in order to see the history of the changes to the file) -- see the comments in the cover letter to that patch-series!!! (I've also trimmed down the CC list). 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 | 95 + doc/README.android-fastboot | 5 ++- drivers/usb/gadget/f_fastboot.c | 44 +-- include/fb_mmc.h| 8 7 files changed, 166 insertions(+), 9 deletions(-) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/4] vexpress64: kconfig: consolidate CONFIG_TARGET_VEXPRESS_AEMV8A_SEMI
Reviewed-by: Steve Rae Thanks, Steve On 14-08-16 11:16 PM, Masahiro Yamada wrote: We do not have to distinguish CONFIG_TARGET_VEXPRESS_AEMV8A_SEMI from CONFIG_TARGET_VEXPRESS_AEMV8A. Rename the former to the latter. Signed-off-by: Masahiro Yamada Cc: David Feng Cc: Steve Rae --- arch/arm/Kconfig | 3 --- board/armltd/vexpress64/Kconfig| 20 configs/vexpress_aemv8a_semi_defconfig | 2 +- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index e97f94d..2bd19b8 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -719,9 +719,6 @@ config TARGET_VENICE2 config TARGET_VEXPRESS_AEMV8A bool "Support vexpress_aemv8a" -config TARGET_VEXPRESS_AEMV8A_SEMI - bool "Support vexpress_aemv8a_semi" - config TARGET_LS2085A_EMU bool "Support ls2085a_emu" diff --git a/board/armltd/vexpress64/Kconfig b/board/armltd/vexpress64/Kconfig index 91eb8d2..d8c4e21 100644 --- a/board/armltd/vexpress64/Kconfig +++ b/board/armltd/vexpress64/Kconfig @@ -17,23 +17,3 @@ config SYS_CONFIG_NAME default "vexpress_aemv8a" endif - -if TARGET_VEXPRESS_AEMV8A_SEMI - -config SYS_CPU - string - default "armv8" - -config SYS_BOARD - string - default "vexpress64" - -config SYS_VENDOR - string - default "armltd" - -config SYS_CONFIG_NAME - string - default "vexpress_aemv8a" - -endif diff --git a/configs/vexpress_aemv8a_semi_defconfig b/configs/vexpress_aemv8a_semi_defconfig index e6dd8e7..24b868c 100644 --- a/configs/vexpress_aemv8a_semi_defconfig +++ b/configs/vexpress_aemv8a_semi_defconfig @@ -1,3 +1,3 @@ CONFIG_SYS_EXTRA_OPTIONS="ARM64,SEMIHOSTING,BASE_FVP" CONFIG_ARM=y -CONFIG_TARGET_VEXPRESS_AEMV8A_SEMI=y +CONFIG_TARGET_VEXPRESS_AEMV8A=y ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v5 0/4] Implement "fastboot flash" for eMMC
On 14-08-26 02:14 AM, Lukasz Majewski wrote: Hi Steve, On 14-08-25 07:57 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(???) This has been tested on ARMv7. This series depends on: http://patchwork.ozlabs.org/patch/379438/ This patch is already applied. Correct (But it wasn't when I was preparing this) http://patchwork.ozlabs.org/patch/382443/ (to 382446) Could you resend the above patch series one more time? From the links it seems that in PATCH 1/4 you add the ./common/aboot.c file and at PATCH 2/4 you remove it. Is this done on purpose? yes: done on purpose (in order to see the history of the changes to the file) -- see the comments in the cover letter to that patch-series!!! Ok, Now it is clear. Is fair as I know bsd-3L-clause license is compatible with GPL. However, to be 100% sure I'd like to ask Tom (as he has much more legal experience than me) to confirm that this code can be added to u-boot. OK -- note that this "bsd-3L-clause" clause is almost identical to the existing "bsd-3-clause" Thanks, Steve (I've also trimmed down the CC list). 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 | 95 + doc/README.android-fastboot | 5 ++- drivers/usb/gadget/f_fastboot.c | 44 +-- include/fb_mmc.h| 8 7 files changed, 166 insertions(+), 9 deletions(-) create mode 100644 common/fb_mmc.c create mode 100644 include/fb_mmc.h Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v6 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. This series depends on: http://patchwork.ozlabs.org/patch/382443/ (to 382446) 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 -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v6 2/4] usb/gadget: fastboot: add support for flash command
- implement 'fastboot flash' for eMMC devices Signed-off-by: Steve Rae Acked-by: Lukasz Majewski Reviewed-by: Marek Vasut --- Changes in v6: - fix spelling Changes in v5: None 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 14d6b22..5e8c9ed 100644 --- a/README +++ b/README @@ -1624,6 +1624,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 additional 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 4045727..1677609 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 #include #include +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#include +#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 v6 4/4] usb/gadget: fastboot: implement sparse format
- add capability to "fastboot flash" with sparse format images Signed-off-by: Steve Rae Acked-by: Lukasz Majewski --- Changes in v6: - remove excess braces Changes in v5: - use the common/aboot.c for the "sparse format" handling Changes in v4: - rearranged "sparse format" support in this patchset, in order to isolate... Changes in v3: None Changes in v2: None common/Makefile | 1 + common/fb_mmc.c | 32 ++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/common/Makefile b/common/Makefile index daebe39..bc53078 100644 --- a/common/Makefile +++ b/common/Makefile @@ -268,6 +268,7 @@ 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 += aboot.o obj-y += fb_mmc.o endif diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 14d3982..fb06d8a 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -7,16 +7,24 @@ #include #include #include +#include +#include /* The 64 defined bytes plus the '\0' */ #define RESPONSE_LEN (64 + 1) static char *response_str; -static void fastboot_resp(const char *s) +void fastboot_fail(const char *s) { - strncpy(response_str, s, RESPONSE_LEN); - response_str[RESPONSE_LEN - 1] = '\0'; + strncpy(response_str, "FAIL", 4); + strncat(response_str, s, RESPONSE_LEN - 4 - 1); +} + +void fastboot_okay(const char *s) +{ + strncpy(response_str, "OKAY", 4); + strncat(response_str, s, RESPONSE_LEN - 4 - 1); } static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, @@ -32,7 +40,7 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, if (blkcnt > info->size) { error("too large for partition: '%s'\n", part_name); - fastboot_resp("FAILtoo large for partition"); + fastboot_fail("too large for partition"); return; } @@ -42,13 +50,13 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, buffer); if (blks != blkcnt) { error("failed writing to device %d\n", dev_desc->dev); - fastboot_resp("FAILfailed writing to device"); + fastboot_fail("failed writing to device"); return; } printf(" wrote " LBAFU " bytes to '%s'\n", blkcnt * info->blksz, part_name); - fastboot_resp("OKAY"); + fastboot_okay(""); } void fb_mmc_flash_write(const char *cmd, void *download_buffer, @@ -64,17 +72,21 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV); if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) { error("invalid mmc device\n"); - fastboot_resp("FAILinvalid mmc device"); + fastboot_fail("invalid mmc device"); return; } ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); if (ret) { error("cannot find partition: '%s'\n", cmd); - fastboot_resp("FAILcannot find partition"); + fastboot_fail("cannot find partition"); return; } - write_raw_image(dev_desc, &info, cmd, download_buffer, - download_bytes); + if (is_sparse_image(download_buffer)) + write_sparse_image(dev_desc, &info, cmd, download_buffer, + download_bytes); + else + write_raw_image(dev_desc, &info, cmd, download_buffer, + download_bytes); } -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v6 3/4] 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 --- Changes in v6: - printf() to error() Changes in v5: None 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 | 15 ++- 2 files changed, 14 insertions(+), 8 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..38c0965 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 #include #include #include @@ -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) { + error("missing variable\n"); 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 { + error("unknown variable: %s\n", cmd); strcpy(response, "FAILVariable not implemented"); } fastboot_tx_write_str(response); @@ -480,7 +483,7 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) strsep(&cmd, ":"); if (!cmd) { - printf("%s: missing partition name\n", __func__); + error("missing partition name\n"); fastboot_tx_write_str("FAILmissing partition name"); return; } @@ -534,10 +537,12 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) } } - if (!func_cb) + if (!func_cb) { + error("unknown command: %s\n", 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 v6 1/4] usb/gadget: fastboot: add eMMC support for flash command
- add support for 'fastboot flash' command for eMMC devices Signed-off-by: Steve Rae --- Changes in v6: - printf() to error() Changes in v5: None 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 | 80 include/fb_mmc.h | 8 ++ 3 files changed, 93 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..14d3982 --- /dev/null +++ b/common/fb_mmc.c @@ -0,0 +1,80 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include + +/* The 64 defined bytes plus the '\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) { + error("too large for partition: '%s'\n", 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) { + error("failed writing to device %d\n", 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) { + error("invalid mmc device\n"); + fastboot_resp("FAILinvalid mmc device"); + return; + } + + ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); + if (ret) { + error("cannot find partition: '%s'\n", 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
Re: [U-Boot] [PATCH v5 1/4] usb/gadget: fastboot: add eMMC support for flash command
Steve agrees!!! -- I have fixed them this time, see "v6", However, I have no issue with you cleaning up the minor issues THANKS, Steve On 14-08-26 02:41 AM, Marek Vasut wrote: On Tuesday, August 26, 2014 at 11:28:43 AM, Lukasz Majewski wrote: Hi Steve, - add support for 'fastboot flash' command for eMMC devices Signed-off-by: Steve Rae If those are only small things, I think we can fix them up ourselves before applying, no? Let's do just that if Steve agrees, no ? 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 v6 4/4] usb/gadget: fastboot: implement sparse format
Hi Michael On 14-08-26 10:07 PM, Michael Trimarchi wrote: Hi Il 26/ago/2014 20:46 "Steve Rae" ha scritto: - add capability to "fastboot flash" with sparse format images Signed-off-by: Steve Rae Acked-by: Lukasz Majewski --- Changes in v6: - remove excess braces Changes in v5: - use the common/aboot.c for the "sparse format" handling Changes in v4: - rearranged "sparse format" support in this patchset, in order to isolate... Changes in v3: None Changes in v2: None common/Makefile | 1 + common/fb_mmc.c | 32 ++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/common/Makefile b/common/Makefile index daebe39..bc53078 100644 --- a/common/Makefile +++ b/common/Makefile @@ -268,6 +268,7 @@ 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 += aboot.o obj-y += fb_mmc.o endif diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 14d3982..fb06d8a 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -7,16 +7,24 @@ #include #include #include +#include +#include /* The 64 defined bytes plus the '\0' */ #define RESPONSE_LEN (64 + 1) static char *response_str; -static void fastboot_resp(const char *s) +void fastboot_fail(const char *s) { - strncpy(response_str, s, RESPONSE_LEN); - response_str[RESPONSE_LEN - 1] = '\0'; + strncpy(response_str, "FAIL", 4); + strncat(response_str, s, RESPONSE_LEN - 4 - 1); +} + Change not connect to bug description. If you remove static this should go in some header. For now it's only overhead. Sorry for the confusion (1) the file "include/aboot.h" defines these two functions, and is part of the patchset that this series depends on (as documented in the cover letter): This series depends on: http://patchwork.ozlabs.org/patch/382443/ (to 382446) (2) this is the implementation of those functions that are required by that patchset (3) so I thought the the commit message was sufficient -- implying that in order to implement the "sparse format" (from aboot.c) that these changes are required... If required, I could submit a "v7" with more information in the commit message Please let me know! Thanks, Steve +void fastboot_okay(const char *s) +{ + strncpy(response_str, "OKAY", 4); + strncat(response_str, s, RESPONSE_LEN - 4 - 1); } Ditto Michael static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, @@ -32,7 +40,7 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, if (blkcnt > info->size) { error("too large for partition: '%s'\n", part_name); - fastboot_resp("FAILtoo large for partition"); + fastboot_fail("too large for partition"); return; } @@ -42,13 +50,13 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, buffer); if (blks != blkcnt) { error("failed writing to device %d\n", dev_desc->dev); - fastboot_resp("FAILfailed writing to device"); + fastboot_fail("failed writing to device"); return; } printf(" wrote " LBAFU " bytes to '%s'\n", blkcnt * info->blksz, part_name); - fastboot_resp("OKAY"); + fastboot_okay(""); } void fb_mmc_flash_write(const char *cmd, void *download_buffer, @@ -64,17 +72,21 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV); if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) { error("invalid mmc device\n"); - fastboot_resp("FAILinvalid mmc device"); + fastboot_fail("invalid mmc device"); return; } ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); if (ret) { error("cannot find partition: '%s'\n", cmd); - fastboot_resp("FAILcannot find partition"); + fastboot_fail("cannot find partition"); return; } - write_raw_image(dev_desc, &info, cmd, download_buffer, - download_bytes); + if (is_sparse_image(download_buffer)) + write_sparse_image(dev_desc, &info, cmd, download_buffer, + download_bytes); + else + write_raw_image(dev_desc, &info, cmd, download_buffer, + download_bytes); } -- 1.8.5 ___ 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] buildman: suspect issue with patman tags
Another issue may be related to the "combined issue" below) Five consecutive builds (with no changes between builds) (1)does not always generate the "u-boot.bin" file (2)random error messages ?!?!? Is anyone else seeing these issues? (please don't delete MAKEALL yet ) Thanks, Steve srae@host1:~/work/to_denx$ tools/buildman/buildman bcm28155_ap No section: 'make-flags' Could not find ./boards.cfg Generating boards.cfg ... (jobs: 8) 1171/1171 [===>] Building current source for 2 boards (2 threads, 4 jobs per thread) 002 /2 0:00:06 : bcm28155_ap srae@host1:~/work/to_denx$ find .. -name "u-boot.[mb]*" -exec ls -l {} \; -rw-r--r-- 1 srae srae 239004 Aug 26 15:34 ../current/.bm-work/00/build/u-boot.map -rw-r--r-- 1 srae srae 245242 Aug 26 15:34 ../current/.bm-work/01/build/u-boot.map -rw-r--r-- 1 srae srae 190100 Aug 26 15:34 ../current/.bm-work/01/build/u-boot.bin srae@host1:~/work/to_denx$ tools/buildman/buildman bcm28155_ap No section: 'make-flags' Building current source for 2 boards (2 threads, 4 jobs per thread) 002 /2 0:00:06 : bcm28155_w1d srae@host1:~/work/to_denx$ find .. -name "u-boot.[mb]*" -exec ls -l {} \; -rw-r--r-- 1 srae srae 239004 Aug 26 15:36 ../current/.bm-work/00/build/u-boot.map -rw-r--r-- 1 srae srae 245242 Aug 26 15:36 ../current/.bm-work/01/build/u-boot.map srae@host1:~/work/to_denx$ tools/buildman/buildman bcm28155_ap No section: 'make-flags' Building current source for 2 boards (2 threads, 4 jobs per thread) arm: + bcm28155_w1d +make[1]: *** [checkarmreloc] Error 1 +make: *** [sub-make] Error 2 002 /2 0:00:06 : bcm28155_ap srae@host1:~/work/to_denx$ find .. -name "u-boot.[mb]*" -exec ls -l {} \; -rw-r--r-- 1 srae srae 239004 Aug 26 15:37 ../current/.bm-work/00/build/u-boot.map -rw-r--r-- 1 srae srae 189744 Aug 26 15:37 ../current/.bm-work/00/build/u-boot.bin -rw-r--r-- 1 srae srae 245242 Aug 26 15:37 ../current/.bm-work/01/build/u-boot.map -rw-r--r-- 1 srae srae 190100 Aug 26 15:37 ../current/.bm-work/01/build/u-boot.bin srae@host1:~/work/to_denx$ tools/buildman/buildman bcm28155_ap No section: 'make-flags' Building current source for 2 boards (2 threads, 4 jobs per thread) arm: + bcm28155_w1d +make[1]: *** [checkarmreloc] Error 1 +make: *** [sub-make] Error 2 002 /2 0:00:06 : bcm28155_ap srae@host1:~/work/to_denx$ find .. -name "u-boot.[mb]*" -exec ls -l {} \; -rw-r--r-- 1 srae srae 239004 Aug 26 15:37 ../current/.bm-work/00/build/u-boot.map -rw-r--r-- 1 srae srae 245242 Aug 26 15:37 ../current/.bm-work/01/build/u-boot.map -rw-r--r-- 1 srae srae 190100 Aug 26 15:37 ../current/.bm-work/01/build/u-boot.bin srae@host1:~/work/to_denx$ tools/buildman/buildman bcm28155_ap No section: 'make-flags' Building current source for 2 boards (2 threads, 4 jobs per thread) arm: + bcm28155_w1d +make[1]: *** [checkarmreloc] Error 1 +make: *** [sub-make] Error 2 002 /2 0:00:05 : bcm28155_w1d srae@host1:~/work/to_denx$ find .. -name "u-boot.[mb]*" -exec ls -l {} \; -rw-r--r-- 1 srae srae 239004 Aug 26 15:39 ../current/.bm-work/00/build/u-boot.map -rw-r--r-- 1 srae srae 245242 Aug 26 15:39 ../current/.bm-work/01/build/u-boot.map srae@host1:~/work/to_denx$ *From:*Steve Rae *Sent:* Monday, August 25, 2014 09:06 *To:* Simon Glass *Subject:* buildman: issue with patman tags Simon, When I combine multiple patch-series, each with their own patman tags in the commit messages, into a single branch... Then: $ tools/buildman/buildman -b combined bcm28155_ap No section: 'make-flags' Traceback (most recent call last): File "tools/buildman/buildman", line 139, in control.DoBuildman(options, args) File "/home/srae/work/to_denx/tools/buildman/control.py", line 161, in DoBuildman options.git_dir, count) File "/home/srae/work/to_denx/tools/buildman/../patman/patchstream.py", line 387, in GetMetaDataForList ps.ProcessLine(line) File "/home/srae/work/to_denx/tools/buildman/../patman/patchstream.py", line 248, in ProcessLine self.AddToSeries(line, name, value) File "/home/srae/work/to_denx/tools/buildman/../patman/patchstream.py", line 94, in AddToSeries self.series.AddTag(self.commit, line, name, value) File "/home/srae/work/to_denx/tools/buildman/../patman/series.py", line 67, in AddTag (commit.hash, line, values, self[name])) ValueError: In 442a87cd: line 'Series-version: 1': Cannot add another value '['1']' to series '4' $ Note: each patch-series individually build successfully with buildman, it is only after I combine that there are issues Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] buildman: selection question
question: Two of the boards that I support are almost the same: Active arm armv7 bcm281xxbroadcom bcm28155_ap bcm28155_ap - Active arm armv7 bcm281xxbroadcom bcm28155_ap bcm28155_w1d bcm28155_ap:BCM_SF2_ETH,BCM_SF2_ETH_GMAC Using "buildman" how can I build the first one (without always building the second one too?) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v5 0/4] Implement "fastboot flash" for eMMC
On 14-08-28 06:24 AM, Tom Rini wrote: On Wed, Aug 27, 2014 at 09:04:09AM +0200, Lukasz Majewski wrote: Hi Steve, On 14-08-26 02:14 AM, Lukasz Majewski wrote: Hi Steve, On 14-08-25 07:57 AM, Lukasz Majewski wrote: [.. snip ...] Is fair as I know bsd-3L-clause license is compatible with GPL. However, to be 100% sure I'd like to ask Tom (as he has much more legal experience than me) to confirm that this code can be added to u-boot. OK -- note that this "bsd-3L-clause" clause is almost identical to the existing "bsd-3-clause" Tom, could you give your opinion on this? So, upstream made a slight (and likely unintentional) change to the normal BSD 3 clause license and changed the last clause from "the copyright holders" to "The Linux Foundation". I've poked our legal dept about this but I suspect the best answer is to go back up to Android folks and ask them to fix this quite likely unintentional change. Actually, there are three diffs, and I am thinking that they were intentional (especially the last one!): $ diff bsd-3-clause.txt bsd-3L-clause.txt 5,6c5notice, this list of conditions and the following disclaimer. 10,12c9,12 < 3. The names of the above-listed copyright holders may not be used 3. Neither the name of The Linux Foundation nor >the names of its contributors may be used to endorse or promote >products derived from this software without specific prior written >permission. 16,17c16,17 < THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR < PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR --- > THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND > NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR So, would U-Boot accept this BSD-3L-Clause, or should I contact Colin Cross to attempt to get a BSD-3-Clause version, or Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] buildman: selection question
Ahhh -- that would work! Thanks, Steve On 14-08-28 07:54 AM, Simon Glass wrote: Hi Steve, On 27 August 2014 15:23, Steve Rae wrote: question: Two of the boards that I support are almost the same: Active arm armv7 bcm281xxbroadcom bcm28155_ap bcm28155_ap - Active arm armv7 bcm281xxbroadcom bcm28155_ap bcm28155_w1d bcm28155_ap:BCM_SF2_ETH,BCM_SF2_ETH_GMAC Using "buildman" how can I build the first one (without always building the second one too?) What command are you using? Are you trying to build bcm28155_ap? Maybe the only option is to use -x bcm28155_w1d to exclude it. You will need the latest series though: http://patchwork.ozlabs.org/patch/382769/ (or see u-boot-x86.git branch 'buildman5') Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] buildman: suspect issue with patman tags
On 14-08-28 07:45 AM, Simon Glass wrote: Hi Steve, On 27 August 2014 15:22, Steve Rae wrote: [... snip ...] *From:*Steve Rae *Sent:* Monday, August 25, 2014 09:06 *To:* Simon Glass *Subject:* buildman: issue with patman tags Simon, When I combine multiple patch-series, each with their own patman tags in the commit messages, into a single branch... Then: $ tools/buildman/buildman -b combined bcm28155_ap No section: 'make-flags' Traceback (most recent call last): File "tools/buildman/buildman", line 139, in control.DoBuildman(options, args) File "/home/srae/work/to_denx/tools/buildman/control.py", line 161, in DoBuildman options.git_dir, count) File "/home/srae/work/to_denx/tools/buildman/../patman/patchstream.py", line 387, in GetMetaDataForList ps.ProcessLine(line) File "/home/srae/work/to_denx/tools/buildman/../patman/patchstream.py", line 248, in ProcessLine self.AddToSeries(line, name, value) File "/home/srae/work/to_denx/tools/buildman/../patman/patchstream.py", line 94, in AddToSeries self.series.AddTag(self.commit, line, name, value) File "/home/srae/work/to_denx/tools/buildman/../patman/series.py", line 67, in AddTag (commit.hash, line, values, self[name])) ValueError: In 442a87cd: line 'Series-version: 1': Cannot add another value '['1']' to series '4' $ Note: each patch-series individually build successfully with buildman, it is only after I combine that there are issues This is because buildman doesn't need these tags. For patman you need to work with one series at a time. If you have multiple series, then some might be at one version and some at another, and it wouldn't know what version to put on the patch. Also there might be multiple cover letters, etc. If you want to keep several series in a branch, you need to use -s and -c to control what portion of the branch represents each series. Yes, I am successfully using these flags in patman; but I want to be able to build all the combined patches... I have thought about adding support for multiple series in a branch - e.g. a marker on the bottom commit, giving each series a name. But I haven't convinced myself it is desirable. That might be too complicated... Maybe just add a flag (in buildman) to simply ignore all of the commit messages (or ignore the patman tags in the commit messages) just so that the build would execute. Actually, the only think that I really need is to be able to build the last one (but I think that "--step=0" is close enough) Thanks, Steve Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [U-Boot, v1, 3/4] cleanup code which handles the Android sparse image format
OK - AWESOME! Can you just update the one line, ( and drop the bsd-3l-clause.txt ) Or would you like me to submit a "v2" ? Thanks, Steve On 14-08-28 10:11 AM, Tom Rini wrote: On Sat, Aug 23, 2014 at 10:39:02AM -0700, Steve Rae wrote: - update license format - port dprintf() to debug() - update formatting Signed-off-by: Steve Rae --- Licenses/bsd-3L-clause.txt | 24 + common/aboot.c | 120 + 2 files changed, 79 insertions(+), 65 deletions(-) create mode 100644 Licenses/bsd-3L-clause.txt diff --git a/Licenses/bsd-3L-clause.txt b/Licenses/bsd-3L-clause.txt new file mode 100644 index 000..3a08ce4 --- /dev/null +++ b/Licenses/bsd-3L-clause.txt @@ -0,0 +1,24 @@ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of The Linux Foundation nor + the names of its contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/common/aboot.c b/common/aboot.c index a302c92..f38fc95 100644 --- a/common/aboot.c +++ b/common/aboot.c @@ -3,31 +3,9 @@ * All rights reserved. * * Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. + * Portions Copyright 2014 Broadcom Corporation. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of The Linux Foundation nor - * the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * SPDX-License-Identifier:BSD-3L-Clause */ OK, so I asked around in the legal dept here and the answer was we can just call it BSD-3-Clause in the SPDX-License-Identifier and be OK, so lets do that. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 2/4] update code which handles Android sparse image format
- remove unnecessary functions Signed-off-by: Steve Rae --- Changes in v2: None common/aboot.c | 2438 1 file changed, 2438 deletions(-) diff --git a/common/aboot.c b/common/aboot.c index 3b5092d..a302c92 100644 --- a/common/aboot.c +++ b/common/aboot.c @@ -30,1819 +30,6 @@ * */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if DEVICE_TREE -#include -#include -#endif - -#include "image_verify.h" -#include "recovery.h" -#include "bootimg.h" -#include "fastboot.h" -#include "sparse_format.h" -#include "mmc.h" -#include "devinfo.h" -#include "board.h" -#include "scm.h" - -extern bool target_use_signed_kernel(void); -extern void platform_uninit(void); -extern void target_uninit(void); -extern int get_target_boot_params(const char *cmdline, const char *part, - char *buf, int buflen); - -void write_device_info_mmc(device_info *dev); -void write_device_info_flash(device_info *dev); - -#define EXPAND(NAME) #NAME -#define TARGET(NAME) EXPAND(NAME) - -#ifdef MEMBASE -#define EMMC_BOOT_IMG_HEADER_ADDR (0xFF000+(MEMBASE)) -#else -#define EMMC_BOOT_IMG_HEADER_ADDR 0xFF000 -#endif - -#ifndef MEMSIZE -#define MEMSIZE 1024*1024 -#endif - -#define MAX_TAGS_SIZE 1024 - -#define RECOVERY_MODE 0x77665502 -#define FASTBOOT_MODE 0x77665500 - -/* make 4096 as default size to ensure EFS,EXT4's erasing */ -#define DEFAULT_ERASE_SIZE 4096 -#define MAX_PANEL_BUF_SIZE 128 - -#define UBI_MAGIC "UBI#" -#define DISPLAY_DEFAULT_PREFIX "mdss_mdp" -#define UBI_MAGIC_SIZE 0x04 -#define BOOT_DEV_MAX_LEN 64 - -#define IS_ARM64(ptr) (ptr->magic_64 == KERNEL64_HDR_MAGIC) ? true : false - -#define ADD_OF(a, b) (UINT_MAX - b > a) ? (a + b) : UINT_MAX - -#if UFS_SUPPORT -static const char *emmc_cmdline = " androidboot.bootdevice="; -#else -static const char *emmc_cmdline = " androidboot.emmc=true"; -#endif -static const char *usb_sn_cmdline = " androidboot.serialno="; -static const char *androidboot_mode = " androidboot.mode="; -static const char *loglevel = " quiet"; -static const char *battchg_pause = " androidboot.mode=charger"; -static const char *auth_kernel = " androidboot.authorized_kernel=true"; -static const char *secondary_gpt_enable = " gpt"; - -static const char *baseband_apq = " androidboot.baseband=apq"; -static const char *baseband_msm = " androidboot.baseband=msm"; -static const char *baseband_csfb= " androidboot.baseband=csfb"; -static const char *baseband_svlte2a = " androidboot.baseband=svlte2a"; -static const char *baseband_mdm = " androidboot.baseband=mdm"; -static const char *baseband_mdm2= " androidboot.baseband=mdm2"; -static const char *baseband_sglte = " androidboot.baseband=sglte"; -static const char *baseband_dsda= " androidboot.baseband=dsda"; -static const char *baseband_dsda2 = " androidboot.baseband=dsda2"; -static const char *baseband_sglte2 = " androidboot.baseband=sglte2"; -static const char *warmboot_cmdline = " qpnp-power-on.warm_boot=1"; - -static unsigned page_size = 0; -static unsigned page_mask = 0; -static char ffbm_mode_string[FFBM_MODE_BUF_SIZE]; -static bool boot_into_ffbm; -static char target_boot_params[64]; - -/* Assuming unauthorized kernel image by default */ -static int auth_kernel_img = 0; - -static device_info device = {DEVICE_MAGIC, 0, 0, 0, 0}; - -struct atag_ptbl_entry -{ - char name[16]; - unsigned offset; - unsigned size; - unsigned flags; -}; - -/* - * Partition info, required to be published - * for fastboot - */ -struct getvar_partition_info { - const char part_name[MAX_GPT_NAME_SIZE]; /* Partition name */ - char getvar_size[MAX_GET_VAR_NAME_SIZE]; /* fastboot get var name for size */ - char getvar_type[MAX_GET_VAR_NAME_SIZE]; /* fastboot get var name for type */ - char size_response[MAX_RSP_SIZE];/* fastboot response for size */ - char type_response[MAX_RSP_SIZE];/* fastboot response for type */ -}; - -/* - * Right now, we are publishing the info for only - * three partitions - */ -struct getvar_partition_info part_info[] = -{ - { "system" , "partition-size:", "partition-type:", "", "ext4" }, - { "userdata", "partition-size:", "partition-type:", "", "ext4" }, - { "cache" , "partition-size:", "partit
[U-Boot] [PATCH v2 3/4] cleanup code which handles the Android sparse image format
- update license format - port dprintf() to debug() - update formatting Signed-off-by: Steve Rae --- Changes in v2: - use BSD-3-Clause common/aboot.c | 120 ++--- 1 file changed, 55 insertions(+), 65 deletions(-) diff --git a/common/aboot.c b/common/aboot.c index a302c92..351199e 100644 --- a/common/aboot.c +++ b/common/aboot.c @@ -3,31 +3,9 @@ * All rights reserved. * * Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. + * Portions Copyright 2014 Broadcom Corporation. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of The Linux Foundation nor - * the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * SPDX-License-Identifier:BSD-3-Clause */ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) @@ -70,23 +48,24 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) } data += sparse_header->file_hdr_sz; - if(sparse_header->file_hdr_sz > sizeof(sparse_header_t)) + if (sparse_header->file_hdr_sz > sizeof(sparse_header_t)) { - /* Skip the remaining bytes in a header that is longer than + /* +* Skip the remaining bytes in a header that is longer than * we expected. */ data += (sparse_header->file_hdr_sz - sizeof(sparse_header_t)); } - dprintf (SPEW, "=== Sparse Image Header ===\n"); - dprintf (SPEW, "magic: 0x%x\n", sparse_header->magic); - dprintf (SPEW, "major_version: 0x%x\n", sparse_header->major_version); - dprintf (SPEW, "minor_version: 0x%x\n", sparse_header->minor_version); - dprintf (SPEW, "file_hdr_sz: %d\n", sparse_header->file_hdr_sz); - dprintf (SPEW, "chunk_hdr_sz: %d\n", sparse_header->chunk_hdr_sz); - dprintf (SPEW, "blk_sz: %d\n", sparse_header->blk_sz); - dprintf (SPEW, "total_blks: %d\n", sparse_header->total_blks); - dprintf (SPEW, "total_chunks: %d\n", sparse_header->total_chunks); + debug("=== Sparse Image Header ===\n"); + debug("magic: 0x%x\n", sparse_header->magic); + debug("major_version: 0x%x\n", sparse_header->major_version); + debug("minor_version: 0x%x\n", sparse_header->minor_version); + debug("file_hdr_sz: %d\n", sparse_header->file_hdr_sz); + debug("chunk_hdr_sz: %d\n", sparse_header->chunk_hdr_sz); + debug("blk_sz: %d\n", sparse_header->blk_sz); + debug("total_blks: %d\n", sparse_header->total_blks); + debug("total_chunks: %d\n", sparse_header->total_chunks); /* Start processing chunks */ for (chunk=0; chunktotal_chunks; chunk++) @@ -95,33 +74,37 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) chunk_header = (chunk_header_t *) data; data += sizeof(chunk_header_t); - dprintf (SPEW, "=== Chunk Header ===\n"); - dprintf (SPEW, "chunk_type: 0x%x\n", chunk_header->chunk_type); - dprintf (SPEW, "chunk_data_sz: 0x%x\n", chunk_header->chunk_sz); - dprintf (SPEW, "total_size: 0x%x\n", chunk_header->total_sz); + debug("
[U-Boot] [PATCH v2 0/4] Implement "sparse format" for fastboot
This series implements the "sparse format" file handling for fastboot. - [1/4] brings in the pristine file "aboot.c" - [2/4] deletes all unnecessary functions in "aboot.c" - [3/4] is a simple cleanup of "aboot.c" - [4/4] provides the implementation of "aboot.c" suitable for U-Boot Changes in v2: - use BSD-3-Clause Steve Rae (4): add code to handle Android sparse image format update code which handles Android sparse image format cleanup code which handles the Android sparse image format implement the Android sparse image format common/aboot.c| 217 ++ include/aboot.h | 28 +++ include/sparse_defs.h | 7 ++ 3 files changed, 252 insertions(+) create mode 100644 common/aboot.c create mode 100644 include/aboot.h create mode 100644 include/sparse_defs.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 4/4] implement the Android sparse image format
update to provide usable implementation to U-Boot Signed-off-by: Steve Rae --- Changes in v2: None common/aboot.c| 128 +- include/aboot.h | 28 +++ include/sparse_defs.h | 7 +++ 3 files changed, 110 insertions(+), 53 deletions(-) create mode 100644 include/aboot.h create mode 100644 include/sparse_defs.h diff --git a/common/aboot.c b/common/aboot.c index 351199e..efeeece 100644 --- a/common/aboot.c +++ b/common/aboot.c @@ -8,44 +8,32 @@ * SPDX-License-Identifier:BSD-3-Clause */ -void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) +#include +#include +#include +#include +#include +#include + +void write_sparse_image(block_dev_desc_t *dev_desc, + disk_partition_t *info, const char *part_name, + void *data, unsigned sz) { + lbaint_t blk; + lbaint_t blkcnt; + lbaint_t blks; + uint32_t bytes_written = 0; unsigned int chunk; unsigned int chunk_data_sz; uint32_t *fill_buf = NULL; uint32_t fill_val; - uint32_t chunk_blk_cnt = 0; sparse_header_t *sparse_header; chunk_header_t *chunk_header; uint32_t total_blocks = 0; - unsigned long long ptn = 0; - unsigned long long size = 0; - int index = INVALID_PTN; int i; - uint8_t lun = 0; - - index = partition_get_index(arg); - ptn = partition_get_offset(index); - if(ptn == 0) { - fastboot_fail("partition table doesn't exist"); - return; - } - - size = partition_get_size(index); - if (ROUND_TO_PAGE(sz,511) > size) { - fastboot_fail("size too large"); - return; - } - - lun = partition_get_lun(index); - mmc_set_lun(lun); /* Read and skip over sparse image header */ sparse_header = (sparse_header_t *) data; - if ((sparse_header->total_blks * sparse_header->blk_sz) > size) { - fastboot_fail("size too large"); - return; - } data += sparse_header->file_hdr_sz; if (sparse_header->file_hdr_sz > sizeof(sparse_header_t)) @@ -67,17 +55,31 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) debug("total_blks: %d\n", sparse_header->total_blks); debug("total_chunks: %d\n", sparse_header->total_chunks); + /* verify sparse_header->blk_sz is an exact multiple of info->blksz */ + if (sparse_header->blk_sz != + (sparse_header->blk_sz & ~(info->blksz - 1))) { + printf("%s: Sparse image block size issue [%u]\n", + __func__, sparse_header->blk_sz); + fastboot_fail("sparse image block size issue"); + return; + } + + puts("Flashing Sparse Image\n"); + /* Start processing chunks */ + blk = info->start; for (chunk=0; chunktotal_chunks; chunk++) { /* Read and skip over chunk header */ chunk_header = (chunk_header_t *) data; data += sizeof(chunk_header_t); - debug("=== Chunk Header ===\n"); - debug("chunk_type: 0x%x\n", chunk_header->chunk_type); - debug("chunk_data_sz: 0x%x\n", chunk_header->chunk_sz); - debug("total_size: 0x%x\n", chunk_header->total_sz); + if (chunk_header->chunk_type != CHUNK_TYPE_RAW) { + debug("=== Chunk Header ===\n"); + debug("chunk_type: 0x%x\n", chunk_header->chunk_type); + debug("chunk_data_sz: 0x%x\n", chunk_header->chunk_sz); + debug("total_size: 0x%x\n", chunk_header->total_sz); + } if (sparse_header->chunk_hdr_sz > sizeof(chunk_header_t)) { @@ -90,6 +92,7 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) } chunk_data_sz = sparse_header->blk_sz * chunk_header->chunk_sz; + blkcnt = chunk_data_sz / info->blksz; switch (chunk_header->chunk_type) { case CHUNK_TYPE_RAW: @@ -101,14 +104,25 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) return; } - if (mmc_write(ptn + - ((uint64_t)total_blocks * -sparse_header->blk_sz), - chunk_data_sz, (unsigned int *)data)) - { + if
[U-Boot] [PATCH v2 1/4] add code to handle Android sparse image format
Add original file (pristine) from : https://www.codeaurora.org/cgit/quic/la/kernel/lk/plain/app/aboot/aboot.c?h=master [3b5092d20bd15a7a2879c13e9f64acc48d04af2d] Signed-off-by: Steve Rae --- Changes in v2: None common/aboot.c | 2643 1 file changed, 2643 insertions(+) create mode 100644 common/aboot.c diff --git a/common/aboot.c b/common/aboot.c new file mode 100644 index 000..3b5092d --- /dev/null +++ b/common/aboot.c @@ -0,0 +1,2643 @@ +/* + * Copyright (c) 2009, Google Inc. + * All rights reserved. + * + * Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of The Linux Foundation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if DEVICE_TREE +#include +#include +#endif + +#include "image_verify.h" +#include "recovery.h" +#include "bootimg.h" +#include "fastboot.h" +#include "sparse_format.h" +#include "mmc.h" +#include "devinfo.h" +#include "board.h" +#include "scm.h" + +extern bool target_use_signed_kernel(void); +extern void platform_uninit(void); +extern void target_uninit(void); +extern int get_target_boot_params(const char *cmdline, const char *part, + char *buf, int buflen); + +void write_device_info_mmc(device_info *dev); +void write_device_info_flash(device_info *dev); + +#define EXPAND(NAME) #NAME +#define TARGET(NAME) EXPAND(NAME) + +#ifdef MEMBASE +#define EMMC_BOOT_IMG_HEADER_ADDR (0xFF000+(MEMBASE)) +#else +#define EMMC_BOOT_IMG_HEADER_ADDR 0xFF000 +#endif + +#ifndef MEMSIZE +#define MEMSIZE 1024*1024 +#endif + +#define MAX_TAGS_SIZE 1024 + +#define RECOVERY_MODE 0x77665502 +#define FASTBOOT_MODE 0x77665500 + +/* make 4096 as default size to ensure EFS,EXT4's erasing */ +#define DEFAULT_ERASE_SIZE 4096 +#define MAX_PANEL_BUF_SIZE 128 + +#define UBI_MAGIC "UBI#" +#define DISPLAY_DEFAULT_PREFIX "mdss_mdp" +#define UBI_MAGIC_SIZE 0x04 +#define BOOT_DEV_MAX_LEN 64 + +#define IS_ARM64(ptr) (ptr->magic_64 == KERNEL64_HDR_MAGIC) ? true : false + +#define ADD_OF(a, b) (UINT_MAX - b > a) ? (a + b) : UINT_MAX + +#if UFS_SUPPORT +static const char *emmc_cmdline = " androidboot.bootdevice="; +#else +static const char *emmc_cmdline = " androidboot.emmc=true"; +#endif +static const char *usb_sn_cmdline = " androidboot.serialno="; +static const char *androidboot_mode = " androidboot.mode="; +static const char *loglevel = " quiet"; +static const char *battchg_pause = " androidboot.mode=charger"; +static const char *auth_kernel = " androidboot.authorized_kernel=true"; +static const char *secondary_gpt_enable = " gpt"; + +static const char *baseband_apq = " androidboot.baseband=apq"; +static const char *baseband_msm = " androidboot.baseband=msm"; +static const char *baseband_csfb= " androidboot.baseband=csfb"; +static const char *baseband_svlte2a = " androidboot.baseband=svlte2a"; +static const char *baseband_mdm = " androidboot.b
Re: [U-Boot] [PATCH v3 0/5] Introducing the Broadcom Cygnus and NSP boards.
On 14-08-11 01:58 PM, Steve Rae wrote: 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 Any chance of getting this in soon? ( we have an upcoming release ) Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 1/3] arm: bcm281xx: Add Ethernet Clock support
On 14-08-01 08:37 PM, Steve Rae wrote: From: Jiandong Zheng Enable Ethernet clock when Broadcom StarFighter2 Ethernet block (CONFIG_BCM_SF2_ETH) is enabled. Signed-off-by: Jiandong Zheng Signed-off-by: Steve Rae --- - 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 +#include +#include +#include +#include +#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 norm
Re: [U-Boot] [PATCH v2 3/4] cleanup code which handles the Android sparse image format
On 14-08-28 12:43 PM, Tom Rini wrote: On Thu, Aug 28, 2014 at 10:53:53AM -0700, Steve Rae wrote: - update license format - port dprintf() to debug() - update formatting Signed-off-by: Steve Rae --- Changes in v2: - use BSD-3-Clause common/aboot.c | 120 ++--- 1 file changed, 55 insertions(+), 65 deletions(-) diff --git a/common/aboot.c b/common/aboot.c index a302c92..351199e 100644 --- a/common/aboot.c +++ b/common/aboot.c @@ -3,31 +3,9 @@ * All rights reserved. * * Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. + * Portions Copyright 2014 Broadcom Corporation. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of The Linux Foundation nor - * the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * SPDX-License-Identifier:BSD-3-Clause */ OK, sorry for the churn. After you pointed out the other differences, I re-asked legal who look a closer look (they started with my "they just changed this one thing..") and do believe the license is GPL compatible but it is NOT BSD-3-Clause. So I think rather than make a one-off tag lets just leave the full text and insert a note saying it's a slightly different wording from normal BSD-3, and we inherit this license as-is from Android. comments: (1) I suspect that the "Linux Foundation" has adopted this "license text", and I also suspect that we will likely getting more code from there; thus, while it is one-off right now, I 'm guessing that will change... (2) so "v3" will leave the original text in place, and add the following: * NOTE: * Although it is very similar, this license text is not identical * to the "BSD-3-Clause", therefore, DO NOT MODIFY THIS LICENSE TEXT! Is this what you would like? ( my preference would be to add the BSD-3L-Clause ... ) Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 1/4] add code to handle Android sparse image format
On 14-08-28 02:16 PM, Tom Rini wrote: On Thu, Aug 28, 2014 at 10:53:51AM -0700, Steve Rae wrote: Add original file (pristine) from : https://www.codeaurora.org/cgit/quic/la/kernel/lk/plain/app/aboot/aboot.c?h=master [3b5092d20bd15a7a2879c13e9f64acc48d04af2d] Signed-off-by: Steve Rae OK, let us back the truck up, so to speak. This particular version of the file has an odd license. Looking at https://android.googlesource.com/kernel/lk/+/master/app/aboot/aboot.c [54963a727d3e4ed1e945c7ec012b5cc5de168ac5] and it has the normal BSD-3-Clause text. Lets grab and adapt that so we can drop the license issue. OK -- "v3" coming soon! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 1/4] add code to handle Android sparse image format
On 14-08-28 02:31 PM, Steve Rae wrote: On 14-08-28 02:16 PM, Tom Rini wrote: On Thu, Aug 28, 2014 at 10:53:51AM -0700, Steve Rae wrote: Add original file (pristine) from : https://www.codeaurora.org/cgit/quic/la/kernel/lk/plain/app/aboot/aboot.c?h=master [3b5092d20bd15a7a2879c13e9f64acc48d04af2d] Signed-off-by: Steve Rae OK, let us back the truck up, so to speak. This particular version of the file has an odd license. Looking at https://android.googlesource.com/kernel/lk/+/master/app/aboot/aboot.c [54963a727d3e4ed1e945c7ec012b5cc5de168ac5] and it has the normal BSD-3-Clause text. Lets grab and adapt that so we can drop the license issue. OK -- "v3" coming soon! OOPS! -- this "aboot.c" does not contain the support for the "sparse image format" -- I cannot use this file! Sorry ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] buildman: suspect issue with patman tags
On 14-08-28 05:59 PM, Simon Glass wrote: Hi Steve, On 28 August 2014 10:21, Steve Rae wrote: On 14-08-28 07:45 AM, Simon Glass wrote: Hi Steve, On 27 August 2014 15:22, Steve Rae wrote: [... snip ...] *From:*Steve Rae *Sent:* Monday, August 25, 2014 09:06 *To:* Simon Glass *Subject:* buildman: issue with patman tags Simon, When I combine multiple patch-series, each with their own patman tags in the commit messages, into a single branch... Then: $ tools/buildman/buildman -b combined bcm28155_ap No section: 'make-flags' Traceback (most recent call last): File "tools/buildman/buildman", line 139, in control.DoBuildman(options, args) File "/home/srae/work/to_denx/tools/buildman/control.py", line 161, in DoBuildman options.git_dir, count) File "/home/srae/work/to_denx/tools/buildman/../patman/patchstream.py", line 387, in GetMetaDataForList ps.ProcessLine(line) File "/home/srae/work/to_denx/tools/buildman/../patman/patchstream.py", line 248, in ProcessLine self.AddToSeries(line, name, value) File "/home/srae/work/to_denx/tools/buildman/../patman/patchstream.py", line 94, in AddToSeries self.series.AddTag(self.commit, line, name, value) File "/home/srae/work/to_denx/tools/buildman/../patman/series.py", line 67, in AddTag (commit.hash, line, values, self[name])) ValueError: In 442a87cd: line 'Series-version: 1': Cannot add another value '['1']' to series '4' $ Note: each patch-series individually build successfully with buildman, it is only after I combine that there are issues This is because buildman doesn't need these tags. For patman you need to work with one series at a time. If you have multiple series, then some might be at one version and some at another, and it wouldn't know what version to put on the patch. Also there might be multiple cover letters, etc. If you want to keep several series in a branch, you need to use -s and -c to control what portion of the branch represents each series. Yes, I am successfully using these flags in patman; but I want to be able to build all the combined patches... I have thought about adding support for multiple series in a branch - e.g. a marker on the bottom commit, giving each series a name. But I haven't convinced myself it is desirable. That might be too complicated... Maybe just add a flag (in buildman) to simply ignore all of the commit messages (or ignore the patman tags in the commit messages) just so that the build would execute. Actually, the only think that I really need is to be able to build the last one (but I think that "--step=0" is close enough) You can build just the top commit by leaving off the -b argument. OK, awesome! Re ignoring duplicate tags, there is logic in there but it doesn't go far enough for all cases. Please try this patch on top of what I sent earlier today (branch buildman6 at u-boot-x86.git) By the time I fetched "buildman6" this morning, it seems that you already added this patch So with this: commit 6aa2c7fa621d888dd0d225af2be5dfe46409f942 Author: Simon Glass Date: Thu Aug 28 17:54:40 2014 -0700 buildman: Ignore conflicting tags running: /tools/buildman/buildman bcm28155_ap it now builds successfully! Thanks, Steve diff --git a/tools/buildman/control.py b/tools/buildman/control.py index c473ab9..3628ac1 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -168,6 +168,10 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, # upstream/master~..branch but that isn't possible if upstream/master is # a merge commit (it will list all the commits that form part of the # merge) +# Conflicting tags are not a problem for buildman, since it does not use +# them. For example, Series-version is not useful for buildman. On the +# other hand conflicting tags will cause an error. So allow later tags +# to overwrite earlier ones by setting allow_overwrite=True if options.branch: if count == -1: range_expr = gitutil.GetRangeInBranch(options.git_dir, @@ -175,19 +179,14 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, upstream_commit = gitutil.GetUpstream(options.git_dir, options.branch) series = patchstream.GetMetaDataForList(upstream_commit, -options.git_dir, 1) +options.git_dir, 1, series=None, allow_overwrite=True) -# Conflicting tags are not a problem for buildman, since it does -# not use them. For example, Series-version is not useful for -# buildman. On the other hand conflicting tags will cause an -# error.
Re: [U-Boot] [PATCH v2 1/4] add code to handle Android sparse image format
On 14-08-29 08:11 AM, Tom Rini wrote: On Thu, Aug 28, 2014 at 02:52:40PM -0700, Steve Rae wrote: On 14-08-28 02:31 PM, Steve Rae wrote: On 14-08-28 02:16 PM, Tom Rini wrote: On Thu, Aug 28, 2014 at 10:53:51AM -0700, Steve Rae wrote: Add original file (pristine) from : https://www.codeaurora.org/cgit/quic/la/kernel/lk/plain/app/aboot/aboot.c?h=master [3b5092d20bd15a7a2879c13e9f64acc48d04af2d] Signed-off-by: Steve Rae OK, let us back the truck up, so to speak. This particular version of the file has an odd license. Looking at https://android.googlesource.com/kernel/lk/+/master/app/aboot/aboot.c [54963a727d3e4ed1e945c7ec012b5cc5de168ac5] and it has the normal BSD-3-Clause text. Lets grab and adapt that so we can drop the license issue. OK -- "v3" coming soon! OOPS! -- this "aboot.c" does not contain the support for the "sparse image format" -- I cannot use this file! Can you poke around more for a version of aboot.c that has sparse image support and comes more directly from google.com and thus hopefully someone caught the rather strange license text changes? I have previously spent hours looking for: (1) sparse_format.h -- which we now have (thanks to Colin Cross) (2) any implementation of the "while()" loop which parses this "sparse format" This implementation, in aboot.c (also recommended by Colin Cross), is also available from "Code Aurora" -- but it has the same wording as the "Linux Foundation" file; I have not found it anywhere else. I cannot spend any more time on this license issue Please keep me informed of the outcome! Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 1/4] add code to handle Android sparse image format
On 14-08-29 01:54 PM, Marek Vasut wrote: On Friday, August 29, 2014 at 07:38:39 PM, Steve Rae wrote: On 14-08-29 08:11 AM, Tom Rini wrote: On Thu, Aug 28, 2014 at 02:52:40PM -0700, Steve Rae wrote: On 14-08-28 02:31 PM, Steve Rae wrote: On 14-08-28 02:16 PM, Tom Rini wrote: On Thu, Aug 28, 2014 at 10:53:51AM -0700, Steve Rae wrote: Add original file (pristine) from : https://www.codeaurora.org/cgit/quic/la/kernel/lk/plain/app/aboot/abo ot.c?h=master [3b5092d20bd15a7a2879c13e9f64acc48d04af2d] Signed-off-by: Steve Rae OK, let us back the truck up, so to speak. This particular version of the file has an odd license. Looking at https://android.googlesource.com/kernel/lk/+/master/app/aboot/aboot.c [54963a727d3e4ed1e945c7ec012b5cc5de168ac5] and it has the normal BSD-3-Clause text. Lets grab and adapt that so we can drop the license issue. OK -- "v3" coming soon! OOPS! -- this "aboot.c" does not contain the support for the "sparse image format" -- I cannot use this file! Can you poke around more for a version of aboot.c that has sparse image support and comes more directly from google.com and thus hopefully someone caught the rather strange license text changes? I have previously spent hours looking for: (1) sparse_format.h -- which we now have (thanks to Colin Cross) (2) any implementation of the "while()" loop which parses this "sparse format" This implementation, in aboot.c (also recommended by Colin Cross), is also available from "Code Aurora" -- but it has the same wording as the "Linux Foundation" file; I have not found it anywhere else. I cannot spend any more time on this license issue Please keep me informed of the outcome! ... and, this is how it ends. Again, legal crap proved to be a death sentence for a patch and carried with it an excessive amount of wasted effort. Best regards, Marek Vasut I certainly hope not 100% dead If U-Boot would accept (the currently one-off) BSD-3L-Clause, then this could live! Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 1/4] add code to handle Android sparse image format
On 14-08-29 04:13 PM, Steve Rae wrote: On 14-08-29 01:54 PM, Marek Vasut wrote: On Friday, August 29, 2014 at 07:38:39 PM, Steve Rae wrote: On 14-08-29 08:11 AM, Tom Rini wrote: On Thu, Aug 28, 2014 at 02:52:40PM -0700, Steve Rae wrote: On 14-08-28 02:31 PM, Steve Rae wrote: On 14-08-28 02:16 PM, Tom Rini wrote: On Thu, Aug 28, 2014 at 10:53:51AM -0700, Steve Rae wrote: Add original file (pristine) from : https://www.codeaurora.org/cgit/quic/la/kernel/lk/plain/app/aboot/abo ot.c?h=master [3b5092d20bd15a7a2879c13e9f64acc48d04af2d] Signed-off-by: Steve Rae OK, let us back the truck up, so to speak. This particular version of the file has an odd license. Looking at https://android.googlesource.com/kernel/lk/+/master/app/aboot/aboot.c [54963a727d3e4ed1e945c7ec012b5cc5de168ac5] and it has the normal BSD-3-Clause text. Lets grab and adapt that so we can drop the license issue. OK -- "v3" coming soon! OOPS! -- this "aboot.c" does not contain the support for the "sparse image format" -- I cannot use this file! Can you poke around more for a version of aboot.c that has sparse image support and comes more directly from google.com and thus hopefully someone caught the rather strange license text changes? I have previously spent hours looking for: (1) sparse_format.h -- which we now have (thanks to Colin Cross) (2) any implementation of the "while()" loop which parses this "sparse format" This implementation, in aboot.c (also recommended by Colin Cross), is also available from "Code Aurora" -- but it has the same wording as the "Linux Foundation" file; I have not found it anywhere else. I cannot spend any more time on this license issue Please keep me informed of the outcome! ... and, this is how it ends. Again, legal crap proved to be a death sentence for a patch and carried with it an excessive amount of wasted effort. Best regards, Marek Vasut I certainly hope not 100% dead If U-Boot would accept (the currently one-off) BSD-3L-Clause, then this could live! Thanks, Steve Any progress on the license wording? (1) create BSD-3L-Clause or (2) leave the original text in place, and add the following: * NOTE: * Although it is very similar, this license text is not identical * to the "BSD-3-Clause", therefore, DO NOT MODIFY THIS LICENSE TEXT! or (3) ??? Please let me know! Thanks, Steve ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 3/4] cleanup code which handles the Android sparse image format
- port dprintf() to debug() - update formatting Signed-off-by: Steve Rae --- Changes in v3: - use original license text Changes in v2: - use BSD-3-Clause common/aboot.c | 97 +- 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/common/aboot.c b/common/aboot.c index a302c92..3611feb 100644 --- a/common/aboot.c +++ b/common/aboot.c @@ -28,6 +28,9 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * NOTE: + * Although it is very similar, this license text is not identical + * to the "BSD-3-Clause", therefore, DO NOT MODIFY THIS LICENSE TEXT! */ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) @@ -70,23 +73,24 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) } data += sparse_header->file_hdr_sz; - if(sparse_header->file_hdr_sz > sizeof(sparse_header_t)) + if (sparse_header->file_hdr_sz > sizeof(sparse_header_t)) { - /* Skip the remaining bytes in a header that is longer than + /* +* Skip the remaining bytes in a header that is longer than * we expected. */ data += (sparse_header->file_hdr_sz - sizeof(sparse_header_t)); } - dprintf (SPEW, "=== Sparse Image Header ===\n"); - dprintf (SPEW, "magic: 0x%x\n", sparse_header->magic); - dprintf (SPEW, "major_version: 0x%x\n", sparse_header->major_version); - dprintf (SPEW, "minor_version: 0x%x\n", sparse_header->minor_version); - dprintf (SPEW, "file_hdr_sz: %d\n", sparse_header->file_hdr_sz); - dprintf (SPEW, "chunk_hdr_sz: %d\n", sparse_header->chunk_hdr_sz); - dprintf (SPEW, "blk_sz: %d\n", sparse_header->blk_sz); - dprintf (SPEW, "total_blks: %d\n", sparse_header->total_blks); - dprintf (SPEW, "total_chunks: %d\n", sparse_header->total_chunks); + debug("=== Sparse Image Header ===\n"); + debug("magic: 0x%x\n", sparse_header->magic); + debug("major_version: 0x%x\n", sparse_header->major_version); + debug("minor_version: 0x%x\n", sparse_header->minor_version); + debug("file_hdr_sz: %d\n", sparse_header->file_hdr_sz); + debug("chunk_hdr_sz: %d\n", sparse_header->chunk_hdr_sz); + debug("blk_sz: %d\n", sparse_header->blk_sz); + debug("total_blks: %d\n", sparse_header->total_blks); + debug("total_chunks: %d\n", sparse_header->total_chunks); /* Start processing chunks */ for (chunk=0; chunktotal_chunks; chunk++) @@ -95,33 +99,37 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) chunk_header = (chunk_header_t *) data; data += sizeof(chunk_header_t); - dprintf (SPEW, "=== Chunk Header ===\n"); - dprintf (SPEW, "chunk_type: 0x%x\n", chunk_header->chunk_type); - dprintf (SPEW, "chunk_data_sz: 0x%x\n", chunk_header->chunk_sz); - dprintf (SPEW, "total_size: 0x%x\n", chunk_header->total_sz); + debug("=== Chunk Header ===\n"); + debug("chunk_type: 0x%x\n", chunk_header->chunk_type); + debug("chunk_data_sz: 0x%x\n", chunk_header->chunk_sz); + debug("total_size: 0x%x\n", chunk_header->total_sz); - if(sparse_header->chunk_hdr_sz > sizeof(chunk_header_t)) + if (sparse_header->chunk_hdr_sz > sizeof(chunk_header_t)) { - /* Skip the remaining bytes in a header that is longer than -* we expected. + /* +* Skip the remaining bytes in a header that is longer +* than we expected. */ - data += (sparse_header->chunk_hdr_sz - sizeof(chunk_header_t)); + data += (sparse_header->chunk_hdr_sz - +sizeof(chunk_header_t)); } chunk_data_sz = sparse_header->blk_sz * chunk_header->chunk_sz; switch (chunk_header->chunk_type) { case CHUNK_TYPE_RAW: - if(chunk_header->total_sz != (sparse_header->chunk_hdr_sz + - chunk_data_sz)) + if (chunk_header->total_sz != + (spar
[U-Boot] [PATCH v3 1/4] add code to handle Android sparse image format
Add original file (pristine) from : https://www.codeaurora.org/cgit/quic/la/kernel/lk/plain/app/aboot/aboot.c?h=master [3b5092d20bd15a7a2879c13e9f64acc48d04af2d] Signed-off-by: Steve Rae --- Changes in v3: None Changes in v2: None common/aboot.c | 2643 1 file changed, 2643 insertions(+) create mode 100644 common/aboot.c diff --git a/common/aboot.c b/common/aboot.c new file mode 100644 index 000..3b5092d --- /dev/null +++ b/common/aboot.c @@ -0,0 +1,2643 @@ +/* + * Copyright (c) 2009, Google Inc. + * All rights reserved. + * + * Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of The Linux Foundation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if DEVICE_TREE +#include +#include +#endif + +#include "image_verify.h" +#include "recovery.h" +#include "bootimg.h" +#include "fastboot.h" +#include "sparse_format.h" +#include "mmc.h" +#include "devinfo.h" +#include "board.h" +#include "scm.h" + +extern bool target_use_signed_kernel(void); +extern void platform_uninit(void); +extern void target_uninit(void); +extern int get_target_boot_params(const char *cmdline, const char *part, + char *buf, int buflen); + +void write_device_info_mmc(device_info *dev); +void write_device_info_flash(device_info *dev); + +#define EXPAND(NAME) #NAME +#define TARGET(NAME) EXPAND(NAME) + +#ifdef MEMBASE +#define EMMC_BOOT_IMG_HEADER_ADDR (0xFF000+(MEMBASE)) +#else +#define EMMC_BOOT_IMG_HEADER_ADDR 0xFF000 +#endif + +#ifndef MEMSIZE +#define MEMSIZE 1024*1024 +#endif + +#define MAX_TAGS_SIZE 1024 + +#define RECOVERY_MODE 0x77665502 +#define FASTBOOT_MODE 0x77665500 + +/* make 4096 as default size to ensure EFS,EXT4's erasing */ +#define DEFAULT_ERASE_SIZE 4096 +#define MAX_PANEL_BUF_SIZE 128 + +#define UBI_MAGIC "UBI#" +#define DISPLAY_DEFAULT_PREFIX "mdss_mdp" +#define UBI_MAGIC_SIZE 0x04 +#define BOOT_DEV_MAX_LEN 64 + +#define IS_ARM64(ptr) (ptr->magic_64 == KERNEL64_HDR_MAGIC) ? true : false + +#define ADD_OF(a, b) (UINT_MAX - b > a) ? (a + b) : UINT_MAX + +#if UFS_SUPPORT +static const char *emmc_cmdline = " androidboot.bootdevice="; +#else +static const char *emmc_cmdline = " androidboot.emmc=true"; +#endif +static const char *usb_sn_cmdline = " androidboot.serialno="; +static const char *androidboot_mode = " androidboot.mode="; +static const char *loglevel = " quiet"; +static const char *battchg_pause = " androidboot.mode=charger"; +static const char *auth_kernel = " androidboot.authorized_kernel=true"; +static const char *secondary_gpt_enable = " gpt"; + +static const char *baseband_apq = " androidboot.baseband=apq"; +static const char *baseband_msm = " androidboot.baseband=msm"; +static const char *baseband_csfb= " androidboot.baseband=csfb"; +static const char *baseband_svlte2a = " androidboot.baseband=svlte2a"; +static const char *baseband_mdm = " androidboot.b
[U-Boot] [PATCH v3 0/4] Implement "sparse format" for fastboot
This series implements the "sparse format" file handling for fastboot. - [1/4] brings in the pristine file "aboot.c" - [2/4] deletes all unnecessary functions in "aboot.c" - [3/4] is a simple cleanup of "aboot.c" - [4/4] provides the implementation of "aboot.c" suitable for U-Boot Changes in v3: - use original license text Changes in v2: - use BSD-3-Clause Steve Rae (4): add code to handle Android sparse image format update code which handles Android sparse image format cleanup code which handles the Android sparse image format implement the Android sparse image format common/aboot.c| 243 ++ include/aboot.h | 28 ++ include/sparse_defs.h | 7 ++ 3 files changed, 278 insertions(+) create mode 100644 common/aboot.c create mode 100644 include/aboot.h create mode 100644 include/sparse_defs.h -- 1.8.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot