diff --git a/arch/arm/dts/am335x-bone-common.dtsi b/arch/arm/dts/am335x-bone-common.dtsi index ef97d90..0413724 100644 --- a/arch/arm/dts/am335x-bone-common.dtsi +++ b/arch/arm/dts/am335x-bone-common.dtsi @@ -194,6 +194,7 @@ &usb0 { status = "okay"; + dr_mode = "peripheral"; }; &usb1 { diff --git a/commands/i2c.c b/commands/i2c.c index b74c535..21c39fe 100644 --- a/commands/i2c.c +++ b/commands/i2c.c @@ -115,7 +115,7 @@ count = argc - optind; - if ((addr < 0) || (reg < 0) || (count == 0) || (addr > 0x7F)) + if ((addr < 0) || (count == 0) || (addr > 0x7F)) return COMMAND_ERROR_USAGE; adapter = i2c_get_adapter(bus); @@ -131,7 +131,11 @@ for (i = 0; i < count; i++) *(buf + i) = (char) simple_strtol(argv[optind+i], NULL, 0); - ret = i2c_write_reg(&client, reg | wide, buf, count); + if (reg > 0) { + ret = i2c_write_reg(&client, reg | wide, buf, count); + } else { + ret = i2c_master_send(&client, buf, count); + } if (ret != count) { if (verbose) printf("write aborted, count(%i) != writestatus(%i)\n", diff --git a/common/Kconfig b/common/Kconfig index 93b1d89..25de248 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -632,6 +632,13 @@ Additionally the barebox device tree needs a /signature node with the public key with which the image has been signed. +config BOOTM_FITIMAGE_PUBKEY + string "Path to dtsi containing pubkey" + default "../fit/pubkey.dtsi" + depends on BOOTM_FITIMAGE_SIGNATURE + help + Set Path to a dts snippet which holds the public keys for FIT images. + config BOOTM_FORCE_SIGNED_IMAGES bool prompt "Force booting of signed images" @@ -744,6 +751,14 @@ endchoice +config CONSOLE_ALLOW_COLOR + prompt "Allow colored console output during boot" + bool + help + If enabled, colored output is allowed during boot. This is the + compile time default for colored console output. After boot it + can be controlled using global.allow_color. + config PBL_CONSOLE depends on PBL_IMAGE depends on !CONSOLE_NONE diff --git a/common/console_common.c b/common/console_common.c index d051458..00e020b 100644 --- a/common/console_common.c +++ b/common/console_common.c @@ -33,6 +33,15 @@ #ifndef CONFIG_CONSOLE_NONE +static const char *colored_log_level[] = { + [MSG_EMERG] = "\033[31mEMERG:\033[0m ", /* red */ + [MSG_ALERT] = "\033[31mALERT:\033[0m ", /* red */ + [MSG_CRIT] = "\033[31mCRITICAL:\033[0m ", /* red */ + [MSG_ERR] = "\033[31mERROR:\033[0m ", /* red */ + [MSG_WARNING] = "\033[33mWARNING:\033[0m ", /* yellow */ + [MSG_NOTICE] = "\033[34mNOTICE:\033[0m ", /* blue */ +}; + int barebox_loglevel = CONFIG_DEFAULT_LOGLEVEL; LIST_HEAD(barebox_logbuf); @@ -102,6 +111,18 @@ puts(str); } +static void print_colored_log_level(const int level) +{ + if (!console_allow_color()) + return; + if (level >= ARRAY_SIZE(colored_log_level)) + return; + if (!colored_log_level[level]) + return; + + pr_puts(level, colored_log_level[level]); +} + int pr_print(int level, const char *fmt, ...) { va_list args; @@ -111,6 +132,8 @@ if (!IS_ENABLED(CONFIG_LOGBUF) && level > barebox_loglevel) return 0; + print_colored_log_level(level); + va_start(args, fmt); i = vsprintf(printbuffer, fmt, args); va_end(args); @@ -129,6 +152,8 @@ if (!IS_ENABLED(CONFIG_LOGBUF) && level > barebox_loglevel) return 0; + print_colored_log_level(level); + if (dev->driver && dev->driver->name) ret += sprintf(printbuffer, "%s ", dev->driver->name); @@ -145,15 +170,28 @@ return ret; } -static int loglevel_init(void) +#ifdef CONFIG_CONSOLE_ALLOW_COLOR +static unsigned int __console_allow_color = 1; +#else +static unsigned int __console_allow_color = 0; +#endif + +bool console_allow_color(void) +{ + return __console_allow_color; +} + +static int console_common_init(void) { if (IS_ENABLED(CONFIG_LOGBUF)) globalvar_add_simple_int("log_max_messages", &barebox_log_max_messages, "%d"); + globalvar_add_simple_bool("allow_color", &__console_allow_color); + return globalvar_add_simple_int("loglevel", &barebox_loglevel, "%d"); } -device_initcall(loglevel_init); +device_initcall(console_common_init); void log_print(unsigned flags) { diff --git a/common/misc.c b/common/misc.c index 0888f1f..665f72b 100644 --- a/common/misc.c +++ b/common/misc.c @@ -141,20 +141,15 @@ */ void barebox_set_model(const char *__model) { - if (IS_ENABLED(CONFIG_GLOBALVAR)) { - globalvar_add_simple("model", __model); - } else { - free(model); - model = xstrdup(__model); - } + globalvar_add_simple_string("model", &model); + + free(model); + model = xstrdup(__model); } EXPORT_SYMBOL(barebox_set_model); const char *barebox_get_model(void) { - if (IS_ENABLED(CONFIG_GLOBALVAR)) - return getenv("global.model"); - return model; } EXPORT_SYMBOL(barebox_get_model); @@ -170,19 +165,14 @@ */ void barebox_set_hostname(const char *__hostname) { - if (IS_ENABLED(CONFIG_GLOBALVAR)) { - globalvar_add_simple("hostname", __hostname); - } else { - free(hostname); - hostname = xstrdup(__hostname); - } + globalvar_add_simple_string("hostname", &hostname); + + free(hostname); + hostname = xstrdup(__hostname); } const char *barebox_get_hostname(void) { - if (IS_ENABLED(CONFIG_GLOBALVAR)) - return getenv("global.hostname"); - return hostname; } EXPORT_SYMBOL(barebox_get_hostname); diff --git a/defaultenv/defaultenv-2-base/bin/init b/defaultenv/defaultenv-2-base/bin/init index 7af3c7d..6f3a34d 100644 --- a/defaultenv/defaultenv-2-base/bin/init +++ b/defaultenv/defaultenv-2-base/bin/init @@ -6,7 +6,6 @@ global user global autoboot_timeout global boot.default -global allow_color global linux.bootargs.base global linux.bootargs.console #linux.bootargs.dyn.* will be cleared at the beginning of boot @@ -20,8 +19,6 @@ [ -z "${global.autoboot_timeout}" ] && global.autoboot_timeout=3 magicvar -a global.autoboot_timeout "timeout in seconds before automatic booting" [ -z "${global.boot.default}" ] && global.boot.default=net -[ -z "${global.allow_color}" ] && global.allow_color=true -magicvar -a global.allow_color "Allow color on the console (boolean)" [ -z "${global.editcmd}" ] && global.editcmd=sedit [ -e /env/config-board ] && /env/config-board diff --git a/defaultenv/defaultenv-2-base/data/ansi-colors b/defaultenv/defaultenv-2-base/data/ansi-colors index 6365329..c61cae2 100644 --- a/defaultenv/defaultenv-2-base/data/ansi-colors +++ b/defaultenv/defaultenv-2-base/data/ansi-colors @@ -1,6 +1,6 @@ #!/bin/sh -if [ ${global.allow_color} != "true" ]; then +if [ ${global.allow_color} != "1" ]; then exit fi diff --git a/defaultenv/defaultenv-2-base/init/ps1 b/defaultenv/defaultenv-2-base/init/ps1 index 02d7b4b..bbb5443 100644 --- a/defaultenv/defaultenv-2-base/init/ps1 +++ b/defaultenv/defaultenv-2-base/init/ps1 @@ -1,6 +1,6 @@ #!/bin/sh -if [ ${global.allow_color} = "true" ]; then +if [ ${global.allow_color} = "1" ]; then export PS1="\e[1;32mbarebox@\e[1;36m\h:\w\e[0m " else export PS1="barebox@\h:\w " diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 5cf650c..057638e 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -641,6 +641,7 @@ { "w25q20cl", INFO(0xef4012, 0, 64 * 1024, 4, SECT_4K) }, { "w25q20bw", INFO(0xef5012, 0, 64 * 1024, 4, SECT_4K) }, { "w25q20ew", INFO(0xef6012, 0, 64 * 1024, 4, SECT_4K) }, + { "w25q16dw", INFO(0xef6015, 0, 64 * 1024, 32, SECT_4K) }, { "w25q32", INFO(0xef4016, 0, 64 * 1024, 64, SECT_4K) }, { "w25q32dw", INFO(0xef6016, 0, 64 * 1024, 64, SECT_4K) }, { "w25x64", INFO(0xef3017, 0, 64 * 1024, 128, SECT_4K) }, diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c index d11ca33..3d3939c 100644 --- a/drivers/net/cpsw.c +++ b/drivers/net/cpsw.c @@ -761,11 +761,6 @@ dev_dbg(&slave->dev, "* %s\n", __func__); - ret = phy_device_connect(edev, &priv->miibus, slave->phy_id, - cpsw_adjust_link, 0, slave->phy_if); - if (ret) - return ret; - /* soft reset the controller and initialize priv */ soft_reset(priv, &priv->regs->soft_reset); @@ -913,16 +908,11 @@ struct eth_device *edev = &slave->edev; struct device_d *dev = &slave->dev; int ret; - struct phy_device *phy; - phy = mdiobus_scan(&priv->miibus, priv->slaves[slave_num].phy_id); - if (IS_ERR(phy)) { - ret = PTR_ERR(phy); - goto err_out; - } + edev->parent = dev; - phy->dev.device_node = priv->slaves[slave_num].dev.device_node; - ret = phy_register_device(phy); + ret = phy_device_connect(edev, &priv->miibus, slave->phy_id, + cpsw_adjust_link, 0, slave->phy_if); if (ret) goto err_out; @@ -948,7 +938,6 @@ edev->recv = cpsw_recv; edev->get_ethaddr = cpsw_get_hwaddr; edev->set_ethaddr = cpsw_set_hwaddr; - edev->parent = dev; ret = eth_register(edev); if (ret) @@ -957,7 +946,7 @@ return 0; err_register_dev: - phy_unregister_device(phy); + phy_unregister_device(edev->phydev); err_register_edev: unregister_device(dev); err_out: @@ -1100,11 +1089,13 @@ if (i < priv->num_slaves && !strncmp(child->name, "slave", 5)) { struct cpsw_slave *slave = &priv->slaves[i]; - uint32_t phy_id[2]; + uint32_t phy_id[2] = {-1, -1}; - ret = of_property_read_u32_array(child, "phy_id", phy_id, 2); - if (ret) - return ret; + if (!of_find_node_by_name(child, "fixed-link")) { + ret = of_property_read_u32_array(child, "phy_id", phy_id, 2); + if (ret) + return ret; + } slave->dev.device_node = child; slave->phy_id = phy_id[1]; diff --git a/drivers/of/base.c b/drivers/of/base.c index 152dbe7..4bcc113 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -129,7 +129,7 @@ } EXPORT_SYMBOL(of_find_property); -const void *of_property_get_value(struct property *pp) +static const void *of_property_get_value(struct property *pp) { return pp->value ? pp->value : pp->value_const; } diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 1edb35f..92dd86e 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -117,7 +117,7 @@ * Parse a flat device tree binary blob and return a pointer to the * unflattened tree. */ -struct device_node *__of_unflatten_dtb(const void *infdt, bool constprops) +static struct device_node *__of_unflatten_dtb(const void *infdt, bool constprops) { const void *nodep; /* property node pointer */ uint32_t tag; /* tag */ diff --git a/include/console.h b/include/console.h index 724168e..a8b2663 100644 --- a/include/console.h +++ b/include/console.h @@ -94,4 +94,6 @@ static inline void pbl_set_putc(void (*putcf)(void *ctx, int c), void *ctx) {} #endif +bool console_allow_color(void); + #endif diff --git a/net/dhcp.c b/net/dhcp.c index 946efaa..d30551d 100644 --- a/net/dhcp.c +++ b/net/dhcp.c @@ -76,7 +76,6 @@ static uint32_t Bootp_id; static dhcp_state_t dhcp_state; -static IPaddr_t net_dhcp_server_ip; static uint64_t dhcp_start; static struct eth_device *dhcp_edev; struct dhcp_req_param dhcp_param; @@ -350,7 +349,6 @@ { struct bootp *bp; int extlen; - IPaddr_t OfferedIP; debug("%s: Sending DHCPREQUEST\n", __func__); @@ -378,9 +376,8 @@ /* * Copy options from OFFER packet if present */ - net_copy_ip(&OfferedIP, &bp_offer->bp_yiaddr); - extlen = dhcp_extended(bp->bp_vend, DHCP_REQUEST, net_dhcp_server_ip, - OfferedIP); + extlen = dhcp_extended(bp->bp_vend, DHCP_REQUEST, dhcp_result->serverip, + dhcp_result->ip); debug("Transmitting DHCPREQUEST packet\n"); net_udp_send(dhcp_con, sizeof(*bp) + extlen); diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index d202a72..272b598 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -157,6 +157,12 @@ -I$(srctree)/dts/src/ \ -undef -D__DTS__ +ifdef CONFIG_BOOTM_FITIMAGE_PUBKEY +ifneq ($(CONFIG_BOOTM_FITIMAGE_PUBKEY),"") +dtc_cpp_flags += -DCONFIG_BOOTM_FITIMAGE_PUBKEY=\"$(CONFIG_BOOTM_FITIMAGE_PUBKEY)\" +endif +endif + # Finds the multi-part object the current object will be linked into modname-multi = $(sort $(foreach m,$(multi-used),\ $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) @@ -420,7 +426,13 @@ imxcfg_cpp_flags = -Wp,-MD,$(depfile) -nostdinc -x assembler-with-cpp \ -I $(srctree)/include -I $(srctree)/arch/arm/mach-imx/include \ - -include include/generated/autoconf.h + -include include/generated/autoconf.h \ + -DCONFIG_HABV3_SRK_PEM=\"$(CONFIG_HABV3_SRK_PEM)\" \ + -DCONFIG_HABV3_CSF_CRT_DER=\"$(CONFIG_HABV3_CSF_CRT_DER)\" \ + -DCONFIG_HABV3_IMG_CRT_DER=\"$(CONFIG_HABV3_IMG_CRT_DER)\" \ + -DCONFIG_HABV4_TABLE_BIN=\"$(CONFIG_HABV4_TABLE_BIN)\" \ + -DCONFIG_HABV4_CSF_CRT_PEM=\"$(CONFIG_HABV4_CSF_CRT_PEM)\" \ + -DCONFIG_HABV4_IMG_CRT_PEM=\"$(CONFIG_HABV4_IMG_CRT_PEM)\" dcd-tmp = $(subst $(comma),_,$(dot-target).dcd.tmp)