Skip to content

Commit

Permalink
Merge branch 'bugfix/xtensa_defines' into 'master'
Browse files Browse the repository at this point in the history
Fix compilation for IDF <=4.2, run CI builds with multiple IDF versions

See merge request idf/esp-dsp!57
  • Loading branch information
igrr committed Jul 15, 2021
2 parents 1c8447a + ed33103 commit 3175e82
Show file tree
Hide file tree
Showing 20 changed files with 176 additions and 139 deletions.
88 changes: 43 additions & 45 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ variables:

ESP_IDF_GIT: "https://gitlab-ci-token:${CI_JOB_TOKEN}@${GITLAB_HTTPS_SERVER}/espressif/esp-idf.git"

.setup_idf_tools: &setup_idf_tools |
cd esp-idf
# tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1

.add_gh_key_remote: &add_gh_key_remote |
command -v ssh-agent >/dev/null || exit 1
eval $(ssh-agent -s)
Expand All @@ -34,51 +30,53 @@ after_script:
# Just for cleaning space, no other causes
- git clean -ffdx

build:

# This template gets expanded multiple times, once for every IDF version.
# IDF version is specified by setting the espressif/idf image tag.
#
# EXAMPLE_TARGETS sets the list of IDF_TARGET values to build examples for.
# It should be equal to the list of targets supported by the specific IDF version.
#
# TEST_TARGETS sets the list of IDF_TARGET values to build the test_app for.
# It should contain only the targets with optimized assembly implementations.
#
.build_template:
stage: build
tags:
- build
- internet
script:
# Get ESP-IDF
- dir
- git clone ${ESP_IDF_GIT} esp-idf
- dir
- pushd esp-idf
- dir
# Non-recursive getting its submodules
- git submodule update --init
- dir
- export IDF_PATH=$PWD
- dir
#- *setup_idf_tools
- dir
- ./tools/ci/mirror-submodule-update.sh

- source /opt/pyenv/activate
- pyenv global $(pyenv versions --bare)
- ./tools/idf_tools.py --non-interactive install-python-env
- ./tools/idf_tools.py --non-interactive install

- idf_exports=$(${IDF_PATH}/tools/idf_tools.py --non-interactive export)
- eval "${idf_exports}"
- popd

# Create a copy of the project in "esp-dsp" directory.
# This is needed because CMake build system can not build a component
# when ESP-IDF directory is inside the component.
# After cloning, we will have two directories at the same level: "esp-idf" and "esp-dsp"
- git clone $PWD esp-dsp
- cd esp-dsp

# Build test app by both Makefiles and CMake ways
- pushd test_app
- make defconfig && make
- rm -rf build
- idf.py build
- popd

# Build examples
- ./build_examples.sh
- ./build_all.sh
variables:
EXAMPLE_TARGETS: "esp32"
TEST_TARGETS: "esp32"

build_idf_v4.0:
extends: .build_template
image: espressif/idf:release-v4.0

build_idf_v4.1:
extends: .build_template
image: espressif/idf:release-v4.1

build_idf_v4.2:
extends: .build_template
image: espressif/idf:release-v4.2
variables:
EXAMPLE_TARGETS: "esp32 esp32s2"

build_idf_v4.3:
extends: .build_template
image: espressif/idf:release-v4.3
variables:
EXAMPLE_TARGETS: "esp32 esp32s2"

build_idf_latest:
extends: .build_template
image: espressif/idf:latest
variables:
EXAMPLE_TARGETS: "esp32 esp32s2 esp32s3"
TEST_TARGETS: "esp32 esp32s3"

build_docs:
stage: build
Expand Down
16 changes: 12 additions & 4 deletions Kconfig
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
menu "DSP Library"


config DSP_OPTIMIZATIONS_SUPPORTED
bool
default y
depends on IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3

choice DSP_OPTIMIZATION
bool "DSP Optimization for ESP32"
default DSP_OPTIMIZED
bool "DSP Optimization"
default DSP_OPTIMIZED if DSP_OPTIMIZATIONS_SUPPORTED
default DSP_ANSI
help
An Ansi C version could be used for verification and debug purpose.
An ANSI C version could be used for verification and debug purpose,
or for chips where an optimized version is not available.

config DSP_ANSI
bool "ANSI C"
config DSP_OPTIMIZED
bool "ESP32 Optimized"
bool "Optimized"
depends on DSP_OPTIMIZATIONS_SUPPORTED
endchoice

config DSP_OPTIMIZATION
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Espressif DSP Library

