Esp8266 doesn't boot depending on linkage ordering

sake402
Posts: 7
Joined: Fri Sep 30, 2016 6:18 am

Esp8266 doesn't boot depending on linkage ordering

Postby sake402 » Fri Sep 30, 2016 7:39 am

Good day to you all.
So I have an esp8266 application I am building using eclipse cross GCC using Rtos SDK.
Most compiler and linker flags were manually setup and I have successful compilation and linkage. But depending on the ordering of the library passed to the linker, the code runs on the target or not
I started linking with the command below

Code: Select all

xtensa-***-gcc -nostdlib -u call_user_start -WL,--gc-sections -L"<libPath> -T"<linker script.ld>" -Wl,--start-group -lcirom -l...  ./main.o


Sorry I couldn't write my exact commands as I am away from the system and currently accessing this site from a mobile phone
But when I started referencing codes from the SDK library, I have errors 'undefined reference to xxx' as expected. So rearranged my libraries as

Code: Select all

xtensa-***-gcc -nostdlib -u call_user_start -WL,--gc-sections -L"<libPath> -T"<linker script.ld>" -Wl,--start-group ./main.o -lcirom -l... 

Compilation and linkage successful but now the target will not execute. Even with exactly the same main.c code compiled with the first command, it still wouldn't.
I am doing something wrong. Right?
Thanks for your assistance

pratik

Re: Esp8266 doesn't boot depending on linkage ordering

Postby pratik » Fri Sep 30, 2016 6:45 pm

Did you add all the directives required by your project?
You can try to copy all from the makefile provided in Espressif SDK download.

sake402
Posts: 7
Joined: Fri Sep 30, 2016 6:18 am

Re: Esp8266 doesn't boot depending on linkage ordering

Postby sake402 » Sat Oct 01, 2016 1:25 am

Finally worked by rearranging the link order again to

Code: Select all

xtensa-lx106-elf-gcc -L"C:\ESP8266\esp8266-bsp\RTOS-SDK\lib" -L"C:\ESP8266\HAL" -nostdlib -u call_user_start -Wl,-static -TC:/ESP8266/esp8266-bsp/RTOS-SDK/ld/eagle.app.v6_4M.ld -Wl,--gc-sections -o "RGBDisplay" -Wl,--start-group -lminic -lmirom -lcirom -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lfreertos -llwip -lssc -lspiffs  ./main.o -Wl,--end-group


Thanks for your response.

But I will still like to know what the difference is between that and the command below as far as esp8266 is concerned

Code: Select all

xtensa-lx106-elf-gcc -L"C:\ESP8266\esp8266-bsp\RTOS-SDK\lib" -L"C:\ESP8266\HAL" -nostdlib -u call_user_start -Wl,-static -TC:/ESP8266/esp8266-bsp/RTOS-SDK/ld/eagle.app.v6_4M.ld -Wl,--gc-sections -o "RGBDisplay" -Wl,--start-group ./main.o -lminic -lmirom -lcirom -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lfreertos -llwip -lssc -lspiffs  -Wl,--end-group

pratik

Re: Esp8266 doesn't boot depending on linkage ordering

Postby pratik » Sun Oct 02, 2016 12:22 pm

Well, it happens with GCC sometimes. The issue is with whether the symbols needed are resolved before they are actually used. Static libraries would cause this issue, depending on how your application is organized. Typically you don't have cycling dependencies in C code, but when you do, you may have to arrange dependencies in the proper order, preferably with the main object in the end as it uses all other libraries (which must be resolved first). That is possibly why you are having the order issue!

Here is a related post that contains a lot of useful information:
http://stackoverflow.com/questions/4513 ... ors-in-gcc

Who is online

Users browsing this forum: No registered users and 3 guests