mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-26 06:30:39 +00:00
VoiceBlue: fix linker errors
linking eeprom with libgeneric.a is not really needed and causes following error: ../../lib_generic/libgeneric.a(string.o): In function `strcmp': /home/ladis/src/u-boot-ti/lib_generic/string.c:152: multiple definition of `strcmp' ../../examples/standalone/libstubs.a(stubs.o):include/_exports.h:24: first defined here make[1]: *** [eeprom.srec] Error 1 Fix undefined reference to memset generated by some versions of gcc to zero out initialized structure on the stack: eeprom.o: In function `eeprom': board/voiceblue/eeprom.c:152: undefined reference to `memset' make[1]: *** [eeprom] Error 1 Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
This commit is contained in:
parent
a32c1e0ecd
commit
5c97a1de19
4 changed files with 65 additions and 127 deletions
|
@ -29,40 +29,37 @@ LIB = $(obj)lib$(BOARD).a
|
||||||
COBJS := voiceblue.o
|
COBJS := voiceblue.o
|
||||||
SOBJS := setup.o
|
SOBJS := setup.o
|
||||||
|
|
||||||
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) eeprom.c eeprom_start.S
|
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
|
||||||
OBJS := $(addprefix $(obj),$(COBJS))
|
OBJS := $(addprefix $(obj),$(COBJS))
|
||||||
SOBJS := $(addprefix $(obj),$(SOBJS))
|
SOBJS := $(addprefix $(obj),$(SOBJS))
|
||||||
|
|
||||||
gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
|
|
||||||
|
|
||||||
LOAD_ADDR = 0x10400000
|
LOAD_ADDR = 0x10400000
|
||||||
LDSCRIPT = $(TOPDIR)/board/$(BOARDDIR)/eeprom.lds
|
|
||||||
lnk = $(if $(obj),$(obj),.)
|
#########################################################################
|
||||||
|
|
||||||
all: $(obj).depend $(LIB) $(obj)eeprom.srec $(obj)eeprom.bin
|
all: $(obj).depend $(LIB) $(obj)eeprom.srec $(obj)eeprom.bin
|
||||||
|
|
||||||
$(LIB): $(OBJS) $(SOBJS)
|
$(LIB): $(OBJS) $(SOBJS)
|
||||||
$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
|
$(AR) $(ARFLAGS) $@ $^
|
||||||
|
|
||||||
$(obj)eeprom.srec: $(obj)eeprom.o $(obj)eeprom_start.o $(obj)u-boot.lds
|
$(obj)eeprom_start.o:
|
||||||
cd $(lnk) && $(LD) -T $(obj)u-boot.lds -g -Ttext $(LOAD_ADDR) \
|
echo "b eeprom" | $(CC) $(AFLAGS) -c -x assembler -o $@ -
|
||||||
-o $(<:.o=) -e eeprom eeprom.o eeprom_start.o \
|
|
||||||
|
$(obj)eeprom: $(obj)eeprom_start.o $(obj)eeprom.o
|
||||||
|
$(LD) -Ttext $(LOAD_ADDR) -e eeprom -o $@ $^ \
|
||||||
-L$(obj)../../examples/standalone -lstubs \
|
-L$(obj)../../examples/standalone -lstubs \
|
||||||
-L$(obj)../../lib_generic -lgeneric \
|
$(PLATFORM_LIBS)
|
||||||
-L$(gcclibdir) -lgcc
|
|
||||||
$(OBJCOPY) -O srec $(<:.o=) $@
|
|
||||||
|
|
||||||
$(obj)eeprom.bin: $(obj)eeprom.srec
|
$(obj)eeprom.srec: $(obj)eeprom
|
||||||
$(OBJCOPY) -I srec -O binary $< $@ 2>/dev/null
|
$(OBJCOPY) -S -O srec $(<:.o=) $@
|
||||||
|
|
||||||
$(obj)u-boot.lds: $(LDSCRIPT)
|
$(obj)eeprom.bin: $(obj)eeprom
|
||||||
$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
|
$(OBJCOPY) -S -O binary $< $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(SOBJS) $(OBJS) $(obj)eeprom \
|
rm -f $(SOBJS) $(OBJS) $(obj)eeprom \
|
||||||
$(obj)eeprom.srec $(obj)eeprom.bin \
|
$(obj)eeprom.srec $(obj)eeprom.bin \
|
||||||
$(obj)eeprom.o $(obj)eeprom_start.o \
|
$(obj)eeprom.o $(obj)eeprom_start.o
|
||||||
$(obj)u-boot.lds
|
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -f $(LIB) core *.bak $(obj).depend
|
rm -f $(LIB) core *.bak $(obj).depend
|
||||||
|
|
|
@ -22,75 +22,82 @@
|
||||||
* Some code shamelessly stolen back from Robin Getz.
|
* Some code shamelessly stolen back from Robin Getz.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DEBUG
|
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <exports.h>
|
#include <exports.h>
|
||||||
#include <timestamp.h>
|
#include <timestamp.h>
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
#include "../drivers/net/smc91111.h"
|
#include "../drivers/net/smc91111.h"
|
||||||
|
|
||||||
static u16 read_eeprom_reg(struct eth_device *dev, u16 reg)
|
static struct eth_device dev = {
|
||||||
|
.iobase = CONFIG_SMC91111_BASE
|
||||||
|
};
|
||||||
|
|
||||||
|
static u16 read_eeprom_reg(u16 reg)
|
||||||
{
|
{
|
||||||
int timeout;
|
int timeout;
|
||||||
|
|
||||||
SMC_SELECT_BANK(dev, 2);
|
SMC_SELECT_BANK(&dev, 2);
|
||||||
SMC_outw(dev, reg, PTR_REG);
|
SMC_outw(&dev, reg, PTR_REG);
|
||||||
|
|
||||||
|
SMC_SELECT_BANK(&dev, 1);
|
||||||
|
SMC_outw(&dev, SMC_inw(&dev, CTL_REG) | CTL_EEPROM_SELECT |
|
||||||
|
CTL_RELOAD, CTL_REG);
|
||||||
|
|
||||||
SMC_SELECT_BANK(dev, 1);
|
|
||||||
SMC_outw(dev, SMC_inw (dev, CTL_REG) | CTL_EEPROM_SELECT | CTL_RELOAD,
|
|
||||||
CTL_REG);
|
|
||||||
timeout = 100;
|
timeout = 100;
|
||||||
while((SMC_inw (dev, CTL_REG) & CTL_RELOAD) && --timeout)
|
|
||||||
|
while ((SMC_inw(&dev, CTL_REG) & CTL_RELOAD) && --timeout)
|
||||||
udelay(100);
|
udelay(100);
|
||||||
if (timeout == 0) {
|
if (timeout == 0) {
|
||||||
printf("Timeout Reading EEPROM register %02x\n", reg);
|
printf("Timeout reading register %02x\n", reg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SMC_inw (dev, GP_REG);
|
return SMC_inw(&dev, GP_REG);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_eeprom_reg(struct eth_device *dev, u16 value, u16 reg)
|
static int write_eeprom_reg(u16 value, u16 reg)
|
||||||
{
|
{
|
||||||
int timeout;
|
int timeout;
|
||||||
|
|
||||||
SMC_SELECT_BANK(dev, 2);
|
SMC_SELECT_BANK(&dev, 2);
|
||||||
SMC_outw(dev, reg, PTR_REG);
|
SMC_outw(&dev, reg, PTR_REG);
|
||||||
|
|
||||||
|
SMC_SELECT_BANK(&dev, 1);
|
||||||
|
|
||||||
|
SMC_outw(&dev, value, GP_REG);
|
||||||
|
SMC_outw(&dev, SMC_inw(&dev, CTL_REG) | CTL_EEPROM_SELECT |
|
||||||
|
CTL_STORE, CTL_REG);
|
||||||
|
|
||||||
SMC_SELECT_BANK(dev, 1);
|
|
||||||
SMC_outw(dev, value, GP_REG);
|
|
||||||
SMC_outw(dev, SMC_inw (dev, CTL_REG) | CTL_EEPROM_SELECT | CTL_STORE, CTL_REG);
|
|
||||||
timeout = 100;
|
timeout = 100;
|
||||||
while ((SMC_inw(dev, CTL_REG) & CTL_STORE) && --timeout)
|
|
||||||
|
while ((SMC_inw(&dev, CTL_REG) & CTL_STORE) && --timeout)
|
||||||
udelay(100);
|
udelay(100);
|
||||||
if (timeout == 0) {
|
if (timeout == 0) {
|
||||||
printf("Timeout Writing EEPROM register %02x\n", reg);
|
printf("Timeout writing register %02x\n", reg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_data(struct eth_device *dev, u16 *buf, int len)
|
static int write_data(u16 *buf, int len)
|
||||||
{
|
{
|
||||||
u16 reg = 0x23;
|
u16 reg = 0x23;
|
||||||
|
|
||||||
while (len--)
|
while (len--)
|
||||||
write_eeprom_reg(dev, *buf++, reg++);
|
write_eeprom_reg(*buf++, reg++);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int verify_macaddr(struct eth_device *dev, char *s)
|
static int verify_macaddr(char *s)
|
||||||
{
|
{
|
||||||
u16 reg;
|
u16 reg;
|
||||||
int i, err = 0;
|
int i, err = 0;
|
||||||
|
|
||||||
printf("MAC Address: ");
|
puts("HWaddr: ");
|
||||||
err = i = 0;
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
reg = read_eeprom_reg(dev, 0x20 + i);
|
reg = read_eeprom_reg(0x20 + i);
|
||||||
printf("%02x:%02x%c", reg & 0xff, reg >> 8, i != 2 ? ':' : '\n');
|
printf("%02x:%02x%c", reg & 0xff, reg >> 8, i != 2 ? ':' : '\n');
|
||||||
if (s)
|
if (s)
|
||||||
err |= reg != ((u16 *)s)[i];
|
err |= reg != ((u16 *)s)[i];
|
||||||
|
@ -99,7 +106,7 @@ static int verify_macaddr(struct eth_device *dev, char *s)
|
||||||
return err ? 0 : 1;
|
return err ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_mac(struct eth_device *dev, char *s)
|
static int set_mac(char *s)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *e, eaddr[6];
|
char *e, eaddr[6];
|
||||||
|
@ -111,7 +118,7 @@ static int set_mac(struct eth_device *dev, char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
write_eeprom_reg(dev, *(((u16 *)eaddr) + i), 0x20 + i);
|
write_eeprom_reg(*(((u16 *)eaddr) + i), 0x20 + i);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -147,34 +154,30 @@ int eeprom(int argc, char *argv[])
|
||||||
int i, len, ret;
|
int i, len, ret;
|
||||||
unsigned char buf[58], *p;
|
unsigned char buf[58], *p;
|
||||||
|
|
||||||
struct eth_device dev = {
|
|
||||||
.iobase = CONFIG_SMC91111_BASE
|
|
||||||
};
|
|
||||||
|
|
||||||
app_startup(argv);
|
app_startup(argv);
|
||||||
if (get_version() != XF_VERSION) {
|
i = get_version();
|
||||||
printf("Wrong XF_VERSION.\n");
|
if (i != XF_VERSION) {
|
||||||
printf("Application expects ABI version %d\n", XF_VERSION);
|
printf("Using ABI version %d, but U-Boot provides %d\n",
|
||||||
printf("Actual U-Boot ABI version %d\n", (int)get_version());
|
XF_VERSION, i);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((SMC_inw(&dev, BANK_SELECT) & 0xFF00) != 0x3300) {
|
if ((SMC_inw(&dev, BANK_SELECT) & 0xFF00) != 0x3300) {
|
||||||
printf("SMSC91111 not found.\n");
|
puts("SMSC91111 not found\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called without parameters - print MAC address */
|
/* Called without parameters - print MAC address */
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
verify_macaddr(&dev, NULL);
|
verify_macaddr(NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print help message */
|
/* Print help message */
|
||||||
if (argv[1][1] == 'h') {
|
if (argv[1][1] == 'h') {
|
||||||
printf("VoiceBlue EEPROM writer\n");
|
puts("VoiceBlue EEPROM writer\n"
|
||||||
printf("Built: %s at %s\n", U_BOOT_DATE, U_BOOT_TIME);
|
"Built: " U_BOOT_DATE " at " U_BOOT_TIME "\n"
|
||||||
printf("Usage:\n\t<mac_address> [<element_1>] [<...>]\n");
|
"Usage:\n\t<mac_address> [<element_1>] [<...>]\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +194,7 @@ int eeprom(int argc, char *argv[])
|
||||||
printf("Element %d: odd character count\n", i - 1);
|
printf("Element %d: odd character count\n", i - 1);
|
||||||
return 3;
|
return 3;
|
||||||
case -3:
|
case -3:
|
||||||
printf("Out of EEPROM memory\n");
|
puts("Out of EEPROM memory\n");
|
||||||
return 3;
|
return 3;
|
||||||
default:
|
default:
|
||||||
p += ret;
|
p += ret;
|
||||||
|
@ -200,16 +203,16 @@ int eeprom(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* First argument (MAC) is mandatory */
|
/* First argument (MAC) is mandatory */
|
||||||
set_mac(&dev, argv[1]);
|
set_mac(argv[1]);
|
||||||
if (verify_macaddr(&dev, argv[1])) {
|
if (verify_macaddr(argv[1])) {
|
||||||
printf("*** MAC address does not match! ***\n");
|
puts("*** HWaddr does not match! ***\n");
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (len--)
|
while (len--)
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
|
|
||||||
write_data(&dev, (u16 *)buf, sizeof(buf) >> 1);
|
write_data((u16 *)buf, sizeof(buf) >> 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
/*
|
|
||||||
* (C) Copyright 2002
|
|
||||||
* Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
|
|
||||||
* (C) Copyright 2005
|
|
||||||
* Ladislav Michl, 2N Telekomunikace, <michl@2n.cz>
|
|
||||||
*
|
|
||||||
* See file CREDITS for list of people who contributed to this
|
|
||||||
* project.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
||||||
* MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
|
||||||
OUTPUT_ARCH(arm)
|
|
||||||
ENTRY(_start)
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
. = ALIGN(4);
|
|
||||||
.text :
|
|
||||||
{
|
|
||||||
eeprom_start.o (.text)
|
|
||||||
*(.text)
|
|
||||||
}
|
|
||||||
|
|
||||||
. = ALIGN(4);
|
|
||||||
.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
|
|
||||||
|
|
||||||
. = ALIGN(4);
|
|
||||||
.data : { *(.data) }
|
|
||||||
|
|
||||||
. = ALIGN(4);
|
|
||||||
.got : { *(.got) }
|
|
||||||
|
|
||||||
. = ALIGN(4);
|
|
||||||
__bss_start = .;
|
|
||||||
.bss (NOLOAD) : { *(.bss) . = ALIGN(4); }
|
|
||||||
_end = .;
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2005 2N Telekomunikace
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* version 2 as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
.globl _start
|
|
||||||
_start: b eeprom
|
|
Loading…
Reference in a new issue