Skip to content

Commit

Permalink
Rearranged structure to allow for different cmake projects
Browse files Browse the repository at this point in the history
  • Loading branch information
clydebarrow committed Mar 24, 2017
1 parent 5fecd66 commit 84622d3
Show file tree
Hide file tree
Showing 41 changed files with 566 additions and 245 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt → bootload/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ set(GATT_DIR ${CMAKE_SOURCE_DIR}/gatt)
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_OUTPUTS ${GATT_DIR}/${GATT_DB}.c ${GATT_DIR}/${GATT_DB}.h)
set(GATT_I ${GATT_DIR}/gatt.i)
set(GATT_OUTPUTS ${GATT_DIR}/${GATT_DB}.c ${GATT_DIR}/${GATT_DB}.h )
set(BGBUILD_CMD "/Users/clyde/dev/tools/ble/v2.1.1.0/protocol/bluetooth_2.1/bin/bgbuild")
set(EBL_CMD "/Applications/Simplicity Studio.app/Contents/Eclipse/developer/adapter_packs/commander/Commander.app/Contents/MacOS/commander")

file(GLOB_RECURSE USER_SOURCES "src/*.c")
file(GLOB_RECURSE USER_HEADERS "inc/*.h")
file(STRINGS localdefs/ota_service.txt OTA_SERVICE)

IF (CMAKE_BUILD_TYPE MATCHES Debug)
file(GLOB_RECURSE RTT_LIBS "libs/SEGGER_RTT_V612j/RTT/*.c")
Expand All @@ -40,11 +42,12 @@ set(STARTUP "src/startup.c")

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")
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 ${CMAKE_C_COMPILER} -E -C -P -C -DOTA_SERVICE_UUID=\\\"${OTA_SERVICE}\\\" - < ${GATT_XML} > ${GATT_I}
COMMAND ${BGBUILD_CMD} -gn ${GATT_SRC})
set_source_files_properties(${GATT_OUTPUTS} PROPERTIES GENERATED TRUE)

Expand Down
File renamed without changes.
File renamed without changes.
31 changes: 22 additions & 9 deletions bgbootload.ld → bootload/bgbootload.ld
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ SECTIONS
} > FLASH
__exidx_end = .;

/* here goes the dfu app ATT, vectors */
.dfu_text :
{
. = ALIGN(0x800);
__dfu_AAT = .;
KEEP(*(.AAT))
. = ALIGN(0x80);
__dfu_VectorTable = .;
KEEP(*(.dfu_vectors))
. = ALIGN(4);
} >FLASH

.gecko_table :
{
KEEP(*(.gecko_configuration))
Expand Down Expand Up @@ -104,6 +116,7 @@ SECTIONS

__etext = .;


_stack_start = 0x4000;
.text_stack_bin _stack_start :
{
Expand All @@ -113,15 +126,6 @@ SECTIONS
. = ALIGN(0x800);
}> FLASH

/* here goes the dfu app ATT, vectors */
.dfu_text :
{
KEEP(*(.AAT))
. = ALIGN(0x80);
__dfu_VectorTable = .;
KEEP(*(.dfu_vectors))
. = ALIGN(4);
} >FLASH

.text_app_data : AT (__etext)
{
Expand Down Expand Up @@ -198,4 +202,13 @@ SECTIONS

/* 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

}
File renamed without changes.
2 changes: 1 addition & 1 deletion gatt/gatt.bgproj → bootload/gatt/gatt.bgproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<project device="bgm111">

<!-- GATT service database -->
<gatt in="gatt.xml" />
<gatt in="gatt.i" />

</project>
2 changes: 1 addition & 1 deletion gatt/gatt.xml → bootload/gatt/gatt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</characteristic>
</service>

<service uuid="95301000-963F-46B1-B801-0B23E8904835">
<service uuid=OTA_SERVICE_UUID>
<description>EFR32BG OTA</description>
<characteristic uuid="95301001-963F-46B1-B801-0B23E8904835" id="ota_control">
<properties write="true"/>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions src/startup.c → bootload/src/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ static uint8_t stack[__STACK_SIZE] __attribute__ ((aligned(8), used, section(".s
static uint8_t heap[__HEAP_SIZE] __attribute__ ((aligned(8), used, section(".heap")));
#endif

extern uint32_t __dfu_AAT;
const uint32_t * __PatchAddr[] __attribute__ ((section(".patch"))) = {
&__dfu_AAT,
};



/*----------------------------------------------------------------------------
Exception / Interrupt Handler
Expand Down
226 changes: 0 additions & 226 deletions gatt/gatt_db.c

This file was deleted.

20 changes: 14 additions & 6 deletions utils/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@
#include <stdarg.h>
#include <stdlib.h>

/**
* This is the structure of the firmware file. There is a fixed size header followed by one or more block headers,
* which point to the data in the rest of the file.
* All data in the headers is little endian
*/

#define FW_TAG 0x55A322BF // magic number to identify the file

typedef struct
{
unsigned char tag[4];
unsigned char product[4];
unsigned char version[4];
unsigned char addr[4];
unsigned char size[4];
unsigned char tag[4]; // magic number goes here
unsigned char major[2]; // major version number
unsigned char minor[2]; // minor version number
unsigned char numblocks[2]; // the number of blocks in the file,
unsigned char service_uuid[16]; // the service uuid of the bootloader
unsigned char init_vector[16]; // the block 0 initialization vector
} firmware;

#define FW_TAG 0x554322BF

unsigned long base, last;
unsigned long lineno, version ,product;
Expand Down
Loading

0 comments on commit 84622d3

Please sign in to comment.