提交 f9e3d2e1 编写于 作者: T Tom Rini

Merge tag 'dm-pull-12jun20' of git://git.denx.de/u-boot-dm into next

patman improvements to allow it to work with Zephyr
change to how sequence numbers are assigned to devices
minor fixes and improvements
......@@ -698,6 +698,7 @@ S: Maintained
T: git https://gitlab.denx.de/u-boot/u-boot.git
F: common/log*
F: cmd/log.c
F: doc/develop/logging.rst
F: test/log/
F: test/py/tests/test_log.py
......
......@@ -86,8 +86,19 @@
&fec {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_fec>;
phy-handle = <&ethphy0>;
phy-mode = "rmii";
status = "okay";
mdio {
#address-cells = <1>;
#size-cells = <0>;
ethphy0: ethernet-phy@0 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <0>;
};
};
};
&i2c1 {
......
......@@ -147,12 +147,12 @@
};
lcdif: lcdif@402b8000 {
compatible = "fsl,imxrt-lcdif";
reg = <0x402b8000 0x10000>;
interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMXRT1050_CLK_LCDIF>;
clock-names = "per";
status = "disabled";
compatible = "fsl,imxrt-lcdif";
reg = <0x402b8000 0x4000>;
interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMXRT1050_CLK_LCDIF>;
clock-names = "per";
status = "disabled";
};
};
};
......@@ -274,6 +274,7 @@ struct src {
#define SRC_DDRC_RCR_DDRC_CORE_RST_OFFSET 1
#define SRC_DDRC_RCR_DDRC_CORE_RST_MASK (1 << 1)
#define SRC_DDRC_RCR_DDRC_PRST_MASK (1 << 0)
/* GPR0 Bit Fields */
#define IOMUXC_GPR_GPR0_DMAREQ_MUX_SEL0_MASK 0x1u
......
......@@ -23,7 +23,7 @@ config IMX_RDC
config IMX_BOOTAUX
bool "Support boot auxiliary core"
depends on ARCH_MX7 || ARCH_MX6 || ARCH_VF610
depends on ARCH_MX7 || ARCH_MX6 || ARCH_VF610 || ARCH_IMX8M
help
bootaux [addr] to boot auxiliary core.
......
......@@ -62,6 +62,23 @@ cat << __HEADER_EOF
compression = "none";
load = <$BL33_LOAD_ADDR>;
};
__HEADER_EOF
cnt=1
for dtname in $*
do
cat << __FDT_IMAGE_EOF
fdt@$cnt {
description = "$(basename $dtname .dtb)";
data = /incbin/("$dtname");
type = "flat_dt";
compression = "none";
};
__FDT_IMAGE_EOF
cnt=$((cnt+1))
done
cat << __HEADER_EOF
atf@1 {
description = "ARM Trusted Firmware";
os = "arm-trusted-firmware";
......@@ -88,20 +105,6 @@ cat << __HEADER_EOF
__HEADER_EOF
fi
cnt=1
for dtname in $*
do
cat << __FDT_IMAGE_EOF
fdt@$cnt {
description = "$(basename $dtname .dtb)";
data = /incbin/("$dtname");
type = "flat_dt";
compression = "none";
};
__FDT_IMAGE_EOF
cnt=$((cnt+1))
done
cat << __CONF_HEADER_EOF
};
configurations {
......
......@@ -13,6 +13,7 @@
#include <asm/arch/crm_regs.h>
#include <asm/arch/mx7-ddr.h>
#include <common.h>
#include <linux/delay.h>
/*
* Routine: mx7_dram_cfg
......@@ -37,8 +38,23 @@ void mx7_dram_cfg(struct ddrc *ddrc_regs_val, struct ddrc_mp *ddrc_mp_val,
(struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
int i;
/* Assert DDR Controller preset and DDR PHY reset */
writel(SRC_DDRC_RCR_DDRC_CORE_RST_MASK, &src_regs->ddrc_rcr);
/*
* iMX7D RM 9.2.4.9.3 Power removal flow Table 9-11. Re-enabling power
* row 2 says "Reset controller / PHY by driving core_ddrc_rst = 0 ,
* aresetn_n = 0, presetn = 0. That means reset everything.
*/
writel(SRC_DDRC_RCR_DDRC_CORE_RST_MASK | SRC_DDRC_RCR_DDRC_PRST_MASK,
&src_regs->ddrc_rcr);
/*
* iMX7D RM 6.2.7.26 SRC_DDRC_RCR says wait 30 cycles (of unknown).
* If we assume this is 30 cycles at 100 MHz (about the rate of a
* DRAM bus), that's 300 nS, so waiting 10 uS is more then plenty.
*/
udelay(10);
/* De-assert DDR Controller 'preset' and DDR PHY reset */
clrbits_le32(&src_regs->ddrc_rcr, SRC_DDRC_RCR_DDRC_PRST_MASK);
/* DDR controller configuration */
writel(ddrc_regs_val->mstr, &ddrc_regs->mstr);
......@@ -71,7 +87,7 @@ void mx7_dram_cfg(struct ddrc *ddrc_regs_val, struct ddrc_mp *ddrc_mp_val,
writel(ddrc_regs_val->odtcfg, &ddrc_regs->odtcfg);
writel(ddrc_regs_val->odtmap, &ddrc_regs->odtmap);
/* De-assert DDR Controller preset and DDR PHY reset */
/* De-assert DDR Controller 'core_ddrc_rstn' and 'aresetn' */
clrbits_le32(&src_regs->ddrc_rcr, SRC_DDRC_RCR_DDRC_CORE_RST_MASK);
/* PHY configuration */
......
......@@ -23,8 +23,8 @@
pci0 = &pci0;
pci1 = &pci1;
pci2 = &pci2;
remoteproc1 = &rproc_1;
remoteproc2 = &rproc_2;
remoteproc0 = &rproc_1;
remoteproc1 = &rproc_2;
rtc0 = &rtc_0;
rtc1 = &rtc_1;
spi0 = "/spi@0";
......@@ -810,6 +810,8 @@
hub {
compatible = "usb-hub";
usb,device-class = <9>;
#address-cells = <1>;
#size-cells = <0>;
hub-emul {
compatible = "sandbox,usb-hub";
#address-cells = <1>;
......@@ -838,6 +840,13 @@
};
};
usbstor@1 {
reg = <1>;
};
usbstor@3 {
reg = <3>;
};
};
};
......
U-Boot for the NXP i.MX8MP EVK board
Quick Start
===========
- Build the ARM Trusted firmware binary
- Get the firmware-imx package
- Build U-Boot
- Boot
Get and Build the ARM Trusted firmware
======================================
Note: $(srctree) is the U-Boot source directory
Get ATF from: https://source.codeaurora.org/external/imx/imx-atf
branch: imx_5.4.3_2.0.0
$ make PLAT=imx8mp bl31
$ sudo cp build/imx8mp/release/bl31.bin $(srctree)
Get the ddr firmware
====================
$ wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.7.bin
$ chmod +x firmware-imx-8.7.bin
$ ./firmware-imx-8.7
$ sudo cp firmware-imx-8.7/firmware/ddr/synopsys/lpddr4_pmu_train_1d_dmem_201904.bin $(srctree)/lpddr4_pmu_train_1d_dmem.bin
$ sudo cp firmware-imx-8.7/firmware/ddr/synopsys/lpddr4_pmu_train_1d_imem_201904.bin $(srctree)/lpddr4_pmu_train_1d_imem.bin
$ sudo cp firmware-imx-8.7/firmware/ddr/synopsys/lpddr4_pmu_train_2d_dmem_201904.bin $(srctree)/lpddr4_pmu_train_2d_dmem.bin
$ sudo cp firmware-imx-8.7/firmware/ddr/synopsys/lpddr4_pmu_train_2d_imem_201904.bin $(srctree)/lpddr4_pmu_train_2d_imem.bin
Build U-Boot
============
$ export CROSS_COMPILE=aarch64-poky-linux-
$ make imx8mp_evk_defconfig
$ export ATF_LOAD_ADDR=0x960000
$ make flash.bin
Burn the flash.bin to the MicroSD card at offset 32KB
$sudo dd if=flash.bin of=/dev/sd[x] bs=1K seek=32; sync
Boot
====
Set Boot switch to SD boot
Use /dev/ttyUSB2 for U-Boot console
......@@ -29,11 +29,6 @@
#include <mmc.h>
#include <asm/arch/ddr.h>
#include <dm/uclass.h>
#include <dm/device.h>
#include <dm/uclass-internal.h>
#include <dm/device-internal.h>
DECLARE_GLOBAL_DATA_PTR;
int spl_board_boot_device(enum boot_device boot_dev_spl)
......@@ -48,16 +43,7 @@ void spl_dram_init(void)
void spl_board_init(void)
{
struct udevice *dev;
int ret;
puts("Normal Boot\n");
ret = uclass_get_device_by_name(UCLASS_CLK,
"clock-controller@30380000",
&dev);
if (ret < 0)
printf("Failed to find clock node. Check device tree\n");
}
#define I2C_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PE)
......@@ -118,6 +104,7 @@ int board_fit_config_name_match(const char *name)
}
#endif
/* Do not use BSS area in this phase */
void board_init_f(ulong dummy)
{
int ret;
......@@ -128,19 +115,14 @@ void board_init_f(ulong dummy)
board_early_init_f();
timer_init();
preloader_console_init();
/* Clear the BSS. */
memset(__bss_start, 0, __bss_end - __bss_start);
ret = spl_init();
ret = spl_early_init();
if (ret) {
debug("spl_init() failed: %d\n", ret);
hang();
}
preloader_console_init();
enable_tzc380();
setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
......@@ -149,6 +131,4 @@ void board_init_f(ulong dummy)
/* DDR initialization */
spl_dram_init();
board_init_r(NULL, 0);
}
......@@ -353,24 +353,28 @@ int board_late_init(void)
ret = splash_screen_prepare();
if (ret < 0)
return ret;
goto splasherr;
len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE;
ret = gunzip(dst + 2, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE - 2,
(uchar *)addr, &len);
if (ret) {
printf("Error: no valid bmp or bmp.gz image at %lx\n", addr);
free(dst);
return ret;
goto splasherr;
}
ret = uclass_get_device(UCLASS_VIDEO, 0, &dev);
if (ret)
return ret;
goto splasherr;
ret = video_bmp_display(dev, (ulong)dst + 2, xpos, ypos, true);
if (ret)
return ret;
goto splasherr;
return 0;
splasherr:
free(dst);
#endif
return 0;
}
......
......@@ -14,10 +14,18 @@ static char log_fmt_chars[LOGF_COUNT] = "clFLfm";
static int do_log_level(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
if (argc > 1)
gd->default_log_level = simple_strtol(argv[1], NULL, 10);
else
if (argc > 1) {
long log_level = simple_strtol(argv[1], NULL, 10);
if (log_level < 0 || log_level > _LOG_MAX_LEVEL) {
printf("Only log levels <= %d are supported\n",
_LOG_MAX_LEVEL);
return CMD_RET_FAILURE;
}
gd->default_log_level = log_level;
} else {
printf("Default log level: %d\n", gd->default_log_level);
}
return 0;
}
......
......@@ -647,28 +647,12 @@ config LOG
discarded if not needed. Logging supports various categories and
levels of severity.
config SPL_LOG
bool "Enable logging support in SPL"
depends on LOG
help
This enables support for logging of status and debug messages. These
can be displayed on the console, recorded in a memory buffer, or
discarded if not needed. Logging supports various categories and
levels of severity.
config TPL_LOG
bool "Enable logging support in TPL"
depends on LOG
help
This enables support for logging of status and debug messages. These
can be displayed on the console, recorded in a memory buffer, or
discarded if not needed. Logging supports various categories and
levels of severity.
if LOG
config LOG_MAX_LEVEL
int "Maximum log level to record"
depends on LOG
default 5
default 6
range 0 9
help
This selects the maximum log level that will be recorded. Any value
higher than this will be ignored. If possible log statements below
......@@ -685,14 +669,15 @@ config LOG_MAX_LEVEL
8 - debug content
9 - debug hardware I/O
config SPL_LOG_MAX_LEVEL
int "Maximum log level to record in SPL"
depends on SPL_LOG
default 3
config LOG_DEFAULT_LEVEL
int "Default logging level to display"
default LOG_MAX_LEVEL
range 0 LOG_MAX_LEVEL
help
This selects the maximum log level that will be recorded. Any value
higher than this will be ignored. If possible log statements below
this level will be discarded at build time. Levels:
This is the default logging level set when U-Boot starts. It can
be adjusted later using the 'log level' command. Note that setting
this to a value above LOG_MAX_LEVEL will be ineffective, since the
higher levels are not compiled in to U-Boot.
0 - emergency
1 - alert
......@@ -705,10 +690,38 @@ config SPL_LOG_MAX_LEVEL
8 - debug content
9 - debug hardware I/O
config TPL_LOG_MAX_LEVEL
int "Maximum log level to record in TPL"
depends on TPL_LOG
config LOG_CONSOLE
bool "Allow log output to the console"
default y
help
Enables a log driver which writes log records to the console.
Generally the console is the serial port or LCD display. Only the
log message is shown - other details like level, category, file and
line number are omitted.
config LOG_SYSLOG
bool "Log output to syslog server"
depends on NET
help
Enables a log driver which broadcasts log records via UDP port 514
to syslog servers.
config SPL_LOG
bool "Enable logging support in SPL"
depends on LOG
help
This enables support for logging of status and debug messages. These
can be displayed on the console, recorded in a memory buffer, or
discarded if not needed. Logging supports various categories and
levels of severity.
if SPL_LOG
config SPL_LOG_MAX_LEVEL
int "Maximum log level to record in SPL"
depends on SPL_LOG
default 3
range 0 9
help
This selects the maximum log level that will be recorded. Any value
higher than this will be ignored. If possible log statements below
......@@ -725,14 +738,37 @@ config TPL_LOG_MAX_LEVEL
8 - debug content
9 - debug hardware I/O
config LOG_DEFAULT_LEVEL
int "Default logging level to display"
default 6
config SPL_LOG_CONSOLE
bool "Allow log output to the console in SPL"
default y
help
This is the default logging level set when U-Boot starts. It can
be adjusted later using the 'log level' command. Note that setting
this to a value above LOG_MAX_LEVEL will be ineffective, since the
higher levels are not compiled in to U-Boot.
Enables a log driver which writes log records to the console.
Generally the console is the serial port or LCD display. Only the
log message is shown - other details like level, category, file and
line number are omitted.
endif
config TPL_LOG
bool "Enable logging support in TPL"
depends on LOG
help
This enables support for logging of status and debug messages. These
can be displayed on the console, recorded in a memory buffer, or
discarded if not needed. Logging supports various categories and
levels of severity.
if TPL_LOG
config TPL_LOG_MAX_LEVEL
int "Maximum log level to record in TPL"
depends on TPL_LOG
default 3
range 0 9
help
This selects the maximum log level that will be recorded. Any value
higher than this will be ignored. If possible log statements below
this level will be discarded at build time. Levels:
0 - emergency
1 - alert
......@@ -745,29 +781,8 @@ config LOG_DEFAULT_LEVEL
8 - debug content
9 - debug hardware I/O
config LOG_CONSOLE
bool "Allow log output to the console"
depends on LOG
default y
help
Enables a log driver which writes log records to the console.
Generally the console is the serial port or LCD display. Only the
log message is shown - other details like level, category, file and
line number are omitted.
config SPL_LOG_CONSOLE
bool "Allow log output to the console in SPL"
depends on SPL_LOG
default y
help
Enables a log driver which writes log records to the console.
Generally the console is the serial port or LCD display. Only the
log message is shown - other details like level, category, file and
line number are omitted.
config TPL_LOG_CONSOLE
bool "Allow log output to the console in TPL"
depends on TPL_LOG
default y
help
Enables a log driver which writes log records to the console.
......@@ -775,26 +790,10 @@ config TPL_LOG_CONSOLE
log message is shown - other details like level, category, file and
line number are omitted.
config LOG_SYSLOG
bool "Log output to syslog server"
depends on LOG && NET
help
Enables a log driver which broadcasts log records via UDP port 514
to syslog servers.
config LOG_TEST
bool "Provide a test for logging"
depends on LOG && UNIT_TEST
default y if SANDBOX
help
This enables a 'log test' command to test logging. It is normally
executed from a pytest and simply outputs logging information
in various different ways to test that the logging system works
correctly with various settings.
endif
config LOG_ERROR_RETURN
bool "Log all functions which return an error"
depends on LOG
help
When an error is returned in U-Boot it is sometimes difficult to
figure out the root cause. For example, reading from SPI flash may
......@@ -805,6 +804,18 @@ config LOG_ERROR_RETURN
You can add log_ret() to all functions which return an error code.
config LOG_TEST
bool "Provide a test for logging"
depends on UNIT_TEST
default y if SANDBOX
help
This enables a 'log test' command to test logging. It is normally
executed from a pytest and simply outputs logging information
in various different ways to test that the logging system works
correctly with various settings.
endif
endmenu
config SUPPORT_RAW_INITRD
......
......@@ -71,7 +71,7 @@ CONFIG_CMD_FAT=y
CONFIG_CMD_FS_GENERIC=y
CONFIG_CMD_MTDPARTS=y
CONFIG_MTDIDS_DEFAULT="nor0=02008000.spi.1"
CONFIG_MTDPARTS_DEFAULT="mtdparts=02008000.spi.1:128k(SPL),1m(u-boot),64k(env1),64k(env2),4m(swu-kernel),16m(swu-initramfs),1m(factory),-(reserved)"
CONFIG_MTDPARTS_DEFAULT="mtdparts=02008000.spi.1:128k(SPL),1m(u-boot),64k(env1),64k(env2),6m(swu-kernel),20m(swu-initramfs),3840k(reserved),1m(factory)"
# CONFIG_SPL_EFI_PARTITION is not set
CONFIG_OF_CONTROL=y
CONFIG_DEFAULT_DEVICE_TREE="imx6q-display5"
......
......@@ -73,7 +73,7 @@ CONFIG_CMD_FAT=y
CONFIG_CMD_FS_GENERIC=y
CONFIG_CMD_MTDPARTS=y
CONFIG_MTDIDS_DEFAULT="nor0=02008000.spi.1"
CONFIG_MTDPARTS_DEFAULT="mtdparts=02008000.spi.1:128k(SPL),1m(u-boot),64k(env1),64k(env2),4m(swu-kernel),16m(swu-initramfs),1m(factory),-(reserved)"
CONFIG_MTDPARTS_DEFAULT="mtdparts=02008000.spi.1:128k(SPL),1m(u-boot),64k(env1),64k(env2),6m(swu-kernel),20m(swu-initramfs),3840k(reserved),1m(factory)"
# CONFIG_SPL_EFI_PARTITION is not set
CONFIG_PARTITION_TYPE_GUID=y
CONFIG_OF_CONTROL=y
......
......@@ -100,5 +100,4 @@ CONFIG_SPL_SYSRESET=y
CONFIG_SYSRESET_PSCI=y
CONFIG_SYSRESET_WATCHDOG=y
CONFIG_DM_THERMAL=y
# CONFIG_WATCHDOG is not set
CONFIG_IMX_WATCHDOG=y
......@@ -85,5 +85,4 @@ CONFIG_SPL_SYSRESET=y
CONFIG_SYSRESET_PSCI=y
CONFIG_SYSRESET_WATCHDOG=y
CONFIG_DM_THERMAL=y
# CONFIG_WATCHDOG is not set
CONFIG_IMX_WATCHDOG=y
......@@ -79,5 +79,4 @@ CONFIG_SPL_SYSRESET=y
CONFIG_SYSRESET_PSCI=y
CONFIG_SYSRESET_WATCHDOG=y
CONFIG_DM_THERMAL=y
# CONFIG_WATCHDOG is not set
CONFIG_IMX_WATCHDOG=y
......@@ -4,7 +4,8 @@ CONFIG_SYS_TEXT_BASE=0x40200000
CONFIG_SPL_GPIO_SUPPORT=y
CONFIG_SPL_LIBCOMMON_SUPPORT=y
CONFIG_SPL_LIBGENERIC_SUPPORT=y
CONFIG_SYS_MALLOC_F_LEN=0x10000
CONFIG_SYS_MALLOC_F_LEN=0x8000
CONFIG_SPL_SYS_MALLOC_SIMPLE=y
CONFIG_ENV_SIZE=0x1000
CONFIG_ENV_OFFSET=0x400000
CONFIG_SYS_I2C_MXC_I2C1=y
......@@ -82,5 +83,4 @@ CONFIG_SYSRESET=y
CONFIG_SPL_SYSRESET=y
CONFIG_SYSRESET_PSCI=y
CONFIG_SYSRESET_WATCHDOG=y
# CONFIG_WATCHDOG is not set
CONFIG_IMX_WATCHDOG=y
......@@ -75,6 +75,9 @@ CONFIG_NAND_MXC=y
CONFIG_PHYLIB=y
CONFIG_PHY_MICREL=y
CONFIG_PHY_MICREL_KSZ8XXX=y
CONFIG_DM_ETH=y
CONFIG_DM_MDIO=y
CONFIG_DM_ETH_PHY=y
CONFIG_PINCTRL=y
CONFIG_PINCTRL_IMX5=y
CONFIG_DM_REGULATOR=y
......
......@@ -99,5 +99,4 @@ CONFIG_SPL_SYSRESET=y
CONFIG_SYSRESET_PSCI=y
CONFIG_SYSRESET_WATCHDOG=y
CONFIG_DM_THERMAL=y
# CONFIG_WATCHDOG is not set
CONFIG_IMX_WATCHDOG=y
......@@ -60,13 +60,14 @@ Enabling logging
The following options are used to enable logging at compile time:
CONFIG_LOG - Enables the logging system
CONFIG_MAX_LOG_LEVEL - Max log level to build (anything higher is compiled
CONFIG_LOG_MAX_LEVEL - Max log level to build (anything higher is compiled
out)
CONFIG_LOG_CONSOLE - Enable writing log records to the console
If CONFIG_LOG is not set, then no logging will be available.
The above have SPL versions also, e.g. CONFIG_SPL_MAX_LOG_LEVEL.
The above have SPL and TPL versions also, e.g. CONFIG_SPL_LOG_MAX_LEVEL and
CONFIG_TPL_LOG_MAX_LEVEL.
Temporary logging within a single file
......
......@@ -8,3 +8,4 @@ Develop U-Boot
:maxdepth: 2
crash_dumps
logging
.. SPDX-License-Identifier: GPL-2.0+
.. Copyright (c) 2017 Simon Glass <sjg@chromium.org>
Logging in U-Boot
=================
Introduction
------------
U-Boot's internal operation involves many different steps and actions. From
setting up the board to displaying a start-up screen to loading an Operating
System, there are many component parts each with many actions.
Most of the time this internal detail is not useful. Displaying it on the
console would delay booting (U-Boot's primary purpose) and confuse users.
But for digging into what is happening in a particular area, or for debugging
a problem it is often useful to see what U-Boot is doing in more detail than
is visible from the basic console output.
U-Boot's logging feature aims to satisfy this goal for both users and
developers.
Logging levels
--------------
There are a number logging levels available, in increasing order of verbosity:
* LOGL_EMERG - Printed before U-Boot halts
* LOGL_ALERT - Indicates action must be taken immediate or U-Boot will crash
* LOGL_CRIT - Indicates a critical error that will cause boot failure
* LOGL_ERR - Indicates an error that may cause boot failure
* LOGL_WARNING - Warning about an unexpected condition
* LOGL_NOTE - Important information about progress
* LOGL_INFO - Information about normal boot progress
* LOGL_DEBUG - Debug information (useful for debugging a driver or subsystem)
* LOGL_DEBUG_CONTENT - Debug message showing full message content
* LOGL_DEBUG_IO - Debug message showing hardware I/O access
Logging category
----------------
Logging can come from a wide variety of places within U-Boot. Each log message
has a category which is intended to allow messages to be filtered according to
their source.
The following main categories are defined:
* LOGC_NONE - Unknown category (e.g. a debug() statement)
* UCLASS\_... - Related to a particular uclass (e.g. UCLASS_USB)
* LOGC_ARCH - Related to architecture-specific code
* LOGC_BOARD - Related to board-specific code
* LOGC_CORE - Related to core driver-model support
* LOGC_DT - Related to device tree control
* LOGC_EFI - Related to EFI implementation
Enabling logging
----------------
The following options are used to enable logging at compile time:
* CONFIG_LOG - Enables the logging system
* CONFIG_LOG_MAX_LEVEL - Max log level to build (anything higher is compiled
out)
* CONFIG_LOG_CONSOLE - Enable writing log records to the console
If CONFIG_LOG is not set, then no logging will be available.
The above have SPL and TPL versions also, e.g. CONFIG_SPL_LOG_MAX_LEVEL and
CONFIG_TPL_LOG_MAX_LEVEL.
Temporary logging within a single file
--------------------------------------
Sometimes it is useful to turn on logging just in one file. You can use this
.. code-block:: c
#define LOG_DEBUG
to enable building in of all logging statements in a single file. Put it at
the top of the file, before any #includes.
To actually get U-Boot to output this you need to also set the default logging
level - e.g. set CONFIG_LOG_DEFAULT_LEVEL to 7 (LOGL_DEBUG) or more. Otherwise
debug output is suppressed and will not be generated.
Convenience functions
---------------------
A number of convenience functions are available to shorten the code needed
for logging:
* log_err(_fmt...)
* log_warning(_fmt...)
* log_notice(_fmt...)
* log_info(_fmt...)
* log_debug(_fmt...)
* log_content(_fmt...)
* log_io(_fmt...)
With these the log level is implicit in the name. The category is set by
LOG_CATEGORY, which you can only define once per file, above all #includes, e.g.
.. code-block:: c
#define LOG_CATEGORY LOGC_ALLOC
Remember that all uclasses IDs are log categories too.
Log command
-----------
The 'log' command provides access to several features:
* level - access the default log level
* format - access the console log format
* rec - output a log record
* test - run tests
Type 'help log' for details.
Using DEBUG
-----------
U-Boot has traditionally used a #define called DEBUG to enable debugging on a
file-by-file basis. The debug() macro compiles to a printf() statement if
DEBUG is enabled, and an empty statement if not.
With logging enabled, debug() statements are interpreted as logging output
with a level of LOGL_DEBUG and a category of LOGC_NONE.
The logging facilities are intended to replace DEBUG, but if DEBUG is defined
at the top of a file, then it takes precedence. This means that debug()
statements will result in output to the console and this output will not be
logged.
Logging destinations
--------------------
If logging information goes nowhere then it serves no purpose. U-Boot provides
several possible determinations for logging information, all of which can be
enabled or disabled independently:
* console - goes to stdout
* syslog - broadcast RFC 3164 messages to syslog servers on UDP port 514
The syslog driver sends the value of environmental variable 'log_hostname' as
HOSTNAME if available.
Log format
----------
You can control the log format using the 'log format' command. The basic
format is::
LEVEL.category,file.c:123-func() message
In the above, file.c:123 is the filename where the log record was generated and
func() is the function name. By default ('log format default') only the
function name and message are displayed on the console. You can control which
fields are present, but not the field order.
Filters
-------
Filters are attached to log drivers to control what those drivers emit. Only
records that pass through the filter make it to the driver.
Filters can be based on several criteria:
* maximum log level
* in a set of categories
* in a set of files
If no filters are attached to a driver then a default filter is used, which
limits output to records with a level less than CONFIG_MAX_LOG_LEVEL.
Logging statements
------------------
The main logging function is:
.. code-block:: c
log(category, level, format_string, ...)
Also debug() and error() will generate log records - these use LOG_CATEGORY
as the category, so you should #define this right at the top of the source
file to ensure the category is correct.
You can also define CONFIG_LOG_ERROR_RETURN to enable the log_ret() macro. This
can be used whenever your function returns an error value:
.. code-block:: c
return log_ret(uclass_first_device(UCLASS_MMC, &dev));
This will write a log record when an error code is detected (a value < 0). This
can make it easier to trace errors that are generated deep in the call stack.
Code size
---------
Code size impact depends largely on what is enabled. The following numbers are
generated by 'buildman -S' for snow, which is a Thumb-2 board (all units in
bytes)::
This series: adds bss +20.0 data +4.0 rodata +4.0 text +44.0
CONFIG_LOG: bss -52.0 data +92.0 rodata -635.0 text +1048.0
CONFIG_LOG_MAX_LEVEL=7: bss +188.0 data +4.0 rodata +49183.0 text +98124.0
The last option turns every debug() statement into a logging call, which
bloats the code hugely. The advantage is that it is then possible to enable
all logging within U-Boot.
To Do
-----
There are lots of useful additions that could be made. None of the below is
implemented! If you do one, please add a test in test/py/tests/test_log.py
Convenience functions to support setting the category:
* log_arch(level, format_string, ...) - category LOGC_ARCH
* log_board(level, format_string, ...) - category LOGC_BOARD
* log_core(level, format_string, ...) - category LOGC_CORE
* log_dt(level, format_string, ...) - category LOGC_DT
More logging destinations:
* device - goes to a device (e.g. serial)
* buffer - recorded in a memory buffer
Convert debug() statements in the code to log() statements
Support making printf() emit log statements at L_INFO level
Convert error() statements in the code to log() statements
Figure out what to do with BUG(), BUG_ON() and warn_non_spl()
Figure out what to do with assert()
Add a way to browse log records
Add a way to record log records for browsing using an external tool
Add commands to add and remove filters
Add commands to add and remove log devices
Allow sharing of printf format strings in log records to reduce storage size
for large numbers of log records
Add a command-line option to sandbox to set the default logging level
Convert core driver model code to use logging
Convert uclasses to use logging with the correct category
Consider making log() calls emit an automatic newline, perhaps with a logn()
function to avoid that
Passing log records through to linux (e.g. via device tree /chosen)
Provide a command to access the number of log records generated, and the
number dropped due to them being generated before the log system was ready.
Add a printf() format string pragma so that log statements are checked properly
Enhance the log console driver to show level / category / file / line
information
Add a command to add new log records and delete existing records.
Provide additional log() functions - e.g. logc() to specify the category
......@@ -613,7 +613,7 @@ be connected on a SATA bus or standalone with no bus::
xhci_usb (UCLASS_USB)
flash (UCLASS_FLASH_STORAGE) - parent data/methods defined by USB bus
sata (UCLASS_SATA)
sata (UCLASS_AHCI)
flash (UCLASS_FLASH_STORAGE) - parent data/methods defined by SATA bus
flash (UCLASS_FLASH_STORAGE) - no parent data/methods (not on a bus)
......@@ -628,7 +628,7 @@ parent device which is a bus, causes the device to start behaving like a
bus device, regardless of its own views on the matter.
The uclass for the device can also contain data private to that uclass.
But note that each device on the bus may be a memeber of a different
But note that each device on the bus may be a member of a different
uclass, and this data has nothing to do with the child data for each child
on the bus. It is the bus' uclass that controls the child with respect to
the bus.
......
......@@ -310,13 +310,13 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
}
range = &map->ranges[range_num];
ptr = map_physmem(range->start + offset, val_len, MAP_NOCACHE);
if (offset + val_len > range->size) {
debug("%s: offset/size combination invalid\n", __func__);
return -ERANGE;
}
ptr = map_physmem(range->start + offset, val_len, MAP_NOCACHE);
switch (val_len) {
case REGMAP_SIZE_8:
*((u8 *)valp) = __read_8(ptr, map->endianness);
......@@ -419,13 +419,13 @@ int regmap_raw_write_range(struct regmap *map, uint range_num, uint offset,
}
range = &map->ranges[range_num];
ptr = map_physmem(range->start + offset, val_len, MAP_NOCACHE);
if (offset + val_len > range->size) {
debug("%s: offset/size combination invalid\n", __func__);
return -ERANGE;
}
ptr = map_physmem(range->start + offset, val_len, MAP_NOCACHE);
switch (val_len) {
case REGMAP_SIZE_8:
__write_8(ptr, val, map->endianness);
......
......@@ -689,13 +689,14 @@ int uclass_unbind_device(struct udevice *dev)
int uclass_resolve_seq(struct udevice *dev)
{
struct uclass *uc = dev->uclass;
struct uclass_driver *uc_drv = uc->uc_drv;
struct udevice *dup;
int seq;
int seq = 0;
int ret;
assert(dev->seq == -1);
ret = uclass_find_device_by_seq(dev->uclass->uc_drv->id, dev->req_seq,
false, &dup);
ret = uclass_find_device_by_seq(uc_drv->id, dev->req_seq, false, &dup);
if (!ret) {
dm_warn("Device '%s': seq %d is in use by '%s'\n",
dev->name, dev->req_seq, dup->name);
......@@ -707,9 +708,17 @@ int uclass_resolve_seq(struct udevice *dev)
return ret;
}
for (seq = 0; seq < DM_MAX_SEQ; seq++) {
ret = uclass_find_device_by_seq(dev->uclass->uc_drv->id, seq,
false, &dup);
if (CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
(uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) {
/*
* dev_read_alias_highest_id() will return -1 if there no
* alias. Thus we can always add one.
*/
seq = dev_read_alias_highest_id(uc_drv->name) + 1;
}
for (; seq < DM_MAX_SEQ; seq++) {
ret = uclass_find_device_by_seq(uc_drv->id, seq, false, &dup);
if (ret == -ENODEV)
break;
if (ret)
......
......@@ -105,6 +105,13 @@ config DM_PMIC_PFUZE100
This config enables implementation of driver-model pmic uclass features
for PMIC PFUZE100. The driver implements read/write operations.
config SPL_DM_PMIC_PFUZE100
bool "Enable Driver Model for PMIC PFUZE100 in SPL"
depends on DM_PMIC
---help---
This config enables implementation of driver-model pmic uclass features
for PMIC PFUZE100 in SPL. The driver implements read/write operations.
config DM_PMIC_MAX77686
bool "Enable Driver Model for PMIC MAX77686"
depends on DM_PMIC
......
......@@ -494,6 +494,35 @@ static int usb_match_one_id(struct usb_device_descriptor *desc,
return usb_match_one_id_intf(desc, int_desc, id);
}
static ofnode usb_get_ofnode(struct udevice *hub, int port)
{
ofnode node;
u32 reg;
if (!dev_has_of_node(hub))
return ofnode_null();
/*
* The USB controller and its USB hub are two different udevices,
* but the device tree has only one node for both. Thus we are
* assigning this node to both udevices.
* If port is zero, the controller scans its root hub, thus we
* are using the same ofnode as the controller here.
*/
if (!port)
return dev_ofnode(hub);
ofnode_for_each_subnode(node, dev_ofnode(hub)) {
if (ofnode_read_u32(node, "reg", &reg))
continue;
if (reg == port)
return node;
}
return ofnode_null();
}
/**
* usb_find_and_bind_driver() - Find and bind the right USB driver
*
......@@ -502,13 +531,14 @@ static int usb_match_one_id(struct usb_device_descriptor *desc,
static int usb_find_and_bind_driver(struct udevice *parent,
struct usb_device_descriptor *desc,
struct usb_interface_descriptor *iface,
int bus_seq, int devnum,
int bus_seq, int devnum, int port,
struct udevice **devp)
{
struct usb_driver_entry *start, *entry;
int n_ents;
int ret;
char name[30], *str;
ofnode node = usb_get_ofnode(parent, port);
*devp = NULL;
debug("%s: Searching for driver\n", __func__);
......@@ -533,8 +563,8 @@ static int usb_find_and_bind_driver(struct udevice *parent,
* find another driver. For now this doesn't seem
* necesssary, so just bind the first match.
*/
ret = device_bind(parent, drv, drv->name, NULL, -1,
&dev);
ret = device_bind_ofnode(parent, drv, drv->name, NULL,
node, &dev);
if (ret)
goto error;
debug("%s: Match found: %s\n", __func__, drv->name);
......@@ -651,9 +681,10 @@ int usb_scan_device(struct udevice *parent, int port,
if (ret) {
if (ret != -ENOENT)
return ret;
ret = usb_find_and_bind_driver(parent, &udev->descriptor, iface,
ret = usb_find_and_bind_driver(parent, &udev->descriptor,
iface,
udev->controller_dev->seq,
udev->devnum, &dev);
udev->devnum, port, &dev);
if (ret)
return ret;
created = true;
......
......@@ -28,9 +28,10 @@
* 0x020000 - 0x120000 : SPI.u-boot (1MiB)
* 0x120000 - 0x130000 : SPI.u-boot-env1 (64KiB)
* 0x130000 - 0x140000 : SPI.u-boot-env2 (64KiB)
* 0x140000 - 0x540000 : SPI.swupdate-kernel-FIT (4MiB)
* 0x540000 - 0x1540000 : SPI.swupdate-initramfs (16MiB)
* 0x1540000 - 0x1640000 : SPI.factory (1MiB)
* 0x140000 - 0x740000 : SPI.swupdate-kernel-FIT (6MiB)
* 0x740000 - 0x1B40000 : SPI.swupdate-initramfs (20MiB)
* 0x1B40000 - 0x1F00000 : SPI.reserved (3840KiB)
* 0x1F00000 - 0x2000000 : SPI.factory (1MiB)
*/
/* SPI Flash Configs */
......
......@@ -24,16 +24,14 @@
#ifdef CONFIG_SPL_BUILD
/*#define CONFIG_ENABLE_DDR_TRAINING_DEBUG*/
#define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds"
#define CONFIG_SPL_STACK 0x990000
#define CONFIG_SPL_BSS_START_ADDR 0x0095e000
#define CONFIG_SPL_BSS_MAX_SIZE 0x2000 /* 8 KB */
#define CONFIG_SYS_SPL_MALLOC_START 0x42200000
#define CONFIG_SYS_SPL_MALLOC_SIZE SZ_512K /* 512 KB */
#define CONFIG_SPL_STACK 0x960000
#define CONFIG_SPL_BSS_START_ADDR 0x0098FC00
#define CONFIG_SPL_BSS_MAX_SIZE 0x400 /* 1 KB */
#define CONFIG_SYS_SPL_MALLOC_START 0x42200000
#define CONFIG_SYS_SPL_MALLOC_SIZE SZ_512K /* 512 KB */
#define CONFIG_SYS_ICACHE_OFF
#define CONFIG_SYS_DCACHE_OFF
#define CONFIG_MALLOC_F_ADDR 0x940000
#define CONFIG_SPL_ABORT_ON_RAW_IMAGE
#undef CONFIG_DM_MMC
......
......@@ -94,9 +94,9 @@
#endif
#define SANDBOX_ETH_SETTINGS "ethaddr=00:00:11:22:33:44\0" \
"eth1addr=00:00:11:22:33:45\0" \
"eth3addr=00:00:11:22:33:46\0" \
"eth5addr=00:00:11:22:33:47\0" \
"eth3addr=00:00:11:22:33:45\0" \
"eth5addr=00:00:11:22:33:46\0" \
"eth6addr=00:00:11:22:33:47\0" \
"ipaddr=1.2.3.4\0"
#define MEM_LAYOUT_ENV_SETTINGS \
......
......@@ -983,6 +983,8 @@ static inline u64 dev_translate_dma_address(const struct udevice *dev,
static inline int dev_read_alias_highest_id(const char *stem)
{
if (!CONFIG_IS_ENABLED(OF_LIBFDT))
return -1;
return fdtdec_get_alias_highest_id(gd->fdt_blob, stem);
}
......
......@@ -1294,9 +1294,11 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
/* find a matching node and return the phandle to that */
fdt_for_each_subnode(node, blob, parent) {
const char *name = fdt_get_name(blob, node, NULL);
phys_addr_t addr, size;
fdt_addr_t addr;
fdt_size_t size;
addr = fdtdec_get_addr_size(blob, node, "reg", &size);
addr = fdtdec_get_addr_size_fixed(blob, node, "reg", 0, na, ns,
&size, false);
if (addr == FDT_ADDR_T_NONE) {
debug("failed to read address/size for %s\n", name);
continue;
......
......@@ -757,7 +757,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)
&& (memcmp(s, "/__overlay__", len - 1) == 0)) {
/* /<fragment-name>/__overlay__ */
rel_path = "";
rel_path_len = 0;
rel_path_len = 1; /* Include NUL character */
} else {
/* Symbol refers to something that won't end
* up in the target tree */
......@@ -794,7 +794,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)
}
ret = fdt_setprop_placeholder(fdt, root_sym, name,
len + (len > 1) + rel_path_len + 1, &p);
len + (len > 1) + rel_path_len, &p);
if (ret < 0)
return ret;
......@@ -820,7 +820,6 @@ static int overlay_symbol_update(void *fdt, void *fdto)
buf[len] = '/';
memcpy(buf + len + 1, rel_path, rel_path_len);
buf[len + 1 + rel_path_len] = '\0';
}
return 0;
......
......@@ -48,7 +48,7 @@ static int dm_test_eth_alias(struct unit_test_state *uts)
ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10002000", env_get("ethact"));
env_set("ethact", "eth1");
env_set("ethact", "eth6");
ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10004000", env_get("ethact"));
......@@ -105,7 +105,7 @@ static int dm_test_eth_act(struct unit_test_state *uts)
const char *ethname[DM_TEST_ETH_NUM] = {"eth@10002000", "eth@10003000",
"sbe5", "eth@10004000"};
const char *addrname[DM_TEST_ETH_NUM] = {"ethaddr", "eth5addr",
"eth3addr", "eth1addr"};
"eth3addr", "eth6addr"};
char ethaddr[DM_TEST_ETH_NUM][18];
int i;
......@@ -188,15 +188,15 @@ static int dm_test_eth_rotate(struct unit_test_state *uts)
/* Invalidate eth1's MAC address */
memset(ethaddr, '\0', sizeof(ethaddr));
strncpy(ethaddr, env_get("eth1addr"), 17);
/* Must disable access protection for eth1addr before clearing */
env_set(".flags", "eth1addr");
env_set("eth1addr", NULL);
strncpy(ethaddr, env_get("eth6addr"), 17);
/* Must disable access protection for eth6addr before clearing */
env_set(".flags", "eth6addr");
env_set("eth6addr", NULL);
retval = _dm_test_eth_rotate1(uts);
/* Restore the env */
env_set("eth1addr", ethaddr);
env_set("eth6addr", ethaddr);
env_set("ethrotate", NULL);
if (!retval) {
......
......@@ -361,20 +361,32 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts)
ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 2, &dev));
ut_asserteq_str("d-test", dev->name);
/* d-test actually gets 0 */
ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 0, &dev));
/*
* d-test actually gets 9, because thats the next free one after the
* aliases.
*/
ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 9, &dev));
ut_asserteq_str("d-test", dev->name);
/* initially no one wants seq 1 */
ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 1,
/* initially no one wants seq 10 */
ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 10,
&dev));
ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 4, &dev));
/* But now that it is probed, we can find it */
ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 1, &dev));
ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 10, &dev));
ut_asserteq_str("f-test", dev->name);
/*
* And we should still have holes in our sequence numbers, that is 2
* and 4 should not be used.
*/
ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 2,
true, &dev));
ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 4,
true, &dev));
return 0;
}
DM_TEST(dm_test_fdt_uclass_seq, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
......
......@@ -78,6 +78,28 @@ static int dm_test_usb_multi(struct unit_test_state *uts)
}
DM_TEST(dm_test_usb_multi, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
/* test that we have an associated ofnode with the usb device */
static int dm_test_usb_fdt_node(struct unit_test_state *uts)
{
struct udevice *dev;
ofnode node;
state_set_skip_delays(true);
ut_assertok(usb_init());
ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, &dev));
node = ofnode_path("/usb@1/hub/usbstor@1");
ut_asserteq(1, ofnode_equal(node, dev_ofnode(dev)));
ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 1, &dev));
ut_asserteq(1, ofnode_equal(ofnode_null(), dev_ofnode(dev)));
ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 2, &dev));
node = ofnode_path("/usb@1/hub/usbstor@3");
ut_asserteq(1, ofnode_equal(node, dev_ofnode(dev)));
ut_assertok(usb_stop());
return 0;
}
DM_TEST(dm_test_usb_fdt_node, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
static int count_usb_devices(void)
{
struct udevice *hub;
......
......@@ -70,12 +70,12 @@ As an example, say we are building branch 'us-net' for boards 'sandbox' and
like this:
us-net/ base directory
01_of_02_g4ed4ebc_net--Add-tftp-speed-/
01_g4ed4ebc_net--Add-tftp-speed-/
sandbox/
u-boot.bin
seaboard/
u-boot.bin
02_of_02_g4ed4ebc_net--Check-tftp-comp/
02_g4ed4ebc_net--Check-tftp-comp/
sandbox/
u-boot.bin
seaboard/
......@@ -487,8 +487,8 @@ class Builder:
commit = self.commits[commit_upto]
subject = commit.subject.translate(trans_valid_chars)
# See _GetOutputSpaceRemovals() which parses this name
commit_dir = ('%02d_of_%02d_g%s_%s' % (commit_upto + 1,
self.commit_count, commit.hash, subject[:20]))
commit_dir = ('%02d_g%s_%s' % (commit_upto + 1,
commit.hash, subject[:20]))
elif not self.no_subdirs:
commit_dir = 'current'
if not commit_dir:
......@@ -1599,7 +1599,7 @@ class Builder:
for dirname in glob.glob(os.path.join(self.base_dir, '*')):
if dirname not in dir_list:
leaf = dirname[len(self.base_dir) + 1:]
m = re.match('[0-9]+_of_[0-9]+_g[0-9a-f]+_.*', leaf)
m = re.match('[0-9]+_g[0-9a-f]+_.*', leaf)
if m:
to_remove.append(dirname)
return to_remove
......
......@@ -541,7 +541,7 @@ class TestBuild(unittest.TestCase):
build.commits = self.commits
build.commit_count = len(self.commits)
subject = self.commits[1].subject.translate(builder.trans_valid_chars)
dirname ='/%02d_of_%02d_g%s_%s' % (2, build.commit_count, commits[1][0],
dirname ='/%02d_g%s_%s' % (2, build.commit_count, commits[1][0],
subject[:20])
self.CheckDirs(build, dirname)
......@@ -609,9 +609,9 @@ class TestBuild(unittest.TestCase):
base_dir = tempfile.mkdtemp()
# Add various files that we want removed and left alone
to_remove = ['01_of_22_g0982734987_title', '102_of_222_g92bf_title',
'01_of_22_g2938abd8_title']
to_leave = ['something_else', '01-something.patch', '01_of_22_another']
to_remove = ['01_g0982734987_title', '102_g92bf_title',
'01_g2938abd8_title']
to_leave = ['something_else', '01-something.patch', '01_another']
for name in to_remove + to_leave:
_Touch(name)
......
......@@ -59,7 +59,7 @@ def CheckPatch(fname, verbose=False):
'stdout']
result = collections.namedtuple('CheckPatchResult', fields)
result.ok = False
result.errors, result.warning, result.checks = 0, 0, 0
result.errors, result.warnings, result.checks = 0, 0, 0
result.lines = 0
result.problems = []
chk = FindCheckPatch()
......@@ -72,24 +72,39 @@ def CheckPatch(fname, verbose=False):
# total: 0 errors, 0 warnings, 159 lines checked
# or:
# total: 0 errors, 2 warnings, 7 checks, 473 lines checked
re_stats = re.compile('total: (\\d+) errors, (\d+) warnings, (\d+)')
re_stats_full = re.compile('total: (\\d+) errors, (\d+) warnings, (\d+)'
emacs_prefix = '(?:[0-9]{4}.*\.patch:[0-9]+: )?'
emacs_stats = '(?:[0-9]{4}.*\.patch )?'
re_stats = re.compile(emacs_stats +
'total: (\\d+) errors, (\d+) warnings, (\d+)')
re_stats_full = re.compile(emacs_stats +
'total: (\\d+) errors, (\d+) warnings, (\d+)'
' checks, (\d+)')
re_ok = re.compile('.*has no obvious style problems')
re_bad = re.compile('.*has style problems, please review')
re_error = re.compile('ERROR: (.*)')
re_warning = re.compile('WARNING: (.*)')
re_warning = re.compile(emacs_prefix + 'WARNING:(?:[A-Z_]+:)? (.*)')
re_check = re.compile('CHECK: (.*)')
re_file = re.compile('#\d+: FILE: ([^:]*):(\d+):')
re_note = re.compile('NOTE: (.*)')
indent = ' ' * 6
for line in result.stdout.splitlines():
if verbose:
print(line)
# A blank line indicates the end of a message
if not line and item:
result.problems.append(item)
item = {}
if not line:
if item:
result.problems.append(item)
item = {}
continue
if re_note.match(line):
continue
# Skip lines which quote code
if line.startswith(indent):
continue
# Skip code quotes and #<n>
if line.startswith('+') or line.startswith('#'):
continue
match = re_stats_full.match(line)
if not match:
match = re_stats.match(line)
......@@ -101,14 +116,18 @@ def CheckPatch(fname, verbose=False):
result.lines = int(match.group(4))
else:
result.lines = int(match.group(3))
continue
elif re_ok.match(line):
result.ok = True
continue
elif re_bad.match(line):
result.ok = False
continue
err_match = re_error.match(line)
warn_match = re_warning.match(line)
file_match = re_file.match(line)
check_match = re_check.match(line)
subject_match = line.startswith('Subject:')
if err_match:
item['msg'] = err_match.group(1)
item['type'] = 'error'
......@@ -121,6 +140,11 @@ def CheckPatch(fname, verbose=False):
elif file_match:
item['file'] = file_match.group(1)
item['line'] = int(file_match.group(2))
elif subject_match:
item['file'] = '<patch subject>'
item['line'] = None
else:
print('bad line "%s", %d' % (line, len(line)))
return result
......@@ -139,7 +163,8 @@ def GetWarningMsg(col, msg_type, fname, line, msg):
msg_type = col.Color(col.RED, msg_type)
elif msg_type == 'check':
msg_type = col.Color(col.MAGENTA, msg_type)
return '%s:%d: %s: %s\n' % (fname, line, msg_type, msg)
line_str = '' if line is None else '%d' % line
return '%s:%s: %s: %s\n' % (fname, line_str, msg_type, msg)
def CheckPatches(verbose, args):
'''Run the checkpatch.pl script on each patch'''
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册