Skip to contentSkip to conversation

Initial Stamp9261 board support

PATCH New Michael Roth 4 participants 12 messages Feb 4, 2009 – Feb 5, 2009

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

cover Initial Stamp9261 board support

Hello,

this is a patch to support the Taskit Stamp9261 board.

If the EXTRABOARDOBJS patch is not acceptable please let me know and maybe make a suggestion how to solve it.

Michael Roth

#1 lore raw

PATCH 1/2 Allow board specific overwriting of library code

Enables to overwrite any library code by defining EXTRABOARDOBJS in the board specific config.mk.
Those listed object files get linked directly into the u-boot binary right after the start objects and before any archives.

---
 Makefile |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
Makefile +10 -2
index 787c5f2..50c9975 100644
@@ -273,6 +273,8 @@ LIBS := $(addprefix $(obj),$(LIBS))
 LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).a
 LIBBOARD := $(addprefix $(obj),$(LIBBOARD))
 
+EXTRABOARDOBJS := $(addprefix $(obj)board/$(BOARDDIR)/,$(EXTRABOARDOBJS))
+
 # Add GCC lib
 PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
 
@@ -294,7 +296,7 @@ ONENAND_IPL = onenand_ipl
 U_BOOT_ONENAND = $(obj)u-boot-onenand.bin
 endif
 
-__OBJS := $(subst $(obj),,$(OBJS))
+__OBJS := $(subst $(obj),,$(OBJS)) $(subst $(obj),,$(EXTRABOARDOBJS))
 __LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD))
 
 #########################################################################
@@ -338,7 +340,8 @@ $(obj)u-boot.sha1:	$(obj)u-boot.bin
 $(obj)u-boot.dis:	$(obj)u-boot
 		$(OBJDUMP) -d $< > $@
 
-$(obj)u-boot:		depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT)
+$(obj)u-boot:		depend $(SUBDIRS) $(OBJS) $(EXTRABOARDOBJS) \
+			$(LIBBOARD) $(LIBS) $(LDSCRIPT)
 		UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
 		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
 		cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
