Support for WAVE 300 Wi-Fi chip

Thanks, that worked now I have this error message:

../src/tls/bignum.c:17:10: fatal error: tommath.h: No such file or directory
 #include <tommath.h>
          ^~~~~~~~~~~
compilation terminated.
make: *** [Makefile:1217: ../src/tls/bignum.o] Error 1

Maybe you should try older hostapd; or copy the one from openwrt.

I'm trying to compile the one in this thread it is a modified version to work with this specific driver do you the codes to another one? by copying the one from openwrt you mean to copy the existing hostapd with the name mtlk-ap?

I managed to compile it about 6 years ago, but lost sources.

Basically I started from patch attached here (with driver_mtlk.c), for hostapd version 0.6.
I decided to use wpad package from OpenWRT, patch it - after compilation it worked.

Please disable flags starting from:
CONFIG_EAP*

from file hostapd/.config. Then libtommath should not be needed anymore

Hello Smim0,

Congratulations! I have a Livebox 2.1 (aka ARV7519RW22) and I never managed to get the driver up, always stuck, in the best case, with this CHI Magic.

Could you share a detailed recipe of how you did it? I mean, Openwrt version, Wave300 sources, firmware uploaded, etc?

I was about to write you that I made a fork from @ahmar16 git that should compile well:

Many thanks in advance

Hello Mandrake-Lee,

I followed these instrcutions:

1 - Compiled 18.06.8 with MSI enabled and the patch and compiled the driver from pc2005 sources with pci express and polling enabled (instructions from Souleiman)
2 - To get the driver working I had to figure out the correct firmware files cocktail, I first copied all the original ones from LiveBox then started to see what the driver is looking for from the log which were ap_upper_wave300.bin and contr_lm.bin which I got from the version 3.4.2 plus a couple of ProgModel***.bin files with I had to take from the folder WAVE300__FW_UGW711.
Dont use cal_wlan0.bin file as for Livebox it is loaded from the eeprom the one in the firmware files is for the an version.
Let me know if you need any more info
Edit: the patches are to be applied to the 4.9 version not the 4.14

I checked the sources from @ahmar16, they are the same as @pc2005 I could compile the drivers succesfully

I tested Livebox with the wifi in ap mode and I could get ip address via dhcp and also got access to internet so basically we have a uncrypted wireless ap router.

Were you able to compile the modified hostapd?

Thanks @lukasz92

I will need some more guidance here, should I do any changes to the Makefile of the hostapd copied from OpenWrt? Trying to compile it with its original Makefile and the Makefile from this repo I have always an error message.

By disabling the CONFIG_EAP* flags now I get this error message:

CC  ../src/drivers/driver_common.c
/home/smim0/src/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl/lib/gcc/mips-openwrt-linux-musl/7.3.0/../../../../mips-openwrt-linux-musl/bin/ld: cannot find -ltommath
collect2: error: ld returned 1 exit status
make: *** [Makefile:1244: hostapd] Error 1

When I copy wpad from ../openwrt/build_dir/target-mips_24kc_musl/hostapd-wpad-full-internal/hostapd-2018-05-21-62566bc2/hostapd and try to compile I get this error message

../src/drivers/driver_nl80211.c:17:10: fatal error: netlink/genl/genl.h: No such file or directory
 #include <netlink/genl/genl.h>
          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:1217: ../src/drivers/driver_nl80211.o] Error 1

Thanks in advance

First error is a missing library (file .a), I am not sure why it is still needed; possibly disabling linking option (find -ltommath flag, and delete it everywhere in Makefile, maybe it helps?)

Second error is a missing headers for libnetlink, they should be in OpenWRT SDK.

Maybe when I have some time, I will try to compile them

it worked I could compile both hostapd and wpa_supplicant that come with the repo with the solutions you provided, first by changing CONFIG_TLS to internal and second by disabling all CONFIG_EAP* in hostapd/.config and removing all flags of -ltommath.

Is there any instructions on how to use the wireless device with hostapd/wpa_supplicant?

