From 5b3ddb17baec13b4386620b533527d0f53ddeddf Mon Sep 17 00:00:00 2001 From: Jason Wessel Date: Tue, 23 Jun 2020 14:36:54 -0700 Subject: [PATCH 01/22] fs/fat/fat.c: Do not perform zero block reads if there are no blocks left While using u-boot with qemu's virtio driver I stumbled across a problem reading files less than sector size. On the real hardware the block reader seems ok with reading zero blocks, and while we could fix the virtio host side of qemu to deal with a zero block read instead of crashing, the u-boot fat driver should not be doing zero block reads in the first place. If you ask hardware to read zero blocks you are just going to get zero data. There may also be other hardware that responds similarly to the virtio interface so this is worth fixing. Without the patch I get the following and have to restart qemu because it dies. --------------------------------- => fatls virtio 0:1 30 cmdline.txt => fatload virtio 0:1 ${loadaddr} cmdline.txt qemu-system-aarch64: virtio: zero sized buffers are not allowed --------------------------------- With the patch I get the expected results. --------------------------------- => fatls virtio 0:1 30 cmdline.txt => fatload virtio 0:1 ${loadaddr} cmdline.txt 30 bytes read in 11 ms (2 KiB/s) => md.b ${loadaddr} 0x1E 40080000: 64 77 63 5f 6f 74 67 2e 6c 70 6d 5f 65 6e 61 62 dwc_otg.lpm_enab 40080010: 6c 65 3d 30 20 72 6f 6f 74 77 61 69 74 0a le=0 rootwait. --------------------------------- Signed-off-by: Jason Wessel Signed-off-by: Jason Wessel Reviewed-by: Tom Rini --- fs/fat/fat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 9578b74bae7..28aa5aaa9ff 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -278,7 +278,10 @@ get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, unsigned long size) } } else { idx = size / mydata->sect_size; - ret = disk_read(startsect, idx, buffer); + if (idx == 0) + ret = 0; + else + ret = disk_read(startsect, idx, buffer); if (ret != idx) { debug("Error reading data (got %d)\n", ret); return -1; From 4a4830cf915e76f07cff5ce346c3ccbc987c1557 Mon Sep 17 00:00:00 2001 From: John Chau Date: Thu, 2 Jul 2020 12:01:21 +0800 Subject: [PATCH 02/22] cmd: add clone command This patch adds a feature for block device cloning similar to dd command, this should be useful for boot-strapping a device where usb gadget or networking is not available. For instance one can clone a factory image into a blank emmc from an external sd card. Signed-off-by: John Chau --- arch/Kconfig | 1 + cmd/Kconfig | 8 ++++ cmd/Makefile | 1 + cmd/clone.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 cmd/clone.c diff --git a/arch/Kconfig b/arch/Kconfig index 7f3cbe2ec88..2174336fa00 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -139,6 +139,7 @@ config SANDBOX imply ACPI_PMC imply ACPI_PMC_SANDBOX imply CMD_PMC + imply CMD_CLONE config SH bool "SuperH architecture" diff --git a/cmd/Kconfig b/cmd/Kconfig index d7136b0e790..e11176451b1 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1148,6 +1148,14 @@ config CMD_MMC_SWRITE endif +config CMD_CLONE + bool "clone" + depends on BLK + help + Enable storage cloning over block devices, useful for + initial flashing by external block device without network + or usb support. + config CMD_MTD bool "mtd" depends on MTD diff --git a/cmd/Makefile b/cmd/Makefile index 6e0086ba07f..70750375d12 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -98,6 +98,7 @@ obj-$(CONFIG_CMD_MMC) += mmc.o obj-$(CONFIG_MP) += mp.o obj-$(CONFIG_CMD_MTD) += mtd.o obj-$(CONFIG_CMD_MTDPARTS) += mtdparts.o +obj-$(CONFIG_CMD_CLONE) += clone.o ifneq ($(CONFIG_CMD_NAND)$(CONFIG_CMD_SF),) obj-y += legacy-mtd-utils.o endif diff --git a/cmd/clone.c b/cmd/clone.c new file mode 100644 index 00000000000..97747f8f080 --- /dev/null +++ b/cmd/clone.c @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020 John Chau + * + */ + +#include +#include +#include +#include +#include +#include + +#define BUFSIZE (1 * 1024 * 1024) +static int do_clone(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) +{ + int srcdev, destdev; + struct blk_desc *srcdesc, *destdesc; + int srcbz, destbz, ret; + char *unit, *buf; + unsigned long wrcnt, rdcnt, requested, srcblk, destblk; + unsigned long timer; + const unsigned long buffersize = 1024 * 1024; + + if (argc < 6) + return CMD_RET_USAGE; + + srcdev = blk_get_device_by_str(argv[1], argv[2], &srcdesc); + destdev = blk_get_device_by_str(argv[3], argv[4], &destdesc); + if (srcdev < 0) { + printf("Unable to open source device\n"); + return 1; + } else if (destdev < 0) { + printf("Unable to open destination device\n"); + return 1; + } + requested = simple_strtoul(argv[5], &unit, 10); + srcbz = srcdesc->blksz; + destbz = destdesc->blksz; + + if ((srcbz * (buffersize / srcbz) != buffersize) && + (destbz * (buffersize / destbz) != buffersize)) { + printf("failed: cannot match device block sizes\n"); + return 1; + } + if (requested == 0) { + unsigned long a = srcdesc->lba * srcdesc->blksz; + unsigned long b = destdesc->lba * destdesc->blksz; + + if (a > b) + requested = a; + else + requested = b; + } else { + switch (unit[0]) { + case 'g': + case 'G': + requested *= 1024; + case 'm': + case 'M': + requested *= 1024; + case 'k': + case 'K': + requested *= 1024; + break; + } + } + printf("Copying %ld bytes from %s:%s to %s:%s\n", + requested, argv[1], argv[2], argv[3], argv[4]); + wrcnt = 0; + rdcnt = 0; + buf = (char *)malloc(BUFSIZE); + srcblk = 0; + destblk = 0; + timer = get_timer(0); + while (wrcnt < requested) { + unsigned long toread = BUFSIZE / srcbz; + unsigned long towrite = BUFSIZE / destbz; + unsigned long offset = 0; + +read: + ret = blk_dread(srcdesc, srcblk, toread, buf + offset); + if (ret < 0) { + printf("Src read error @blk %ld\n", srcblk); + goto exit; + } + rdcnt += ret * srcbz; + srcblk += ret; + if (ret < toread) { + toread -= ret; + offset += ret * srcbz; + goto read; + } + offset = 0; +write: + ret = blk_dwrite(destdesc, destblk, towrite, buf + offset); + if (ret < 0) { + printf("Dest write error @blk %ld\n", srcblk); + goto exit; + } + wrcnt += ret * destbz; + destblk += ret; + if (ret < towrite) { + towrite -= ret; + offset += ret * destbz; + goto write; + } + } + +exit: + timer = get_timer(timer); + timer = 1000 * timer / CONFIG_SYS_HZ; + printf("%ld read\n", rdcnt); + printf("%ld written\n", wrcnt); + printf("%ldms, %ldkB/s\n", timer, wrcnt / timer); + free(buf); + + return 0; +} + +U_BOOT_CMD( + clone, 6, 1, do_clone, + "simple storage cloning", + " \n" + "clone storage from 'src dev' on 'src interface' to 'dest dev' on 'dest interface' with maximum 'size' bytes (or 0 for clone to end)" +); From 06fc4573b9d0878dd1d3b302884601263fe6e85f Mon Sep 17 00:00:00 2001 From: "Doyle, Patrick" Date: Wed, 15 Jul 2020 14:46:34 +0000 Subject: [PATCH 03/22] Fix corner case in bad block table handling. In the unlikely event that both blocks 10 and 11 are marked as bad (on a 32 bit machine), then the process of marking block 10 as bad stomps on cached entry for block 11. There are (of course) other examples. Signed-off-by: Patrick Doyle Reviewed-by: Richard Weinberger --- drivers/mtd/nand/bbt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c index 84d60b86521..294daee7b22 100644 --- a/drivers/mtd/nand/bbt.c +++ b/drivers/mtd/nand/bbt.c @@ -127,7 +127,7 @@ int nanddev_bbt_set_block_status(struct nand_device *nand, unsigned int entry, unsigned int rbits = bits_per_block + offs - BITS_PER_LONG; pos[1] &= ~GENMASK(rbits - 1, 0); - pos[1] |= val >> rbits; + pos[1] |= val >> (bits_per_block - rbits); } return 0; From 5cc7df7ebaccc0d02e3322a35b2dcb47951bc9ae Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Fri, 17 Jul 2020 14:20:15 +0200 Subject: [PATCH 04/22] psci: put psci_method in .data section if EFI_LOADER is not enabled Move the variable psci_method in .data section when EFI is not activated and the psci driver safely access it before relocation. Without this patch the variable is located in .bss section and the psci probe requested before relocation corrupts the device tree (probe is requested by board_f.c::print_resetinfo()). When EFI_LOADER is activated, this variable in already located in the .data.efi_runtime section by __efi_runtime_data. Signed-off-by: Yann Gautier Signed-off-by: Patrick Delaunay --- drivers/firmware/psci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 23cf807591c..7d2e49fd3e3 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -25,7 +25,11 @@ #define PSCI_METHOD_HVC 1 #define PSCI_METHOD_SMC 2 +#if CONFIG_IS_ENABLED(EFI_LOADER) int __efi_runtime_data psci_method; +#else +int psci_method __attribute__ ((section(".data"))); +#endif unsigned long __efi_runtime invoke_psci_fn (unsigned long function_id, unsigned long arg0, From cc6b87ecaa96325577a8fafabc0d5972b816bc6c Mon Sep 17 00:00:00 2001 From: Ramon Fried Date: Sat, 18 Jul 2020 23:31:46 +0300 Subject: [PATCH 05/22] net: tftp: Add client support for RFC 7440 Add support for RFC 7440: "TFTP Windowsize Option". This optional feature allows the client and server to negotiate a window size of consecutive blocks to send as an alternative for replacing the single-block lockstep schema. windowsize can be defined statically during compilation by setting CONFIG_TFTP_WINDOWSIZE, or defined in runtime by setting an environment variable: "tftpwindowsize" If not defined, the windowsize is set to 1, meaning that it behaves as it was never defined. Choosing the appropriate windowsize depends on the specific network topology, underlying NIC. You should test various windowsize scenarios and see which best work for you. Setting a windowsize too big can actually decreases performance. Signed-off-by: Ramon Fried Reviewed-by: Marek Vasut --- README | 5 ++++ net/Kconfig | 9 ++++++ net/tftp.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 86 insertions(+), 7 deletions(-) diff --git a/README b/README index d4bf74ce75d..121dc4966af 100644 --- a/README +++ b/README @@ -3444,6 +3444,11 @@ List of environment variables (most likely not complete): downloads succeed with high packet loss rates, or with unreliable TFTP servers or client hardware. + tftpwindowsize - if this is set, the value is used for TFTP's + window size as described by RFC 7440. + This means the count of blocks we can receive before + sending ack to server. + vlan - When set to a value < 4095 the traffic over Ethernet is encapsulated/received over 802.1q VLAN tagged frames. diff --git a/net/Kconfig b/net/Kconfig index 6c47b7d69c5..6874b55aacb 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -59,4 +59,13 @@ config TFTP_BLOCKSIZE almost-MTU block sizes. You can also activate CONFIG_IP_DEFRAG to set a larger block. +config TFTP_WINDOWSIZE + int "TFTP window size" + default 1 + help + Default TFTP window size. + RFC7440 defines an optional window size of transmits, + before an ack response is required. + The default TFTP implementation implies a window size of 1. + endif # if NET diff --git a/net/tftp.c b/net/tftp.c index c05b7b5532b..84e970bec13 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -5,7 +5,6 @@ * Copyright 2011 Comelit Group SpA, * Luca Ceresoli */ - #include #include #include @@ -98,6 +97,12 @@ static int tftp_tsize; /* The number of hashes we printed */ static short tftp_tsize_num_hash; #endif +/* The window size negotiated */ +static ushort tftp_windowsize; +/* Next block to send ack to */ +static ushort tftp_next_ack; +/* Last nack block we send */ +static ushort tftp_last_nack; #ifdef CONFIG_CMD_TFTPPUT /* 1 if writing, else 0 */ static int tftp_put_active; @@ -138,8 +143,19 @@ static char tftp_filename[MAX_LEN]; * (but those using CONFIG_IP_DEFRAG may want to set a larger block in cfg file) */ +/* When windowsize is defined to 1, + * tftp behaves the same way as it was + * never declared + */ +#ifdef CONFIG_TFTP_WINDOWSIZE +#define TFTP_WINDOWSIZE CONFIG_TFTP_WINDOWSIZE +#else +#define TFTP_WINDOWSIZE 1 +#endif + static unsigned short tftp_block_size = TFTP_BLOCK_SIZE; static unsigned short tftp_block_size_option = CONFIG_TFTP_BLOCKSIZE; +static unsigned short tftp_window_size_option = TFTP_WINDOWSIZE; static inline int store_block(int block, uchar *src, unsigned int len) { @@ -356,6 +372,14 @@ static void tftp_send(void) /* try for more effic. blk size */ pkt += sprintf((char *)pkt, "blksize%c%d%c", 0, tftp_block_size_option, 0); + + /* try for more effic. window size. + * Implemented only for tftp get. + * Don't bother sending if it's 1 + */ + if (tftp_state == STATE_SEND_RRQ && tftp_window_size_option > 1) + pkt += sprintf((char *)pkt, "windowsize%c%d%c", + 0, tftp_window_size_option, 0); len = pkt - xp; break; @@ -550,7 +574,17 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip, (char *)pkt + i + 6, tftp_tsize); } #endif + if (strcasecmp((char *)pkt + i, "windowsize") == 0) { + tftp_windowsize = + simple_strtoul((char *)pkt + i + 11, + NULL, 10); + debug("windowsize = %s, %d\n", + (char *)pkt + i + 11, tftp_windowsize); + } } + + tftp_next_ack = tftp_windowsize; + #ifdef CONFIG_CMD_TFTPPUT if (tftp_put_active && tftp_state == STATE_OACK) { /* Get ready to send the first block */ @@ -564,7 +598,28 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip, if (len < 2) return; len -= 2; - tftp_cur_block = ntohs(*(__be16 *)pkt); + + if (ntohs(*(__be16 *)pkt) != (ushort)(tftp_cur_block + 1)) { + debug("Received unexpected block: %d, expected: %d\n", + ntohs(*(__be16 *)pkt), + (ushort)(tftp_cur_block + 1)); + /* + * If one packet is dropped most likely + * all other buffers in the window + * that will arrive will cause a sending NACK. + * This just overwellms the server, let's just send one. + */ + if (tftp_last_nack != tftp_cur_block) { + tftp_send(); + tftp_last_nack = tftp_cur_block; + tftp_next_ack = (ushort)(tftp_cur_block + + tftp_windowsize); + } + break; + } + + tftp_cur_block++; + tftp_cur_block %= TFTP_SEQUENCE_SIZE; if (tftp_state == STATE_SEND_RRQ) debug("Server did not acknowledge any options!\n"); @@ -606,10 +661,15 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip, * Acknowledge the block just received, which will prompt * the remote for the next one. */ - tftp_send(); + if (tftp_cur_block == tftp_next_ack) { + tftp_send(); + tftp_next_ack += tftp_windowsize; + } - if (len < tftp_block_size) + if (len < tftp_block_size) { + tftp_send(); tftp_complete(); + } break; case TFTP_ERROR: @@ -683,6 +743,10 @@ void tftp_start(enum proto_t protocol) if (ep != NULL) tftp_block_size_option = simple_strtol(ep, NULL, 10); + ep = env_get("tftpwindowsize"); + if (ep != NULL) + tftp_window_size_option = simple_strtol(ep, NULL, 10); + ep = env_get("tftptimeout"); if (ep != NULL) timeout_ms = simple_strtol(ep, NULL, 10); @@ -704,8 +768,8 @@ void tftp_start(enum proto_t protocol) } #endif - debug("TFTP blocksize = %i, timeout = %ld ms\n", - tftp_block_size_option, timeout_ms); + debug("TFTP blocksize = %i, TFTP windowsize = %d timeout = %ld ms\n", + tftp_block_size_option, tftp_window_size_option, timeout_ms); tftp_remote_ip = net_server_ip; if (!net_parse_bootfile(&tftp_remote_ip, tftp_filename, MAX_LEN)) { @@ -801,7 +865,8 @@ void tftp_start(enum proto_t protocol) tftp_our_port = simple_strtol(ep, NULL, 10); #endif tftp_cur_block = 0; - + tftp_windowsize = 1; + tftp_last_nack = 0; /* zero out server ether in case the server ip has changed */ memset(net_server_ethaddr, 0, 6); /* Revert tftp_block_size to dflt */ From 9996cea75f5a77db5a6055342130d27a36830ef8 Mon Sep 17 00:00:00 2001 From: Tero Kristo Date: Mon, 20 Jul 2020 11:10:45 +0300 Subject: [PATCH 06/22] lmb/bdinfo: dump lmb info via bdinfo Dump lmb status from the bdinfo command. This is useful for seeing the reserved memory regions from the u-boot cmdline. Signed-off-by: Tero Kristo --- cmd/bdinfo.c | 7 +++++++ include/lmb.h | 1 + lib/lmb.c | 52 +++++++++++++++++++++++++++------------------------ 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index 8b2c105e777..2a6dd6c67a5 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -96,6 +97,12 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) #if CONFIG_IS_ENABLED(MULTI_DTB_FIT) bdinfo_print_num("multi_dtb_fit", (ulong)gd->multi_dtb_fit); #endif + if (gd->fdt_blob) { + struct lmb lmb; + + lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob); + lmb_dump_all_force(&lmb); + } arch_print_bdinfo(); diff --git a/include/lmb.h b/include/lmb.h index 73b7a5cbe3d..e9f19b16ea0 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -49,6 +49,7 @@ extern int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr); extern long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size); extern void lmb_dump_all(struct lmb *lmb); +extern void lmb_dump_all_force(struct lmb *lmb); static inline phys_size_t lmb_size_bytes(struct lmb_region *type, unsigned long region_nr) diff --git a/lib/lmb.c b/lib/lmb.c index 2d680d8d02f..75082f35599 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -14,33 +14,37 @@ #define LMB_ALLOC_ANYWHERE 0 +void lmb_dump_all_force(struct lmb *lmb) +{ + unsigned long i; + + printf("lmb_dump_all:\n"); + printf(" memory.cnt = 0x%lx\n", lmb->memory.cnt); + printf(" memory.size = 0x%llx\n", + (unsigned long long)lmb->memory.size); + for (i = 0; i < lmb->memory.cnt; i++) { + printf(" memory.reg[0x%lx].base = 0x%llx\n", i, + (unsigned long long)lmb->memory.region[i].base); + printf(" .size = 0x%llx\n", + (unsigned long long)lmb->memory.region[i].size); + } + + printf("\n reserved.cnt = 0x%lx\n", lmb->reserved.cnt); + printf(" reserved.size = 0x%llx\n", + (unsigned long long)lmb->reserved.size); + for (i = 0; i < lmb->reserved.cnt; i++) { + printf(" reserved.reg[0x%lx].base = 0x%llx\n", i, + (unsigned long long)lmb->reserved.region[i].base); + printf(" .size = 0x%llx\n", + (unsigned long long)lmb->reserved.region[i].size); + } +} + void lmb_dump_all(struct lmb *lmb) { #ifdef DEBUG - unsigned long i; - - debug("lmb_dump_all:\n"); - debug(" memory.cnt = 0x%lx\n", lmb->memory.cnt); - debug(" memory.size = 0x%llx\n", - (unsigned long long)lmb->memory.size); - for (i = 0; i < lmb->memory.cnt; i++) { - debug(" memory.reg[0x%lx].base = 0x%llx\n", i, - (unsigned long long)lmb->memory.region[i].base); - debug(" .size = 0x%llx\n", - (unsigned long long)lmb->memory.region[i].size); - } - - debug("\n reserved.cnt = 0x%lx\n", - lmb->reserved.cnt); - debug(" reserved.size = 0x%llx\n", - (unsigned long long)lmb->reserved.size); - for (i = 0; i < lmb->reserved.cnt; i++) { - debug(" reserved.reg[0x%lx].base = 0x%llx\n", i, - (unsigned long long)lmb->reserved.region[i].base); - debug(" .size = 0x%llx\n", - (unsigned long long)lmb->reserved.region[i].size); - } -#endif /* DEBUG */ + lmb_dump_all_force(lmb); +#endif } static long lmb_addrs_overlap(phys_addr_t base1, phys_size_t size1, From a08f2f7b944f6926843b26a216db58b8d02a19e1 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Mon, 8 Jun 2020 11:27:19 +0200 Subject: [PATCH 07/22] net: dwc_eth_qos: add Kconfig option to select supported configuration Add configuration flag to select the supported dwc driver configuration: - CONFIG_DWC_ETH_QOS_TEGRA186 - CONFIG_DWC_ETH_QOS_IMX - CONFIG_DWC_ETH_QOS_STM32 See Linux driver ethernet/stmicro/stmmac and associated glue layers for other configuration examples. This patch removes the not-selected compatibles and lets the linker remove the unused functions to reduce the size of the driver. Signed-off-by: Patrick Delaunay --- drivers/net/Kconfig | 27 ++++++++++++++++++++++++--- drivers/net/dwc_eth_qos.c | 12 +++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 15030b81651..ecd779d979e 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -156,9 +156,30 @@ config DWC_ETH_QOS help This driver supports the Synopsys Designware Ethernet QOS (Quality Of Service) IP block. The IP supports many options for bus type, - clocking/reset structure, and feature list. This driver currently - supports the specific configuration used in NVIDIA's Tegra186 chip, - but should be extensible to other combinations quite easily. + clocking/reset structure, and feature list. + +config DWC_ETH_QOS_IMX + bool "Synopsys DWC Ethernet QOS device support for IMX" + depends on DWC_ETH_QOS + help + The Synopsys Designware Ethernet QOS IP block with the specific + configuration used in IMX soc. + +config DWC_ETH_QOS_STM32 + bool "Synopsys DWC Ethernet QOS device support for STM32" + depends on DWC_ETH_QOS + default y if ARCH_STM32MP + help + The Synopsys Designware Ethernet QOS IP block with the specific + configuration used in STM32MP soc. + +config DWC_ETH_QOS_TEGRA186 + bool "Synopsys DWC Ethernet QOS device support for TEGRA186" + depends on DWC_ETH_QOS + default y if TEGRA186 + help + The Synopsys Designware Ethernet QOS IP block with specific + configuration used in NVIDIA's Tegra186 chip. config E1000 bool "Intel PRO/1000 Gigabit Ethernet support" diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index 1d9eefbb3e8..810a2b95b19 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -2100,7 +2100,7 @@ static struct eqos_ops eqos_tegra186_ops = { .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_tegra186 }; -static const struct eqos_config eqos_tegra186_config = { +static const struct eqos_config __maybe_unused eqos_tegra186_config = { .reg_access_always_ok = false, .mdio_wait = 10, .swr_wait = 10, @@ -2127,7 +2127,7 @@ static struct eqos_ops eqos_stm32_ops = { .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_stm32 }; -static const struct eqos_config eqos_stm32_config = { +static const struct eqos_config __maybe_unused eqos_stm32_config = { .reg_access_always_ok = false, .mdio_wait = 10000, .swr_wait = 50, @@ -2154,7 +2154,7 @@ static struct eqos_ops eqos_imx_ops = { .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_imx }; -struct eqos_config eqos_imx_config = { +struct eqos_config __maybe_unused eqos_imx_config = { .reg_access_always_ok = false, .mdio_wait = 10000, .swr_wait = 50, @@ -2165,18 +2165,24 @@ struct eqos_config eqos_imx_config = { }; static const struct udevice_id eqos_ids[] = { +#if IS_ENABLED(CONFIG_DWC_ETH_QOS_TEGRA186) { .compatible = "nvidia,tegra186-eqos", .data = (ulong)&eqos_tegra186_config }, +#endif +#if IS_ENABLED(CONFIG_DWC_ETH_QOS_STM32) { .compatible = "st,stm32mp1-dwmac", .data = (ulong)&eqos_stm32_config }, +#endif +#if IS_ENABLED(CONFIG_DWC_ETH_QOS_IMX) { .compatible = "fsl,imx-eqos", .data = (ulong)&eqos_imx_config }, +#endif { } }; From def7a5c00f4a84edf7a8a83c28bf9a7063e00731 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Mon, 15 Jun 2020 11:15:57 +0200 Subject: [PATCH 08/22] net: ping: reset stored IP address Reset the stored ping IP address before entering a netloop with different protocol to ensure that it won't be interrupted by the received correct ICMP_ECHO_REPLY packet. Signed-off-by: Marek Szyprowski --- net/net.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/net.c b/net/net.c index 1e7f633cb69..28d9eebf9dd 100644 --- a/net/net.c +++ b/net/net.c @@ -409,6 +409,10 @@ int net_loop(enum proto_t protocol) int ret = -EINVAL; enum net_loop_state prev_net_state = net_state; +#if defined(CONFIG_CMD_PING) + if (protocol != PING) + net_ping_ip.s_addr = 0; +#endif net_restarted = 0; net_dev_exists = 0; net_try_count = 1; From 44758771eefb8e600144e2e0a13cf87b9df64276 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Tue, 21 Jul 2020 09:32:20 +0200 Subject: [PATCH 09/22] arm: move CONFIG_PREBOOT="usb start" to KConfig This commit moves CONFIG_PREBOOT="usb start" to common/KConfig for all boards also declaring USB_KEYBOARD. Besides simplifying defconfig files, this also enables support for board-specific CONFIG_PREBOOT for sunxi boards: commit 37304aaf60bf ("Convert CONFIG_USE_PREBOOT and CONFIG_PREBOOT to Kconfig") intended to support CONFIG_PREBOOT, but include/configs/sunxi-common.h hardcodes preboot as part of internally defined CONSOLE_STDIN_SETTINGS, silently ignoring any board-specific CONFIG_PREBOOT. Signed-off-by: Jonas Smedegaard Reviewed-by: Neil Armstrong Series-Cc: Jagan Teki Series-Cc: Lukasz Majewski Series-Cc: Andre Przywara --- common/Kconfig | 1 + configs/libretech-ac_defconfig | 1 - configs/libretech-s905d-pc_defconfig | 1 - configs/libretech-s912-pc_defconfig | 1 - configs/pinebook-pro-rk3399_defconfig | 1 - configs/rockpro64-rk3399_defconfig | 1 - configs/rpi_0_w_defconfig | 1 - configs/rpi_2_defconfig | 1 - configs/rpi_3_32b_defconfig | 1 - configs/rpi_3_b_plus_defconfig | 1 - configs/rpi_3_defconfig | 1 - configs/rpi_defconfig | 1 - configs/seaboard_defconfig | 1 - configs/ventana_defconfig | 1 - include/configs/sunxi-common.h | 1 - 15 files changed, 1 insertion(+), 14 deletions(-) diff --git a/common/Kconfig b/common/Kconfig index 67b3818fdef..62d78c5bd73 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -403,6 +403,7 @@ config BOOTCOMMAND config USE_PREBOOT bool "Enable preboot" + default "usb start" if USB_KEYBOARD help When this option is enabled, the existence of the environment variable "preboot" will be checked immediately before starting the diff --git a/configs/libretech-ac_defconfig b/configs/libretech-ac_defconfig index 62094f21fa6..2ca169cd7d9 100644 --- a/configs/libretech-ac_defconfig +++ b/configs/libretech-ac_defconfig @@ -15,7 +15,6 @@ CONFIG_DEFAULT_DEVICE_TREE="meson-gxl-s805x-libretech-ac" CONFIG_DEBUG_UART=y CONFIG_OF_BOARD_SETUP=y CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_MISC_INIT_R=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set diff --git a/configs/libretech-s905d-pc_defconfig b/configs/libretech-s905d-pc_defconfig index 74e4c7fbab6..c10e549ded2 100644 --- a/configs/libretech-s905d-pc_defconfig +++ b/configs/libretech-s905d-pc_defconfig @@ -15,7 +15,6 @@ CONFIG_DEFAULT_DEVICE_TREE="meson-gxl-s905d-libretech-pc" CONFIG_DEBUG_UART=y CONFIG_OF_BOARD_SETUP=y CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_MISC_INIT_R=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_CMD_BDI is not set diff --git a/configs/libretech-s912-pc_defconfig b/configs/libretech-s912-pc_defconfig index 7fe00a92c4b..fffca0fa5a8 100644 --- a/configs/libretech-s912-pc_defconfig +++ b/configs/libretech-s912-pc_defconfig @@ -14,7 +14,6 @@ CONFIG_DEFAULT_DEVICE_TREE="meson-gxm-s912-libretech-pc" CONFIG_DEBUG_UART=y CONFIG_OF_BOARD_SETUP=y CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_MISC_INIT_R=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_CMD_BDI is not set diff --git a/configs/pinebook-pro-rk3399_defconfig b/configs/pinebook-pro-rk3399_defconfig index 959c40c330b..3967863e602 100644 --- a/configs/pinebook-pro-rk3399_defconfig +++ b/configs/pinebook-pro-rk3399_defconfig @@ -13,7 +13,6 @@ CONFIG_DEFAULT_DEVICE_TREE="rk3399-pinebook-pro" CONFIG_DEBUG_UART=y CONFIG_BOOTDELAY=3 CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-pinebook-pro.dtb" CONFIG_MISC_INIT_R=y CONFIG_DISPLAY_BOARDINFO_LATE=y diff --git a/configs/rockpro64-rk3399_defconfig b/configs/rockpro64-rk3399_defconfig index 31d30954438..a420372fb0b 100644 --- a/configs/rockpro64-rk3399_defconfig +++ b/configs/rockpro64-rk3399_defconfig @@ -13,7 +13,6 @@ CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEFAULT_DEVICE_TREE="rk3399-rockpro64" CONFIG_DEBUG_UART=y CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb" CONFIG_MISC_INIT_R=y CONFIG_DISPLAY_BOARDINFO_LATE=y diff --git a/configs/rpi_0_w_defconfig b/configs/rpi_0_w_defconfig index a8752f5008f..350a18211c1 100644 --- a/configs/rpi_0_w_defconfig +++ b/configs/rpi_0_w_defconfig @@ -9,7 +9,6 @@ CONFIG_DEFAULT_DEVICE_TREE="bcm2835-rpi-zero-w" CONFIG_DISTRO_DEFAULTS=y CONFIG_OF_BOARD_SETUP=y CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_MISC_INIT_R=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set diff --git a/configs/rpi_2_defconfig b/configs/rpi_2_defconfig index 867f59c4d44..2ec3c4b9cd2 100644 --- a/configs/rpi_2_defconfig +++ b/configs/rpi_2_defconfig @@ -9,7 +9,6 @@ CONFIG_DEFAULT_DEVICE_TREE="bcm2836-rpi-2-b" CONFIG_DISTRO_DEFAULTS=y CONFIG_OF_BOARD_SETUP=y CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_MISC_INIT_R=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set diff --git a/configs/rpi_3_32b_defconfig b/configs/rpi_3_32b_defconfig index 08643fa3f6b..8c3c9804df5 100644 --- a/configs/rpi_3_32b_defconfig +++ b/configs/rpi_3_32b_defconfig @@ -10,7 +10,6 @@ CONFIG_DEFAULT_DEVICE_TREE="bcm2837-rpi-3-b" CONFIG_DISTRO_DEFAULTS=y CONFIG_OF_BOARD_SETUP=y CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_MISC_INIT_R=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set diff --git a/configs/rpi_3_b_plus_defconfig b/configs/rpi_3_b_plus_defconfig index c31ea55d091..1e2d4b1357d 100644 --- a/configs/rpi_3_b_plus_defconfig +++ b/configs/rpi_3_b_plus_defconfig @@ -10,7 +10,6 @@ CONFIG_DEFAULT_DEVICE_TREE="bcm2837-rpi-3-b-plus" CONFIG_DISTRO_DEFAULTS=y CONFIG_OF_BOARD_SETUP=y CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_MISC_INIT_R=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set diff --git a/configs/rpi_3_defconfig b/configs/rpi_3_defconfig index aa4770ec7f2..e992b64185a 100644 --- a/configs/rpi_3_defconfig +++ b/configs/rpi_3_defconfig @@ -10,7 +10,6 @@ CONFIG_DEFAULT_DEVICE_TREE="bcm2837-rpi-3-b" CONFIG_DISTRO_DEFAULTS=y CONFIG_OF_BOARD_SETUP=y CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_MISC_INIT_R=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set diff --git a/configs/rpi_defconfig b/configs/rpi_defconfig index da767eff189..8532cacde59 100644 --- a/configs/rpi_defconfig +++ b/configs/rpi_defconfig @@ -9,7 +9,6 @@ CONFIG_DEFAULT_DEVICE_TREE="bcm2835-rpi-b" CONFIG_DISTRO_DEFAULTS=y CONFIG_OF_BOARD_SETUP=y CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_MISC_INIT_R=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set diff --git a/configs/seaboard_defconfig b/configs/seaboard_defconfig index cc47587ef85..e4404580af5 100644 --- a/configs/seaboard_defconfig +++ b/configs/seaboard_defconfig @@ -10,7 +10,6 @@ CONFIG_TARGET_SEABOARD=y CONFIG_DEFAULT_DEVICE_TREE="tegra20-seaboard" CONFIG_OF_SYSTEM_SETUP=y CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_SYS_PROMPT="Tegra20 (SeaBoard) # " # CONFIG_CMD_IMI is not set # CONFIG_CMD_FLASH is not set diff --git a/configs/ventana_defconfig b/configs/ventana_defconfig index 33131ce0278..b51254abf82 100644 --- a/configs/ventana_defconfig +++ b/configs/ventana_defconfig @@ -10,7 +10,6 @@ CONFIG_TARGET_VENTANA=y CONFIG_DEFAULT_DEVICE_TREE="tegra20-ventana" CONFIG_OF_SYSTEM_SETUP=y CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start" CONFIG_SYS_PROMPT="Tegra20 (Ventana) # " # CONFIG_CMD_IMI is not set CONFIG_CMD_GPIO=y diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 5b0bec05616..5d7544b5cd4 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -425,7 +425,6 @@ extern int soft_i2c_gpio_scl; #ifdef CONFIG_USB_KEYBOARD #define CONSOLE_STDIN_SETTINGS \ - "preboot=usb start\0" \ "stdin=serial,usbkbd\0" #else #define CONSOLE_STDIN_SETTINGS \ From c9db1a103cfc6ee4edb75820035a53368ceb01a3 Mon Sep 17 00:00:00 2001 From: Yan Liu Date: Tue, 21 Jul 2020 11:12:05 -0400 Subject: [PATCH 10/22] test/py: Add test support for three stage boot Current pytest only support upto 2 stage boot; Some boards like TI K3 am6/J7 boards use 3 stage boot. This patch adds u_boot_spl2 to be able to handle the 3-stage boot case. User needs to set "env__spl2_skipped" in u_boot_boardenv config file to use this support. By default it is set to TRUE. Signed-off-by: Yan Liu Signed-off-by: Yan Liu --- test/py/u_boot_console_base.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py index 326b2ac51fb..1db5da4c1e1 100644 --- a/test/py/u_boot_console_base.py +++ b/test/py/u_boot_console_base.py @@ -17,6 +17,7 @@ import u_boot_spawn # Regexes for text we expect U-Boot to send to the console. pattern_u_boot_spl_signon = re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))') +pattern_u_boot_spl2_signon = re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))') pattern_u_boot_main_signon = re.compile('(U-Boot \\d{4}\\.\\d{2}[^\r\n]*\\))') pattern_stop_autoboot_prompt = re.compile('Hit any key to stop autoboot: ') pattern_unknown_command = re.compile('Unknown command \'.*\' - try \'help\'') @@ -28,6 +29,7 @@ PAT_RE = 1 bad_pattern_defs = ( ('spl_signon', pattern_u_boot_spl_signon), + ('spl2_signon', pattern_u_boot_spl2_signon), ('main_signon', pattern_u_boot_main_signon), ('stop_autoboot_prompt', pattern_stop_autoboot_prompt), ('unknown_command', pattern_unknown_command), @@ -353,12 +355,20 @@ class ConsoleBase(object): 'n') == 'y' env_spl_skipped = self.config.env.get('env__spl_skipped', False) + env_spl2_skipped = self.config.env.get('env__spl2_skipped', + True) if config_spl and config_spl_serial_support and not env_spl_skipped: m = self.p.expect([pattern_u_boot_spl_signon] + self.bad_patterns) if m != 0: raise Exception('Bad pattern found on SPL console: ' + self.bad_pattern_ids[m - 1]) + if not env_spl2_skipped: + m = self.p.expect([pattern_u_boot_spl2_signon] + + self.bad_patterns) + if m != 0: + raise Exception('Bad pattern found on SPL2 console: ' + + self.bad_pattern_ids[m - 1]) m = self.p.expect([pattern_u_boot_main_signon] + self.bad_patterns) if m != 0: raise Exception('Bad pattern found on console: ' + From 2d8e102cd2fbf639447b52f3cdfb748d9b667556 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Tue, 21 Jul 2020 14:38:51 -0600 Subject: [PATCH 11/22] fixdep: fix coding style in previous fix Remove a double space introduced by my previous fixdep fix. Fixes: 76ae74d348a0 ("fixdep: fix CONFIG_IS_ENABLED etc. handling") Signed-off-by: Stephen Warren --- scripts/basic/fixdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 958668df554..6d59cf8c07e 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -266,7 +266,7 @@ static void parse_config_file(const char *p) (q - p == 9 && !memcmp(p, "IS_MODULE(", 10)) || (q - p == 3 && !memcmp(p, "VAL(", 4))) { p = q + 1; - q = p; + q = p; while (isalnum(*q) || *q == '_') q++; r = q; From a965f4dfb522532f07f7ab18b54de1e01677ffea Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 22 Jul 2020 13:58:54 +0200 Subject: [PATCH 12/22] dt-bindings: Sync include/dt-bindings/phy/phy.h from Linux Add 4 new phy types which are present in Linux kernel. DP and SGMII types are used on Xilinx ZynqMP devices. Signed-off-by: Michal Simek --- include/dt-bindings/phy/phy.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/dt-bindings/phy/phy.h b/include/dt-bindings/phy/phy.h index 6c901930eb3..7e657da4542 100644 --- a/include/dt-bindings/phy/phy.h +++ b/include/dt-bindings/phy/phy.h @@ -15,5 +15,9 @@ #define PHY_TYPE_PCIE 2 #define PHY_TYPE_USB2 3 #define PHY_TYPE_USB3 4 +#define PHY_TYPE_UFS 5 +#define PHY_TYPE_DP 6 +#define PHY_TYPE_XPCS 7 +#define PHY_TYPE_SGMII 8 #endif /* _DT_BINDINGS_PHY */ From 36766d39e889d601e5d69df8a976960839a68875 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 22 Jul 2020 14:58:25 +0200 Subject: [PATCH 13/22] Makefile.lib: Build all DTS with -@ if OF_LIBFDT_OVERLAY is enabled The commit 47818e23a228 ("Makefile.lib: include /__symbols__ in dtb if SPL_LOAD_FIT_APPLY_OVERLAY is enabled") enables DT building as overlays based on symbols which depends on SPL. But there is already an option to apply overlays in full U-Boot too. And there are platforms which are not using SPL and there is no option to build DTs with -@ parameter. That's why change dependency on OF_LIBFDT_OVERLAY which is already symbol which is selected when SPL_LOAD_FIT_APPLY_OVERLAY is enabled but also adding support for platforms which don't enable SPL and want to work with overlays on U-Boot prompt. Signed-off-by: Michal Simek Reviewed-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- scripts/Makefile.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 734001c952a..56e9d542429 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -311,7 +311,7 @@ cmd_dt_S_dtb= \ $(obj)/%.dtb.S: $(obj)/%.dtb $(call cmd,dt_S_dtb) -ifeq ($(CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY),y) +ifeq ($(CONFIG_OF_LIBFDT_OVERLAY),y) DTC_FLAGS += -@ endif From 171fd224ae3c860e3a66617f26a7e1145a3ff305 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 23 Jul 2020 09:00:40 +0200 Subject: [PATCH 14/22] pinctrl: aspeed: Fix Kconfig entry indentation Fix Kconfig entry indentation for Aspeed ast2500 pin control driver. Fixes: 4f0e44e46615 ("aspeed: AST2500 Pinctrl Driver") Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- drivers/pinctrl/Kconfig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index bd2061b765b..cdbccfd285a 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -276,13 +276,13 @@ config SPL_PINCTRL_STMFX See the help of PINCTRL_STMFX for details. config ASPEED_AST2500_PINCTRL - bool "Aspeed AST2500 pin control driver" - depends on DM && PINCTRL_GENERIC && ASPEED_AST2500 - default y - help - Support pin multiplexing control on Aspeed ast2500 SoC. The driver uses - Generic Pinctrl framework and is compatible with the Linux driver, - i.e. it uses the same device tree configuration. + bool "Aspeed AST2500 pin control driver" + depends on DM && PINCTRL_GENERIC && ASPEED_AST2500 + default y + help + Support pin multiplexing control on Aspeed ast2500 SoC. The driver + uses Generic Pinctrl framework and is compatible with the Linux + driver, i.e. it uses the same device tree configuration. endif From 7f89e85631936a17b2e9bf997fa6d239cd65bba6 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 25 Jul 2020 09:55:46 +0200 Subject: [PATCH 15/22] doc: move Clang documentation to HTML * Move README.clang to doc/build/clang.rst and reformat as reStructeredText. * Indicate that -ffixed-r9 and -ffixed-x18 are used to reserve registers for gd. * Minor editing. Signed-off-by: Heinrich Schuchardt --- doc/README.clang | 55 -------------------------------- doc/build/clang.rst | 76 +++++++++++++++++++++++++++++++++++++++++++++ doc/build/index.rst | 1 + 3 files changed, 77 insertions(+), 55 deletions(-) delete mode 100644 doc/README.clang create mode 100644 doc/build/clang.rst diff --git a/doc/README.clang b/doc/README.clang deleted file mode 100644 index 475bb1e2ed8..00000000000 --- a/doc/README.clang +++ /dev/null @@ -1,55 +0,0 @@ -The biggest problem when trying to compile U-Boot with clang is that -almost all archs rely on storing gd in a global register and clang user -manual states: "clang does not support global register variables; this -is unlikely to be implemented soon because it requires additional LLVM -backend support." - -Since version 3.4 the ARM backend can be instructed to leave r9 alone. -Global registers themselves are not supported so some inline assembly is -used to get its value. This does lead to larger code then strictly -necessary, but at least works. - -NOTE: target compilation only work for _some_ ARM boards at the moment. -Also AArch64 is not supported currently due to a lack of private libgcc -support. Boards which reassign gd in c will also fail to compile, but there is -in no strict reason to do so in the ARM world, since crt0.S takes care of this. -These assignments can be avoided by changing the init calls but this is not in -mainline yet. - -Debian (based) --------------- -Binary packages can be installed as usual, e.g.: -sudo apt-get install clang - -Note that we still use binutils for some tools so we must continue to set -CROSS_COMPILE. To compile U-Boot with clang on linux without IAS use e.g.: -make HOSTCC=clang rpi_2_defconfig -make HOSTCC=clang CROSS_COMPILE=arm-linux-gnueabi- \ - CC="clang -target arm-linux-gnueabi" -j8 - -It can also be used to compile sandbox: -make HOSTCC=clang sandbox_defconfig -make HOSTCC=clang CC=clang -j8 - -FreeBSD 11 (Current): --------------------- -Since llvm 3.4 is currently in the base system, the integrated as is -incapable of building U-Boot. Therefore gas from devel/arm-gnueabi-binutils -is used instead. It needs a symlinks to be picked up correctly though: - -ln -s /usr/local/bin/arm-gnueabi-freebsd-as /usr/bin/arm-freebsd-eabi-as - -# The following commands compile U-Boot using the clang xdev toolchain. -# NOTE: CROSS_COMPILE and target differ on purpose! -export CROSS_COMPILE=arm-gnueabi-freebsd- -gmake rpi_2_defconfig -gmake CC="clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd" -j8 - -Given that U-Boot will default to gcc, above commands can be -simplified with a simple wrapper script, listed below. - -/usr/local/bin/arm-gnueabi-freebsd-gcc ---- -#!/bin/sh - -exec clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd "$@" diff --git a/doc/build/clang.rst b/doc/build/clang.rst new file mode 100644 index 00000000000..1d35616eb5e --- /dev/null +++ b/doc/build/clang.rst @@ -0,0 +1,76 @@ +Building with Clang +=================== + +The biggest problem when trying to compile U-Boot with Clang is that almost all +archs rely on storing gd in a global register and the Clang 3.5 user manual +states: "Clang does not support global register variables; this is unlikely to +be implemented soon because it requires additional LLVM backend support." + +The ARM backend can be instructed not to use the r9 and x18 registers using +-ffixed-r9 or -ffixed-x18 respectively. As global registers themselves are not +supported inline assembly is needed to get and set the r9 or x18 value. This +leads to larger code then strictly necessary, but at least works. + +**NOTE:** target compilation only work for _some_ ARM boards at the moment. +Also AArch64 is not supported currently due to a lack of private libgcc +support. Boards which reassign gd in c will also fail to compile, but there is +in no strict reason to do so in the ARM world, since crt0.S takes care of this. +These assignments can be avoided by changing the init calls but this is not in +mainline yet. + + +Debian based +------------ + +Required packages can be installed via apt, e.g. + +.. code-block:: bash + + sudo apt-get install clang + +Note that we still use binutils for some tools so we must continue to set +CROSS_COMPILE. To compile U-Boot with Clang on Linux without IAS use e.g. + +.. code-block:: bash + + make HOSTCC=clang rpi_2_defconfig + make HOSTCC=clang CROSS_COMPILE=arm-linux-gnueabi- \ + CC="clang -target arm-linux-gnueabi" -j8 + +It can also be used to compile sandbox: + +.. code-block:: bash + + make HOSTCC=clang sandbox_defconfig + make HOSTCC=clang CC=clang -j8 + + +FreeBSD 11 +---------- + +Since llvm 3.4 is currently in the base system, the integrated assembler as +is incapable of building U-Boot. Therefore gas from devel/arm-gnueabi-binutils +is used instead. It needs a symlink to be picked up correctly though: + +.. code-block:: bash + + ln -s /usr/local/bin/arm-gnueabi-freebsd-as /usr/bin/arm-freebsd-eabi-as + +The following commands compile U-Boot using the Clang xdev toolchain. + +**NOTE:** CROSS_COMPILE and target differ on purpose! + +.. code-block:: bash + + export CROSS_COMPILE=arm-gnueabi-freebsd- + gmake rpi_2_defconfig + gmake CC="clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd" -j8 + +Given that U-Boot will default to gcc, above commands can be +simplified with a simple wrapper script - saved as +/usr/local/bin/arm-gnueabi-freebsd-gcc - listed below: + +.. code-block:: bash + + #!/bin/sh + exec clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd "$@" diff --git a/doc/build/index.rst b/doc/build/index.rst index e4e34114af3..e0072afb5e8 100644 --- a/doc/build/index.rst +++ b/doc/build/index.rst @@ -6,4 +6,5 @@ Build U-Boot .. toctree:: :maxdepth: 2 + clang tools From dfd2390dff9cd1000469c59f40afe143699088ea Mon Sep 17 00:00:00 2001 From: Brian Moyer Date: Sun, 26 Jul 2020 13:17:53 -0700 Subject: [PATCH 16/22] arm: Add SPL build check to SPL early bss clear SPL_CLEAR_BSS is called regardless of build type if CONFIG_SPL_EARLY_BSS is defined. Add a guard for CONFIG_SPL_BUILD to fix. Signed-off-by: Brian Moyer --- arch/arm/lib/crt0.S | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S index df9dd83e409..46b6be21a8d 100644 --- a/arch/arm/lib/crt0.S +++ b/arch/arm/lib/crt0.S @@ -64,7 +64,7 @@ * can afford it due to sufficient memory being available early. */ -.macro SPL_CLEAR_BSS +.macro CLEAR_BSS ldr r0, =__bss_start /* this is auto-relocated! */ #ifdef CONFIG_USE_ARCH_MEMSET @@ -109,8 +109,8 @@ ENTRY(_main) mov r9, r0 bl board_init_f_init_reserve -#if defined(CONFIG_SPL_EARLY_BSS) - SPL_CLEAR_BSS +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_EARLY_BSS) + CLEAR_BSS #endif mov r0, #0 @@ -150,8 +150,8 @@ here: #endif #if !defined(CONFIG_SPL_BUILD) || CONFIG_IS_ENABLED(FRAMEWORK) -#if !defined(CONFIG_SPL_EARLY_BSS) - SPL_CLEAR_BSS +#if !defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SPL_EARLY_BSS) + CLEAR_BSS #endif # ifdef CONFIG_SPL_BUILD From aaa91a4e4b8a5d74f1317e18aa47d2a7a72e0c43 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 27 Jul 2020 21:03:13 -0300 Subject: [PATCH 17/22] fit_image: Use calloc() to fix reproducibility issue Vagrant Cascadian reported that mx6cuboxi target no longer builds reproducibility on Debian. One example of builds mismatches: 00096680: 696e 6700 736f 756e 642d 6461 6900 6465 ing.sound-dai.de -00096690: 7465 6374 2d67 7069 6f73 0000 tect-gpios.. +00096690: 7465 6374 2d67 7069 6f73 0061 tect-gpios.a This problem happens because all the buffers in fit_image.c are allocated via malloc(), which does not zero out the allocated buffer. Using calloc() fixes this unpredictable behaviour as it guarantees that the allocated buffer are zero initialized. Reported-by: Vagrant Cascadian Suggested-by: Tom Rini Signed-off-by: Fabio Estevam Tested-by: Vagrant Cascadian --- tools/fit_image.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/fit_image.c b/tools/fit_image.c index df310b53da3..f7d2f560294 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -388,7 +388,7 @@ static int fit_build(struct image_tool_params *params, const char *fname) size = fit_calc_size(params); if (size < 0) return -1; - buf = malloc(size); + buf = calloc(1, size); if (!buf) { fprintf(stderr, "%s: Out of memory (%d bytes)\n", params->cmdname, size); @@ -467,7 +467,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) * Allocate space to hold the image data we will extract, * extral space allocate for image alignment to prevent overflow. */ - buf = malloc(fit_size + (align_size * image_number)); + buf = calloc(1, fit_size + (align_size * image_number)); if (!buf) { ret = -ENOMEM; goto err_munmap; @@ -572,7 +572,7 @@ static int fit_import_data(struct image_tool_params *params, const char *fname) /* Allocate space to hold the new FIT */ size = sbuf.st_size + 16384; - fdt = malloc(size); + fdt = calloc(1, size); if (!fdt) { fprintf(stderr, "%s: Failed to allocate memory (%d bytes)\n", __func__, size); @@ -673,7 +673,7 @@ static int copyfile(const char *src, const char *dst) goto out; } - buf = malloc(512); + buf = calloc(1, 512); if (!buf) { printf("Can't allocate buffer to copy file\n"); goto out; From f2d58f3bdad30ac088f76cce38a2e64a6c640f19 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Tue, 28 Jul 2020 17:57:48 +0300 Subject: [PATCH 18/22] cmd: bootz: fix device-tree overlap test The address of the kernel image is stored in images->ep. zi_start is the offset of execution entry in the image, which is usually 0 for ARM zImage. Fixes boot error when ftd is stored near RAM address 0x0: ERROR: FDT image overlaps OS image (OS=0x0..0x5fd608) Fixes: fbde7589ce30 ("common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image") Cc: Tero Kristo Signed-off-by: Baruch Siach --- cmd/bootz.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/bootz.c b/cmd/bootz.c index 1c8b0cf89f9..7556cd2752a 100644 --- a/cmd/bootz.c +++ b/cmd/bootz.c @@ -54,7 +54,7 @@ static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc, * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not * have a header that provide this informaiton. */ - if (bootm_find_images(flag, argc, argv, zi_start, zi_end - zi_start)) + if (bootm_find_images(flag, argc, argv, images->ep, zi_end - zi_start)) return 1; return 0; From 5ce2776ae63326807bc504fcfed24997c2a03bb2 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 28 Jul 2020 17:56:33 +0200 Subject: [PATCH 19/22] cmd: bdinfo: cleanup phys_addr_t output We currently print the memory size with at least 8 hexadecimal digits. This creates a ragged output on 64 bit boards, e.g. on a Kendryte K210: DRAM bank = 0x0000000000000002 -> start = 0x0000000080600000 -> size = 0x0000000000200000 memstart = 0x0000000000000000 memsize = 0x00000000 flashstart = 0x0000000000000000 flashsize = 0x0000000000000000 flashoffset = 0x0000000000000000 All other numbers are printed with the number of digits needed for the type ulong. So use this value as minimum number of digits (precision) for printing physical addresses. Signed-off-by: Heinrich Schuchardt Reviewed-by: Heiko Schocher Reviewed-by: Stefan Roese Reviewed-by: Simon Glass --- cmd/bdinfo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index 2a6dd6c67a5..9485c404740 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -34,9 +34,10 @@ static void print_eth(int idx) printf("%-12s= %s\n", name, val); } -static void print_lnum(const char *name, unsigned long long value) +static void print_phys_addr(const char *name, phys_addr_t value) { - printf("%-12s= 0x%.8llX\n", name, value); + printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong), + (unsigned long long)value); } void bdinfo_print_mhz(const char *name, unsigned long hz) @@ -75,7 +76,7 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) bdinfo_print_num("boot_params", (ulong)bd->bi_boot_params); print_bi_dram(bd); bdinfo_print_num("memstart", (ulong)bd->bi_memstart); - print_lnum("memsize", (u64)bd->bi_memsize); + print_phys_addr("memsize", bd->bi_memsize); bdinfo_print_num("flashstart", (ulong)bd->bi_flashstart); bdinfo_print_num("flashsize", (ulong)bd->bi_flashsize); bdinfo_print_num("flashoffset", (ulong)bd->bi_flashoffset); From 7f772fbcc04b8f70a70b79f869b03c2897ba0651 Mon Sep 17 00:00:00 2001 From: Icenowy Zheng Date: Sat, 1 Aug 2020 02:56:45 +0800 Subject: [PATCH 20/22] ARM: add Kconfig option for PSCI 0.1 We still have some platforms that only implements functionalities in PSCI 0.1 (e.g. Allwinner ARMv7 SoCs). Add a Kconfig option for exporting only PSCI 0.1. The code to export PSCI 0.1 is still available and gets activated by this patch. In addition, default ARCH_SUNXI U-Boot PSCI implementation to export PSCI 0.1, to fix poweroff/reboot regression on Allwinner multi-core ARMv7 SoCs. Signed-off-by: Icenowy Zheng --- arch/arm/cpu/armv7/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/cpu/armv7/Kconfig b/arch/arm/cpu/armv7/Kconfig index 8eee801dce9..60bb0a9e1ec 100644 --- a/arch/arm/cpu/armv7/Kconfig +++ b/arch/arm/cpu/armv7/Kconfig @@ -44,6 +44,7 @@ config ARMV7_PSCI choice prompt "Supported PSCI version" depends on ARMV7_PSCI + default ARMV7_PSCI_0_1 if ARCH_SUNXI default ARMV7_PSCI_1_0 help Select the supported PSCI version. @@ -53,6 +54,9 @@ config ARMV7_PSCI_1_0 config ARMV7_PSCI_0_2 bool "PSCI V0.2" + +config ARMV7_PSCI_0_1 + bool "PSCI V0.1" endchoice config ARMV7_PSCI_NR_CPUS From d9cd4d2a8d429068a6a5061a33459ae3ae113ef8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 1 Aug 2020 10:30:38 -0600 Subject: [PATCH 21/22] tools: env: Fix printf() warning in fw_env The printf() string produces a warning about %d not matching size_t. Fix it and put the format string on one line to avoid a checkpatch warning. Signed-off-by: Simon Glass --- tools/env/fw_env.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index 3ab1ae69c7a..ccbeb5552bc 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -952,8 +952,8 @@ static int flash_read_buf(int dev, int fd, void *buf, size_t count, return -1; } if (rc != readlen) { - fprintf(stderr, "Read error on %s: " - "Attempted to read %d bytes but got %d\n", + fprintf(stderr, + "Read error on %s: Attempted to read %zd bytes but got %d\n", DEVNAME(dev), readlen, rc); return -1; } From 7b27e0fe13d8d44da6cd357a69668a726b852502 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 1 Aug 2020 10:30:39 -0600 Subject: [PATCH 22/22] tools: env: Avoid an uninited warning with was_locked Set this variable to 0 to avoid a warning about an unused variable. This happens on gcc 7.5.0 for me. Signed-off-by: Simon Glass --- tools/env/fw_env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index ccbeb5552bc..66cb9d2a25e 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -995,7 +995,7 @@ static int flash_write_buf(int dev, int fd, void *buf, size_t count) of the data */ loff_t blockstart; /* running start of the current block - MEMGETBADBLOCK needs 64 bits */ - int was_locked; /* flash lock flag */ + int was_locked = 0; /* flash lock flag */ int rc; /*