ESP-DSP is the official DSP library for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview) chip and for the [ESP32S3](https://espressif.com/en/products/hardware/esp32s3/overview) chip.
ESP-DSP is the official DSP library for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview) chip and for the [ESP32-S3](https://espressif.com/en/products/hardware/esp32s3/overview) chip.

## Overview

Expand Down Expand Up @@ -28,7 +28,7 @@ Documentation found in the above links is automatically generated from the conte

## Installation and Usage

The ESP-DSP library is a component for the [ESP-IDF build system](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html). It also works with the [new CMake-based build system](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system-cmake.html).
The ESP-DSP library is a component for the [ESP-IDF build system](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html). It also works for ESP32 with the [legacy GNU Make-based build system](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system-legacy.html).

### Trying out ESP-DSP examples

Expand All @@ -37,10 +37,6 @@ If you haven't created an ESP-IDF project yet, and wish to try the examples prov
cd ~/esp
git clone https://github.com/espressif/esp-dsp.git
cd esp-dsp/examples/dotprod
make -j4 flash monitor ESPPORT=PORT

or, if you are using CMake based build system,

idf.py -p PORT flash monitor

where `PORT` is the UART port name of your development board, such as `/dev/ttyUSB0` or `COM1`.
Expand Down Expand Up @@ -68,4 +64,4 @@ For general questions related to this library, please use the [esp32.com forum](

## Copyrights and License

All original source code in this repository is Copyright (C) 2018-2019 Espressif Systems. This source code is licensed under the Apache License 2.0 as described in the file LICENSE.
All original source code in this repository is Copyright (C) 2018-2021 Espressif Systems. This source code is licensed under the Apache License 2.0 as described in the file LICENSE.
81 changes: 81 additions & 0 deletions build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
#
# Build the test app and all examples from the examples directory.
# Expects EXAMPLE_TARGETS and TEST_TARGETS environment variables to be set.
# Each variable is the list of IDF_TARGET values to build the examples and
# the test app for, respectively.
#
# -----------------------------------------------------------------------------
# Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).

if [[ -n "${DEBUG_SHELL}" ]]
then
set -x # Activate the expand mode if DEBUG is anything but empty.
fi

if [[ -z "${EXAMPLE_TARGETS}" || -z "${TEST_TARGETS}" ]]
then
echo "EXAMPLE_TARGETS and TEST_TARGETS environment variables must be set before calling this script"
exit 1
fi

set -o errexit # Exit if command failed.
set -o pipefail # Exit if pipe failed.
set -o nounset # Exit if variable not set.


STARS='***************************************************'

# -----------------------------------------------------------------------------

die() {
echo "${1:-"Unknown Error"}" 1>&2
exit 1
}

# build_for_targets <target list>
# call this in the project directory
function build_for_targets
{
target_list="$1"
for IDF_TARGET in ${target_list}
do
export IDF_TARGET
if [[ "${IDF_TARGET}" = "esp32" ]]
then
echo "${STARS}"
echo "Building in $PWD with Make"
# -j option will be set via MAKEFLAGS in .gitlab-ci.yml
# shellcheck disable=SC2015
make defconfig && make || die "Make build in ${PWD} has failed"
rm -rf build
fi

echo "${STARS}"
echo "Building in $PWD with CMake for ${IDF_TARGET}"
if [[ ${IDF_TARGET} != "esp32" ]]
then
# IDF 4.0 doesn't support idf.py set-target, and only supports esp32.
idf.py set-target "${IDF_TARGET}"
fi
idf.py build || die "CMake build in ${PWD} has failed for ${IDF_TARGET}"
idf.py fullclean
done
}

# Build the test app
echo "${STARS}"
pushd test_app
build_for_targets "${TEST_TARGETS}"
popd

# Build the examples
pushd examples
EXAMPLES=$(find . -maxdepth 1 -mindepth 1 -type d | cut -d '/' -f 2)
for NAME in ${EXAMPLES}
do
pushd "${NAME}"
build_for_targets "${EXAMPLE_TARGETS}"
popd
done
popd
56 changes: 0 additions & 56 deletions build_examples.sh

This file was deleted.

8 changes: 8 additions & 0 deletions modules/common/include/dsp_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#ifndef _DSP_TESTS_H_
#define _DSP_TESTS_H_

#include <stdlib.h>
#include "esp_idf_version.h"

#define TEST_ASSERT_EXEC_IN_RANGE(min_exec, max_exec, actual) \
if (actual >= max_exec) { \
ESP_LOGE("", "Time error. Expected max: %i, reached: %i", (int)max_exec, (int)actual);\
Expand All @@ -26,4 +29,9 @@
}


// memalign function is implemented in IDF 4.3 and later
#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(4, 3, 0)
#define memalign(align_, size_) malloc(size_)
#endif

#endif // _DSP_TESTS_H_
4 changes: 2 additions & 2 deletions modules/conv/include/dsps_conv_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

#include "sdkconfig.h"

#ifdef CONFIG_IDF_TARGET_ARCH_XTENSA
#ifdef __XTENSA__
#include <xtensa/config/core-isa.h>
#include <xtensa/config/core-matmap.h>
#endif


#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
Expand All @@ -16,5 +15,6 @@
#define dsps_corr_f32_ae32_enabled 1

#endif
#endif // __XTENSA__

#endif // _dsps_conv_platform_H_
4 changes: 2 additions & 2 deletions modules/dotprod/include/dspi_dotprod_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

#include "sdkconfig.h"

#ifdef CONFIG_IDF_TARGET_ARCH_XTENSA
#ifdef __XTENSA__
#include <xtensa/config/core-isa.h>
#include <xtensa/config/core-matmap.h>
#endif


#if CONFIG_IDF_TARGET_ESP32S3
#define dspi_dotprod_aes3_enabled 1
#endif
#endif // __XTENSA__

#endif // _dspi_dotprod_platform_H_
5 changes: 3 additions & 2 deletions modules/dotprod/include/dsps_dotprod_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

#include "sdkconfig.h"

#ifdef CONFIG_IDF_TARGET_ARCH_XTENSA
#ifdef __XTENSA__
#include <xtensa/config/core-isa.h>
#include <xtensa/config/core-matmap.h>
#endif


#if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1))
Expand All @@ -21,11 +20,13 @@
#define dsps_dotprod_s16_ae32_enabled 1

#endif //
#endif // __XTENSA__


#if CONFIG_IDF_TARGET_ESP32S3
#define dsps_dotprod_s16_aes3_enabled 1
#define dsps_dotprod_f32_aes3_enabled 1
#endif


#endif // _dsps_dotprod_platform_H_
Loading

0 comments on commit 3175e82

Please sign in to comment.