Thanks

Possibly something like:
hostapd -Dmtlk -iwlan0 -cCONFIG_FILE

You have to write CONFIG_FILE , like that:
https://wiki.gentoo.org/wiki/Hostapd#802.11b.2Fg.2Fn_with_WPA2-PSK_and_CCMP

Hello @Smim0,

I've got some free time now and I would like to help you with this topic.

First of all, I have followed your instructions and also @suleiman's.

I have used kernel 4.14 just because it was the one already in my toolchain and I didn't waste more space.

In summary: I'm afraid it doesn't work since it is not capable of loading cal_wlan0.bin. Something with the eeprom.

Therefore:

  • After your experience, is it really mandatory to use kernel 4.9?
  • Do you have a git with your sources?
  • Could you share your log too?

I add at the bottom the console log of the module.

An interface is created though, but there's nothing I can do with it.


root@OpenWrt:~# iwconfig
eth0      no wireless extensions.

br-lan    no wireless extensions.

lo        no wireless extensions.

wlan0     802.11bgn  ESSID:""
          Mode:Master  Channel:0  Access Point: 00:12:34:00:02:42
          Tx-Power=off
          RTS thr=2347 B
          Encryption key:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

eth0.1    no wireless extensions.

root@OpenWrt:/# insmod mtlkroot.ko
[   81.789836] [4294748992] mtlk0(mtlk_cdev_init:355): Max nodes set to 1048575
root@OpenWrt:/# insmod mtlk.ko ap=1
[   91.276400] [4294758480] mtlk0(__mtlk_print_endianess:4926): The system is Big endian (0xbeadfeed, 0xedfeadbe)
[   91.285358] ifx_pcie_bios_map_irq port 0 dev 0000:01:00.0 slot 0 pin 1
[   91.291703] ifx_pcie_bios_map_irq dev 0000:01:00.0 irq 144 assigned
[   91.297965] [4294758500] mtlk0(mtlk_fast_mem_print_info:114): Using normal memory for hot context
[   91.306870] PCI: Enabling device 0000:00:00.0 (0000 -> 0002)
[   91.312575] PCI: Enabling device 0000:01:00.0 (0000 -> 0002)
[   91.318907] [4294758520] mtlk0(_mtlk_df_user_alloc_devname:8350): NDEV Name pattern: wlan%d
[   91.327055] [4294758528] mtlk0(mtlk_core_pdb_fast_handles_open:42): Open Hot-path parameters
[   91.335680] [4294758540] mtlk4(_mtlk_mmb_cleanup_reset_mac:3256): FW CPU reset is done
[   91.395744] mtlk 0000:01:00.0: Direct firmware load for cal_wlan0.bin failed with error -2
[   91.402671] mtlk 0000:01:00.0: Falling back to user helper
[   91.547602] firmware cal_wlan0.bin: firmware_loading_store: map pages failed
[   91.553662] [4294758756] mtlk3(_mtlk_df_fw_request_firmware:63): Firmware (cal_wlan0.bin) is missing
[   91.866039] [4294759068] mtlk0(get_firmware_version:1161): CID-0000: ap_upper_wave300.bin: @@@ VERSION INFO @@@ version number: 3.4.2.40.05_NoPsTxCancel_r4005 MIPS:  Upper CPU(TMC AGG AP) interface: PCI  phy type: real phy on Jul  2 2014 at 16:00:39@@@ END @@@
[   91.866039]
[   91.899716] [4294759104] mtlk0(get_firmware_version:1161): CID-0000: contr_lm.bin: @@@ VERSION INFO @@@ version number: 3.4.2.40.05_NoPsTxCancel_r4005 MIPS:  Lower MAC  interface: --  phy type: real phy on Jul  2 2014 at 15:59:50@@@ END @@@
[   91.899716]
[   92.139548] command buffer dump 87df32ac:
[   92.142119] 0000: 448a0000
[   92.144910] 0001: 7b010000
[   92.147593] 0002: 58840000
[   92.150202] 0003: 7b010000
[   92.152980] 0004: 007e0000
[   92.155696] 0005: a0000000
[   92.158284] 0006: 20680000
[   92.161092] 0007: c8000000
[   92.163779] 0008: 409c0000
[   92.166391] 0009: 0e000000
[   92.169174] 000a: e8630000
[   92.171874] 000b: 02000000
[   92.174486] 000c: 6c820000
[   92.177268] 000d: 01000000
[   92.179969] 000e: 80800000
[   92.182580] 000f: 01000000
[   92.185363] 0010: edfeadbe
[   92.188064] 0011: f0000000
[   92.190675] 0012: 00000000
[   92.193457] 0013: 00000000
[   92.196157] 0014: 00000000
[   92.198770] 0015: 00000000
[   92.201552] 0016: 00000000
[   92.204253] 0017: 00000000
[   92.206865] 0018: 00000000
[   92.209647] 0019: 00000000
[   92.212358] 001a: 00000000
[   92.214948] 001b: 00000000
[   92.217738] 001c: 00000000
[   92.220445] 001d: 00000000
[   92.223042] 001e: 00000000
[   92.225836] 001f: 00000000
[   92.228542] 0020: 00000000
[   92.231149] 0021: 00000000
[   92.233938] 0022: 00000000
[   92.236637] 0023: 00000000
[   92.239232] 0024: 00000000
[   92.242025] 0025: 00000000
[   92.244728] 0026: 00000000
[   92.247338] 0027: 0000000e
[   92.250122] 0028: c1012900
[   92.252822] 0029: 00000000
[   92.255433] 002a: 00000000
[   92.258218] 002b: 00000001
[   92.260920] 002c: 00000001
[   92.263618] 002d: 00000000
[   92.266227] 002e: 00000000
[   92.269030] 002f: 00000000
[   92.271711] 0030: 00000000
[   92.274320] 0031: 00000000
[   92.277103] 0032: 00000000
[   92.279804] 0033: 00000000
[   92.282415] 0034: 00000000
[   92.285199] 0035: 00000000
[   92.287903] 0036: 00000000
[   92.290499] 0037: 00000000
[   92.293291] 0038: 00000000
[   92.295994] 0039: 00000000
[   92.298604] 003a: 00000000
[   92.301389] 003b: 00000000
[   92.304092] 003c: 00000000
[   92.306688] 003d: 00000000
[   92.309480] 003e: 00000000
[   92.312183] 003f: 00000000
[   92.314794] 0040: 00000000
[   92.317579] 0041: 00000000
[   92.320279] 0042: 00000000
[   92.322889] 0043: 00000000
[   92.325673] 0044: 00000000
[   92.328374] 0045: 00000000
[   92.330983] 0046: 00000000
[   92.333768] 0047: 00000000
[   92.336470] 0048: 00000000
[   92.339067] 0049: 00000000
[   92.341860] 004a: 00000000
[   92.344563] 004b: 00000000
[   92.347173] 004c: 00000000
[   92.349958] 004d: 00000000
[   92.352658] 004e: 00000000
[   92.355267] 004f: 00000000
[   92.875786] [4294760080] mtlk0(mtlk_eeprom_check_ee_data:1353): Options mask is 0x00
[   92.980385] [4294760184] mtlk0(load_default_hw_table:2128): HW configuration is 2X2

