Showing posts with label Wireless. Show all posts
Showing posts with label Wireless. Show all posts

Friday, March 14, 2025

How to Build the TensorFlow Lite C API from Source Inside WSL

How to Build TensorFlow Lite C API from Source Inside WSL

TensorFlow Lite is a lightweight, efficient runtime for deploying machine learning models on edge devices. It's ideal for environments that are low-power and performance-critical such as embedded systems mobile devices, and microcontrollers.

Building the TensorFlow Lite C API from source inside Windows Subsystem for Linux (WSL) allows you to integrate AI inference into native C applications. This is useful when working on constrained devices, building low-level systems, or working with existing C/C++ codebases.

Step 1: Set Up WSL and Create a .wslconfig File (Optional)

+

To prevent Bazel crashes from memory exhaustion, increase the memory limit for WSL. First, Open the Terminal(Windows Powershell):

# On Windows (not WSL):
Create C:\Users\<yourname>\.wslconfig with the following content:

[wsl2]
memory=6GB
processors=4

To do this with Notepad:

  • Open the Start menu and type Notepad
  • Paste the above configuration text into the new file
  • Click File > Save As...
  • Set File name: .wslconfig
  • Set Save as type: to All Files
  • Save it to C:\Users\<yourname>\

Then from PowerShell:

wsl --shutdown

Step 2: Install Prerequisites

sudo apt update
sudo apt install -y build-essential clang git wget python3-pip

Step 3: Install Numpy

pip install numpy

Step 4: Install Bazelisk

wget https://github.com/bazelbuild/bazelisk/releases/download/v1.17.0/bazelisk-linux-amd64 -O bazelisk
chmod +x bazelisk
sudo mv bazelisk /usr/local/bin/bazelisk

Step 5: Set the Required Bazel Version

export USE_BAZEL_VERSION=5.3.0
echo 'export USE_BAZEL_VERSION=5.3.0' >> ~/.bashrc
source ~/.bashrc

Step 6: Clone TensorFlow and Check Out the Version

git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
git checkout v2.12.0

Step 7: Build TensorFlow Lite C API

Optional but recommended: limit RAM usage to avoid crashes.

export BAZEL_BUILD_OPTS="--local_ram_resources=2048"
cd tensorflow/tensorflow/lite/c
bazelisk build -c opt $BAZEL_BUILD_OPTS --define=flatbuffer_op_resolver=false //tensorflow/lite/c:libtensorflowlite_c.so

Step 8: Install the Library and Headers

cd ~/tensorflow
sudo cp bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so /usr/local/lib/
sudo ldconfig

# Copy required top-level headers
sudo mkdir -p /usr/local/include/tflite
sudo cp tensorflow/lite/c/c_api.h /usr/local/include/tflite/

# Copy all internal TensorFlow Lite C API dependencies
sudo mkdir -p /usr/local/include/tensorflow/lite/core/c
sudo cp tensorflow/lite/core/c/c_api.h /usr/local/include/tensorflow/lite/core/c/
sudo cp tensorflow/lite/core/c/c_api_types.h /usr/local/include/tensorflow/lite/core/c/

# Copy additional headers required by the C API
sudo mkdir -p /usr/local/include/tensorflow/lite
sudo cp tensorflow/lite/builtin_ops.h /usr/local/include/tensorflow/lite/

Step 9: Verify With a Simple C Program

#include "tflite/c_api.h"
#include <stdio.h>

int main() {
    TfLiteModel* model = TfLiteModelCreateFromFile("model.tflite");
    if (!model) {
        printf("Failed to load TensorFlow Lite model\n");
        return 1;
    }
    printf("TensorFlow Lite model loaded successfully!\n");
    TfLiteModelDelete(model);
    return 0;
}

Compile it with:

gcc -o tflite_test tflite_test.c -I/usr/local/include -L/usr/local/lib -ltensorflowlite_c
./tflite_test

Conclusion

Now that you’ve built the TensorFlow Lite C API from source inside WSL, you're ready to run AI inference directly in your C applications. This setup is ideal for embedded AI applications such as digital signal processing. By building from source, you gain control when integrating with systems where Python or heavy dependencies are incompatible.

Wednesday, July 17, 2024

Ezurio Development Board Kit Giveaway

Ezurio (formerly Laird Connectivity) is offering a development kit giveaway that includes a System on Module (SOM), a carrier board, a wireless module, and an antenna. Ezurio specializes in SOMs featuring NXP i.MX processors, including the i.MX 8M Mini, 8M Plus, and i.MX 93, with support for both Android and Linux. The giveaway also includes Sona WiFi 6/6E and Bluetooth LE modules.



Friday, November 27, 2020

Electronics Deals Black Friday 2020

Black Friday is a great time to get a new development board or some parts for a DIY electronics project.  Here are a few great online electronics stores where you can find deals.

Adafruit is having two sales, one is for 15% all items in stock with the code ADATHX see more details in the Adafruit Thanksgiving Weekend Sale blog post.  The Adafruit Feather line of development boards is 20% off today only with the same code, see Adafruit Feather Friday Sale for details.

