Skip to content

Instantly share code, notes, and snippets.

@DerEros
Created September 13, 2019 13:19
Show Gist options
  • Save DerEros/3c696618842e0dd7f1f621ba8ef3b094 to your computer and use it in GitHub Desktop.
Save DerEros/3c696618842e0dd7f1f621ba8ef3b094 to your computer and use it in GitHub Desktop.
Setting up Makefile based build for ESP8266, including Vim autocomplete

Compiler not being found

When running make with even a simple blink project, the build aborts right away complaining about a missing compiler.

Solution: Put the include statement in the Makefile at the end of the file, after all other variables have been set.

Python not found

After linking, build complains that it cannot find /python. Obviously lacking the path where to look at. Looks like the path should come from the Arduino IDE but it is not. Issue is also tracked here:

plerup/makeEspArduino#125

Workaround: modify the esp Makefile and add the path to Python:

diff --git a/makeEspArduino.mk b/makeEspArduino.mk
index b09091e..2f06989 100644
--- a/makeEspArduino.mk
+++ b/makeEspArduino.mk
@@ -491,6 +491,7 @@ sub def_var {
    $$v{$$name} = "\$$($$var)";
 }
 
+$$v{'runtime.tools.python.path'} = '/usr/bin';
 $$v{'runtime.platform.path'} = '$$(ESP_ROOT)';
 $$v{'includes'} = '$$(C_INCLUDES)';
 $$v{'runtime.ide.version'} = '10605';

Autocomplete with Vim and Coc

Using ccls. Install it, in Vim run Coc config and in the languageserver section add:

        "ccls": {
            "command": "ccls",
            "filetypes": ["c", "cpp", "objc", "objcpp"],
            "rootPatterns": [".ccls", "compile_commands.json", ".vim/", ".git/", ".hg/"],
            "initializationOptions": {
                "cache": {
                    "directory": "/tmp/ccls"
                }
            }
        }

Restart Vim.

Autocomplete does not recognize code from ESP SDK

Install Bear (Build EAR). Run it in the directory where the Makefile is with bear make. This will generate the compile_commands.json file which ccls needs to know where to look for header files. Restart Vim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment