--- u-boot-1.2.0/lib_mips/board.c
+++ u-boot-1.2.0/lib_mips/board.c
@@ -28,6 +28,7 @@
 #include <version.h>
 #include <net.h>
 #include <environment.h>
+#include <stb225_gpio.h>
 
 #if (CONFIG_COMMANDS & CFG_CMD_NAND)
 /*#include <linux/mtd/nand_ids.h>*/
@@ -312,6 +313,7 @@ void board_init_f(ulong bootflag)
 
 static char stb225_mac_address[20];
 #include "nand.h"
+extern unsigned int sdram_MemoryTestQuick(unsigned int);
 void board_init_r (gd_t *id, ulong dest_addr)
 {
 	cmd_tbl_t *cmdtp;
@@ -551,6 +553,29 @@ void board_init_r (gd_t *id, ulong dest_
 #endif
 #endif
 
+	if (sdram_MemoryTestQuick(id->ram_size > (128 * 1024 * 1024) ? 2 : 1)) {
+		int times = 0;
+		const gpio_pin_t LED_PIN = GPIO_7;
+
+		printf("SDRAM test failure. Halting.\n");
+		gpio_set_as_input(GPIO_23);
+		gpio_set_as_output(LED_PIN, 0);
+
+		// Don't let people exit too quickly.
+		while ((++times < 10) || gpio_get_value(GPIO_23)) {
+			// Turn error LED on.
+			gpio_set_low(LED_PIN);
+			udelay(250000);
+
+			// Turn error LED off.
+			gpio_set_high(LED_PIN);
+			udelay(1500000+300000);
+
+			if (times == 10)
+				printf("Hold GPIO12 to escape %d.\n", gpio_get_value(GPIO_23));
+		}
+	}
+
 	/*
 	   timer_init() is called very early in the u-boot startup sequence and
 	   initialises the value returned by 'get_ticks()' to 0. Therefore, at
