[U-Boot] [PATCH 00/10] rockchip: Tidy up SPL operation on jerry

At present chromebook_jerry does not boot due to a configuration error and a missing Makefile piece. This series fixes that and also adds a few more adjustments mostly related to SPL and pinctrl.
The first three patches could perhaps be applied for this release - the rest are for later.
Simon Glass (10): rockchip: Enable generation of SPI images rockchip: Drop a debug message when outputing SPI images rockchip: Fix the configuration for chromebook_jerry tiny-printf: Avoid printing NULL strings dm: spi_flash: Allow the uclass to work without printf() dm: gpio: Allow the uclass to work without printf() dm: mmc: Try to honour the sequence order i2c: Correct command return values malloc_simple: Display an error when memory is exhausted pinctrl: Avoid binding all pinconfig nodes before relocation
common/cmd_i2c.c | 6 ++++-- common/malloc_simple.c | 5 ++++- configs/chromebook_jerry_defconfig | 4 ++++ doc/README.rockchip | 7 ++++--- drivers/gpio/gpio-uclass.c | 8 ++++++++ drivers/mmc/mmc.c | 20 +++++++++++++++----- drivers/mtd/spi/sf-uclass.c | 8 +++++++- drivers/pinctrl/pinctrl-uclass.c | 4 ++++ include/configs/chromebook_jerry.h | 1 + lib/tiny-printf.c | 6 ++++-- tools/Makefile | 2 +- tools/rkspi.c | 2 +- 12 files changed, 57 insertions(+), 16 deletions(-)

This feature was dropped at some point. Restore it.
Signed-off-by: Simon Glass sjg@chromium.org ---
tools/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/Makefile b/tools/Makefile index 9cfd80b..d49e40d 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -64,7 +64,7 @@ RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \ rsa-sign.o rsa-verify.o rsa-checksum.o \ rsa-mod-exp.o)
-ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o +ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o
# common objs for dumpimage and mkimage dumpimage-mkimage-objs := aisimage.o \

On 29 December 2015 at 05:22, Simon Glass sjg@chromium.org wrote:
This feature was dropped at some point. Restore it.
Signed-off-by: Simon Glass sjg@chromium.org
tools/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-rockchip, and now in mainline.

