SDK BLE example project command line compilation (HeartRate device)
[Copy link]
The previous compilation process shared was the simplest blinky project for testing. This time, we will compile a BLE application that uses the BLE API.
There are 6 C source files in this project, which can be compiled one by one. In addition to the header files in the SDK include directory, the header files used also include the files in its three subdirectories: bb (wireless baseband), ble (low-power Bluetooth), and kernel (system kernel).
In addition to compiling and linking several startup and hardware device related modules like the blinky project, the BLE part also requires the C source files and header files under the SDK source\firmware\ble_abstraction_layer. It is not difficult to find clues in the ble_peripheral_server_hrp.rteconfig project configuration file.
But it does not mean that all the codes are in these C source files. Because the RSL10 BLE protocol stack is not open source, in fact, most of the BLE APIs of the SDK are provided in the form of binary libraries. There are several .a binary library files under the lib directory of the SDK.
lib
├─ble_core
│ ├─Release
│ │ libblelib.a
│ │ libkelib.a
│ │ libweak_prf.a
│ │
│ ├─Release_HCI
│ │ libblelib.a
│ │ libkelib.a
│ │ libweak_prf.a
│ │
│ └─Release_Light
│ libblelib.a
│ libkelib.a
│ libweak_prf.a
│
├─ble_profiles
│ ├─Release
│ │ libanpc.a
│ │ libanps.a
│ │ libbasc.a
│ │ libbass.a
│ │ libblpc.a
│ │ libblps.a
│ │ libcgmc.a
│ │ ......
│ │
│ └─Release_HCI
│ libanpc.a
│ libanps.a
│ libbasc.a
│ libbass.a
│ libblpc.a
│ libblps.a
│ ......
│
└─Release
fota.bin
libfota.a
These library files have the same name, that is, there are different versions of the same library. I don't know what the difference is.
When linking, use the -l parameter to specify the library to be used (without the suffix or the first three letters of lib), and use the -L parameter to specify the path of the library file. I first tried to add the three library files under lib/ble_core/Release ( -lblelib -lkelib -lweak_prf ), and the link was successful, and an ELF file was obtained.
However, after I burned the image file into RSL10, I couldn't scan the device when I ran it. According to the instructions, the LED should light up when the device is broadcasting, but it didn't. What went wrong?
I checked the memory address of the exported image file, and there was no error in the corresponding ELF file. The link process did not report any missing symbols.
Finally, I checked the files in the SDK involved in the IDE project file and found that the library file usage was different:
<component Capiversion="1.0.0" Cclass="Device" Cgroup="Bluetooth Core" Csub="BLE Stack" Cvariant="release" Cvendor="ONSemiconductor" Cversion="3.5.285" deviceDependent="1">
<package name="RSL10" url="www.onsemi.com" vendor="ONSemiconductor" version="3.5.285"/>
<file category="doc" deviceDependent="1" name="documentation/RSL10_firmware_reference.pdf"/>
<file category="library" deviceDependent="1" name="lib/ble_core/Release/libblelib.a"/>
</component>
<component Capiversion="1.0.0" Cclass="Device" Cgroup="Bluetooth Core" Csub="Kernel" Cvariant="release" Cvendor="ONSemiconductor" Cversion="3.5.285" deviceDependent="1">
<package name="RSL10" url="www.onsemi.com" vendor="ONSemiconductor" version="3.5.285"/>
<file category="doc" deviceDependent="1" name="documentation/RSL10_firmware_reference.pdf"/>
<file category="library" deviceDependent="1" name="lib/ble_core/Release/libkelib.a"/>
</component>
<component Cclass="Device" Cgroup="Bluetooth Profiles" Csub="BASS" Cvariant="release" Cvendor="ONSemiconductor" Cversion="3.5.285" deviceDependent="1">
<package name="RSL10" url="www.onsemi.com" vendor="ONSemiconductor" version="3.5.285"/>
<file category="doc" deviceDependent="1" name="documentation/ceva/RW-BLE-PRF-BAS-IS.pdf"/>
<file category="header" deviceDependent="1" name="include/ble/profiles/bass.h"/>
<file category="library" deviceDependent="1" name="lib/ble_profiles/Release/libbass.a"/>
</component>
<component Cclass="Device" Cgroup="Bluetooth Profiles" Csub="DISS" Cvariant="release" Cvendor="ONSemiconductor" Cversion="3.5.285" deviceDependent="1">
<package name="RSL10" url="www.onsemi.com" vendor="ONSemiconductor" version="3.5.285"/>
<file category="doc" deviceDependent="1" name="documentation/ceva/RW-BLE-PRF-DIS-IS.pdf"/>
<file category="header" deviceDependent="1" name="include/ble/profiles/diss.h"/>
<file category="library" deviceDependent="1" name="lib/ble_profiles/Release/libdiss.a"/>
</component>
<component Cclass="Device" Cgroup="Bluetooth Profiles" Csub="HRPS" Cvariant="release" Cvendor="ONSemiconductor" Cversion="3.5.285" deviceDependent="1">
<package name="RSL10" url="www.onsemi.com" vendor="ONSemiconductor" version="3.5.285"/>
<file category="doc" deviceDependent="1" name="documentation/ceva/RW-BLE-PRF-HRP-IS.pdf"/>
<file category="header" deviceDependent="1" name="include/ble/profiles/hrps.h"/>
<file category="library" deviceDependent="1" name="lib/ble_profiles/Release/libhrps.a"/>
</component>
That is, the example project did not use libweak_prf.a, but used three more libraries, libbass.a, libdiss.a, and libhrps.a. I didn't know the functions of these libraries, so I tried to change them. As a result, it worked.
The Makefile defines the following:
default: app.elf
INC = -Iinc -Iinc/kernel -Iinc/bb -Iinc/ble -Iinc/ble/profiles
APP_OBJ = app.o app_bass.o app_config.o app_hrps.o app_msg_handler.o app_trace.o
APP_OPTS = -DRSL10_CID=101 \
-DCFG_PRF_DISS=1 \
-DCFG_PRF_HRPS=1 \
-DSECURE_CONNECTION \
-DAPP_BONDLIST_SIZE=28 \
-DCFG_BOND_LIST_IN_NVR2=true \
-DCFG_BLE=1 \
-DCFG_ALLROLES=1 \
-DCFG_APP \
-DCFG_APP_BATT \
-DCFG_ATTS=1 \
-DCFG_CON=8 \
-DCFG_EMB=1 \
-DCFG_HOST=1 \
-DCFG_RF_ATLAS=1 \
-DCFG_ALLPRF=1 \
-DCFG_PRF=1 \
-DCFG_NB_PRF=8 \
-DCFG_CHNL_ASSESS=1 \
-DCFG_SEC_CON=1 \
-DCFG_EXT_DB \
-DCFG_PRF_BASS=1
SYSOBJ = rsl10_romvect.o \
rsl10_sys_asrc.o \
rsl10_sys_audio.o \
rsl10_sys_clocks.o \
rsl10_sys_crc.o \
rsl10_sys_dma.o \
rsl10_sys_flash.o \
rsl10_sys_power.o \
rsl10_sys_power_modes.o \
rsl10_sys_rffe.o \
rsl10_sys_timers.o \
rsl10_sys_uart.o \
rsl10_sys_version.o \
rsl10_protocol.o \
sbrk.o \
start.o \
system_rsl10.o \
startup_rsl10.o
BLEOBJ = ble_gap.o \
ble_gatt.o \
ble_l2c.o \
msg_handler.o \
ble_bass.o \
ble_diss.o \
ble_hrps.o \
stubprf.o
CFLAGS = -std=gnu99 -mcpu=cortex-m3 -mthumb -O2 $(APP_OPTS) -ffunction-sections -fdata-sections
LDFLAGS = -Llib -lblelib -lkelib -lbass -ldiss -lhrps -Tsections.ld -nostartfiles -Wl,--gc-sections
%.o : %.c
arm-none-eabi-gcc -c -I. -Ible $(INC) $(CFLAGS) $<
%.o : ble/%.c
arm-none-eabi-gcc -c -I. -Ible $(INC) $(CFLAGS) $<
%.o : sys/%.c
arm-none-eabi-gcc -c $(INC) $(CFLAGS) $<
%.o : sys/%.S
arm-none-eabi-gcc -c $(CFLAGS) $<
app.elf : $(APP_OBJ) $(SYSOBJ) $(BLEOBJ)
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb $^ $(LDFLAGS) -o $@
Compiled result: the code occupies more than 128kB. The statically allocated RAM is slightly more than 16kB.
app.elf: file format elf32-littlearm
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00024720 00100000 00100000 00010000 2**3
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .ARM.exidx.reset 00000008 00124720 00124720 00034 720 2**2
CONTENTS, ALLOC, LOAD , READONLY, DATA
2 .systemclock 00000004 20000000 20000000 00050000 2**2
ALLOC
3 .data 000008cc 20000008 00124728 00040008 2**3
CONTENTS, ALLOC, LOAD, DATA
4 .bss 000039cc 200008d4 00124ff4 000408d4 2**2
ALLOC
5 .noinit 00000000 200042a0 200042a0 000408d4 2**0
CONTENTS
6 ._stack 00000 400 200042a0 001289c0 000408d4 2**0
ALLOC
|