- Tue Aug 18, 2015 9:08 pm
#26422
Hi Richard -
Below is the output from booting the two roms:
Code: Select all ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x40100000, len 2208, room 16
tail 0
chksum 0x64
load 0x3ffe8000, len 760, room 8
tail 0
chksum 0x1f
csum 0x1f
rBoot v1.2.1 - richardaburton@gmail.com
Flash Size: 32 Mbit
Flash Mode: QIO
Flash Speed: 40 MHz
rBoot Option: Big flash
rBoot Option: Config chksum
rBoot Option: irom chksum
Booting rom 0.
And . . . .
Code: Select all ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x40100000, len 2208, room 16
tail 0
chksum 0x64
load 0x3ffe8000, len 760, room 8
tail 0
chksum 0x1f
csum 0x1f
rBoot v1.2.1 - richardaburton@gmail.com
Flash Size: 32 Mbit
Flash Mode: QIO
Flash Speed: 40 MHz
rBoot Option: Big flash
rBoot Option: Config chksum
rBoot Option: irom chksum
Booting rom 1.
Both images boot up fine. I have a function that prints out which image was flashed (static text . . . in a C++ method) when probed over MQTT. I believe in Sming all C++ functions/methods (unless explicitly marked otherwise) are placed in irom.txt. I'd have to look at the Sming linker file in more details but I think I recall someone asking a similar question a while back.
I think one problem I have is that Cache_Read_Enable_New() is *not* overriding the one in libmain2.a. Here's a dump of that symbol from app.out:
Code: Select allxtensa-lx106-elf-objdump -t app.out | grep Cache_Read_Enable_New
40100098 w F .text 00000032 Cache_Read_Enable_New
Here's what it looks like in the "app" static library that Sming produces:
Code: Select allxtensa-lx106-elf-objdump -t app_app.a | grep Cache_Read_Enable_New
00000020 g F .iram.text 00000067 Cache_Read_Enable_New
So you can see it's using the "weak" libmain2.a version in the final output file instead of the one defined in the "app" archive. For the life of me I can't force it to use the stronger "global" one defined in my application.
I found this after searching the Internet:
Gcc (actually the linker) treats libraries differently.
By default, it tries use the first found symbol and does not detect duplicated symbols.
The suggestion is to use the "-Wl,--whole-archive" and "-Wl,--no-whole-archive" options to force the linker to rescan *all* the libraries between the markers when resolving symbols so that it picks the stronger symbol over the weaker., e.g.
Code: Select all(TC)gcc main.c -L. -Wl,--whole-archive -lbar -Wl,--no-whole-archive -o test.exe
That might work but I encountered symbols in both the SDK (and Sming) that are defined multiple times which causes the linker to error out. Likely these should be fixed by ExpressIf and the Sming developers but that doesn't help me at the moment.
I'd share my project but it's a little complex. I created a Docker ESP8266 buildbox where I house the SDK and build tools. Then I pull in Sming and rboot as submodules in a larger Git repo. It works nicely for me but it may be tough for you to recreate. I can certainly share the pertinent files (e.g. linker files, makefiles, etc...) if that would prove helpful. Likewise, I'd love to share the steps necessary to get this to work if I could manage to pull it off. I think I'm close but overriding weak symbols with
static libraries is not the usual (nor apparently recommended) use case with the GCC (or xtensa) linker. That probably explains your earlier difficulty. I even tried making Cache_Read_Enable_New() local to the libmain2.a library but that just resulted in an image the reboots due to an exception early on. I also tried re-arranged the order the libraries specified on the linker command-line - no luck.
Do you have any other tricks/suggestions up your sleeves? This probably explains (I think) why I'm not seeing the mmap printf's on the screen during boot. I think it's using the version in my manufactured libmain2.a rather than the one in my application.
Thanks again for the continued suggestions . . .