@@ -348,6 +351,11 @@ $(obj)u-boot:		depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT)
 $(OBJS):	depend $(obj)include/autoconf.mk
 		$(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
 
+$(EXTRABOARDOBJS):	depend $(obj)include/autoconf.mk
+		$(MAKE) -C $(dir $(subst $(obj),,$@)) \
+			$(if $(REMOTE_BUILD), \
+				$(EXTRABOARDOBJS),$(notdir $(EXTRABOARDOBJS)))
+
 $(LIBS):	depend $(obj)include/autoconf.mk $(SUBDIRS)
 		$(MAKE) -C $(dir $(subst $(obj),,$@))
 
Signature · 1 line
1.6.0.6
#2 lore raw

PATCH 2/2 Stamp9261 board support

Initial support for Taskit Stamp9261 board - based on an AT91SAM9261 SoC from Atmel.

Currently only a Stamp9261 with 64MB RAM fitted together with a Stamp-Adaptor on a Panel-Card EVB is supported.

---
 MAINTAINERS                     |    4 +
 MAKEALL                         |    1 +
 Makefile                        |    3 +
 board/stamp9261/Makefile        |   60 ++++++
 board/stamp9261/config.mk       |    2 +
 board/stamp9261/led.c           |   77 ++++++++
 board/stamp9261/lowlevel_init.S |  387 +++++++++++++++++++++++++++++++++++++++
 board/stamp9261/stamp9261.c     |  139 ++++++++++++++
 include/configs/stamp9261.h     |  199 ++++++++++++++++++++
 9 files changed, 872 insertions(+), 0 deletions(-)
 create mode 100644 board/stamp9261/Makefile
 create mode 100644 board/stamp9261/config.mk
 create mode 100644 board/stamp9261/led.c
 create mode 100644 board/stamp9261/lowlevel_init.S
 create mode 100644 board/stamp9261/stamp9261.c
 create mode 100644 include/configs/stamp9261.h
MAINTAINERS +4 -0
index 38feac8..59cd536 100644
@@ -607,6 +607,10 @@ Stefan Roese <[email protected]>
 	pdnb3		xscale
 	scpu		xscale
 
+Michael Roth <[email protected]>
+
+	stamp9261	ARM926EJS (AT91SAM9261 SoC)
+
 Alessandro Rubini <[email protected]>
 Nomadik Linux Team <[email protected]>
 
MAKEALL +1 -0
index cf05133..7a5bbbf 100755
@@ -573,6 +573,7 @@ LIST_at91="		\
 	kb9202		\
 	mp2usb		\
 	m501sk		\
+	stamp9261	\
 "
 
 #########################################################################
Makefile +3 -0
index 50c9975..20cccf0 100644
@@ -2831,6 +2831,9 @@ smdk2400_config	:	unconfig
 smdk2410_config	:	unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 samsung s3c24x0
 
+stamp9261_config:	unconfig
+	@$(MKCONFIG) $(@:_config=) arm arm926ejs stamp9261 NULL at91
+
 SX1_stdout_serial_config \
 SX1_config:		unconfig
 	@mkdir -p $(obj)include
board/stamp9261/Makefile new file +60 -0

60 lines not on this page · raw message

board/stamp9261/config.mk new file +2 -0
new file mode 100644
index 0000000..6d8135a
@@ -0,0 +1,2 @@
+TEXT_BASE = 0x23f00000
+EXTRABOARDOBJS = lowlevel_init.o led.o
board/stamp9261/led.c new file +77 -0

77 lines not on this page · raw message

board/stamp9261/lowlevel_init.S new file +387 -0

387 lines not on this page · raw message

board/stamp9261/stamp9261.c new file +139 -0

139 lines not on this page · raw message

include/configs/stamp9261.h new file +199 -0

199 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#3 lore raw

PATCH 2/2 Stamp9261 board support

Dear Michael Roth,

Quoted 7 lines · In message <[email protected]> you wrote:

Initial support for Taskit Stamp9261 board - based on an AT91SAM9261 SoC from Atmel.

Currently only a Stamp9261 with 64MB RAM fitted together with a Stamp-Adaptor on a Panel-Card EVB is supported.

...

board/stamp9261/led.c

Quoted 5 lines
board/stamp9261/led.c new file +0 -0
new file mode 100644
index 0000000..367db20

NAK. Enough is enough, and this is more than enough.

We already have 6 mostly identical copies of board/atmel/at91*/led.c files. I will not accept adding yet another of these.

Please move the common stuff into common code with just board specific cunfigurable settings.

Quoted 5 lines
board/stamp9261/lowlevel_init.S new file +0 -0
new file mode 100644
index 0000000..0531091

...

Quoted 10 lines
board/stamp9261/lowlevel_init.S new file +10 -0
+#define SRAM_BASE		0x300000	/* Internal SRAM C */
+
+#define SDRAM_BASE		0x20000000	/* External SDRAM */
+
+#define SYS_BASE		0xffffea00	/* System Controller */
+
+#define SDRAMC_OFFSET		(0xffffea00 - SYS_BASE)
+#define SDRAMC_MR_OFFSET	(0xffffea00 - SDRAMC_OFFSET - SYS_BASE)
+#define SDRAMC_TR_OFFSET	(0xffffea04 - SDRAMC_OFFSET - SYS_BASE)
+#define SDRAMC_CR_OFFSET	(0xffffea08 - SDRAMC_OFFSET - SYS_BASE)

board/stamp9261/lowlevel_init.S line 47

Quoted 10 lines
board/stamp9261/lowlevel_init.S new file +10 -0
+
+#define SMC0_OFFSET		(0xffffec00 - SYS_BASE)
+
+#define MATRIX_OFFSET		(0xffffee00 - SYS_BASE)
+#define MATRIX_SCFG3_OFFSET	(0xffffee10 - MATRIX_OFFSET - SYS_BASE)
+#define SLOT_CYCLE(a)		((a)<<0)
+#define DEFMSTR_TYPE(a)		((a)<<16)
+#define FIXED_DEFMSTR(a)	((a)<<18)
+#define EBI_CSA_OFFSET		(0xffffee30 - MATRIX_OFFSET - SYS_BASE)
+#define EBI_CS1A(a)		((a)<<1)

...

etc.

NAK. lowlevel_init.S is not the place for such #defines. Either these are common to the processor, than they should be part of some processor header file, or they are board specific, then they should be part of your board config file.

Quoted 5 lines
board/stamp9261/stamp9261.c new file +0 -0
new file mode 100644
index 0000000..51fe785

...

Quoted 18 lines
board/stamp9261/stamp9261.c new file +18 -0
+/*
+ * Serial Port initialisation
+ */
+static void stamp9261_serial_init(void)
+{
+#ifdef CONFIG_ATMEL_USART
+#ifdef CONFIG_USART0
+	at91_set_A_periph(AT91_PIN_PC8, 1);		/* TXD0 */
+	at91_set_A_periph(AT91_PIN_PC9, 0);		/* RXD0 */
+	at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_US0);
+#endif
+#ifdef CONFIG_USART1
+	at91_set_A_periph(AT91_PIN_PC12, 1);		/* TXD1 */
+	at91_set_A_periph(AT91_PIN_PC13, 0);		/* RXD1 */
+	at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_US1);
+#endif
+#ifdef CONFIG_USART2
+	at91_set_A_periph(AT91_PIN_PC14, 1);		/* TXD2 */

