Designing with the SparkFun Artemis
Programming
Artemis can be programmed using the standard JTAG interface or with a serial bootloader. You'll find a USB connector for serial bootloading with the CH340 or a JTAG footprint for more advanced programming and debugging, on a variety of dev boards from SparkFun. For more information on ARM programming, including JTAG interfaces, check out our ARM Programming Tutorial.
SparkFun Bootloader
We've designed a baud rate flexible bootloader that is run at each power on reset. What does baud rate flexible mean exactly? The computer and bootloader initiate communication at 9600bps, then agree to go to a faster baud rate to transfer the bulk of the binary data. This enables upload speeds up to 921600bps; significantly reducing upload times. A flexible rate allows computer systems that may have problems at higher rates to select the rate that works best. This bootloader is the preferred method for uploading sketches and user code that needs quick and reliable means of getting new code onto the Artemis.
Once you've selected an Artemis target board additional menu options will appear the next time you open the Tools menu. The SVL Baud Rate options will allow you to change the upload speed. 921600bps is the recommended speed as it's extremely fast to update new sketches. However, there are some platforms (Linux flavors) where the standard CH340 USB to serial drivers don't operate well at speeds higher than 115200. So if you run into upload problems, consider reducing the upload speed. For more information about upload issues, see this forum post and consider upgrading with these drivers for Mac OSX or these for Linux.
Just like the classic Arduino Uno, Arduino Mega, etc, the bootloader is activated by resetting the board. A single 0.1uF capacitor between DTR and reset is all that is needed to cause the Artemis to reset and enter bootload mode. If no new firmware is detected within a short amount of time (50ms), user code is run.
If you're into niche electrical engineering discussions on things like bootloaders, you can read more about the Artemis bootloader here.
Factory Bootloader
In addition to the SparkFun Artemis bootloader, we program every Artemis with the Ambiq factory Secure Bootloader (SBL). This bootloader is best used for low-level updates of devices that need to have a secure provenance. The bootloader is activated at reset if pin 47 is high and communicates at 115200. The bootloader will then wait indefinitely for new binary data. We provide a python tool as well as an executable to communicate with this bootloader.
This style of bootloading is slightly different from bootloaders that you may be accustomed to. The STK500 bootloader that runs on most ATmega328 based Arduinos is run automatically at reset, then times out and the user’s code is run. The Artemis bootloader is similar but requires an extra pin (the Bootload pin) to be held high. To make using Artemis as cheap and easy as possible we’ve designed a simple RC circuit that can be implemented on your design using USB-to-serial ICs with the bare minimum control pins (the CH340E has only RTS) and still allow for factory bootloader activation. If you suspect you will need to modify the SparkFun Artemis Bootloader (described above) or if you need to use the secure bootload toolchain, the circuit above can be used to bootload using a single pin (DTR or RTS is supported). This single-pin reset and bootload solution is ideal for any USB to serial implementation that has control pins exposed (CH340, CP210x, FT232, etc).
To load new code onto your Artemis module using the Ambiq bootloader toolchain select the Ambiq Secure Bootloader option in the Arduino Tools->Bootloader menu. These tools will modify your binary and package them with various security headers. The code will load at 115200bps and may fail. Hit upload again if the process fails.
How the Single Pin RC Circuit Works
By pulling DTR (or RTS) low, the module is reset. After 10ms, DTR is pushed high in software. This causes the bootload pin to be high for 100ms allowing the bootloader to run. Opening of a serial port causes DTR to go low causing the module to reset, but because DTR stays low during normal serial operations the module does not enter the SBL and instead proceeds to run the SparkFun Artemis Bootloader.
We have modified the Ambiq python bootload tool so that both DTR and RTS are driven at the same time, and in the same way, so you can use either RTS or DTR to bootload the Artemis. Our Ambiq SBL tools then drive DTR/RTS high to enter the the factory bootloader.
If you prefer, the bootload pin can be broken out to a button. When the user holds the button and resets the board the Artemis will enter bootload mode and stay there until a bootload cycle completes or a reset occurs. This method works well but requires the user’s interaction every time new code needs to be loaded.