Recent

Author Topic: Problem linking for Xtensa (ESP32)  (Read 5066 times)

electronickiwi

  • New member
  • *
  • Posts: 8
Problem linking for Xtensa (ESP32)
« on: May 09, 2020, 06:39:55 am »
I've been following the instructions at https://wiki.lazarus.freepascal.org/Xtensa, and getting stuck at compiling a test program.

I've got the following error message coming up when I try and do the cross-compile for xtensa-freertos. (I'm running on Windows)

Code: Text  [Select][+][-]
  1. helloworld.pp(8,17) Error: Can't call the linker, switching to external linking
  2. helloworld.pp(8,17) Error: Error while linking
  3. helloworld.pp(8,17) Fatal: There were 2 errors compiling module, stopping
  4. Fatal: Compilation aborted
  5.  

I'm running the following command, adapted from the command in the wiki
Code: Text  [Select][+][-]
  1. C:\lazarus\fpc\fpc>compiler\ppcrossxtensa -Furtl\units\xtensa-freertos\ -Tfreertos -XPxtensa-esp32-elf- -O3 -Wpesp32 -FlC:\Users\Wes\esp\xtensa-esp32-elf-libs  -FlC:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf\xtensa-esp32-elf\lib\ helloworld

I can run the command
Code: Text  [Select][+][-]
  1. C:\lazarus\fpc\fpc>xtensa-esp32-elf-ld
and I get
Code: Text  [Select][+][-]
  1. xtensa-esp32-elf-ld: no input files
, which I think means that the appropriate binutils are on my path.

Any ideas?

Wes

TRon

  • Hero Member
  • *****
  • Posts: 525
Re: Problem linking for Xtensa (ESP32)
« Reply #1 on: May 09, 2020, 07:23:20 am »
Quote
helloworld.pp(8,17) Error: Can't call the linker, switching to external linking
That msg seems to suggest that you haven't setup your configuration for crosscompiling correctly

Quote
helloworld.pp(8,17) Error: Error while linking
That msg seems to suggest that fpc is unable to locate your linker. That is also configuration related.