I think with 4.14 works too

Ok now do the following

iwpriv wlan0 sCountry XX
iwconfig wlan0 essid test
ifconfig wlan0 up

Let me know if it is up

Hi again,

I was playing with that and yes! there's an AP available with that name although with very poor signal power.

I've tried to connect to it but I believe it is not serving the right IP to the clients. Probably it is not connected to a dhcp server.

  • Do you know if it's possible to switch to client (STA) mode?
  • As a conclussion, the message below can be ignored?
[   91.553662] [4294758756] mtlk3(_mtlk_df_fw_request_firmware:63): Firmware (cal_wlan0.bin) is missing

Thanks in advance!

You are on the right path :slight_smile:

In the first begining I had a low signal too then I had to change some firmware files, these are the ones I have now:

ProgModel_BG_CB_39_RevA_wave300.bin          
ProgModel_BG_CB_wave300.bin                  
ap_upper_wave300.bin                         
contr_lm.bin  

Now the signal I have is very good

Related to cal_wlan0.bin file I think it is not needed for Livebox, if you use the one from the firmware files the card is detected as 802.11an which is not correct without it the driver load information from the eeprom which is just fine.

There is no STA mode because version 3.4 doesn't have it, if I try to use the one from other version I get the famous CHI Magic error message.

Somehow @suleiman managed to get those files from version 3.2 work with version 3.4, so he is the saviour here because he even got the driver to work with stock firmware without MSI and got scanning to work. Waiting for him to publish his findings

