[U-Boot] [PATCH v4 0/8] assortment of fixes/enhancements

From: Marcel Ziswiler marcel.ziswiler@toradex.com
This patch set is an assortment of fixes/enhancements distilled straight from our downstream integration work.
Marcel Ziswiler (4): net: asix: fix operation without eeprom generic-board: allow showing custom board info colibri_vf: remove spurious new line mtd/nand/ubi: assortment of alignment fixes
Max Krummenacher (3): fs/fs.c: read up to EOF when len would read past EOF image-fdt.c: store returned error value tftp.c: fix CONFIG_TFTP_TSIZE for small files
Stefan Agner (1): logos: add Toradex logo
common/board_info.c | 2 +- common/cmd_ubi.c | 2 +- common/image-fdt.c | 3 ++- drivers/mtd/nand/nand_util.c | 2 +- drivers/usb/eth/asix.c | 40 ++++++++++++++++++++++++++++++++++------ fs/fs.c | 6 ++---- fs/ubifs/super.c | 5 +++-- fs/ubifs/ubifs.c | 4 ++-- include/common.h | 7 +++++++ include/configs/colibri_vf.h | 1 - lib/gzip.c | 2 +- net/tftp.c | 2 ++ tools/logos/toradex.bmp | Bin 0 -> 24982 bytes 13 files changed, 56 insertions(+), 20 deletions(-) create mode 100644 tools/logos/toradex.bmp

From: Max Krummenacher max.krummenacher@toradex.com
http://lists.denx.de/pipermail/u-boot/2012-September/134347.html allows for reading files in chunks from the shell.
When this feature is used to read past the end of a file an error was returned instead of returning the bytes read up to the end of file. Thus the following fails in the shell:
offset = 0 len = chunksize do read file, offset, len write data until bytes_read < len
The patch changes the behaviour to printing an informational message and returning the actual read number of bytes aka read(2) behaviour for convenient use in U-Boot scripts.
Signed-off-by: Max Krummenacher max.krummenacher@toradex.com Signed-off-by: Marcel Ziswiler marcel.ziswiler@toradex.com Acked-by: Marek Vasut marex@denx.de --- Changes in v2: mention read(2) behaviour as suggested by Marek
fs/fs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c index ac0897d..827b143 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -301,10 +301,8 @@ int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len, unmap_sysmem(buf);
/* If we requested a specific number of bytes, check we got it */ - if (ret == 0 && len && *actread != len) { - printf("** Unable to read file %s **\n", filename); - ret = -1; - } + if (ret == 0 && len && *actread != len) + printf("** %s shorter than offset + len **\n", filename); fs_close();
return ret;

