oweals/u-boot.git
7 years agoARM: imx6: Add DHCOM i.MX6 PDK board support
Marek Vasut [Mon, 9 Oct 2017 19:51:10 +0000 (21:51 +0200)]
ARM: imx6: Add DHCOM i.MX6 PDK board support

Add support for the DHCOM i.MX6 PDK board. This board has:
- FEC ethernet
- EHCI USB host
- 3x SDMMC

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Stefano Babic <sbabic@denx.de>
7 years agoimx: mx7: spl: remove redundant SATA definitionas
Uri Mashiach [Tue, 10 Oct 2017 06:13:10 +0000 (09:13 +0300)]
imx: mx7: spl: remove redundant SATA definitionas

The i.MX7 SOC doesn't include the SATA interface.

Signed-off-by: Uri Mashiach <uri.mashiach@compulab.co.il>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
7 years agomx6: sys_proto: Add prototypes for imx6_pcie_toggle() functions
Diego Dorta [Thu, 5 Oct 2017 12:15:58 +0000 (09:15 -0300)]
mx6: sys_proto: Add prototypes for imx6_pcie_toggle() functions

When compiling with W=1 errors are observed:

drivers/pci/pcie_imx.c:517:12: warning: no previous prototype for ‘imx6_pcie_toggle_power’ [-Wmissing-prototypes] __weak int imx6_pcie_toggle_power(void)

drivers/pci/pcie_imx.c:528:12: warning: no previous prototype for ‘imx6_pcie_toggle_reset’ [-Wmissing-prototypes] __weak int imx6_pcie_toggle_reset(void)

Remove these warnings by adding the functions prototypes on arch-mx6/sys_proto.

Signed-off-by: Diego Dorta <diego.dorta@nxp.com>
7 years agomx6: clock: Add a prototype for do_mx6_showclocks()
Diego Dorta [Thu, 5 Oct 2017 12:15:57 +0000 (09:15 -0300)]
mx6: clock: Add a prototype for do_mx6_showclocks()

When compiling with W=1 the following warning is observed:

arch/arm/mach-imx/mx6/clock.c:1268:5: warning: no previous prototype for ‘do_mx6_showclocks’ [-Wmissing-prototypes] int do_mx6_showclocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

Remove this warning by adding the function prototype into arch-mx6/clock.h file.

Signed-off-by: Diego Dorta <diego.dorta@nxp.com>
7 years agoi.mx6ul: xpress: update UART init for current board revision
Anatolij Gustschin [Mon, 2 Oct 2017 19:32:55 +0000 (21:32 +0200)]
i.mx6ul: xpress: update UART init for current board revision

UART pinmux has been changed on the last board revision. Change
board pinmux accordingly. Console is on UART7 now, add pinmux,
base address and update console string in environment.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Stefano Babic <sbabic@denx.de>
7 years agomx6slevk: Use PARTUUID to specify the rootfs location
Fabio Estevam [Mon, 2 Oct 2017 13:11:37 +0000 (10:11 -0300)]
mx6slevk: Use PARTUUID to specify the rootfs location

mx6slevk can run different kernel versions, such as NXP 4.1 or mainline.

Currently the rootfs location is passed via mmcblk number and the
problem with this approach is that the mmcblk number for the SD
card changes depending on the kernel version.

In order to avoid such issue, use the UUID method to specify the
rootfs location.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
7 years agodrivers: pci: imx: fix imx_pcie_remove function
Sven-Ola Tuecke [Thu, 5 Oct 2017 11:46:42 +0000 (08:46 -0300)]
drivers: pci: imx: fix imx_pcie_remove function