There is an unnecessary sector count displayed. Drop it.
Signed-off-by: Simon Glass sjg@chromium.org ---
tools/rkspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/rkspi.c b/tools/rkspi.c index 800e235..a0b0051 100644 --- a/tools/rkspi.c +++ b/tools/rkspi.c @@ -54,7 +54,7 @@ static void rkspi_set_header(void *buf, struct stat *sbuf, int ifd, * boot ROM. Its rationale is unknown. */ for (sector = size / RKSPI_SECT_LEN - 1; sector >= 0; sector--) { - printf("sector %u\n", sector); + debug("sector %u\n", sector); memmove(buf + sector * RKSPI_SECT_LEN * 2, buf + sector * RKSPI_SECT_LEN, RKSPI_SECT_LEN);

On 29 December 2015 at 05:22, Simon Glass sjg@chromium.org wrote:
There is an unnecessary sector count displayed. Drop it.
Signed-off-by: Simon Glass sjg@chromium.org
tools/rkspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/rkspi.c b/tools/rkspi.c index 800e235..a0b0051 100644 --- a/tools/rkspi.c +++ b/tools/rkspi.c @@ -54,7 +54,7 @@ static void rkspi_set_header(void *buf, struct stat *sbuf, int ifd, * boot ROM. Its rationale is unknown. */ for (sector = size / RKSPI_SECT_LEN - 1; sector >= 0; sector--) {
printf("sector %u\n", sector);
debug("sector %u\n", sector); memmove(buf + sector * RKSPI_SECT_LEN * 2, buf + sector * RKSPI_SECT_LEN, RKSPI_SECT_LEN);
-- 2.6.0.rc2.230.g3dd15c0
Applied to u-boot-rockchip, and now in mainline.

Various updates did not make it through to this board. Also the instructions for building a SPI image are no-longer correct. Fix these so that Jerry can boot to a prompt again.
Signed-off-by: Simon Glass sjg@chromium.org ---
configs/chromebook_jerry_defconfig | 4 ++++ doc/README.rockchip | 7 ++++--- include/configs/chromebook_jerry.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/configs/chromebook_jerry_defconfig b/configs/chromebook_jerry_defconfig index da47707..a515d8d 100644 --- a/configs/chromebook_jerry_defconfig +++ b/configs/chromebook_jerry_defconfig @@ -27,7 +27,9 @@ CONFIG_RESET=y CONFIG_DM_MMC=y CONFIG_ROCKCHIP_DWMMC=y CONFIG_PINCTRL=y +# CONFIG_PINCTRL_FULL is not set CONFIG_SPL_PINCTRL=y +# CONFIG_SPL_PINCTRL_FULL is not set CONFIG_ROCKCHIP_PINCTRL=y CONFIG_DM_PMIC=y CONFIG_PMIC_ACT8846=y @@ -41,5 +43,7 @@ CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_DEBUG_UART_SHIFT=2 CONFIG_SYS_NS16550=y CONFIG_USE_PRIVATE_LIBGCC=y +CONFIG_USE_TINY_PRINTF=y CONFIG_CMD_DHRYSTONE=y CONFIG_ERRNO_STR=y +CONFIG_ROCKCHIP_SPI=y diff --git a/doc/README.rockchip b/doc/README.rockchip index b455f6f..9a2ebca 100644 --- a/doc/README.rockchip +++ b/doc/README.rockchip @@ -135,9 +135,10 @@ Booting from SPI
To write an image that boots from SPI flash (e.g. for the Haier Chromebook):
- ./chromebook_jerry/tools/mkimage -n rk3036 -T rkspi -d chromebook_jerry/spl/u-boot-spl-dtb.bin out - dd if=spl.bin of=out.bin bs=128K conv=sync - cat chromebook_jerry/u-boot-dtb.img out.bin + ./chromebook_jerry/tools/mkimage -n rk3288 -T rkspi \ + -d chromebook_jerry/spl/u-boot-spl-dtb.bin spl.bin && \ + dd if=spl.bin of=spl-out.bin bs=128K conv=sync && \ + cat spl-out.bin chromebook_jerry/u-boot-dtb.img >out.bin && \ dd if=out.bin of=out.bin.pad bs=4M conv=sync
This converts the SPL image to the required SPI format by adding the Rockchip diff --git a/include/configs/chromebook_jerry.h b/include/configs/chromebook_jerry.h index 058325c..e29d776 100644 --- a/include/configs/chromebook_jerry.h +++ b/include/configs/chromebook_jerry.h @@ -13,5 +13,6 @@ #define CONFIG_SPL_SPI_SUPPORT #define CONFIG_SPL_SPI_FLASH_SUPPORT #define CONFIG_SPL_SPI_LOAD +#define CONFIG_SPI_FLASH_GIGADEVICE
#endif

On 29 December 2015 at 05:22, Simon Glass sjg@chromium.org wrote:
Various updates did not make it through to this board. Also the instructions for building a SPI image are no-longer correct. Fix these so that Jerry can boot to a prompt again.
Signed-off-by: Simon Glass sjg@chromium.org
configs/chromebook_jerry_defconfig | 4 ++++ doc/README.rockchip | 7 ++++--- include/configs/chromebook_jerry.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-)
Applied to u-boot-rockchip, and now in mainline.

Add a check for NULL strings to avoid printing junk to the console.
Signed-off-by: Simon Glass sjg@chromium.org ---
lib/tiny-printf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index 403b134..efe5c25 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -108,8 +108,10 @@ int vprintf(const char *fmt, va_list va) w--; while (w-- > 0) putc(lz ? '0' : ' '); - while ((ch = *p++)) - putc(ch); + if (p) { + while ((ch = *p++)) + putc(ch); + } } }

On 29.12.2015 13:22, Simon Glass wrote:
Add a check for NULL strings to avoid printing junk to the console.
Signed-off-by: Simon Glass sjg@chromium.org
lib/tiny-printf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index 403b134..efe5c25 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -108,8 +108,10 @@ int vprintf(const char *fmt, va_list va) w--; while (w-- > 0) putc(lz ? '0' : ' ');
while ((ch = *p++))
putc(ch);
if (p) {
while ((ch = *p++))
putc(ch);
} }}
Reviewed-by: Stefan Roese sr@denx.de
Thanks, Stefan

On 29 December 2015 at 06:23, Stefan Roese sr@denx.de wrote:
On 29.12.2015 13:22, Simon Glass wrote:
Add a check for NULL strings to avoid printing junk to the console.
Signed-off-by: Simon Glass sjg@chromium.org
lib/tiny-printf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index 403b134..efe5c25 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -108,8 +108,10 @@ int vprintf(const char *fmt, va_list va) w--; while (w-- > 0) putc(lz ? '0' : ' ');
while ((ch = *p++))
putc(ch);
if (p) {
while ((ch = *p++))
putc(ch);
} } }
Reviewed-by: Stefan Roese sr@denx.de
Applied to u-boot-dm

