Giter VIP home page Giter VIP logo

arduino_apollo3's Introduction

Generate Variants Status Badge

SparkFun Ambiq Apollo3 Arduino Core

An mbed-os enabled Arduino core for Ambiq Apollo3 based boards

Contents

Installation

Arduino Boards Manager (recommended)

Git (development)

  • Ensure the proper directory structure exists by following the Arduino Boards Manager instructions (install latest)
  • navigate to your directory with the latest version
  • rename the directory from 2.x.x to .bckup2.x.x (or simply delete it and download it later if wanted)
  • clone this repo git clone https://github.com/sparkfun/Arduino_Apollo3.git
  • checkout desired branch cd Arduino_Apollo3 git checkout release-candidate
  • update all submodules git submodule update --init --recursive
  • rename directory from Arduino_Apollo3 to 2.x.x from above
  • restart Arduino and enjoy.

Getting Started

For in depth tutorials, checkout out the Artemis page for the latest. Tutorials that may be of interest include:

If you are comfortable with the arduino IDE and already have the boards installed, we recommend trying some examples from within the arduino IDE. Start with the "Built-in Examples" from arduino, but don't forget to checkout out some of the board specific examples that we have included with the package. These demonstrate how to use some of the libraries that make our Artemis board unique, and can take your next project to a new level!

Development Status

  • v2.0.0 Based on an mbed-os framework
  • v2.1.0 Contains latest fixes for the v2 core and feature that have been added since v2 release

For more information on how to contribute or how to navigate this repo, check out the Contributing page.

As mentioned MbedOS is the framework to our latest Arduino Core. To contribute to, or use these targets on, MbedOS check out the main repo by ARM. This library uses mbed libraries built from a fork of mbed that is maintained by us. The latest version of that repo can be found here.

Main Arduino Features

  • Serial: ✅
  • GPIO: ✅
  • Analog / Servo Output: ✅
  • Analog Input: ✅
  • Timing / Delays: ✅

Standard Libraries

  • Wire
    • Controller: ✅
    • Peripheral: 🤔
  • SPI
    • Controller: ✅
    • Peripheral: 🤔
  • EEPROM: ✅

Apollo3 Specialty Peripherals

  • PDM Microphones / I2S: ✅
  • BLE: ✅
  • RTC: ✅
  • Watchdog Timer: ✅
  • Burst Mode: ✅

More

arduino_apollo3's People

Contributors

adamgarbo avatar bboyho avatar computeraided avatar dandobs avatar embeddedman avatar frinkahedron avatar gigapod avatar konkers avatar lauszus avatar makin-stuff avatar metanav avatar nigelb avatar nseidle avatar paulvha avatar paulzc avatar stephenf7072 avatar tgruetzm avatar wenn0101 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino_apollo3's Issues

pins_arduino.h not found

No pins_arduino.h in the variants

I am using red board Artemis nano with 2.8" adafruit TFT LCD shield. For simple graphic test, I am getting error
pins_arduino.h: No such file or directory

workbench

Expected behaviour

The LCD screen should show graphical outputs

Actual behaviour

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "SparkFun RedBoard Artemis Nano, 115200, Ambiq Secure Bootloader (Advanced)"

C:\Users\Documents\Arduino\libraries\Adafruit_ILI9341\Adafruit_ILI9341.cpp:52:12: fatal error: pins_arduino.h: No such file or directory
#include "pins_arduino.h"
^~~~~~~~~~~~~~~~
compilation terminated.

Using Visual Studio Code for Apollo3

Subject of the issue

I'm trying to setup a development environment in VS Code for the Apollo 3 (Sparkfun Redboard Artemis) and I was hoping someone could point me in a good starting direction. @oclyke, you implied in issue #36 that you use VS Code. What is your setup? Do you have the Ambiq SDK setup to compile in VSCode or do you use the arduino-vscode extension? The extension is limiting for me -- I cannot jump into HAL function definitions or debug in general. If you have a sample VS Code project, that will be very helpful.

Some background: I am successfully compiling AmbiqSDK examples and my own projects using Makefiles and the command line tools. I have also (with help from Sparkfun Forums) been able to setup a Segger Embedded Studio (SES) for the Apollo3/Artemis and can debug code using J-LINK.

Your workbench

macOS 10.15, Catalina
Sparkfun Redboard Artemis
USB-C, J-LINK Debugger
Powered via USB

AnalogWrite stops working when the value is reset to 0

When writing PWM values, the analogWrite function (v1.0.5) gets stuck when writing a value of 0 a second time. Using the builtin LED connected to D5 of the ATP board and running the following code:

void setup() {
Serial.begin(115200);
delay(100);

pinMode(5, OUTPUT);
Serial.println("Start!");

analogWrite(5,0);
Serial.println("Wrote a value of 0");

analogWrite(5,1);
Serial.println("Wrote a value of 1");

analogWrite(5,0);
Serial.println("Wrote a value of 0");
}

void loop() {
Serial.println("Looping");
delay(100);
}

My serial terminal window displays:

⸮Start!
Wrote a value of 0
Wrote a value of 1

It seems that the interrupt isn't triggering when the value is changed back to 0 a second time. AnalogWrite seems to work as expected if I write any 8-bit value other than 0.

HWSerial: overloaded 'write(int)' is ambiguous

