Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added MAX32665 EvKit as PORT #495

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
18 changes: 18 additions & 0 deletions port/max32665-evkit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.swp
.*.sw[op]
*~
*.o
*.a
*.xml
*.d
*.map
*.elf
build/
GPATH
GRTAGS
GTAGS
tags
*.txt
*.log
core
example/*
Binary file added port/max32665-evkit/BLE5_ctr_bin/ble5_ctr.elffff
Binary file not shown.
11 changes: 11 additions & 0 deletions port/max32665-evkit/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.phony: examples
all: examples

examples:
scripts/create_examples.py

clean:
scripts/delete_examples.py
@rm -rf example/Makefile
@echo "Deleting CC2564B Init Script in src folder"
@rm -rf src/cc256x* bluetooth_init*
56 changes: 56 additions & 0 deletions port/max32665-evkit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# BTstack Port for the Maxim MAX32665 EvKit-V1

This port uses the [MAX32665/6 ARM Cortex M4F Board](https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/max32666evkit.html). All EvKits come with an external CMSIS-DAP programmer used to flash the boards.

## Software

The [Analog Devices MSDK](https://github.com/Analog-Devices-MSDK/msdk) is a free development kit that includes all the necessary drivers for the board's operation.


## Toolchain Setup

Please follow the directions given in the [MSDK README.md](https://github.com/Analog-Devices-MSDK/msdk#readme)





## Build

Ensure that the `MAXIM_PATH` points to the root directory where MSDK installed.
Then, navigate to the port/max32665-evkit folder and run the make command in the terminal to generate example projects in the example folder.

In each example folder, e.g. port/max323630-fthr/example/spp_and_le_streamer, you can run make again to build an .elf file. The build folder will contain this file, making it conveniently accessible for debugging with Eclipse or GDB.


## Flashing MAX32665
There are two methods to program the board. The easiest is to drag and drop the generated .bin file to the DAPLINK mass storage drive. Once the file is copied, the DAPLINK should program and then run the new firmware.

Alternatively, OpenOCD can be used to flash and debug the device. A suitable programming script is available in the scripts folder.

## Usage

The project is designed to connect over HCI via the H4 transport (UART) to another MAX32 BLE capable device (MAX32665 is BLE capable).

For the controller, build and flash the BLE5_ctr project found in the MSDK under [Examples/MAX32665/BLE5_ctr](https://github.com/Analog-Devices-MSDK/msdk/tree/main/Examples/MAX32665/BLE5_ctr) to another MAX32665 EV Kit or FTHR. For comvenience, the ELF file can also be found in this directory under BLE5_ctr_bin.

After this code is flashed onto a secondary board, flash an example onto the primary EVKIT running the BTstack host software.

To connect the boards, use a jumper wire to link UART3 from one board to the other. UART3 can be found on the EVKIT at JP9 and JP10. After the connection and flashing are complete, reset both boards to start the example.

The HCI uart can be found and modified in the MSDK under Libraries/Boards/MAX32665/EvKit_V1/Include/board.h
## Debugging

OpenOCD can be used for both development and debugging. Step-by-step debugging can be achieved with either Eclipse or GDB via OpenOCD.

## Debug output

printf messages are redirected to UART0, which can be accessed via the onboard USB to serial converter.



Additional debugging information can be enabled by uncommenting ENABLE_LOG_INFO in the src/btstack_config.h header file and performing a clean rebuild.



Debug output is available on both the host and controller.
90 changes: 90 additions & 0 deletions port/max32665-evkit/scripts/create_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env python3
#
# Create project files for all BTstack embedded examples in WICED/apps/btstack

import os
import re
import shutil
import subprocess
import sys

# build all template
build_all = '''
SUBDIRS = \\
%s

all:
\techo Building all examples
\tfor dir in $(SUBDIRS); do \\
\t$(MAKE) -C $$dir || exit 1; \\
\tdone

clean:
\techo Cleaning all ports
\tfor dir in $(SUBDIRS); do \\
\t$(MAKE) -C $$dir clean; \\
\tdone
'''

# get script path
script_path = os.path.abspath(os.path.dirname(sys.argv[0])) + '/../'

# get btstack root
btstack_root = script_path + '../../'



# path to examples
examples_embedded = btstack_root + 'example/'

# path to generated example projects
projects_path = script_path + "example/"

# path to template
template_path = script_path + 'template/Makefile'

print("Creating example projects:")

# iterate over btstack examples
example_files = os.listdir(examples_embedded)

examples = []

for file in example_files:
if not file.endswith(".c"):
continue
if file in ['panu_demo.c', 'sco_demo_util.c', 'ant_test.c']:
continue
example = file[:-2]
examples.append(example)

# create folder
project_folder = projects_path + example + "/"
if not os.path.exists(project_folder):
os.makedirs(project_folder)

# check if .gatt file is present
gatt_path = examples_embedded + example + ".gatt"
gatt_h = ""
if os.path.exists(gatt_path):
gatt_h = example+'.h'

# create makefile
with open(project_folder + 'Makefile', 'wt') as fout:
with open(template_path, 'rt') as fin:
for line in fin:
if 'PROJECT=spp_and_le_streamer' in line:
fout.write('PROJECT=%s\n' % example)
continue
if 'all: spp_and_le_streamer.h' in line:
if len(gatt_h):
fout.write("all: %s\n" % gatt_h)
continue
fout.write(line)

print("- %s" % example)

with open(projects_path+'Makefile', 'wt') as fout:
fout.write(build_all % ' \\\n'.join(examples))

print("Projects are ready for compile in example folder. See README for details.")
31 changes: 31 additions & 0 deletions port/max32665-evkit/scripts/delete_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3
#
# Delete project files for all BTstack embedded examples in local port/esp32 folder

import os
import shutil
import sys
import time
import subprocess

# get script path
script_path = os.path.abspath(os.path.dirname(sys.argv[0]))

# path to examples
examples_embedded = script_path + "/../../../example/"

# path to port/esp32
apps_btstack = "example/"

print("Deleting examples in local folder")

# iterate over btstack examples
for file in os.listdir(examples_embedded):
if not file.endswith(".c"):
continue
example = file[:-2]
apps_folder = apps_btstack + example + "/"
if os.path.exists(apps_folder):
shutil.rmtree(apps_folder)
print("- %s" % example)

62 changes: 62 additions & 0 deletions port/max32665-evkit/src/btstack_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

#ifndef BTSTACK_CONFIG_H
#define BTSTACK_CONFIG_H

#include <stdint.h>

// Port related features
// #define HAVE_BTSTACK_STDIN
#define HAVE_EMBEDDED_TIME_MS
#define HAVE_INIT_SCRIPT

// BTstack features that can be enabled
#define ENABLE_BLE
#define ENABLE_MESH
#define ENABLE_CLASSIC
#define ENABLE_LE_CENTRAL
#define ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS
#define ENABLE_PRINTF_HEXDUMP
#define ENABLE_SCO_OVER_HCI
#define ENABLE_HFP_WIDE_BAND_SPEECH
#define ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS
#define ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE
#define ENABLE_LE_PERIPHERAL
#define ENABLE_LE_SECURE_CONNECTIONS
#define ENABLE_LOG_INFO
#define ENABLE_LOG_ERROR
#define ENABLE_PRINTF_HEXDUMP
#define ENABLE_SCO_OVER_HCI


// BTstack configuration. buffers, sizes, ...
#define HCI_ACL_PAYLOAD_SIZE 1021
#define MAX_NR_AVDTP_CONNECTIONS 1
#define MAX_NR_AVDTP_STREAM_ENDPOINTS 1
#define MAX_NR_AVRCP_CONNECTIONS 2
#define MAX_NR_BNEP_CHANNELS 1
#define MAX_NR_BNEP_SERVICES 1
#define MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 2
#define MAX_NR_GATT_CLIENTS 1
#define MAX_NR_HCI_CONNECTIONS 1
#define MAX_NR_HID_HOST_CONNECTIONS 1
#define MAX_NR_HIDS_CLIENTS 1
#define MAX_NR_HFP_CONNECTIONS 1
#define MAX_NR_L2CAP_CHANNELS 3
#define MAX_NR_L2CAP_SERVICES 3
#define MAX_NR_RFCOMM_CHANNELS 1
#define MAX_NR_RFCOMM_MULTIPLEXERS 1
#define MAX_NR_RFCOMM_SERVICES 1
#define MAX_NR_SERVICE_RECORD_ITEMS 4
#define MAX_NR_SM_LOOKUP_ENTRIES 3
#define MAX_NR_WHITELIST_ENTRIES 1


#define MAX_NR_MESH_VIRTUAL_ADDRESSES 4
#define MAX_NR_MESH_NETWORK_KEYS 4
#define MAX_NR_MESH_TRANSPORT_KEYS 4

// Link Key DB and LE Device DB using TLV on top of Flash Sector interface
#define NVM_NUM_DEVICE_DB_ENTRIES 16
#define NVM_NUM_LINK_KEYS 16

#endif
Loading