For SPL we don't really need sprintf() and with tiny-printf this is not available. Allow this to be dropped in SPL when using tiny-printf.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/mtd/spi/sf-uclass.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c index 72e0f6b..5aa4e6f 100644 --- a/drivers/mtd/spi/sf-uclass.c +++ b/drivers/mtd/spi/sf-uclass.c @@ -55,11 +55,17 @@ int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs, { struct spi_slave *slave; struct udevice *bus; - char name[30], *str; + char *str; int ret;
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_USE_TINY_PRINTF) + str = "spi_flash"; +#else + char name[30]; + snprintf(name, sizeof(name), "spi_flash@%d:%d", busnum, cs); str = strdup(name); +#endif ret = spi_get_bus_and_cs(busnum, cs, max_hz, spi_mode, "spi_flash_std", str, &bus, &slave); if (ret)

On 29 December 2015 at 05:22, Simon Glass sjg@chromium.org wrote:
For SPL we don't really need sprintf() and with tiny-printf this is not available. Allow this to be dropped in SPL when using tiny-printf.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/mtd/spi/sf-uclass.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Applied to u-boot-rockchip, as it fixes a build error with Jerry.

For SPL we don't really need sprintf() and with tiny-printf this is not available. Allow this to be dropped in SPL when using tiny-printf.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/gpio/gpio-uclass.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 4cce11f..3ed4d89 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -154,6 +154,7 @@ int dm_gpio_request(struct gpio_desc *desc, const char *label)
static int dm_gpio_requestf(struct gpio_desc *desc, const char *fmt, ...) { +#if !defined(CONFIG_SPL_BUILD) || !defined(CONFIG_USE_TINY_PRINTF) va_list args; char buf[40];
@@ -161,6 +162,9 @@ static int dm_gpio_requestf(struct gpio_desc *desc, const char *fmt, ...) vscnprintf(buf, sizeof(buf), fmt, args); va_end(args); return dm_gpio_request(desc, buf); +#else + return dm_gpio_request(desc, fmt); +#endif }
/** @@ -199,6 +203,7 @@ int gpio_request(unsigned gpio, const char *label) */ int gpio_requestf(unsigned gpio, const char *fmt, ...) { +#if !defined(CONFIG_SPL_BUILD) || !defined(CONFIG_USE_TINY_PRINTF) va_list args; char buf[40];
@@ -206,6 +211,9 @@ int gpio_requestf(unsigned gpio, const char *fmt, ...) vscnprintf(buf, sizeof(buf), fmt, args); va_end(args); return gpio_request(gpio, buf); +#else + return gpio_request(gpio, fmt); +#endif }
int _dm_gpio_free(struct udevice *dev, uint offset)

On 29 December 2015 at 05:22, Simon Glass sjg@chromium.org wrote:
For SPL we don't really need sprintf() and with tiny-printf this is not available. Allow this to be dropped in SPL when using tiny-printf.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/gpio/gpio-uclass.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Applied to u-boot-dm

At present we add driver-model MMC devices in the order we find them. The 'alias' order is not honoured.
It is difficult to fix this for the case where we have holes in the sequence. But for the common case where the devices are numbered from 0 without any gaps, we can add the devices to the internal data structures in this order.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/mmc/mmc.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 3a34028..ae24b63 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1772,18 +1772,28 @@ static int mmc_probe(bd_t *bis) #elif defined(CONFIG_DM_MMC) static int mmc_probe(bd_t *bis) { - int ret; + int ret, i; struct uclass *uc; - struct udevice *m; + struct udevice *dev;
ret = uclass_get(UCLASS_MMC, &uc); if (ret) return ret;
- uclass_foreach_dev(m, uc) { - ret = device_probe(m); + /* + * Try to add them in sequence order. Really with driver model we + * should allow holes, but the current MMC list does not allow that. + * So if we request 0, 1, 3 we will get 0, 1, 2. + */ + for (i = 0; ; i++) { + ret = uclass_get_device_by_seq(UCLASS_MMC, i, &dev); + if (ret == -ENODEV) + break; + } + uclass_foreach_dev(dev, uc) { + ret = device_probe(dev); if (ret) - printf("%s - probe failed: %d\n", m->name, ret); + printf("%s - probe failed: %d\n", dev->name, ret); }
return 0;

On 29 December 2015 at 05:22, Simon Glass sjg@chromium.org wrote:
At present we add driver-model MMC devices in the order we find them. The 'alias' order is not honoured.
It is difficult to fix this for the case where we have holes in the sequence. But for the common case where the devices are numbered from 0 without any gaps, we can add the devices to the internal data structures in this order.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/mmc/mmc.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
Applied to u-boot-dm

We should not return a -ve error code from command functions. Instead, return CMD_RET_FAILURE. This avoids the "exit not allowed from main input shell" error messages from the hush shell.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/cmd_i2c.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 552c875..b3bb644 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -1809,7 +1809,8 @@ static int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc, if (ret) printf("Failure changing bus number (%d)\n", ret); } - return ret; + + return ret ? CMD_RET_FAILURE : 0; } #endif /* defined(CONFIG_SYS_I2C) */
@@ -1852,7 +1853,8 @@ static int do_i2c_bus_speed(cmd_tbl_t * cmdtp, int flag, int argc, char * const if (ret) printf("Failure changing bus speed (%d)\n", ret); } - return ret; + + return ret ? CMD_RET_FAILURE : 0; }
/**

Hello Simon,
Am 29.12.2015 um 13:22 schrieb Simon Glass:
We should not return a -ve error code from command functions. Instead, return CMD_RET_FAILURE. This avoids the "exit not allowed from main input shell" error messages from the hush shell.
Signed-off-by: Simon Glass sjg@chromium.org
common/cmd_i2c.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Thanks! As it is in a patchserie:
Acked-by: Heiko Schocher hs@denx.de
bye, Heiko
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 552c875..b3bb644 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -1809,7 +1809,8 @@ static int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc, if (ret) printf("Failure changing bus number (%d)\n", ret); }
- return ret;
- return ret ? CMD_RET_FAILURE : 0; } #endif /* defined(CONFIG_SYS_I2C) */
@@ -1852,7 +1853,8 @@ static int do_i2c_bus_speed(cmd_tbl_t * cmdtp, int flag, int argc, char * const if (ret) printf("Failure changing bus speed (%d)\n", ret); }
- return ret;
return ret ? CMD_RET_FAILURE : 0; }
/**

On 4 January 2016 at 00:08, Heiko Schocher hs@denx.de wrote:
Hello Simon,
Am 29.12.2015 um 13:22 schrieb Simon Glass:
We should not return a -ve error code from command functions. Instead, return CMD_RET_FAILURE. This avoids the "exit not allowed from main input shell" error messages from the hush shell.
Signed-off-by: Simon Glass sjg@chromium.org
common/cmd_i2c.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Thanks! As it is in a patchserie:
Acked-by: Heiko Schocher hs@denx.de
Applied to u-boot-dm!

This is an uncommon but annoying case. Normal error handling will ensure it is reported, but it is useful to have a message which provides a little more detail.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/malloc_simple.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/common/malloc_simple.c b/common/malloc_simple.c index 479a1e4..4621b6d 100644 --- a/common/malloc_simple.c +++ b/common/malloc_simple.c @@ -21,8 +21,11 @@ void *malloc_simple(size_t bytes) new_ptr = gd->malloc_ptr + bytes; debug("%s: size=%zx, ptr=%lx, limit=%lx\n", __func__, bytes, new_ptr, gd->malloc_limit); - if (new_ptr > gd->malloc_limit) + if (new_ptr > gd->malloc_limit) { + printf("Out of memory (%zu bytes, %lx requested)\n", bytes, + new_ptr); return NULL; + } ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes); gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));

This can create a large number of pinctrl devices. It chews up early malloc() memory and takes time. Only bind those which are marked as needed before relocation.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/pinctrl/pinctrl-uclass.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c index b5fdcd1..c42b312 100644 --- a/drivers/pinctrl/pinctrl-uclass.c +++ b/drivers/pinctrl/pinctrl-uclass.c @@ -111,12 +111,16 @@ static int pinconfig_post_bind(struct udevice *dev) { const void *fdt = gd->fdt_blob; int offset = dev->of_offset; + bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC); const char *name; int ret;
for (offset = fdt_first_subnode(fdt, offset); offset > 0; offset = fdt_next_subnode(fdt, offset)) { + if (pre_reloc_only && + !fdt_getprop(fdt, offset, "u-boot,dm-pre-reloc", NULL)) + continue; /* * If this node has "compatible" property, this is not * a pin configuration node, but a normal device. skip.

On 29 December 2015 at 05:22, Simon Glass sjg@chromium.org wrote:
This can create a large number of pinctrl devices. It chews up early malloc() memory and takes time. Only bind those which are marked as needed before relocation.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/pinctrl/pinctrl-uclass.c | 4 ++++ 1 file changed, 4 insertions(+)
Applied to u-boot-dm!
participants (3)
-
Heiko Schocher
-
Simon Glass
-
Stefan Roese