From: Marcel Ziswiler marcel.ziswiler@toradex.com
This patch fixes operation of our on-board AX88772B chip without EEPROM but with a ethaddr coming from the regular U-Boot environment. This is a forward port of some remaining parts initially implemented by Antmicro.
Signed-off-by: Marcel Ziswiler marcel.ziswiler@toradex.com Acked-by: Marek Vasut marex@denx.de --- Changes in v3 as suggested by Marek: - introduce ctl variable - fix comment style - use mdelay Changes in v2: - run it through checkpatch.pl as suggested by Marek and Joe - cleanup comments and use VID/PID defines as suggested by Marek - dug out an AX88772 (not B) dongle again and verified operation - AX88772 (not B) indeed does not work with B modifications (e.g. VID/PID based differentiation is indeed required) - dug out another AX88772B dongle as well and verified operation
drivers/usb/eth/asix.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c index 72ec41e..8a43e7c 100644 --- a/drivers/usb/eth/asix.c +++ b/drivers/usb/eth/asix.c @@ -1,6 +1,8 @@ /* * Copyright (c) 2011 The Chromium OS Authors. * + * Patched for AX88772B by Antmicro Ltd <www.antmicro.com> + * * SPDX-License-Identifier: GPL-2.0+ */
@@ -64,8 +66,11 @@ AX_MEDIUM_AC | AX_MEDIUM_RE)
/* AX88772 & AX88178 RX_CTL values */ -#define AX_RX_CTL_SO 0x0080 -#define AX_RX_CTL_AB 0x0008 +#define AX_RX_CTL_RH2M 0x0200 /* 32-bit aligned RX IP header */ +#define AX_RX_CTL_RH1M 0x0100 /* Enable RX header format type 1 */ +#define AX_RX_CTL_SO 0x0080 +#define AX_RX_CTL_AB 0x0008 +#define AX_RX_HEADER_DEFAULT (AX_RX_CTL_RH1M | AX_RX_CTL_RH2M)
#define AX_DEFAULT_RX_CTL \ (AX_RX_CTL_SO | AX_RX_CTL_AB) @@ -92,6 +97,8 @@ #define FLAG_TYPE_AX88772B (1U << 2) #define FLAG_EEPROM_MAC (1U << 3) /* initial mac address in eeprom */
+#define ASIX_USB_VENDOR_ID 0x0b95 +#define AX88772B_USB_PRODUCT_ID 0x772b
/* driver private */ struct asix_private { @@ -418,15 +425,23 @@ static int asix_basic_reset(struct ueth_data *dev) return 0; }
-static int asix_init_common(struct ueth_data *dev) +static int asix_init_common(struct ueth_data *dev, uint8_t *enetaddr) { int timeout = 0; #define TIMEOUT_RESOLUTION 50 /* ms */ int link_detected; + u32 ctl = AX_DEFAULT_RX_CTL;
debug("** %s()\n", __func__);
- if (asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL) < 0) + if ((dev->pusb_dev->descriptor.idVendor == ASIX_USB_VENDOR_ID) && + (dev->pusb_dev->descriptor.idProduct == AX88772B_USB_PRODUCT_ID)) + ctl |= AX_RX_HEADER_DEFAULT; + + if (asix_write_rx_ctl(dev, ctl) < 0) + goto out_err; + + if (asix_write_hwaddr_common(dev, enetaddr) < 0) goto out_err;
do { @@ -447,6 +462,12 @@ static int asix_init_common(struct ueth_data *dev) goto out_err; }
+ /* + * Wait some more to avoid timeout on first transfer + * (e.g. EHCI timed out on TD - token=0x8008d80) + */ + mdelay(25); + return 0; out_err: return -1; @@ -488,7 +509,7 @@ static int asix_init(struct eth_device *eth, bd_t *bd) { struct ueth_data *dev = (struct ueth_data *)eth->priv;
- return asix_init_common(dev); + return asix_init_common(dev, eth->enetaddr); }
static int asix_send(struct eth_device *eth, void *packet, int length) @@ -550,6 +571,12 @@ static int asix_recv(struct eth_device *eth) return -1; }
+ if ((dev->pusb_dev->descriptor.idVendor == + ASIX_USB_VENDOR_ID) && + (dev->pusb_dev->descriptor.idProduct == + AX88772B_USB_PRODUCT_ID)) + buf_ptr += 2; + /* Notify net stack */ net_process_received_packet(buf_ptr + sizeof(packet_len), packet_len); @@ -729,9 +756,10 @@ int asix_eth_get_info(struct usb_device *dev, struct ueth_data *ss, #ifdef CONFIG_DM_ETH static int asix_eth_start(struct udevice *dev) { + struct eth_pdata *pdata = dev_get_platdata(dev); struct asix_private *priv = dev_get_priv(dev);
- return asix_init_common(&priv->ueth); + return asix_init_common(&priv->ueth, pdata->enetaddr); }
void asix_eth_stop(struct udevice *dev)

Hi Marcel,
On Tue, Aug 4, 2015 at 1:56 AM, Marcel Ziswiler marcel@ziswiler.com wrote:
From: Marcel Ziswiler marcel.ziswiler@toradex.com
This patch fixes operation of our on-board AX88772B chip without EEPROM but with a ethaddr coming from the regular U-Boot environment. This is a forward port of some remaining parts initially implemented by Antmicro.
Signed-off-by: Marcel Ziswiler marcel.ziswiler@toradex.com Acked-by: Marek Vasut marex@denx.de
Acked-by: Joe Hershberger joe.hershberger@ni.com

