Permalink
Browse files

esp32: re-implement integrate_btstack in python as rsync is missing i…

…n prebuild esp-idf windows toolchain
  • Loading branch information...
mringwal committed Oct 9, 2017
1 parent 3d244bf commit 9c7c30eebab013c8a0bd14dcd3940a4b1debdaa4
Showing with 130 additions and 107 deletions.
  1. +5 −3 port/esp32/README.md
  2. +73 −68 port/esp32/create_examples.py
  3. +52 −0 port/esp32/integrate_btstack.py
  4. +0 −36 port/esp32/integrate_btstack.sh
View
@@ -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 @@
COMPONENT_EXTRA_CLEAN = EXAMPLE.h
'''
# get script path
script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
# path to examples
examples_embedded = 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 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
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)
# 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)
# 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)
# 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 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)
def create_examples(script_path):
# path to examples
examples_embedded = 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 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
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)
# 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)
# 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)
# 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 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)
@@ -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)

This file was deleted.

Oops, something went wrong.

0 comments on commit 9c7c30e

Please sign in to comment.