Cannot compile for esp8266, error in C natives


#1

I am running zerynth version r2.1.2 on Arch linux x86_68 kernel version 4.18.12-arch1-1-ARCH and I’m currently facing a problem which is that whenever I try to compile the Wifi_scan example for my nodemcu v2 board I get the following error:

Error in C natives [---] in [[/home/ale/.zerynth2/dist/r2.1.2/libs/official/espressif/esp8266wifi/csrc/wifi_ifc.c] at line 0]

Digging further I found a topic created on May 24 addressing the same issue, saying that it is a problem with the compiler.
Trying to manually compile wifi_ifc.c with xtensa-l016-elf-gcc resulted in error:

/home/ale/.zerynth2/dist/r2.1.1/libs/official/espressif/esp8266wifi/csrc/wifi_ifc.c:1:21: fatal error:         zerynth.h: No such file or directory
 #include "zerynth.h"

The code I’m trying to compile is:

# import streams & socket
import streams
import socket

# import the wifi interface
from wireless import wifi

# the wifi module needs a networking driver to be loaded
# in order to control the board hardware.
# FOR THIS EXAMPLE TO WORK, A NETWORK DRIVER MUST BE SELECTED BELOW

from espressif.esp8266wifi import esp8266wifi as wifi_driver

streams.serial()

# init the wifi driver!
# The driver automatically registers itself to the wifi interface
# with the correct configuration for the selected board
wifi_driver.auto_init()

 # a list of security strings
 wifi_sec=["Open","WEP","WPA","WPA2"]
 try:
    print("Scanning for 15 seconds...")
    # start scanning for 15000 milliseconds
    res = wifi.scan(15000)

    # if everything goes well, res is a sequence of tuples
    # each tuple contains:
    # -ssid: the name of the network
    # -sec: the security type of the network, from 0 to 3
    # -rssi: the strength of the signal, from 0 to 127
    # -bssid: the mac address of the access point
    for ssid,sec,rssi,bssid in res:
    print(ssid,"::",wifi_sec[sec],":: strength ",rssi*100/127)
except Exception as e:
    print(e)

#2

hi @curvd

This is strange, can you compile other examples successful?


#3

Yes, I’ve been abled to compile the same program on my windows machine, and on the arch machine I’ve compiled successfully the multiblink example without running into errors.


#4

Hi @curvd,

unfortunately esp8266 compilers have stopped working on some GNU/Linux distributions due to a link error, we will try to recompile them as soon as possible.

In the meantime, not recommended if you do not know that you are doing, you could try to take a look at .zerynth2/sys/xtensa-lx106 folder and try to update them manually (even if after that you would have your project C code compiled with a version of the compiler different from the one used to compile the virtual machine).


#5

Hi,
Thank you for your response, I’ve managed to manually update the compiler and it seems to work fine for now, with just some translation warnings.
In any case I will be waiting for an official fix.