# Kraxor's Boilerplate Framework A collection of useful things in the form of an `esp-idf` component. Tested with `esp-idf/v4.3`. ## Using as a component To use `kbf` as an `esp-idf` component, clone it into the `components` subdirectory of your project: ```shell cd /path/to/project/components git clone https://git.kraxor.net/kraxor/kbf.git cd kbf git submodule update --init ``` Then you can `REQUIRE` it in `idf_component_register` in your app's `CMakeLists.txt`: ```cmake idf_component_register( SRCS "app_main.cpp" REQUIRES "kbf" INCLUDE_DIRS "." ) ``` ## Checkout as standalone project For a standalone checkout, in order for the test application to compile, the parent directory of the project root (`test_app/../..`) is included in `EXTRA_COMPONENT_DIRS`. This is fine when used as a component, but will cause issues if this directory contains other projects that are not `esp-idf` components. Therefore, if you want to setup `kbf` as a standalone project, it is recommended to clone the project into a subdirectory: ```shell mkdir ~/src/kbf cd ~/src/kbf git clone https://git.kraxor.net/kraxor/kbf.git cd kbf # ~/src/kbf/kbf/ git submodule init && git submodule update ``` ## CLion setup The smoothest way is to open the `test_app` as a project, e.g. following the above example: ```shell clion ~/src/kbf/kbf/test_app ``` Next, you need to setup `cmake`. In `File / Settings / Build, Execution, Deployment / CMake`, add the following to `CMake options`: ```shell -DIDF_PATH=/path/to/esp-idf ``` Then you need to add `IDF_PATH` again, this time as an environment variable, along with the `PATH` variable updated by `/path/to/esp-idf/export.sh`. In my case, it looks like this: ``` IDF_PATH=/home/kraxor/src/esp-idf;PATH=/home/kraxor/src/kbf/esp-idf/components/esptool_py/esptool:/home/kraxor/src/esp-idf/components/espcoredump:/home/kraxor/src/esp-idf/components/partition_table:/home/kraxor/src/esp-idf/components/app_update:/home/kraxor/.espressif/python_env/idf4.4_py3.8_env/bin:/home/kraxor/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin:/home/kraxor/.espressif/tools/xtensa-esp32s2-elf/esp-2020r3-8.4.0/xtensa-esp32s2-elf/bin:/home/kraxor/.espressif/tools/xtensa-esp32s3-elf/esp-2020r3-8.4.0/xtensa-esp32s3-elf/bin:/home/kraxor/.espressif/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin:/home/kraxor/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin:/home/kraxor/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin:/home/kraxor/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/bin:/home/kraxor/src/esp-idf/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin ``` After this, CLion should be able to parse `test_app/CMakeLists.txt` and add the parent directory (i.e. `kbf` root) and `esp-idf` to the project.