-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Paul Guyot <pguyot@kallisys.net>
- Loading branch information
0 parents
commit 435ab29
Showing
20 changed files
with
1,370 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# SPDX-License-Identifier: MIT | ||
name: Build | ||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
soc: ["esp32", "esp32c3", "esp32s2", "esp32s3", "esp32c6"] | ||
idf-version: | ||
- 'v5.1.3' | ||
- 'v5.2.1' | ||
otp: | ||
- "26" | ||
elixir_version: | ||
- "1.16" | ||
|
||
container: espressif/idf:release-v5.2 | ||
steps: | ||
- name: Checkout AtomVM | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: atomvm/AtomVM | ||
path: AtomVM | ||
|
||
- name: Checkout atomvm_esp_adf | ||
uses: actions/checkout@v3 | ||
with: | ||
path: AtomVM/src/platform/esp32/components/ | ||
|
||
- uses: erlef/setup-beam@v1 | ||
with: | ||
otp-version: ${{ matrix.otp }} | ||
elixir-version: ${{ matrix.elixir_version }} | ||
|
||
- name: Install dependencies to build host AtomVM | ||
run: | | ||
set -eu | ||
apt update | ||
DEBIAN_FRONTEND=noninteractive apt install -y -q \ | ||
doxygen \ | ||
libglib2.0-0 libpixman-1-0 \ | ||
gcc g++ zlib1g-dev libsdl2-2.0-0 libslirp0 libmbedtls-dev | ||
# needed for generating AtomVM version when running in a docker container | ||
- name: Configure Git | ||
run: | | ||
git config --global --add safe.directory /__w/AtomVM/AtomVM | ||
echo -n "git rev-parse: " | ||
git rev-parse --short HEAD | ||
- name: Build AtomVM libraries | ||
shell: bash | ||
working-directory: AtomVM/ | ||
run: | | ||
mkdir build | ||
cd build | ||
cmake .. | ||
cd libs | ||
make | ||
- name: Build ${{ matrix.soc }} binary with idf.py | ||
shell: bash | ||
working-directory: AtomVM/src/platforms/esp32/ | ||
run: | | ||
cp sdkconfig.release-defaults sdkconfig.defaults | ||
rm -rf build | ||
. $IDF_PATH/export.sh | ||
idf.py set-target ${{ matrix.soc }} | ||
idf.py reconfigure | ||
idf.py build | ||
- name: "Create a ${{ matrix.soc }} image" | ||
working-directory: ./src/platforms/esp32/build | ||
run: | | ||
./mkimage.sh | ||
ls -l *.img | ||
- name: "Upload ${{ matrix.soc }} artifacts" | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: atomvm-${{ matrix.soc }}-image | ||
path: ./src/platforms/esp32/build/atomvm-${{ matrix.soc }}.img | ||
if-no-files-found: error | ||
|
||
build-doc: | ||
runs-on: ubuntu-latest | ||
container: erlang:26 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Pages | ||
uses: actions/configure-pages@v3 | ||
- name: Build edoc | ||
run: | | ||
rebar3 edoc | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v1 | ||
with: | ||
path: doc | ||
|
||
clang-format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install clang-format | ||
run: | | ||
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" | ||
- name: Install run-clang-format | ||
run: | | ||
curl -sSfL https://raw.githubusercontent.com/Sarcasm/run-clang-format/master/run-clang-format.py -o run-clang-format | ||
chmod +x run-clang-format | ||
- name: Check format with clang-format | ||
run: | | ||
./run-clang-format --style=file -r nifs/ | ||
erlfmt: | ||
runs-on: ubuntu-latest | ||
container: erlang:26 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Checkout erlfmt | ||
run: | | ||
cd .. | ||
git clone --depth 1 -b v1.1.0 https://github.com/WhatsApp/erlfmt.git | ||
cd erlfmt | ||
rebar3 as release escriptize | ||
- name: Check format with erlfmt | ||
run: | | ||
find . -name *.erl | xargs ../erlfmt/_build/release/bin/erlfmt -c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Object files | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Linker output | ||
*.ilk | ||
*.map | ||
*.exp | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
# Debug files | ||
*.dSYM/ | ||
*.su | ||
*.idb | ||
*.pdb | ||
|
||
# Kernel Module Compile Results | ||
*.mod* | ||
*.cmd | ||
.tmp_versions/ | ||
modules.order | ||
Module.symvers | ||
Mkfile.old | ||
dkms.conf | ||
|
||
# macOS | ||
.DS_Store | ||
|
||
# rebar3 | ||
_build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "components/esp-adf"] | ||
path = components/esp-adf | ||
url = https://github.com/espressif/esp-adf.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# | ||
# This file is part of AtomVM. | ||
# | ||
# Copyright 2024 Paul Guyot <pguyot@kallisys.net> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later | ||
# | ||
|
||
set(ATOMVM_ESP_AUDIO_COMPONENT_SRCS | ||
"nifs/atomvm_esp_adf_audio_element.c" | ||
"nifs/atomvm_esp_adf_audio_pipeline.c" | ||
"nifs/atomvm_esp_adf_i2s_output.c" | ||
"nifs/atomvm_esp_adf_mp3_decoder.c" | ||
) | ||
|
||
# WHOLE_ARCHIVE option is supported only with esp-idf 5.x | ||
# A link option will be used with esp-idf 4.x | ||
if (IDF_VERSION_MAJOR EQUAL 5) | ||
set(OPTIONAL_WHOLE_ARCHIVE WHOLE_ARCHIVE) | ||
else() | ||
set(OPTIONAL_WHOLE_ARCHIVE "") | ||
endif() | ||
|
||
idf_component_register( | ||
SRCS ${ATOMVM_ESP_AUDIO_COMPONENT_SRCS} | ||
INCLUDE_DIRS "nifs/include" | ||
PRIV_REQUIRES "libatomvm" "avm_sys" "driver" "audio_pipeline" | ||
${OPTIONAL_WHOLE_ARCHIVE} | ||
) | ||
|
||
if (IDF_VERSION_MAJOR EQUAL 4) | ||
idf_build_set_property( | ||
LINK_OPTIONS "-Wl,--whole-archive ${CMAKE_CURRENT_BINARY_DIR}/lib${COMPONENT_NAME}.a -Wl,--no-whole-archive" | ||
APPEND) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# SPDX-License-Identifier: MIT | ||
|
||
menu "ATOMVM_ESP_ADF Configuration" | ||
|
||
config AVM_ESP_ADF_AUDIO_ELEMENT_ENABLE | ||
bool "Enable AtomVM esp adf audio element driver" | ||
default y | ||
|
||
config AVM_ESP_ADF_AUDIO_PIPELINE_ENABLE | ||
bool "Enable AtomVM esp adf audio pipeline" | ||
default y | ||
depends on AVM_ESP_ADF_AUDIO_ELEMENT_ENABLE | ||
|
||
config AVM_ESP_ADF_I2S_OUTPUT_ENABLE | ||
bool "Enable AtomVM esp adf i2s output" | ||
default y | ||
depends on AVM_ESP_ADF_AUDIO_ELEMENT_ENABLE | ||
|
||
config AVM_ESP_ADF_MP3_DECODER_ENABLE | ||
bool "Enable AtomVM esp adf mp3 decoder" | ||
default y | ||
depends on AVM_ESP_ADF_AUDIO_ELEMENT_ENABLE | ||
|
||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Paul Guyot <pguyot@kallisys.net> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# AtomVM driver for Espressif Audio Framework | ||
|
||
## Usage: | ||
|
||
1. Clone this repository into atomvm/src/platforms/esp32/components with submodules | ||
|
||
```bash | ||
cd AtomVM/src/platforms/esp32/components/ | ||
git clone --recurse-submodules https://github.com/pguyot/atomvm_esp_adf.git | ||
``` | ||
|
||
2. Build and flash AtomVM | ||
|
||
Use a command sequence such as: (port name depends on OS) | ||
|
||
```bash | ||
cd AtomVM/src/platforms/esp32/ | ||
idf.py build | ||
idf.py -p /dev/cu.usbmodem14401 flash | ||
``` | ||
|
||
3. Use `atomvm_esp_adf_*` modules in your code. | ||
|
||
```erlang | ||
AudioPipeline = esp_adf_audio_pipeline:init([]), | ||
|
||
MP3File = atomvm:read_priv(?MODULE, "adf_music.mp3"), | ||
MP3Decoder = esp_adf_mp3_decoder:init([]), | ||
ok = esp_adf_audio_element:set_read_binary(MP3Decoder, MP3File), | ||
ok = esp_adf_audio_pipeline:register(AudioPipeline, MP3Decoder, <<"mp3">>), | ||
|
||
I2SOutput = esp_adf_i2s_output:init([{gpio_bclk, ?MAX_BCLK_GPIO}, {gpio_lrclk, ?MAX_LRC_GPIO}, {gpio_dout, ?MAX_DIN_GPIO}]), | ||
ok = esp_adf_audio_pipeline:register(AudioPipeline, I2SOutput, <<"i2s">>), | ||
|
||
ok = esp_adf_audio_pipeline:link(AudioPipeline, [<<"mp3">>, <<"i2s">>]), | ||
|
||
ok = esp_adf_audio_pipeline:run(AudioPipeline), | ||
|
||
... | ||
|
||
ok = esp_adf_audio_pipeline:stop(AudioPipeline), | ||
ok = esp_adf_audio_pipeline:wait_for_stop(AudioPipeline), | ||
ok = esp_adf_audio_pipeline:terminate(AudioPipeline), | ||
ok = esp_adf_audio_pipeline:unregister(AudioPipeline, MP3Decoder), | ||
ok = esp_adf_audio_pipeline:unregister(AudioPipeline, I2SOutput), | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
COMPONENT_ADD_INCLUDEDIRS := nifs/include | ||
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive | ||
COMPONENT_SRCDIRS := nifs | ||
CXXFLAGS += -fno-rtti |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## IDF Component Manager Manifest File | ||
dependencies: | ||
## Required IDF version | ||
idf: | ||
version: ">=4.1.0" | ||
audio_pipeline: | ||
path: components/esp-adf/components/audio_pipeline | ||
audio_sal: | ||
path: components/esp-adf/components/audio_sal | ||
esp-adf-libs: | ||
path: components/esp-adf/components/esp-adf-libs |
Oops, something went wrong.