Skip to contentSkip to conversation

Fix friendlyarm-tiny210 regression

PATCH In review Alexey Galakhov 2 participants 5 messages Jul 9, 2013

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

cover Fix friendlyarm-tiny210 regression

Tiny210 was broken in the most recent releases of barebox. This is the fix.

Alexey Galakhov (3):
friendlyarm-tiny210: do not restart barebox twice
friendlyarm-tiny210: use LEDs for boot errors
friendlyarm-tiny210: add heartbeat LED

 arch/arm/boards/friendlyarm-tiny210/lowlevel.c |   57 ++++++++++++++++++++----
 arch/arm/boards/friendlyarm-tiny210/tiny210.c  |    2 +
 2 files changed, 51 insertions(+), 8 deletions(-)
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/3 friendlyarm-tiny210: do not restart barebox twice

The old way to boot tiny210 was to restart barebox after loading stage2 image. This turned out to be unstable and stopped working after barebox refactoring. Now jump to the same position in the loaded code instead of starting it from the very beginning.

---
 arch/arm/boards/friendlyarm-tiny210/lowlevel.c |   31 ++++++++++++++++++------
 1 file changed, 23 insertions(+), 8 deletions(-)
arch/arm/boards/friendlyarm-tiny210/lowlevel.c +23 -8
index 3bd1379..0c7fbf3 100644
@@ -31,6 +31,8 @@
 #include <mach/s3c-clocks.h>
 #include <mach/s3c-generic.h>
 
+#define IRAM_CODE_BASE		0xD0020010
+
 /*
  * iROM boot from MMC
  * TODO: replace this by native boot
@@ -50,6 +52,19 @@ int __bare_init s5p_irom_load_mmc(void *dest, uint32_t start_block, uint16_t blo
 	return func(chan, start_block, block_count, (uint32_t*)dest, 0) ? 1 : 0;
 }
 
+static __bare_init __naked void jump_sdram(unsigned long offset)
+{
+	__asm__ __volatile__ (
+			"sub lr, lr, %0;"
+			"mov pc, lr;" : : "r"(offset)
+			);
+}
+
+static __bare_init bool load_stage2(void *dest, size_t size)
+{
+	/* TODO add other ways to boot */
+	return s5p_irom_load_mmc(dest, 1, (size+ 511) / 512);
+}
 
 void __bare_init barebox_arm_reset_vector(void)
 {
@@ -61,18 +76,18 @@ void __bare_init barebox_arm_reset_vector(void)
 	s5p_init_pll();
 #endif
 
-	if (get_pc() < 0xD0000000) /* Are we running from iRAM? */
+	if (get_pc() < IRAM_CODE_BASE) /* Are we running from iRAM? */
 		/* No, we don't. */
-		barebox_arm_entry(S3C_SDRAM_BASE, SZ_64M, 0);
+		goto boot;
 
 	s5p_init_dram_bank_ddr2(S5P_DMC0_BASE, 0x20E00323, 0, 0);
 
-	if (! s5p_irom_load_mmc((void*)TEXT_BASE - 16, 1,
-				(ld_var(_barebox_image_size) + 16 + 511) / 512))
+	if (! load_stage2((void*)(ld_var(_text) - 16),
+				ld_var(_barebox_image_size) + 16))
 		while (1) { } /* hang */
 
-	/* Jump to SDRAM */
-	r = (unsigned)TEXT_BASE;
-	__asm__ __volatile__("mov pc, %0" : : "r"(r));
-	while (1) { } /* hang */
+	jump_sdram(IRAM_CODE_BASE - ld_var(_text));
+
+boot:
+	barebox_arm_entry(S3C_SDRAM_BASE, SZ_256M, 0);
 }
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/3 friendlyarm-tiny210: use LEDs for boot errors

In reply to Alexey Galakhov
---
 arch/arm/boards/friendlyarm-tiny210/lowlevel.c |   28 +++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
arch/arm/boards/friendlyarm-tiny210/lowlevel.c +27 -1
index 0c7fbf3..9676094 100644
@@ -33,6 +33,22 @@
 
 #define IRAM_CODE_BASE		0xD0020010
 
+/* Tiny210 has 4 leds numbered from 0 to 3 at GPJ2 */
+static inline void __bare_init debug_led(int led, bool state)
+{
+	uint32_t r;
+	/* GPJ2CON: mode 0001=output */
+	r = readl(0xE0200280);
+	r &= ~(0xF << (4 * led));
+	r |=  (0x1 << (4 * led));
+	writel(r, 0xE0200280);
+	/* GPJ2DAT: active low */
+	r = readl(0xE0200284);
+	r &= ~(1 << led);
+	r |= (state ? 0 : 1) << led;
+	writel(r, 0xE0200284);
+}
+
 /*
  * iROM boot from MMC
  * TODO: replace this by native boot
@@ -76,18 +92,28 @@ void __bare_init barebox_arm_reset_vector(void)
 	s5p_init_pll();
 #endif
 
+	debug_led(0, 1);
+
 	if (get_pc() < IRAM_CODE_BASE) /* Are we running from iRAM? */
 		/* No, we don't. */
 		goto boot;
 
 	s5p_init_dram_bank_ddr2(S5P_DMC0_BASE, 0x20E00323, 0, 0);
 
+	debug_led(1, 1);
+
 	if (! load_stage2((void*)(ld_var(_text) - 16),
-				ld_var(_barebox_image_size) + 16))
+				ld_var(_barebox_image_size) + 16)) {
+		debug_led(3, 1);
 		while (1) { } /* hang */
+	}
+
+	debug_led(2, 1);
 
 	jump_sdram(IRAM_CODE_BASE - ld_var(_text));
 
+	debug_led(1, 0);
+
 boot:
 	barebox_arm_entry(S3C_SDRAM_BASE, SZ_256M, 0);
 }
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 3/3 friendlyarm-tiny210: add heartbeat LED

In reply to Alexey Galakhov
---
 arch/arm/boards/friendlyarm-tiny210/tiny210.c |    2 ++
 1 file changed, 2 insertions(+)
arch/arm/boards/friendlyarm-tiny210/tiny210.c +2 -0
index 18494b0..fb144f5 100644
@@ -105,6 +105,8 @@ static int tiny210_devices_init(void)
 		led_gpio_register(&leds[i]);
 	}
 
+	led_set_trigger(LED_TRIGGER_HEARTBEAT, &leds[0].led);
+
 	armlinux_set_bootparams((void*)S3C_SDRAM_BASE + 0x100);
 	armlinux_set_architecture(MACH_TYPE_MINI210);
 
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw
In reply to Alexey Galakhov
Quoted 6 lines · Alexey Galakhov

Tiny210 was broken in the most recent releases of barebox. This is the fix.

Alexey Galakhov (3):
friendlyarm-tiny210: do not restart barebox twice
friendlyarm-tiny210: use LEDs for boot errors
friendlyarm-tiny210: add heartbeat LED

Applied the first one to master and stable/v2013.07 and the remaining to next.

Thanks
Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox