GCC example, BLE SDK 2.0 (test only)

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Legend Employee</font></font> </a> JaakkoV ‎09-27-2016 04:00 AM - edited ‎03-13-2017 03:09 AM

NOTE: this article is obsolete. Bluetooth SDK 2.3.0 (released March 2017) includes beta support for GCC toolchain.

 

 

Introduction

 

This is a simple BLE example that can be built with GCC. It is intended only for testing. This is not for production use.

 

GCC is not fully supported yet and there are some features (like OTA) that do not work with GCC. Any feedback is appreciated, you can either

1) comment directly to this article (Preferred method)

2) create a new thread on our forum or

3) create a private support ticket at http://www.silabs.com/support/Pages/default.aspx

 

Options 2) and 3): remember to mention that you are using GCC to build.

 

Prerequisites

 

To run this example you will need to have Simplicity Studio v4 and BLE SDK 2.0 installed. For instructions, see this article:

http://community.silabs.com/t5/Bluetooth-Wi-Fi-Knowledge-Base/How-to-install-BLE-SDK-2-0-0/ta-p/1788...

 

This example has been tested with MinGW and Cygwin. 

 

Example content

 

The example is a minimal BLE peripheral that turns on advertising at boot. It uses a soft timer to blink the development board LEDs in an alternating pattern. You can use this as a template for your own experiments.

 

The project is split into three directories:

src - source files. Whole application is in main.c.

bgbuild - the GATT database is defined here. Edit gatt.xml to customize the GATT for your own project.

gcc - for building with GCC. You can find the Makefile here.

 

Building the example with MinGW

 

To build the example with MinGW:

 

  1. Extract the attached GCC.zip to
    C:\SiliconLabs\SimplicityStudio\v4\developer\stacks\ble\v2.0.0.0\app\bluetooth_2.0
  2. open MinGW terminal

  3. cd to
    C:\SiliconLabs\SimplicityStudio\v4\developer\stacks\ble\v2.0.0.0\app\bluetooth_2.0\GCC\Example\gcc

4) run 'mingw32-make' to build project

5) run 'mingw32-make load' to build and load binary to target

 

Below is a screenshot showing successful build and flashing from MinGW terminal.

 

mingw_gcc.png

 

To build with Cygwin, run "make" instead of "mingw32-make". NOTE: when building with Cygwin you need to run make twice the first time you build the project.

 

 

 

 

 

Comments
by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Genius</font></font> </a> miceuz1
on ‎09-27-2016 02:59 PM
I have tested this on Linux Mint 17.3 and it works fine! Then I have tried configuring the empty_ble example to compile from Simplicity IDE. I had to add include directories containing missing .h files (C/C++ General > Paths and Symbols > Includes > GNU C): stacks/ble/v2.0.0.0/platform/emlib/inc stacks/ble/v2.0.0.0/platform/Devices/SiliconLabs/EFR32BG1B/Include stacks/ble/v2.0.0.0/platform/CMSIS/Include I had to add Symbols (C/C++ General > Paths and Symbols > Symbols > GNU C): _NO_SYSTEM_INIT ERF32BG1B232F256GM48 I had to add Other objects to Linker (C/C++ Build > Settings > GNU ARM C Linker > Miscelaneous) /home/miceuz/Downloads/SimplicityStudio_v4/developer/stacks/ble/v2.0.0.0/protocol/bluetooth_2.0/lib/binbootloader.o /home/miceuz/Downloads/SimplicityStudio_v4/developer/stacks/ble/v2.0.0.0/protocol/bluetooth_2.0/lib/binstack.o /home/miceuz/Downloads/SimplicityStudio_v4/developer/stacks/ble/v2.0.0.0/protocol/bluetooth_2.0/lib/stack.a /home/miceuz/Downloads/SimplicityStudio_v4/developer/stacks/ble/v2.0.0.0/platform/Device/SiliconLabs/EFR32BG1B/Source/GCC/startup_efr32bg1b.S I had to deselect No startup or default libs (-nostdlib) checkbox in C/C++ Build > Settings > GNU ARM C Linker > General so that linker stopped complaining about missing _start symbol. Then I just had to provide an empty main() function and the build was successful. I'm still not sure if this produces a runnable code, some compiler and linker settings might be suboptimal. Will try to build a more real example tomorrow.
by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Genius</font></font> </a> miceuz1
on ‎09-28-2016 05:34 AM
I have tried building Thermometer SOC example today. It build successfully, but does not work on the real hardware. I'm using BGM111M256KV1.1 module with wireless starter kit. I'm assuming there is EFR32BG1B232F256GM48 processor in this module and use ld and startup files from stacks/ble/v2.0.0.0/platform/Device/SiliconLabs/EFR32BG1B/Source/GCC. The code crashes with Usage Fault caused by attempting to access a coprocessor at 0x0000A484 instruction vldmia in function gecko_init from stack.a. My linker command is: arm-none-eabi-gcc -D__NO_SYSTEM_INIT --specs=nosys.specs -g3 -gdwarf-2 -mcpu=cortex-m4 -mthumb -T "/home/miceuz/Downloads/SimplicityStudio_v4/developer/stacks/ble/v2.0.0.0/platform/Device/SiliconLabs/EFR32BG1B/Source/GCC/efr32bg1b.ld" -L"/home/miceuz/Downloads/SimplicityStudio_v4/developer/stacks/ble/v2.0.0.0//protocol/bluetooth_2.0/lib/" -Xlinker --gc-sections -Xlinker -Map="soc-thermometer_2.map" -o soc-thermometer_2.axf -l:binbootloader.o -l:binstack.o -l:stack.a "./src/InitDevice.o" "./gatt_db.o" "./main.o" "./kit/BRD4300ArevA02/bsp_bcc.o" "./kit/BRD4300ArevA02/bsp_stk.o" "./kit/BRD4300ArevA02/bsp_stk_leds.o" "./kit/BRD4300ArevA02/i2cspm.o" "./kit/BRD4300ArevA02/si7013.o" "./kit/BRD4300ArevA02/tempsens.o" "./kit/BRD4300ArevA02/udelay.o" "./emlib/em_gpio.o" "./emlib/em_i2c.o" "./emlib/em_rtcc.o" "./emlib/em_usart.o" ""/home/miceuz/Downloads/SimplicityStudio_v4/developer/stacks/ble/v2.0.0.0//platform/Device/SiliconLabs/EFR32BG1B/Source/GCC/startup_efr32bg1b.S"" -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group Any help would be highly apreciated.
by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Genius</font></font> </a> miceuz1
on ‎09-28-2016 06:04 AM
if I add -march=armv7e-m I also get a usage exception that is hard to catch and debug - if I run the code, I get Usage Fault: invalid combination of EPSR and instruction, if I step thru the code I get the same "attempting to access a coprocessor" Usage Fault on instruction blx at 0x00008dc4
by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Genius</font></font> </a> miceuz1
on ‎09-28-2016 06:33 AM
When I use your ld script and startup file and -march=armv7e-m, I get Bus Fault: imprecise data bus error. Your linker files are named efr32mg1 - which supposes use of Mighty Gecko processor. As far as I can see, BG1 anf MG1 linker files are the same in the sdk, but different from yours. Could you please provide linker script and startup file for EFR32BG1?
by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Genius</font></font> </a> miceuz1
on ‎09-28-2016 10:15 AM
Finally I was able to make the Thermometer SOC example to compile on Linux and work on BGM111 module! The last thing to do was to remove all OTA references: in gecko config in main.c and OTA service in gatt_db.bgproj.
by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Super Star</font></font> </a> stevecasey
on ‎10-01-2016 04:18 AM

The basic GCC example worked well on Windows 7 x64. The following links may be helpful for installing Cygwin and GCC.

 

http://preshing.com/20141108/how-to-install-the-latest-gcc-on-windows/

 

NOTE: Did not need to perform step 3 (Download, Build and Install the Latest GCC)

 

 

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Master Employee</font></font> </a> tmonte
on ‎10-04-2016 06:56 AM

For everyone's information: this also works on MAC OS.

 

Just extract the zip to /Applications/Simplicity Studio.app/Contents/Eclipse/developer/stacks/ble/v2.0.0.0/app/bluetooth_2.0, then open the terminal and navigate to /Applications/Simplicity Studio.app/Contents/Eclipse/developer/stacks/ble/v2.0.0.0/app/bluetooth_2.0/GCC/Example/gcc and run 'make' twice. The second run will generate a *.bin file which you can load using SS Flash Programmer.

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Star</font></font> </a> fraveydank
on ‎10-04-2016 02:40 PM

I got it to build and MOSTLY run on the EFR32 Blue Gecko starter kit (SLWSTK6020A), which has a EFR32BG1P instead of an EFR32BG1B.  Distressingly, there are two serious problems:

 

- stack.a in the BLE stack lib directory is not a static library (per the name), but an object file.  It took me a while to figure out why I could look at it with nm and objdump, but not ar.

- There are several device-specific object files linked in which I had to remove with objcopy; I stripped EMU*, CMU*, INT* and System* and added the device-appropriate emlib files to my project to replace them.  Without this step, the init routines would bug out because the struct sizes for the EFR32BG1B appear to be larger, and they live at the top of the stack, so it immediately tried to access out-of-bounds memory.

 

So I have something that compiles and runs.  Unfortunately, something seems wrong with the stack; the gecko_evt_system_boot_id message never seems to get received after init.  It seems like something is wrong with the gecko_wait_event() function, because the assembly it steps into is garbage for what it should be doing:

