U-Boot
Threads by month
- ----- 2025 -----
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2000 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
January 2016
- 195 participants
- 740 discussions

[U-Boot] [PATCH v2] MIPS: initialize board_init_f() argument to zero.
by Purna Chandra Mandal 21 Jan '16
by Purna Chandra Mandal 21 Jan '16
21 Jan '16
Argument boot_flags of board_init_f() should be set to 0 as
$a0 may be utilized in lowlevel_init() or mips_cache_reset()
or previous stage boot-loader.
Signed-off-by: Purna Chandra Mandal <purna.mandal(a)microchip.com>
---
Changes in v2:
- add comment in same line as of the asm instruction
- add commit message
arch/mips/cpu/start.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/mips/cpu/start.S b/arch/mips/cpu/start.S
index e95cdca..2aa2dcb 100644
--- a/arch/mips/cpu/start.S
+++ b/arch/mips/cpu/start.S
@@ -185,7 +185,7 @@ reset:
PTR_ADDU t0, k0, GD_MALLOC_BASE # gd->malloc_base offset
sw sp, 0(t0)
#endif
-
+ move a0, zero # a0 <-- boot_flags = 0
PTR_LA t9, board_init_f
jr t9
move ra, zero
--
1.8.3.1
2
1

[U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support
by Simon Glass 21 Jan '16
by Simon Glass 21 Jan '16
21 Jan '16
This series starts the process of converting LCD and video devices over to
use driver model. Both now use a very similar API thanks to earlier work by
Nikita Kiryanov. With the driver-model conversion these will end up unified
in a single uclass.
Unfortunately there are different features supported by each. This
implementation provides for a common set of features which should serve
most purposes. The intent is to support:
- bitmap devices with 8, 16 and 32 bits per pixel
- text console wih white on black or vice versa
- rotated text console
- bitmap display (BMP format)
More can be added as additional boards are ported over to use driver model
for video.
The name 'video' is chosen for the uclass since it is more generic than LCD.
Another option would be 'display' but that would introduce a third concept
to U-Boot which seems like the wrong approach.
The existing LCD and video init functions are not needed now, so this uclass
does not implement them. This includes lcd_ctrl_init(), lcd_enable() and
video_init().
Tests are provided to check that console text and bitmap output is correct.
These should be able to be extended as more features are added.
Future work will convert a few boards over to use driver model for video.
Likely targets are x86, exynos, tegra. Also, Rockchip LCD support will be
added using driver model (patches will likely be sent some time in January).
Changes in v2:
- Fix Ebabling typo in comment
- Remove duplicated @fb_size line in common
- Fix comment for video_get_ysize()
- Fix reference to \n which should be \b
- Fix 'withthe' typo in comment
- Fix 'resolutino' typo in comment
Simon Glass (14):
dm: video: Add a video uclass
dm: lcd: Avoid using the lcd.h header file with driver model
dm: video: Add a uclass for the text console
dm: video: Add a 'normal' text console driver
dm: video: Add a driver for a rotated text console
common: Move LCD and video memory reservation together
dm: common: Add memory reservation for the video uclass
dm: video: Implement the bmp command for driver model
dm: stdio: video: Plumb the video uclass into stdio
sandbox: Move CONFIG_VIDEO_SANDBOX_SDL to Kconfig
dm: video: sandbox: Convert sandbox to use driver model for video
dm: video: test: Add tests for the video uclass
dm: video: test: Add tests for rotated consoles
dm: video: test: Test that bitmap display works correctly
arch/sandbox/dts/sandbox.dts | 1 +
arch/sandbox/dts/test.dts | 7 +
board/sandbox/sandbox.c | 17 --
common/Makefile | 2 +
common/board_f.c | 71 ++++---
common/cmd_bmp.c | 22 +-
common/lcd.c | 11 -
common/stdio.c | 19 +-
configs/sandbox_defconfig | 5 +-
drivers/serial/sandbox.c | 5 +-
drivers/video/Kconfig | 62 ++++++
drivers/video/Makefile | 3 +
drivers/video/console_normal.c | 141 ++++++++++++
drivers/video/console_rotate.c | 436 ++++++++++++++++++++++++++++++++++++++
drivers/video/sandbox_sdl.c | 90 ++++----
drivers/video/vidconsole-uclass.c | 239 +++++++++++++++++++++
drivers/video/video-uclass.c | 249 ++++++++++++++++++++++
drivers/video/video_bmp.c | 353 ++++++++++++++++++++++++++++++
include/asm-generic/global_data.h | 4 +
include/configs/sandbox.h | 13 +-
include/dm/test.h | 8 +
include/dm/uclass-id.h | 2 +
include/fdtdec.h | 1 -
include/lcd.h | 12 +-
include/video.h | 168 ++++++++++++++-
include/video_console.h | 136 ++++++++++++
lib/fdtdec.c | 1 -
test/dm/Makefile | 1 +
test/dm/video.c | 271 +++++++++++++++++++++++
tools/logos/denx-comp.bmp | Bin 0 -> 4148 bytes
30 files changed, 2221 insertions(+), 129 deletions(-)
create mode 100644 drivers/video/console_normal.c
create mode 100644 drivers/video/console_rotate.c
create mode 100644 drivers/video/vidconsole-uclass.c
create mode 100644 drivers/video/video-uclass.c
create mode 100644 drivers/video/video_bmp.c
create mode 100644 include/video_console.h
create mode 100644 test/dm/video.c
create mode 100644 tools/logos/denx-comp.bmp
--
2.6.0.rc2.230.g3dd15c0
2
31

[U-Boot] [PATCH v2 0/9] arm: ls1021atwr: Convert to driver model and enable serial support
by Bin Meng 21 Jan '16
by Bin Meng 21 Jan '16
21 Jan '16
This series converts Freescale LS1021A-TWR board to driver model.
- Enable ns16550 serial driver on ls1021atwr_nor configuration
- Convert LPUART serial driver to driver model
- Enable LPUART serial driver on ls1021atwr_nor_lpuart configuration
Changes in v2:
- Rewrite the commit message using 'git revert' format.
- Add missing 'base' parameter in the call to _lpuart_serial_tstc()
- Change internal routines' parameter 'reg' to 'base'
- Split to use two separate U_BOOT_DRIVER()
- New patch to split off board device tree
- Create a ls1021a-twr-lpuart.dts for ls1021atwr_nor_lpuart_defconfig
Bin Meng (9):
Revert "fdt_support: Add multi-serial support for stdout fixup"
arm: ls1021atwr: Convert to driver model and enable serial support
serial: lpuart: Move CONFIG_FSL_LPUART to Kconfig
serial: lpuart: Fix several cosmetic issues
serial: lpuart: Call local version of setbrg and putc directly
serial: lpuart: Prepare the driver for DM conversion
serial: lpuart: Add driver model serial support
arm: ls1021atwr: Split off board device tree
arm: ls1021atwr: Enable driver model lpuart serial driver
arch/arm/dts/Makefile | 2 +-
arch/arm/dts/ls1021a-twr-duart.dts | 16 ++
arch/arm/dts/ls1021a-twr-lpuart.dts | 16 ++
arch/arm/dts/{ls1021a-twr.dts => ls1021a-twr.dtsi} | 7 +-
arch/arm/dts/ls1021a.dtsi | 4 -
common/fdt_support.c | 16 +-
configs/colibri_vf_defconfig | 1 +
configs/colibri_vf_dtb_defconfig | 1 +
configs/ls1021aqds_ddr4_nor_lpuart_defconfig | 1 +
configs/ls1021aqds_nor_lpuart_defconfig | 1 +
configs/ls1021atwr_nor_defconfig | 4 +
configs/ls1021atwr_nor_lpuart_defconfig | 5 +
configs/ls1021atwr_qspi_defconfig | 2 +-
configs/ls1021atwr_sdcard_qspi_defconfig | 2 +-
configs/pcm052_defconfig | 1 +
configs/vf610twr_defconfig | 1 +
configs/vf610twr_nand_defconfig | 1 +
doc/driver-model/serial-howto.txt | 1 -
drivers/serial/Kconfig | 6 +
drivers/serial/serial_lpuart.c | 286 ++++++++++++++++++---
include/configs/colibri_vf.h | 1 -
include/configs/ls1021aqds.h | 1 -
include/configs/ls1021atwr.h | 3 +-
include/configs/pcm052.h | 1 -
include/configs/vf610twr.h | 1 -
25 files changed, 311 insertions(+), 70 deletions(-)
create mode 100644 arch/arm/dts/ls1021a-twr-duart.dts
create mode 100644 arch/arm/dts/ls1021a-twr-lpuart.dts
rename arch/arm/dts/{ls1021a-twr.dts => ls1021a-twr.dtsi} (93%)
--
1.8.2.1
5
30

21 Jan '16
This patch series adds support for Microchip PIC32MZ[DA] MIPS microcontroller platform.
All drivers required to boot from MMC uSD card and network are included in it; clock,
pinctrl, gpio, DDR2, serial, SDHCI, ethernet.
This series is tested on PIC32MZ[DA] Starter Kit.
This series is generated on mips_io_v1 branch of u-boot-mips tree.
A tree with these changes are available at [2].
[2] https://github.com/purna-mandal/u-boot/tree/pic32-upstream-v3
[1] https://github.com/purna-mandal/u-boot/tree/pic32-upstream-v2
[0] https://github.com/purna-mandal/u-boot/tree/pic32-upstream-v1
Changes in v3:
- drop empty choices in mach-pic32/Kconfig
- add pic32_get_syscfg_base() for device-config regs base
- rename clk-pic32.c to clk_pic32.c
- update clock binding documentation
- replace pic32_ioremap() with ioremap()
- read register base from device-tree
- add/update comments to explain how pinctrl'r works.
- remove ofdata_to_platdata, and replace platdata with priv
- serial:remove special handling of '\r' as being handled by serial-uclass
- serial:remove loop to wait for space in tx buffer before pumping char
- pinctrl: annotating fixed table with const
- ddr: fix camel-case in ddr2 timing parameters
- ddr: fix cmd index parameter of host_load_cmd().
- drop forcing CONFIG_MIPS_BOOT_* selection in mach-pic32/Kconfig
- indent assembly instructions in delay slot
- made GPIO-nodes child of pinctrl-node in devicetree
- drop SKIP_LOWLEVEL_INIT, GBL_DATA_OFFSET from config header
- move CMD_MEMTEST, CMD_MEMINFO to defconfig
- increase SYS_MALLOC_F_LEN to 0x600
- use auto-generated defconfig - no hand edit
- net: merge internal wrappers functions with eth operation callbacks
- net: read ethernet-phy address from device-tree
- net: rename ethernet callback functions
Changes in v2:
- move PIC32 specific headers to arch/mips/mach-pic32/include/mach/
- define register-base as physical address
- drop CONFIG_PIC32_SUPPORTS_FDT_BOOT
- add mpll get clock rate
- add pinconf routine for configuring pin property
- fix missing/corrupted chars during baud rate change
- remove loop until any char is avaialbale in getc()
- move ddr2 initialization from board/microchip/ to drivers/ddr/microchip
- drop board_early_init_f
- use macro LEAF(), END() for lowlevel_init
- move initialization of board_init_f() argument to common start.S
- move initdram() from board/microchip/ to mach-pic32/cpu.c
- remove MIPS virtual address in favor physical one in dts file
- move CONFIG_SYS_TEXT_BASE (from board/*/config.mk) to include/configs/<board>.h
- drop sdhci shared bus configuration (for shared interrupt, clock pins)
- drop shared bus (shared pin selection) configuration.
- replace unbounded loop with wait_for_bit()
- replace register access as readl/writel(base + offset)
- translate (dts provided) physical address to MIPS kseg1 address before use
Andrei Pistirica (1):
drivers: mmc: add driver for Microchip PIC32 SDHCI controller.
Paul Thacker (1):
drivers: serial: add driver for Microchip PIC32 UART controller.
Purna Chandra Mandal (12):
MIPS: initialize board_init_f() argument to zero.
MIPS: initial infrastructure for Microchip PIC32 architecture
drivers: clk: Add clock driver for Microchip PIC32 Microcontroller.
drivers: pinctrl: Add pinctrl driver for Microchip PIC32.
drivers: gpio: add driver for Microchip PIC32 GPIO controller.
drivers: ddr: Add DDR2 SDRAM controller driver for Microchip PIC32.
MIPS: Add support for Microchip PIC32MZ[DA] SoC family.
board: Add Microchip PIC32MZ[DA]-Starter-Kit board.
board: add SDHCI support for PIC32MZDASK board.
drivers: net: phy: add SMSC LAN8740 Phy support.
drivers: net: Add ethernet driver for Microchip PIC32.
board: Enable ethernet, tftpboot support to pic32mzdask board.
arch/mips/Kconfig | 6 +
arch/mips/Makefile | 1 +
arch/mips/cpu/start.S | 2 +
arch/mips/dts/Makefile | 2 +-
arch/mips/dts/pic32mzda.dtsi | 174 ++++++
arch/mips/dts/pic32mzda_sk.dts | 55 ++
arch/mips/mach-pic32/Kconfig | 38 ++
arch/mips/mach-pic32/Makefile | 7 +
arch/mips/mach-pic32/cpu.c | 160 ++++++
arch/mips/mach-pic32/include/mach/ddr.h | 32 ++
arch/mips/mach-pic32/include/mach/pic32.h | 79 +++
arch/mips/mach-pic32/lowlevel_init.S | 27 +
arch/mips/mach-pic32/reset.c | 36 ++
board/microchip/pic32mzda/Kconfig | 13 +
board/microchip/pic32mzda/MAINTAINERS | 6 +
board/microchip/pic32mzda/Makefile | 7 +
board/microchip/pic32mzda/README | 22 +
board/microchip/pic32mzda/pic32mzda.c | 31 ++
configs/pic32mzdask_defconfig | 426 +++++++++++++++
.../clock/microchip,pic32-clock.txt | 33 ++
.../serial/microchip,pic32-uart.txt | 5 +
drivers/Makefile | 1 +
drivers/clk/Makefile | 1 +
drivers/clk/clk_pic32.c | 433 +++++++++++++++
drivers/ddr/microchip/Makefile | 6 +
drivers/ddr/microchip/ddr2.c | 278 ++++++++++
drivers/ddr/microchip/ddr2_regs.h | 148 +++++
drivers/ddr/microchip/ddr2_timing.h | 65 +++
drivers/gpio/Kconfig | 7 +
drivers/gpio/Makefile | 2 +-
drivers/gpio/pic32_gpio.c | 175 ++++++
drivers/mmc/Kconfig | 6 +
drivers/mmc/Makefile | 2 +-
drivers/mmc/pic32_sdhci.c | 61 +++
drivers/mmc/sdhci.c | 12 +
drivers/net/Kconfig | 7 +
drivers/net/Makefile | 1 +
drivers/net/phy/smsc.c | 10 +
drivers/net/pic32_eth.c | 606 +++++++++++++++++++++
drivers/net/pic32_eth.h | 171 ++++++
drivers/net/pic32_mdio.c | 121 ++++
drivers/pinctrl/Kconfig | 9 +
drivers/pinctrl/Makefile | 1 +
drivers/pinctrl/pinctrl_pic32.c | 363 ++++++++++++
drivers/serial/Kconfig | 13 +
drivers/serial/Makefile | 1 +
drivers/serial/serial_pic32.c | 199 +++++++
include/configs/pic32mzdask.h | 178 ++++++
include/dt-bindings/clock/microchip,clock.h | 29 +
49 files changed, 4065 insertions(+), 3 deletions(-)
create mode 100644 arch/mips/dts/pic32mzda.dtsi
create mode 100644 arch/mips/dts/pic32mzda_sk.dts
create mode 100644 arch/mips/mach-pic32/Kconfig
create mode 100644 arch/mips/mach-pic32/Makefile
create mode 100644 arch/mips/mach-pic32/cpu.c
create mode 100644 arch/mips/mach-pic32/include/mach/ddr.h
create mode 100644 arch/mips/mach-pic32/include/mach/pic32.h
create mode 100644 arch/mips/mach-pic32/lowlevel_init.S
create mode 100644 arch/mips/mach-pic32/reset.c
create mode 100644 board/microchip/pic32mzda/Kconfig
create mode 100644 board/microchip/pic32mzda/MAINTAINERS
create mode 100644 board/microchip/pic32mzda/Makefile
create mode 100644 board/microchip/pic32mzda/README
create mode 100644 board/microchip/pic32mzda/pic32mzda.c
create mode 100644 configs/pic32mzdask_defconfig
create mode 100644 doc/device-tree-bindings/clock/microchip,pic32-clock.txt
create mode 100644 doc/device-tree-bindings/serial/microchip,pic32-uart.txt
create mode 100644 drivers/clk/clk_pic32.c
create mode 100644 drivers/ddr/microchip/Makefile
create mode 100644 drivers/ddr/microchip/ddr2.c
create mode 100644 drivers/ddr/microchip/ddr2_regs.h
create mode 100644 drivers/ddr/microchip/ddr2_timing.h
create mode 100644 drivers/gpio/pic32_gpio.c
create mode 100644 drivers/mmc/pic32_sdhci.c
create mode 100644 drivers/net/pic32_eth.c
create mode 100644 drivers/net/pic32_eth.h
create mode 100644 drivers/net/pic32_mdio.c
create mode 100644 drivers/pinctrl/pinctrl_pic32.c
create mode 100644 drivers/serial/serial_pic32.c
create mode 100644 include/configs/pic32mzdask.h
create mode 100644 include/dt-bindings/clock/microchip,clock.h
--
1.8.3.1
4
61

21 Jan '16
This tool aims to test U-Boot by executing U-Boot shell commands using the
console interface. A single top-level script exists to execute or attach
to the U-Boot console, run the entire script of tests against it, and
summarize the results. Advantages of this approach are:
- Testing is performed in the same way a user or script would interact
with U-Boot; there can be no disconnect.
- There is no need to write or embed test-related code into U-Boot itself.
It is asserted that writing test-related code in Python is simpler and
more flexible that writing it all in C.
- It is reasonably simple to interact with U-Boot in this way.
A few simple tests are provided as examples. Soon, we should convert as
many as possible of the other tests in test/* and test/cmd_ut.c too.
The hook scripts, relay control utilities, and udev rules I use for my
own HW setup are published at https://github.com/swarren/uboot-test-hooks.
See README.md for more details!
Signed-off-by: Stephen Warren <swarren(a)wwwdotorg.org>
Signed-off-by: Stephen Warren <swarren(a)nvidia.com>
Tested-by: Michal Simek <michal.simek(a)xilinx.com>
Tested-by: Simon Glass <sjg(a)chromium.org>
Acked-by: Simon Glass <sjg(a)chromium.org> #v3
---
Apologies for the resend; I forgot to CC the list last time.
v4:
- Fix all users after ubspawn -> u_boot_spawn module rename.
- Don't escape ^ in the HTML log file.
- Fix u_boot_spawn.py Spawn.__init__ to set SIGHUP handler is set to
SIG_DFL. This ensures that sandbox responds to SIGHUP when run non-
interactively (e.g. under a daemon continuous integration server).
- Fix logging of all child processes to make sure that all stdout/err,
exit code, and exception data from all processes makes its way to both
test stdout (for pytest to log to its stdout in case of error) and the
HTML test log. This changed multiplexed_log.py RunAndLog.run() (a fair
bit of change) and u_boot_console_exec_attach.py ConseolExecAttach.*
(just passing sys.stdout to log.get_runner() everywhere).
- Also mention kermit as a possible app to attach to a serial console.
- Fix test_version to work correctly when BUILD_TAG is set, which causes
U-Boot to print both the version string and BUILD_TAG value at startup,
whereas the "version" shell command only prints the version string.
- Reformat function-level documentation.
v3:
- Rework HTML log generation so that TAB characters render as expected.
Suggested by Michal Simek.
- Move test scripts into a sub-directory.
Suggested by Michal Simek.
- s/uboot/u[-_]boot/g. Suggested by Simon Glass.
- s/"/'/g. Suggested by Simon Glass.
- Typo fixes.
- Add more documentation. Suggested by Simon Glass.
- Make "notes" in the log file be <pre> so that their formatting is
preserved. This is useful for large notes such as exception dumps.
v2:
- Many fixes and tweaks have been squashed in. Separated out some of
the tests into separate commits, and added some more tests.
---
test/py/.gitignore | 1 +
test/py/README.md | 300 ++++++++++++++++++++
test/py/conftest.py | 422 ++++++++++++++++++++++++++++
test/py/multiplexed_log.css | 88 ++++++
test/py/multiplexed_log.py | 515 ++++++++++++++++++++++++++++++++++
test/py/pytest.ini | 11 +
test/py/test.py | 32 +++
test/py/tests/test_000_version.py | 20 ++
test/py/tests/test_help.py | 9 +
test/py/tests/test_unknown_cmd.py | 14 +
test/py/u_boot_console_base.py | 360 ++++++++++++++++++++++++
test/py/u_boot_console_exec_attach.py | 65 +++++
test/py/u_boot_console_sandbox.py | 79 ++++++
test/py/u_boot_spawn.py | 174 ++++++++++++
14 files changed, 2090 insertions(+)
create mode 100644 test/py/.gitignore
create mode 100644 test/py/README.md
create mode 100644 test/py/conftest.py
create mode 100644 test/py/multiplexed_log.css
create mode 100644 test/py/multiplexed_log.py
create mode 100644 test/py/pytest.ini
create mode 100755 test/py/test.py
create mode 100644 test/py/tests/test_000_version.py
create mode 100644 test/py/tests/test_help.py
create mode 100644 test/py/tests/test_unknown_cmd.py
create mode 100644 test/py/u_boot_console_base.py
create mode 100644 test/py/u_boot_console_exec_attach.py
create mode 100644 test/py/u_boot_console_sandbox.py
create mode 100644 test/py/u_boot_spawn.py
diff --git a/test/py/.gitignore b/test/py/.gitignore
new file mode 100644
index 000000000000..0d20b6487c61
--- /dev/null
+++ b/test/py/.gitignore
@@ -0,0 +1 @@
+*.pyc
diff --git a/test/py/README.md b/test/py/README.md
new file mode 100644
index 000000000000..8036299d0735
--- /dev/null
+++ b/test/py/README.md
@@ -0,0 +1,300 @@
+# U-Boot pytest suite
+
+## Introduction
+
+This tool aims to test U-Boot by executing U-Boot shell commands using the
+console interface. A single top-level script exists to execute or attach to the
+U-Boot console, run the entire script of tests against it, and summarize the
+results. Advantages of this approach are:
+
+- Testing is performed in the same way a user or script would interact with
+ U-Boot; there can be no disconnect.
+- There is no need to write or embed test-related code into U-Boot itself.
+ It is asserted that writing test-related code in Python is simpler and more
+ flexible that writing it all in C.
+- It is reasonably simple to interact with U-Boot in this way.
+
+## Requirements
+
+The test suite is implemented using pytest. Interaction with the U-Boot console
+involves executing some binary and interacting with its stdin/stdout. You will
+need to implement various "hook" scripts that are called by the test suite at
+the appropriate time.
+
+On Debian or Debian-like distributions, the following packages are required.
+Similar package names should exist in other distributions.
+
+| Package | Version tested (Ubuntu 14.04) |
+| -------------- | ----------------------------- |
+| python | 2.7.5-5ubuntu3 |
+| python-pytest | 2.5.1-1 |
+
+The test script supports either:
+
+- Executing a sandbox port of U-Boot on the local machine as a sub-process,
+ and interacting with it over stdin/stdout.
+- Executing an external "hook" scripts to flash a U-Boot binary onto a
+ physical board, attach to the board's console stream, and reset the board.
+ Further details are described later.
+
+### Using `virtualenv` to provide requirements
+
+Older distributions (e.g. Ubuntu 10.04) may not provide all the required
+packages, or may provide versions that are too old to run the test suite. One
+can use the Python `virtualenv` script to locally install more up-to-date
+versions of the required packages without interfering with the OS installation.
+For example:
+
+```bash
+$ cd /path/to/u-boot
+$ sudo apt-get install python python-virtualenv
+$ virtualenv venv
+$ . ./venv/bin/activate
+$ pip install pytest
+```
+
+## Testing sandbox
+
+To run the testsuite on the sandbox port (U-Boot built as a native user-space
+application), simply execute:
+
+```
+./test/py/test.py --bd sandbox --build
+```
+
+The `--bd` option tells the test suite which board type is being tested. This
+lets the test suite know which features the board has, and hence exactly what
+can be tested.
+
+The `--build` option tells U-Boot to compile U-Boot. Alternatively, you may
+omit this option and build U-Boot yourself, in whatever way you choose, before
+running the test script.
+
+The test script will attach to U-Boot, execute all valid tests for the board,
+then print a summary of the test process. A complete log of the test session
+will be written to `${build_dir}/test-log.html`. This is best viewed in a web
+browser, but may be read directly as plain text, perhaps with the aid of the
+`html2text` utility.
+
+## Command-line options
+
+- `--board-type`, `--bd`, `-B` set the type of the board to be tested. For
+ example, `sandbox` or `seaboard`.
+- `--board-identity`, `--id` set the identity of the board to be tested.
+ This allows differentiation between multiple instances of the same type of
+ physical board that are attached to the same host machine. This parameter is
+ not interpreted by the test script in any way, but rather is simply passed
+ to the hook scripts described below, and may be used in any site-specific
+ way deemed necessary.
+- `--build` indicates that the test script should compile U-Boot itself
+ before running the tests. If using this option, make sure that any
+ environment variables required by the build process are already set, such as
+ `$CROSS_COMPILE`.
+- `--build-dir` sets the directory containing the compiled U-Boot binaries.
+ If omitted, this is `${source_dir}/build-${board_type}`.
+- `--result-dir` sets the directory to write results, such as log files,
+ into. If omitted, the build directory is used.
+- `--persistent-data-dir` sets the directory used to store persistent test
+ data. This is test data that may be re-used across test runs, such as file-
+ system images.
+
+`pytest` also implements a number of its own command-line options. Please see
+`pytest` documentation for complete details. Execute `py.test --version` for
+a brief summary. Note that U-Boot's test.py script passes all command-line
+arguments directly to `pytest` for processing.
+
+## Testing real hardware
+
+The tools and techniques used to interact with real hardware will vary
+radically between different host and target systems, and the whims of the user.
+For this reason, the test suite does not attempt to directly interact with real
+hardware in any way. Rather, it executes a standardized set of "hook" scripts
+via `$PATH`. These scripts implement certain actions on behalf of the test
+suite. This keeps the test suite simple and isolated from system variances
+unrelated to U-Boot features.
+
+### Hook scripts
+
+#### Environment variables
+
+The following environment variables are set when running hook scripts:
+
+- `UBOOT_BOARD_TYPE` the board type being tested.
+- `UBOOT_BOARD_IDENTITY` the board identity being tested, or `na` if none was
+ specified.
+- `UBOOT_SOURCE_DIR` the U-Boot source directory.
+- `UBOOT_TEST_PY_DIR` the full path to `test/py/` in the source directory.
+- `UBOOT_BUILD_DIR` the U-Boot build directory.
+- `UBOOT_RESULT_DIR` the test result directory.
+- `UBOOT_PERSISTENT_DATA_DIR` the test peristent data directory.
+
+#### `u-boot-test-console`
+
+This script provides access to the U-Boot console. The script's stdin/stdout
+should be connected to the board's console. This process should continue to run
+indefinitely, until killed. The test suite will run this script in parallel
+with all other hooks.
+
+This script may be implemented e.g. by exec()ing `cu`, `kermit`, `conmux`, etc.
+
+If you are able to run U-Boot under a hardware simulator such as qemu, then
+you would likely spawn that simulator from this script. However, note that
+`u-boot-test-reset` may be called multiple times per test script run, and must
+cause U-Boot to start execution from scratch each time. Hopefully your
+simulator includes a virtual reset button! If not, you can launch the
+simulator from `u-boot-test-reset` instead, while arranging for this console
+process to always communicate with the current simulator instance.
+
+#### `u-boot-test-flash`
+
+Prior to running the test suite against a board, some arrangement must be made
+so that the board executes the particular U-Boot binary to be tested. Often,
+this involves writing the U-Boot binary to the board's flash ROM. The test
+suite calls this hook script for that purpose.
+
+This script should perform the entire flashing process synchronously; the
+script should only exit once flashing is complete, and a board reset will
+cause the newly flashed U-Boot binary to be executed.
+
+It is conceivable that this script will do nothing. This might be useful in
+the following cases:
+
+- Some other process has already written the desired U-Boot binary into the
+ board's flash prior to running the test suite.
+- The board allows U-Boot to be downloaded directly into RAM, and executed
+ from there. Use of this feature will reduce wear on the board's flash, so
+ may be preferable if available, and if cold boot testing of U-Boot is not
+ required. If this feature is used, the `u-boot-test-reset` script should
+ peform this download, since the board could conceivably be reset multiple
+ times in a single test run.
+
+It is up to the user to determine if those situations exist, and to code this
+hook script appropriately.
+
+This script will typically be implemented by calling out to some SoC- or
+board-specific vendor flashing utility.
+
+#### `u-boot-test-reset`
+
+Whenever the test suite needs to reset the target board, this script is
+executed. This is guaranteed to happen at least once, prior to executing the
+first test function. If any test fails, the test infra-structure will execute
+this script again to restore U-Boot to an operational state before running the
+next test function.
+
+This script will likely be implemented by communicating with some form of
+relay or electronic switch attached to the board's reset signal.
+
+The semantics of this script require that when it is executed, U-Boot will
+start running from scratch. If the U-Boot binary to be tested has been written
+to flash, pulsing the board's reset signal is likely all this script need do.
+However, in some scenarios, this script may perform other actions. For
+example, it may call out to some SoC- or board-specific vendor utility in order
+to download the U-Boot binary directly into RAM and execute it. This would
+avoid the need for `u-boot-test-flash` to actually write U-Boot to flash, thus
+saving wear on the flash chip(s).
+
+### Board-type-specific configuration
+
+Each board has a different configuration and behaviour. Many of these
+differences can be automatically detected by parsing the `.config` file in the
+build directory. However, some differences can't yet be handled automatically.
+
+For each board, an optional Python module `u_boot_board_${board_type}` may exist
+to provide board-specific information to the test script. Any global value
+defined in these modules is available for use by any test function. The data
+contained in these scripts must be purely derived from U-Boot source code.
+Hence, these configuration files are part of the U-Boot source tree too.
+
+### Execution environment configuration
+
+Each user's hardware setup may enable testing different subsets of the features
+implemented by a particular board's configuration of U-Boot. For example, a
+U-Boot configuration may support USB device mode and USB Mass Storage, but this
+can only be tested if a USB cable is connected between the board and the host
+machine running the test script.
+
+For each board, optional Python modules `u_boot_boardenv_${board_type}` and
+`u_boot_boardenv_${board_type}_${board_identity}` may exist to provide
+board-specific and board-identity-specific information to the test script. Any
+global value defined in these modules is available for use by any test
+function. The data contained in these is specific to a particular user's
+hardware configuration. Hence, these configuration files are not part of the
+U-Boot source tree, and should be installed outside of the source tree. Users
+should set `$PYTHONPATH` prior to running the test script to allow these
+modules to be loaded.
+
+### Board module parameter usage
+
+The test scripts rely on the following variables being defined by the board
+module:
+
+- None at present.
+
+### U-Boot `.config` feature usage
+
+The test scripts rely on various U-Boot `.config` features, either directly in
+order to test those features, or indirectly in order to query information from
+the running U-Boot instance in order to test other features.
+
+One example is that testing of the `md` command requires knowledge of a RAM
+address to use for the test. This data is parsed from the output of the
+`bdinfo` command, and hence relies on CONFIG_CMD_BDI being enabled.
+
+For a complete list of dependencies, please search the test scripts for
+instances of:
+
+- `buildconfig.get(...`
+- `@pytest.mark.buildconfigspec(...`
+
+### Complete invocation example
+
+Assuming that you have installed the hook scripts into $HOME/ubtest/bin, and
+any required environment configuration Python modules into $HOME/ubtest/py,
+then you would likely invoke the test script as follows:
+
+If U-Boot has already been built:
+
+```bash
+PATH=$HOME/ubtest/bin:$PATH \
+ PYTHONPATH=${HOME}/ubtest/py:${PYTHONPATH} \
+ ./test/py/test.py --bd seaboard
+```
+
+If you want the test script to compile U-Boot for you too, then you likely
+need to set `$CROSS_COMPILE` to allow this, and invoke the test script as
+follow:
+
+```bash
+CROSS_COMPILE=arm-none-eabi- \
+ PATH=$HOME/ubtest/bin:$PATH \
+ PYTHONPATH=${HOME}/ubtest/py:${PYTHONPATH} \
+ ./test/py/test.py --bd seaboard --build
+```
+
+## Writing tests
+
+Please refer to the pytest documentation for details of writing pytest tests.
+Details specific to the U-Boot test suite are described below.
+
+A test fixture named `u_boot_console` should be used by each test function. This
+provides the means to interact with the U-Boot console, and retrieve board and
+environment configuration information.
+
+The function `u_boot_console.run_command()` executes a shell command on the
+U-Boot console, and returns all output from that command. This allows
+validation or interpretation of the command output. This function validates
+that certain strings are not seen on the U-Boot console. These include shell
+error messages and the U-Boot sign-on message (in order to detect unexpected
+board resets). See the source of `u_boot_console_base.py` for a complete list of
+"bad" strings. Some test scenarios are expected to trigger these strings. Use
+`u_boot_console.disable_check()` to temporarily disable checking for specific
+strings. See `test_unknown_cmd.py` for an example.
+
+Board- and board-environment configuration values may be accessed as sub-fields
+of the `u_boot_console.config` object, for example
+`u_boot_console.config.ram_base`.
+
+Build configuration values (from `.config`) may be accessed via the dictionary
+`u_boot_console.config.buildconfig`, with keys equal to the Kconfig variable
+names.
diff --git a/test/py/conftest.py b/test/py/conftest.py
new file mode 100644
index 000000000000..e1674dfce053
--- /dev/null
+++ b/test/py/conftest.py
@@ -0,0 +1,422 @@
+# Copyright (c) 2015 Stephen Warren
+# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+# Implementation of pytest run-time hook functions. These are invoked by
+# pytest at certain points during operation, e.g. startup, for each executed
+# test, at shutdown etc. These hooks perform functions such as:
+# - Parsing custom command-line options.
+# - Pullilng in user-specified board configuration.
+# - Creating the U-Boot console test fixture.
+# - Creating the HTML log file.
+# - Monitoring each test's results.
+# - Implementing custom pytest markers.
+
+import atexit
+import errno
+import os
+import os.path
+import pexpect
+import pytest
+from _pytest.runner import runtestprotocol
+import ConfigParser
+import StringIO
+import sys
+
+# Globals: The HTML log file, and the connection to the U-Boot console.
+log = None
+console = None
+
+def mkdir_p(path):
+ '''Create a directory path.
+
+ This includes creating any intermediate/parent directories. Any errors
+ caused due to already extant directories are ignored.
+
+ Args:
+ path: The directory path to create.
+
+ Returns:
+ Nothing.
+ '''
+
+ try:
+ os.makedirs(path)
+ except OSError as exc:
+ if exc.errno == errno.EEXIST and os.path.isdir(path):
+ pass
+ else:
+ raise
+
+def pytest_addoption(parser):
+ '''pytest hook: Add custom command-line options to the cmdline parser.
+
+ Args:
+ parser: The pytest command-line parser.
+
+ Returns:
+ Nothing.
+ '''
+
+ parser.addoption('--build-dir', default=None,
+ help='U-Boot build directory (O=)')
+ parser.addoption('--result-dir', default=None,
+ help='U-Boot test result/tmp directory')
+ parser.addoption('--persistent-data-dir', default=None,
+ help='U-Boot test persistent generated data directory')
+ parser.addoption('--board-type', '--bd', '-B', default='sandbox',
+ help='U-Boot board type')
+ parser.addoption('--board-identity', '--id', default='na',
+ help='U-Boot board identity/instance')
+ parser.addoption('--build', default=False, action='store_true',
+ help='Compile U-Boot before running tests')
+
+def pytest_configure(config):
+ '''pytest hook: Perform custom initialization at startup time.
+
+ Args:
+ config: The pytest configuration.
+
+ Returns:
+ Nothing.
+ '''
+
+ global log
+ global console
+ global ubconfig
+
+ test_py_dir = os.path.dirname(os.path.abspath(__file__))
+ source_dir = os.path.dirname(os.path.dirname(test_py_dir))
+
+ board_type = config.getoption('board_type')
+ board_type_filename = board_type.replace('-', '_')
+
+ board_identity = config.getoption('board_identity')
+ board_identity_filename = board_identity.replace('-', '_')
+
+ build_dir = config.getoption('build_dir')
+ if not build_dir:
+ build_dir = source_dir + '/build-' + board_type
+ mkdir_p(build_dir)
+
+ result_dir = config.getoption('result_dir')
+ if not result_dir:
+ result_dir = build_dir
+ mkdir_p(result_dir)
+
+ persistent_data_dir = config.getoption('persistent_data_dir')
+ if not persistent_data_dir:
+ persistent_data_dir = build_dir + '/persistent-data'
+ mkdir_p(persistent_data_dir)
+
+ import multiplexed_log
+ log = multiplexed_log.Logfile(result_dir + '/test-log.html')
+
+ if config.getoption('build'):
+ if build_dir != source_dir:
+ o_opt = 'O=%s' % build_dir
+ else:
+ o_opt = ''
+ cmds = (
+ ['make', o_opt, '-s', board_type + '_defconfig'],
+ ['make', o_opt, '-s', '-j8'],
+ )
+ runner = log.get_runner('make', sys.stdout)
+ for cmd in cmds:
+ runner.run(cmd, cwd=source_dir)
+ runner.close()
+
+ class ArbitraryAttributeContainer(object):
+ pass
+
+ ubconfig = ArbitraryAttributeContainer()
+ ubconfig.brd = dict()
+ ubconfig.env = dict()
+
+ modules = [
+ (ubconfig.brd, 'u_boot_board_' + board_type_filename),
+ (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
+ (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
+ board_identity_filename),
+ ]
+ for (dict_to_fill, module_name) in modules:
+ try:
+ module = __import__(module_name)
+ except ImportError:
+ continue
+ dict_to_fill.update(module.__dict__)
+
+ ubconfig.buildconfig = dict()
+
+ for conf_file in ('.config', 'include/autoconf.mk'):
+ dot_config = build_dir + '/' + conf_file
+ if not os.path.exists(dot_config):
+ raise Exception(conf_file + ' does not exist; ' +
+ 'try passing --build option?')
+
+ with open(dot_config, 'rt') as f:
+ ini_str = '[root]\n' + f.read()
+ ini_sio = StringIO.StringIO(ini_str)
+ parser = ConfigParser.RawConfigParser()
+ parser.readfp(ini_sio)
+ ubconfig.buildconfig.update(parser.items('root'))
+
+ ubconfig.test_py_dir = test_py_dir
+ ubconfig.source_dir = source_dir
+ ubconfig.build_dir = build_dir
+ ubconfig.result_dir = result_dir
+ ubconfig.persistent_data_dir = persistent_data_dir
+ ubconfig.board_type = board_type
+ ubconfig.board_identity = board_identity
+
+ env_vars = (
+ 'board_type',
+ 'board_identity',
+ 'source_dir',
+ 'test_py_dir',
+ 'build_dir',
+ 'result_dir',
+ 'persistent_data_dir',
+ )
+ for v in env_vars:
+ os.environ['U_BOOT_' + v.upper()] = getattr(ubconfig, v)
+
+ if board_type == 'sandbox':
+ import u_boot_console_sandbox
+ console = u_boot_console_sandbox.ConsoleSandbox(log, ubconfig)
+ else:
+ import u_boot_console_exec_attach
+ console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig)
+
+def pytest_generate_tests(metafunc):
+ '''pytest hook: parameterize test functions based on custom rules.
+
+ If a test function takes parameter(s) (fixture names) of the form brd__xxx
+ or env__xxx, the brd and env configuration dictionaries are consulted to
+ find the list of values to use for those parameters, and the test is
+ parametrized so that it runs once for each combination of values.
+
+ Args:
+ metafunc: The pytest test function.
+
+ Returns:
+ Nothing.
+ '''
+
+ subconfigs = {
+ 'brd': console.config.brd,
+ 'env': console.config.env,
+ }
+ for fn in metafunc.fixturenames:
+ parts = fn.split('__')
+ if len(parts) < 2:
+ continue
+ if parts[0] not in subconfigs:
+ continue
+ subconfig = subconfigs[parts[0]]
+ vals = []
+ val = subconfig.get(fn, [])
+ # If that exact name is a key in the data source:
+ if val:
+ # ... use the dict value as a single parameter value.
+ vals = (val, )
+ else:
+ # ... otherwise, see if there's a key that contains a list of
+ # values to use instead.
+ vals = subconfig.get(fn + 's', [])
+ metafunc.parametrize(fn, vals)
+
+(a)pytest.fixture(scope='session')
+def u_boot_console(request):
+ '''Generate the value of a test's u_boot_console fixture.
+
+ Args:
+ request: The pytest request.
+
+ Returns:
+ The fixture value.
+ '''
+
+ return console
+
+tests_not_run = set()
+tests_failed = set()
+tests_skipped = set()
+tests_passed = set()
+
+def pytest_itemcollected(item):
+ '''pytest hook: Called once for each test found during collection.
+
+ This enables our custom result analysis code to see the list of all tests
+ that should eventually be run.
+
+ Args:
+ item: The item that was collected.
+
+ Returns:
+ Nothing.
+ '''
+
+ tests_not_run.add(item.name)
+
+def cleanup():
+ '''Clean up all global state.
+
+ Executed (via atexit) once the entire test process is complete. This
+ includes logging the status of all tests, and the identity of any failed
+ or skipped tests.
+
+ Args:
+ None.
+
+ Returns:
+ Nothing.
+ '''
+
+ if console:
+ console.close()
+ if log:
+ log.status_pass('%d passed' % len(tests_passed))
+ if tests_skipped:
+ log.status_skipped('%d skipped' % len(tests_skipped))
+ for test in tests_skipped:
+ log.status_skipped('... ' + test)
+ if tests_failed:
+ log.status_fail('%d failed' % len(tests_failed))
+ for test in tests_failed:
+ log.status_fail('... ' + test)
+ if tests_not_run:
+ log.status_fail('%d not run' % len(tests_not_run))
+ for test in tests_not_run:
+ log.status_fail('... ' + test)
+ log.close()
+atexit.register(cleanup)
+
+def setup_boardspec(item):
+ '''Process any 'boardspec' marker for a test.
+
+ Such a marker lists the set of board types that a test does/doesn't
+ support. If tests are being executed on an unsupported board, the test is
+ marked to be skipped.
+
+ Args:
+ item: The pytest test item.
+
+ Returns:
+ Nothing.
+ '''
+
+ mark = item.get_marker('boardspec')
+ if not mark:
+ return
+ required_boards = []
+ for board in mark.args:
+ if board.startswith('!'):
+ if ubconfig.board_type == board[1:]:
+ pytest.skip('board not supported')
+ return
+ else:
+ required_boards.append(board)
+ if required_boards and ubconfig.board_type not in required_boards:
+ pytest.skip('board not supported')
+
+def setup_buildconfigspec(item):
+ '''Process any 'buildconfigspec' marker for a test.
+
+ Such a marker lists some U-Boot configuration feature that the test
+ requires. If tests are being executed on an U-Boot build that doesn't
+ have the required feature, the test is marked to be skipped.
+
+ Args:
+ item: The pytest test item.
+
+ Returns:
+ Nothing.
+ '''
+
+ mark = item.get_marker('buildconfigspec')
+ if not mark:
+ return
+ for option in mark.args:
+ if not ubconfig.buildconfig.get('config_' + option.lower(), None):
+ pytest.skip('.config feature not enabled')
+
+def pytest_runtest_setup(item):
+ '''pytest hook: Configure (set up) a test item.
+
+ Called once for each test to perform any custom configuration. This hook
+ is used to skip the test if certain conditions apply.
+
+ Args:
+ item: The pytest test item.
+
+ Returns:
+ Nothing.
+ '''
+
+ log.start_section(item.name)
+ setup_boardspec(item)
+ setup_buildconfigspec(item)
+
+def pytest_runtest_protocol(item, nextitem):
+ '''pytest hook: Called to execute a test.
+
+ This hook wraps the standard pytest runtestprotocol() function in order
+ to acquire visibility into, and record, each test function's result.
+
+ Args:
+ item: The pytest test item to execute.
+ nextitem: The pytest test item that will be executed after this one.
+
+ Returns:
+ A list of pytest reports (test result data).
+ '''
+
+ reports = runtestprotocol(item, nextitem=nextitem)
+ failed = None
+ skipped = None
+ for report in reports:
+ if report.outcome == 'failed':
+ failed = report
+ break
+ if report.outcome == 'skipped':
+ if not skipped:
+ skipped = report
+
+ if failed:
+ tests_failed.add(item.name)
+ elif skipped:
+ tests_skipped.add(item.name)
+ else:
+ tests_passed.add(item.name)
+ tests_not_run.remove(item.name)
+
+ try:
+ if failed:
+ msg = 'FAILED:\n' + str(failed.longrepr)
+ log.status_fail(msg)
+ elif skipped:
+ msg = 'SKIPPED:\n' + str(skipped.longrepr)
+ log.status_skipped(msg)
+ else:
+ log.status_pass('OK')
+ except:
+ # If something went wrong with logging, it's better to let the test
+ # process continue, which may report other exceptions that triggered
+ # the logging issue (e.g. console.log wasn't created). Hence, just
+ # squash the exception. If the test setup failed due to e.g. syntax
+ # error somewhere else, this won't be seen. However, once that issue
+ # is fixed, if this exception still exists, it will then be logged as
+ # part of the test's stdout.
+ import traceback
+ print 'Exception occurred while logging runtest status:'
+ traceback.print_exc()
+ # FIXME: Can we force a test failure here?
+
+ log.end_section(item.name)
+
+ if failed:
+ console.cleanup_spawn()
+
+ return reports
diff --git a/test/py/multiplexed_log.css b/test/py/multiplexed_log.css
new file mode 100644
index 000000000000..50f7b9092983
--- /dev/null
+++ b/test/py/multiplexed_log.css
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015 Stephen Warren
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+/*
+ * This provides pretty formatting of the HTML log file, e.g.
+ * - colored bars beside/above log sections for easily parsed delineation.
+ * - color highlighting of various messages.
+ */
+
+body {
+ background-color: black;
+ color: #ffffff;
+}
+
+pre {
+ margin-top: 0px;
+ margin-bottom: 0px;
+}
+
+.implicit {
+ color: #808080;
+}
+
+.section {
+ border-style: solid;
+ border-color: #303030;
+ border-width: 0px 0px 0px 5px;
+ padding-left: 5px
+}
+
+.section-header {
+ background-color: #303030;
+ margin-left: -5px;
+ margin-top: 5px;
+}
+
+.section-trailer {
+ display: none;
+}
+
+.stream {
+ border-style: solid;
+ border-color: #303030;
+ border-width: 0px 0px 0px 5px;
+ padding-left: 5px
+}
+
+.stream-header {
+ background-color: #303030;
+ margin-left: -5px;
+ margin-top: 5px;
+}
+
+.stream-trailer {
+ display: none;
+}
+
+.error {
+ color: #ff0000
+}
+
+.warning {
+ color: #ffff00
+}
+
+.info {
+ color: #808080
+}
+
+.action {
+ color: #8080ff
+}
+
+.status-pass {
+ color: #00ff00
+}
+
+.status-skipped {
+ color: #ffff00
+}
+
+.status-fail {
+ color: #ff0000
+}
diff --git a/test/py/multiplexed_log.py b/test/py/multiplexed_log.py
new file mode 100644
index 000000000000..48f2b51de15f
--- /dev/null
+++ b/test/py/multiplexed_log.py
@@ -0,0 +1,515 @@
+# Copyright (c) 2015 Stephen Warren
+# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+# Generate an HTML-formatted log file containing multiple streams of data,
+# each represented in a well-delineated/-structured fashion.
+
+import cgi
+import os.path
+import shutil
+import subprocess
+
+mod_dir = os.path.dirname(os.path.abspath(__file__))
+
+class LogfileStream(object):
+ '''A file-like object used to write a single logical stream of data into
+ a multiplexed log file. Objects of this type should be created by factory
+ functions in the Logfile class rather than directly.'''
+
+ def __init__(self, logfile, name, chained_file):
+ '''Initialize a new object.
+
+ Args:
+ logfile: The Logfile object to log to.
+ name: The name of this log stream.
+ chained_file: The file-like object to which all stream data should be
+ logged to in addition to logfile. Can be None.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.logfile = logfile
+ self.name = name
+ self.chained_file = chained_file
+
+ def close(self):
+ '''Dummy function so that this class is "file-like".
+
+ Args:
+ None.
+
+ Returns:
+ Nothing.
+ '''
+
+ pass
+
+ def write(self, data, implicit=False):
+ '''Write data to the log stream.
+
+ Args:
+ data: The data to write tot he file.
+ implicit: Boolean indicating whether data actually appeared in the
+ stream, or was implicitly generated. A valid use-case is to
+ repeat a shell prompt at the start of each separate log
+ section, which makes the log sections more readable in
+ isolation.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.logfile.write(self, data, implicit)
+ if self.chained_file:
+ self.chained_file.write(data)
+
+ def flush(self):
+ '''Flush the log stream, to ensure correct log interleaving.
+
+ Args:
+ None.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.logfile.flush()
+ if self.chained_file:
+ self.chained_file.flush()
+
+class RunAndLog(object):
+ '''A utility object used to execute sub-processes and log their output to
+ a multiplexed log file. Objects of this type should be created by factory
+ functions in the Logfile class rather than directly.'''
+
+ def __init__(self, logfile, name, chained_file):
+ '''Initialize a new object.
+
+ Args:
+ logfile: The Logfile object to log to.
+ name: The name of this log stream or sub-process.
+ chained_file: The file-like object to which all stream data should
+ be logged to in addition to logfile. Can be None.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.logfile = logfile
+ self.name = name
+ self.chained_file = chained_file
+
+ def close(self):
+ '''Clean up any resources managed by this object.'''
+ pass
+
+ def run(self, cmd, cwd=None):
+ '''Run a command as a sub-process, and log the results.
+
+ Args:
+ cmd: The command to execute.
+ cwd: The directory to run the command in. Can be None to use the
+ current directory.
+
+ Returns:
+ Nothing.
+ '''
+
+ msg = "+" + " ".join(cmd) + "\n"
+ if self.chained_file:
+ self.chained_file.write(msg)
+ self.logfile.write(self, msg)
+
+ try:
+ p = subprocess.Popen(cmd, cwd=cwd,
+ stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ (stdout, stderr) = p.communicate()
+ output = ''
+ if stdout:
+ if stderr:
+ output += 'stdout:\n'
+ output += stdout
+ if stderr:
+ if stdout:
+ output += 'stderr:\n'
+ output += stderr
+ exit_status = p.returncode
+ exception = None
+ except subprocess.CalledProcessError as cpe:
+ output = cpe.output
+ exit_status = cpe.returncode
+ exception = cpe
+ except Exception as e:
+ output = ''
+ exit_status = 0
+ exception = e
+ if output and not output.endswith('\n'):
+ output += '\n'
+ if exit_status and not exception:
+ exception = Exception('Exit code: ' + str(exit_status))
+ if exception:
+ output += str(exception) + '\n'
+ self.logfile.write(self, output)
+ if self.chained_file:
+ self.chained_file.write(output)
+ if exception:
+ raise exception
+
+class SectionCtxMgr(object):
+ '''A context manager for Python's "with" statement, which allows a certain
+ portion of test code to be logged to a separate section of the log file.
+ Objects of this type should be created by factory functions in the Logfile
+ class rather than directly.'''
+
+ def __init__(self, log, marker):
+ '''Initialize a new object.
+
+ Args:
+ log: The Logfile object to log to.
+ marker: The name of the nested log section.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.log = log
+ self.marker = marker
+
+ def __enter__(self):
+ self.log.start_section(self.marker)
+
+ def __exit__(self, extype, value, traceback):
+ self.log.end_section(self.marker)
+
+class Logfile(object):
+ '''Generates an HTML-formatted log file containing multiple streams of
+ data, each represented in a well-delineated/-structured fashion.'''
+
+ def __init__(self, fn):
+ '''Initialize a new object.
+
+ Args:
+ fn: The filename to write to.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.f = open(fn, "wt")
+ self.last_stream = None
+ self.blocks = []
+ self.cur_evt = 1
+ shutil.copy(mod_dir + "/multiplexed_log.css", os.path.dirname(fn))
+ self.f.write("""\
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="multiplexed_log.css">
+</head>
+<body>
+<tt>
+""")
+
+ def close(self):
+ '''Close the log file.
+
+ After calling this function, no more data may be written to the log.
+
+ Args:
+ None.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.f.write("""\
+</tt>
+</body>
+</html>
+""")
+ self.f.close()
+
+ # The set of characters that should be represented as hexadecimal codes in
+ # the log file.
+ _nonprint = ("%" + "".join(chr(c) for c in range(0, 32) if c not in (9, 10)) +
+ "".join(chr(c) for c in range(127, 256)))
+
+ def _escape(self, data):
+ '''Render data format suitable for inclusion in an HTML document.
+
+ This includes HTML-escaping certain characters, and translating
+ control characters to a hexadecimal representation.
+
+ Args:
+ data: The raw string data to be escaped.
+
+ Returns:
+ An escaped version of the data.
+ '''
+
+ data = data.replace(chr(13), "")
+ data = "".join((c in self._nonprint) and ("%%%02x" % ord(c)) or
+ c for c in data)
+ data = cgi.escape(data)
+ return data
+
+ def _terminate_stream(self):
+ '''Write HTML to the log file to terminate the current stream's data.
+
+ Args:
+ None.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.cur_evt += 1
+ if not self.last_stream:
+ return
+ self.f.write("</pre>\n")
+ self.f.write("<div class=\"stream-trailer\" id=\"" +
+ self.last_stream.name + "\">End stream: " +
+ self.last_stream.name + "</div>\n")
+ self.f.write("</div>\n")
+ self.last_stream = None
+
+ def _note(self, note_type, msg):
+ '''Write a note or one-off message to the log file.
+
+ Args:
+ note_type: The type of note. This must be a value supported by the
+ accompanying multiplexed_log.css.
+ msg: The note/message to log.
+
+ Returns:
+ Nothing.
+ '''
+
+ self._terminate_stream()
+ self.f.write("<div class=\"" + note_type + "\">\n<pre>")
+ self.f.write(self._escape(msg))
+ self.f.write("\n</pre></div>\n")
+
+ def start_section(self, marker):
+ '''Begin a new nested section in the log file.
+
+ Args:
+ marker: The name of the section that is starting.
+
+ Returns:
+ Nothing.
+ '''
+
+ self._terminate_stream()
+ self.blocks.append(marker)
+ blk_path = "/".join(self.blocks)
+ self.f.write("<div class=\"section\" id=\"" + blk_path + "\">\n")
+ self.f.write("<div class=\"section-header\" id=\"" + blk_path +
+ "\">Section: " + blk_path + "</div>\n")
+
+ def end_section(self, marker):
+ '''Terminate the current nested section in the log file.
+
+ This function validates proper nesting of start_section() and
+ end_section() calls. If a mismatch is found, an exception is raised.
+
+ Args:
+ marker: The name of the section that is ending.
+
+ Returns:
+ Nothing.
+ '''
+
+ if (not self.blocks) or (marker != self.blocks[-1]):
+ raise Exception("Block nesting mismatch: \"%s\" \"%s\"" %
+ (marker, "/".join(self.blocks)))
+ self._terminate_stream()
+ blk_path = "/".join(self.blocks)
+ self.f.write("<div class=\"section-trailer\" id=\"section-trailer-" +
+ blk_path + "\">End section: " + blk_path + "</div>\n")
+ self.f.write("</div>\n")
+ self.blocks.pop()
+
+ def section(self, marker):
+ '''Create a temporary section in the log file.
+
+ This function creates a context manager for Python's "with" statement,
+ which allows a certain portion of test code to be logged to a separate
+ section of the log file.
+
+ Usage:
+ with log.section("somename"):
+ some test code
+
+ Args:
+ marker: The name of the nested section.
+
+ Returns:
+ A context manager object.
+ '''
+
+ return SectionCtxMgr(self, marker)
+
+ def error(self, msg):
+ '''Write an error note to the log file.
+
+ Args:
+ msg: A message describing the error.
+
+ Returns:
+ Nothing.
+ '''
+
+ self._note("error", msg)
+
+ def warning(self, msg):
+ '''Write an warning note to the log file.
+
+ Args:
+ msg: A message describing the warning.
+
+ Returns:
+ Nothing.
+ '''
+
+ self._note("warning", msg)
+
+ def info(self, msg):
+ '''Write an informational note to the log file.
+
+ Args:
+ msg: An informational message.
+
+ Returns:
+ Nothing.
+ '''
+
+ self._note("info", msg)
+
+ def action(self, msg):
+ '''Write an action note to the log file.
+
+ Args:
+ msg: A message describing the action that is being logged.
+
+ Returns:
+ Nothing.
+ '''
+
+ self._note("action", msg)
+
+ def status_pass(self, msg):
+ '''Write a note to the log file describing test(s) which passed.
+
+ Args:
+ msg: A message describing passed test(s).
+
+ Returns:
+ Nothing.
+ '''
+
+ self._note("status-pass", msg)
+
+ def status_skipped(self, msg):
+ '''Write a note to the log file describing skipped test(s).
+
+ Args:
+ msg: A message describing passed test(s).
+
+ Returns:
+ Nothing.
+ '''
+
+ self._note("status-skipped", msg)
+
+ def status_fail(self, msg):
+ '''Write a note to the log file describing failed test(s).
+
+ Args:
+ msg: A message describing passed test(s).
+
+ Returns:
+ Nothing.
+ '''
+
+ self._note("status-fail", msg)
+
+ def get_stream(self, name, chained_file=None):
+ '''Create an object to log a single stream's data into the log file.
+
+ This creates a "file-like" object that can be written to in order to
+ write a single stream's data to the log file. The implementation will
+ handle any required interleaving of data (from multiple streams) in
+ the log, in a way that makes it obvious which stream each bit of data
+ came from.
+
+ Args:
+ name: The name of the stream.
+ chained_file: The file-like object to which all stream data should
+ be logged to in addition to this log. Can be None.
+
+ Returns:
+ A file-like object.
+ '''
+
+ return LogfileStream(self, name, chained_file)
+
+ def get_runner(self, name, chained_file=None):
+ '''Create an object that executes processes and logs their output.
+
+ Args:
+ name: The name of this sub-process.
+ chained_file: The file-like object to which all stream data should
+ be logged to in addition to logfile. Can be None.
+
+ Returns:
+ A RunAndLog object.
+ '''
+
+ return RunAndLog(self, name, chained_file)
+
+ def write(self, stream, data, implicit=False):
+ '''Write stream data into the log file.
+
+ This function should only be used by instances of LogfileStream or
+ RunAndLog.
+
+ Args:
+ stream: The stream whose data is being logged.
+ data: The data to log.
+ implicit: Boolean indicating whether data actually appeared in the
+ stream, or was implicitly generated. A valid use-case is to
+ repeat a shell prompt at the start of each separate log
+ section, which makes the log sections more readable in
+ isolation.
+
+ Returns:
+ Nothing.
+ '''
+
+ if stream != self.last_stream:
+ self._terminate_stream()
+ self.f.write("<div class=\"stream\" id=\"%s\">\n" % stream.name)
+ self.f.write("<div class=\"stream-header\" id=\"" + stream.name +
+ "\">Stream: " + stream.name + "</div>\n")
+ self.f.write("<pre>")
+ if implicit:
+ self.f.write("<span class=\"implicit\">")
+ self.f.write(self._escape(data))
+ if implicit:
+ self.f.write("</span>")
+ self.last_stream = stream
+
+ def flush(self):
+ '''Flush the log stream, to ensure correct log interleaving.
+
+ Args:
+ None.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.f.flush()
diff --git a/test/py/pytest.ini b/test/py/pytest.ini
new file mode 100644
index 000000000000..67e514f42058
--- /dev/null
+++ b/test/py/pytest.ini
@@ -0,0 +1,11 @@
+# Copyright (c) 2015 Stephen Warren
+# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+# Static configuration data for pytest. pytest reads this at startup time.
+
+[pytest]
+markers =
+ boardspec: U-Boot: Describes the set of boards a test can/can't run on.
+ buildconfigspec: U-Boot: Describes Kconfig/config-header constraints.
diff --git a/test/py/test.py b/test/py/test.py
new file mode 100755
index 000000000000..9c23898774ed
--- /dev/null
+++ b/test/py/test.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2015 Stephen Warren
+# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+# Wrapper script to invoke pytest with the directory name that contains the
+# U-Boot tests.
+
+import os
+import os.path
+import sys
+
+# Get rid of argv[0]
+sys.argv.pop(0)
+
+# argv; py.test test_directory_name user-supplied-arguments
+args = ["py.test", os.path.dirname(__file__) + "/tests"]
+args.extend(sys.argv)
+
+try:
+ os.execvp("py.test", args)
+except:
+ # Log full details of any exception for detailed analysis
+ import traceback
+ traceback.print_exc()
+ # Hint to the user that they likely simply haven't installed the required
+ # dependencies.
+ print >>sys.stderr, """
+exec(py.test) failed; perhaps you are missing some dependencies?
+See test/py/README.md for the list."""
diff --git a/test/py/tests/test_000_version.py b/test/py/tests/test_000_version.py
new file mode 100644
index 000000000000..d262f0534efd
--- /dev/null
+++ b/test/py/tests/test_000_version.py
@@ -0,0 +1,20 @@
+# Copyright (c) 2015 Stephen Warren
+# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+# pytest runs tests the order of their module path, which is related to the
+# filename containing the test. This file is named such that it is sorted
+# first, simply as a very basic sanity check of the functionality of the U-Boot
+# command prompt.
+
+def test_version(u_boot_console):
+ '''Test that the "version" command prints the U-Boot version.'''
+
+ # "version" prints the U-Boot sign-on message. This is usually considered
+ # an error, so that any unexpected reboot causes an error. Here, this
+ # error detection is disabled since the sign-on message is expected.
+ with u_boot_console.disable_check('main_signon'):
+ response = u_boot_console.run_command('version')
+ # Ensure "version" printed what we expected.
+ u_boot_console.validate_version_string_in_text(response)
diff --git a/test/py/tests/test_help.py b/test/py/tests/test_help.py
new file mode 100644
index 000000000000..894f3b5f1700
--- /dev/null
+++ b/test/py/tests/test_help.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2015 Stephen Warren
+# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+def test_help(u_boot_console):
+ '''Test that the "help" command can be executed.'''
+
+ u_boot_console.run_command('help')
diff --git a/test/py/tests/test_unknown_cmd.py b/test/py/tests/test_unknown_cmd.py
new file mode 100644
index 000000000000..2de93e0026ff
--- /dev/null
+++ b/test/py/tests/test_unknown_cmd.py
@@ -0,0 +1,14 @@
+# Copyright (c) 2015 Stephen Warren
+# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+def test_unknown_command(u_boot_console):
+ '''Test that executing an unknown command causes U-Boot to print an
+ error.'''
+
+ # The "unknown command" error is actively expected here,
+ # so error detection for it is disabled.
+ with u_boot_console.disable_check('unknown_command'):
+ response = u_boot_console.run_command('non_existent_cmd')
+ assert('Unknown command \'non_existent_cmd\' - try \'help\'' in response)
diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
new file mode 100644
index 000000000000..520f9a9e9f31
--- /dev/null
+++ b/test/py/u_boot_console_base.py
@@ -0,0 +1,360 @@
+# Copyright (c) 2015 Stephen Warren
+# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+# Common logic to interact with U-Boot via the console. This class provides
+# the interface that tests use to execute U-Boot shell commands and wait for
+# their results. Sub-classes exist to perform board-type-specific setup
+# operations, such as spawning a sub-process for Sandbox, or attaching to the
+# serial console of real hardware.
+
+import multiplexed_log
+import os
+import pytest
+import re
+import sys
+
+# 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_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\'')
+pattern_error_notification = re.compile('## Error: ')
+
+class ConsoleDisableCheck(object):
+ '''Context manager (for Python's with statement) that temporarily disables
+ the specified console output error check. This is useful when deliberately
+ executing a command that is known to trigger one of the error checks, in
+ order to test that the error condition is actually raised. This class is
+ used internally by ConsoleBase::disable_check(); it is not intended for
+ direct usage.'''
+
+ def __init__(self, console, check_type):
+ self.console = console
+ self.check_type = check_type
+
+ def __enter__(self):
+ self.console.disable_check_count[self.check_type] += 1
+
+ def __exit__(self, extype, value, traceback):
+ self.console.disable_check_count[self.check_type] -= 1
+
+class ConsoleBase(object):
+ '''The interface through which test functions interact with the U-Boot
+ console. This primarily involves executing shell commands, capturing their
+ results, and checking for common error conditions. Some common utilities
+ are also provided too.'''
+
+ def __init__(self, log, config, max_fifo_fill):
+ '''Initialize a U-Boot console connection.
+
+ Can only usefully be called by sub-classes.
+
+ Args:
+ log: A mulptiplex_log.Logfile object, to which the U-Boot output
+ will be logged.
+ config: A configuration data structure, as built by conftest.py.
+ max_fifo_fill: The maximum number of characters to send to U-Boot
+ command-line before waiting for U-Boot to echo the characters
+ back. For UART-based HW without HW flow control, this value
+ should be set less than the UART RX FIFO size to avoid
+ overflow, assuming that U-Boot can't keep up with full-rate
+ traffic at the baud rate.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.log = log
+ self.config = config
+ self.max_fifo_fill = max_fifo_fill
+
+ self.logstream = self.log.get_stream('console', sys.stdout)
+
+ # Array slice removes leading/trailing quotes
+ self.prompt = self.config.buildconfig['config_sys_prompt'][1:-1]
+ self.prompt_escaped = re.escape(self.prompt)
+ self.p = None
+ self.disable_check_count = {
+ 'spl_signon': 0,
+ 'main_signon': 0,
+ 'unknown_command': 0,
+ 'error_notification': 0,
+ }
+
+ self.at_prompt = False
+ self.at_prompt_logevt = None
+ self.ram_base = None
+
+ def close(self):
+ '''Terminate the connection to the U-Boot console.
+
+ This function is only useful once all interaction with U-Boot is
+ complete. Once this function is called, data cannot be sent to or
+ received from U-Boot.
+
+ Args:
+ None.
+
+ Returns:
+ Nothing.
+ '''
+
+ if self.p:
+ self.p.close()
+ self.logstream.close()
+
+ def run_command(self, cmd, wait_for_echo=True, send_nl=True,
+ wait_for_prompt=True):
+ '''Execute a command via the U-Boot console.
+
+ The command is always sent to U-Boot.
+
+ U-Boot echoes any command back to its output, and this function
+ typically waits for that to occur. The wait can be disabled by setting
+ wait_for_echo=False, which is useful e.g. when sending CTRL-C to
+ interrupt a long-running command such as "ums".
+
+ Command execution is typically triggered by sending a newline
+ character. This can be disabled by setting send_nl=False, which is
+ also useful when sending CTRL-C.
+
+ This function typically waits for the command to finish executing, and
+ returns the console output that it generated. This can be disabled by
+ setting wait_for_prompt=False, which is useful when invoking a long-
+ running command such as "ums".
+
+ Args:
+ cmd: The command to send.
+ wait_for_each: Boolean indicating whether to wait for U-Boot to
+ echo the command text back to its output.
+ send_nl: Boolean indicating whether to send a newline character
+ after the command string.
+ wait_for_prompt: Boolean indicating whether to wait for the
+ command prompt to be sent by U-Boot. This typically occurs
+ immediately after the command has been executed.
+
+ Returns:
+ If wait_for_prompt == False:
+ Nothing.
+ Else:
+ The output from U-Boot during command execution. In other
+ words, the text U-Boot emitted between the point it echod the
+ command string and emitted the subsequent command prompts.
+ '''
+
+ self.ensure_spawned()
+
+ if self.at_prompt and \
+ self.at_prompt_logevt != self.logstream.logfile.cur_evt:
+ self.logstream.write(self.prompt, implicit=True)
+
+ bad_patterns = []
+ bad_pattern_ids = []
+ if (self.disable_check_count['spl_signon'] == 0 and
+ self.u_boot_spl_signon):
+ bad_patterns.append(self.u_boot_spl_signon_escaped)
+ bad_pattern_ids.append('SPL signon')
+ if self.disable_check_count['main_signon'] == 0:
+ bad_patterns.append(self.u_boot_main_signon_escaped)
+ bad_pattern_ids.append('U-Boot main signon')
+ if self.disable_check_count['unknown_command'] == 0:
+ bad_patterns.append(pattern_unknown_command)
+ bad_pattern_ids.append('Unknown command')
+ if self.disable_check_count['error_notification'] == 0:
+ bad_patterns.append(pattern_error_notification)
+ bad_pattern_ids.append('Error notification')
+ try:
+ self.at_prompt = False
+ if send_nl:
+ cmd += '\n'
+ while cmd:
+ # Limit max outstanding data, so UART FIFOs don't overflow
+ chunk = cmd[:self.max_fifo_fill]
+ cmd = cmd[self.max_fifo_fill:]
+ self.p.send(chunk)
+ if not wait_for_echo:
+ continue
+ chunk = re.escape(chunk)
+ chunk = chunk.replace('\\\n', '[\r\n]')
+ m = self.p.expect([chunk] + bad_patterns)
+ if m != 0:
+ self.at_prompt = False
+ raise Exception('Bad pattern found on console: ' +
+ bad_pattern_ids[m - 1])
+ if not wait_for_prompt:
+ return
+ m = self.p.expect([self.prompt_escaped] + bad_patterns)
+ if m != 0:
+ self.at_prompt = False
+ raise Exception('Bad pattern found on console: ' +
+ bad_pattern_ids[m - 1])
+ self.at_prompt = True
+ self.at_prompt_logevt = self.logstream.logfile.cur_evt
+ # Only strip \r\n; space/TAB might be significant if testing
+ # indentation.
+ return self.p.before.strip('\r\n')
+ except Exception as ex:
+ self.log.error(str(ex))
+ self.cleanup_spawn()
+ raise
+
+ def ctrlc(self):
+ '''Send a CTRL-C character to U-Boot.
+
+ This is useful in order to stop execution of long-running synchronous
+ commands such as "ums".
+
+ Args:
+ None.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.run_command(chr(3), wait_for_echo=False, send_nl=False)
+
+ def ensure_spawned(self):
+ '''Ensure a connection to a correctly running U-Boot instance.
+
+ This may require spawning a new Sandbox process or resetting target
+ hardware, as defined by the implementation sub-class.
+
+ This is an internal function and should not be called directly.
+
+ Args:
+ None.
+
+ Returns:
+ Nothing.
+ '''
+
+ if self.p:
+ return
+ try:
+ self.at_prompt = False
+ self.log.action('Starting U-Boot')
+ self.p = self.get_spawn()
+ # Real targets can take a long time to scroll large amounts of
+ # text if LCD is enabled. This value may need tweaking in the
+ # future, possibly per-test to be optimal. This works for 'help'
+ # on board 'seaboard'.
+ self.p.timeout = 30000
+ self.p.logfile_read = self.logstream
+ if self.config.buildconfig.get('CONFIG_SPL', False) == 'y':
+ self.p.expect([pattern_u_boot_spl_signon])
+ self.u_boot_spl_signon = self.p.after
+ self.u_boot_spl_signon_escaped = re.escape(self.p.after)
+ else:
+ self.u_boot_spl_signon = None
+ self.p.expect([pattern_u_boot_main_signon])
+ self.u_boot_main_signon = self.p.after
+ self.u_boot_main_signon_escaped = re.escape(self.p.after)
+ build_idx = self.u_boot_main_signon.find(', Build:')
+ if build_idx == -1:
+ self.u_boot_version_string = self.u_boot_main_signon
+ else:
+ self.u_boot_version_string = self.u_boot_main_signon[:build_idx]
+ while True:
+ match = self.p.expect([self.prompt_escaped,
+ pattern_stop_autoboot_prompt])
+ if match == 1:
+ self.p.send(chr(3)) # CTRL-C
+ continue
+ break
+ self.at_prompt = True
+ self.at_prompt_logevt = self.logstream.logfile.cur_evt
+ except Exception as ex:
+ self.log.error(str(ex))
+ self.cleanup_spawn()
+ raise
+
+ def cleanup_spawn(self):
+ '''Shut down all interaction with the U-Boot instance.
+
+ This is used when an error is detected prior to re-establishing a
+ connection with a fresh U-Boot instance.
+
+ This is an internal function and should not be called directly.
+
+ Args:
+ None.
+
+ Returns:
+ Nothing.
+ '''
+
+ try:
+ if self.p:
+ self.p.close()
+ except:
+ pass
+ self.p = None
+
+ def validate_version_string_in_text(self, text):
+ '''Assert that a command's output includes the U-Boot signon message.
+
+ This is primarily useful for validating the "version" command without
+ duplicating the signon text regex in a test function.
+
+ Args:
+ text: The command output text to check.
+
+ Returns:
+ Nothing. An exception is raised if the validation fails.
+ '''
+
+ assert(self.u_boot_version_string in text)
+
+ def disable_check(self, check_type):
+ '''Temporarily disable an error check of U-Boot's output.
+
+ Create a new context manager (for use with the "with" statement) which
+ temporarily disables a particular console output error check.
+
+ Args:
+ check_type: The type of error-check to disable. Valid values may
+ be found in self.disable_check_count above.
+
+ Returns:
+ A context manager object.
+ '''
+
+ return ConsoleDisableCheck(self, check_type)
+
+ def find_ram_base(self):
+ '''Find the running U-Boot's RAM location.
+
+ Probe the running U-Boot to determine the address of the first bank
+ of RAM. This is useful for tests that test reading/writing RAM, or
+ load/save files that aren't associated with some standard address
+ typically represented in an environment variable such as
+ ${kernel_addr_r}. The value is cached so that it only needs to be
+ actively read once.
+
+ Args:
+ None.
+
+ Returns:
+ The address of U-Boot's first RAM bank, as an integer.
+ '''
+
+ if self.config.buildconfig.get('config_cmd_bdi', 'n') != 'y':
+ pytest.skip('bdinfo command not supported')
+ if self.ram_base == -1:
+ pytest.skip('Previously failed to find RAM bank start')
+ if self.ram_base is not None:
+ return self.ram_base
+
+ with self.log.section('find_ram_base'):
+ response = self.run_command('bdinfo')
+ for l in response.split('\n'):
+ if '-> start' in l:
+ self.ram_base = int(l.split('=')[1].strip(), 16)
+ break
+ if self.ram_base is None:
+ self.ram_base = -1
+ raise Exception('Failed to find RAM bank start in `bdinfo`')
+
+ return self.ram_base
diff --git a/test/py/u_boot_console_exec_attach.py b/test/py/u_boot_console_exec_attach.py
new file mode 100644
index 000000000000..0ca9e7c178ec
--- /dev/null
+++ b/test/py/u_boot_console_exec_attach.py
@@ -0,0 +1,65 @@
+# Copyright (c) 2015 Stephen Warren
+# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+# Logic to interact with U-Boot running on real hardware, typically via a
+# physical serial port.
+
+import sys
+from u_boot_spawn import Spawn
+from u_boot_console_base import ConsoleBase
+
+class ConsoleExecAttach(ConsoleBase):
+ '''Represents a physical connection to a U-Boot console, typically via a
+ serial port. This implementation executes a sub-process to attach to the
+ console, expecting that the stdin/out of the sub-process will be forwarded
+ to/from the physical hardware. This approach isolates the test infra-
+ structure from the user-/installation-specific details of how to
+ communicate with, and the identity of, serial ports etc.'''
+
+ def __init__(self, log, config):
+ '''Initialize a U-Boot console connection.
+
+ Args:
+ log: A multiplexed_log.Logfile instance.
+ config: A "configuration" object as defined in conftest.py.
+
+ Returns:
+ Nothing.
+ '''
+
+ # The max_fifo_fill value might need tweaking per-board/-SoC?
+ # 1 would be safe anywhere, but is very slow (a pexpect issue?).
+ # 16 is a common FIFO size.
+ # HW flow control would mean this could be infinite.
+ super(ConsoleExecAttach, self).__init__(log, config, max_fifo_fill=16)
+
+ self.log.action('Flashing U-Boot')
+ cmd = ['u-boot-test-flash', config.board_type, config.board_identity]
+ runner = self.log.get_runner(cmd[0], sys.stdout)
+ runner.run(cmd)
+ runner.close()
+
+ def get_spawn(self):
+ '''Connect to a fresh U-Boot instance.
+
+ The target board is reset, so that U-Boot begins running from scratch.
+
+ Args:
+ None.
+
+ Returns:
+ A u_boot_spawn.Spawn object that is attached to U-Boot.
+ '''
+
+ args = [self.config.board_type, self.config.board_identity]
+ s = Spawn(['u-boot-test-console'] + args)
+
+ self.log.action('Resetting board')
+ cmd = ['u-boot-test-reset'] + args
+ runner = self.log.get_runner(cmd[0], sys.stdout)
+ runner.run(cmd)
+ runner.close()
+
+ return s
diff --git a/test/py/u_boot_console_sandbox.py b/test/py/u_boot_console_sandbox.py
new file mode 100644
index 000000000000..88b137e8c3a1
--- /dev/null
+++ b/test/py/u_boot_console_sandbox.py
@@ -0,0 +1,79 @@
+# Copyright (c) 2015 Stephen Warren
+# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+# Logic to interact with the sandbox port of U-Boot, running as a sub-process.
+
+import time
+from u_boot_spawn import Spawn
+from u_boot_console_base import ConsoleBase
+
+class ConsoleSandbox(ConsoleBase):
+ '''Represents a connection to a sandbox U-Boot console, executed as a sub-
+ process.'''
+
+ def __init__(self, log, config):
+ '''Initialize a U-Boot console connection.
+
+ Args:
+ log: A multiplexed_log.Logfile instance.
+ config: A "configuration" object as defined in conftest.py.
+
+ Returns:
+ Nothing.
+ '''
+
+ super(ConsoleSandbox, self).__init__(log, config, max_fifo_fill=1024)
+
+ def get_spawn(self):
+ '''Connect to a fresh U-Boot instance.
+
+ A new sandbox process is created, so that U-Boot begins running from
+ scratch.
+
+ Args:
+ None.
+
+ Returns:
+ A u_boot_spawn.Spawn object that is attached to U-Boot.
+ '''
+
+ return Spawn([self.config.build_dir + '/u-boot'])
+
+ def kill(self, sig):
+ '''Send a specific Unix signal to the sandbox process.
+
+ Args:
+ sig: The Unix signal to send to the process.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.ensure_spawned()
+ self.log.action('kill %d' % sig)
+ self.p.kill(sig)
+
+ def validate_exited(self):
+ '''Determine whether the sandbox process has exited.
+
+ If required, this function waits a reasonable time for the process to
+ exit.
+
+ Args:
+ None.
+
+ Returns:
+ Boolean indicating whether the process has exited.
+ '''
+
+ p = self.p
+ self.p = None
+ for i in xrange(100):
+ ret = not p.isalive()
+ if ret:
+ break
+ time.sleep(0.1)
+ p.close()
+ return ret
diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py
new file mode 100644
index 000000000000..1baee63df25c
--- /dev/null
+++ b/test/py/u_boot_spawn.py
@@ -0,0 +1,174 @@
+# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+# Logic to spawn a sub-process and interact with its stdio.
+
+import os
+import re
+import pty
+import signal
+import select
+import time
+
+class Timeout(Exception):
+ '''An exception sub-class that indicates that a timeout occurred.'''
+ pass
+
+class Spawn(object):
+ '''Represents the stdio of a freshly created sub-process. Commands may be
+ sent to the process, and responses waited for.
+ '''
+
+ def __init__(self, args):
+ '''Spawn (fork/exec) the sub-process.
+
+ Args:
+ args: array of processs arguments. argv[0] is the command to execute.
+
+ Returns:
+ Nothing.
+ '''
+
+ self.waited = False
+ self.buf = ''
+ self.logfile_read = None
+ self.before = ''
+ self.after = ''
+ self.timeout = None
+
+ (self.pid, self.fd) = pty.fork()
+ if self.pid == 0:
+ try:
+ # For some reason, SIGHUP is set to SIG_IGN at this point when
+ # run under "go" (www.go.cd). Perhaps this happens under any
+ # background (non-interactive) system?
+ signal.signal(signal.SIGHUP, signal.SIG_DFL)
+ os.execvp(args[0], args)
+ except:
+ print 'CHILD EXECEPTION:'
+ import traceback
+ traceback.print_exc()
+ finally:
+ os._exit(255)
+
+ self.poll = select.poll()
+ self.poll.register(self.fd, select.POLLIN | select.POLLPRI | select.POLLERR | select.POLLHUP | select.POLLNVAL)
+
+ def kill(self, sig):
+ '''Send unix signal "sig" to the child process.
+
+ Args:
+ sig: The signal number to send.
+
+ Returns:
+ Nothing.
+ '''
+
+ os.kill(self.pid, sig)
+
+ def isalive(self):
+ '''Determine whether the child process is still running.
+
+ Args:
+ None.
+
+ Returns:
+ Boolean indicating whether process is alive.
+ '''
+
+ if self.waited:
+ return False
+
+ w = os.waitpid(self.pid, os.WNOHANG)
+ if w[0] == 0:
+ return True
+
+ self.waited = True
+ return False
+
+ def send(self, data):
+ '''Send data to the sub-process's stdin.
+
+ Args:
+ data: The data to send to the process.
+
+ Returns:
+ Nothing.
+ '''
+
+ os.write(self.fd, data)
+
+ def expect(self, patterns):
+ '''Wait for the sub-process to emit specific data.
+
+ This function waits for the process to emit one pattern from the
+ supplied list of patterns, or for a timeout to occur.
+
+ Args:
+ patterns: A list of strings or regex objects that we expect to
+ see in the sub-process' stdout.
+
+ Returns:
+ The index within the patterns array of the pattern the process
+ emitted.
+
+ Notable exceptions:
+ Timeout, if the process did not emit any of the patterns within
+ the expected time.
+ '''
+
+ for pi in xrange(len(patterns)):
+ if type(patterns[pi]) == type(''):
+ patterns[pi] = re.compile(patterns[pi])
+
+ try:
+ while True:
+ earliest_m = None
+ earliest_pi = None
+ for pi in xrange(len(patterns)):
+ pattern = patterns[pi]
+ m = pattern.search(self.buf)
+ if not m:
+ continue
+ if earliest_m and m.start() > earliest_m.start():
+ continue
+ earliest_m = m
+ earliest_pi = pi
+ if earliest_m:
+ pos = earliest_m.start()
+ posafter = earliest_m.end() + 1
+ self.before = self.buf[:pos]
+ self.after = self.buf[pos:posafter]
+ self.buf = self.buf[posafter:]
+ return earliest_pi
+ events = self.poll.poll(self.timeout)
+ if not events:
+ raise Timeout()
+ c = os.read(self.fd, 1024)
+ if not c:
+ raise EOFError()
+ if self.logfile_read:
+ self.logfile_read.write(c)
+ self.buf += c
+ finally:
+ if self.logfile_read:
+ self.logfile_read.flush()
+
+ def close(self):
+ '''Close the stdio connection to the sub-process.
+
+ This also waits a reasonable time for the sub-process to stop running.
+
+ Args:
+ None.
+
+ Returns:
+ Nothing.
+ '''
+
+ os.close(self.fd)
+ for i in xrange(100):
+ if not self.isalive():
+ break
+ time.sleep(0.1)
--
2.7.0
3
16

[U-Boot] [PATCHv2 1/3] armv8: fsl-layerscape: add i/d-cache enable function to enable_caches
by Zhiqiang Hou 21 Jan '16
by Zhiqiang Hou 21 Jan '16
21 Jan '16
From: Hou Zhiqiang <Zhiqiang.Hou(a)freescale.com>
This function assume that the d-cache and MMU has been enabled earlier,
so it just created MMU table in main memory. But the assumption is not
always correct, for example, the early setup is done in EL3, while
enable_caches() is called when the PE has turned into another EL.
Define the function mmu_setup() for fsl-layerscape to cover the weak
one.
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou(a)freescale.com>
---
Tested on LS1043A RDB board
V2:
- Replace patch [PATCH 1/3] ARMv8/layerscape: Add mmu_init API
arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index 6ea28ed..3147870 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -393,15 +393,21 @@ int arch_cpu_init(void)
return 0;
}
+void mmu_setup(void)
+{
+ final_mmu_setup();
+}
+
/*
- * This function is called from lib/board.c.
- * It recreates MMU table in main memory. MMU and d-cache are enabled earlier.
- * There is no need to disable d-cache for this operation.
+ * This function is called from common/board_r.c.
+ * It recreates MMU table in main memory.
*/
void enable_caches(void)
{
- final_mmu_setup();
+ mmu_setup();
__asm_invalidate_tlb_all();
+ icache_enable();
+ dcache_enable();
}
#endif
--
2.1.0.27.g96db324
1
0
Fill the right command type when using CMD12 to stop data transfer.
Signed-off-by: Yangbo Lu <yangbo.lu(a)nxp.com>
---
Changes for v2:
- Removed fix for T4160 because other patch had done that
---
drivers/mmc/fsl_esdhc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index c5054d6..16fb01a 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -107,7 +107,7 @@ static uint esdhc_xfertyp(struct mmc_cmd *cmd, struct mmc_data *data)
#if defined(CONFIG_MX53) || defined(CONFIG_PPC_T4240) || \
defined(CONFIG_LS102XA) || defined(CONFIG_FSL_LAYERSCAPE) || \
- defined(CONFIG_PPC_T4160)
+ defined(CONFIG_PPC_T4160) || defined(CONFIG_PPC_T4080)
if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
xfertyp |= XFERTYP_CMDTYP_ABORT;
#endif
--
2.1.0.27.g96db324
4
7
The below patches depend on the series patches(http://patchwork.ozlabs.org/patch/567250/).
[PATCH v3 1/3] armv8/ls1043aqds: Select lpuart pins of various muxes
[PATCH v3 2/3] armv8/ls1043aqds: Spilt off board device tree
[PATCH v3 3/3] armv8/ls1043aqds: Add lpuart support
2
7

[U-Boot] [PATCH v2 00/55] dm: x86: Convert ivybridge code to use driver model
by Simon Glass 21 Jan '16
by Simon Glass 21 Jan '16
21 Jan '16
At present ivybridge is the only x86 implementation that includes a
reasonably full board init. This means there is a lot more code than with
a board that uses FSP (even then we don't have memory init or graphics init
code).
This code does not use proper drivers for the devices and so its use of
driver model is limited. This series refactors the code to improve this. In
particular it drops use of the old x86_pci_...() API in favour of
dm_pci_...(). The latter requires that each PCI device has a driver.
A few very minor driver model improvements are added to support this. Also a
Northbridge uclass is added - this could instead be done with the syscon, so
comments are well as to which is best.
A small amount of additional work will be needed to remove use of the
x86_pci_...() in arch/x86, but this series represents the bulk of it.
Changes in v2:
- Fix -EEPFNOSUPPORT typo
- Add missing of_match member init so that ehci_pci_ids[] is used
- Add missing 'given' word
- Drop unnecessary/incorrect non-DM code in dm_pci_run_vga_bios()
- Drop unused 'gen-dec' device tree property
- Drop the init() method in the PCH
- Rename this commit from 'x86: ivybridge: Set up the PCH init'
- Drop unnecessary DECLARE_GLOBAL_DATA_PTR
- Drop explicit PCH probe
- Drop LPC init method
- Rename patch from 'Add an init() method for the bd82x6x LPC'
- Update to drop LPC init method and use probe() instead
- Fix 'baords' typo in the commit message
- Add a comment as to why we are initing the devices again
- Drop northbridge_enable()
- Rename from 'Move northbridge setup to the northbridge driver'
- Drop this unnecessary init
- Rename the AHCI uclass to DISK
- Update to use the disk uclass
- Update to use the disk uclass
- Drop unnecessary IRQ and command register init
- Update to use LPC probe() method instead of init()
- Drop the special compatible string in chromebook_link.dts
- Expand the Kconfig help a little
- Avoid needing the pch device to set up the USB bar
- Fix incorrect bits in bridge_silicon_revision() comment
- Rename from 'Convert EHCI init to use the DM PCI API'
- Drop this init
- Fix the USB PCI address in the device tree
- Enable SYSCON and REGMAP for panther to avoid a build error
- Drop bd82x6x_pci_init() function and associated DM-conversion patch
- Drop LPC init method an 'Add an init() method to the LPC uclass' patch
Simon Glass (55):
dm: core: Display the error number when driver binding fails
dm: usb: Add a compatible string for PCI EHCI controller
dm: syscon: Allow finding devices by driver data
dm: pci: Convert bios_emu to use the driver model PCI API
x86: ivybridge: Set up the LPC device using driver model
x86: ivybridge: Move lpc_early_init() to probe()
x86: ivybridge: Move more init to the probe() function
x86: ivybridge: Rename bd82x6x_init()
dm: x86: Add a northbridge uclass
x86: ivybridge: Add a driver for the bd82x6x northbridge
x86: ivybridge: Move northbridge init into the probe() method
x86: ivybridge: Move LPC and PCH init into northbridge probe()
x86: ivybridge: Rename lpc_init() to lpc_init_extra()
x86: ivybridge: Probe the LPC in CPU init
x86: ivybridge: Move graphics init much later
x86: ivybridge: Move sandybridge init to the lpc probe() method
x86: ivybridge: Move GPIO init to the LPC init() method
x86: ivybridge: Use common CPU init code
x86: ivybridge: Move CPU init code into the driver
x86: ivybridge: Set up the thermal target correctly
x86: ivybridge: Drop the dead MTRR code
x86: ivybridge: Move early init code into northbridge.c
x86: Make x86_init_cpus() static
x86: Don't show an error when the MRC cache is up to date
x86: Bring up northbridge, pch and lpc after the CPUs
x86: ivybridge: Move northbridge and PCH init into drivers
x86: ivybridge: Use driver model PCI API in bd82x6x.c
x86: ivybridge: Drop unnecessary northbridge setup
ahci: Add a disk-controller uclass
x86: ivybridge: Do the SATA init before relocation
x86: ivybridge: Drop the unused bd82x6x_init_extra()
x86: ivybridge: Use the SATA driver to do the init
x86: ivybridge: Use driver model PCI API in sata.c
x86: ivybridge: Move lpc_enable() into gma.c
x86: ivybridge: Move LPC init into the LPC probe() method
x86: ivybridge: Drop the special PCI driver
x86: ivybridge: Convert lpc init code to DM PCI API
x86: Enable DM_USB for link and panther
x86: i2c: Add a stub driver for Intel I2C/SMbus
x86: ivybridge: Use the I2C driver to perform SMbus init
x86: ivybridge: Convert enable_usb_bar() to use DM PCI API
x86: ivybridge: Convert dram_init() to use DM PCI API
x86: ivybridge: Convert sdram_initialise() to use DM PCI API
x86: chromebook_link: Enable the syscon uclass
x86: ivybridge: Convert SDRAM init to use driver model
x86: ivybridge: Convert report_platform to DM PCI API
x86: ivybridge: Convert pch.c to use DM PCI API
x86: ivybridge: Move code from pch.c to bd82x6x.c
x86: ivybridge: Sort out the calls to bridge_silicon_revision()
x86: ivybridge: Drop special EHCI init
x86: ivybridge: Drop XHCI support
x86: ivybridge: Drop the SMM-locking code
x86: Set up a shared syscon numbering schema
x86: ivybridge: Use syscon for the GMA device
x86: fdt: Drop the unused compatible strings in fdtdec
arch/x86/cpu/cpu.c | 22 +-
arch/x86/cpu/ivybridge/Makefile | 5 -
arch/x86/cpu/ivybridge/bd82x6x.c | 217 ++++++++++------
arch/x86/cpu/ivybridge/cpu.c | 146 +++--------
arch/x86/cpu/ivybridge/early_init.c | 147 -----------
arch/x86/cpu/ivybridge/early_me.c | 70 +++--
arch/x86/cpu/ivybridge/gma.c | 114 ++++++--
arch/x86/cpu/ivybridge/lpc.c | 301 ++++++++++++----------
arch/x86/cpu/ivybridge/model_206ax.c | 126 ++++-----
arch/x86/cpu/ivybridge/northbridge.c | 126 ++++++---
arch/x86/cpu/ivybridge/pch.c | 123 ---------
arch/x86/cpu/ivybridge/pci.c | 67 -----
arch/x86/cpu/ivybridge/report_platform.c | 11 +-
arch/x86/cpu/ivybridge/sata.c | 132 ++++++----
arch/x86/cpu/ivybridge/sdram.c | 64 +++--
arch/x86/cpu/ivybridge/usb_ehci.c | 29 ---
arch/x86/cpu/ivybridge/usb_xhci.c | 32 ---
arch/x86/dts/chromebook_link.dts | 86 ++++++-
arch/x86/include/asm/arch-ivybridge/bd82x6x.h | 23 +-
arch/x86/include/asm/arch-ivybridge/me.h | 45 +++-
arch/x86/include/asm/arch-ivybridge/pch.h | 27 +-
arch/x86/include/asm/arch-ivybridge/sandybridge.h | 13 +-
arch/x86/include/asm/cpu.h | 11 +
arch/x86/include/asm/u-boot-x86.h | 2 -
arch/x86/lib/Makefile | 1 +
arch/x86/lib/mrccache.c | 6 +-
arch/x86/lib/northbridge-uclass.c | 15 ++
board/google/chromebook_link/link.c | 8 -
configs/chromebook_link_defconfig | 9 +
configs/chromebox_panther_defconfig | 4 +
drivers/bios_emulator/atibios.c | 109 +++++++-
drivers/bios_emulator/bios.c | 39 +++
drivers/block/Kconfig | 9 +
drivers/block/Makefile | 1 +
drivers/block/disk-uclass.c | 14 +
drivers/core/lists.c | 3 +-
drivers/core/syscon-uclass.c | 31 ++-
drivers/i2c/Kconfig | 9 +
drivers/i2c/Makefile | 1 +
drivers/i2c/intel_i2c.c | 75 ++++++
drivers/pci/pci_rom.c | 6 +-
drivers/usb/host/ehci-pci.c | 6 +
include/bios_emul.h | 19 +-
include/dm/uclass-id.h | 2 +
include/fdtdec.h | 5 -
include/syscon.h | 14 +
lib/fdtdec.c | 5 -
test/dm/syscon.c | 17 ++
48 files changed, 1288 insertions(+), 1059 deletions(-)
delete mode 100644 arch/x86/cpu/ivybridge/early_init.c
delete mode 100644 arch/x86/cpu/ivybridge/pch.c
delete mode 100644 arch/x86/cpu/ivybridge/pci.c
delete mode 100644 arch/x86/cpu/ivybridge/usb_ehci.c
delete mode 100644 arch/x86/cpu/ivybridge/usb_xhci.c
create mode 100644 arch/x86/lib/northbridge-uclass.c
create mode 100644 drivers/block/disk-uclass.c
create mode 100644 drivers/i2c/intel_i2c.c
--
2.6.0.rc2.230.g3dd15c0
3
129

[U-Boot] [PATCH 1/2] i2c: mvtwsi: Fix mvtwsi not working on sun6i and newer sunxi SoCs
by Hans de Goede 21 Jan '16
by Hans de Goede 21 Jan '16
21 Jan '16
On sun6i and newer IFLG is a write-clear bit which is cleared by writing 1,
rather then a normal r/w bit which is cleared by writing 0.
Signed-off-by: Hans de Goede <hdegoede(a)redhat.com>
---
drivers/i2c/mvtwsi.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index f20d1b2..698bfc1 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -73,6 +73,17 @@ struct mvtwsi_registers {
#define MVTWSI_CONTROL_INTEN 0x00000080
/*
+ * On sun6i and newer IFLG is a write-clear bit which is cleared by writing 1,
+ * on other platforms it is a normal r/w bit which is cleared by writing 0.
+ */
+
+#ifdef CONFIG_SUNXI_GEN_SUN6I
+#define MVTWSI_CONTROL_CLEAR_IFLG 0x00000008
+#else
+#define MVTWSI_CONTROL_CLEAR_IFLG 0x00000000
+#endif
+
+/*
* Status register values -- only those expected in normal master
* operation on non-10-bit-address devices; whatever status we don't
* expect in nominal conditions (bus errors, arbitration losses,
@@ -189,7 +200,7 @@ static int twsi_start(struct i2c_adapter *adap, int expected_status)
/* globally set TWSIEN in case it was not */
twsi_control_flags |= MVTWSI_CONTROL_TWSIEN;
/* assert START */
- writel(twsi_control_flags | MVTWSI_CONTROL_START, &twsi->control);
+ writel(twsi_control_flags | MVTWSI_CONTROL_START | MVTWSI_CONTROL_CLEAR_IFLG, &twsi->control);
/* wait for controller to process START */
return twsi_wait(adap, expected_status);
}
@@ -204,7 +215,7 @@ static int twsi_send(struct i2c_adapter *adap, u8 byte, int expected_status)
/* put byte in data register for sending */
writel(byte, &twsi->data);
/* clear any pending interrupt -- that'll cause sending */
- writel(twsi_control_flags, &twsi->control);
+ writel(twsi_control_flags | MVTWSI_CONTROL_CLEAR_IFLG, &twsi->control);
/* wait for controller to receive byte and check ACK */
return twsi_wait(adap, expected_status);
}
@@ -224,7 +235,7 @@ static int twsi_recv(struct i2c_adapter *adap, u8 *byte)
else
expected_status = MVTWSI_STATUS_DATA_R_NAK;
/* acknowledge *previous state* and launch receive */
- writel(twsi_control_flags, &twsi->control);
+ writel(twsi_control_flags | MVTWSI_CONTROL_CLEAR_IFLG, &twsi->control);
/* wait for controller to receive byte and assert ACK or NAK */
status = twsi_wait(adap, expected_status);
/* if we did receive expected byte then store it */
@@ -246,7 +257,7 @@ static int twsi_stop(struct i2c_adapter *adap, int status)
/* assert STOP */
control = MVTWSI_CONTROL_TWSIEN | MVTWSI_CONTROL_STOP;
- writel(control, &twsi->control);
+ writel(control | MVTWSI_CONTROL_CLEAR_IFLG, &twsi->control);
/* wait for IDLE; IFLG won't rise so twsi_wait() is no use. */
do {
stop_status = readl(&twsi->status);
--
2.5.0
2
3