-->
Page 1 of 1

ESP8266 wont boot depending on linking ordering

PostPosted: Thu Sep 29, 2016 4:08 pm
by sake402
So I have this ESP8266 application in eclipse using the Cross GCC with one main file I named main.c.

All compiler and linker flags were manually setup and I have a successful compilation and linking.

But then depending on the order of my linkage, my application runs or not.

If I link with the below command, the application runs perfectly

Code: Select allxtensa-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.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 -Wl,--end-group  ./main.o


But you see the linking order is wrong as main.o should appear before all the SDK libraries. If I eventually reference some library code from my main.o, I get error 'undefined references to xxx'.

So I had to order my linkage as

Code: Select allxtensa-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.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


Compilation and linkage is still successful, but then it wont run on the target ESP8266.

I also tried

Code: Select allxtensa-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.ld -Wl,--gc-sections -o "RGBDisplay"  ./main.o -Wl,--start-group -lminic -lmirom -lcirom -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lfreertos -llwip -lssc -lspiffs -Wl,--end-group


And it wont run either.

I am certainly missing something. Right?

Thanks for your response.

Re: ESP8266 wont boot depending on linking ordering

PostPosted: Fri Sep 30, 2016 11:41 am
by jcmvbkbc
sake402 wrote:If I link with the below command, the application runs perfectly

Code: Select allxtensa-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.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 -Wl,--end-group  ./main.o


But you see the linking order is wrong as main.o should appear before all the SDK libraries. If I eventually reference some library code from my main.o, I get error 'undefined references to xxx'.

So I had to order my linkage as

Code: Select allxtensa-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.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


Compilation and linkage is still successful, but then it wont run on the target ESP8266.

I also tried

Code: Select allxtensa-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.ld -Wl,--gc-sections -o "RGBDisplay"  ./main.o -Wl,--start-group -lminic -lmirom -lcirom -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lfreertos -llwip -lssc -lspiffs -Wl,--end-group


And it wont run either.

Can you add -Wl,-Map=RGBDisplay.map to each of these command lines and share the resulting maps?
I'd expect your second and third command lines to work, it's a bit surprising that they don't.