SparkFun Forums 

Where electronics enthusiasts find answers.

Tips, tricks, & best best practices using Artemis with your board designs.
User avatar
By robotastic
#209058
I am working on getting the Micro Voice demo working on the Artemis RedBoard. I have been taking the steps used to get it working on the Edge and Edge 2, and just running it. There is a general walk through here: https://codelabs.developers.google.com/ ... sorflow/#0

I am pretty sure I need to point to the BSP for the RedBoard instead. I have managed to at least get it to compile and have it spit out some info over Serial.

I am running this on OSX. You will have to use brew or MacPorts to get a newer version of make and then make sure the updated version is used as the default.

I am using the SparkFun fork of TensorFlow, which @liquid.soulder has been updating to work with the Edge 2 and the latest version of the Ambiq SDK.

Here are the steps I take:
Code: Select all
git clone https://github.com/sparkfun/tensorflow.git
cd tensorflow
gmake -f tensorflow/lite/experimental/micro/tools/make/Makefile TARGET=sparkfun_edge2 micro_speech_bin  
Oddly, I have to run this twice because I get a sed error. it works fine the second time.

I then use this command to flash the compiled bin. In order to flash, I need to pull the boot loader pin high. Follow the directions here: viewtopic.php?f=168&t=50825#p207893
Basically, connect a jump wire to 3.3v. Touch the other end to the right side of the resistor that is above LED 13. With this connection made, hit the reset button. Continue to keep the connection and then run the following command:
Code: Select all
python3 tensorflow/lite/experimental/micro/tools/make/downloads/AmbiqSuite-Rel2.2.0/boards_sfe/common/tools_sfe/ambiq/ambiq_bin2board.py --bin tensorflow/lite/experimental/micro/tools/make/gen/sparkfun_edge2_cortex-m4/bin/micro_speech.bin --load-address-blob 0x20000 --magic-num 0xCB -o main_nonsecure_ota --version 0x0 --load-address-wired 0xC000 -i 6 --options 0x1 -b 115200 -port /dev/cu.usbserial-1410 -r 2 -v

After doing all of that... all I get is the follow if I open up serial monitor:
Code: Select all
FPU Enabled.

PDM DMA Threshold = 16
I am going to go in and try modifying the Makefile to point to the correct BSP for the RedBoard. I will keep this thread updated as I make progress. If anyone has figured this out, please contribute!
User avatar
By robotastic
#209068
OK! I got MicroVoice working on a RedBoard!

It is still a little wonky... and there is some debug code in there that appears to be structural. There is some sort of timing or interrupt issue and if you remove the debug statements I added, it breaks. Those debug messages are in command_reciever.cc on lines 52, 56 & 60. I will try to hunt down the root cause, but wanted to pass this progress along because it is fun to play with.

My fork of the SparkFun branch is here: https://github.com/robotastic/tensorflo ... 7eb0cfe9d7

This code should build the bin:
Code: Select all
gmake -f tensorflow/lite/experimental/micro/tools/make/Makefile TARGET=sparkfun_redboard_artemis micro_speech_bin  
Use the flashing technique described above and the following command to flash:
Code: Select all
python3 tensorflow/lite/experimental/micro/tools/make/downloads/AmbiqSuite-Rel2.2.0/boards_sfe/common/tools_sfe/ambiq/ambiq_bin2board.py --bin tensorflow/lite/experimental/micro/tools/make/gen/sparkfun_redboard_artemis_cortex-m4/bin/micro_speech.bin --load-address-blob 0x20000 --magic-num 0xCB -o main_nonsecure_ota --version 0x0 --load-address-wired 0xC000 -i 6 --options 0x1 -b 115200 -port /dev/cu.usbserial-1410 -r 2 -v
Now, open up Serial Monitor and say Yes or No. I have found making it a really long Noooooo seems to help with recognition.
User avatar
By robotastic
#209385
I updated my code against the latest version of Tensorflow and things are working a lot more reliably. I have tested against the Redboard Artemis and Edge 2. Folks have also reported it work with the ATP. This is for the Micro-Voice example.

I also figured out that I was having trouble flashing the board and having to use a jumper wire because I didn't have a current version of the CH340 driver installed.

Checkout the sparkfun_artemis branch of this repo:
https://github.com/robotastic/tensorflo ... un_artemis
User avatar
By liquid.soulder
#215047
@robotastic - I never reached an acceptable conclusion, in my mind, about the issues we were having with the Artemis module based boards. I just wanted to check in with you about the status of your branch. Have you continued to use the micro_speech example on the RedBoard Artemis and or the RedBoard Artemis ATP?

I'm hoping that soon I will have some bandwidth open up to allow me to put those issues to rest so that we can be confident that all the Apollo3 based boards we sell are TFLu compatible.

Also thanks again for your hard work on this at the end of last year!
User avatar
By robotastic
#216295
@liquid.soulder I didn't keep running with it after I got it working... My branch of code is now way behind. I am now starting to work on TinyML for a new project though. I would be game to take another swing at it.

Now that Arduino is running on Artemis pretty reliably, would it be better to have TF Lite Micro compile for an Arduino target and then run the Arduino Library it generates? I am not sure if it would take a performance hit going the Arduino route. The benefit is that it would be a lot easier to pull in other sensors or hook it up to LoRa.
User avatar
By liquid.soulder
#216302
Good to hear back from you - in the time since you've been gone we got some PRs accepted into TFLu including both an update to the BSP repo that is used (so that more boards are available) and the inclusion of the Edge board in the Arduino library build.

I don't know whether the Arduino library has actually been updated in the Arduino Library Manager though (but you can build it yourself from the latest TFLu repo) Here are Pete Warden's instructions for building the Arduino library:
To generate the Arduino library, download the main repo at https://github.com/tensorflow/tensorflow and then run https://github.com/tensorflow/tensorflo ... arduino.sh
Furthermore the Artemis based boards still aren't included - I have been working on enabling them to run mbed os (releasing soon, stay tuned!) But with the addition of our new BSP repo into the default project it should be a lot easier.

The most worrying thing on my mind is of course the odd behavior that we were investigating last fall. (Hard faults etc...) If we can work past that then we should have a good foundation! I hope that I will be able to focus more on this as soon as we release mbed support. Keep me updated on anything interesting you find.

Cheers!
 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