Polulu has a few different Black Friday deals.  There are coupons for individual products, discounts on your entire order and the unique design your own deal sale.  Follow this link to Pololu Black Friday/Cyber Monday Sale 2020 for the details.

The design your own deal allows you to propose propose a discount for up to three products.  Last year I was able to get even bigger discounts than I asked for.  I don't recall the original prices but I was pleasantly surprised that they were all approved and discounted further.  Here are my three wishes and the deals I was offered.

You requested: 1 at $12.00 each.
We can do even better!  Up to 3 at $8.88 each.

You requested: 1 at $3.00 each.
We can do even better!  Up to 3 at $2.75 each.
   

You requested: 1 at $15.00 each.
We can do even better!  Up to 3 at $14.00 each.

SparkFun Black Friday Deals are discounts from 15 to 60 percent off select products.  There are not as many deals here but you might get lucky and find something you want.  You can also check out this sneak peak of Cyber Monday Deals.

At the Black Friday Sale on Tindie many development boards are discounted.  Tindie is a unique online store featuring independent sellers of all kinds of development boards and accessories for unique applications.   If you haven't been to this site before it's a great time to look around.

Friday, October 30, 2020

SparkFun A La Carte Custom Board Designer

SparkFun Electronics is offering a web based custom board design service called SparkFun A La Carte (ALC).  You can choose from a few different microcontrollers that can run Arduino programs.  You also have a choice of I/O, connectors and power options.  Communications options include RFID, WiFi and Bluetooth.  There is a one-time design fee for each board and a per unit cost calculated as you add the components.  You can get a 50% discount on the design fee until 12/31/2020 with the promocode ALCSPARKFUN50. For more information see this ALC post on the SparkFun Blog  

This YouTube video on the custom board designer goes over an example design.




Tuesday, February 23, 2016

TI Development Board Deals for Engineers Week 2016

This week the AM437x starter kit is only $99 ($149 off with coupon code EWKDEAL10).  It's engineers week and TI has 12 deals on it's best-selling products while supplies last.  There are deals on a few SensorTags, LaunchPads, BoosterPacks and EVMs.

The AM437x starter kit (TMDXSK437X) has a 4.3" capacitive touch screen LCD, on board camera module and connector for a Wilink8 evaluation board.  The Wilink8 bundle is also on sale for engineers week (coupon code EWKDEAL12), it supports WiFi, Bluetooth, and Bluetooth Low Energy and includes a Wilink8 EVN and an SDIO board to connect the wilink to hosts with generic SD/MMC card slots.

Friday, October 4, 2013

New Arduino Features 1GHz Texas Instruments Processor

The Arduino TRE Board is coming soon, an official Arduino open source prototyping platform.  Announced today on the TI E2E community site as the most powerful Arduino available to date.  It features the Texas Instruments Sitara AM3359 ARM Cortex-A8 processor.  This is the same processor used on TI's BeagleBone Black. It is clocked at 1GHz, and the board also has 512MB 800MHz DDR3, HDMI, 4-ports of  USB, audio I/O, XBee RF module Connectors and lots of I/O.  For Arduino shield compatibility, it has the shield connectors and also an Atmel ATmega32u4.  This board will also run embedded Linux. It is targeted to prototyping 3D printers, networking hubs for building control, lighting and telemetry, and DIY projects that require more processing power.


Monday, January 7, 2013

Start-up Develops Wireless iPod Controller for Smartphones

A former client, Tau Cygnus, sent me a note that a prototype I helped develop is ready for production.  The Cyborg dock makes use of an iPod and a smartphone (or tablet) to connect your audio system and to control it wirelessly.  The free app works with Apple, Android, Kindle Fire and Nook devices.  The iPod dock connects directly to your music system so there is no streaming or buffering of the audio.  The app runs on your wireless phone or tablet to browse and control playback remotely.  Visit www.cyborgdock.com for more details and see the video embedded below.  There is currently a funding campaign at www.indiegogo.com/cyborgdock to help start production.  In case you are wondering, I'm no longer working for Tau Cygnus and I'm not receiving any compensation for this post.




If you want to expand the capabilities of the Cyborg, "...we have opened up Cyborg for developers. An API is provided so third party developers can customize Cyborg - the API is provided for both Android and Apple platforms. Of course our base station software that you helped with is under the GNU license, so that is provided as well" (President of Tau Cygnus, Greg Smolinski).  For my part, I reviewed the schematics and layout, performed the board bring-up (not too much smoke), ported the bootloader, and ported the Linux OS to the system.  It looks like a lot of additional work has been put into this since those early prototypes were completed.  When you contribute to a project like this, it is great to see the finished product.  I hope it does well and people will enjoy using it.

Wednesday, September 26, 2012

New TI ARM Starter Kit Includes Display

