'Multiple definition' errors when compiling u-boot_mod for TL-WR1043ND v1 with OpenWrt toolchain

I was pointed to a u-boot mod project that would allow me to install a u-boot with a webserver on my aging TL-WR1043ND v1, which, given the limited recovery capabilities if you're not handy with serial like me, would be a great step forward.

Unfortunately, while the author talks about precompiled images I'm not able to find any and I am stuck building the source myself. It was suggested on IRC it should work with the 15.05 toolchain, so I tried that one, but that breaks... Well, to be fair, they all break; I tried 18.06, 15.05, 14.07 and 12.09 :smiley:.

Errors I'm seeing:

lib_generic/libgeneric.a(string.o): In function `strcpy':
string.c:(.text+0x0): multiple definition of `strcpy'
board/ar7100/ap83/libap83.a(ar7240_flash.o):ar7240_flash.c:(.text+0x67c): first defined here
lib_generic/libgeneric.a(string.o): In function `strncpy':
string.c:(.text+0x24): multiple definition of `strncpy'
board/ar7100/ap83/libap83.a(ar7240_flash.o):ar7240_flash.c:(.text+0x6a0): first defined here
lib_generic/libgeneric.a(string.o): In function `strcmp':
string.c:(.text+0x5c): multiple definition of `strcmp'
board/ar7100/ap83/libap83.a(ar7240_flash.o):ar7240_flash.c:(.text+0x6d8): first defined here
lib_generic/libgeneric.a(string.o): In function `strncmp':
string.c:(.text+0x88): multiple definition of `strncmp'
board/ar7100/ap83/libap83.a(ar7240_flash.o):ar7240_flash.c:(.text+0x704): first defined here
lib_generic/libgeneric.a(string.o): In function `memscan':
string.c:(.text+0xb8): multiple definition of `memscan'
board/ar7100/ap83/libap83.a(ar7240_flash.o):ar7240_flash.c:(.text+0x734): first defined here
Makefile:195: recept voor doel 'u-boot' is mislukt
make[1]: *** [u-boot] Fout 1
Makefile:160: recept voor doel 'tplink_wr1043nd_v1' is mislukt
make: *** [tplink_wr1043nd_v1] Fout 2

I've grepped the source code for multiple definitions, but I'm unsure how to proceed from here, so I'd appreciate all the help I can get. I have filtered further for const with the str* functions since they returned a lot of output, but I can post everything of course.

Grepping for strcpy

$ git grep strcpy|grep const
u-boot/include/asm-mips/string.h:extern __inline__ char *strcpy(char *__dest, __const__ char *__src)
u-boot/include/linux/string.h:extern char * strcpy(char *,const char *);
u-boot/lib_bootstrap/string.c:char * strcpy(char * dest,const char *src)
u-boot/lib_generic/string.c:char * strcpy(char * dest,const char *src)

Grepping for strcmp

$ git grep strcmp|grep const
u-boot/httpd/fs.c:fs_strcmp(const char *str1, const char *str2)
u-boot/include/asm-mips/string.h:extern __inline__ int strcmp(__const__ char *__cs, __const__ char *__ct)
u-boot/include/linux/string.h:extern int strcmp(const char *,const char *);
u-boot/lib_bootstrap/string.c:int strcmp(const char * cs,const char * ct)
u-boot/lib_generic/string.c:int strcmp(const char * cs,const char * ct)

Grepping for strncmp

$ git grep strncmp|grep const
u-boot/include/asm-mips/string.h:strncmp(__const__ char *__cs, __const__ char *__ct, size_t __count)
u-boot/include/linux/string.h:extern int strncmp(const char *,const char *,__kernel_size_t);
u-boot/lib_bootstrap/string.c:int strncmp(const char * cs,const char * ct,size_t count)
u-boot/lib_generic/string.c:int strncmp(const char * cs,const char * ct,size_t count)

Grepping for memscan

$ git grep memscan
u-boot/include/asm-mips/string.h:extern __inline__ void *memscan(void *__addr, int __c, size_t __size)
u-boot/include/linux/string.h:extern void * memscan(void *,int,__kernel_size_t);
u-boot/lib_bootstrap/string.c: * memscan - Find a character in an area of memory.
u-boot/lib_bootstrap/string.c:void * memscan(void * addr, int c, size_t size)
u-boot/lib_generic/string.c: * memscan - Find a character in an area of memory.
u-boot/lib_generic/string.c:void * memscan(void * addr, int c, size_t size)


In the first sentence of the readme on the github page there is a link to the prebuild images...
Its called on my server

I can compile it with lede 17.01.04 sdk without errors and the images are working fine.
Pepe2k does also compile his prebuild images with the mentioned toolchain...

Oh sorry, i see it now that this is not the original u-boot mod of pepe2k...
You should use an older toolchain, eg the one from tplink gpl code...

It took me going back to the Sourcery 2014.11.22 toolchain, that finally worked, and flashing went well as well; it just refuses to boot :smiley: .

@Borromini sorry to dig out a very old topic - could you share your changes to support that unit, even if incomplete?

I was about to start building this myself to investigate one issue I have after a botched RAM mod on one unit. I heated it too much, and now it won't boot from power-on reset, but will boot when I apply hardware reset on the unpopulated button near JTAG port.

Disclaimer: the following did not succeed for Borromini, so be warned, take your backups and have serial console and spi-nor flasher handy:

1 Like

Yeah I broke mine, so take your precautions as @slh said. The unit was already a write-off, but still :slightly_smiling_face:.

Sure thing, I will. I have a full flash backup of that unit already. Also, soldered in JTAG connector, so I have multiple ways to deal with that, 16-pin ISP clip included. Why save such an old device? For educational purposes, of course. I've sent two of such units to "happy hunting ground", I at least want to know, how.

1 Like

@Borromini, I got back to the topic. Built and flashed the image, and the U-boot itself seems to work. The thing with it is, it requires LZMA-compressed image, not GZIP one like stock U-boot does, there is a warning in this commit: https://github.com/pepe2k/u-boot_mod/commit/aee52d2f579f4d107d98adbc97d894f41ad8c0c7
It appears that later some fixes appeared to mitigate that and skip the loader, however kernel doesn't finish decompressing for me.
As for not booting without pressing reset after botched flash mod, still no joy, it behaves just as stock.
I can post my binary (built with the same Sourcery toolchain) if you'd like, I also almost managed to built the stock U-boot from GPL drop with it.

*   U-Boot 1.1.4  (Jun  4 2022, 18:28:46)   *

AP83 (AR9132) U-Boot for TL-WR1043ND

DRAM:   64 MB
FLASH:  Winbond W25Q128 (16 MB)
CLOCKS: 400/400/200/25 MHz (CPU/RAM/AHB/SPI)

** Warning: bad env CRC, using default,
   use 'saveenv' to save it in FLASH

LED on during eth initialization...

: cfg1 0xf cfg2 0x7114
eth0: 74:ea:3a:e4:bb:be
eth0 up
Hit any key to stop autoboot: 0 

Booting image at: 0xBF020000

   Image name:   OpenWrt r11429+93-f6
   Image type:   MIPS Linux Kernel Image (lzma compressed)
   Data size:    1612843 Bytes = 1.5 MB
   Load address: 0x80060000
   Entry point:  0x80060000

Uncompressing kernel image... 

and there it stays. Perhaps the kernel size is too big or clipped. Enough for today :wink:

That's cool to hear! I sent mine off for recycling, so can't test anymore. Glad you got it working.