[U-Boot-Users] [PATCH] 1/7 Nios: bugfixes

Stephan Linz linz at mazet.de
Mon Feb 2 11:53:57 CET 2004


Hi all,
Hi Scott,

last week I've made some bugfixes, structure changes and expansion of the 
U-Boot NIOS port:

1/7   bugfixes
2/7   split board configuration of DK1C20
3/7   split board configuration of DK1S10
4/7   new CPU configuration / support at DK1S10 (Microtronix LDK 2.0)
5/7   new documentation for DK1S10
6/7   Nios SPI Master support
7/7   DS1306 with external SPI transfer

These pathes are realy important for my upcoming new Nios board support. 
Scott, could you check-up the pathes at your DK1C20 board and note me and 
Wolfgang so we can put it into CVS ? -- thanks.


Best Regards,
Stephan Linz

------------------ THIS IS PATCH 1/7 ------------------

* Patch by Stephan Linz, 30 Jan 2004
  - board/altera/common/flash.c:flash_erase():
    o allow interrupts befor get_timer() call
    o check-up each erased sector and avoid unexpected timeouts
  - board/altera/common/sevenseg.c:
    o avoid 'unused' warning
  - board/altera/dk1c20/dk1c20.c:board_early_init_f():
  - board/altera/dk1c20/dk1s10.c:board_early_init_f():
    o enclose sevenseg_set() in cpp condition
  - makes the ASMI configuration of DK1C20 more conform to documentation
  - remove the ASMI configuration for DK1S10_standard_32 (never present)
  - fix some typed in mistakes in the NIOS documentation
-------------- next part --------------
diff -purN -x CVS u-boot-20040130cvs/board/altera/common/flash.c u-boot-20040130cvs-nios_bugfixes/board/altera/common/flash.c
--- u-boot-20040130cvs/board/altera/common/flash.c	2004-01-03 20:43:48.000000000 +0100
+++ u-boot-20040130cvs-nios_bugfixes/board/altera/common/flash.c	2004-02-01 00:49:06.000000000 +0100
@@ -71,7 +71,6 @@ int flash_erase (flash_info_t * info, in
 	volatile CFG_FLASH_WORD_SIZE *addr = (CFG_FLASH_WORD_SIZE *) (info->start[0]);
 	volatile CFG_FLASH_WORD_SIZE *addr2;
 	int prot, sect;
-	int any = 0;
 	unsigned oldpri;
 	ulong start;
 
@@ -94,6 +93,12 @@ int flash_erase (flash_info_t * info, in
 		printf ("\n");
 	}
 
+#ifdef DEBUG
+	for (sect = s_first; sect <= s_last; sect++) {
+		printf("- Erase: Sect: %i @ 0x%08x\n", sect,  info->start[sect]);
+	}
+#endif
+
 	/* NOTE: disabling interrupts on Nios can be very bad since it
 	 * also disables the LO_LIMIT exception. It's better here to
 	 * set the interrupt priority to 3 & restore it when we're done.
@@ -114,27 +119,26 @@ int flash_erase (flash_info_t * info, in
 			*addr = 0xaa;
 			*addr = 0x55;
 			*addr2 = 0x30;
-			any = 1;
-		}
-	}
-
-	/* Now just wait for 0xff & provide some user feedback while
-	 * we wait.
-	 */
-	if (any) {
-		addr2 = (CFG_FLASH_WORD_SIZE *) (info->start[sect]);
-		start = get_timer (0);
-		while (*addr2 != 0xff) {
-			udelay (1000 * 1000);
-			putc ('.');
-			if (get_timer (start) > CFG_FLASH_ERASE_TOUT) {
-				printf ("timeout\n");
-				return 1;
+			/* Now just wait for 0xff & provide some user
+			 * feedback while we wait. Here we have to grant
+			 * timer interrupts. Otherwise get_timer() can't
+			 * work right. */
+			ipri(oldpri);
+			start = get_timer (0);
+			while (*addr2 != 0xff) {
+				udelay (1000 * 1000);
+				putc ('.');
+				if (get_timer (start) > CFG_FLASH_ERASE_TOUT) {
+					printf ("timeout\n");
+					return 1;
+				}
 			}
+			oldpri = ipri (3); /* disallow non important irqs again */
 		}
-		printf ("\n");
 	}
 
+	printf ("\n");
+
 	/* Restore interrupt priority */
 	ipri (oldpri);
 
diff -purN -x CVS u-boot-20040130cvs/board/altera/common/sevenseg.c u-boot-20040130cvs-nios_bugfixes/board/altera/common/sevenseg.c
--- u-boot-20040130cvs/board/altera/common/sevenseg.c	2004-01-03 20:43:48.000000000 +0100
+++ u-boot-20040130cvs-nios_bugfixes/board/altera/common/sevenseg.c	2004-02-01 00:49:06.000000000 +0100
@@ -44,7 +44,7 @@ static int sevenseg_init_done = 0;
 
 static inline void __sevenseg_set_masked (unsigned int mask, int value)
 {
-	nios_pio_t *piop = (nios_pio_t*)SEVENSEG_BASE;
+	nios_pio_t *piop __attribute__((unused)) = (nios_pio_t*)SEVENSEG_BASE;
 
 #ifdef	SEVENSEG_WRONLY	/* emulate read access */
 
@@ -97,7 +97,7 @@ static inline void __sevenseg_toggle_mas
 
 static inline void __sevenseg_set (unsigned int value)
 {
-	nios_pio_t *piop = (nios_pio_t*)SEVENSEG_BASE;
+	nios_pio_t *piop __attribute__((unused)) = (nios_pio_t*)SEVENSEG_BASE;
 
 #ifdef	SEVENSEG_WRONLY	/* emulate read access */
 
@@ -126,7 +126,7 @@ static inline void __sevenseg_set (unsig
 
 static inline void __sevenseg_init (void)
 {
-	nios_pio_t *piop = (nios_pio_t*)SEVENSEG_BASE;
+	nios_pio_t *piop __attribute__((unused)) = (nios_pio_t*)SEVENSEG_BASE;
 
 	__sevenseg_set(0);
 
diff -purN -x CVS u-boot-20040130cvs/board/altera/dk1c20/dk1c20.c u-boot-20040130cvs-nios_bugfixes/board/altera/dk1c20/dk1c20.c
--- u-boot-20040130cvs/board/altera/dk1c20/dk1c20.c	2004-01-21 00:12:13.000000000 +0100
+++ u-boot-20040130cvs-nios_bugfixes/board/altera/dk1c20/dk1c20.c	2004-02-01 00:49:06.000000000 +0100
@@ -33,8 +33,10 @@ void _default_hdlr (void)
 
 int board_early_init_f (void)
 {
+#if	defined(CONFIG_SEVENSEG)
 	/* init seven segment led display and switch off */
 	sevenseg_set(SEVENSEG_OFF);
+#endif
 	return 0;
 }
 
diff -purN -x CVS u-boot-20040130cvs/board/altera/dk1s10/dk1s10.c u-boot-20040130cvs-nios_bugfixes/board/altera/dk1s10/dk1s10.c
--- u-boot-20040130cvs/board/altera/dk1s10/dk1s10.c	2004-01-21 00:12:13.000000000 +0100
+++ u-boot-20040130cvs-nios_bugfixes/board/altera/dk1s10/dk1s10.c	2004-02-01 00:49:06.000000000 +0100
@@ -33,8 +33,10 @@ void _default_hdlr (void)
 
 int board_early_init_f (void)
 {
+#if	defined(CONFIG_SEVENSEG)
 	/* init seven segment led display and switch off */
 	sevenseg_set(SEVENSEG_OFF);
+#endif
 	return 0;
 }
 
diff -purN -x CVS u-boot-20040130cvs/doc/README.dk1c20 u-boot-20040130cvs-nios_bugfixes/doc/README.dk1c20
--- u-boot-20040130cvs/doc/README.dk1c20	2004-01-04 17:28:35.000000000 +0100
+++ u-boot-20040130cvs-nios_bugfixes/doc/README.dk1c20	2004-02-01 00:49:06.000000000 +0100
@@ -24,7 +24,7 @@ Contents:
 
 1. Files
 =========
-	board/dk1c20/*
+	board/altera/dk1c20/*
 	include/configs/DK1C20.h
 
 2. Memory Organization
@@ -73,11 +73,7 @@ see the following:
 2. Quit nios-run and start your terminal application (e.g. start
 Hyperterminal or minicom).
 
-3. From the U-Boot command prompt, erase flash 0x40000 to 0x 5ffff:
-
-    ==> erase 1:4-5
-
-4. Download the u-boot code to RAM. When using Hyperterminal, do the
+3. Download the u-boot code to RAM. When using Hyperterminal, do the
 following:
 
    a.  From the u-boot command prompt start a binary download to SRAM:
@@ -86,6 +82,10 @@ following:
 
     b. Download u-boot.bin using kermit.
 
+4. From the U-Boot command prompt, erase flash 0x40000 to 0x5ffff:
+
+    ==> erase 1:4-5
+
 5. Copy the binary image from SRAM to flash:
 
     ==> cp.b 800000 40000 10000
diff -purN -x CVS u-boot-20040130cvs/doc/README.dk1c20_std32 u-boot-20040130cvs-nios_bugfixes/doc/README.dk1c20_std32
--- u-boot-20040130cvs/doc/README.dk1c20_std32	2004-01-03 20:43:49.000000000 +0100
+++ u-boot-20040130cvs-nios_bugfixes/doc/README.dk1c20_std32	2004-02-01 00:49:06.000000000 +0100
@@ -91,10 +91,10 @@ IDE:	(TODO)
   0x02000000 ---32-----------16|15------------0-
 	       |	       :	       | \
 	       |	       :	       | |
-  SDRAM	       |	       :	       |  > CFG_NIOS_CPU_SRAM_SIZE
+  SDRAM	       |	       :	       |  > CFG_NIOS_CPU_SDRAM_SIZE
 	       |	       :	       | |   = 0x01000000
 	       |	       :	       | /
-  0x01000000 ---32-----------16|15------------0-    CFG_NIOS_CPU_SRAM_BASE
+  0x01000000 ---32-----------16|15------------0-    CFG_NIOS_CPU_SDRAM_BASE
 	       |			       |
 	       :	      gap	       :
 	       :			       :
@@ -345,6 +345,7 @@ IDE:	(TODO)
 	       |	       :	       | |
   0x00040000 --+- - - - - - - -:- - - - - - - -+-|- u-boot _start()
 	       |	       :	       | /
+  0x00000000   |- - - - - - - -:- - - - - - - -+- - u-boot environment
   0x00000000 ---8-------------4|3-------------0-
 
 
diff -purN -x CVS u-boot-20040130cvs/doc/README.dk1s10_std32 u-boot-20040130cvs-nios_bugfixes/doc/README.dk1s10_std32
--- u-boot-20040130cvs/doc/README.dk1s10_std32	2004-01-03 20:43:49.000000000 +0100
+++ u-boot-20040130cvs-nios_bugfixes/doc/README.dk1s10_std32	2004-02-01 00:49:06.000000000 +0100
@@ -87,10 +87,10 @@ IDE:	(TODO)
   0x02000000 ---32-----------16|15------------0-
 	       |	       :	       | \
 	       |	       :	       | |
-  SDRAM	       |	       :	       |  > CFG_NIOS_CPU_SRAM_SIZE
+  SDRAM	       |	       :	       |  > CFG_NIOS_CPU_SDRAM_SIZE
 	       |	       :	       | |   = 0x01000000
 	       |	       :	       | /
-  0x01000000 ---32-----------16|15------------0-    CFG_NIOS_CPU_SRAM_BASE
+  0x01000000 ---32-----------16|15------------0-    CFG_NIOS_CPU_SDRAM_BASE
 	       |			       |
 	       :	      gap	       :
 	       :			       :
@@ -335,6 +335,7 @@ IDE:	(TODO)
 	       |	       :	       | |
   0x00040000 --+- - - - - - - -:- - - - - - - -+-|- u-boot _start()
 	       |	       :	       | /
+  0x00000000   |- - - - - - - -:- - - - - - - -+- - u-boot environment
   0x00000000 ---8-------------4|3-------------0-
 
 
diff -purN -x CVS u-boot-20040130cvs/doc/README.dk20k200_std32 u-boot-20040130cvs-nios_bugfixes/doc/README.dk20k200_std32
--- u-boot-20040130cvs/doc/README.dk20k200_std32	2004-01-03 20:43:49.000000000 +0100
+++ u-boot-20040130cvs-nios_bugfixes/doc/README.dk20k200_std32	2004-02-01 00:49:06.000000000 +0100
@@ -117,7 +117,7 @@ UART:	UART0: fixed baudrate of 115200, f
 	+ 0x18 |- - - - - - - - - - - - - - - -| |
 	       |		     (unused)  | |
 	+ 0x14 |- - - - - - - - - - - - - - - -| |
-  UART0	       |		     (unused)  |  > 0x00000020
+  UART1	       |		     (unused)  |  > 0x00000020
   [2]	+ 0x10 |- - - - - - - - - - - - - - - -| |
 	       |  control (10 bit)	 (rw)  | |
 	+ 0x0c |- - - - - - - - - - - - - - - -| |
diff -purN -x CVS u-boot-20040130cvs/include/configs/DK1C20.h u-boot-20040130cvs-nios_bugfixes/include/configs/DK1C20.h
--- u-boot-20040130cvs/include/configs/DK1C20.h	2004-01-21 00:12:33.000000000 +0100
+++ u-boot-20040130cvs-nios_bugfixes/include/configs/DK1C20.h	2004-02-01 00:49:06.000000000 +0100
@@ -647,8 +647,8 @@
  * ASMI is for Cyclone devices only and only works when the configuration
  * is loaded via JTAG or ASMI. Please see doc/README.dk1c20 for details.
  *----------------------------------------------------------------------*/
-#define CONFIG_NIOS_ASMI			/* Enable ASMI		*/
-#define CFG_NIOS_ASMIBASE	0x00920b00	/* ASMI base address	*/
+#define CONFIG_NIOS_ASMI			   /* Enable ASMI	*/
+#define CFG_NIOS_ASMIBASE	CFG_NIOS_CPU_ASMI0 /* ASMI base address	*/
 
 /*------------------------------------------------------------------------
  * COMMANDS
diff -purN -x CVS u-boot-20040130cvs/include/configs/DK1S10.h u-boot-20040130cvs-nios_bugfixes/include/configs/DK1S10.h
--- u-boot-20040130cvs/include/configs/DK1S10.h	2004-01-21 00:12:33.000000000 +0100
+++ u-boot-20040130cvs-nios_bugfixes/include/configs/DK1S10.h	2004-02-01 00:49:06.000000000 +0100
@@ -243,11 +243,6 @@
 #define	CFG_NIOS_CPU_IDE_NUMS	1		/* number of IDE contr.	*/
 #define	CFG_NIOS_CPU_IDE0	0x00920a00	/* IDE0		addr	*/
 
-/* active serial memory i/f */
-#define	CFG_NIOS_CPU_ASMI_NUMS	1		/* number of ASMI	*/
-#define	CFG_NIOS_CPU_ASMI0	0x00920b00	/* ASMI0	addr	*/
-#define	CFG_NIOS_CPU_ASMI0_IRQ	45		/*		IRQ	*/
-
 /* memory accessibility */
 #define	CFG_NIOS_CPU_SRAM_BASE	0x00800000	/* board SRAM	addr	*/
 #define	CFG_NIOS_CPU_SRAM_SIZE	(1024 * 1024)	/*  1 MB	size	*/
-------------- next part --------------
* Patch by Stephan Linz, 30 Jan 2004
  - board/altera/common/flash.c:flash_erase():
    o allow interrupts befor get_timer() call
    o check-up each erased sector and avoid unexpected timeouts
  - board/altera/common/sevenseg.c:
    o avoid 'unused' warning
  - board/altera/dk1c20/dk1c20.c:board_early_init_f():
  - board/altera/dk1c20/dk1s10.c:board_early_init_f():
    o enclose sevenseg_set() in cpp condition
  - makes the ASMI configuration of DK1C20 more conform to documentation
  - remove the ASMI configuration for DK1S10_standard_32 (never present)
  - fix some typed in mistakes in the NIOS documentation


More information about the U-Boot mailing list