Texas Instruments' new AM335x Starter Kit is now available for $199 featuring a 720MHz AM3358 ARM processor, 4.3 inch touch-screen/LCD, and dual-gigabit Ethernet with integrated switch.  This processor is in the same family as the Beaglebone's AM3359, so it should be easy to port software that is available for that popular platform.  TI already has Linux and Android software development kits for the 3.x kernel and ice cream sandwich respectively.  Here is a list of features from the starter kit's product page:
  • AM3358, 720Mhz
  • 256MB DDR3
  • 4.3” Touch screen LCD
  • Dual Gigabit Ethernet Ports with integrated switch
  • WiFi WL1271 with Wifi Direct Support’
  • Bluetooth®
  • USB-UART
  • USB-XDS100 emulator
  • Android navigation buttons
  • User configured LEDs
  • Audio Out
UPDATE: There is now an AM335x Starter Kit Page on the Texas Instruments Wiki  for developers with software and development tool downloads and design files.

You can purchase from the TI e-store, Avnet, DigiKey or Mouser, all have it in stock at the time of writing.  The part number is TMDSSK3358.

Introducing the Sitara AM335x Starter Kit

Saturday, June 30, 2012

Google Reimagines the Development Board

The ADK 2012 platform is packed with innovation and usable code for Android accessory development.



They advertise that all of the code is open source and with a less restrictive license like BSD so you can include it in your products. Here are the main libraries:
  • Bluetooth stack (BSD license) with libraries for RFCOMM, A2DP,L2CAP, SDP
  • Multimedia library including an ogg player
  • MicroSD SD/SDHC driver with FAT12/RAT16/FAT32
  • USB Host stack with Android open accessory protocol implementation

All of this runs on the Atmel SAM3X ARM Cortex-M3 processor with 512kB flash, 100kB RAM, and bluetooth is provide by a Texas Instruments CC2564. There are also sensors for light, proximity, acceleration, magnetism, temperature, humidity, barometric pressure, and other toys like a capacitive slider and buttons, RGB LEDs including the 7 segment display, a transducer speaker, and an NFC tag.

For more info, here is the developer's guide from google Accesory Development Kit 2012 Guide. A little more info about the Arduino IDE (for an ARM processor) it uses on the Arduino blog.

The surprise at the end of the video is that an ADK 2012 was given to each attendee of this talk, and the device is not for sale (yet). If you really want one, try e-bay, currently the best price is an auction at $400 US. If are lucky enough to have one here is the Android app from google play.

Tuesday, March 6, 2012

Tiny Serial WiFi Module Includes ARM Cortex M3

The Inventek Systems 802.11 b/g/n Serial to WiFi module makes it easy to add Wi-Fi to your embedded design.  It can be programmed from a host with a choice of serial interfaces using a simple AT command set.



These serial interfaces are provided by an STM32 ARM Cortex M3 processor as shown on the block diagram.  No software development is required for the STM32, the AT command set interface is resident in firmware.  This means your host microcontroller does not need a TCP/IP stack or RTOS.  This simplifies software development for your application - you only need to write serial I/O code to send the AT commands and process data.

An embedded wireless evaluation board is available that make it easy to connect the module to your microcontroller board for development of your WiFi application.  Both the evaluation board and the module are available from the Inventek Systems online store.


For more information on the module and evaluation board watch this video that includes a description of the functional block diagram above.


Thursday, December 22, 2011

Robotshop Taking Over The World's Robots

Robotshop is already the leading source for robots, now they want to control all of them with the MyRobots.com portal. The service is currently in beta, but free, so you might want to register now to try it out. The site lets you monitor and control your internet enabled robot with an open API.  If your robot doesn't have an internet connection, the MyRobots Connect kit will let you access the serial port of with an XBee wireless transceiver.

Another part of MyRobots.com that is under development is the Robot App Store, where you can sell your robot enabled apps that can run on the robot or in the cloud.

Of course, if you don't yet have a robot, you can buy one already compatible with the site from Robotshop.  Shown below is the Arduino compatible DFRobotShop Rover.  They have a lot more than robots, including development boards, soldering equipment, 3D printers and test instruments.

Wednesday, December 14, 2011

CadSoft Eagle 6 Release

Cadsoft has released Eagle 6 and their sluggish site may indicate it's increasing popularity.  Eagle has been popular for it's low cost and free versions, especially with DIY electronics enthusiasts and students.  You can even get a skill badge with the Eagle Logo from Adafruit.


Eagle's low cost and popularity with DIYers may be helping it gain support in industry.  For example, Texas Instruments provides a library of symbols and footprints for the MSP430 for use with Eagle.  TI also provides schematics and layout for its $4.30US MSP430 LaunchPad development board in Eagle format.


LaunchPad Schematic and PCB Trace (Created using Eagle) | Download Now

Shown above is the LaunchPad with a transciever daughterboard from the $19 RF BoosterPack and a blurb from TI about eagle support.  If you are interested in MSP430 development on other boards than the LaunchPad, tideals.com is featuring a USB Debugger/board bundle.