Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script changes #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ Notes:
**device** variables are replaced when building the project - others will take
default values if unspecified.

## Prerequisites
* MPLAB® X IDE *>=6.00* (https://microchip.com/mplab/mplab-x-ide)
* XCode *>=12.0* (https://developer.apple.com/xcode/)
* Edge Impulse CLI (https://github.com/edgeimpulse/edge-impulse-cli)
* Edge Impulse Stand-alone Inferencing (C++) (https://github.com/edgeimpulse/example-standalone-inferencing)
* Docker (https://www.docker.com/)
* Docker Compose (https://docs.docker.com/compose/)
* Python *>=3.6* (https://www.python.org/downloads/)




## Software Used
* MPLAB® X IDE *>=6.00* (https://microchip.com/mplab/mplab-x-ide)

Expand Down Expand Up @@ -43,6 +55,11 @@ The following steps cover compiling the Edge Impulse library into a static libra
MPLABX_VERSION=6.00 XC_VERSION=4.00 XC_NUMBER_BITS=32 ./build.sh ATSAME54P20A libedgeimpulse .
```

On OSX:
```bash
MPLABX_VERSION=6.15 XC_VERSION=4.35 OS_TYPE=osx Executable_TYPE=dmg XC_NUMBER_BITS=32 ./build.sh ATSAME54P20A libedgeimpulse .
```

If MPLAB X or the XC compiler are in non-default install locations, set the
corresponding path directly through the `MPLABX_PATH` and `XC_PATH`
environment variables.
Expand Down
70 changes: 36 additions & 34 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ if [ "$#" -lt 2 ]; then
exit 1
fi

#%% Environment
test -n ${XC_NUMBER_BITS} \
|| ( test -n ${PRJ_PROJECT_FILE} \
&& test -n ${PRJ_OPTIONS_FILE} \
&& test -n ${XC_PATH} )
#%% Environment checks
test -n ${XC_NUMBER_BITS} ||
(test -n ${PRJ_PROJECT_FILE} &&
test -n ${PRJ_OPTIONS_FILE} &&
test -n ${XC_PATH})

#%% Build options
PRJ_TARGET=${1}
Expand All @@ -23,8 +23,8 @@ DSTDIR=${3:-.}
: ${PRJ_CMSIS_DSP:=1}
: ${PRJ_BUILD_AS_CPP:=1}

test -e "${PRJ_OPTIONS_FILE}" \
&& test -e "${PRJ_PROJECT_FILE}"
test -e "${PRJ_OPTIONS_FILE}" &&
test -e "${PRJ_PROJECT_FILE}"

#%% Tool paths
if [ "${OS}" = "Windows_NT" ]; then
Expand All @@ -40,22 +40,22 @@ fi

if [ -z "${MPLABX_PATH}" ] && [ -z "${MPLABX_VERSION}" ] && [ -e "${MPLABX_ROOT}" ]; then
# Select latest installed version
MPLABX_VERSION=$(\
find "${MPLABX_ROOT}" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; \
| sed -n 's/^v\([0-9]\+\.[0-9]\+\)$/\1/p' \
| sort -gr | head -n1 \
)
MPLABX_VERSION=$(
find "${MPLABX_ROOT}" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; |
sed -n 's/^v\([0-9]\+\.[0-9]\+\)$/\1/p' |
sort -gr | head -n1
)
fi

: ${MPLABX_PATH:="${MPLABX_ROOT}/v${MPLABX_VERSION}/mplab_platform/bin"}

if [ -z "${XC_PATH}" ] && [ -z "${XC_VERSION}" ] && [ -e "${XC_ROOT}" ]; then
# Select latest installed version
XC_VERSION=$(\
find "${XC_ROOT}" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; \
| sed -n 's/^v\([0-9]\+\.[0-9]\+\)$/\1/p' \
| sort -gr | head -n1 \
)
XC_VERSION=$(
find "${XC_ROOT}" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; |
sed -n 's/^v\([0-9]\+\.[0-9]\+\)$/\1/p' |
sort -gr | head -n1
)
fi

: ${XC_PATH:="${XC_ROOT}/v${XC_VERSION}/bin"}
Expand All @@ -82,7 +82,7 @@ if [ "${PRJ_BUILD_LIB}" -eq 0 ]; then
# Add generic implementation files
printf '%s\n' \
src/ \
>> "${SOURCE_LIST_FILE}"
>>"${SOURCE_LIST_FILE}"
fi

# This list is directly pulled from here:
Expand All @@ -93,14 +93,16 @@ printf '%s\n' \
edge-impulse-sdk/dsp/kissfft/*.cpp \
edge-impulse-sdk/dsp/dct/*.cpp \
edge-impulse-sdk/dsp/memory.cpp \
edge-impulse-sdk/porting/posix/*.c* \
edge-impulse-sdk/porting/mingw32/*.c* \
edge-impulse-sdk/tensorflow/lite/kernels/*.cc \
edge-impulse-sdk/tensorflow/lite/kernels/internal/*.cc \
edge-impulse-sdk/tensorflow/lite/micro/kernels/*.cc \
edge-impulse-sdk/tensorflow/lite/micro/*.cc \
edge-impulse-sdk/tensorflow/lite/micro/memory_planner/*.cc \
edge-impulse-sdk/tensorflow/lite/core/api/*.cc \
edge-impulse-sdk/tensorflow/lite/c/common.c \
>> "${SOURCE_LIST_FILE}"
>>"${SOURCE_LIST_FILE}"

if [ "$PRJ_BUILD_AS_CPP" -eq 0 ]; then
printf '%s\n' \
Expand All @@ -119,7 +121,7 @@ if [ "$PRJ_CMSIS_NN" -eq 1 ]; then
edge-impulse-sdk/CMSIS/NN/Source/ReshapeFunctions/*.c \
edge-impulse-sdk/CMSIS/NN/Source/SoftmaxFunctions/*.c \
edge-impulse-sdk/CMSIS/NN/Source/SVDFunctions/*.c \
>> "${SOURCE_LIST_FILE}"
>>"${SOURCE_LIST_FILE}"
fi
if [ "$PRJ_CMSIS_DSP" -eq 1 ]; then
printf '%s\n' \
Expand All @@ -131,12 +133,12 @@ if [ "$PRJ_CMSIS_DSP" -eq 1 ]; then
edge-impulse-sdk/CMSIS/DSP/Source/CommonTables/*.c \
edge-impulse-sdk/CMSIS/DSP/Source/TransformFunctions/*bit*.c \
edge-impulse-sdk/CMSIS/DSP/Source/SupportFunctions/*.c \
>> "${SOURCE_LIST_FILE}"
>>"${SOURCE_LIST_FILE}"
fi
set -x

# (Make paths relative to project dir)
echo "$(cat ${SOURCE_LIST_FILE} | awk '{print "../" $0}')" > "${SOURCE_LIST_FILE}"
echo "$(cat ${SOURCE_LIST_FILE} | awk '{print "../" $0}')" >"${SOURCE_LIST_FILE}"

#%% Create project
rm -rf ${PRJ_NAME}.X
Expand All @@ -149,7 +151,7 @@ rm -rf ${PRJ_NAME}.X

# (Change project to library type (3) manually)
if [ "${PRJ_BUILD_LIB}" -ne 0 ]; then
echo "$(cat ${PRJ_NAME}.X/nbproject/configurations.xml | sed 's|\(<conf name="default" type="\)[0-9]\+|\13|g')" > "${PRJ_NAME}".X/nbproject/configurations.xml
echo "$(cat ${PRJ_NAME}.X/nbproject/configurations.xml | sed 's|\(<conf name="default" type="\)[0-9]\+|\13|g')" >"${PRJ_NAME}".X/nbproject/configurations.xml
fi

#%% Add files
Expand All @@ -159,17 +161,17 @@ fi

#%% Finalize project
if [ "${PRJ_BUILD_LIB}" -ne 0 ]; then
cd "${PRJ_NAME}".X \
&& "${MAKE}" \
&& cp $(find . -name "${PRJ_NAME}.X.a") ../"${PRJ_NAME}".a \
&& cd ..
cd "${PRJ_NAME}".X &&
"${MAKE}" &&
cp $(find . -name "${PRJ_NAME}.X.a") ../"${PRJ_NAME}".a &&
cd ..
fi

if [ "$(readlink -f ${DSTDIR})" != "$PWD" ]; then
mkdir -p "${DSTDIR}" \
&& mv \
$(test -e "${PRJ_NAME}.a" && echo "${PRJ_NAME}.a") \
*.X \
src edge-impulse-sdk tflite-model model-parameters \
"${DSTDIR}"
fi
mkdir -p "${DSTDIR}" &&
mv \
$(test -e "${PRJ_NAME}.a" && echo "${PRJ_NAME}.a") \
*.X \
src edge-impulse-sdk tflite-model model-parameters \
"${DSTDIR}"
fi