000071dc: strb r1,[r0,#0x1c]
000071de: movs r1,#0x0
000071e0: str r1,[r0]
000071e2: bx lr

 

I'll keep hacking on it.  It's progress, anyway!

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Star</font></font> </a> fraveydank
on ‎10-04-2016 02:46 PM

Oh, I see.  stack.a is just a pile of addresses that point to absolute locations in binstack.o and the like, and I wasn't using the included linker script which kept binstack and binbootloader in the correct locations.  What a mess.  This isn't a great way to provide a library, for what it's worth.  I know you want to strip the symbol names, but must be better ways of doing that.

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Star</font></font> </a> fraveydank
on ‎10-04-2016 03:03 PM

Well, I get an executable that's much closer to the right size when I add the binstack and binbootloader sections into the linker script appropriate for my part.  However, I get the feeling that the bootloader may not be 100% compatible with my part, since it never seems to make it to main().  I haven't bothered stepping through to see where it's getting hung up, though it doesn't appear to be getting stuck on a HardFault or anything of the like.  Is there a reason the bootloader is necessary?  I rather like to see how my chip is getting initialized.

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Super Star</font></font> </a> mcbain
on ‎10-06-2016 07:31 AM

Thanks a lot for the GCC sample. I work as well with the Bluetooth Developer Studio, where can I find documentation of the native_gecko.h? E.g. to customize the content of the advertising packet?

 

Thanks.

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Legend Employee</font></font> </a> JaakkoV
on ‎10-06-2016 08:12 AM

If you want to modify the example (especially the BLE part), then the best document to start with is probably the BGAPI reference manual. It can be found under BLE SDK installation directory, see:

C:\SiliconLabs\SimplicityStudio\v4\developer\stacks\ble\v2.0.0.0\app\bluetooth_2.0\doc

-> BluetoothSmart_APIRefMan.pdf

 

To customize advertising packet content, see following functions:

cmd_le_gap_set_adv_data,

cmd_le_gap_set_mode

 

In a nutshell: use the first function to set the advertising data (following the format specified in BT spec) and then start advertising with cmd_le_gap_set_mode(4,2)

 

The first argument 4 (le_gap_user_data) tells the stack to use your own data instead of automatically generating the content based on what is in the GATT.

 

 

 

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Super Star</font></font> </a> mcbain
on ‎10-06-2016 08:28 AM

Thanks for the fast reply. I would like to have:

 

1. device name (3 bytes)

2. services (3 16bit-UUIDs == 6 bytes)

 

in the ADV packet. Actually I have generated with the BGTool the files gatt_db.c/h. These files are already included in the main.c, but the ADV packet still only contains the device name. I am not sure if I got the workflow with the BGTool and the gatt_db right... Thank you very much for the help.

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Ninja</font></font> </a> ablumenk
on ‎10-06-2016 07:03 PM

Thank you very much Jaakko, Tiago.

 

Got the example to work on my mac without issues, also adding a service and characteristic.

 

Side note, my Mac is from 2015 can comes with pre-installed GNU Make 3.81 (from 2006 !) and still worked fine, at least for this example. Which make version do you use for your tests ? Latest ?

 

Question: until we have this all moved and integrated w/ Simplicity Studio, any suggestion how to do debugging if I want to keep working with this setup? Made a first attemp integrating SWO Terminal with no success, any idea here?

 

Thank you!

 

Alex

 

 

 

 

 

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Super Star</font></font> </a> mcbain
on ‎10-10-2016 11:44 AM

Do you have an estimation when the GCC support is "production-ready"? Thanks!

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Super Star</font></font> </a> mcbain
on ‎10-11-2016 01:30 PM

Did anyone get characteristic notifications to work? I tried with the default "Health Thermometer" service, but no success. Thanks for help!

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Star</font></font> </a> fraveydank
on ‎10-12-2016 03:36 PM

Ah, I found my mistake after stepping through the bootloader one instruction at a time and then reading its source.

 

Looks like the problem was that my merged linker script (merged between my project's linker script and the one included with the GCC example) had failed to include the .AAT section, which meant that the bootloader couldn't find the application address table, which it needs to boot the app.  Once I included that (and made sure that my main.c also had a #include "aat.h"), everything worked fine and I'm able to at least send simple iBeacons.  Moving forward!

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Star</font></font> </a> fraveydank
on ‎10-20-2016 10:53 AM

So with the extremely large chunks of opaque, arbitrary memory taken up by the BT stack/heap above and beyond the heap that is already passed in through gecko_init(), there's a lot less memory available.  For example, with the old stack, I was able to allocate 12K to my FreeRTOS heap without trouble; now I can barely get 4K.

 

Here's what seems to be taken up by the new stack as far as RAM goes:

 

- 0x3400 bytes (13K) taken up in the linker script by the RAM region definition (the custom linker script declares the range as starting at 0x20003000 and being 0x4C00 - 4 bytes long)

- 0xb00 bytes (2.75K) taken up by the .heap section (how is this different from the heap passed in at init time and the region already reserved in the linker, and why isn't it passed in at init time?)

- 0x1400 bytes taken up by the .stack section (how is this different from the 0x400 of top memory already reserved at link time?)

 

I've experimented with different variations of allocating and not allocating these things, and sometimes they crash, but it's not easy to tell whether I'm doing something Very Bad or not, because there's no visibility into how this memory is getting used.  This all seems like rather a lot of RAM, especially considering that it only leaves about 4K of a 32K part free, and the previous stack left at least 8K more.

 

Is there any way I can reliably shrink the RAM consumption of the stack?  4K isn't a lot for our application.

 

By the way, the new stack still claims the PendSV interrupt, which is not documented behavior.  I've made it coexist with FreeRTOS by writing a shim routine to determine who "owns" PendSV and execute the correct handler (the performance hit is fairly minor).  If anyone is interested, I'll be glad to share (we plan to contribute it back to FreeRTOS when it's a little more settled).

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Star</font></font> </a> fraveydank
on ‎10-20-2016 10:55 AM

Further: are there plans for a non-autonomous version of the stack (i.e. one that is more amenable to being run within an RTOS that exposes the polling routine instead of executing it itself)?  That would be very helpful for larger projects where things like threading are required.

by aut432
on ‎10-28-2016 03:49 PM

I got the following error Using Mingw . Please let me know.

 

C:\SiliconLabs\SimplicityStudio\v4\developer\stacks\ble\v2.0.1.0\app\bluetooth_2
.0\GCC\Example\gcc>mingw32-make
../../../../../protocol/bluetooth_2.0/bin/bgbuild -gn -c ../../../../../../../..
/toolchains/gnu_arm/4.9_2015q3 ../bgbuild/gatt.bgproj
Directory ../../../../../../../../toolchains/gnu_arm/4.9_2015q3/bin/ does not ex
ist. Trying to use compilers from system PATH.
ALL OK
../../../../../../../../toolchains/gnu_arm/4.9_2015q3/bin/arm-none-eabi-gcc -c -
mcpu=cortex-m4 -march=armv7e-m -mthumb -fno-short-enums -D__NO_SYSTEM_INIT -DEFR
32BG1B232F256GM48 -Os -I../../../../../protocol/bluetooth_2.0/ble_stack/inc/ -I
../../../../../protocol/bluetooth_2.0/ble_stack/inc/common/ -I../../../../../pro
tocol/bluetooth_2.0/ble_stack/inc/soc/ -I../../../../../platform/emlib/inc/ -I..
/../../../../platform/emlib/src/ -I../../../../../platform/Device/SiliconLabs/EF
R32BG1B/Include/ -I../../../../../platform/CMSIS/Include/ -I../bgbuild/ ../src/m
ain.c -o main.o
process_begin: CreateProcess(NULL, ../../../../../../../../toolchains/gnu_arm/4.
9_2015q3/bin/arm-none-eabi-gcc -c -mcpu=cortex-m4 -march=armv7e-m -mthumb -fno-s
hort-enums -D__NO_SYSTEM_INIT -DEFR32BG1B232F256GM48 -Os -I../../../../../protoc
ol/bluetooth_2.0/ble_stack/inc/ -I../../../../../protocol/bluetooth_2.0/ble_stac
k/inc/common/ -I../../../../../protocol/bluetooth_2.0/ble_stack/inc/soc/ -I../..
/../../../platform/emlib/inc/ -I../../../../../platform/emlib/src/ -I../../../..
/../platform/Device/SiliconLabs/EFR32BG1B/Include/ -I../../../../../platform/CMS
IS/Include/ -I../bgbuild/ ../src/main.c -o main.o, ...) failed.
make (e=2): The system cannot find the file specified.
Makefile:33: recipe for target 'main.o' failed
mingw32-make: *** [main.o] Error 2

 

Thanks,

Amit

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero</font></font> </a> superpanda
on ‎11-09-2016 08:18 AM

Would anyone care to share a working SimplicityStudio sample project? While I can compile and flash to example project with the provided makefile, I am having a hard time getting the IDE setup properly to make this work. I have read carefull through all the comments and something is just not working. 

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Master Employee</font></font> </a> tmonte
on ‎11-09-2016 09:18 PM

Hi @superpanda, for now it's really just using makefile, once GCC is fully supported then it will have studio support as well. There might be some way to hack-in studio support but we're not actively looking into that until GCC support is official.

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Genius</font></font> </a> miceuz1
on ‎11-10-2016 01:33 AM
Hi @superpanda it is definately possible and does not require a lot of hacking. Me and at least one more person did that with my help. You have to read the compiler/linker messages really carefully and go forward - it's just a matter of properly configuring your environment. I could prepare a thermometer package, but don't have time to do that now, but might in the end of the next week.
by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero</font></font> </a> superpanda
on ‎11-10-2016 05:50 AM
Thanks. I made a quite a ways but the compiler is not giving me enough feedback to sort it out. Did you use MinGW?
by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Genius</font></font> </a> miceuz1
on ‎11-10-2016 05:56 AM

I'm under Linux and use GCC natively.

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Star</font></font> </a> fraveydank
on ‎11-10-2016 08:43 AM

I'll verify that it also works under OS X quite well, and I think Windows (I did some initial tests, but not more than that).  There's a bit of tinkering to be done, especially after you "generate" from the hardware configurator (which you need to do, but it litters the project with some bad links and a new build target for IAR, which you won't have if you're not on Windows).

 

I'll see if I have a minimum working example somewhere.  The key, really, is to do the following:

 

1) Make sure you use the linker script provided with the GCC example (or, if you know your way around a linker script, one carefully derived from it).  This is essential because it links the binary stack and bootloader blobs into the right place ("stack.a" is actually an object file with no code, just symbols for stack entry points that point to absolute locations in memory, so for now it's essential that the bootloader and stack are at the exact right locations in flash), and it has the entry for the application attribute table (the .AAT section), without which the bootloader won't find your application.

 

2) Manually add in the emlib C files you need from your appropriate platform directory.  You'll have to manually exclude some of them, because the stack already includes them built in (kinda sloppy, IMO, but oh well).  Specifically, you need to exclude em_cmu.c, em_emu.c, em_int.c, and em_system.c.  Fortunately, their symbols are included in stack.a, so you can still use the functionality.

 

3) Make sure you also use the startup files (or something derived from them) included with the GCC example.  They contain some linker sections used as dummies to check the stack (I edited mine to remove the heap section because it was redundant; the BLE heap is supplied at init time).  You may be able to trim the size of the stack section down as well; I've trimmed it down to 0x0c00 (from 0x1400) with no ill effect, but we're watching closely to make sure we don't have a stack/heap collision.

 

4) Manually add the proper include paths for emlib, emdrv for your platform, BLE stack and BSP for your platform (detailed above).

 

Where possible, use relative paths with the ${StudioSdkPath} variable so that your builds will work on other machines; absolute paths make for nightmares.  Also make sure you quote it, in case your build machine has a path with spaces in it.  For example, "${StudioSdkPath}platform/emlib/inc".

 

What's the best way to post a minimum working example?

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero</font></font> </a> superpanda
on ‎11-10-2016 01:21 PM

Thanks, I don't see a private messaging feature on this forum. Perhaps a dropbox link would work.

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero</font></font> </a> superpanda
on ‎11-10-2016 02:41 PM

Is the PCNT functionality not supported with GCC yet?

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Star</font></font> </a> Heleen
on ‎12-07-2016 02:42 AM

Is there an update when the GCC will be officially released as part of Simplicity Studio?

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Genius</font></font> </a> zvanstefan
on ‎12-12-2016 05:43 AM

Like

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Ninja</font></font> </a> gerlad0
on ‎12-16-2016 07:07 PM

What modifications do I need to get this sample to run on a SLWSTK6101A (with EFR32BG1B232F256M48) ?
These two files appear to be for Mighty Gecko: efr32mg1p.ld and startup_efr32mg1p.S - do they work with Blue Gecko?
P.S.  Is there any way to attach files to a "Comment" ??

Thanks

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Star</font></font> </a> ks
on ‎12-18-2016 06:02 AM

After several days of trying to figure out why I keep getting "No Toolchains Found" from Simplicity Studio, I eventually figured out that BGScript or GCC support doesnt exist from the studio. I managed to get BGScript working from the command line (on MAC) and then hit major stumbling blocks with the scripting language (speed and limitations). So I am trying to use GCC now with the example here, (have the sample working correctly with my BLE 2.1.0 stack), but the thermometer example may save a lot of time to then customise to where I am with the BGScript version.

 

<!-- my custom service -->
<service uuid="ebc5edb0-f1c4-45bf-b5eb-bede92a48de7" advertise="true" >
<description>Custom Service</description>
<characteristic uuid="67b31884-0e4e-4217-b03b-788f7bcf0f93" id="customwrite">
<properties write="true" />
<value length="4" type="user" />
</characteristic>
<characteristic uuid="66a99dcf-d94d-47bf-b505-95716d85cbe0" id="customread">
<properties read="true" />
<value length="4" type="user" />
</characteristic>
</service>
by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero</font></font> </a> superpanda
on ‎12-22-2016 02:25 PM

Can the FPU in the BGM111 be enabled in GCC?

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero</font></font> </a> superpanda
on ‎12-24-2016 04:45 AM

Ahh, So close to making this work in studio...

 

I can compile and run outside of studio just fine. I can now (finally) compile in studio. Unfortunately the bin file is 1/3 the size and will not run on the chip so something is amis, but I have no feedack to clue me into the issue. I am using same code, linker and startup script for both. I followed all the comments very closely above to work through the compile issues so I am pretty sure I have Studio setup properly. Any thoughts?

 

Invoking: GNU ARM C Linker
arm-none-eabi-gcc -g -gdwarf-2 -mcpu=cortex-m4 -mthumb -T "C:/Users/Andrew/SimplicityStudio/v4_workspace/c40mkII/linker/efr32mg1p.ld" -Xlinker --gc-sections -Xlinker -Map="c40mkII.map" -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -lm -lgcc -lc -o c40mkII.axf "./bgbuild/gatt_db.o" "./linker/startup_efr32mg1p.o" "./src/CY15B104Q.o" "./src/InitDevice.o" "./src/LIS3DSH.o" "./src/RV8803.o" "./src/SI705X.o" "./src/TLH2450.o" "./src/app.o" "./src/app_battery.o" "./src/app_ble.o" "./src/app_ble_adv.o" "./src/app_displacement.o" "./src/app_interrupt.o" "./src/app_memory.o" "./src/app_rtc.o" "./src/app_speed.o" "./src/app_temperature.o" "./src/atc2000.o" "./src/connection.o" "./src/debug.o" "./src/dmactrl.o" "./src/em_adc.o" "./src/em_dma.o" "./src/em_gpio.o" "./src/em_i2c.o" "./src/em_letimer.o" "./src/em_pcnt.o" "./src/em_rtcc.o" "./src/em_timer.o" "./src/em_usart.o" "./src/i2cspm.o" "./src/main.o" "./src/retargetio.o" "./src/tempdrv.o" "./src/udelay.o" ""C:/SiliconLabs/SimplicityStudio/v4/developer/stacks/ble/v2.1.0.0//protocol/bluetooth_2.1/lib/stack.a"" ""C:/SiliconLabs/SimplicityStudio/v4/developer/stacks/ble/v2.1.0.0//protocol/bluetooth_2.1/lib/binstack.o"" ""C:/SiliconLabs/SimplicityStudio/v4/developer/stacks/ble/v2.1.0.0//protocol/bluetooth_2.1/lib/binbootloader.o"" -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
Finished building target: c40mkII.axf
by RossiRPI
on ‎12-24-2016 10:05 PM

Hi guys, can someone please share a working Simplicity studio project? Would be greatly apreciated!

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero</font></font> </a> superpanda
on ‎12-27-2016 01:01 AM

I have a working project now. You are welcome to have a look if it's helpful. 

 

https://www.dropbox.com/s/yk9lneya4c42pqy/c40mk4.zip?dl=0

 

The sum of comments above are pretty accurate. My issues were mostly related to the IDE. For example, the default "bgBuild" builder was not working. The bgBuild toolchain could not be included. The IDE was not very forthcoming about the issue so it took a while to find. I had to make my own builder to generate the GATT db etc. 

 

Still trying to sort out some math library issues. I added "GROUP(-lc -lm)" to the linker file which worked outside of studio, but I get undefined resources inside studio. 

 

Also, when compiling against the latest SDK I found issues. GPIO interrrupts will not fire with SDK 2.1.0.0. Anyone else see this? 

 

 

 

 

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Ninja</font></font> </a> gerlad0
on ‎12-30-2016 06:59 PM

Hello @superpanda   - a few questions if I may
#1 - Which hardware platform are you using?
#2 - Appears to have a Mighty Gecko (your Linker file indicates such) ?
#3 - What do you mean by compiling under Studio - ARM Compiler from IAR EW ??

 

Thanks

by jcf
on ‎01-18-2017 12:17 PM

I am working on getting a GCC project up and working.

 

I have had pretty good luck but I'm having some trouble with getting the timer PWM settings fully working.

 

If I set TOP much lower than 1700 the PWM output looks fine but chip quits responding via bluetooth.

 

At 38.4MHz, according the to the formual TOP should equal 1200 for 16kHz output.

 

At first I thought the problem was the bluetooth firmware trying to use TIMER0 but I changed to TIMER1 and get the same result.

 

I also thought maybe I was using too much CPU time but even if my ISR takes 100clock cycles that is still only a little over 4% usage.

 

If I can solve this and one other software problem I think this module will be a good fit for the project I'm working on.

 

uint16_t set = 0;
uint16_t iterator = 0;
uint16_t toPlay = 0;
opus_int32 len_or_error = 0;

uint16_t next(uint16_t val)
{
    if(val == (INPUT_BUF_SIZE-1))
        val=0;
    else
        val++;
    return val;
}

void play(uint16_t * data, uint16_t size)
{
	uint16_t i;
    for(i = 0; i < size; i++ ) //
    {
        buff[(set = next(set))] = data[i];
        toPlay++;
    }
	timer1_Start();
}

void timer1_Init() {
CMU_ClockEnable(cmuClock_TIMER1, true);
TIMER1->CTRL = _TIMER_CTRL_RESETVALUE;
TIMER1->CTRL |= TIMER_CTRL_PRESC_DIV1;
TIMER1->CTRL |= TIMER_CTRL_CLKSEL_PRESCHFPERCLK;
TIMER1->CTRL |= TIMER_CTRL_MODE_UPDOWN;

// route CC0 to location 28 ( PF4 ) and CC1 to it's location 28 ( PF5 )
TIMER1->ROUTELOC0 |= TIMER_ROUTELOC0_CC0LOC_LOC28 | TIMER_ROUTELOC0_CC1LOC_LOC28;
TIMER1->ROUTEPEN |= TIMER_ROUTEPEN_CC0PEN | TIMER_ROUTEPEN_CC1PEN;

TIMER1->CC[0].CTRL = TIMER_CC_CTRL_MODE_PWM;
TIMER1->CC[0].CTRL |= TIMER_CC_CTRL_CMOA_TOGGLE;
TIMER1->CC[0].CTRL |= TIMER_CC_CTRL_ICEDGE_BOTH;
TIMER1->CC[1].CTRL = TIMER_CC_CTRL_MODE_PWM;
TIMER1->CC[1].CTRL |= TIMER_CC_CTRL_CMOA_TOGGLE;
TIMER1->CC[1].CTRL |= TIMER_CC_CTRL_ICEDGE_BOTH;
TIMER1->TOPB = 2400-1;//1200-1; // 16kHz = 38.4MHz/ (2^(0+1)*TOP); f = HFPERCLK/ ( 2^(PRESC+1) * TOP))
TIMER1->CC[0].CCVB = 0;
TIMER1->CC[1].CCVB = 0;

///* Enable overflow interrupt */
TIMER1->IEN |= TIMER_IF_OF;

/* clear the interrupt flag */
TIMER1->IFC |= TIMER_IFC_OF;

/* Enable TIMER1 interrupt vector in NVIC */
NVIC_EnableIRQ(TIMER1_IRQn);

}
void timer1_Start() {
// Keep the chip from going lower than EM2 sleep mode.
EMU_EM2Block();
TIMER1->CMD = TIMER_CMD_START;
}
void timer0_Stop() {
// Allow the chip to enter EM2 sleep mode.
TIMER1->CMD = TIMER_CMD_STOP;
EMU_EM2UnBlock();
}
//static void ledBlink(void);
static void ledBlink(void);
void TIMER1_IRQHandler(void)
{
    uint16_t audio_Sample;
    if(toPlay > 0)
    {
        audio_Sample = buff[(iterator = next(iterator))];
        toPlay--;
    }else{
        audio_Sample = (255<<8) + 1;
    }
	TIMER1->CC[0].CCVB = ((audio_Sample>>8)&0xFF);
	TIMER1->CC[1].CCVB = ((audio_Sample)&0xFF);

	EMU_EM2Block();
	/* clear the interrupt flag */
	TIMER1->IFC |= TIMER_IFC_OF;
}
by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Super Star</font></font> </a> msam
on ‎02-02-2017 06:04 AM

Hi all,

 

I would like to share my eclipse gcc project template for Thunderboard Sense board.The project is running on simplicity studio.

Special thanks to JaakkoV.

 

 

https://www.dropbox.com/s/64noetxftgnll3z/BLE_Sense.zip?dl=0 ( Eclipse project )

https://www.dropbox.com/s/elnn5hdy3usp9pq/BLESenseSetup.docx?dl=0( setup instructions docx )

https://www.dropbox.com/s/7a5hqwjmj4cdq5e/BLESenseSetup.pdf?dl=0 ( setup instructions pdf)

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Legend Employee</font></font> </a> JaakkoV
on ‎03-13-2017 03:00 AM

Latest BLE SDK 2.3.0 was just released and this is the first SDK that has built-in support for GCC. When creating an example project, you can select GCC toolchain instead of IAR and use breakpoints, single stepping etc. in the Simplicity Studio IDE.

 

From the release notes: (SDK 2.3.0 build 1981)

"This SDK release contains Beta level support for gcc compiler."

 

For GCC related questions in the 2.3.0 SDK please create a new topic instead of replying to this old thread.

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Ninja</font></font> </a> ablumenk
on ‎03-13-2017 09:23 PM

Awesome, Jaakko ! Much appreciated. I will keep you posted how it goes.

 

Alex