--- flash_t.orig.cpp	2012-01-22 19:11:06.000000000 +0100
+++ flash_t.cpp	2012-02-04 20:38:56.942653200 +0100
@@ -1527,6 +1527,24 @@
 
 	printf("AMDFlash::Write_Config_Flash\r\n");
 
+    SectorAddress = (unsigned long) nasys_main_flash + Config_Flash;			// get config start address
+    for (unsigned long *sa=SectorAddress; sa<(SectorAddress+0x3999); sa+=CONFIG_SIZE) {
+        //printf("Checking for free slot @ %lX ... ",sa);
+        if ((sa[1] == 0xFFFFFFFF) && (sa[299] == 0xFFFFFFFF))
+        {
+            //printf("found\r\n");
+            SectorAddress=sa;   // Use next free Slot
+            break;
+        }
+    }
+
+    if(SectorAddress==(unsigned long) nasys_main_flash + Config_Flash) {
+        //printf("Config sector full, erase\r\n");
+        if (-1 == nr_flash_erase_sector((unsigned long *) nasys_main_flash, SectorAddress))		// erase config area
+        { lWriteError = true; }
+    }
+
+
 	//backup LED setting
 	if (LED_ON[0] == 1) led_value = led_value | 0x0001;		// Select Channel 1
 	if (LED_ON[1] == 1) led_value = led_value | 0x0002;		// Select Channel 2
@@ -1545,11 +1563,6 @@
 	if (LED_ON[14] == 1) led_value = led_value | 0x4000;		// Single Red					
 	if (LED_ON[15] == 1) led_value = led_value | 0x8000;		// Single Green	
 
-	SectorAddress = (unsigned long) nasys_main_flash + Config_Flash;			// get config start address
-
-	if (-1 == nr_flash_erase_sector((unsigned long *) nasys_main_flash, SectorAddress))		// erase config area 
-	{ lWriteError = true; }
-
 	buf[0] = (unsigned long) 0x00;
 	buf[1] = (unsigned long) 0xAACC5523;		// Configuration Start Sign
 	buf[2] = (unsigned long) 0x22334455;
@@ -1982,14 +1995,33 @@
 //	int x;
 	unsigned long *SectorAddress;
 	unsigned long buf[300];
+    unsigned long *lastfound;
 	
 	for(int lbackup=0;lbackup<2;lbackup++)	//try only two times
 	{
 		if (lbackup)
 		{SectorAddress = (unsigned long) nasys_main_flash + ConfBackup_Flash;}		// get config backup start address
 		else
-		{SectorAddress = (unsigned long) nasys_main_flash + Config_Flash;}		// get config start address
-		
+        {SectorAddress = (unsigned long) nasys_main_flash + Config_Flash;}			// get config start address
+
+        lastfound = NULL;
+        for (unsigned long *sa=SectorAddress; sa<(SectorAddress+0x3999); sa+=300) {
+            //printf("Checking for config @ %lX ... ",sa);
+            if ((sa[1] == 0xAACC5523) && (sa[2] == 0x22334455) && (sa[299] == 0x23232323))
+            {
+                //printf("found\r\n");
+                lastfound=sa;
+            }
+            else
+            {
+                SectorAddress=lastfound;   // Use last valid config
+                break;
+            }
+        }
+
+        if (lastfound==NULL) { continue; }  // No valid config found
+
+        printf("Reading config from %lX.\r\n", SectorAddress);
 		for (int x = 0; x < 300; x++) buf[x] = SectorAddress[x];
 		
 		if ((buf[4] == tc_version) && (buf[5] == tc_subversion) && (buf[6] == tc_dev_version) && (buf[1] == 0xAACC5523) && (buf[2] == 0x22334455) && (buf[299] == 0x23232323))
