AmbiqSuite/SFE SDK blinky example stops blinking

When running the AmbiqSuite/SFE SDK blinky example, I’ve noticed that the user (blue) LED stops blinking ~23.8 minutes (~1430 seconds) after a reset. Initially, I found this by accident after walking away from my desk… when I came back the user LED was solid blue. Then, I started timing the start to freeze time. I’ve confirmed this on an Artemis Redboard and an Artemis Redboard ATP.

I was hoping someone else could confirm this independently. It is not a huge issue, but it would be nice to know whether this is something intentional or a bug. I tried to look through the code, but I don’t see any obvious reason for this behavior. I don’t have a debugger, yet. This one is not that easy to debug using printf’s.

I should also mention that the Arduino Blinky example does not seem to have the same issue.

The root cause of this is the STIMER capture/overflow interrupt, IRQ22, is enabled. When the STIMER overflows, the am_default_isr() handler is called. The STIMER will overflow after 2^32/3MHz = ~1431 seconds Then, the handler spins in an infinite while loop and the application appears to freeze. As a side note, am_default_isr() is the default handler assigned in startup_gcc.c to all the peripherals and 4 other handlers. It appears that the SF Artemis SVL bootloader is enabling this interrupt. So, the blinky example is not the only code affected by this. Any application that doesn’t clear the STIMER capture/overflow interrupt while using the default handler will see this. So, it is always a good idea to pay attention to how the Apollo3 is configured before main() or immediately upon entry into main().

I should also note that the 3MHz used in the calculation above comes from the STCFG register CLKSEL field. Out of the bootloader, It is set to 0x1 corresponding to setting the STIMER clock source to HFRC_DIV16.

Thanks, I had observed the same behavior after a reset but also had no way to debug the program.

I’m a little surprised that no one from SFE has made any comment on this issue. This is subjective, but I don’t think this should be the default behavior as many users will use the SVL bootloader. Or, at least document that behavior. It would save others debugging time. Before your reply, I thought I was the only one seeing this issue.

Hard to believe they have not commented on a few things.

Hi all - until yesterday I had not been subscribed to this forum topic (only to the hardware topics for some reason, so I have missed A LOT of good conversations). Yes this is an issue! I’ll take a look ASAP.

I’ve drafted changes to the SVL in the BSP.

https://github.com/sparkfun/SparkFun_Ap … Ps/pull/22

They still need to be tested and then migrated into Arduino - and then to see the changes users will have to re-flash the bootloader using the provided tools. We will also release documentation advising people to do so.

l.s, that’s good to see. Thanks.

Arduino core is updated to v1.0.22 which updates the SVL to version 4. To see the benefits use the ‘burn bootloader’ option with ‘Ambiq Secure bootloader’ selected as the programmer from the tools menu.

I just burned the new SVL to my Redboard ATP. Works like a charm. Thanks again!

I bought an Artemis ATP board this month, but it must be old stock, as it still has this bug and all programs freeze after 1431 seconds. Is there a trick to burning a new version of the SVP? Using liquid.soulder’s instructions - use the ‘burn bootloader’ option with ‘Ambiq Secure bootloader’ selected as the programmer - just gives me error messages. I’m using the stand-alone IDE.

Arduino: 1.8.13 (Windows 10), Board: “RedBoard Artemis ATP, 115200, Ambiq Secure Bootloader (Advanced)”

java.lang.NullPointerException

at cc.arduino.packages.uploaders.SerialUploader.burnBootloader(SerialUploader.java:329)

at processing.app.Editor.lambda$handleBurnBootloader$61(Editor.java:2379)

at java.lang.Thread.run(Thread.java:748)

Error while burning bootloader.

Thanks,

Fran

Typo, SVP should be SVL.

https://learn.sparkfun.com/tutorials/de … rogramming has instructions walking through the steps for this :slight_smile:

Hope this helps!

Thank you, Russell. Well, I had already looked there, and it mostly says to do what I had already done using the IDE.

There are some other links, and one of the things they talk about is using other hardware to install new bootloaders.

However, I looked further and found this:

If you’re into niche electrical engineering discussions on things like bootloaders, you can read more about the Artemis bootloader here.

https://github.com/sparkfun/SparkFun_Ar … Bootloader

Here, in addition to sending you back to where you just were, it also says this:

It can also be upgraded using the Artemis Firmware Upload GUI.

https://github.com/sparkfun/Artemis-Firmware-Upload-GUI

I downloaded the Artemis Firmware Uploader, and then was able to use it to upload SVL version 5 (apparently, I had version 3).

So, now it truly does run “over and over again forever.”