mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-03 23:47:08 +00:00
esp32: re-implement integrate_btstack in python as rsync is missing in prebuild esp-idf windows toolchain
This commit is contained in:
parent
3d244bfa4d
commit
9c7c30eeba
@ -12,9 +12,11 @@ Status: Basic port incl. all examples. BTstack runs on dedicated FreeRTOS thread
|
||||
|
||||
In port/esp32, run
|
||||
|
||||
./integrate_btstack.sh
|
||||
./integrate_btstack.py
|
||||
|
||||
The script will copy parts of the BTstack tree into the ESP-IDF as $IDF_PATH/components/btstack and then create project folders for all examples. Each example project folder, e.g. port/esp32/examples/spp_and_le_counter, contains a Makefile. Please run the command again after updating the BTstack tree to also update the copy in the ESP-IDF.
|
||||
The script will copy parts of the BTstack tree into the ESP-IDF as $IDF_PATH/components/btstack and then create project folders for all examples.
|
||||
|
||||
Each example project folder, e.g. port/esp32/examples/spp_and_le_counter, contains a Makefile. Please run the command again after updating the BTstack tree (e.g. by git pull) to also update the copy in the ESP-IDF.
|
||||
|
||||
To compile an example, run:
|
||||
|
||||
@ -34,7 +36,7 @@ You can quit the monitor with CTRL-].
|
||||
|
||||
## Old Make Versions
|
||||
|
||||
Compilation fails with older versions of the make tool, e.g. make 3.8.1 (from 2006) providedby the current Xcode 9 on macOS.
|
||||
Compilation fails with older versions of the make tool, e.g. make 3.8.1 (from 2006) provided by the current Xcode 9 on macOS.
|
||||
Interestingly, if you run make a second time, it completes the compilation.
|
||||
|
||||
## Configuration
|
||||
|
@ -31,71 +31,76 @@ EXAMPLE.h: $(COMPONENT_PATH)/EXAMPLE.gatt
|
||||
COMPONENT_EXTRA_CLEAN = EXAMPLE.h
|
||||
'''
|
||||
|
||||
# get script path
|
||||
script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
def create_examples(script_path):
|
||||
# path to examples
|
||||
examples_embedded = script_path + "/../../example/"
|
||||
|
||||
# path to examples
|
||||
examples_embedded = script_path + "/../../example/"
|
||||
# path to samples
|
||||
example_folder = script_path + "/example/"
|
||||
|
||||
# path to samples
|
||||
example_folder = script_path + "/example/"
|
||||
print("Creating examples folder")
|
||||
if not os.path.exists(example_folder):
|
||||
os.makedirs(example_folder)
|
||||
|
||||
print("Creating examples folder")
|
||||
if not os.path.exists(example_folder):
|
||||
os.makedirs(example_folder)
|
||||
print("Creating examples in examples folder")
|
||||
|
||||
print("Creating examples in examples folder")
|
||||
# iterate over btstack examples
|
||||
for file in os.listdir(examples_embedded):
|
||||
if not file.endswith(".c"):
|
||||
continue
|
||||
if file in ['panu_demo.c', 'sco_demo_util.c']:
|
||||
continue
|
||||
|
||||
# iterate over btstack examples
|
||||
for file in os.listdir(examples_embedded):
|
||||
if not file.endswith(".c"):
|
||||
continue
|
||||
if file in ['panu_demo.c', 'sco_demo_util.c']:
|
||||
continue
|
||||
example = file[:-2]
|
||||
gatt_path = examples_embedded + example + ".gatt"
|
||||
|
||||
example = file[:-2]
|
||||
gatt_path = examples_embedded + example + ".gatt"
|
||||
# create folder
|
||||
apps_folder = example_folder + example + "/"
|
||||
if os.path.exists(apps_folder):
|
||||
shutil.rmtree(apps_folder)
|
||||
os.makedirs(apps_folder)
|
||||
|
||||
# create folder
|
||||
apps_folder = example_folder + example + "/"
|
||||
if os.path.exists(apps_folder):
|
||||
shutil.rmtree(apps_folder)
|
||||
os.makedirs(apps_folder)
|
||||
# copy files
|
||||
for item in ['sdkconfig', 'set_port.sh']:
|
||||
shutil.copyfile(script_path + '/template/' + item, apps_folder + '/' + item)
|
||||
|
||||
# copy files
|
||||
for item in ['sdkconfig', 'set_port.sh']:
|
||||
shutil.copyfile(script_path + '/template/' + item, apps_folder + '/' + item)
|
||||
# mark set_port.sh as executable
|
||||
os.chmod(apps_folder + '/set_port.sh', 0o755)
|
||||
|
||||
# mark set_port.sh as executable
|
||||
os.chmod(apps_folder + '/set_port.sh', 0o755)
|
||||
# create Makefile file
|
||||
with open(apps_folder + "Makefile", "wt") as fout:
|
||||
fout.write(mk_template.replace("EXAMPLE", example).replace("TOOL", script_path).replace("DATE",time.strftime("%c")))
|
||||
|
||||
# create Makefile file
|
||||
with open(apps_folder + "Makefile", "wt") as fout:
|
||||
fout.write(mk_template.replace("EXAMPLE", example).replace("TOOL", script_path).replace("DATE",time.strftime("%c")))
|
||||
# create main folder
|
||||
main_folder = apps_folder + "main/"
|
||||
if not os.path.exists(main_folder):
|
||||
os.makedirs(main_folder)
|
||||
|
||||
# create main folder
|
||||
main_folder = apps_folder + "main/"
|
||||
if not os.path.exists(main_folder):
|
||||
os.makedirs(main_folder)
|
||||
# copy example file
|
||||
shutil.copyfile(examples_embedded + file, apps_folder + "/main/" + example + ".c")
|
||||
|
||||
# copy example file
|
||||
shutil.copyfile(examples_embedded + file, apps_folder + "/main/" + example + ".c")
|
||||
# add sco_demo_util.c for audio examples
|
||||
if example in ['hfp_ag_demo','hfp_hf_demo', 'hsp_ag_demo', 'hsp_hf_demo']:
|
||||
shutil.copy(examples_embedded + 'sco_demo_util.c', apps_folder + '/main/')
|
||||
shutil.copy(examples_embedded + 'sco_demo_util.h', apps_folder + '/main/')
|
||||
|
||||
# add sco_demo_util.c for audio examples
|
||||
if example in ['hfp_ag_demo','hfp_hf_demo', 'hsp_ag_demo', 'hsp_hf_demo']:
|
||||
shutil.copy(examples_embedded + 'sco_demo_util.c', apps_folder + '/main/')
|
||||
shutil.copy(examples_embedded + 'sco_demo_util.h', apps_folder + '/main/')
|
||||
# add component.mk file to main folder
|
||||
main_component_mk = apps_folder + "/main/component.mk"
|
||||
shutil.copyfile(script_path + '/template/main/component.mk', main_component_mk)
|
||||
|
||||
# add rules to compile gatt db if .gatt file is present
|
||||
gatt_path = examples_embedded + example + ".gatt"
|
||||
if os.path.exists(gatt_path):
|
||||
shutil.copy(gatt_path, apps_folder + "/main/" + example + ".gatt")
|
||||
with open(main_component_mk, "a") as fout:
|
||||
fout.write(component_mk_gatt_add_on.replace("EXAMPLE", example))
|
||||
print("- %s including GATT DB compilation rules" % example)
|
||||
else:
|
||||
print("- %s" % example)
|
||||
|
||||
if __name__ == '__main__':
|
||||
# get script path
|
||||
script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
create_examples(script_path)
|
||||
|
||||
# add component.mk file to main folder
|
||||
main_component_mk = apps_folder + "/main/component.mk"
|
||||
shutil.copyfile(script_path + '/template/main/component.mk', main_component_mk)
|
||||
|
||||
# add rules to compile gatt db if .gatt file is present
|
||||
gatt_path = examples_embedded + example + ".gatt"
|
||||
if os.path.exists(gatt_path):
|
||||
shutil.copy(gatt_path, apps_folder + "/main/" + example + ".gatt")
|
||||
with open(main_component_mk, "a") as fout:
|
||||
fout.write(component_mk_gatt_add_on.replace("EXAMPLE", example))
|
||||
print("- %s including GATT DB compilation rules" % example)
|
||||
else:
|
||||
print("- %s" % example)
|
||||
|
52
port/esp32/integrate_btstack.py
Executable file
52
port/esp32/integrate_btstack.py
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Add btstack component to esp-idf
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import create_examples
|
||||
|
||||
if not 'IDF_PATH' in os.environ:
|
||||
print('Error: IDF_PATH not defined. Please set IDF_PATH as described here:\nhttp://esp-idf.readthedocs.io/en/latest/get-started/index.html#get-started-get-esp-idf');
|
||||
sys.exit(10)
|
||||
|
||||
IDF_PATH=os.environ['IDF_PATH']
|
||||
print("IDF_PATH=%s" % IDF_PATH)
|
||||
|
||||
IDF_COMPONENTS=IDF_PATH + "/components"
|
||||
|
||||
if not os.path.exists(IDF_COMPONENTS):
|
||||
print("Error: No components folder at $IDF_PATH/components, please check IDF_PATH")
|
||||
sys.exit(10)
|
||||
|
||||
IDF_BTSTACK=IDF_COMPONENTS+"/btstack"
|
||||
|
||||
if os.path.exists(IDF_BTSTACK):
|
||||
print("Deleting old BTstack component %s" % IDF_BTSTACK)
|
||||
shutil.rmtree(IDF_BTSTACK)
|
||||
|
||||
# get local dir
|
||||
local_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
|
||||
# create components/btstack
|
||||
print("Creating BTstack component at %s" % IDF_COMPONENTS)
|
||||
shutil.copytree(local_dir+'/components/btstack', IDF_BTSTACK)
|
||||
|
||||
dirs_to_copy = [
|
||||
'src',
|
||||
'3rd-party/bluedroid',
|
||||
'3rd-party/hxcmod-player',
|
||||
'platform/freertos',
|
||||
'platform/embedded',
|
||||
'tool'
|
||||
]
|
||||
|
||||
for dir in dirs_to_copy:
|
||||
print('- %s' % dir)
|
||||
shutil.copytree(local_dir + '/../../' + dir, IDF_BTSTACK + '/' + dir)
|
||||
|
||||
# create example/btstack
|
||||
create_examples.create_examples(local_dir)
|
@ -1,36 +0,0 @@
|
||||
#/bin/sh
|
||||
|
||||
# check esp-idf path
|
||||
if [ ! -f "$IDF_PATH/README.md" ]; then
|
||||
echo "IDF_PATH not set, please follow esp-idf installation instructions"
|
||||
echo "http://esp-idf.readthedocs.io/en/latest/get-started/index.html#setup-path-to-esp-idf"
|
||||
exit 10
|
||||
fi
|
||||
|
||||
echo "Integrating BTstack into esp-idf at $IDF_PATH"
|
||||
|
||||
echo "Adding component/btstack"
|
||||
|
||||
# create subsys/btstack
|
||||
rsync -a components/btstack ${IDF_PATH}/components
|
||||
|
||||
# sync sources
|
||||
rsync -a ../../src ${IDF_PATH}/components/btstack
|
||||
|
||||
# sync bludroid
|
||||
rsync -a ../../3rd-party/bluedroid ${IDF_PATH}/components/btstack/3rd-party
|
||||
|
||||
# sync hxcmod player
|
||||
rsync -a ../../3rd-party/hxcmod-player ${IDF_PATH}/components/btstack/3rd-party
|
||||
|
||||
# sync freertos support
|
||||
rsync -a ../../platform/freertos ${IDF_PATH}/components/btstack/platform
|
||||
|
||||
# sync embedded run loop
|
||||
rsync -a ../../platform/embedded ${IDF_PATH}/components/btstack/platform
|
||||
|
||||
# sync tools - used to access compile_gatt.py
|
||||
rsync -a ../../tool ${IDF_PATH}/components/btstack
|
||||
|
||||
# create samples/btstack
|
||||
./create_examples.py
|
Loading…
Reference in New Issue
Block a user