BTW to get ip drom dhcp try to add the wlan0 to the lan interface in /etc/config/network file

option iface 'lan wlan0'

Cheers

@Smim0
To get DHCP working, apart of adding wlan0 to br-lan (or any other bridge), one must also provide that information to driver. I can not found it at this moment, but such flag should be set with iwpriv command. If you provide list of possible commands, I would tell you which is that. It was something like iwpriv wlan0 sBridge 1, but I do not remember.

After that I was able to setup WPA2 network with DHCP working; but it was 6 years ago.

There are 2 commands

iwpriv wlan0 sBridgeMode 1
iwpriv wlan0 gBridgeMode 1

I used the 1st one but then I noticed that without it the dhcp serves the ip address too and I have access to the wan also

BTW regarding to hostapd I couldn't use it

everytime I lunch it the router crashes and reboots without any log message

Could you install strace, and launch hostapd once more?
strace -f hostapd (...)

Could you also (after crash reboot) try to do:
cat /sys/kernel/debug/crashlog

We possibly could add some debugging to driver-mtlk.c, to know where it crashes.

this the log of strace mtlk-ap config.conf

strace mtlk-ap /root/config.conf 
execve("/usr/sbin/mtlk-ap", ["mtlk-ap", "/root/config.conf"], 0x7ff63a54 /* 13 vars */) = 0
set_thread_area(0x7760fdc0)             = 0
set_tid_address(0x77608d28)             = 4285
open("/etc/ld-musl-mips-sf.path", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib/libgcc_s.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=78096, ...}) = 0
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\10\0\0\0\1\0\0(p\0\0\0004"..., 936) = 936
mmap2(NULL, 147456, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x77540000
mmap2(0x77563000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x13000) = 0x77563000
close(3)                                = 0
open("/dev/random", O_RDONLY|O_NONBLOCK|O_LARGEFILE) = 3
rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 16) = 0
rt_sigaction(SIGHUP, {sa_handler=0x4539c0, sa_mask=[RT_68 RT_69 RT_70 RT_73 RT_74 RT_75 RT_76 RT_78 RT_81 RT_82 RT_83 RT_85 RT_87 RT_89 RT_90 RT_91 RT_93 RT_94 RT_95], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=NULL}, {sa_handler=SIG_DFL, sa_mask=[RT_67 RT_74 RT_75 RT_76 RT_80 RT_86 RT_87 RT_89 RT_90 RT_91 RT_93 RT_94 RT_95], sa_flags=0}, 16) = 0
rt_sigaction(SIGUSR1, {sa_handler=0x4539c0, sa_mask=[RT_68 RT_69 RT_70 RT_73 RT_74 RT_75 RT_76 RT_78 RT_81 RT_82 RT_83 RT_85 RT_87 RT_89 RT_90 RT_91 RT_93 RT_94 RT_95], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=NULL}, {sa_handler=SIG_DFL, sa_mask=[RT_67 RT_74 RT_75 RT_76 RT_80 RT_86 RT_87 RT_89 RT_90 RT_91 RT_93 RT_94 RT_95], sa_flags=0}, 16) = 0
rt_sigaction(SIGINT, {sa_handler=0x4539c0, sa_mask=[RT_68 RT_69 RT_70 RT_73 RT_74 RT_75 RT_76 RT_78 RT_81 RT_82 RT_83 RT_85 RT_87 RT_89 RT_90 RT_91 RT_93 RT_94 RT_95], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=NULL}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 16) = 0
rt_sigaction(SIGTERM, {sa_handler=0x4539c0, sa_mask=[RT_68 RT_69 RT_70 RT_73 RT_74 RT_75 RT_76 RT_78 RT_81 RT_82 RT_83 RT_85 RT_87 RT_89 RT_90 RT_91 RT_93 RT_94 RT_95], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=NULL}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 16) = 0
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1463, tv_nsec=316934727}) = 0
writev(1, [{iov_base="Configuration file: /root/config"..., iov_len=37}, {iov_base="\n", iov_len=1}], 2Configuration file: /root/config.conf
) = 38
open("/root/config.conf", O_RDONLY|O_LARGEFILE) = 4
readv(4, [{iov_base="", iov_len=0}, {iov_base="# the interface used by the AP\ni"..., iov_len=1024}], 2) = 487
readv(4, [{iov_base="", iov_len=0}, {iov_base="", iov_len=1024}], 2) = 0
close(4)                                = 0
socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
ioctl(4, SIOCGIFINDEX, {ifr_name="wlan0", }) = 0
socket(AF_PACKET, SOCK_RAW, 34958)      = 5
ioctl(5, SIOCGIFINDEX, {ifr_name="wlan0", }) = 0
bind(5, {sa_family=AF_PACKET, sll_protocol=htons(ETH_P_PAE), sll_ifindex=if_nametoindex("wlan0"), sll_hatype=ARPHRD_NETROM, sll_pkttype=PACKET_HOST, sll_halen=0}, 20) = 0
ioctl(5, SIOCGIFHWADDR, {ifr_name="wlan0", ifr_hwaddr=00:12:34:00:02:42}) = 0
ioctl(4, SIOCSIWMODE, 0x7f85713c)       = 0
ioctl(4, SIOCGIFFLAGS, {ifr_name="wlan0", ifr_flags=IFF_BROADCAST|IFF_MULTICAST}) = 0
ioctl(4, SIOCSIFFLAGS, {ifr_name="wlan0", ifr_flags=IFF_BROADCAST|IFF_MULTICAST}) = 0
ioctl(4, SIOCGIWRANGE, 0x7f8570a4)      = 0
socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE) = 6
bind(6, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=0x000001}, 12) = 0
writev(1, [{iov_base="wlan0: interface state UNINITIAL"..., iov_len=52}, {iov_base="\n", iov_len=1}], 2wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
) = 53
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1463, tv_nsec=509635344}) = 0
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1463, tv_nsec=513943723}) = 0
_newselect(7, [3 5 6], [], [], {tv_sec=4, tv_usec=995692}) = 2 (in [3 5], left {tv_sec=4, tv_usec=995662})
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1463, tv_nsec=516237460}) = 0
read(3, "5\330\213\337eC\377\262\20Tk\247\210:,\20\327\7\235\347", 20) = 20
close(3)                                = 0
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1463, tv_nsec=519848246}) = 0
_newselect(7, [5 6], [], [], {tv_sec=4, tv_usec=989787}) = 1 (in [5], left {tv_sec=4, tv_usec=989756})
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1463, tv_nsec=524628851}) = 0
recvfrom(5, 0x7f856860, 2300, 0, 0x7f85715c, [20]) = -1 ENETDOWN (Network is down)
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1463, tv_nsec=530139322}) = 0
_newselect(7, [5 6], [], [], {tv_sec=4, tv_usec=979496}^[[A) = 0 (Timeout)
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1468, tv_nsec=517357017}) = 0
ioctl(4, SIOCSIWMLME, 0x7f856f5c)       = 0
ioctl(4, SIOCSIWENCODEEXT, 0x7f856f4c)  = 0
ioctl(4, SIOCSIWENCODEEXT, 0x7f856f4c)  = 0
ioctl(4, SIOCSIWENCODEEXT, 0x7f856f4c)  = 0
ioctl(4, SIOCSIWENCODEEXT, 0x7f856f4c)  = 0
ioctl(4, SIOCGIWESSID, 0x7f856fc8)      = 0
writev(1, [{iov_base="Using interface wlan0 with hwadd"..., iov_len=67}, {iov_base="\n", iov_len=1}], 2Using interface wlan0 with hwaddr 00:12:34:00:02:42 and ssid "test"
) = 68
ioctl(4, SIOCSIWESSID, 0x7f856fc4)      = 0
open("/dev/urandom", O_RDONLY|O_LARGEFILE) = 3
readv(3, [{iov_base="\254\rb}\237^\f\352\7\356\305\3\311m\\\32;\261ti\311\261\fUY\337e\250\341\16\316", iov_len=31}, {iov_base="Y/^\v6\34\221/8\275\243\23ec;B:pH\302\316\201@C\267\10\325\244\213K\17i"..., iov_len=1024}], 2) = 1055
_llseek(3, -1023, [0], SEEK_CUR)        = 0
close(3)                                = 0
open("/dev/urandom", O_RDONLY|O_LARGEFILE) = 3
readv(3, [{iov_base="\240*&\t\300\202\33\313\31Oq/X\27\310\334\266\221\275}\2140\2416T|\213\273l\270\340", iov_len=31}, {iov_base="\306#\26R\257\326\n\374\222\233p\325\346<\347i\257:r\1\311\21\5e\212\312\355&\326\2\263\222"..., iov_len=1024}], 2) = 1055
_llseek(3, -1023, [0], SEEK_CUR)        = 0
close(3)                                = 0
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1469, tv_nsec=349065474}) = 0
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1469, tv_nsec=349679003}) = 0
ioctl(4, SIOCSIWGENIE, 0x7f856f30)      = 0
open("/dev/urandom", O_RDONLY|O_LARGEFILE) = 3
readv(3, [{iov_base="\315t\313\345\374\342\37", iov_len=7}, {iov_base=".\304\346v,y\204%;\241\312\201\217\303\202\360\256\337\365\362Io\365cK\314=*\37\36R\354"..., iov_len=1024}], 2) = 1031
_llseek(3, -1023, [0], SEEK_CUR)        = 0
close(3)                                = 0
open("/dev/urandom", O_RDONLY|O_LARGEFILE) = 3
readv(3, [{iov_base="\353\340\345\4\237\210^-\35;J@\265\356\223", iov_len=15}, {iov_base="\0243\344\2521v!\201P\246\267\360h\276\365\27\355\215&\267\244\303Q\357\302f\3\336\215dD\350"..., iov_len=1024}], 2) = 1039
_llseek(3, -1023, [0], SEEK_CUR)        = 0
close(3)                                = 0
ioctl(4, SIOCSIWENCODEEXT, 0x7f856e8c)  = 0
ioctl(4, SIOCGIFFLAGS, {ifr_name="wlan0", ifr_flags=IFF_BROADCAST|IFF_MULTICAST}) = 0
ioctl(4, SIOCSIFFLAGS, {ifr_name="wlan0", ifr_flags=IFF_UP|IFF_BROADCAST|IFF_MULTICAST}^[[B^[[A) = -1 EAGAIN (Resource temporarily unavailable)
writev(2, [{iov_base="", iov_len=0}, {iov_base="ioctl[SIOCSIFFLAGS]", iov_len=19}], 2ioctl[SIOCSIFFLAGS]) = 19
writev(2, [{iov_base="", iov_len=0}, {iov_base=":", iov_len=1}], 2:) = 1
writev(2, [{iov_base="", iov_len=0}, {iov_base=" ", iov_len=1}], 2 ) = 1
writev(2, [{iov_base="", iov_len=0}, {iov_base="Resource temporarily unavailable", iov_len=32}], 2Resource temporarily unavailable) = 32
writev(2, [{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}], 2
) = 1
writev(1, [{iov_base="hostapd_setup_interface_complete"..., iov_len=76}, {iov_base="\n", iov_len=1}], 2hostapd_setup_interface_complete_sync: Failed to commit driver configuration
) = 77
writev(1, [{iov_base="Interface initialization failed", iov_len=31}, {iov_base="\n", iov_len=1}], 2Interface initialization failed
) = 32
writev(1, [{iov_base="wlan0: interface state COUNTRY_U"..., iov_len=47}, {iov_base="\n", iov_len=1}], 2wlan0: interface state COUNTRY_UPDATE->DISABLED
) = 48
writev(1, [{iov_base="wlan0: AP-DISABLED ", iov_len=19}, {iov_base="\n", iov_len=1}], 2wlan0: AP-DISABLED 
) = 20
writev(1, [{iov_base="wlan0: interface state DISABLED-"..., iov_len=41}, {iov_base="\n", iov_len=1}], 2wlan0: interface state DISABLED->DISABLED
) = 42
ioctl(4, SIOCSIWMLME, 0x7f8570f4)       = 0
ioctl(4, SIOCSIWENCODEEXT, 0x7f8570c4)  = 0
ioctl(4, SIOCSIWENCODEEXT, 0x7f8570c4)  = 0
ioctl(4, SIOCSIWENCODEEXT, 0x7f8570c4)  = 0
ioctl(4, SIOCSIWENCODEEXT, 0x7f8570c4)  = 0
writev(1, [{iov_base="wlan0: AP-DISABLED ", iov_len=19}, {iov_base="\n", iov_len=1}], 2wlan0: AP-DISABLED 
) = 20
writev(1, [{iov_base="wlan0: CTRL-EVENT-TERMINATING ", iov_len=30}, {iov_base="\n", iov_len=1}], 2wlan0: CTRL-EVENT-TERMINATING 
) = 31
ioctl(4, SIOCSIWGENIE, 0x7f857118)      = 0
clock_gettime(CLOCK_BOOTTIME, {tv_sec=1477, tv_nsec=741839128}) = 0
writev(1, [{iov_base="ELOOP: remaining socket: sock=5 "..., iov_len=80}, {iov_base="\n", iov_len=1}], 2ELOOP: remaining socket: sock=5 eloop_data=0x4e7e30 user_data=0 handler=0x490638
) = 81
writev(1, [{iov_base="ELOOP: remaining socket: sock=6 "..., iov_len=80}, {iov_base="\n", iov_len=1}], 2ELOOP: remaining socket: sock=6 eloop_data=0x4e7ed0 user_data=0 handler=0x48e7f0
) = 81
close(-1)                               = -1 EBADF (Bad file descriptor)
exit_group(0)                           = ?
+++ exited with 0 +++

this is my config.conf

# the interface used by the AP
interface=wlan0
# "g" simply means 2.4GHz band
driver=mtlk
hw_mode=g
# the channel to use
channel=11
# limit the frequencies used to those allowed in the country
ieee80211d=1
# the country code
country_code=ES
# 802.11n support
# QoS support, also required for full speed on 802.11n/ac/ax
wmm_enabled=1

# the name of the AP
ssid=test
# 1=wpa, 2=wep, 3=both
auth_algs=1
# WPA2 only
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_passphrase=somepassword

I have added the line: driver=mtlk and it stopped crashing

Good news,
1st the hostapd config file should have the line driver=mtlk
2nd I launched mtlkroot.ko with cdebug=3 option and saw that the driver need 2 more firmware files in order to launch, the files are:

ProgModel_BG_nCB_39_RevA_wave300.bin
ProgModel_BG_nCB_wave300.bin

Now hostapd gets the wlan0 up with encryption but I can't connect to the ap, it says password incorrect