size_t write(const char *str) {
            ^~~~~
exit status 1
call of overloaded 'write(int)' is ambiguous

This should be really easy to fix. Just making a note for near future. All we need is an overloaded function signature.

Binding Arduino Binaries with TensorFlow Models

Subject of the issue

As I am currently working on a project with the SparkFun Edge Dev Board which uses the Ambiq Apollo 3, I'm wondering if there is a way to bind the Arduino generated binaries with a TensorFlow Lite build for the Edge?

Your workbench

  • MacOS Mojave 10.14.5 (18F132)
  • SparkFun Edge Dev Board V1
  • USB-C Breakout UART

Feature Request: Generic QWIIC/Wire.h + SPI interfaces

Subject of the issue

I2C and SPI interfaces as a drop-in replacement for the Wire.h Arduino library with the QWIIC ecosystem would allow users to interface with relays, sensors, displays, and plenty of other external devices.

Expected behaviour

I should be able to write code to a device's implementation as described. As many devices use the Wire.h library, it should be as easy as porting this to the Apollo3.

Actual behaviour

No such library exists, requiring users to have to research the Apollo3 SPI/I2C interfaces and create their own custom drivers for selected hardware that typically already has an implementation in existence.

Is SD card functionality supported?

I am considering this platform for my next project.
Just wonder if SD card functionality is already supported or will that be in the close future?

Warning: SPI function without return

Looks like a function __interruptsStatus() needs a return value:

C:\Users\user\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\0.0.0\libraries\SPI\src\SPI.cpp: In function 'unsigned char __interruptsStatus()':
C:\Users\user\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\0.0.0\libraries\SPI\src\SPI.cpp:133:1: warning: no return statement in function returning non-void [-Wreturn-type]

Windows recognizes artemis_svl.exe as a virus

Issue

First time I tried to compile & upload example Example8_BLE_LED after installing SF Apollo core via the Arduino IDE:

CreateProcess error=225, Operation did not complete successfully because the file contains a virus or potentially unwanted software at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)

Then Windows removesd the file from the system. When I tried to run again it failed to locate the file:

java.io.IOException: Cannot run program "C:\Users\lordbunson\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\1.0.15/tools/artemis/windows/artemis_svl.exe": CreateProcess error=2, The system cannot find the file specified

Details

  • Platform: Windows 10 Pro Version 1809 OS build 17763.805
  • Device: Artemis Nano
  • How is device wired: USB C to USB C
  • How is everything being powered? USB C
  • Are there any additional details that may help us help you?
    • Only antivirus is Windows Defender.
    • I believe I was able to upload Example1_Blink once from 1.0.15 before this happened, but now it triggers on any Artemis example.
    • If you try to click on the file after a fresh install a dialog pops up with the original error, then the file is removed from the system.
    • This happens regardless of whether you install via the official package_sparkfun_index.json via boards manager or by cloning from GH. It also does not seem to matter what branch I am on.
    • Rerpo'd with 1.0.15, 1.0.14 and core-ble branch.

Repro

From git bash or WSL:

# backup Arduino installed board
mv ~/AppData/Local/Arduino15/packages/SparkFun/hardware/apollo3/1.0.15 1.0.15.bak
# clone from GH
git clone https://github.com/sparkfun/Arduino_Apollo3.git ~/AppData/Local/Arduino15/packages/SparkFun/hardware/apollo3/1.0.15

Press Win+R to open up run, enter %userprofile%/AppData/Local/Arduino15/packages/SparkFun/hardware/apollo3/1.0.15/tools/artemis/windows/ to open the directory in explorer.

Now you can double click the file to see the error dialog watch it get deleted in real time.

It's easy to rinse and repeat by simply running a git checkout tools to bring the exe back.

SparkFun RedBoard Artemis Nano - Upload fails from Linux

Subject of the issue

I have a SparkFun RedBoard Artemis Nano. I followed the instillation instructions from the README on both Windows and Linux. Everything works fine from windows but when I use Linux the uploader fails.

Your workbench

  • What platform are you using?

Linux (Ubuntu 18.04.3 LTS): ardunio-1.8.10
Windows 10 Pro: ardunio-1.8.10

  • What version of the device are you using? Is there a firmware version?

SparkFun RedBoard Artemis Nano

  • How is the device wired to your platform?

USB-C Cable from PC to device.

  • How is everything being powered?

USB-C Cable from PC to device.

  • Are there any additional details that may help us help you?

Steps to reproduce

  1. Install Arduino
  2. Add SparkFun boards to Arduino as per instillation instructions.
  3. Select Board: SparkFun RedBoard Artemis Nano
  4. Select Bootloader: SparkFun Variable Bootloader
  5. Select SVL Baud Rate: 921600
  6. Select port: Appropriate Port for Machine
  7. Create Sketch:
#include "Arduino.h"

void setup()
{
    Serial.begin(115200);

};

void loop()
{
    Serial.println("Hello World!");
};
  1. Press the Compile and Upload Buttons.

Expected behaviour

When I compile and upload from windows:

.
.
.
Sketch uses 6712 bytes (0%) of program storage space. Maximum is 960000 bytes.
C:\Users\user\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\1.0.20/tools/artemis/windows/artemis_svl.exe COM12 -f C:\Users\iser\AppData\Local\Temp\arduino_build_484232/helloworld.ino.bin -b 921600 -v 


Artemis SVL Bootloader

phase:	setup
	cleared startup blip
	Got SVL Bootloader Version: 3
	Sending 'enter bootloader' command

phase:	bootload
	have 6744 bytes to send in 4 frames
	sending frame #1, length: 2048
	sending frame #2, length: 2048
	sending frame #3, length: 2048
	sending frame #4, length: 600

	 Upload complete

Actual behaviour

When I compile and upload from Linux:

.
.
.
Sketch uses 6712 bytes (0%) of program storage space. Maximum is 960000 bytes.
/home/user/.arduino15/packages/SparkFun/hardware/apollo3/1.0.20/tools/artemis/linux/artemis_svl /dev/ttyUSB0 -f /tmp/arduino_build_176074/apollo3_hello_world.ino.bin -b 921600 -v 


Artemis SVL Bootloader

phase:	setup
	cleared startup blip

phase:	bootload
	have 6744 bytes to send in 4 frames

	error receiving packet
{'len': 0, 'cmd': 0, 'data': 0, 'crc': 1, 'timeout': 1}


unknown error
	sending frame #0, length: 0

	 Upload failed

phase:	setup
	cleared startup blip

phase:	bootload
	have 6744 bytes to send in 4 frames

	error receiving packet
{'len': 0, 'cmd': 0, 'data': 0, 'crc': 1, 'timeout': 1}