edit: So, were is your fpc.cfg ?  ;D
Sorry, i overlooked the fact that you are invoking the crosscompiler directly  :-[ (2x fpc in there )

By default there is a define named NEEDCROSSBINUTILS, which adds a prefix to the name of the binutil it wants to invoke:
<redundancy removed>
Does the name then still match ?


You can add the option -vt to your parameters for compilation (which results in more output from the compiler) in order to see what linker FPC is looking for and if FPC is able to find it. The -vt option actually outputs information on every file FPC attempts to locate.

Furthermore you can use the option -FD (inside your configuration file as well) to add the path to your binutils , which makes it redundant to add this path to your path environment variable.
« Last Edit: May 09, 2020, 07:48:40 am by TRon »

ccrause

  • Sr. Member
  • ****
  • Posts: 447
Re: Problem linking for Xtensa (ESP32)
« Reply #2 on: May 09, 2020, 09:24:42 am »
You can add the option -vt to your parameters for compilation (which results in more output from the compiler) in order to see what linker FPC is looking for and if FPC is able to find it. The -vt option actually outputs information on every file FPC attempts to locate.
+1.  Difficult to troubleshoot if you don't know exactly what the compiler was looking for and where.

Since you didn't specify the binutils prefix, the compiler may have assumed a different prefix (such as xtensa-freertos-). You can also set the prefix to the binutils explicitly with the -XP option. You can also use -XP to specify the path+prefix, I guess on your installation it will be something along the lines of:
Code: Text  [Select][+][-]
  1. -XPC:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf/bin/xtensa-esp32-elf-
EDIT: probably qualifies for the WoMM certification  :-[.

Quote
Furthermore you can use the option -FD (inside your configuration file as well) to add the path to your binutils , which makes it redundant to add this path to your path environment variable.
This option sets the path to compiler utils, not binutils.
EDIT: As others pointed out this is incorrect!
« Last Edit: May 09, 2020, 11:29:43 am by ccrause »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9589
  • FPC developer.
Re: Problem linking for Xtensa (ESP32)
« Reply #3 on: May 09, 2020, 10:04:04 am »
XP is only for the prefix. Paths to binutils should be set with -FD

PascalDragon

  • Hero Member
  • *****
  • Posts: 3386
  • Compiler Developer
Re: Problem linking for Xtensa (ESP32)
« Reply #4 on: May 09, 2020, 10:06:31 am »
You can add the option -vt to your parameters for compilation (which results in more output from the compiler) in order to see what linker FPC is looking for and if FPC is able to find it. The -vt option actually outputs information on every file FPC attempts to locate.
+1.  Difficult to troubleshoot if you don't know exactly what the compiler was looking for and where.

Since you didn't specify the binutils prefix, the compiler may have assumed a different prefix (such as xtensa-freertos-). You can also set the prefix to the binutils explicitly with the -XP option. You can also use -XP to specify the path+prefix, I guess on your installation it will be something along the lines of:
Code: Text  [Select][+][-]
  1. -XPC:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf/bin/xtensa-esp32-elf-

Quote
Furthermore you can use the option -FD (inside your configuration file as well) to add the path to your binutils , which makes it redundant to add this path to your path environment variable.
This option sets the path to compiler utils, not binutils.

You're wrong. -FD is the path to the binutils, while -XP is only the filename's prefix.

electronickiwi

  • New member
  • *
  • Posts: 8
Re: Problem linking for Xtensa (ESP32)
« Reply #5 on: May 09, 2020, 10:20:12 am »
Thank you all for your input.  The -XP option was being used, but only the prefix, not the full path.  I've put in the full path to the bin utils, both as -XP and -FD and get the same error each time.

I'm now running this command:
Code: Text  [Select][+][-]
  1. C:\lazarus\fpc\fpc>compiler\ppcrossxtensa -vt -Furtl\units\xtensa-freertos\ -Tfreertos -XPC:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf- -O3 -Wpesp32 -FlC:\Users\Wes\esp\xtensa-esp32-elf-libs  -FlC:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf\xtensa-esp32-elf\lib\ helloworld

or this one:
Code: Text  [Select][+][-]
  1. compiler\ppcrossxtensa -vt -Furtl\units\xtensa-freertos\ -Tfreertos -FDC:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf\bin\ -XPxtensa-esp32-elf- -O3 -Wpesp32 -FlC:\Users\Wes\esp\xtensa-esp32-elf-libs  -FlC:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf\xtensa-esp32-elf\lib\ helloworld

and getting this result.  I can see it looks for and finds the assembler, but I don't see any messages about looking for the linker and not finding it, only that it can't call the (internal?) linker, and switches to the external linker, which has an error.

Code: Text  [Select][+][-]
  1. Configfile search: fpc.cfg
  2. Configfile search: C:\Users\Wes\fpc.cfg
  3. Configfile search: C:\ProgramData\fpc.cfg
  4. Configfile search: C:\lazarus\fpc\fpc\compiler\fpc.cfg
  5. Path ".\::=::\" not found
  6. Path ".\rtl\xtensa-freertos\" not found
  7. Compiler: C:\lazarus\fpc\fpc\compiler\ppcrossxtensa.exe
  8. Using executable path: C:\lazarus\fpc\fpc\compiler\
  9. Using unit path: .\rtl\units\xtensa-freertos\
  10. Using unit path: .\compiler\
  11. Using library path: C:\Users\Wes\esp\xtensa-esp32-elf-libs\
  12. Using library path: C:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf\xtensa-esp32-elf\lib\
  13. Using library path: .\rtl\units\xtensa-freertos\
  14. Using library path: .\compiler\
  15. Using object path: .\rtl\units\xtensa-freertos\
  16. Using object path: .\compiler\
  17. Searching file helloworld.pp... found
  18. Unitsearch: system.ppu
  19. Unitsearch: system.pp
  20. Unitsearch: system.pas
  21. Unitsearch: .\rtl\units\xtensa-freertos\system.ppu
  22. PPU Loading .\rtl\units\xtensa-freertos\system.ppu
  23. Searching file helloworld.pp... found
  24. Searching file helloworld.pp... found
  25. Unitsearch: ESP32.ppu
  26. Unitsearch: ESP32.pp
  27. Unitsearch: ESP32.pas
  28. Unitsearch: .\rtl\units\xtensa-freertos\ESP32.ppu
  29. PPU Loading .\rtl\units\xtensa-freertos\esp32.ppu
  30. Unitsearch: consoleio.ppu
  31. Unitsearch: consoleio.pp
  32. Unitsearch: consoleio.pas
  33. Unitsearch: .\rtl\units\xtensa-freertos\consoleio.ppu
  34. PPU Loading .\rtl\units\xtensa-freertos\consoleio.ppu
  35. Unitsearch: heapmgr.ppu
  36. Unitsearch: heapmgr.pp
  37. Unitsearch: heapmgr.pas
  38. Unitsearch: .\rtl\units\xtensa-freertos\heapmgr.ppu
  39. PPU Loading .\rtl\units\xtensa-freertos\heapmgr.ppu
  40. Searching file helloworld.pp... found
  41. Searching file C:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-as.exe... found
  42. Using assembler: C:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-as.exe
  43. Searching file helloworld.o... found
  44. Searching file .\rtl\units\xtensa-freertos\system.o... found
  45. Searching file .\rtl\units\xtensa-freertos\esp32.o... found
  46. Searching file libesp32.a... not found
  47. Searching file libesp32.a... not found
  48. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libesp32.a... found
  49. Searching file libsoc.a... not found
  50. Searching file libsoc.a... not found
  51. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libsoc.a... found
  52. Searching file libdriver.a... not found
  53. Searching file libdriver.a... not found
  54. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libdriver.a... found
  55. Searching file libfreertos.a... not found
  56. Searching file libfreertos.a... not found
  57. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libfreertos.a... found
  58. Searching file liblog.a... not found
  59. Searching file liblog.a... not found
  60. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\liblog.a... found
  61. Searching file libesp_common.a... not found
  62. Searching file libesp_common.a... not found
  63. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libesp_common.a... found
  64. Searching file libheap.a... not found
  65. Searching file libheap.a... not found
  66. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libheap.a... found
  67. Searching file libnewlib.a... not found
  68. Searching file libnewlib.a... not found
  69. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libnewlib.a... found
  70. Searching file libvfs.a... not found
  71. Searching file libvfs.a... not found
  72. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libvfs.a... found
  73. Searching file libesp_ringbuf.a... not found
  74. Searching file libesp_ringbuf.a... not found
  75. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libesp_ringbuf.a... found
  76. Searching file libspi_flash.a... not found
  77. Searching file libspi_flash.a... not found
  78. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libspi_flash.a... found
  79. Searching file libapp_update.a... not found
  80. Searching file libapp_update.a... not found
  81. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libapp_update.a... found
  82. Searching file libxtensa.a... not found
  83. Searching file libxtensa.a... not found
  84. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libxtensa.a... found
  85. Searching file libbootloader_support.a... not found
  86. Searching file libbootloader_support.a... not found
  87. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libbootloader_support.a... found
  88. Searching file libpthread.a... not found
  89. Searching file libpthread.a... not found
  90. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libpthread.a... found
  91. Searching file libhal.a... not found
  92. Searching file libhal.a... not found
  93. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libhal.a... found
  94. Searching file libm.a... not found
  95. Searching file libm.a... not found
  96. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libm.a... found
  97. Searching file libg.a... not found
  98. Searching file libg.a... not found
  99. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libg.a... found
  100. Searching file libc.a... not found
  101. Searching file libc.a... not found
  102. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libc.a... found
  103. Searching file libesp_event.a... not found
  104. Searching file libesp_event.a... not found
  105. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libesp_event.a... found
  106. Searching file .\rtl\units\xtensa-freertos\consoleio.o... found
  107. Searching file .\rtl\units\xtensa-freertos\heapmgr.o... found
  108. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libesp32.a... found
  109. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libsoc.a... found
  110. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libdriver.a... found
  111. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libfreertos.a... found
  112. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\liblog.a... found
  113. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libesp_common.a... found
  114. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libheap.a... found
  115. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libnewlib.a... found
  116. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libvfs.a... found
  117. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libesp_ringbuf.a... found
  118. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libspi_flash.a... found
  119. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libapp_update.a... found
  120. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libxtensa.a... found
  121. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libbootloader_support.a... found
  122. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libpthread.a... found
  123. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libhal.a... found
  124. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libm.a... found
  125. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libg.a... found
  126. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libc.a... found
  127. Searching file C:\Users\Wes\esp\xtensa-esp32-elf-libs\libesp_event.a... found
  128. helloworld.pp(3,24) Error: Can't call the linker, switching to external linking
  129. helloworld.pp(3,24) Error: Error while linking
  130. Searching file helloworld.o... found
  131. Searching file helloworld.o... found
  132. Searching file .\rtl\units\xtensa-freertos\system.o... found
  133. Searching file .\rtl\units\xtensa-freertos\system.o... found
  134. Searching file .\rtl\units\xtensa-freertos\esp32.o... found
  135. Searching file .\rtl\units\xtensa-freertos\esp32.o... found
  136. Searching file .\rtl\units\xtensa-freertos\consoleio.o... found
  137. Searching file .\rtl\units\xtensa-freertos\consoleio.o... found
  138. Searching file .\rtl\units\xtensa-freertos\heapmgr.o... found
  139. Searching file .\rtl\units\xtensa-freertos\heapmgr.o... found
  140. helloworld.pp(3,24) Fatal: There were 2 errors compiling module, stopping
  141. Fatal: Compilation aborted

Contents of helloworld.pp
Code: Pascal  [Select][+][-]
  1. program helloworld;
  2. begin
  3.   writeln('Hello World');
  4. end.

I've noticed a linkXXX.res file is created.  It's contents are:
Code: Text  [Select][+][-]
  1. SEARCH_DIR("C:\Users\Wes\esp\xtensa-esp32-elf-libs\")
  2. SEARCH_DIR("C:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf\xtensa-esp32-elf\lib\")
  3. SEARCH_DIR(".\rtl\units\xtensa-freertos\")
  4. SEARCH_DIR(".\compiler\")
  5. INPUT (
  6. helloworld.o
  7. .\rtl\units\xtensa-freertos\system.o
  8. .\rtl\units\xtensa-freertos\esp32.o
  9. .\rtl\units\xtensa-freertos\consoleio.o
  10. .\rtl\units\xtensa-freertos\heapmgr.o
  11. )
  12. GROUP(
  13. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libesp32.a
  14. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libsoc.a
  15. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libdriver.a
  16. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libfreertos.a
  17. C:\Users\Wes\esp\xtensa-esp32-elf-libs\liblog.a
  18. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libesp_common.a
  19. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libheap.a
  20. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libnewlib.a
  21. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libvfs.a
  22. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libesp_ringbuf.a
  23. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libspi_flash.a
  24. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libapp_update.a
  25. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libxtensa.a
  26. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libbootloader_support.a
  27. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libpthread.a
  28. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libhal.a
  29. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libm.a
  30. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libg.a
  31. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libc.a
  32. C:\Users\Wes\esp\xtensa-esp32-elf-libs\libesp_event.a
  33. )
  34. SECTIONS
  35. {
  36.   .data :
  37.   {
  38.     KEEP (*(.fpc .fpc.n_version .fpc.n_links))
  39.   }
  40. }

MiR

  • Full Member
  • ***
  • Posts: 205
Re: Problem linking for Xtensa (ESP32)
« Reply #6 on: May 09, 2020, 10:24:52 am »
One more thing to do is to add -sh parameter to build, this way a linker script will be generated and you see step by step what is happening (and going wrong) in the linker phase.

In the past (when I remember correctly) parts of the steps done to link were unix specific, perhaps some detail still needs to be fixed for running on windows.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9589
  • FPC developer.
Re: Problem linking for Xtensa (ESP32)
« Reply #7 on: May 09, 2020, 11:03:02 am »
This option sets the path to compiler utils, not binutils.

Compiler utils are anything that the compiler calls. Binutils included.

TRon

  • Hero Member
  • *****
  • Posts: 525
Re: Problem linking for Xtensa (ESP32)
« Reply #8 on: May 09, 2020, 11:29:25 am »
and getting this result.  I can see it looks for and finds the assembler,
Indeed it searhes for and finds the assembler correctly.

Quote
but I don't see any messages about looking for the linker and not finding it,
That is the part that is concerning. After the assembly, when it processed all required files to do so, it should invoke the linker

It does so in a similar fashion as the assembler. Searching for it, finding it, then invoking it.

That last part is indeed missing from your log.

Quote
only that it can't call the (internal?) linker, and switches to the external linker, which has an error.
That it tries the internal linker first should afaik not happen.

You could perhaps try to 'override' internal linking with providing the compiler option -Xe (Use external linker)

Another thing that might perhaps help is to try to avoid to optimize (so get rid of the option -O3).

Other than that i have no idea atm. I am unfamiliar with the target, so have no idea on particular ins and/or outs and with regards to my knowledge regarding the backend i'm out of idea's.

Oh, perhaps one thing (but as said i am unfamiliar with this particular toolchain) you could perhaps try and pass some (debug) options through to the linker (which ones those should be i have no idea. You could try to invoke the linker with --help or /help and see if there are any meaningful options you could perhaps pass along at linking stage.

I did read something with regards to this toolchain about setting environment variables ?


electronickiwi

  • New member
  • *
  • Posts: 8
Re: Problem linking for Xtensa (ESP32)
« Reply #9 on: May 09, 2020, 11:39:02 am »
When I run with the -sh option it produces the ppas.bat script:
Code: Text  [Select][+][-]
  1. @echo off
  2. SET THEFILE=helloworld
  3. echo Assembling %THEFILE%
  4. C:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-as.exe -o helloworld.o  helloworld.s --longcalls
  5. if errorlevel 1 goto asmend
  6. Del helloworld.s
  7. SET THEFILE=helloworld
  8. echo Linking %THEFILE%
  9. xtensa-esp32-elf-gcc -C -P -x c -E -o esp32_out.ld -I . C:\Users\Wes\esp\esp-idf/components/esp32/ld/esp32.ld
  10. if errorlevel 1 goto linkend
  11. SET THEFILE=helloworld
  12. echo Linking %THEFILE%
  13. C:\Users\Wes\esp\esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 elf2image --flash_mode dio --flash_freq 40m --flash_size 2MB --elf-sha256-offset 0xb0 -o helloworld.bin helloworld.elf
  14. if errorlevel 1 goto linkend
  15. goto end
  16. :asmend
  17. echo An error occurred while assembling %THEFILE%
  18. goto end
  19. :linkend
  20. echo An error occurred while linking %THEFILE%
  21. :end
  22.  

Running that script produces:
Code: Text  [Select][+][-]
  1. Assembling helloworld
  2. Linking helloworld
  3. Linking helloworld
  4. esptool.py v3.0-dev
  5. Traceback (most recent call last):
  6.   File "C:\Users\Wes\esp\esp-idf\components\esptool_py\esptool\esptool.py", line 3430, in <module>
  7.     _main()
  8.   File "C:\Users\Wes\esp\esp-idf\components\esptool_py\esptool\esptool.py", line 3423, in _main
  9.     main()
  10.   File "C:\Users\Wes\esp\esp-idf\components\esptool_py\esptool\esptool.py", line 3163, in main
  11.     operation_func(args)
  12.   File "C:\Users\Wes\esp\esp-idf\components\esptool_py\esptool\esptool.py", line 2633, in elf2image
  13.     e = ELFFile(args.input)
  14.   File "C:\Users\Wes\esp\esp-idf\components\esptool_py\esptool\esptool.py", line 2108, in __init__
  15.     with open(self.name, 'rb') as f:
  16. FileNotFoundError: [Errno 2] No such file or directory: 'helloworld.elf'
  17. An error occurred while linking helloworld

gcc is producing the expected esp32_out.ld file, but there is no helloworld.elf for esptool.py to produce the helloworld.bin from.



electronickiwi

  • New member
  • *
  • Posts: 8
Re: Problem linking for Xtensa (ESP32)
« Reply #10 on: May 09, 2020, 11:45:08 am »
No change using the -Xe option and leaving out the -O3 option.
It still says "Can't call the linker, switching to external linker"

I'm assuming I only need to put -Xe and not include the path to the linker (as that is specified in -FD option)?

TRon

  • Hero Member
  • *****
  • Posts: 525
Re: Problem linking for Xtensa (ESP32)
« Reply #11 on: May 09, 2020, 11:54:39 am »
No change using the -Xe option and leaving out the -O3 option.
Ok, thank for trying and reporting back.

I noticed that you posted pretty quick after my post, and the script more or less already explained that the issue is not related to optimising.

Quote
It still says "Can't call the linker, switching to external linker"
Sorry to hear that. I have to surrender here. Hopefully one of the more experienced developers or the maintainer of this particular target reads this and is able to help you out here.

Perhaps worth a report in the mantis bug-tracker to draw some more attention to it ?

Quote
I'm assuming I only need to put -Xe and not include the path to the linker (as that is specified in -FD option)?
That is correct.

You can try though. FPC will respectfully throw that back in your face with an error  :D

electronickiwi

  • New member
  • *
  • Posts: 8
Re: Problem linking for Xtensa (ESP32)
« Reply #12 on: May 09, 2020, 11:59:41 am »
Thanks TRon.

TRon

  • Hero Member
  • *****
  • Posts: 525
Re: Problem linking for Xtensa (ESP32)
« Reply #13 on: May 09, 2020, 12:55:37 pm »
EDIT: As others pointed out this is incorrect!
Nevertheless, your input is very much appreciated.

You are most probably correct in that i should not have named it literally "to add the path to your binutils", which perhaps suggested that the -FD option is meant only for pointing to binutils.

You are able to 'abuse' that option to add about every path that has at least some meaning for the toolchain, so that FPC is able to actually set things in such motion that an executable (or other kind of output) is constructed.

As pointed out by others (thank you others), binutils is a chain of tools (hence toolchain) that is/becomes part of the compiler utilities (although originating from external sources).

For most generic targets ld, as and others like strip are pretty common, but there are some pretty unorthodox targets out there (that are supported by FPC as well) and which require FPC to (indirectly) invoke a complete set of (exotic) tools in order to produce something useful.

Quote
...
Code: Text  [Select][+][-]
  1. -XPC:\Users\Wes\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf/bin/xtensa-esp32-elf-
EDIT: probably qualifies for the WoMM certification  :-[.
... and that is perhaps one of such toolchains that installs itself (automatically) in such WoMM manner  ;)

Another example is for instance Android with it's .apk files (which is very convenient when the toolchain is able to produce that automatically for you).

On top of that, such (wonderful) options allows for a complete standalone (independent from OS) setup for FPC. You can just toss every native + cross compiler versions onto a (big) flash-drive and you never have to worry about installing things again (that is until the next release from FPC/Lazarus team of course .. those blimey releases  :D ).

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9589
  • FPC developer.
Re: Problem linking for Xtensa (ESP32)
« Reply #14 on: May 09, 2020, 01:14:36 pm »
.py's don't execute on Windows without being prefixed by the interpreter ?

 

TinyPortal © 2005-2018