board/stamp9261/stamp9261.c line 68

Quoted 10 lines
board/stamp9261/stamp9261.c new file +10 -0
+	at91_set_A_periph(AT91_PIN_PC15, 0);		/* RXD2 */
+	at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_US2);
+#endif
+#ifdef CONFIG_USART3	/* DBGU */
+	at91_set_A_periph(AT91_PIN_PA10, 1);		/* DTXD */
+	at91_set_A_periph(AT91_PIN_PA9, 0);		/* DRXD */
+	at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+#endif
+#endif
+}

Error handling if CONFIG_ATMEL_USART or if none of CONFIG_USART[0-3] is defined?

board/stamp9261/stamp9261.c line 105

Quoted 7 lines
board/stamp9261/stamp9261.c new file +7 -0
+int board_init(void)
+{
+	/* Enable Ctrlc */
+	console_init_f();
+
+	/* arch number of Stamp9261 on Panel-Card EVB */
+	gd->bd->bi_arch_number = 2056;	/* FIXME: Change to MACH_TYPE_STAMP9261_PC_EVB as soon as include/asm-arm/mach-types.h is updated */

Maximum line length exceeded.

board/stamp9261/stamp9261.c line 125

Quoted 6 lines
board/stamp9261/stamp9261.c new file +6 -0
+int dram_init(void)
+{
+	gd->bd->bi_dram[0].start = PHYS_SDRAM;
+	gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE;
+	return 0;
+}

You should auto-size the RAM instead of hardcoding it.

board/stamp9261/stamp9261.c line 137

Quoted 11 lines
board/stamp9261/stamp9261.c new file +11 -0
+
+#ifdef CONFIG_RESET_PHY_R
+void reset_phy(void)
+{
+#ifdef CONFIG_DRIVER_DM9000
+	/*
+	 * Initialize ethernet HW addr prior to starting Linux,
+	 * needed for nfsroot
+	 */
+	eth_init(gd->bd);
+#endif

No. Please do not do this. This is in violation with U-Boot implementation requirements. The network interface MUST NOT be initialized if no network related command is used in U-Boot. See for example http://www.denx.de/wiki/U-Boot/DesignRequirements

Quoted 3 lines
include/configs/stamp9261.h new file +0 -0
new file mode 100644
index 0000000..ab825e2

...

Quoted 4 lines

+/*
+ * Clocks
+ *
+ * Supported values for AT91_CPU_CLOCK are: 161938286, 199916308, 239616000

Maximum line length exceeded.

include/configs/stamp9261.h line 52

Quoted 3 lines
include/configs/stamp9261.h new file +3 -0
+#define CONFIG_CMDLINE_TAG	/* enable command line passing */
+#define CONFIG_SETUP_MEMORY_TAGS /* tells memory configuration to the kernel */
+#define CONFIG_INITRD_TAG	/* tells where the initrd can be found */

Maximum line length exceeded.

include/configs/stamp9261.h line 128

Quoted 6 lines
include/configs/stamp9261.h new file +6 -0
+/*
+ * SDRAM
+ */
+#define CONFIG_NR_DRAM_BANKS	1
+#define PHYS_SDRAM		0x20000000
+#define PHYS_SDRAM_SIZE		0x04000000	/* 64 megs */

Please use get_ram_size() instead.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The first 90% of a project takes 90% of the time, the last 10%  takes
the other 90% of the time.
#4 lore raw

PATCH 2/2 Stamp9261 board support

Quoted 8 lines · Wolfgang Denk

board/stamp9261/stamp9261.c line 125

Quoted 6 lines
board/stamp9261/stamp9261.c new file +6 -0
+int dram_init(void)
+{
+	gd->bd->bi_dram[0].start = PHYS_SDRAM;
+	gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE;
+	return 0;
+}

You should auto-size the RAM instead of hardcoding it.

	[...]
Quoted 5 lines

include/configs/stamp9261.h line 128

Quoted 3 lines
include/configs/stamp9261.h new file +3 -0
+#define CONFIG_NR_DRAM_BANKS	1
+#define PHYS_SDRAM		0x20000000
+#define PHYS_SDRAM_SIZE		0x04000000	/* 64 megs */

Please use get_ram_size() instead.

On this board U-Boot runs from the same memory which get_ram_size() should probe for its actual size.

Currently, as far as I can see, the implementation of get_ram_size() don't hit itself (by fortune?) while probing. But maybe the algorithm will change in some feature.

Additionally the fixed RAM size is (implicit) needed in several other places for example CONFIG_SYS_MEMTEST_END and lowlevel initialization of SDRAM, relocation to TEXT_BASE and so on.

Normally autoconf is a good thing (TM) but in this case I'm not sure.

Michael Roth

#5 lore raw

PATCH 1/2 Allow board specific overwriting of library code

In reply to Michael Roth
Quoted 6 lines · Michael Roth

Enables to overwrite any library code by defining EXTRABOARDOBJS in the board specific config.mk.
Those listed object files get linked directly into the u-boot binary right after the start objects and before any archives.

Hi Michael,

Sorry for not speaking up sooner, but the term "overwrite" had really bad connotations (implies you are smashing the library). "Override" is a much better term for what you are doing.

FWIIW, I don't have experience with "weak" functions, but I've seen the struggles of others on this email list. My understanding is that you are getting gcc (the linker, actually) to behave much more as a developer expects when he needs to override a weak function. (Current gcc behavior makes sense to the gcc folks, but tends to surprise mere mortals. The principle of least astonishment[1] says this is a problem.)

Thanks,
gvb

[1] <http://en.wikipedia.org/wiki/Principle_of_least_astonishment>

#6 lore raw

PATCH 1/2 Allow board specific overwriting of library code

In reply to Michael Roth

Dear Michael Roth,

Quoted 4 lines · In message <[email protected]> you wrote:

Enables to overwrite any library code by defining EXTRABOARDOBJS in the board specific config.mk.
Those listed object files get linked directly into the u-boot binary right after the start objects and before any archives.

Why would that be needed?

Normally you deal with such issues in your linker script, i. e. in a board specific way without need to modify global files.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Bradley's Bromide: If computers get too  powerful,  we  can  organize
them into a committee - that will do them in.
#7 lore raw

PATCH 1/2 Allow board specific overwriting of library code

Quoted 1 line · Wolfgang Denk

Why would that be needed?

Because the whole weak-linking looks like it is somewhat broken or at least very difficult to get it correctly.

Quoted 2 lines

Normally you deal with such issues in your linker script, i. e. in a board specific way without need to modify global files.

Yes, there are several possible solutions to address this issue. Until now, there were discussed: CONFIG_XYZ and ifdef/endif and pre-build objects (patch from Jean-Christophe) and my proposal.

Using a board specific linker script is another way.

However, because the problem regarding weak-linking is a global one, maybe the circumvention should be global too.

But I don't know. I could also use a board specific linker script.

Michael Roth

(Email resend because of stupid user error by my...)

#8 lore raw

PATCH 1/2 Allow board specific overwriting of library code

Dear Michael Roth,

Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 2 lines

Why would that be needed?

Because the whole weak-linking looks like it is somewhat broken or at least very difficult to get it correctly.

Then you should at least document this purpose in the commit message.

Quoted 8 lines

Yes, there are several possible solutions to address this issue. Until now, there were discussed: CONFIG_XYZ and ifdef/endif and pre-build objects (patch from Jean-Christophe) and my proposal.

Using a board specific linker script is another way.

However, because the problem regarding weak-linking is a global one, maybe the circumvention should be global too.

In the long term, following the Linux style is probably the way to go. In the man time, I suggest to use what has least impact.

Quoted 1 line

But I don't know. I could also use a board specific linker script.

OK, fine.

Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
This restaurant was advertising breakfast  any  time.  So  I  ordered
french toast in the renaissance.            - Steven Wright, comedian
#9 lore raw

PATCH 1/2 Allow board specific overwriting of library code

In reply to Michael Roth
Quoted 2 lines · Michael Roth

Because the whole weak-linking looks like it is somewhat broken or at least very difficult to get it correctly.

Small example:

In board/atmel/at91sam9261ek there is:

led.c:

	void red_LED_on(void)
	...
	void red_LED_off(void)
	...

Makefile:

	COBJS-y += led.o
	...
	OBJS    := $(addprefix $(obj),$(COBJS-y))
	...
	$(LIB): $(obj).depend $(OBJS) $(SOBJS)

And in lib_arm/board.c we have:

	void inline __red_LED_on (void) {}
	void inline red_LED_on (void) __attribute__((weak, alias("__red_LED_on")));
	void inline __red_LED_off(void) {}
	void inline red_LED_off(void)        __attribute__((weak, alias("__red_LED_off")));

But as you can see from u-boot.map, the result is not as expected:

	0x23f00340      0x35c lib_arm/libarm.a(board.o)
	0x23f00390                __red_LED_off
	...
	0x23f00390                red_LED_off
	...
	0x23f0038c                red_LED_on
	0x23f0038c                __red_LED_on

No single weak symbol from lib_arm/board.c get overridden from the board specific led.c. Very annoying.

Michael Roth

#10 lore raw

PATCH 1/2 Allow board specific overwriting of library code

Quoted 43 lines · On Wednesday 04 February 2009 11:18:16 Michael Roth wrote:
Quoted 2 lines · Michael Roth

Because the whole weak-linking looks like it is somewhat broken or at least very difficult to get it correctly.

Small example:

In board/atmel/at91sam9261ek there is:

led.c:

	void red_LED_on(void)
	...
	void red_LED_off(void)
	...

Makefile:

	COBJS-y += led.o
	...
	OBJS    := $(addprefix $(obj),$(COBJS-y))
	...
	$(LIB): $(obj).depend $(OBJS) $(SOBJS)

And in lib_arm/board.c we have:

	void inline __red_LED_on (void) {}
	void inline red_LED_on (void) __attribute__((weak,

alias("__red_LED_on"))); void inline __red_LED_off(void) {}
void inline red_LED_off(void) __attribute__((weak,
alias("__red_LED_off")));

But as you can see from u-boot.map, the result is not as expected:

	0x23f00340      0x35c lib_arm/libarm.a(board.o)
	0x23f00390                __red_LED_off
	...
	0x23f00390                red_LED_off
	...
	0x23f0038c                red_LED_on
	0x23f0038c                __red_LED_on
Quoted 2 lines

No single weak symbol from lib_arm/board.c get overridden from the board specific led.c. Very annoying.

that's because your led.o was not pulled in for any other reason. give it a reason to be pulled in and the weak overrides will work fine. in other words, what you show is not the linker being broken, but your expectations being broken ;).
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090204/e259fc99/attachment.pgp

#11 lore raw

PATCH 1/2 Allow board specific overwriting of library code

In reply to Michael Roth

Dear Michael Roth,

Quoted 3 lines · In message <[email protected]> you wrote:
Quoted 3 lines

Because the whole weak-linking looks like it is somewhat broken or at least very difficult to get it correctly.

...

Quoted 9 lines

But as you can see from u-boot.map, the result is not as expected:

	0x23f00340      0x35c lib_arm/libarm.a(board.o)
	0x23f00390                __red_LED_off
	...
	0x23f00390                red_LED_off
	...
	0x23f0038c                red_LED_on
	0x23f0038c                __red_LED_on

Link led.o explicitely, and early, in your linker script.

I don't see what's very difficult to do that.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You don't have to stay up nights to succeed; you have to  stay  awake
days.