unknown error
	sending frame #0, length: 0

	 Upload failed

phase:	setup
	cleared startup blip

phase:	bootload
	have 6744 bytes to send in 4 frames

	error receiving packet
{'len': 0, 'cmd': 0, 'data': 0, 'crc': 1, 'timeout': 1}


unknown error
	sending frame #0, length: 0

	 Upload failed

When I compile and upload from Linux, after I have uploaded the same sketch from Windows I get this different error:

.
.
.
Sketch uses 6712 bytes (0%) of program storage space. Maximum is 960000 bytes.
/home/user/.arduino15/packages/SparkFun/hardware/apollo3/1.0.20/tools/artemis/linux/artemis_svl /dev/ttyUSB0 -f /tmp/arduino_build_176074/apollo3_hello_world.ino.bin -b 921600 -v 

[32220] Failed to execute script artemis_svl

Traceback (most recent call last):
Artemis SVL Bootloader

  File "artemis_svl.py", line 393, in <module>
phase:	setup
	cleared startup blip
  File "artemis_svl.py", line 333, in main

phase:	bootload
  File "artemis_svl.py", line 224, in phase_bootload
	have 6744 bytes to send in 4 frames
  File "artemis_svl.py", line 132, in wait_for_packet
IndexError: index out of range
IndexError: index out of range

Time masking issue with RTC library

Hi there, this isn't a major issue as you can work around it. I'm posting it here more so that others don't bang their heads against the wall :)

I'm having an issue where if use the rtc library then you try to use the regular time functions from time.h, the compiler doesn't recognize them. I think this is because minutes, hours... and stuff are defined in the rtc library and this masks those in time.h. I think... i dunno feel free to tell me I'm crazy. This makes it a bit tricky to actually set up your rtc from an external source.

my workaround was to copy the gnu time formating stuff i needed and rename the variables...

ATP fails to compile Blink - Unused pin def not compatible

ATP uses the

AP3_GPIO_PAD_UNUSED, //The one pad not broken out of the Apollo3 on the Artemis

in the variant file:

image

When we removed the -w compiler flag, ATP now fails to compile with the following error:

C:\...\...\apollo3\0.0.0\variants\SparkFun_BlackBoard_Artemis_ATP\config\variant.cpp:77:1: error: narrowing conversion of '-1' from 'int' to 'ap3_gpio_pad_t' {aka 'unsigned char'} inside { } [-Wnarrowing]

I plan to change the header files to change UNUSED define to 255 instead of -1.

RTC.cpp error line 62

Subject of the issue

setTime method adds an offset in the week of day computation.

Your workbench

  • What platform are you using? RedBoard Artemis Nano
  • What version of the device are you using? Is there a firmware version?
  • How is the device wired to your platform?
  • How is everything being powered? through USB
  • Are there any additional details that may help us help you?

Steps to reproduce

Tell us how to reproduce this issue. Please post stripped down example code demonstrating your issue to a gist.
call setTime( 20, 36, 0, 0, 11, 11, 2019) should compute monday.

Expected behaviour

Tell us what should happen
Month parameter in function should be 1-12 to compute day of the week.

Actual behaviour

Tell us what happens instead
Month value is reduced by 1, day computation is wrong.

Solution

hal_time.ui32Weekday = am_util_time_computeDayofWeek(2000 + year, month + 0, dayOfMonth); // Error month + 0 instead of month + 1 - JLC 11/11/2019

Enabling Software Interrupts Appears to Freeze Program

Enabling Software Interrupts Appears to Freeze Program

Using the ARM NVIC appears to freeze the apollo3 microcontroller a short while after the PDM IRQ is enabled.

My workbench

  • I'm using an Artemis Blackboard ATP with version 1.0.2 of the SparkFun Apollo Library
  • It is connected over a USB-C cable and is using the onboard microphone
  • This is being powered over the USB port on my Laptop

Steps to reproduce

To do this, I started adapting the code from the pdm_fft example in the apollo3 evaluation board example code. In the init function, it appears the NVIC_EnableIRQ(PDM_IRQn); function call freezes the chip a short while later when the pdm_config_print(); function is called.

The following functions are called as follows:

void pdm_init(void) {
    ...
    // There appears to be an error in this IRQ Enable
    // Commenting this function apperars to solve this issue,
    // although I believe this means the code can no longer be interrupt-driven
    NVIC_EnableIRQ(PDM_IRQn);
}
void setup () {
    ...
    //
    // Turn on the PDM, set it up for our chosen recording settings, and start
    // the first DMA transaction.
    //
    pdm_init();
    pdm_config_print();
}

Expected behavior

It is expected the interrupt is enabled and the sketch will continue into the pdm_config_print() function.

Actual behavior

The pdm_config_print() function stops output about halfway through the first line it is supposed to print.

DigitalWrite fails after analogWrite

Suppose a user does an analogWrite to an output pin. Then they do a digitalWrite HIGH to the same pin. On Artemis as currently implemented, the pin will remain in PWM / analog output mode rather than going HIGH. However, the ATmega328 core will actually drive the pin high. This discrepancy leads to some user code not working correctly when users switch to Artemis.

I'm trying to figure out the best place to implement the fix. I believe we could do a .uFuncSel on a given pin inside digitalWrite:

image

But that would basically be a pinMode(xPin, OUTPUT); every time digitalWrite was called (not good).

I believe we can't easily read or decipher a pad's current funcsel. Correct me if I'm wrong. So I am slowly leaning towards a global array of 50 uint8_ts that keep track of how each pin/pad is setup (in, out, analogin, analogout, i2c, spi, pdm, uart, ?). This would replace and supersede the ap3_analog_configure_map (used to keep track of which pads are currently defined as analogInput).

I love how "this will be a simple fix" turns into a big deal...

arduino-cli upload not working but works in Arduino IDE

Subject of the issue

Attempting to use the latest 0.7.1 arduino-cli on macOS with a SparkFun RedBoard Artemis Nano fails after detecting bootloader.