From: Marcel Ziswiler marcel.ziswiler@toradex.com
Allow showing custom board info from a checkboard() function being implemented if CONFIG_CUSTOM_BOARDINFO is specified. Previously the device tree model was always displayed not taking any CONFIG_CUSTOM_BOARDINFO into account.
Signed-off-by: Marcel Ziswiler marcel.ziswiler@toradex.com Reviewed-by: Simon Glass sjg@chromium.org --- Changes in v2: reword commit message as requested by Simon
common/board_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/board_info.c b/common/board_info.c index 4e5a1f7..839fa5a 100644 --- a/common/board_info.c +++ b/common/board_info.c @@ -18,7 +18,7 @@ int __weak checkboard(void) */ int show_board_info(void) { -#ifdef CONFIG_OF_CONTROL +#if defined(CONFIG_OF_CONTROL) && !defined(CONFIG_CUSTOM_BOARDINFO) DECLARE_GLOBAL_DATA_PTR; const char *model;

From: Stefan Agner stefan.agner@toradex.com
Use the boot loader splash screen from WinCE which matches our wallpapers position wise. Although the logo is an 8-bit indexed BMP as well colours looked odd at first in U-Boot. After converting to full RGB palette and converting back to an indexed BMP using imagemagick the Logo showed up properly.
$ convert tools/logos/toradex-rgb.bmp -type Palette -colors 256 \ -compress none -verbose BMP3:tools/logos/toradex.bmp
Signed-off-by: Stefan Agner stefan.agner@toradex.com Signed-off-by: Marcel Ziswiler marcel.ziswiler@toradex.com --- tools/logos/toradex.bmp | Bin 0 -> 24982 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tools/logos/toradex.bmp
diff --git a/tools/logos/toradex.bmp b/tools/logos/toradex.bmp new file mode 100644 index 0000000000000000000000000000000000000000..3e2dcf23358dd46fc7b1bb0dae70d3ba985606ee GIT binary patch literal 24982 zcmeHPy>H~k6(3!0Ppji;#g)jt)k#_{wd9K2#Q*^=NL&Xlg21U<8%UaK+}lmcz@3r8 zfPpKV!nJ|?0|wHjaPQK8fh$)A3?uJj-pr63?s8A3a}M4CL=NZUy*Iyk^WK{wSAYD= z=YLa_e*aLZ5_0byDD@|}AE+Uf|Mdf<P9y$<Lad;4aB!dw9z0MF;P2q!Z`5EgP!Em{ z)o?ge$H&KN5I<3e=V$8d>`X=FOvUf4RF-9GwOXm?&!4O0&+n+q7w@T?zki_KefM4U z{`>E%7cX9@4?p}+ee}^sYW=T|)$^Ax)NlX&5B0nM{8Rnmzn`m5KKVp_`st_Yv(G+L zFJHb?UwrX}`tr*!)mLAArM~|9YxT`H->7fD{Z@VV-FNEy@4r_+{P2VN@y8$4Pe1*n ze*XDq7JPr*Bd|wckH8**|6c?$-BY$WuXH)>+4$GltT&d^Dw`HM`*ot!Z`8f993j0- z)2$!rUtO!-SQ0X^-mmg*71<5T=*=whD64cerzMc+B?zC=6_$mH3O3tvSK1o<LQ{fn zB&EG%WnAcLMi@*>T@|n=0S?u4y2i3urHi;E<0ZADLN604a@3Vdz+-S{=(3z(U(17X znYN6Qr7kB^4V;ov=iHE?rY_KKnQ&(-KGM5~6zSz0hL2#*Gz!F5#Bx;SV790BUc(Z0 zTv-Oqn?tM$W9kcC%w|iVo9ld5RfuJ#p|YwFOR0^@Y6e(ik%uM7P-H~~<O`ioml`Lh zi_r+?4k#c_Knq%8Lx*KlVfCBAQpF%dg7c}COP$KqNCS@*)L<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&= z5R@ieP#6+}Q39>fxM>5Rcrs}hTgJj-f-H;$3}Oild(o;>{w1C^VEN|7>B92OOY%w_ zdFLhp+AEQGeVyJeER(d6*cUDur4n_#KA3t@db_ZcO^xrQ1NkjBvKKI~(CF>L(rs!2 z2-+e!9eV{h?$qTi!_w>wENsEd9?O0z;Wo@c7^!gG3~>69zH_U$O)phkc7Ir6YWyAU RodMc`0Q`TRs=7z!{{x@?rvLx|
literal 0 HcmV?d00001

From: Marcel Ziswiler marcel.ziswiler@toradex.com
Remove spurious new line in configuration file.
Signed-off-by: Marcel Ziswiler marcel.ziswiler@toradex.com Tested-by: Marek Vasut marex@denx.de Acked-by: Marek Vasut marex@denx.de --- include/configs/colibri_vf.h | 1 - 1 file changed, 1 deletion(-)
diff --git a/include/configs/colibri_vf.h b/include/configs/colibri_vf.h index ab8d293..e4a0c66 100644 --- a/include/configs/colibri_vf.h +++ b/include/configs/colibri_vf.h @@ -69,7 +69,6 @@ "512k(u-boot-env)," \ "-(ubi)"
- #define CONFIG_MMC #define CONFIG_FSL_ESDHC #define CONFIG_SYS_FSL_ESDHC_ADDR 0

From: Max Krummenacher max.krummenacher@toradex.com
This fixes the following warning (and the runtime error reporting): ../common/image-fdt.c:491:4: warning: 'fdt_ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
Signed-off-by: Max Krummenacher max.krummenacher@toradex.com Signed-off-by: Marcel Ziswiler marcel.ziswiler@toradex.com Acked-by: Marek Vasut marex@denx.de Acked-by: Simon Glass sjg@chromium.org --- Changes in v2: run it through checkpatch.pl and replace spaces with tab
common/image-fdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/image-fdt.c b/common/image-fdt.c index 80e3e63..5180a03 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -492,7 +492,8 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob, } } if (IMAGE_OF_SYSTEM_SETUP) { - if (ft_system_setup(blob, gd->bd)) { + fdt_ret = ft_system_setup(blob, gd->bd); + if (fdt_ret) { printf("ERROR: system-specific fdt fixup failed: %s\n", fdt_strerror(fdt_ret)); goto err;

From: Marcel Ziswiler marcel.ziswiler@toradex.com
Various U-Boot adoptions/extensions to MTD/NAND/UBI did not take buffer alignment into account which led to failures of the following form:
ERROR: v7_dcache_inval_range - start address is not aligned - 0x1f7f0108 ERROR: v7_dcache_inval_range - stop address is not aligned - 0x1f7f1108
Signed-off-by: Marcel Ziswiler marcel.ziswiler@toradex.com Reviewed-by: Simon Glass sjg@chromium.org Acked-by: Scott Wood scottwood@freescale.com --- Changes in v4: move wrapper to common.h as suggested by Scott Changes in v3: introduce malloc_cache_aligned() as suggested by Scott Changes in v2: run it through checkpatch.pl and fix long lines
common/cmd_ubi.c | 2 +- drivers/mtd/nand/nand_util.c | 2 +- fs/ubifs/super.c | 5 +++-- fs/ubifs/ubifs.c | 4 ++-- include/common.h | 7 +++++++ lib/gzip.c | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c index cbc10c5..10eea65 100644 --- a/common/cmd_ubi.c +++ b/common/cmd_ubi.c @@ -363,7 +363,7 @@ int ubi_volume_read(char *volume, char *buf, size_t size) tbuf_size = vol->usable_leb_size; if (size < tbuf_size) tbuf_size = ALIGN(size, ubi->min_io_size); - tbuf = malloc(tbuf_size); + tbuf = malloc_cache_aligned(tbuf_size); if (!tbuf) { printf("NO MEM\n"); return ENOMEM; diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c index ee2c24d..21b4a61 100644 --- a/drivers/mtd/nand/nand_util.c +++ b/drivers/mtd/nand/nand_util.c @@ -839,7 +839,7 @@ int nand_torture(nand_info_t *nand, loff_t offset)
patt_count = ARRAY_SIZE(patterns);
- buf = malloc(nand->erasesize); + buf = malloc_cache_aligned(nand->erasesize); if (buf == NULL) { puts("Out of memory for erase block buffer\n"); return -ENOMEM; diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 10f8fff..0bf52db 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -57,7 +57,8 @@ struct inode *iget_locked(struct super_block *sb, unsigned long ino) { struct inode *inode;
- inode = (struct inode *)malloc(sizeof(struct ubifs_inode)); + inode = (struct inode *)malloc_cache_aligned( + sizeof(struct ubifs_inode)); if (inode) { inode->i_ino = ino; inode->i_sb = sb; @@ -104,7 +105,7 @@ void iput(struct inode *inode) /* * Allocate and use new inode */ - ino = (struct inode *)malloc(sizeof(struct ubifs_inode)); + ino = (struct inode *)malloc_cache_aligned(sizeof(struct ubifs_inode)); memcpy(ino, inode, sizeof(struct ubifs_inode));
/* diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index 6dd6174..4daa7fa 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -108,7 +108,7 @@ static inline struct crypto_comp *crypto_alloc_comp(const char *alg_name, struct crypto_comp *ptr; int i = 0;
- ptr = malloc(sizeof(struct crypto_comp)); + ptr = malloc_cache_aligned(sizeof(struct crypto_comp)); while (i < UBIFS_COMPR_TYPES_CNT) { comp = ubifs_compressors[i]; if (!comp) { @@ -723,7 +723,7 @@ static int do_readpage(struct ubifs_info *c, struct inode *inode, * destination area to a multiple of * UBIFS_BLOCK_SIZE. */ - buff = malloc(UBIFS_BLOCK_SIZE); + buff = malloc_cache_aligned(UBIFS_BLOCK_SIZE); if (!buff) { printf("%s: Error, malloc fails!\n", __func__); diff --git a/include/common.h b/include/common.h index 4566bd1..3f02e82 100644 --- a/include/common.h +++ b/include/common.h @@ -1010,6 +1010,13 @@ int cpu_release(int nr, int argc, char * const argv[]); #define DEFINE_CACHE_ALIGN_BUFFER(type, name, size) \ DEFINE_ALIGN_BUFFER(type, name, size, ARCH_DMA_MINALIGN)
+#include <malloc.h> + +static inline void *malloc_cache_aligned(size_t size) +{ + return memalign(ARCH_DMA_MINALIGN, ALIGN(size, ARCH_DMA_MINALIGN)); +} + /* * check_member() - Check the offset of a structure member * diff --git a/lib/gzip.c b/lib/gzip.c index ff37d4f..cd8e9fe 100644 --- a/lib/gzip.c +++ b/lib/gzip.c @@ -25,7 +25,7 @@ static void *zalloc(void *x, unsigned items, unsigned size) size *= items; size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1);
- p = malloc (size); + p = malloc_cache_aligned(size);
return (p); }

From: Max Krummenacher max.krummenacher@toradex.com
CONFIG_TFTP_TSIZE should limit a tftp downloads progress to 50 '#' chars. Make this work also for small files.
If the file size is small, i.e. smaller than 2 tftp block sizes the number of '#' can get much larger. i.e. with a 1 byte file 65000 characters are printed, with a 512 byte file around 500.
When using CONFIG TFTP BLOCKSIZE together with CONFIG_IP_DEFRAG the issue is more notable.
Signed-off-by: Max Krummenacher max.krummenacher@toradex.com Signed-off-by: Marcel Ziswiler marcel.ziswiler@toradex.com Reviewed-by: Marek Vasut marex@denx.de --- Changes in v2: run it through checkpatch.pl and fix missing space in if clause as suggested by Marek
net/tftp.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/net/tftp.c b/net/tftp.c index 3e99e73..89be32a 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -249,6 +249,8 @@ static void show_block_marker(void) if (tftp_tsize) { ulong pos = tftp_cur_block * tftp_block_size + tftp_block_wrap_offset; + if (pos > tftp_tsize) + pos = tftp_tsize;
while (tftp_tsize_num_hash < pos * 50 / tftp_tsize) { putc('#');

Hi Marcel,
On Tue, Aug 4, 2015 at 1:58 AM, Marcel Ziswiler marcel@ziswiler.com wrote:
From: Max Krummenacher max.krummenacher@toradex.com
CONFIG_TFTP_TSIZE should limit a tftp downloads progress to 50 '#' chars. Make this work also for small files.
If the file size is small, i.e. smaller than 2 tftp block sizes the number of '#' can get much larger. i.e. with a 1 byte file 65000 characters are printed, with a 512 byte file around 500.
When using CONFIG TFTP BLOCKSIZE together with CONFIG_IP_DEFRAG the issue is more notable.
Signed-off-by: Max Krummenacher max.krummenacher@toradex.com Signed-off-by: Marcel Ziswiler marcel.ziswiler@toradex.com Reviewed-by: Marek Vasut marex@denx.de
Acked-by: Joe Hershberger joe.hershberger@ni.com
participants (2)
-
Joe Hershberger
-
Marcel Ziswiler