Takayoshi Koizumi 885c55ca95 PR #46195: micro: Add Sony Spresense board target
Imported from GitHub PR https://github.com/tensorflow/tensorflow/pull/46195

Add build terget on Sony Spresense board.
To build it, Spresense SDK is required.
And hello_world, micro_speech and preson_detection are added for the board.

The related issue is #46240
Copybara import of the project:

--
bff4913f03be75a368c6845c448fdd2fe5624bb1 by Takayoshi Koizumi <takayoshi.koizumi@gmail.com>:

Add Sony Spresense board target

Add build terget on Sony Spresense board.
To build it, Spresense SDK is required.
And hello_world, micro_speech and preson_detection are added for the
board.

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/tensorflow/pull/46195 from takayoshi-k:add_spresense_target bff4913f03be75a368c6845c448fdd2fe5624bb1
PiperOrigin-RevId: 356357681
Change-Id: I4b62059ef27b47775431168536da563a56343a6d
2021-02-08 14:49:54 -08:00
..

Person detection example for Spresense

Here explaines how to build and execute this Person detection example for Spresense. To try this on the Spresense, below hardware is required.

Spresense Main board, which is a microcontroller board. Spresense Extention board, which is for connecting a mic like MEMS mic. Spresense Camera board, which is for sensing image

Table of contents

How to build

The tensorflow.git will be downloaded in build system of Spresense.

Initial setup

The Spresense SDK build system is required to build this example. The following instructions will help you to make it on your PC. Spresense SDK Getting Started Guide:EN Spresense SDK Getting Started Guide:JA Spresense SDK Getting Started Guide:CN

And after setup the build system, download Spresense repository.

git clone --recursive https://github.com/sonydevworld/spresense.git

Configure Spresense for this example

The Spresense SDK uses Kconfig mechanism for configuration of software components. So at first, you need to configure it for this example. Spresense SDK provides some default configurations, and there is a default config to build this Person detection example.

  1. Go to sdk/ directory in the repository.

    cd spresense/sdk
    
  2. Execute config.py to configure for this example.

    ./tools/config.py examples/tf_example_persondetection
    

This command creates .config file in spesense/nuttx directory.

Build and Flash the binary into Spresense Main board

After configured, execute make and then flash built image.

  1. Execute "make" command in the same directory you configured.

    make
    
  2. Flash built image into Spresense main board. If the build is successful, a file named nuttx.spk will be created in the current directory, and flash it into Spresense Main board. Make sure USB cable is connected between the board and your PC. The USB will be recognized as USB/serial device like /dev/ttyUSB0 in your PC. In this explanation, we will assume that the device is recognized as /dev/ttyUSB0.

    ./tools/flash.sh -c /dev/ttyUSB0 nuttx.spk
    

How to run

To run the example, connect to the device with a terminal soft like "minicom". Then you can see a "nsh>" prompt on it. (If you can't see the prompt, try to press enter.)

  1. Execute tf_example command on the prompt.

    nsh> tf_example
    
  2. Put a person's face in the camera image. Rate which is a face or not will print on the terminal as a result of the detection.