Skip to contentSkip to conversation

rockchip: Tidy up SPL operation on jerry

PATCH New Simon Glass 3 participants 22 messages Dec 29, 2015 – Jan 16, 2016

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover 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(-)
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
#1 lore raw

PATCH 1/10 rockchip: Enable generation of SPI images

This feature was dropped at some point. Restore it.

---

 tools/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/Makefile +1 -1
index 9cfd80b..d49e40d 100644
@@ -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 \
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
#2 lore raw

PATCH 1/10 rockchip: Enable generation of SPI images

Quoted 7 lines · Simon Glass

This feature was dropped at some point. Restore it.

---

 tools/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-rockchip, and now in mainline.

#3 lore raw

PATCH 2/10 rockchip: Drop a debug message when outputing SPI images

In reply to Simon Glass

There is an unnecessary sector count displayed. Drop it.

---

 tools/rkspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/rkspi.c +1 -1
index 800e235..a0b0051 100644
@@ -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);
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
#4 lore raw

PATCH 2/10 rockchip: Drop a debug message when outputing SPI images

Quoted 22 lines · Simon Glass

There is an unnecessary sector count displayed. Drop it.

---

 tools/rkspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/rkspi.c +1 -2
index 800e235..a0b0051 100644
@@ -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);
--
Quoted 2 lines

2.6.0.rc2.230.g3dd15c0

Applied to u-boot-rockchip, and now in mainline.

#5 lore raw

PATCH 3/10 rockchip: Fix the configuration for chromebook_jerry

In reply to Simon Glass

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.

---

 configs/chromebook_jerry_defconfig | 4 ++++
 doc/README.rockchip                | 7 ++++---
 include/configs/chromebook_jerry.h | 1 +
 3 files changed, 9 insertions(+), 3 deletions(-)
configs/chromebook_jerry_defconfig +4 -0
index da47707..a515d8d 100644
@@ -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
doc/README.rockchip +4 -3
index b455f6f..9a2ebca 100644
@@ -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
include/configs/chromebook_jerry.h +1 -0
index 058325c..e29d776 100644
@@ -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
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
#6 lore raw

PATCH 3/10 rockchip: Fix the configuration for chromebook_jerry

Quoted 11 lines · Simon Glass

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.

---

 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.

#7 lore raw

PATCH 4/10 tiny-printf: Avoid printing NULL strings

In reply to Simon Glass

Add a check for NULL strings to avoid printing junk to the console.

---

 lib/tiny-printf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/tiny-printf.c +4 -2
index 403b134..efe5c25 100644
@@ -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);
+			}
 		}
 	}
 
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
#8 lore raw

PATCH 4/10 tiny-printf: Avoid printing NULL strings

Quoted 16 lines · Simon Glass

Add a check for NULL strings to avoid printing junk to the console.

---

  lib/tiny-printf.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
lib/tiny-printf.c +0 -0
index 403b134..efe5c25 100644
@@ -108,8 +108,10 @@ int vprintf(const char *fmt, va_list va)
  				w--;
  			while (w-- > 0)

lib/tiny-printf.c int vprintf(const char *fmt, va_list va) · line 117

Quoted 10 lines
lib/tiny-printf.c +4 -2
  				putc(lz ? '0' : ' ');
-			while ((ch = *p++))
-				putc(ch);
+			if (p) {
+				while ((ch = *p++))
+					putc(ch);
+			}
  		}
  	}
 

Thanks,
Stefan

#9 lore raw

PATCH 4/10 tiny-printf: Avoid printing NULL strings

Quoted 22 lines · Stefan Roese
Quoted 21 lines · Simon Glass

Add a check for NULL strings to avoid printing junk to the console.

---

  lib/tiny-printf.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
lib/tiny-printf.c +2 -2
index 403b134..efe5c25 100644
@@ -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++))
Quoted 8 lines

lib/tiny-printf.c int vprintf(const char *fmt, va_list va) · line 117

Quoted 6 lines
lib/tiny-printf.c +2 -0
+                                       putc(ch);
+                       }
                }
        }
 

Applied to u-boot-dm

#10 lore raw

PATCH 5/10 dm: spi_flash: Allow the uclass to work without printf()

In reply to Simon Glass

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.

---

 drivers/mtd/spi/sf-uclass.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mtd/spi/sf-uclass.c +7 -1
index 72e0f6b..5aa4e6f 100644
@@ -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)
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
#11 lore raw

PATCH 5/10 dm: spi_flash: Allow the uclass to work without printf()

Quoted 8 lines · Simon Glass

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.

---

 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.

#12 lore raw

PATCH 6/10 dm: gpio: Allow the uclass to work without printf()

In reply to Simon Glass

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.

---

 drivers/gpio/gpio-uclass.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpio/gpio-uclass.c +8 -0
index 4cce11f..3ed4d89 100644
@@ -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)
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
#13 lore raw

PATCH 6/10 dm: gpio: Allow the uclass to work without printf()

Quoted 8 lines · Simon Glass

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.

---

 drivers/gpio/gpio-uclass.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Applied to u-boot-dm

#14 lore raw

PATCH 7/10 dm: mmc: Try to honour the sequence order

In reply to Simon Glass

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.

---

 drivers/mmc/mmc.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/mmc/mmc.c +15 -5
index 3a34028..ae24b63 100644
@@ -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;
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
#15 lore raw

PATCH 7/10 dm: mmc: Try to honour the sequence order

Quoted 8 lines · Simon Glass

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.

Quoted 5 lines

---

 drivers/mmc/mmc.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

Applied to u-boot-dm

#16 lore raw

PATCH 8/10 i2c: Correct command return values

In reply to 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.

---

 common/cmd_i2c.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
common/cmd_i2c.c +4 -2
index 552c875..b3bb644 100644
@@ -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;
 }
 
 /**
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
#17 lore raw

PATCH 8/10 i2c: Correct command return values

Hello Simon,

Am 29.12.2015 um 13:22 schrieb Simon Glass:

Quoted 9 lines

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.

---

  common/cmd_i2c.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)

Thanks! As it is in a patchserie:

bye,
Heiko

Quoted 26 lines
common/cmd_i2c.c +4 -2
index 552c875..b3bb644 100644
@@ -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;
  }
 
  /**
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#18 lore raw

PATCH 8/10 i2c: Correct command return values

Quoted 11 lines · Heiko Schocher

Hello Simon,

Am 29.12.2015 um 13:22 schrieb Simon Glass:

Quoted 8 lines

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.

---

Quoted 8 lines
Quoted 2 lines
  common/cmd_i2c.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)

Thanks! As it is in a patchserie:

Applied to u-boot-dm!

#19 lore raw

PATCH 9/10 malloc_simple: Display an error when memory is exhausted

In reply to Simon Glass

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.

---

 common/malloc_simple.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
common/malloc_simple.c +4 -1
index 479a1e4..4621b6d 100644
@@ -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));
 
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
#20 lore raw

PATCH 10/10 pinctrl: Avoid binding all pinconfig nodes before relocation

In reply to Simon Glass

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.

---

 drivers/pinctrl/pinctrl-uclass.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/pinctrl/pinctrl-uclass.c +4 -0
index b5fdcd1..c42b312 100644
@@ -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.
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
#21 lore raw

PATCH 10/10 pinctrl: Avoid binding all pinconfig nodes before relocation

Quoted 9 lines · Simon Glass

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.

---

 drivers/pinctrl/pinctrl-uclass.c | 4 ++++
 1 file changed, 4 insertions(+)

Applied to u-boot-dm!