Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@
"${workspaceFolder}/bricks/virtualhub",
"${workspaceFolder}/bricks/virtualhub/build",
"${workspaceFolder}/bricks/virtualhub/build-debug",
"${workspaceFolder}/lib/btstack/chipset/realtek",
"${workspaceFolder}/lib/btstack/platform/libusb",
"${workspaceFolder}/lib/btstack/platform/posix",
"${workspaceFolder}/lib/btstack/src",
"${workspaceFolder}/lib/lego",
"${workspaceFolder}/lib/lwrb/src/include",
"${workspaceFolder}/lib/pbio",
Expand All @@ -394,7 +398,8 @@
"${workspaceFolder}/micropython",
"${workspaceFolder}",
"${workspaceFolder}/lib/umm_malloc/src",
"/usr/include/python3.10"
"/usr/include/python3.10",
"/usr/include/libusb-1.0"
],
"defines": [
"MICROPY_MODULE_FROZEN_MPY",
Expand Down
74 changes: 73 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"console":"integratedTerminal"
},
{
"name": "virtualhub",
"name": "virtualhub (no bluetooth)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bricks/virtualhub/build-debug/firmware.elf",
Expand Down Expand Up @@ -92,6 +92,78 @@
],
"preLaunchTask": "build virtualhub (debug)"
},
{
"name": "virtualhub (UB500_INDEX=0)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bricks/virtualhub/build-debug/firmware.elf",
"args": [
"${workspaceFolder}/tests/bluetooth/virtual0.py",
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "PBIO_TEST_CONNECT_SOCKET",
"value": "true"
},
{
"name": "UB500_INDEX",
"value": "0"
}
],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Ignore timer signal",
"text": "handle SIG34 noprint pass",
"ignoreFailures": false
}
],
"preLaunchTask": "build virtualhub (debug)"
},
{
"name": "virtualhub (UB500_INDEX=1)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bricks/virtualhub/build-debug/firmware.elf",
"args": [
"${workspaceFolder}/tests/bluetooth/virtual1.py",
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "PBIO_TEST_CONNECT_SOCKET",
"value": "true"
},
{
"name": "UB500_INDEX",
"value": "1"
}
],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Ignore timer signal",
"text": "handle SIG34 noprint pass",
"ignoreFailures": false
}
],
"preLaunchTask": "build virtualhub (debug)"
},
{
"name": "test-pbio",
"type": "cppdbg",
Expand Down
48 changes: 48 additions & 0 deletions bricks/_common/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ endif
ifneq ($(strip $(PB_LIB_BTSTACK)),)
INC += -I$(PBTOP)/lib/btstack/chipset/cc256x
INC += -I$(PBTOP)/lib/btstack/src
ifeq ($(PBIO_PLATFORM),virtual_hub)
INC += -I$(PBTOP)/lib/btstack/platform/posix
INC += -I$(PBTOP)/lib/btstack/platform/embedded
INC += -I$(PBTOP)/lib/btstack/3rd-party/tinydir
INC += -I$(PBTOP)/lib/btstack/3rd-party/rijndael
INC += -I$(PBTOP)/lib/btstack/3rd-party/micro-ecc
INC += -I$(PBTOP)/lib/btstack/chipset/bcm
INC += -I$(PBTOP)/lib/btstack/chipset/intel
INC += -I$(PBTOP)/lib/btstack/chipset/realtek
INC += -I$(PBTOP)/lib/btstack/chipset/zephyr
ifneq ($(CI_MODE),1)
INC += $(shell pkg-config libusb-1.0 --cflags)
endif
endif
endif
ifeq ($(PB_LIB_LSM6DS3TR_C),1)
INC += -I$(PBTOP)/lib/lsm6ds3tr_c_STdC/driver
Expand Down Expand Up @@ -155,13 +169,22 @@ TEXT0_ADDR ?= 0x08000000
ifeq ($(PB_MCU_FAMILY),native)
UNAME_S := $(shell uname -s)
LD = $(CC)
ifeq ($(CI_MODE),1)
COPT = -DPBDRV_CONFIG_RUN_ON_CI
else
endif
CFLAGS += $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=gnu99 $(COPT) -D_GNU_SOURCE
ifeq ($(UNAME_S),Linux)
LDFLAGS += -Wl,-Map=$@.map,--cref -Wl,--gc-sections
else ifeq ($(UNAME_S),Darwin)
LDFLAGS += -Wl,-map,$@.map -Wl,-dead_strip
endif
LIBS = -lm
ifeq ($(PB_LIB_BTSTACK),lowenergy)
ifneq ($(CI_MODE),1)
LIBS += $(shell pkg-config libusb-1.0 --libs)
endif
endif
else # end native, begin embedded
CROSS_COMPILE ?= arm-none-eabi-
ifeq ($(PB_MCU_FAMILY),STM32)
Expand Down Expand Up @@ -395,6 +418,25 @@ BTSTACK_SRC_C += $(addprefix lib/btstack/chipset/cc256x/,\
btstack_chipset_cc256x.c \
)

# libusb-specific BTStack sources for virtual_hub
ifeq ($(PBIO_PLATFORM),virtual_hub)
BTSTACK_SRC_C += $(addprefix lib/btstack/,\
platform/libusb/hci_transport_h2_libusb.c \
platform/posix/hci_dump_posix_stdout.c \
platform/posix/btstack_tlv_posix.c \
src/classic/btstack_link_key_db_tlv.c \
src/ble/le_device_db_tlv.c \
chipset/zephyr/btstack_chipset_zephyr.c \
chipset/realtek/btstack_chipset_realtek.c \
chipset/bcm/btstack_chipset_bcm.c \
chipset/intel/btstack_chipset_intel_firmware.c \
3rd-party/rijndael/rijndael.c \
3rd-party/micro-ecc/uECC.c \
)
# Suppress unused variable warning for this file
$(BUILD)/lib/btstack/platform/libusb/hci_transport_h2_libusb.o: CFLAGS += -Wno-unused-variable
endif

# STM32 HAL

COPT += -DUSE_FULL_LL_DRIVER
Expand Down Expand Up @@ -528,12 +570,18 @@ OBJ += $(addprefix $(BUILD)/, $(BLE5STACK_SRC_C:.c=.o))
endif

ifeq ($(PB_LIB_BTSTACK),classic)
ifneq ($(CI_MODE),1)
OBJ += $(addprefix $(BUILD)/, $(BTSTACK_SRC_C:.c=.o))
$(BUILD)/lib/btstack/%.o: CFLAGS += -Wno-error
endif
endif

ifeq ($(PB_LIB_BTSTACK),lowenergy)
ifneq ($(CI_MODE),1)
OBJ += $(addprefix $(BUILD)/, $(BTSTACK_SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(BTSTACK_BLE_SRC_C:.c=.o))
$(BUILD)/lib/btstack/%.o: CFLAGS += -Wno-error
endif
endif

ifeq ($(PB_LIB_STM32_HAL),1)
Expand Down
3 changes: 2 additions & 1 deletion bricks/_common/sources.mk
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ PBIO_SRC_C = $(addprefix lib/pbio/,\
drv/block_device/block_device_test.c \
drv/block_device/block_device_w25qxx_stm32.c \
drv/bluetooth/bluetooth.c \
drv/bluetooth/bluetooth_btstack_stm32_hal.c \
drv/bluetooth/bluetooth_btstack.c \
drv/bluetooth/bluetooth_btstack_ev3.c \
drv/bluetooth/bluetooth_btstack_posix.c \
drv/bluetooth/bluetooth_btstack_stm32_hal.c \
drv/bluetooth/bluetooth_simulation.c \
drv/bluetooth/bluetooth_stm32_bluenrg.c \
drv/bluetooth/bluetooth_stm32_cc2640.c \
Expand Down
1 change: 1 addition & 0 deletions bricks/virtualhub/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ PB_MCU_FAMILY = native
PB_FROZEN_MODULES = 1
MICROPY_ROM_TEXT_COMPRESSION = 1
PB_LIB_UMM_MALLOC = 1
PB_LIB_BTSTACK = lowenergy

include ../_common/common.mk
Loading
Loading