SparkFun Forums 

Where electronics enthusiasts find answers.

What are we doing right with Artemis? What are we doing wrong? Let us know here!
User avatar
By robin_hodgson
#209845
Hi all, I have been using Segger Embedded Studio with my Artemis boards now for over a month. In short, it works quite well. Unlike Keil and IAR, SES is free for non-commercial use without the crippling code-size limitations of the free version available from Keil and IAR. SES is based on GCC, so the code quality is excellent. But the whole reason for using SES was to get native support for full hardware debugging, as detailed here viewtopic.php?f=171&t=50960.

If you replicate what I have done, you will be able to write Artemis software in C or C++ with full access to the Ambiq Suite libraries. The best feature is that attaching a J-Link EDU or J-Link Mini will allow you to reflash firmware, examine call stacks, set breakpoints, watch variables, and do everything that a hardware debugger enables you to do, all of it integrated natively into the SES IDE.

I have found it hugely useful to use the SES symbolic directories to include the Ambiq Suite sources in every project. Doing so enables you to use the SES editor to walk through the Ambiq sources, or jump directly to where one of your Ambiq HAL calls is defined so you can see how it works. You can even single step through the libraries or set breakpoints inside them just like any other software you write. And of course, when the program you are writing crashes into the ARM hardfault handler for the umpteenth time, the hardware debugger lets you work backwards through the callstack to find out why.

There is also support for the Segger IO debug mechanisms so that you can use printf() to send data to a terminal window hosted by the debugger. The IO goes over the debug connection meaning that the processor's entire hardware resources are still available to your application.

I am happy with how it all turned out. However, I will say that it was not the most intuitive process for me to get everything working, and it is quite likely that some things I did were non-optimal due to me having to learn SES as I went. If you want to give it a try yourself, I have attached a document that describes how you can replicate my setup. This process has been tested by a couple of volunteers, so it should be mainly debugged at this point. Feel free to send me a reply or a PM if you have a better way of doing this stuff and I will do my best to keep the doc updated. I am hoping that the document will come through as an attachment. It is a zipped PDF.
You do not have the required permissions to view the files attached to this post.
User avatar
By VA3SU
#209966
Just finished flashing the hello world using the Segger Embedded Studio thanks to your instructions Robin. Thanks so much for posting this! I had purchased the their J-link edu from your comment about it a few weeks ago and built up an adapter to connect to the Red board. Really nice having a real hardware debugger!
Regards,
Kevin
User avatar
By robin_hodgson
#209995
It has been brought to my attention that I introduced a couple of mistakes into the 1V5 doc. Here is the 1V6 doc, which fixes them.
You do not have the required permissions to view the files attached to this post.
User avatar
By VA3SU
#210051
I've noticed that if I program my redboard to blink an LED it works fine while the Segger debugger is connected but not if the debugger is disconnected from the redboard. I'm sure it's a setting somewhere but... Can't find anything.

How do I make it stand alone?

Regards,
Kevin
User avatar
By robin_hodgson
#210052
Make sure that your debug sessions have not accidentally overwritten the Sparkfun bootloader. This could happen if you ever wrote flash below 0x00010000, for example if you missed the step about telling the linker to create the executable starting at address 0x00010000. The debugger can install your program anywhere and get it running, but the bootloader insists that it start at 0x00010000.

One way to test that the bootloader is working is to build and download any Arduino sketch. If the sketch does not download, it is probably because the Sparkfun bootloader is gone. If so, there are instructions on the Sparkfun site on how to reinstall the bootloader. They work, because I have had to do it :oops:
User avatar
By VA3SU
#210054
Thanks Robin. One great part about this fix is that I was able to restore the bootloader from within the Arduino App. Just pick Ambiq Secure bootloader and then program bootloader.
Regards,
Kevin
User avatar
By kerry.even@att.net
#210270
Worked like a charm for Hello World but....

Tried two different Edge2 projects that I have previously compiled and loaded with GCC. One that blinks the led's, and the amdtpc Ambiq client app. I would love to be able to debug the many messages so that I can complete my Android app to talk back and forth with these boards. As I was adding include paths and re-building, I kept running into this error and have spent hours playing with it without knowing why it's occurring.

expected identifier or '(' before numeric constant

It shows as a build error with a red X but does not jump to a line or a file when the error is clicked on as other errors do. Googling seems to imply a duplicate definition somewher or something like that. ANY IDEAS????


Here is the entire output:

Building ‘Test’ from solution ‘Test’ in configuration ‘Debug’
'Output/Test Debug/Obj/SEGGER_RTT.o' is up to date
'Output/Test Debug/Obj/SEGGER_RTT_Syscalls_SES.o' is up to date
Output/Test Debug/Obj/ble_freertos_amdtps.o does not exist.
'Output/Test Debug/Obj/Cortex_M_Startup.o' is up to date
Compiling ‘ble_freertos_amdtps.c’
"C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 4.30c/gcc/arm-none-eabi/bin/cc1" -fmessage-length=0 -fno-diagnostics-show-caret -mcpu=cortex-m3 -mlittle-endian -mfloat-abi=soft -mthumb -mtp=soft -munaligned-access -nostdinc "-isystemC:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 4.30c/include" "-isystemC:/Users/kerry/AppData/Local/SEGGER/SEGGER Embedded Studio/v3/packages/include" -isystem../../mcu/apollo3 -isystem../../CMSIS/ARM/INCLUDE -isystem../../boards_sfe/edge2/bsp -isystem../../devices -isystem../../utils -isystem../../third_party/FreeRTOSv10.1.1/Source/include -isystem../../boards_sfe/edge2/examples/ble_freertos_amdtpc/src -isystem../../third_party/FreeRTOSv10.1.1/Source/portable/GCC/ARM_CM4F -ISEGGER -D__SIZEOF_WCHAR_T=4 -D__ARM_ARCH_7M__ -D__SES_ARM -D__HEAP_SIZE__=1024 -D__SES_VERSION=43003 -D__SEGGER_LINKER -DDEBUG -MD "C:/Users/kerry/Documents/AmbiqSuite-Rel2.2.0/SEGGER Embedded Studio for ARM Projects/Test/Output/Test Debug/Obj/ble_freertos_amdtps.d" -MQ "Output/Test Debug/Obj/ble_freertos_amdtps.o" -quiet -std=gnu99 -g3 -gpubnames -fomit-frame-pointer -fno-dwarf2-cfi-asm -fno-builtin -ffunction-sections -fdata-sections -fshort-enums -fno-common C:\Users\kerry\Documents\AmbiqSuite-Rel2.2.0\boards_sfe\edge2\examples\ble_freertos_amdtps\src\ble_freertos_amdtps.c -o "C:/Users/kerry/Documents/AmbiqSuite-Rel2.2.0/SEGGER Embedded Studio for ARM Projects/Test/Output/Test Debug/Obj/ble_freertos_amdtps.asm"
expected identifier or '(' before numeric constant
'Output/Test Debug/Obj/HardFaultHandler.o' is up to date
'Output/Test Debug/Obj/SEGGER_HardFaultHandler.o' is up to date
'Output/Test Debug/Obj/SEGGER_THUMB_Startup.o' is up to date
Build failed

I Loaded main .c file, built it and started adding include directories from Project/Options/Common/Preprocessor/System Include Directories as each "can't find file error" occurred. Is there a better or workable way to build these files that works? Obviously my first time at this but if I have the prob., someone else probably will.

My goal is to get the amdtp app to work with an android app as the esp32 does so well ... for IOT.

Thanks for reading...hope someone knows what is going on.
User avatar
By robin_hodgson
#210271
I think you missed a couple steps from the document. For example, your compile command does not define the processor type or the package type. Inside your compile output, I see this:
Code: Select all
-DDEBUG -MD
After building one of my own project files just to see the command line, I see that my command line has some differences:
Code: Select all
-D_DEBUG -DAM_PACKAGE_BGA "-DAM_PART_APOLLO3 " -MD
There are three problems in that one section of your command line. You can't define "DEBUG" because that will cause a name collision with a badly chosen name of the struct field inside the Ambiq HAL. You also need to define the processor as being an Apollo3 and the package as being the BGA package. There may be more problems than that - I didn't look past that.

The important point is that if you continue reading the very next sections of the Segger doc I posted, it will tell you how to fix the problems above.
User avatar
By robin_hodgson
#210272
Hmm. Looking at my command line showed me that I had a trailing space when I defined AM_PART_APOLLO3 in Segger Studio, which is why the system quoted it all with a space at the end. Fortunately, that ends up being completely harmless. But I fixed it anyway, and now I get:
Code: Select all
-D_DEBUG -DAM_PACKAGE_BGA -DAM_PART_APOLLO3 -MD
If my crappy memory is right, the specific error you are seeing is due to the define of DEBUG via -DDEBUG. This defines a preprocessor symbol DEBUG to have no textual replacement. Sadly, there is a struct field inside the Ambiq HAL called DEBUG (boo: all upper case, so it looks just like a preprocessor symbol). Your -DDEBUG causes the name of that field (DEBUG) to vanish and the compiler gets annoyed when it is expecting to see a name and finds what follows the name instead.
 Topic permissions

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum