ESP-IDF used as Submodule like ESP-ADF

mikemoy
Posts: 415
Joined: Fri Jan 12, 2018 9:10 pm

ESP-IDF used as Submodule like ESP-ADF

Postby mikemoy » Tue Jan 14, 2020 3:40 am

In another thread @chegewara had what I thought was a great idea. But I am not sure how to implement it.
He said:
Lets look at esp-adf project for example. Esp-idf is used as submodule with particular commit:
https://github.com/espressif/esp-adf

I believe you can build any project you want the same way and instead of having global esp-idf, you can have esp-idf per project.
I like this idea. The reason being that looking in the future I can see a potential problem arising where projects that are built today and released using say v3.3.1. But later ESP-IDF will be on another version say v4.x.x. Should my customer want to make changes a year later I need to build that project built on v3.3.1 but my current setup is on v4.x.x which wont work.

Did all that makes sense ;-) How can I copy v3.3.1 into the each project so I know its all self contained much like what ESP-ADF does

chegewara
Posts: 913
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP-IDF used as Submodule like ESP-ADF

Postby chegewara » Tue Jan 14, 2020 8:40 am

1) create project and git init
2) ad esp-idf as submodule https://stackoverflow.com/questions/420 ... repository
3) go to esp-idf and git commit to version you want
4) git add . & git push

https://github.com/chegewara/commit-test

Remember to configure CMakeLists.txt to use esp-idf from subfolder.

mikemoy
Posts: 415
Joined: Fri Jan 12, 2018 9:10 pm

Re: ESP-IDF used as Submodule like ESP-ADF

Postby mikemoy » Tue Jan 14, 2020 3:26 pm

Thank you for the example. But this did not go smooth sailing for me on the PC.
My default Windows IDF_PATH is C:\Users\Mike\ESP32\esp-idf

Its not clear to me in your example how its pointing to the new submodule.
The CMakeLists.txt file contains:

Code: Select all

# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(hello-world)
The way i read this is that it would be still using the defaul path and not pointing to the included ESP-IDF folder.
Am i just not seeing the light here or what ?

mrrosen
Posts: 18
Joined: Tue Sep 26, 2017 12:53 am

Re: ESP-IDF used as Submodule like ESP-ADF

Postby mrrosen » Tue Jan 14, 2020 6:51 pm

For one of my projects, I did this exact thing however, this was right during the shift to cmake so I did it in the old Makefile system; like so (where I created the esp-idf as a submodule in the idf directory):

Code: Select all

export IDF_PATH = $(PWD)/idf

PROJECT_NAME := my_project

include $(IDF_PATH)/make/project.mk
Pretty sure you could do that same thing with cmake by setting the IDF_PATH environment variable at the start of the file:

Code: Select all

cmake_minimum_required(VERSION 3.5)

set(ENV{IDF_PATH} ${CMAKE_CURRENT_LIST_DIR}/idf)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(my_project)
Last edited by mrrosen on Wed Jan 15, 2020 6:05 pm, edited 1 time in total.

chegewara
Posts: 913
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP-IDF used as Submodule like ESP-ADF

Postby chegewara » Wed Jan 15, 2020 12:14 am

https://github.com/espressif/esp-adf/bl ... .txt#L6-L8

I didnt try it yet, but i believe you need to set IDF_PATH without if, just this line:

Code: Select all

set(ENV{IDF_PATH} "${PROJECT_PATH}/esp-idf/")
set(EXTRA_COMPONENT_DIRS ${PROJECT_PATH}/components)

mikemoy
Posts: 415
Joined: Fri Jan 12, 2018 9:10 pm

Re: ESP-IDF used as Submodule like ESP-ADF

Postby mikemoy » Wed Jan 15, 2020 4:24 am

Thanks guys for the help. Didn't work for me. I got much closer with

Code: Select all

set(ENV{IDF_PATH} "${PROJECT_PATH}/esp-idf/")
set(EXTRA_COMPONENT_DIRS ${PROJECT_PATH}/components)
At the moment I just don't have the time to dig into this.

chegewara
Posts: 913
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP-IDF used as Submodule like ESP-ADF

Postby chegewara » Fri Jan 17, 2020 11:56 am

Ok, ive been overthinking it, but it is very simple. I am using PIO and from PIO terminal i had to do this:

Code: Select all

. ./esp-idf/export.sh
idf.py build
It was with esp-idf v3.3 as submodule described earlier.

PS no changes needed in CMakeLists.txt i mentioned earlier, just forget it

Who is online

Users browsing this forum: Baidu [Spider], mihir_t, NevynSelby and 19 guests