We have at least a minor count of boards, that failed to re-initialize
PCI express in the Linux kernel. Typical failure rate is 20% on affected
boards. This is mitigated by commit 6ecbe1375671 ("drivers: pci: imx:
add imx_pcie_remove function").

However, at least on some i.MX6 custom boards, when calling
assert_core_reset() as part of the first-time PCIe init, read access
to PCIE_PL_PFLR simply hangs. Surround this readl() with
imx_pcie_fix_dabt_handler() does not help. For this reason, the forced
LTSSM detection is only used on the second assert_core_reset() that is
called shorly before starting the Linux kernel.

Signed-off-by: Sven-Ola Tuecke <sven-ola.tuecke@numberfour.eu>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Tested-by: David Müller <d.mueller@elsoft.ch>
7 years agowandboard: Add support for the latest revd1 revision
Fabio Estevam [Mon, 2 Oct 2017 18:47:29 +0000 (15:47 -0300)]
wandboard: Add support for the latest revd1 revision

Latest wandboard hardware revision is revd1, which brings the following
new features:

- PFUZE100 PMIC
- AR8035 Ethernet PHY
- Upgrade Wifi/BT chip to BCM4339/BCM43430.

The detection mechanism is to probe the PMIC and when it is
found, then the revision of the board is revd1.

As the detection is done via PMIC, we need to print the board version
at a later stage via CONFIG_DISPLAY_BOARDINFO_LATE and also need
to disable CONFIG_DISPLAY_BOARDINFO, which is done much earlier.

Make the necessary adjustments for the AR8035 PHY to work on revd1.

Based on Richard Hu's work from Technexion's U-Boot tree.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
7 years agodoc: update imx_usb_loader URL
Stefan Agner [Tue, 3 Oct 2017 14:43:26 +0000 (16:43 +0200)]
doc: update imx_usb_loader URL

The changes required to use U-Boot's Serial Download Protocol
implementation are now available in upstream imx_usb_loader
repository. Update the URL accordingly.

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
7 years agoarm: imx7d: add support for Compulab cl-som-imx7
Ilya Ledvich [Sun, 24 Sep 2017 06:00:25 +0000 (09:00 +0300)]
arm: imx7d: add support for Compulab cl-som-imx7

Add initial support for Compulab cl-som-imx7 SoM.
The initial support includes:
 - MMC
 - eMMC
 - SPI flash
 - I2C
 - FEC
 - USB
 - Serial console

Signed-off-by: Ilya Ledvich <ilya@compulab.co.il>
7 years agoimx: mx7: SPL support for i.MX7
Uri Mashiach [Sun, 24 Sep 2017 06:00:24 +0000 (09:00 +0300)]
imx: mx7: SPL support for i.MX7

Add configuration file and spl_boot_device function for the i.MX7 SPL.

Signed-off-by: Uri Mashiach <uri.mashiach@compulab.co.il>
7 years agoimx: mx7: DDR controller configuration for the i.MX7 architecture
Uri Mashiach [Sun, 24 Sep 2017 06:00:23 +0000 (09:00 +0300)]
imx: mx7: DDR controller configuration for the i.MX7 architecture

The configuration files imximage.cfg are used for the DDR controller
configuration.
Add DDR configuration function to replace the DDR controller
configuration in the imximage.cfg file. The function can be used for
DDR size detection.

Signed-off-by: Uri Mashiach <uri.mashiach@compulab.co.il>
7 years agoimx: mx7: fix the CCM_ macros
Uri Mashiach [Sun, 24 Sep 2017 06:00:22 +0000 (09:00 +0300)]
imx: mx7: fix the CCM_ macros

The CCM_ macros use the CCM_BASE_ADDRESS macro, which doesn't exist.
Replace the CCM_BASE_ADDRESS macros with CCM_BASE_ADDR.

Signed-off-by: Uri Mashiach <uri.mashiach@compulab.co.il>
Acked-by: Igor Grinberg <grinberg@compulab.co.il>
7 years agoicorem6_rqs: env: Return mmc devno
Jagan Teki [Thu, 28 Sep 2017 17:59:14 +0000 (23:29 +0530)]
icorem6_rqs: env: Return mmc devno

Instead of changing mmc devno from dts nodes better
to return the detected devno so-that env trigger the same.

Cc: Stefano Babic <sbabic@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
7 years agoicore: configs: Fix merge conflict issue
Jagan Teki [Thu, 28 Sep 2017 17:59:13 +0000 (23:29 +0530)]
icore: configs: Fix merge conflict issue

Fix for finding mmc devices on i.MX6Q icore boards
added in below comment
"icorem6: Fix to find MMC devices"
(sha1: a2b137b38d925df91afef52f5122927de024f81a)

which is reverted in during u-boot-imx merge
" Merge git://git.denx.de/u-boot-imx"
(sha1: 6aee2ab68c362ace5a59f89a63abed82e0bf19e5)

This patch, is recreated to fix merge conflict.

Cc: Stefano Babic <sbabic@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
7 years agotopic_miami: Remove CONFIG_CMD_BOOTZ undef
Fabio Estevam [Thu, 28 Sep 2017 19:46:00 +0000 (16:46 -0300)]
topic_miami: Remove CONFIG_CMD_BOOTZ undef

CONFIG_CMD_BOOTZ option has been converted to defconfig, so there
is no need to undefine it in board config file anymore.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
7 years agomx6sabresd: Include <usb/ehci-ci.h> header file
Diego Dorta [Wed, 27 Sep 2017 16:12:40 +0000 (13:12 -0300)]
mx6sabresd: Include <usb/ehci-ci.h> header file

When compiling with W=1 the following warning is observed:

board/freescale/mx6sabresd/mx6sabresd.c:586:5: warning: no previous prototype for ‘board_ehci_hcd_init’ [-Wmissing-prototypes] int board_ehci_hcd_init(int port)

Remove this warning by including <usb/ehci-ci.h>.

Signed-off-by: Diego Dorta <diego.dorta@nxp.com>
7 years agousb: ehci-ci: Add a prototype for board_ehci_power()
Diego Dorta [Wed, 27 Sep 2017 16:12:39 +0000 (13:12 -0300)]
usb: ehci-ci: Add a prototype for board_ehci_power()

When compiling with W=1 the following warning is observed:

board/freescale/mx6sabresd/mx6sabresd.c:601:5: warning: no previous prototype for ‘board_ehci_power’ [-Wmissing-prototypes] int board_ehci_power(int port, int on)

Remove this warning by adding the function prototype into usb/ehci-ci.h file.

Signed-off-by: Diego Dorta <diego.dorta@nxp.com>
7 years agomx6sabresd: Include <asm/mach-imx/spi.h> header file
Diego Dorta [Wed, 27 Sep 2017 16:12:38 +0000 (13:12 -0300)]
mx6sabresd: Include <asm/mach-imx/spi.h> header file

When compiling with W=1 the following warning is observed:

board/freescale/mx6sabresd/mx6sabresd.c:680:5: warning: no previous prototype for ‘board_spi_cs_gpio’ [-Wmissing-prototypes] int board_spi_cs_gpio(unsigned bus, unsigned cs)

Remove this warning by including <asm/mach-imx/spi.h>.

Signed-off-by: Diego Dorta <diego.dorta@nxp.com>
7 years agomx6: soc: Include <asm/bootm.h> header file
Diego Dorta [Wed, 27 Sep 2017 16:12:37 +0000 (13:12 -0300)]
mx6: soc: Include <asm/bootm.h> header file

When compiling with W=1 the following warning is observed:

arch/arm/mach-imx/mx6/soc.c:213:12: warning: no previous prototype for ‘get_board_rev’ [-Wmissing-prototypes] u32 __weak get_board_rev(void)

Fix the build warning by including <asm/bootm.h>.

Signed-off-by: Diego Dorta <diego.dorta@nxp.com>
7 years agomx7ulp_evk: Move CONFIG_CMD_BOOTZ to Kconfig
Fabio Estevam [Wed, 27 Sep 2017 18:00:41 +0000 (15:00 -0300)]
mx7ulp_evk: Move CONFIG_CMD_BOOTZ to Kconfig

CONFIG_CMD_BOOTZ symbol does not work in board config file
anymore, so fix this by moving it to Kconfig.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
7 years agoimx: sys_proto: Add a prototype for board_mmc_get_env_dev()
Diego Dorta [Thu, 21 Sep 2017 18:10:03 +0000 (15:10 -0300)]
imx: sys_proto: Add a prototype for board_mmc_get_env_dev()

When compiling with W=1 the following warning is observed:

board/freescale/mx6sabresd/mx6sabresd.c:266:5: warning:
no previous prototype for ‘board_mmc_get_env_dev’
[-Wmissing-prototypes] int board_mmc_get_env_dev(int devno)

Remove this warning by adding the function prototype into sys_proto.h file.

Signed-off-by: Diego Dorta <diego.dorta@nxp.com>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Stefano Babic <sbabic@denx.de>
7 years agoimx: Include <input.h> header file
Diego Dorta [Fri, 22 Sep 2017 15:12:18 +0000 (12:12 -0300)]
imx: Include <input.h> header file

When building with W=1 errors like the one below is seen:

board/freescale/mx6sabresd/mx6sabresd.c:546:5: warning:
no previous prototype for ‘overwrite_console’
[-Wmissing-prototypes] int overwrite_console(void)

Fix the build warnings by including <input.h>.

Signed-off-by: Diego Dorta <diego.dorta@nxp.com>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
7 years agomx6: toradex: Remove custom CONFIG_SPL_PAD_TO definition
Fabio Estevam [Mon, 25 Sep 2017 18:20:56 +0000 (15:20 -0300)]
mx6: toradex: Remove custom CONFIG_SPL_PAD_TO definition

CONFIG_SPL_PAD_TO is already defined inside "imx6_spl.h", so there
is no need to redefine it in the board config files.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Stefan Agner <stefan.agner@toradex.com>
7 years agomx25pdk: Remove duplicated define
Otavio Salvador [Sat, 30 Sep 2017 01:55:00 +0000 (22:55 -0300)]
mx25pdk: Remove duplicated define

The CONFIG_SYS_MMC_ENV_DEV is duplicated, drop it.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
7 years agomx25pdk: Use generic filesystem commands
Otavio Salvador [Sat, 30 Sep 2017 01:54:59 +0000 (22:54 -0300)]
mx25pdk: Use generic filesystem commands

This rework the board to use the generic filesystem commands instead
of forcing the use of FAT for the boot files.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
7 years agoREADME.imx6: Prefer loading SPL via the new SDP mechanism
Fabio Estevam [Wed, 20 Sep 2017 14:21:49 +0000 (11:21 -0300)]
README.imx6: Prefer loading SPL via the new SDP mechanism

Now that it is possible to load SPL and u-boot.img via imx_usb_loader
tool, mention this method instead of the old one that relied on ymodem.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
7 years agomx53loco: Let CONFIG_DISPLAY_CPUINFO be selected
Fabio Estevam [Tue, 19 Sep 2017 17:46:29 +0000 (14:46 -0300)]
mx53loco: Let CONFIG_DISPLAY_CPUINFO be selected

With CONFIG_DISPLAY_CPUINFO=y we get a "Reset cause" line, which
brings important information of the reboot cause.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
7 years agoimx6: disable clock command and print_cpuinfo code in SPL
Anatolij Gustschin [Mon, 28 Aug 2017 19:46:26 +0000 (21:46 +0200)]
imx6: disable clock command and print_cpuinfo code in SPL

We do not use print_cpuinfo and clock command code in SPL,
disable it when building SPL image.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
7 years agocolibri_imx6: Avoid calling setup_display() from SPL code
Fabio Estevam [Sat, 23 Sep 2017 02:45:33 +0000 (23:45 -0300)]
colibri_imx6: Avoid calling setup_display() from SPL code

There is no need call setup_display() from SPL code, so move it to
board_init(), which executes only in U-Boot proper.

Reported-by: Stefano Babic <sbabic@denx.de>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
7 years agoapalis_imx6: Avoid calling setup_display() from SPL code
Fabio Estevam [Sat, 23 Sep 2017 02:45:32 +0000 (23:45 -0300)]
apalis_imx6: Avoid calling setup_display() from SPL code

There is no need call setup_display() from SPL code, so move it to
board_init(), which executes only in U-Boot proper.

Reported-by: Stefano Babic <sbabic@denx.de>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
7 years agomx6cuboxi: Avoid calling setup_display() from SPL code
Fabio Estevam [Sat, 23 Sep 2017 02:45:31 +0000 (23:45 -0300)]
mx6cuboxi: Avoid calling setup_display() from SPL code

There is no need call setup_display() from SPL code, so move it to
board_init(), which executes only in U-Boot proper.

Reported-by: Stefano Babic <sbabic@denx.de>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Stefano Babic <sbabic@denx.de>
7 years agowandboard: Avoid calling setup_display() from SPL code
Fabio Estevam [Sat, 23 Sep 2017 02:45:30 +0000 (23:45 -0300)]
wandboard: Avoid calling setup_display() from SPL code

There is no need call setup_display() from SPL code, so move it to
board_init(), which executes only in U-Boot proper.

Reported-by: Stefano Babic <sbabic@denx.de>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Stefano Babic <sbabic@denx.de>
7 years agocgtqmx6eval: Avoid calling setup_display() from SPL code
Fabio Estevam [Sat, 23 Sep 2017 02:45:29 +0000 (23:45 -0300)]
cgtqmx6eval: Avoid calling setup_display() from SPL code

There is no need call setup_display() from SPL code, so move it to
board_init(), which executes only in U-Boot proper.

Reported-by: Stefano Babic <sbabic@denx.de>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Stefano Babic <sbabic@denx.de>
7 years agomx6sabresd: Avoid calling setup_display() from SPL code
Fabio Estevam [Sat, 23 Sep 2017 02:45:28 +0000 (23:45 -0300)]
mx6sabresd: Avoid calling setup_display() from SPL code

There is no need call setup_display() from SPL code, so move it to
board_init(), which executes only in U-Boot proper.

Reported-by: Stefano Babic <sbabic@denx.de>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Stefano Babic <sbabic@denx.de>
7 years agoMerge git://git.denx.de/u-boot-i2c
Tom Rini [Wed, 11 Oct 2017 12:38:20 +0000 (08:38 -0400)]
Merge git://git.denx.de/u-boot-i2c

7 years agoi2c: muxes: pca954x: look up width from chip_desc
Chris Packham [Thu, 28 Sep 2017 21:53:36 +0000 (10:53 +1300)]
i2c: muxes: pca954x: look up width from chip_desc

Commit 8e6eda7cda6c ("drivers/i2c/muxes/pca954x: Add pca9547 I2C mux
support") introduced a chip_desc for the pca954x devices but failed to
update pca954x_ofdata_to_platdata() to be aware of it. Make
pca954x_ofdata_to_platdata() lookup the chip_desc to validate the device
width.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Marek Behun <marek.behun@nic.cz>
7 years agoMerge branch 'rmobile' of git://git.denx.de/u-boot-sh
Tom Rini [Wed, 11 Oct 2017 00:14:38 +0000 (20:14 -0400)]
Merge branch 'rmobile' of git://git.denx.de/u-boot-sh

7 years agoconfigs: Re-sync CONFIG_CMD_IMLS with moveconfig
Tuomas Tynkkynen [Sun, 8 Oct 2017 18:48:02 +0000 (21:48 +0300)]
configs: Re-sync CONFIG_CMD_IMLS with moveconfig

The option is specified in Kconfig, but still a few config header files
are overriding the choice by #undef'ing it. Re-sync the option with
moveconfig to rid of the #undefs.

Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
7 years agocmd: Toggle the default value of CONFIG_CMD_IMLS
Tuomas Tynkkynen [Sun, 8 Oct 2017 18:48:01 +0000 (21:48 +0300)]
cmd: Toggle the default value of CONFIG_CMD_IMLS

Having this as a 'default y' is rather annoying because it doesn't
actually compile unless other options are defined in the board header:

../cmd/bootm.c: In function 'do_imls_nor':
../cmd/bootm.c:330:7: error: 'CONFIG_SYS_MAX_FLASH_BANKS' undeclared (first use in this function); did you mean 'CONFIG_SYS_MAX_FLASH_SECT'?
   i < CONFIG_SYS_MAX_FLASH_BANKS; ++i, ++info) {

Make it 'default n' so people who develop new boards that start from a
blank defconfig have one less compilation failure to debug.

Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
7 years agoMerge git://git.denx.de/u-boot-dm
Tom Rini [Tue, 10 Oct 2017 00:19:39 +0000 (20:19 -0400)]
Merge git://git.denx.de/u-boot-dm

7 years agoARM: rmobile: dts: Add SDR104/HS200 to Salvator-X
Marek Vasut [Fri, 6 Oct 2017 12:08:00 +0000 (14:08 +0200)]
ARM: rmobile: dts: Add SDR104/HS200 to Salvator-X

Add DT nodes to enable SDR104/HS200 modes on Salvator-X boards.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
7 years agoARM: rmobile: Fixup ULCB CPLD support after PFC rework
Marek Vasut [Wed, 4 Oct 2017 01:03:50 +0000 (03:03 +0200)]
ARM: rmobile: Fixup ULCB CPLD support after PFC rework

The ULCB CPLD support was not updated during the PFC table rework,
fix up the GPIO numbers until the CPLD support is rewritten to a
proper DM capable and DT probing driver.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
7 years agoMerge git://git.denx.de/u-boot-video
Tom Rini [Mon, 9 Oct 2017 17:31:33 +0000 (13:31 -0400)]
Merge git://git.denx.de/u-boot-video

7 years agosandbox: avoid memory leak in os_dirent_ls
Heinrich Schuchardt [Thu, 21 Sep 2017 10:56:07 +0000 (12:56 +0200)]
sandbox: avoid memory leak in os_dirent_ls

Realloc does not free the old memory area if it fails.

Identified by cppcheck.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: ofnode: query correct property in livetree ofnode_get_addr_size
Klaus Goger [Wed, 20 Sep 2017 11:50:41 +0000 (13:50 +0200)]
dm: ofnode: query correct property in livetree ofnode_get_addr_size

The livetree codepath of ofnode_get_addr_size always used the "reg"
property for of_get_property. Use the property parameter of the function
call instead and check the return value if the property exists.
Otherwise return FDT_ADDR_T_NONE.

This was discoverd while using SPI NOR with livetree.
spi_flash_decode_fdt checks for memory-map and will not fail with
livetree even if the property does not exist.

Signed-off-by: Klaus Goger <klaus.goger@theobroma-systems.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Round up size when allocating so that it is cache line aligned
Faiz Abbas [Tue, 19 Sep 2017 11:23:50 +0000 (16:53 +0530)]
dm: core: Round up size when allocating so that it is cache line aligned

The size variable may not be always be a mulitple of
ARCH_DMA_MINALIGN and using it to flush cache leads to cache
misaligned warnings.

Therefore, round up the size to a multiple of ARCH_DMA_MINLAIGN
when allocating private data.

Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: gpio: pca953x: Drop pointless data structure checks
Simon Glass [Sun, 17 Sep 2017 22:54:54 +0000 (16:54 -0600)]
dm: gpio: pca953x: Drop pointless data structure checks

These checks cannot fail since driver model will not call a driver's
method if it cannot fully create the driver data structures.

It is confusing to have these checks and others might copy them. Drop this
code.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: gpio: Correct use of -ENODEV in drivers
Simon Glass [Sun, 17 Sep 2017 22:54:53 +0000 (16:54 -0600)]
dm: gpio: Correct use of -ENODEV in drivers

In U-Boot -ENODEV means that there is no device. When there is a problem
with the device, drivers should return an error like -ENXIO or -EREMOTEIO.
When the device tree properties cannot be read correct , they should
return -EINVAL.

Update various GPIO drivers to follow this rule, to help with consistency
for future driver writers.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Adam Ford <aford173@gmail.com>
7 years agodm: gpio: Add a comment about not copying some drivers
Simon Glass [Sun, 17 Sep 2017 22:54:52 +0000 (16:54 -0600)]
dm: gpio: Add a comment about not copying some drivers

These three drivers all use U_BOOT_DEVICE rather than device tree to
create devices, so have to do manual allocation of platform data. This is
not true for new platforms.

Add a more explicit comment so that people do not copy this approach with
new boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Adam Ford <aford173@gmail.com>
7 years agodm: gpio: vybrid_gpio: Correct driver's use of bind() method
Simon Glass [Sun, 17 Sep 2017 22:54:51 +0000 (16:54 -0600)]
dm: gpio: vybrid_gpio: Correct driver's use of bind() method

It does not look like this driver needs to use a bind() method. It does
not manually create devices with device_bind() nor does it create devices
using U_BOOT_DEVICE(). It seems to only use device tree.

Therefore the manual allocation of platform data is not needed and is
confusing. Also platform data should be set up by the ofdata_to_platdata()
method, not bind().

Update the driver in case others use it as a model in future.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Adam Ford <aford173@gmail.com>
7 years agotest: print_ut: Add test for %ls strings
Rob Clark [Wed, 13 Sep 2017 22:46:54 +0000 (18:46 -0400)]
test: print_ut: Add test for %ls strings

Add a simple test for long strings.

Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoconfigs: stm32h743-eval: enable filesystem related flags
Patrice Chotard [Tue, 3 Oct 2017 13:55:02 +0000 (15:55 +0200)]
configs: stm32h743-eval: enable filesystem related flags

Enable CMD_GPT/EXT2/EXT4/EXT4_WRITE/FAT_FS_GENERIC flags

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agoconfigs: stm32h743-disco: enable filesystem related flags
Patrice Chotard [Tue, 3 Oct 2017 13:55:01 +0000 (15:55 +0200)]
configs: stm32h743-disco: enable filesystem related flags

Enable CMD_GPT/EXT2/EXT4/EXT4_WRITE/FAT_FS_GENERIC flags

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agoconfigs: stm32h743-disco: enable SDMMC support
Patrice Chotard [Tue, 3 Oct 2017 13:55:00 +0000 (15:55 +0200)]
configs: stm32h743-disco: enable SDMMC support

Enable CMD_MMC, DM_MMC and STM32_SDMMC2 flags

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agoconfigs: stm32h743-eval: enable SDMMC support
Patrice Chotard [Tue, 3 Oct 2017 13:54:59 +0000 (15:54 +0200)]
configs: stm32h743-eval: enable SDMMC support

Enable CMD_MMC, DM_MMC and STM32_SDMMC2 flags

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agodm: mmc: remove DM_MMC_OPS for STM32_SDMMC
Patrice Chotard [Tue, 3 Oct 2017 13:54:58 +0000 (15:54 +0200)]
dm: mmc: remove DM_MMC_OPS for STM32_SDMMC

Since e7881d85 "dm: mmc: Drop CONFIG_DM_MMC_OPS" DM_MMC_OPS
is no more used, remove it from STM32_SDMMC2 dependencies

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agoARM: DTS: stm32: add SDMMC support fo stm32h743-eval
Patrice Chotard [Tue, 3 Oct 2017 13:54:57 +0000 (15:54 +0200)]
ARM: DTS: stm32: add SDMMC support fo stm32h743-eval

Add pinctrl and sdmmc nodes to add MMC support for
STM32H743 evaluation board.

Evaluation board needs a second pinctrl node
"pinctrl_sdmmc1_level_shifter" to drive a level shifter
on MMC bus.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agoARM: DTS: stm32: add SDMMC support for stm32h743 disco
Patrice Chotard [Tue, 3 Oct 2017 13:54:56 +0000 (15:54 +0200)]
ARM: DTS: stm32: add SDMMC support for stm32h743 disco

Add pinctrl and sdmmc nodes to add MMC support for
STM32H743 discovery board.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agoconfigs: stm32: update SRAM address for STM32H7 disco and eval
Patrice Chotard [Tue, 3 Oct 2017 13:47:59 +0000 (15:47 +0200)]
configs: stm32: update SRAM address for STM32H7 disco and eval

As suggested by Vikas Manocha, update embedded SRAM address
to use AXI SRAM available on D1 domain instead of using
AHB SRAM (D2 domain).
On some STM32H743 SoCs, D2 domain SRAM is accessible even if
SRAMxEN bit in AHB2ENR bits are not set whereas on others SoCs
version it's not accessible.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Vikas Manocha <vikas.manocha@st.com>
7 years agoARM: stm32f7: fix prescaler calculation of timer
Bo Shen [Tue, 3 Oct 2017 05:47:59 +0000 (22:47 -0700)]
ARM: stm32f7: fix prescaler calculation of timer

As the timer 2 is on APB1 bus, the maximum of clock frequency of APB1 timer
clock is half of SYSCLK. Then to calculate the timer prescaler for timer 2
which need to be divided by 2.

Signed-off-by: Bo Shen <voice.shen@gmail.com>
Reviewed-by: Vikas Manocha <vikas.manocha@st.com>
7 years agofs/fat: Check malloc return values and fix memory leaks
Tuomas Tynkkynen [Sat, 30 Sep 2017 23:25:22 +0000 (02:25 +0300)]
fs/fat: Check malloc return values and fix memory leaks

Check malloc() return values and properly unwind on errors so
memory allocated for fat_itr structures get freed properly.

Also fixes a leak of fsdata.fatbuf in fat_size().

Fixes: 2460098cffacd1 ("fs/fat: Reduce stack usage")
Reported-by: Coverity (CID: 167225, 167233, 167234)
Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Reviewed-by: Tom Rini <trini@konsulko.com>
7 years agofs/fat: Fix 'CACHE: Misaligned operation at range' warnings
Tuomas Tynkkynen [Sat, 30 Sep 2017 23:25:21 +0000 (02:25 +0300)]
fs/fat: Fix 'CACHE: Misaligned operation at range' warnings

The 'block' field of fat_itr needs to be properly aligned for DMA and
while it does have '__aligned(ARCH_DMA_MINALIGN)', the fat_itr structure
itself needs to be properly aligned as well.

While at it use malloc_cache_aligned() for the other aligned allocations
in the file as well.

Fixes: 2460098cffacd1 ("fs/fat: Reduce stack usage")
Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Reviewed-by: Tom Rini <trini@konsulko.com>
7 years agocmd: Make CMD_LZMA / CMD_UNZIP default y if CMD_BOOTI
Tom Rini [Fri, 29 Sep 2017 18:32:44 +0000 (14:32 -0400)]
cmd: Make CMD_LZMA / CMD_UNZIP default y if CMD_BOOTI

In the Linux Kernel on ARM64, the Image.COMPRESSION file is not
self-extracting in the way that x86 and ARM images are.  So when
CMD_BOOTI is enabled we should also default to enabling CMD_UNZIP and
CONFIG_LZMA in order for the user to be able to decompress many of the
common compressions that will be done to an Image file.

Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agoscripts: Move Kconfig contents to cmd/Kconfig
Sam Protsenko [Thu, 28 Sep 2017 19:33:45 +0000 (12:33 -0700)]
scripts: Move Kconfig contents to cmd/Kconfig

On case-insensitive file systems we have collision between
scripts/kconfig/ directory and scripts/Kconfig file. This patch moves
scripts/Kcofnig contents to cmd/Kconfig to fix that.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
7 years agoserial: stm32x7: remove useless CONFIG_CLK and OF_CONTROL flag
Patrice Chotard [Wed, 27 Sep 2017 13:44:53 +0000 (15:44 +0200)]
serial: stm32x7: remove useless CONFIG_CLK and OF_CONTROL flag

This driver is currently used by STM32F7 and STM32H7 SoCs.
As CONFIG_CLK and OF_CONTROL flags are set by default for these
2 SoCs, this flag becomes useless in this driver, so remove it.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agoserial: stm32x7: add STM32F4 support
Patrice Chotard [Wed, 27 Sep 2017 13:44:52 +0000 (15:44 +0200)]
serial: stm32x7: add STM32F4 support

stm32f4 doesn't support FIFO and OVERRUN feature.
The enable bit is not at the same location in CR1
register than for STM32F7 and STM32H7.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agoserial: stm32x7: add fifo support for STM32H7
Patrice Chotard [Wed, 27 Sep 2017 13:44:51 +0000 (15:44 +0200)]
serial: stm32x7: add fifo support for STM32H7

Add fifo mode support for rx and tx.
As only STM32H7 supports this feature, add has_fifo flag
to uart configuration to use fifo only when possible.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agoserial: stm32x7: prepare the ground to STM32F4 support
Patrice Chotard [Wed, 27 Sep 2017 13:44:50 +0000 (15:44 +0200)]
serial: stm32x7: prepare the ground to STM32F4 support

STM32F4 serial IP is similar to F7 and H7, but registers
are not located at the same offset and some feature are
only supported by F7 and H7 version.

Registers offset must be added for each version and also
some flags indicated the supported feature.

Update registers name to match with datasheet (sr to isr,
rx_dr to rdr and tx_dr to tdr) and remove unused regs
(cr2, gtpr, rtor, and rqr).

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
7 years agoserial: stm32x7: remove stm32f7-usart and stm32h7-usart compatible
Patrice Chotard [Wed, 27 Sep 2017 13:44:49 +0000 (15:44 +0200)]
serial: stm32x7: remove stm32f7-usart and stm32h7-usart compatible

This patch remove the extra compatibility string "st,stm32h7-usart"
and "st,stm32f7-usart" to avoid confusion, save some time & space.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Vikas Manocha <vikas.manocha@st.com>
7 years agoserial: stm32x7: cleanup code
Patrice Chotard [Wed, 27 Sep 2017 13:44:48 +0000 (15:44 +0200)]
serial: stm32x7: cleanup code

Use BIT() macro and GENMASK() macro

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Vikas Manocha <vikas.manocha@st.com>
7 years agoARMv8: make master CPU checking logic more clear
zijun_hu [Mon, 25 Sep 2017 07:28:50 +0000 (15:28 +0800)]
ARMv8: make master CPU checking logic more clear

macro branch_if_master checks master CPU via (Aff3 & (Aff2:Aff1:Aff0))
it is simple but a little obscure.

fix by checking Affx fields within MPIDR_EL1 directly.

Signed-off-by: zijun_hu <zijun_hu@htc.com>
7 years agoboard: STiH410-B2260: set ramdisk_addr_r to 0x48000000
Lee Jones [Mon, 25 Sep 2017 07:14:20 +0000 (09:14 +0200)]
board: STiH410-B2260: set ramdisk_addr_r to 0x48000000

Add missing ramdisk_addr_r param and set it to 0x48000000

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoboard: STiH410-B2260: fix sdram size
Nicolas Le Bayon [Mon, 25 Sep 2017 07:14:19 +0000 (09:14 +0200)]
board: STiH410-B2260: fix sdram size

32MB are reserved for TrustZone purpose

Signed-off-by: Nicolas Le Bayon <nicolas.le.bayon@st.com>
7 years agoboard: STiH410-B2260: update environment variable
Patrice Chotard [Mon, 25 Sep 2017 07:14:18 +0000 (09:14 +0200)]
board: STiH410-B2260: update environment variable

Update environment variable by updating:
 _ BOOT_TARGET_DEVICE
 _ CONFIGS_BOOTARGS
 _ kernel_addr_r, fdtfile, fdt_addr_r, scriptaddr, fdt_high, intird_high

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoARMv8: fix error in freeing stack frame
zijun_hu [Sat, 23 Sep 2017 05:30:58 +0000 (13:30 +0800)]
ARMv8: fix error in freeing stack frame

relocate_code() allocates 32 bytes stack frame but only 16 bytes are
freed before return. it will cause errors to possible previous frames
and doesn't make relocate_code() look like a function.

fix by freeing 32 bytes stack space

Signed-off-by: zijun_hu <zijun_hu@htc.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoARMv8: get new GD address from gd->new_gd directly
zijun_hu [Fri, 22 Sep 2017 06:39:13 +0000 (14:39 +0800)]
ARMv8: get new GD address from gd->new_gd directly

the new GD address is calculated via board data BD currently
it require the new GD area locates below BD tightly, so a strict
constraint is imposed on memory layout which maybe make special
platform unpleasant.

fix it by getting new GD address from gd->new_gd directly.

Signed-off-by: zijun_hu <zijun_hu@htc.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoTravis-CI: Fix microblaze and xilinx jobs
Tom Rini [Sat, 7 Oct 2017 19:54:18 +0000 (15:54 -0400)]
Travis-CI: Fix microblaze and xilinx jobs

Given how we handle the ARM toolchain we can't easily combine these two
jobs, so don't.  Give xilinx/ARM a separate build.

Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agocmd/gpt.c, cmd/nvedit.c, tools/fit_image.c: Rework recent fixes for Coverity
Tom Rini [Sat, 7 Oct 2017 15:27:59 +0000 (11:27 -0400)]
cmd/gpt.c, cmd/nvedit.c, tools/fit_image.c: Rework recent fixes for Coverity

The recent changes to these files did not completely fix the previous
issues, or introduced different (minor) issues.  In cmd/gpt.c we need to
dereference str_disk_guid to be sure that malloc worked.  In
cmd/nvedit.c we need to be careful that we can also fit in that leading
space when adding to the string.  And in tools/fit_image.c we need to
re-work the error handling slightly in fit_import_data() so that we only
call munmap() once.  We have two error paths here, one where we have an
fd to close and one where we do not.  Adjust labels to match this.

Reported-by: Coverity (CID: 167366, 167367, 167370)
Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agoMerge git://git.denx.de/u-boot-x86
Tom Rini [Sat, 7 Oct 2017 13:12:04 +0000 (09:12 -0400)]
Merge git://git.denx.de/u-boot-x86

7 years agox86: edison: Bring minimal ACPI support to the board
Andy Shevchenko [Tue, 3 Oct 2017 11:55:08 +0000 (14:55 +0300)]
x86: edison: Bring minimal ACPI support to the board

This board is based on Intel Tangier SoC (Intel Merrifield platform)
and may utilize ACPI powerfulness.

Bring minimum support by appending initial DSDT table for it.

Note, the addresses for generated tables are carefully chosen to avoid
any conflicts with existing shadowed BIOS data. The user have somewhat
like ~31 kB available for compiled ACPI tables that ought to be enough.

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
7 years agox86: tangier: Enable ACPI support for Intel Tangier
Andy Shevchenko [Tue, 3 Oct 2017 11:55:07 +0000 (14:55 +0300)]
x86: tangier: Enable ACPI support for Intel Tangier

Intel Tangier SoC is a part of Intel Merrifield platform which doesn't
utilize ACPI by default. Here is an attempt to unleash ACPI flexibility
power on Intel Merrifield based platforms.

The change brings minimum support of the devices that found on
Intel Merrifield based end user device.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: theadorable-x86-xxx_defconfig: Enable setexpr command
Stefan Roese [Fri, 6 Oct 2017 07:12:28 +0000 (09:12 +0200)]
x86: theadorable-x86-xxx_defconfig: Enable setexpr command

The setexpr command is useful for scripting, lets enable it for all
x86 based theadorable platforms.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: theadorable-x86-common: Move "-generic" into kernel-ver variable
Stefan Roese [Fri, 6 Oct 2017 07:12:27 +0000 (09:12 +0200)]
x86: theadorable-x86-common: Move "-generic" into kernel-ver variable

This enables the easier usage of "-custom" kernel versions as well.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agox86: theadorable-x86-common: Add further pci hotplug cmdline parameters
Stefan Roese [Fri, 6 Oct 2017 07:12:26 +0000 (09:12 +0200)]
x86: theadorable-x86-common: Add further pci hotplug cmdline parameters

This is needed for the PCIe hotplug to work correctly on some boards.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
7 years agoTravis-CI: Split out more vendors from the catch-all ARM job
Tom Rini [Fri, 6 Oct 2017 20:37:06 +0000 (16:37 -0400)]
Travis-CI: Split out more vendors from the catch-all ARM job

- Move SoCFPGA and K2 boards to their own job
- Expand the microblaze job to cover ARM boards from Xilinx as well.

Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agoTravis-CI: Move Boundary and Engicam devices to their own jobs
Tom Rini [Fri, 6 Oct 2017 20:27:42 +0000 (16:27 -0400)]
Travis-CI: Move Boundary and Engicam devices to their own jobs

The i.MX6 job can still be close to the time limit, move a few more
devices out.

Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agoTravis-CI: Move Toradex into its own job
Tom Rini [Fri, 6 Oct 2017 15:19:12 +0000 (11:19 -0400)]
Travis-CI: Move Toradex into its own job

A few of the big jobs are getting close to the time limit again, split a
few more things out.

Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agofs/ext4/ext4fs.c: Free dirnode in error path of ext4fs_ls
Tom Rini [Wed, 27 Sep 2017 02:43:45 +0000 (22:43 -0400)]
fs/ext4/ext4fs.c: Free dirnode in error path of ext4fs_ls

As reported by Coverity, we did not free dirnode in the case of failure.
Do so now.

Reported-by: Coverity (CID: 131221)
Cc: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agotools/fit_image.c: Update some return code paths
Tom Rini [Wed, 27 Sep 2017 02:14:44 +0000 (22:14 -0400)]
tools/fit_image.c: Update some return code paths

Coverity has found some problems with the return paths in parts of this
code.  We have a case where we were going to the wrong part of the
unwind (open() failed so we cannot close the fd), a case where we were
only free()ing our buf on the error path and finally a case where we did
not munmap in the failure path.

Reported-by: Coverity (CID: 138492, 138495, 143064)
Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agocmd/time.c: Initialize 'repeatable' variable
Tom Rini [Wed, 27 Sep 2017 01:12:05 +0000 (21:12 -0400)]
cmd/time.c: Initialize 'repeatable' variable

We cannot leave this uninitialized, set it to 0.

Reported-by: Coverity (CID: 144426)
Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agocmd/pxe.c: Rework initrd and bootargs handling slightly
Tom Rini [Wed, 27 Sep 2017 00:44:32 +0000 (20:44 -0400)]
cmd/pxe.c: Rework initrd and bootargs handling slightly

For the initrd portion of handling our bootm arguments we do not have a
sufficiently long enough buffer for some improbable 64bit cases.  Expand
this buffer to allow for a 64bit address and almost 256MB initrd to be
used.  Make use of strncpy/strncat when constructing the values here
since we know what the worst case valid values are, length wise.

Similarly for bootargs themselves, we need to make use of strlen/sizeof
and strncpy/strncat to ensure that we don't overflow bootargs itself.

Cc: Simon Glass <sjg@chromium.org>
Cc: Alexander Graf <agraf@suse.de>
Reported-by: Coverity (CID: 131256)
Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agocmd/nvedit.c: Update input handling to cover overflow cases
Tom Rini [Tue, 26 Sep 2017 23:37:11 +0000 (19:37 -0400)]
cmd/nvedit.c: Update input handling to cover overflow cases

When we have multiple messages provided, we need to be sure that we do
not exceed the length of our 'message' buffer.  In the for loop, make
sure that pos is not larger than message.  Only copy in at most however
much of the message buffer remains.  Finally, if we have not reached the
end of the message buffer, put in a space and NULL, and if we have,
ensure the buffer is now NULL termined.

Reported-by: Coverity (CID: 165116)
Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agotest/dm: Fix string handling issues in the eth test
Tom Rini [Tue, 26 Sep 2017 18:08:30 +0000 (14:08 -0400)]
test/dm: Fix string handling issues in the eth test

Coverity scan has identified potential buffer overruns in these tests.
Correct this by zeroing our buffer and using strncpy not strcpy.

Reported-by: Coverity (CID: 155462, 155463)
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
7 years agotest/overlay: Fix various malloc/free leaks
Tom Rini [Tue, 26 Sep 2017 16:43:12 +0000 (12:43 -0400)]
test/overlay: Fix various malloc/free leaks

With the overlay tests now being built in sandbox Coverity has found a
number of issues in the tests.  In short, if malloc ever failed we would
leak the previous mallocs, so we need to do the usual goto pattern to
free each in turn.  Finally, we always looked at the free()d location to
see how many tests had failed for the return code.

Reported-by: Coverity (CID: 167224, 167227, 167230, 167236)
Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agoGPT: fix memory leaks identified by Coverity
Alison Chaiken [Tue, 26 Sep 2017 14:42:28 +0000 (07:42 -0700)]
GPT: fix memory leaks identified by Coverity

Create a common exit for most of the error handling code in
do_rename_gpt_parts.   Delete the list elements in disk_partitions
before calling INIT_LIST_HEAD from get_gpt_info() a second time.

The SIZEOF_MISMATCH error is not addressed, since that problem was
already fixed by "GPT: incomplete initialization in
allocate_disk_part".

Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
Reported-by: Coverity (CID: 167222, 167235, 167237)
Reviewed-by: Tom Rini <trini@konsulko.com>
7 years agofs-test: Add test for a filename using '..' to go back to the root
Tuomas Tynkkynen [Mon, 25 Sep 2017 19:06:34 +0000 (22:06 +0300)]
fs-test: Add test for a filename using '..' to go back to the root

The previous commit fixed a problem in FAT code where going back to the
root directory using '..' wouldn't work correctly on FAT12 or FAT16.
Add a test to exercise this case (which was once fixed in commit
18a10d46f26 "fat: handle paths that include ../" but reintroduced due to
the directory iterator refactoring).

This test only very barely catches the problem - without the fix the
size command still gives valid output but the additional spurious
"Invalid FAT entry" error message makes it not get caught in the
'egrep -A3 ' output. I tried to make a proper test that grows the root
directory to two clusters lots of with dummy files but that causes the
write tests to crash the sandbox totally...

Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Reviewed-by: Tom Rini <trini@konsulko.com>
7 years agofs/fat: Fix pathnames using '..' that lead to the root directory
Tuomas Tynkkynen [Mon, 25 Sep 2017 19:06:33 +0000 (22:06 +0300)]
fs/fat: Fix pathnames using '..' that lead to the root directory

If we end up back in the root directory via a '..' directory entry, set
itr->is_root accordingly. Failing to do that gives spews like
"Invalid FAT entry" and being unable to access directory entries located
past the first cluster of the root directory.

Fixes: 8eafae209c35 ("fat/fs: convert to directory iterators")
Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
7 years agofs-test: Add FAT16 support
Tuomas Tynkkynen [Mon, 25 Sep 2017 19:06:32 +0000 (22:06 +0300)]
fs-test: Add FAT16 support

Currently we can only test FAT32 which is the default FAT version that
mkfs.vfat creates by default. Instead make it explicitly create either a
FAT16 or a FAT32 volume. This allows us to exercise more code, for
instance the root directory handling is done differently in FAT32 than
the older FATs.

Adding FAT12 support is a much bigger job since the test creates a 2.5GB
file and the FAT12 maximum partition size is way smaller than that.

Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Reviewed-by: Tom Rini <trini@konsulko.com>
7 years agofs/ext4: Fix group descriptor checksum calculation
Tuomas Tynkkynen [Mon, 25 Sep 2017 19:06:31 +0000 (22:06 +0300)]
fs/ext4: Fix group descriptor checksum calculation

The current code doesn't compute the group descriptor checksum correctly
for the filesystems that e2fsprogs 1.43.4 creates (they have
'Group descriptor size: 64' as reported by tune2fs). Extend the checksum
calculation to be done as ext4_group_desc_csum() does in Linux.

This fixes these errors in dmesg from running fs-test.sh and makes it
succeed again:

[1671902.620699] EXT4-fs (loop1): ext4_check_descriptors: Checksum for group 0 failed (35782!=10965)
[1671902.620706] EXT4-fs (loop1): group descriptors corrupted!

Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>