-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c873ad
commit d11a35c
Showing
39 changed files
with
8,540 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ cmake-build-debug/ | |
gatt.i | ||
gatt_db.c | ||
platform/ | ||
bootload/CMakeFiles/ | ||
bootload/Makefile | ||
bootload/cmake_install.cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
cmake_minimum_required(VERSION 3.6) | ||
project(app | ||
VERSION 1.0) | ||
|
||
set(CMAKE_C_STANDARD 99) | ||
add_definitions(-D__NO_SYSTEM_INIT) | ||
add_definitions(-DEFR32BG1B232F256GM48) | ||
add_definitions(-D__FPU_PRESENT) | ||
|
||
include_directories(inc) | ||
include_directories(gatt) | ||
include_directories(libs/SEGGER_RTT_V612j/RTT) | ||
include_directories(platform/emlib/inc) | ||
include_directories(platform/Device/SiliconLabs/EFR32BG1B/Include) | ||
include_directories(platform/CMSIS/Include) | ||
|
||
# find the bgbuild command used to translate xml into C | ||
find_program(BGBUILD_CMD bin/bgbuild | ||
$ENV{HOME}/dev/tools/ble/v2.1.1.0/protocol/bluetooth_2.1) | ||
|
||
# find the bgfirmware utility. Firstly look in the parent directory/utils. Customise this for your project layout | ||
find_program(FIRMWARE_CMD bgfirmware | ||
PATHS ${CMAKE_SOURCE_DIR}/../utils/build-debug) | ||
|
||
set(GATT_DB gatt_db) | ||
set(GATT_DIR ${CMAKE_SOURCE_DIR}/gatt) | ||
set(LOCALDIR ${CMAKE_SOURCE_DIR}/localdefs) | ||
find_file(OTA_SERVICE_UUID_FILE ota_service.txt | ||
${LOCALDIR} | ||
${CMAKE_SOURCE_DIR}/../bootload/localdefs) | ||
find_file(OTA_KEY_FILE ota_key.txt | ||
${LOCALDIR} | ||
${CMAKE_SOURCE_DIR}/../bootload/localdefs) | ||
|
||
set(BLE_STACK_DIR ${CMAKE_SOURCE_DIR}/libs/ble.v2.1.1.0) | ||
set(GATT_SRC ${GATT_DIR}/gatt.bgproj) | ||
set(GATT_XML ${GATT_DIR}/gatt.xml) | ||
set(GATT_I ${GATT_DIR}/gatt.i) | ||
set(GATT_OUTPUTS ${GATT_DIR}/${GATT_DB}.c ${GATT_DIR}/${GATT_DB}.h) | ||
set(BIN_FILE ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.bin) | ||
set(FMW_FILE ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.fmw) | ||
|
||
file(GLOB_RECURSE USER_SOURCES "src/*.c") | ||
file(GLOB_RECURSE USER_HEADERS "inc/*.h") | ||
file(STRINGS ${OTA_SERVICE_UUID_FILE} OTA_SERVICE) | ||
file(STRINGS ${OTA_KEY_FILE} OTA_KEY) | ||
|
||
IF (CMAKE_BUILD_TYPE MATCHES Debug) | ||
file(GLOB_RECURSE RTT_LIBS "libs/SEGGER_RTT_V612j/RTT/*.c") | ||
add_definitions(-DDEBUG) | ||
ENDIF (CMAKE_BUILD_TYPE MATCHES Debug) | ||
|
||
set(LIBRARIES ${BLE_STACK_DIR}/stack.a) | ||
SET(LINKER_SCRIPT app.ld) | ||
set(STARTUP "src/startup.c") | ||
#set_property(SOURCE ${STARTUP} PROPERTY LANGUAGE C) | ||
|
||
set(CMAKE_COM) | ||
# add library sources needed | ||
|
||
SET(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.ld) | ||
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections -T ${LINKER_SCRIPT} --specs=nosys.specs") | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=${PROJECT_NAME}.map,--no-check-sections") | ||
|
||
add_custom_command( | ||
OUTPUT ${GATT_OUTPUTS} | ||
DEPENDS ${GATT_SRC} ${GATT_XML} | ||
COMMAND ${BGBUILD_CMD} -gn ${GATT_SRC}) | ||
set_source_files_properties(${GATT_OUTPUTS} PROPERTIES GENERATED TRUE) | ||
|
||
add_executable(${PROJECT_NAME}.elf ${USER_SOURCES} ${USER_HEADERS} ${LINKER_SCRIPT} gatt/${GATT_DB}.c ${RTT_LIBS}) | ||
target_link_libraries(${PROJECT_NAME}.elf ${LIBRARIES}) | ||
set_target_properties(${PROJECT_NAME}.elf PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT}) | ||
|
||
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD | ||
COMMENT "Building ${BIN_FILE}" | ||
COMMAND ${CMAKE_OBJCOPY} -Obinary --gap-fill 255 $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE} | ||
COMMENT "Building ${FMW_FILE}" | ||
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${PROJECT_NAME}.hex | ||
COMMAND ${FIRMWARE_CMD} -o${FMW_FILE} -n${PROJECT_VERSION} -k${OTA_KEY} -s${OTA_SERVICE} ${PROJECT_NAME}.hex | ||
COMMAND ${OBJSIZE} ${PROJECT_NAME}.elf) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
INCLUDE(CMakeForceCompiler) | ||
|
||
SET(CMAKE_SYSTEM_NAME Generic) | ||
SET(CMAKE_SYSTEM_VERSION 1) | ||
|
||
# The gcc tools start with this prefix | ||
set(GCC_PREFIX arm-none-eabi) | ||
|
||
# locate the c compiler, provide a list of paths for Cmake to look in. | ||
find_path(GCC_DIR bin/${GCC_PREFIX}-gcc | ||
$ENV{HOME}/dev/tools/4.9_2015q3) | ||
|
||
set(OBJSIZE ${GCC_DIR}/bin/${GCC_PREFIX}-size) | ||
# specify the cross compiler | ||
CMAKE_FORCE_C_COMPILER(${GCC_DIR}/bin/${GCC_PREFIX}-gcc GNU) | ||
CMAKE_FORCE_CXX_COMPILER(${GCC_DIR}/bin/${GCC_PREFIX}-g++ GNU) | ||
|
||
# These flags are appropriate for the SiLabs EFR32BG series chips | ||
SET(COMMON_FLAGS "-mcpu=cortex-m4 -mthumb -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ffunction-sections -fdata-sections -g -fno-common -fmessage-length=0") | ||
SET(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -std=c++11") | ||
SET(CMAKE_C_FLAGS "${COMMON_FLAGS} -std=gnu99") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
/* Linker script for Silicon Labs EFR32MG1P devices */ | ||
/* */ | ||
/* This file is subject to the license terms as defined in ARM's */ | ||
/* CMSIS END USER LICENSE AGREEMENT.pdf, governing the use of */ | ||
/* Example Code. */ | ||
/* */ | ||
/* Silicon Laboratories, Inc. 2015 */ | ||
/* */ | ||
/* Version 4.1.1 */ | ||
/* */ | ||
MEMORY | ||
{ | ||
FLASH (rx) : ORIGIN = 0x00021000, LENGTH = 0x40000-0x21000-0x1000 | ||
RAM (rwx) : ORIGIN = 0x20003000, LENGTH = 0x4C00-4 | ||
} | ||
|
||
/* This is the linker script for the bootloader. | ||
|
||
Linker script to place sections and symbol values. Should be used together | ||
* with other linker script that defines memory regions FLASH and RAM. | ||
* It references following symbols, which must be defined in code: | ||
* Reset_Handler : Entry of reset handler | ||
* | ||
* It defines following symbols, which code can use without definition: | ||
* __exidx_start | ||
* __exidx_end | ||
* __copy_table_start__ | ||
* __copy_table_end__ | ||
* __zero_table_start__ | ||
* __zero_table_end__ | ||
* __etext | ||
* __data_start__ | ||
* __preinit_array_start | ||
* __preinit_array_end | ||
* __init_array_start | ||
* __init_array_end | ||
* __fini_array_start | ||
* __fini_array_end | ||
* __data_end__ | ||
* __bss_start__ | ||
* __bss_end__ | ||
* __end__ | ||
* end | ||
* __HeapLimit | ||
* __StackLimit | ||
* __StackTop | ||
* __stack | ||
* __Vectors_End | ||
* __Vectors_Size | ||
*/ | ||
ENTRY(Reset_Handler) | ||
|
||
SECTIONS | ||
{ | ||
/* At the base of our available flash; start with the AAT table for the app, followed by the vectors and other code. */ | ||
.vectors : | ||
{ | ||
KEEP(*(.AAT)) | ||
. = ALIGN(0x80); | ||
KEEP(*(.vectors)) | ||
__Vectors_End = .; | ||
__Vectors_Size = __Vectors_End - __Vectors; | ||
} > FLASH | ||
|
||
.text_app_ARM.extab : | ||
{ | ||
*(.ARM.extab* .gnu.linkonce.armextab.*) | ||
} > FLASH | ||
|
||
__exidx_start = .; | ||
.text_app_ARM.exidx : | ||
{ | ||
*(.ARM.exidx* .gnu.linkonce.armexidx.*) | ||
} > FLASH | ||
__exidx_end = .; | ||
|
||
.gecko_table : | ||
{ | ||
KEEP(*(.gecko_configuration)) | ||
KEEP(*(.xo_configuration)) | ||
KEEP(*(.gatt_header)) | ||
KEEP(*(.gatt_data)) | ||
KEEP(*(.init)) | ||
KEEP(*(.fini)) | ||
*(.text*) | ||
/* .ctors */ | ||
*crtbegin.o(.ctors) | ||
*crtbegin?.o(.ctors) | ||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) | ||
*(SORT(.ctors.*)) | ||
*(.ctors) | ||
|
||
/* .dtors */ | ||
*crtbegin.o(.dtors) | ||
*crtbegin?.o(.dtors) | ||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) | ||
*(SORT(.dtors.*)) | ||
*(.dtors) | ||
|
||
*(.rodata*) | ||
|
||
KEEP(*(.eh_frame*)) | ||
} > FLASH | ||
|
||
__etext = .; | ||
|
||
|
||
.text_app_data : AT (__etext) | ||
{ | ||
__data_start__ = .; | ||
*(vtable) | ||
*(.data*) | ||
. = ALIGN (4); | ||
*(.ram) | ||
|
||
. = ALIGN(4); | ||
/* preinit data */ | ||
PROVIDE_HIDDEN (__preinit_array_start = .); | ||
KEEP(*(.preinit_array)) | ||
PROVIDE_HIDDEN (__preinit_array_end = .); | ||
|
||
. = ALIGN(4); | ||
/* init data */ | ||
PROVIDE_HIDDEN (__init_array_start = .); | ||
KEEP(*(SORT(.init_array.*))) | ||
KEEP(*(.init_array)) | ||
PROVIDE_HIDDEN (__init_array_end = .); | ||
|
||
. = ALIGN(4); | ||
/* finit data */ | ||
PROVIDE_HIDDEN (__fini_array_start = .); | ||
KEEP(*(SORT(.fini_array.*))) | ||
KEEP(*(.fini_array)) | ||
PROVIDE_HIDDEN (__fini_array_end = .); | ||
|
||
KEEP(*(.jcr*)) | ||
. = ALIGN(4); | ||
/* All data end */ | ||
__data_end__ = .; | ||
|
||
} > RAM | ||
|
||
.bss : | ||
{ | ||
. = ALIGN(4); | ||
__bss_start__ = .; | ||
*(.bss*) | ||
*(COMMON) | ||
. = ALIGN(4); | ||
__bss_end__ = .; | ||
} > RAM | ||
|
||
.heap (COPY): | ||
{ | ||
__HeapBase = .; | ||
__end__ = .; | ||
end = __end__; | ||
_end = __end__; | ||
KEEP(*(.heap*)) | ||
__HeapLimit = .; | ||
} > RAM | ||
|
||
/* .stack_dummy section doesn't contains any symbols. It is only | ||
* used for linker to calculate size of stack sections, and assign | ||
* values to stack symbols later */ | ||
.stack_dummy (COPY): | ||
{ | ||
KEEP(*(.stack*)) | ||
} > RAM | ||
__padding = (((__etext + SIZEOF(.text_app_data) +16 +0x800-1)&0xFFFFF800)-16) - (__etext + SIZEOF(.text_app_data)); | ||
|
||
/* Set stack top to end of RAM, and stack limit move down by | ||
* size of stack_dummy section */ | ||
__StackTop = ORIGIN(RAM) + LENGTH(RAM); | ||
__StackLimit = __StackTop - SIZEOF(.stack_dummy); | ||
PROVIDE(__stack = __StackTop); | ||
|
||
/* Check if data + heap + stack exceeds RAM limit */ | ||
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") | ||
|
||
/* Check if FLASH usage exceeds FLASH size */ | ||
/*ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")*/ | ||
|
||
/* Patch the stack */ | ||
|
||
_patch_addr = 0x63d4; | ||
.patch_stack _patch_addr : | ||
{ | ||
KEEP(*(.patch*)) | ||
}> FLASH | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
service_changed_char 3 | ||
serialnum 16 | ||
hwrev 18 | ||
fwrev 20 | ||
user_char 23 | ||
ota_trigger 26 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<project device="bgm111"> | ||
|
||
<!-- GATT service database --> | ||
<gatt in="gatt.xml" /> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<gatt prefix="GATTDB_" out="gatt_db.c" header="gatt_db.h" generic_attribute_service="true"> | ||
|
||
<!-- Generic Access Service --> | ||
<!-- https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.generic_access.xml --> | ||
<service uuid="1800"> | ||
|
||
<!-- Device Name --> | ||
<!-- https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.device_name.xml --> | ||
<characteristic uuid="2a00"> | ||
<properties read="true" const="true"/> | ||
<value>BG_APP</value><!-- TODO:: Set value or change type to "user" and add handling for it --> | ||
</characteristic> | ||
|
||
<!-- Appearance --> | ||
<!-- https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml --> | ||
<characteristic uuid="2a01"> | ||
<properties read="true" const="true"/> | ||
<value type="hex">0000</value><!-- TODO:: Set value or change type to "user" and add handling for it --> | ||
</characteristic> | ||
|
||
</service> | ||
|
||
<!-- Device Information Service --> | ||
<service uuid="180A"> | ||
<!-- Manufacturer name string --> | ||
<characteristic uuid="2A29"> | ||
<properties read="true" const="true"/> | ||
<value>Your name goes here</value> | ||
</characteristic> | ||
<!-- Model number string --> | ||
<characteristic uuid="2A24"> | ||
<properties read="true" const="true"/> | ||
<value>1</value> | ||
</characteristic> | ||
<!-- Serial number string --> | ||
<characteristic uuid="2A23" id="serialnum"> | ||
<properties read="true"/> | ||
<value length="16" const="true" variable_length="true">sernum</value> | ||
</characteristic> | ||
<!-- Hardware revision --> | ||
<characteristic uuid="2A27" id="hwrev"> | ||
<properties read="true" const="true"/> | ||
<value>1</value> | ||
</characteristic> | ||
<!-- Firmware revision --> | ||
<characteristic uuid="2A27" id="fwrev"> | ||
<properties read="true" const="true"/> | ||
<value>1.0</value> | ||
</characteristic> | ||
</service> | ||
|
||
<service uuid="fb323bd4-11b3-11e7-a4ff-38c98653bb53"> | ||
<description>User Service</description> | ||
<characteristic uuid="23401001-963F-46B1-B801-0B23E8904835" id="user_char"> | ||
<properties read="true"/> | ||
<value length="8" type="const">Value...</value> | ||
<description>User char</description> | ||
</characteristic> | ||
<characteristic uuid="773c1007-d065-45bd-890b-d960e85e0247" id="ota_trigger"> | ||
<properties type="user" write="true" write_no_response="true"/> | ||
<value type="user" length="4"/> | ||
<description>DFU Trigger</description> | ||
</characteristic> | ||
</service> | ||
|
||
|
||
</gatt> |
Oops, something went wrong.