Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By isti37
#42608 I want the opus codec (especially the decoder) on the ESP8266 because at 128 kbps should be more than enough with a cheap I2S DAC to stream audio. I think it's really important because opus would allow one to get a playlist from the internet and play music from youtube without using too much resources or play a live stream. Most web services or startups will use only the opus codec, look at Discord for instance.

The codec should be available for both RTOS and NON OS SDK with a stereo I2S output reference app (maybe play some music from youtube or soundcloud). If there are size issues the opus source could be stripped down to either the speech (low bitrate) or the celt (high bitrate) codec and if there are performance issues opus can be compiled with the fixed point implementation.

The ESP8266 running at 160 Mhz should be able to handle opus decoding.

As I remember right first I should replace malloc and free with os_alloc and os_free. (simple macro in opus).

First try: (without replacing anything) :

Code: Select allsp8266@esp8266-VirtualBox:~/opus-1.1.2$ make CC=xtensa-lx106-elf-gcc
make  all-recursive
make[1]: Entering directory `/home/esp8266/opus-1.1.2'
make[2]: Entering directory `/home/esp8266/opus-1.1.2'
  CC       celt/bands.lo
  CC       celt/celt.lo
  CC       celt/celt_encoder.lo
  CC       celt/celt_decoder.lo
  CC       celt/cwrs.lo
  CC       celt/entcode.lo
  CC       celt/entdec.lo
  CC       celt/entenc.lo
...
 CC       src/mlp.lo
  CC       src/mlp_data.lo
  CCLD     libopus.la
/usr/bin/ld: celt/.libs/bands.o: Relocations in generic ELF (EM: 94)
/usr/bin/ld: celt/.libs/bands.o: Relocations in generic ELF (EM: 94)
/usr/bin/ld: celt/.libs/bands.o: Relocations in generic ELF (EM: 94)
/usr/bin/ld: celt/.libs/bands.o: Relocations in generic ELF (EM: 94)
/usr/bin/ld: celt/.libs/bands.o: Relocations in generic ELF (EM: 94)
/usr/bin/ld: celt/.libs/bands.o: Relocations in generic ELF (EM: 94)
/usr/bin/ld: celt/.libs/bands.o: Relocations in generic ELF (EM: 94)
/usr/bin/ld: celt/.libs/bands.o: Relocations in generic ELF (EM: 94)
/usr/bin/ld: celt/.libs/bands.o: Relocations in generic ELF (EM: 94)
/usr/bin/ld: celt/.libs/bands.o: Relocations in generic ELF (EM: 94)
celt/.libs/bands.o: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
make[2]: *** [libopus.la] Error 1
make[2]: Leaving directory `/home/esp8266/opus-1.1.2'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/esp8266/opus-1.1.2'
make: *** [all] Error 2
User avatar
By jcmvbkbc
#42616
isti37 wrote:
Code: Select allsp8266@esp8266-VirtualBox:~/opus-1.1.2$ make CC=xtensa-lx106-elf-gcc
...
/usr/bin/ld: celt/.libs/bands.o: Relocations in generic ELF (EM: 94)

Should have added LD=xtensa-lx106-elf-ld so that it doesn't try to use host ld.
Have you configured opus for cross-compilation with --host option to configure?
User avatar
By piersfinlayson
#42626 To do the cross-compile, do this:

Code: Select allexport LDFLAGS="-nostdlib"
./configure --target=xtensa-lx106-elf --host=xtensa-lx106-elf
make


However, there's a chunk of stuff you'll need fix to get this to link. Easy stuff like mapping memcpy to os_memcpy. Harder stuff like lack of divsi3 and addsf3 to name but a few. You may be able pull the missing pieces in from the likes of https://opensource.apple.com/source/clang/clang-137/src/projects/compiler-rt/lib/divsi3.c