Is it possible to port Advanced Linux Sound Architecture (ALSA) to ESP32 ?

copercini
Posts: 25
Joined: Wed Dec 21, 2016 4:44 pm

Is it possible to port Advanced Linux Sound Architecture (ALSA) to ESP32 ?

Postby copercini » Sun Jul 15, 2018 8:45 pm

I was looking some Intel boards with xtensa DSP and found that Advanced Linux Sound Architecture (ALSA) and PortAudio http://www.portaudio.com/ works on these boards, here is the main page with more informations about ALSA for xtensa: https://www.alsa-project.org/main/index.php/Firmware

I tried to compile it using xtensa-esp32-elf instead xtensa-byt-elf and almost worked, the missing piece seems to be a HAL for ESP32 in the folder \sound-open-firmware\src\platform\ of [url]git://git.alsa-project.org/sound-open-firmware.git[/url] that maybe EspressIf already have somewhere...

My question is: is it theoretically possible, or there is some hardware/software limitation?

copercini
Posts: 25
Joined: Wed Dec 21, 2016 4:44 pm

Re: Is it possible to port Advanced Linux Sound Architecture (ALSA) to ESP32 ?

Postby copercini » Sun Jul 15, 2018 9:04 pm

Code: Select all

make[2]: Leaving directory '/home/copercini/sof.git/src/lib'
Making all in arch
make[2]: Entering directory '/home/copercini/sof.git/src/arch'
Making all in xtensa
make[3]: Entering directory '/home/copercini/sof.git/src/arch/xtensa'
cat ../../platform/cannonlake/cannonlake.x.in | xtensa-esp32-elf-gcc -E -P -I /home/copercini/sof.git/src/platform/cannonlake/include -I /home/copercini/sof.git/src/platform/intel/include  -I /home/copercini/sof.git/src/platform/cannonlake/include/arch -I /home/copercini/sof.git/src/include -I ~/esp/xtensa-esp32-elf/include - >../../platform/cannonlake/cannonlake.x
cat ../../platform/cannonlake/boot_ldr.x.in | xtensa-esp32-elf-gcc -E -P -I /home/copercini/sof.git/src/platform/cannonlake/include -I /home/copercini/sof.git/src/platform/intel/include  -I /home/copercini/sof.git/src/platform/cannonlake/include/arch -I /home/copercini/sof.git/src/include -I ~/esp/xtensa-esp32-elf/include - >../../platform/cannonlake/boot_ldr.x
make  all-recursive
make[4]: Entering directory '/home/copercini/sof.git/src/arch/xtensa'
Making all in hal
make[5]: Entering directory '/home/copercini/sof.git/src/arch/xtensa/hal'
xtensa-esp32-elf-gcc -DHAVE_CONFIG_H -I. -I../../../../src/include    -I /home/copercini/sof.git/src/arch/xtensa/include -I /home/copercini/sof.git/src/arch/xtensa/xtos  -I /home/copercini/sof.git/src/platform/cannonlake/include -I /home/copercini/sof.git/src/platform/intel/include  -I /home/copercini/sof.git/src/platform/cannonlake/include/arch -D__SPLIT__extra_size -D__SPLIT__extra_align -D__SPLIT__cpregs_size -D__SPLIT__cpregs_align -D__SPLIT__cp_names -D__SPLIT__all_extra_size -D__SPLIT__all_extra_align -D__SPLIT__num_coprocessors -D__SPLIT__cp_num -D__SPLIT__cp_max -D__SPLIT__cp_mask -D__SPLIT__cp_id_mappings -D__SPLIT__cp_mask_mappings -D__SPLIT__init_mem_extra -D__SPLIT__init_mem_cp -D__SPLIT__save_extra -D__SPLIT__restore_extra -D__SPLIT__cpregs_save_fn -D__SPLIT__cpregs_restore_fn -D__SPLIT__validate_cp -D__SPLIT__invalidate_cp -D__SPLIT__get_cpenable -D__SPLIT__set_cpenable -D__SPLIT__op0_format_lengths -D__SPLIT__byte0_format_lengths -D__SPLIT__disassemble_size -D__SPLIT__disassemble -D__SPLIT__clear_regcached_code -D__SPLIT__num_intlevels -D__SPLIT__num_interrupts -D__SPLIT__excm_level -D__SPLIT__intlevel -D__SPLIT__get_intenable -D__SPLIT__set_intenable -D__SPLIT__get_interrupt -D__SPLIT__set_intset -D__SPLIT__set_intclear -D__SPLIT__get_cacheattr -D__SPLIT__get_icacheattr -D__SPLIT__set_cacheattr -D__SPLIT__set_icacheattr -D__SPLIT__set_dcacheattr -D__SPLIT__set_idcacheattr -D__SPLIT__idcache_is_enabled -D__SPLIT__icache_is_enabled -D__SPLIT__dcache_is_enabled -D__SPLIT__idcache_is_enabled -D__SPLIT__icache_all_invalidate -D__SPLIT__dcache_all_invalidate -D__SPLIT__dcache_all_writeback -D__SPLIT__dcache_all_writeback_inv -D__SPLIT__icache_all_unlock -D__SPLIT__dcache_all_unlock -D__SPLIT__icache_region_invalidate -D__SPLIT__dcache_region_invalidate -D__SPLIT__dcache_region_writeback -D__SPLIT__dcache_region_writeback_inv -D__SPLIT__icache_region_lock -D__SPLIT__dcache_region_lock -D__SPLIT__icache_region_unlock -D__SPLIT__dcache_region_unlock -D__SPLIT__icache_line_invalidate -D__SPLIT__dcache_line_invalidate -D__SPLIT__dcache_line_writeback -D__SPLIT__dcache_line_writeback_inv -D__SPLIT__icache_line_lock -D__SPLIT__dcache_line_lock -D__SPLIT__icache_line_unlock -D__SPLIT__dcache_line_unlock -D__SPLIT__icache_sync -D__SPLIT__dcache_sync -D__SPLIT__icache_get_ways -D__SPLIT__icache_set_ways -D__SPLIT__dcache_get_ways -D__SPLIT__dcache_set_ways -D__SPLIT__cache_coherence_on -D__SPLIT__cache_coherence_off -D__SPLIT__set_cache_prefetch_long -D__SPLIT__set_cache_prefetch -D__SPLIT__get_cache_prefetch -D__SPLIT__hw_configid0 -D__SPLIT__hw_configid1 -D__SPLIT__release_major -D__SPLIT__release_minor -O2 -g -Wall -Werror -Wl,-EL -Wmissing-prototypes -fno-inline-functions -nostdlib -mlongcalls -MT libhal_a-cache_asm.o -MD -MP -MF .deps/libhal_a-cache_asm.Tpo -c -o libhal_a-cache_asm.o `test -f 'cache_asm.S' || echo './'`cache_asm.S
cache_asm.S: Assembler messages:
cache_asm.S:355: Error: unknown opcode or format name 'iii'
cache_asm.S:355: Error: unknown opcode or format name 'iii'
cache_asm.S:355: Error: unknown opcode or format name 'iii'
cache_asm.S:355: Error: unknown opcode or format name 'iii'
cache_asm.S:382: Error: unknown opcode or format name 'dii'
cache_asm.S:382: Error: unknown opcode or format name 'dii'
cache_asm.S:382: Error: unknown opcode or format name 'dii'
cache_asm.S:382: Error: unknown opcode or format name 'dii'
cache_asm.S:408: Error: unknown opcode or format name 'diwb'
cache_asm.S:408: Error: unknown opcode or format name 'diwb'
cache_asm.S:408: Error: unknown opcode or format name 'diwb'
cache_asm.S:408: Error: unknown opcode or format name 'diwb'
cache_asm.S:434: Error: unknown opcode or format name 'diwbi'
cache_asm.S:434: Error: unknown opcode or format name 'diwbi'
cache_asm.S:434: Error: unknown opcode or format name 'diwbi'
cache_asm.S:434: Error: unknown opcode or format name 'diwbi'
cache_asm.S:460: Error: unknown opcode or format name 'iiu'
cache_asm.S:460: Error: unknown opcode or format name 'iiu'
cache_asm.S:460: Error: unknown opcode or format name 'iiu'
cache_asm.S:460: Error: unknown opcode or format name 'iiu'
cache_asm.S:486: Error: unknown opcode or format name 'diu'
cache_asm.S:486: Error: unknown opcode or format name 'diu'
cache_asm.S:486: Error: unknown opcode or format name 'diu'
cache_asm.S:486: Error: unknown opcode or format name 'diu'
cache_asm.S:512: Error: unknown opcode or format name 'ihi'
cache_asm.S:539: Error: unknown opcode or format name 'dhi'
cache_asm.S:565: Error: unknown opcode or format name 'dhwb'
cache_asm.S:591: Error: unknown opcode or format name 'dhwbi'
cache_asm.S:617: Error: unknown opcode or format name 'ipfl'
cache_asm.S:643: Error: unknown opcode or format name 'dpfl'
cache_asm.S:669: Error: unknown opcode or format name 'ihu'
cache_asm.S:695: Error: unknown opcode or format name 'dhu'
cache_asm.S:721: Error: unknown opcode or format name 'ihi'
cache_asm.S:748: Error: unknown opcode or format name 'dhi'
cache_asm.S:774: Error: unknown opcode or format name 'dhwb'
cache_asm.S:800: Error: unknown opcode or format name 'dhwbi'
cache_asm.S:826: Error: unknown opcode or format name 'ipfl'
cache_asm.S:852: Error: unknown opcode or format name 'dpfl'
cache_asm.S:878: Error: unknown opcode or format name 'ihu'
cache_asm.S:904: Error: unknown opcode or format name 'dhu'
cache_asm.S:1142: Error: unknown opcode or format name 'rsr.prefctl'
cache_asm.S:1152: Error: unknown opcode or format name 'xsr.prefctl'
cache_asm.S:1221: Error: unknown opcode or format name 'rsr.prefctl'
cache_asm.S:1231: Error: unknown opcode or format name 'xsr.prefctl'
cache_asm.S:1280: Error: unknown opcode or format name 'rsr.prefctl'
Makefile:656: recipe for target 'libhal_a-cache_asm.o' failed
make[5]: *** [libhal_a-cache_asm.o] Error 1
make[5]: Leaving directory '/home/copercini/sof.git/src/arch/xtensa/hal'
Makefile:791: recipe for target 'all-recursive' failed
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory '/home/copercini/sof.git/src/arch/xtensa'
Makefile:513: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/home/copercini/sof.git/src/arch/xtensa'
Makefile:368: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/copercini/sof.git/src/arch'
Makefile:369: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/copercini/sof.git/src'
Makefile:413: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
copercini@debian:~/sof.git$ 
After some more tries it seems to be missing some assembly instructions =(

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Is it possible to port Advanced Linux Sound Architecture (ALSA) to ESP32 ?

Postby ESP_Angus » Mon Jul 16, 2018 1:16 am

Hi copercini,

It looks like you're trying to port sound-open-firmware, rather than ALSA (ALSA is a much larger Linux-based audio framework, sound-open-firmware looks to be a firmware that will run on the DSP itself and talk to ALSA).

This firmware won't work on the ESP32. ESP32 has an Xtensa architecture CPU, but it's not an Xtensa DSP. There are DSP extensions (dedicated instructions[*] for running signal processing algorithms) that an Xtensa DSP has, and the ESP32 does not have these. And those are what this firmware is designed to make use of.

Sorry to be the bearer of bad news.

[*] The instructions shown in the error above are cache prefetch related, not DSP (the ESP32 also has a simpler cache than many Xtensa CPUs). However there will be DSP instructions referenced somewhere else in the firmware.

copercini
Posts: 25
Joined: Wed Dec 21, 2016 4:44 pm

Re: Is it possible to port Advanced Linux Sound Architecture (ALSA) to ESP32 ?

Postby copercini » Mon Jul 16, 2018 12:55 pm

Hi Angus,

Thanks for your post, now it's more clear for me: the intend of sound-open-firmware is to be a firmware that communicates with ALSA and not ALSA itself, so the DSP needs something with Linux connected to work

Before read your post I tried a bit more, probably no one will use this, but just for curiosity, it compiles 99% fine when setting as Intel Haswell, the only (compilation) problem is with two functions on sound-open-firmware\src\platform\haswell\include\platform\tie-asm.h

the functions are:

Code: Select all

xchal_cp_AudioEngineLX_store	xchal_cp1_store

Code: Select all

xchal_cp_AudioEngineLX_load	xchal_cp1_load
that have some ae_sp24x2s asm instructions not recognized by ESP32, by the name it seems to be audio specific as you said

removing these instructions it compiles! probably will not work well in runtime, but as sunday fun it's fine :D

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 129 guests