Your workbench

  • What platform are you using?
    macOS 10.14

  • What version of the device are you using? Is there a firmware version?
    SparkFun RedBoard Artemis Nano with SVL Bootloader 5 programmed from the 1.0.23 library.

  • How is the device wired to your platform?
    USB C cable

  • How is everything being powered?

  • Are there any additional details that may help us help you?
    Uploading works fine in the Arduino IDE

Steps to reproduce

Tell us how to reproduce this issue. Please post stripped down example code demonstrating your issue to a gist.

arduino-cli compile -u -t -b SparkFun:apollo3:amap3nano -p /dev/cu.wchusbserial1420 <sketch>

Expected behaviour

The Arduino IDE functions correctly and outputs the following:

Sketch uses 14284 bytes (1%) of program storage space. Maximum is 960000 bytes.


Artemis SVL Bootloader
Got SVL Bootloader Version: 5
[##################################################]Upload complete

Actual behaviour

Attempting to do the same thing with arduino-cli from a Terminal window outputs the following:

Sketch uses 14284 bytes (1%) of program storage space. Maximum is 960000 bytes.


Artemis SVL Bootloader
Got SVL Bootloader Version: 5
/dev/cu.wchusbserial1420 is currently open. Please close any other terminal programs that may be using /dev/cu.wchusbserial1420 and try again.

Note: Closing the Arduino IDE before trying arduino-cli does not solve the problem, nor does rebooting. Sudo also doesn't help.

Upload issue SparkFun Edge

Subject of the issue

I am not able to upload code to SparkFun Edge using Arduino IDE. It always keeps waiting at "sending hello". It seems the bootloader is not responding.

Your workbench

  • What platform are you using?
    MacOS Mojave
  • What version of the device are you using? Is there a firmware version?
    I am using pre-oder SparkFun Edge directly from SparkFun.
  • How is the device wired to your platform?
    Using SparkFun Serial Basic Breakout - CH340C and USB-C
  • Are there any additional details that may help us help you?
    Using Ambiq SDK toolchain there is no such issue.

Ambiq Secure Bootloader Does Not Like Serial Monitor

Ambiq Secure Bootloader seems to have some peculiar interactions with the Arduino Serial Monitor... for example:

  1. Code uploaded using the ASB while the board's Serial Monitor window is open will hang up the microcontroller and be recoverable only by bootloading again with the Serial Monitor window closed. (Only repeatable on some platforms)
  2. Rate of successful ASB loads is significantly lower when the Serial Monitor window is open. Closing the window makes ASB operation much more reliable.

The ASB was never intended to be used in the Arduino IDE and we don't fully understand the interactions that may be taking place. Thanks to the SVL the ASB is only a fallback/failsafe so we are not terribly concerned with fixing this issue. We are planning to remove the ASB option from the Arduino IDE menu to emphasize the "advanced" nature of using it. The ASB can still be used to burn the SVL bootloader onto the boards.

This GitHub issue serves as a record of the problem for anyone else who might stumble across it and wonder what in the world is happening.

PDM Audio Sampling & Data Packing

Subject of the issue

I have implemented an application that streams audio from a PDM microphone to the computer via Serial/Uart. While the audio data is transmitted as expected, it doesn't play back accurately. It sounds fast forwarded -- almost as if the audio was sampled at a much higher sampling rate than expected. However, changing playback sampling rate doesn't make much difference at all. I suspect it has to do with how the PDM data is packed in the FIFO. The Apollo3 Datasheet (on p360, v0.9.1) mentions the different operating modes and how the data is packed in the PDM FIFO. However, it's not clear from the table the correct way to undo the interleaving of samples.

I've attached a sample audio recording:
recording_1104_1115.wav.zip

Your workbench

macOS Catalina
Sparkfun Redboard Artemis Nano, Arduino 1.8.10, Apollo3 Boards v1.0.17

Steps to reproduce

Here is a link to a gist of a simplified implementation.

Serial Print Float / Double

Subject of the issue

Serial print functions cause a hard fault when handling float/double precision variables.

Your workbench

Steps to reproduce

void setup() {
  Serial.begin(9600);

  Serial.println("Float / Double print failure");
  delay(100); // allow banner to print before crash

  Serial.println(10); // print(int) works

  Serial.println(1000.0/960); // print(float/double) crashes into a HardFault

  Serial.println("I should be displayed but instead there is a crash");
}

void loop() {
  // put your main code here, to run repeatedly:

}

Expected behaviour

Serial output should read:

Float / Double print failure
10
1.04
I should be displayed but instead there is a crash

Actual behaviour

Serial output actually shows:

Float / Double print failure
10

String type not printing

This code prints 'Test' but then freezes.

void setup() {
Serial.begin(9600);
Serial.println("Test");

String myString = "String test";
Serial.print(myString);

}

void loop() {
}

Not sure if it's related to Uart::write or WString.cpp in ard_supers.

C++ Constructors/Destructors Not Called

Subject of the issue

When creating classes, such as Uart for Serial communication, the constructor/destructor functions are not called appropriately. For example the line Uart Serial(parameters) should create a Uart object called Serial with parameters stored appropriately as members of the object, however the members are uninitialized and read back as 'zero' without manually setting them (which violates the expectation of C++). This issue affects all development efforts using C++ constructs and so should receive the highest priority.

Your workbench

  • What platform are you using?
    • Windows 10, Arduino 1.8.9, using the Arduino SAMD Core ( 1.6.20 ) for the Arm build tools.
  • Are there any additional details that may help us help you?

Steps to reproduce

Tell us how to reproduce this issue. Please post stripped down example code demonstrating your issue to a gist.

class testClass{
  public:
    testClass(char parameter);
    char x;
    void printX( void );
};

testClass::testClass(char parameter){
  x = parameter;
}

void testClass::printX( void ){
  am_util_stdio_printf("Test class object has X = %d\n\n", x);
}

testClass myTestClassObj( 13 );

void setup() {
  // put your setup code here, to run once:
  am_util_stdio_printf("SparkFun Arduino Apollo3 C++ Constructor Issue Example\n");
  am_util_stdio_printf("Compiled on %s, %s\n\n", __DATE__, __TIME__);
  am_bsp_uart_string_print("Hello, World!\r\n\n");  // Sting_print has less overhead than printf (and less risky behavior since no varargs)

  myTestClassObj.printX(); // Should print with x = 13 (fails, not initialized)
  myTestClassObj.x = 5;
  myTestClassObj.printX(); // Should print with x = 5 (successful, x is set manually - but does not meet C++ expectation)

  testClass localTestClassObj( 13 );  // Constructed 'manually' in main application
  localTestClassObj.printX();         // This succeeds (prints with x = 13) because it does not rely on initialization code (__libc_init_array()) to call constructor
}

void loop() {
  // put your main code here, to run repeatedly:

}

Expected behaviour

Using constructors should correctly set up the values within the object

Actual behaviour

Constructors are not called automatically. They CAN be called manually, but then the scope of that class is restricted.

Further Thoughts:

The Constructor/Destructor feature of C++ is (at least somehow) tied in with the function __libc_init_array() and some entries in the linker script (?) called (something like) .init_array_start and .init_array_end. These entries are lists of all the construction function pointers to call and presumably what arguments to pass to them and what is expected out of them.

Adding the __libc_init_array() function into the startup code (cores/arduino/ard_sup/main.cpp) results in a linker error "init.c:(.text.__libc_init_array+0x22): undefined reference to `_init'"

Currently looking for a solution to this. Any thoughts/expertise are welcome!

Broken Arduino libraries due to implementaion of commonly used GPIO constants

Subject of the issue

I have noticed that some arduino libraries (including those created by sparkfun) fail when using the apollo3 core. In short, the apollo3 core defines common constants used by arduino to specify pin modes (such as INPUT, INPUT_PULLUP, and OUTPUT) as structures instead of a simple data type. The libraries in question make assumptions that these constants will be simple data types and that causes the failures. See https://forum.sparkfun.com/viewtopic.php?f=169&t=51356 for an example.

This is my first real look at Arduino so I don't know if the assumptions being made by those libraries are counter to accepted practices but based on what I have seen so far I would expect there would be more libraries that will run into problems because of this.

In the interest of better compatibility with libraries I am wondering if it makes sense to adjust this in the core. I don't expect library maintainers will redefine thier use of constants to every way a core might define constants differently so it seems to make more sense to change the core (if this argument is valid).

Again I normally work with more low level code so Arduino is new to me so I may not be factoring in some key considerations so please educate me if my conclusions seem flawed.

Proposed Changes

If the suggestions are deemed valid I could post a pull request with more details, I have made changes similar to those described below on my own local copy of the core to work around the issue for myself.

  1. Take existing defines for GPIO constants in question (INPUT, OUTPUT, etc) and rename them with a prefix such as "AP3_PINCFG_" and make those updates throughout the code.
  2. Add back in defines for GPIO constants in question (INPUT, OUTPUT, etc) but with simple integer values.
  3. Create a new version of pinMode that uses the translates the integer based GPIO constants to use the pinMode calls that use the structures.

Last I checked it would affect about 3 files.
It does add a slight level of abstraction that may need to be considered for impact and if it conflicts with your design approach.

Your workbench

Using Linux (Qubes with Fedora 30 Qube instance running Arduino 1.8.5)
Using Artemis boards from sparkfun (Nano, ATP, etc)

Steps to reproduce

Example: Try and use the sparkfun SX1509 ardiuno library (https://github.com/sparkfun/SparkFun_SX1509_Arduino_Library) and run an example such as basic keypad example.

Expected behaviour

Code compiles and uploads to the target board

Actual behaviour

Compile fails with errors such as:
/home/user/Arduino/libraries/SparkFun_SX1509_Arduino_Library-master/src/SparkFunSX1509.cpp:137:6: note: no known conversion for argument 2 from const am_hal_gpio_pincfg_t to byte {aka unsigned char} exit status 1

See https://forum.sparkfun.com/viewtopic.php?f=169&t=51356 for an example.

Support Binary Assignment to Variables

Subject of the issue

Arduino supports assigning values to variables in binary form by prefixing the number with a capital B. (Ex: n = B101)
When I try to compile a program for my Artemis board, this fails, saying that the value was not declared in this scope.

Your workbench

  • Arduno 1.8.10 on Windows 10 1909 x64
  • Using Artemis ATP
  • Connected via USB-C cable to laptop USB-C port
  • Powered over USB-C

Steps to reproduce

  1. Create a new Arduino project with this code.
  2. Configure the Arduino IDE to use the Redboard Artemis ATP
  3. Verify the program.

Expected behaviour

Program verifies successfully.

Actual behaviour

Verification fails with the error that 'B101 was not declared in this scope'

Bootloader SVL aarch64 Support

Continuing from #4 (comment)

There are two thing to address here, it seems.

  1. We could consider adding support for aarch64 by default, since you've gotten it to compile. The bootlaoder problems you are experiencing should be unrelated. If you like you could make a PR to the SparkFun Arduino Boards repo that includes your changes. Otherwise I can take care of it.
  2. You are having bootloader troubles which can be resolved in this issue.

So regarding the bootloader...

  • You seem to have the core v1.0.23 installed. That comes with an updated version of the SVL loader (v5). Have you updated the bootloader on the board by using the 'Burn Bootloader' option from the Arduino Tools menu? (v5 should be backward compatible but it can't hurt to update)
  • Your error appears to be a Python syntax error - potentially also caused by the difference in architecture. The executable under tools/artemis/linux was created using pyinstaller --onefile artemis_svl.py on an Ubuntu 18.04 machine. I'm not terribly familiar with the differences between linux flavors and host architectures but there may be some incompatibility. You can try two solutions:
  1. Modify platform.txt so that the upload step actually calls python3 to run the source code script (which you can then edit play around with to see what's going on)
    Change:
    tools.artemis_svl.pgm={runtime.platform.path}/tools/artemis/linux/artemis_svl
    to:
    python3 {runtime.platform.path}/tools/artemis/artemis_svl.py
  2. Try using PyInstaller to generate an executable for your architecture. That would be along the lines of pyinstaller --onefile artemis_svl.py

Add Linux Support?

Subject of the issue

My Apollo3 board is suppose to arrive in the mail today, so I decided to go ahead and setup the Arduino IDE.
I followed the manual install for core.
no examples show in the example list - but there is a space for "examples for Ambiq Apollo3 Evaluation board".
I manually browsed to the ~/Arduino/hardward/SparkFun/apollo3/libraries directory, and selected the example0_compilation, and the example1_compilation
The Ambiq Apollo3 Evaluation Board from my board choices.
when I click on the verify button, I get a Error compiling for board Ambiq Apollo3 Evaluation Board

In file included from sketch/example0_compilation.ino.cpp:1:0: /home/lfmiller/Arduino/hardware/SparkFun/apollo3/cores/arduino/ard_sup/Arduino.h:42:10: fatal error: am_bsp.h: No such file or directory #include "am_bsp.h" ^~~~~~~~~~ compilation terminated. exit status 1 Error compiling for board Ambiq Apollo3 Evaluation Board.

If I switch to any of the other boards in the package "SparkFun Edge" for example and click on the verify button I get this error.

Build options changed, rebuilding all fork/exec /home/lfmiller/Arduino/hardware/SparkFun/apollo3/tools/apollo3_scripts/artemis_bin_to_blob.exe: exec format error Error compiling for board SparkFun Edge.

.exe file is clearly a Windows thing - leading me to believe that Linux isn't supported yet - but when I goto the above directory, I see python scripts.
So I changed the permissions of the scripts, and the exec files to allow for executing.
And get the same error. Which lead me to believe (???)
Did I miss a step in setup somewhere or is Linux not supported yet.

Your workbench

  • What platform are you using? Linux Mint 19.1 64 bit, Arduino IDE 1.8.9
  • What version of the device are you using? Is there a firmware version? N/A
  • How is the device wired to your platform? N/A
  • How is everything being powered? N/A
  • Are there any additional details that may help us help you?

Steps to reproduce

Tell us how to reproduce this issue. Please post stripped down example code demonstrating your issue to a gist.

Expected behaviour

Tell us what should happen

Actual behaviour

Tell us what happens instead

Serial Port Usage in Core Examples

Subject of the issue

Raising this issue as a response to a compilation error I ran into with example2_serial -- "Serial1 not defined." I was compiling with Edge V2 variant, which is as of right now simply a copy of Edge which only has one serial object defined.

So we can't really guarantee that any given variant will have a particularly named serial object. 'Serial' is extremely likely, and after that it starts getting a little less clear. My suggestion would be to #define SERIAL_PORT Serial at the top of the file and in order to potentially demonstrate a secondary port #define SECONDARY_PORT Serial1 with a comment explaining that you may need to replace that with another name (SERIAL_PORT if you only have one port, and maybe mySerial if you've defined your own serial object on some pins that suit your needs)

As an argument against these #define statements they may be slightly more intimidating or confusing for beginners.

(P.s. taking a more formal approach to suggesting this change b/c the examples have been heavily prettified as we move toward the initial release.)

BLE support

Hi, I'm considering to use the Artemis platform for my next project which require BLE capabilities. Is there any effort currently done to support BLE with the Arduino core?

Thanks

EEPROM Example2_AllFunctions stalls on both the Artemis Thing Plus and ATP - possible memory alignment problem?

I am loving the Artemis. It is my new favorite thing!

Subject of the issue

When running the EEPROM Example2_AllFunctions on the Artemis Thing Plus and ATP it stalls (crashes?) part way through the double (64) sequential test on both boards

Your workbench

Artemis Thing Plus and ATP
Windows Arduino IDE 1.8.10
Apollo3 Boards 1.0.15
Connected and powered via USB-C

Steps to reproduce

Run the example.

Actual behaviour

Example stalls at the EEPROM.get for the double test

32 bit tests
Size of int: 4
Location 349 should be -245000: -245000
Location 353 should be 400123: 400123
Location 298 should be -341002: -341002
Location 302 should be 241544: 241544
Size of float: 4
Location 786 should be -7.350000: -7.350000
Location 790 should be 5.220000: 5.220000

64 bit tests
Size of double: 8

Expected behaviour

This:

32 bit tests
Size of int: 4
Location 349 should be -245000: -245000
Location 353 should be 400123: 400123
Location 298 should be -341002: -341002
Location 302 should be 241544: 241544
Size of float: 4
Location 786 should be -7.350000: -7.350000
Location 790 should be 5.220000: 5.220000

64 bit tests
Size of double: 8
Location 727 should be -290.348572: -290.348572
Location 735 should be 384.957336: 384.957336

Flash Contents:
0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF

Cause and Fix

It looks like it is a memory alignment problem caused by the union of the double and the two uint32_t's

Adding attribute packed to the union seems to fix it:

void ap3_EEPROM::get(uint16_t eepromLocation, double &dataToGet)
{
  union __attribute__((packed)) { // PaulZC added __attribute__((packed))
    double lf;
    uint32_t b[2];
  } temp;
  temp.b[1] = *(uint32_t *)(AP3_FLASH_EEPROM_START + eepromLocation);     //LSB;
  temp.b[0] = *(uint32_t *)(AP3_FLASH_EEPROM_START + eepromLocation + 4); //MSB;
  dataToGet = temp.lf;
}

But here's the weird thing. This only affects the get. The update/put seems immune and yet uses the same union. It's got me confused!

Enjoy!
Paul

GPIOs can be set to illegal states

Following code compiles but pin never outputs High. The reason is the pinMode sets pad 27 to INPUT_PULL which is some sort of illegal state

If you do the following code with pad 28, works great. I think this failure mode is happening on a few different pins.

See file ap3_gpio.cpp. padMode() calls am_hal_gpio_pinconfig, retval is non-zero.

If you simply do a pinMode(27, INPUT); everything works as expected (but without wanted pullups).

void setup() {
Serial.begin(9600);
Serial.println("Test");

pinMode(27, INPUT_PULLUP);
}

void loop() {
if (digitalRead(27) == LOW)
Serial.println("Low");
else
Serial.println("High");
delay(250);
}

package.json - working towards Issue #14

Working towards #14 - Support for PlatformIO

I have been playing around using this repository as a framework to build with platformio, see platform-apollo3blue. To use this repo as a framework package for platformio it needs a simple change, the addition of a package.json file containing a small amount of metadata, and looks like this:

{
    "name": "framework-arduinoapollo3",
    "description": "Arduino Wiring-based Framework (Apollo3 Core)",
    "version": "1.0.21",
    "url": "https://github.com/sparkfun/Arduino_Apollo3"
}

Add support for tone()

beep boop beep add support for the Arduino reference function tone(). Because this world does not have enough annoy-a-trons.

Build out support for PlatformIO

I've never done it but if someone has the experience getting an platform into platformio I would love to work with them. Please let me know.

Serial no longer functional with Arduino Core for Apollo 3 v1.0.26

Subject of the issue

  • Arduino Core for Apollo 3 v1.0.26 appears to have broken Serial output

Your workbench

  • What platform are you using?
    • Software: macOS Catalina, Arduino IDE 1.8.10
    • Hardware: SparkFun Artemis Nano, Edge 2
  • What version of the device are you using? Is there a firmware version?
    • Arduino Core for Apollo 3 v1.0.26
  • How is the device wired to your platform?
    • USB C/FTDI
  • How is everything being powered?
    • USB
  • Are there any additional details that may help us help you?
    • I'm unsure of the nature of this issue, but after updating to v1.0.26 all things Serial related ceased working. When I rollback to v1.0.24 there's no problems at all with Serial. Code that does not involve Serial appears to be working without issue (blink).

Steps to reproduce

  • Uploaded the Example4_analogRead and Example1_getTime

Expected behaviour

  • Visible output on Serial Monitor

Actual behaviour

  • No output on Serial Monitor
  • In the analog read example, an LED should blink but this is not observed. Possibly indicative that code is not executing beyond Serial.begin()

Using Variant BSP in Arduino

Subject of the issue

I need to use the Board Support Package (BSP) feature of AmbiqSDK within Arduino as I am trying to build off some of the AmbiqSuite examples. Unfortunately, I have been unable to include the BSP files (eg. am_bsp.h) in my sketch.

The instructions for doing this is provided in variants/bsp/README.md as:

To include BSP files (i.e. am_bsp.h, am_bsp.c, am_bsp_pins.h, am_bsp_pins.c, as well as
bsp_pins.src and pinconfig.py) add " -I{build.variant.path}/bsp" to the board definition in
boards.txt as part of the board.build.includes parameter.

I tried to add that to the board.txt changing it from
amap3redboard.build.includes=-I{build.variant.path}/config
to
amap3redboard.build.includes=-I{build.variant.path}/config -I{build.variant.path}/bsp

However, my sketch still cannot find am_bsp.h.

Your workbench

  • What platform are you using?
    macOS 10.15, Catalina
    Arduino IDE v1.8.10

  • What version of the device are you using? Is there a firmware version?
    Redboard Artemis. Arduino core: Sparkfun Apollo3 Boards v1.0.14

  • How is the device wired to your platform?
    USB-C port

  • How is everything being powered?
    USB-C port

  • Are there any additional details that may help us help you?
    I have been exploring the Ambiq HAL for sometime now with the gcc+Makefile setup, so I'm familiar with the SDK.

Steps to reproduce

To reproduce, merely add #include "am_bsp.h" to any sketch.

Expected behaviour

Ideally, including the bsp files should compile without errors.

Actual behaviour

However, i just get an error: error: am_bsp.h: No such file or directory

BLE Example doesn't compile as is

Example 8 BLE

Does not compile in the arduino IDE

Your workbench

  • Windows 10 - Arduino IDE 1.8.10
  • Redboard atremis v10
  • USB C to USB A
  • Powered off USB

Steps to reproduce

Try and compile the Example for the Redboard

Needs

It asks for many files from the AmbiqSuite

Add support for Servo

Add support for the Arduino library Servo. Owen's already got the analogWrite() function examples that show how to do this. We just need to build out the other parts of the library API.

Support Additional Host Systems

Apollo3 Board will not install from Board Manager on Pi 4. (Raspbian Buster)

The error is "Tool arm-none-eabi-gcc is not available for your operating system."

I have the 32 bit version of Arduino v 1.8.10 (64 bit is not applicable.)
I prefer using a Pi (3 or 4) for physical computing but in the case of my new Artemis RedBoard it seems to me that is not an option unless or until the board support is enhanced for this platform.

Please advise. Thank you!

Artemis ATP BLE and RTC issue

Subject of the issue

I just received Artemis ATP board and started using with examples.
The Blink example works.
The BLE_LED and RTC example is not working.

Your workbench

  • What platform are you using?
    MacOS

  • What version of the device are you using? Is there a firmware version?
    SparkFun RedBoard Artemis ATP. Sparkfun Apollo 3 Boards version 1.0.24.

  • How is the device wired to your platform?
    USB C connected to Macbook Pro

  • How is everything being powered?
    USB C connected to Macbook Pro

  • Are there any additional details that may help us help you?
    I used the same examples with Sparkfun Edge and it is working fine.

Steps to reproduce

I just uploaded default examples using Arduino IDE.

Expected behaviour

  1. After uploading BLE_LED example it should appear in nRF connect app as "Artemis BLE".
  2. After uploading RTC example the time should be changing every second.

Actual behaviour

  1. There is no "Artemis BLE" advertisement label appears in the nRF connect app.
    The serial monitor outputs is as follows:
    Apollo3 Arduino BLE Example. Compiled: 22:10:13
    fm: NusHandlerInit, file: /var/folders/ck/1n_m22xn15zdntmwtj9bvx400000gn/T/arduino_build_927532/sketch/nus_main.c, line: 1073
    fm: NusStart, file: /var/folders/ck/1n_m22xn15zdntmwtj9bvx400000gn/T/arduino_build_927532/sketch/nus_main.c, line: 1161
    fm: tagAttCback, file: /var/folders/ck/1n_m22xn15zdntmwtj9bvx400000gn/T/arduino_build_927532/sketch/nus_main.c, line: 387
    fm: NusHandler, file: /var/folders/ck/1n_m22xn15zdntmwtj9bvx400000gn/T/arduino_build_927532/sketch/nus_main.c, line: 1119
    fm: tagProcMsg, file: /var/folders/ck/1n_m22xn15zdntmpwtj9bvx400000gn/T/arduino_build_927532/sketch/nus_main.c, line: 938
    sg->hdr.event: 0x0052
    [ serial output stops after above line]

  2. The RTC example serial output:
    RTC Example
    It is now 22:09:16.00 01/12/20 Day of week: 0 = Sunday
    It is now 22:09:16.00 01/12/20 Day of week: 0 = Sunday
    It is now 22:09:16.00 01/12/20 Day of week: 0 = Sunday
    It is now 22:09:16.00 01/12/20 Day of week: 0 = Sunday
    It is now 22:09:16.00 01/12/20 Day of week: 0 = Sunday
    It is now 22:09:16.00 01/12/20 Day of week: 0 = Sunday
    It is now 22:09:16.00 01/12/20 Day of week: 0 = Sunday
    It is now 22:09:16.00 01/12/20 Day of week: 0 = Sunday
    It is now 22:09:16.00 01/12/20 Day of week: 0 = Sunday
    It is now 22:09:16.00 01/12/20 Day of week: 0 = Sunday

Arduino core 1.0.25 Serial Failure

Subject of the issue

Describe your issue here.
compile error:
C:\Users\kerry\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\1.0.25\cores\arduino\ard_sup\uart/ap3_uart.cpp:426: undefined reference to `ap3_g_prfbuf'

Your workbench

  • What platform are you using? Windows 10
  • What version of the device are you using? Is there a firmware version?Artemis Redboard Nano
  • How is the device wired to your platform? not connected..just Verify/Compile
  • How is everything being powered?
  • Are there any additional details that may help us help you?

Steps to reproduce

Tell us how to reproduce this issue. Please post stripped down example code demonstrating your issue to a gist. Using standard example Example8_BLE .. same error with Example5_analogWrite

Expected behaviour

Tell us what should happen

Actual behaviour

Tell us what happens instead

Upload fails when connected to MAX30105 breakout board

Subject of the issue

I have connected a MAX30105 particle sensor breakout board to the QWIIC of the Redboard Artemis nano. I am uploading a sketch for simple serial reading. The upload fails every time.

workbench

*Arduino 1.8.9

Steps to reproduce

`#include <Wire.h>
 #include "MAX30105.h"

 MAX30105 particleSensor;

#define debug Serial //Uncomment this line if you're using an Uno or ESPww  d3
//#define debug SerialUSB //Uncomment this line if you're using a SAMD21

void setup()
{
debug.begin(115200);
if (particleSensor.begin() == false)
{
debug.println("MAX30105 was not found. Please check wiring/power. ");
while (1);
}
byte ledBrightness = 0x1F; //Options: 0=Off to 255=50mA
byte sampleAverage = 2; //Options: 1, 2, 4, 8, 16, 32
byte ledMode = 3; //Options: 1 = Red only, 2 = Red + IR, 3 = Red + IR + Green
int sampleRate = 400; //Options: 50, 100, 200, 400, 800, 1000, 1600, 3200
int pulseWidth = 69; //Options: 69, 118, 215, 411
int adcRange = 4096; //Options: 2048, 4096, 8192, 16384

particleSensor.setup(ledBrightness, sampleAverage, ledMode, sampleRate); //Configure 
sensor. 
Use 6.4mA for LED drive
}
void loop()
{
debug.print(millis());
debug.print(",");
debug.print(particleSensor.getRed());
debug.print(",");
debug.print(particleSensor.getIR());
debug.print(",");
debug.print(particleSensor.getGreen());
debug.println();
}`

Expected behaviour

The expected output should be serial reading on the serial monitor

Actual behaviour

Connecting over serial port COM16... Fail Fail Fail Tries = 3 Upload failed

variant.h: No such file

Subject of the issue

variant.h: No such file

Your workbench

  • Arduino IDE 1.8.10
  • RedBoard Artemis

Steps to reproduce

Compile Blink example with board type SparkFun RedBoard Artemis

Expected behaviour

Successful compile.

Actual behaviour

fatal error: variant.h: No such file or directory

Using version 1.0.9.

Three folders in the variant folder must be changed from BlackBoard to RedBoard to match the change to boards.txt in 4ef0c02

Without this change, compiling Blink.ino for SparkFun RedBoard Artemis* fails with "fatal error: variant.h: No such file or directory"

OLD:
variants/SparkFun_BlackBoard_Artemis/
variants/SparkFun_BlackBoard_Artemis_ATP/
variants/SparkFun_BlackBoard_Artemis_Nano/

NEW:
variants/SparkFun_RedBoard_Artemis/
variants/SparkFun_RedBoard_Artemis_ATP/
variants/SparkFun_RedBoard_Artemis_Nano/


SPI needs setClockDivider

Attempting to run SparkFun BME280 library failed because

C:\Dropbox\Apps\Arduino\libraries\arduino_173658\src\SparkFunBME280.cpp: In member function 'uint8_t BME280::begin()':
C:\Dropbox\Apps\Arduino\libraries\arduino_173658\src\SparkFunBME280.cpp:98:7: error: 'class 
SPIClass' has no member named 'setClockDivider'
    SPI.setClockDivider(SPI_CLOCK_DIV32);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.