Compare commits

..

17 commits

Author SHA1 Message Date
Alin Jerpelea
10c75df01c rename DISCLAIMER-WIP
Before graduation We can only remove the WIP from the DISCLAIMER.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-06-07 19:30:41 +08:00
Alin Jerpelea
bc6f5d6fd7 Revert "remove DISCLAIMER-WIP"
This reverts commit 4a2aa6d8cf.
2022-06-07 09:28:15 +02:00
Alin Jerpelea
ecd8a9722f nxstyle fixes
fixes for nxstyle errors reported by CI

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
3de5b9531a LICENSE: add license for chat
document the license in the LICENSE file

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
71c21c8be1 LICENSE: add license for wapi
document the license in the LICENSE file

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
bcbcbd4920 LICENSE: add license for gpsutils
document the license in the LICENSE file

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
0d99dfecdb LICENSE: add license for netutils
document the license in the LICENSE file

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
3a931940e1 LICENSE: add license for zmodem
document the license in the LICENSE file

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
7ff9afab0d LICENSE: add license for ubloxmodem
document the license in the LICENSE file

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
256e59064e LICENSE: add license for telnet
document the license in the LICENSE file

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
0cb432a3e6 LICENSE: add license for tee
document the license in the LICENSE file

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
6c5deadde8 graphics: nxglyphs: Add Apache License
The initial contribution was missing a license.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
ea286c78d6 nshlib: Add Apache License
The initial contribution was missing a license.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
8821a4cdaa include: netutils: pppd.h: update license to Apache
Brennan Ashton has signed the ICLA. As a result we can migrate the
license to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
7632498251 platform: dummy: Add Apache License
The initial contribution was missing a license.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
ba040c0658 interpreters: ficl: Add Apache License
The initial contribution was missing a license.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-21 21:12:09 +08:00
Alin Jerpelea
4a2aa6d8cf remove DISCLAIMER-WIP
Most licenses have been converted to Apache and the non Apache
licenses have been documented.
We can assume that now it should be the time to remove DISCLAIMER-WIP

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-03-30 16:15:39 +08:00
5417 changed files with 42324 additions and 482822 deletions

View file

@ -1,9 +1,10 @@
# Reference: https://github.com/apache/infrastructure-asfyaml.
github:
description: "Apache NuttX Apps is a collection of tools, shells, network utilities, libraries, interpreters and can be used with the NuttX RTOS"
homepage: https://nuttx.apache.org/
features:
# Enable issues management
issues: true
# Enable project for project management boards
projects: true
labels:
- nuttx
@ -13,22 +14,9 @@ github:
- mcu
- microcontroller
enabled_merge_buttons:
squash: false
merge: false
rebase: true
protected_branches:
master:
required_status_checks:
strict: false
# Contexts cause hanging CI etc disable for now.
# contexts:
# - Check
# - Lint
# - Build
required_pull_request_reviews:
dismiss_stale_reviews: true
require_last_push_approval: true
required_approving_review_count: 2
required_linear_history: true
required_signatures: false
required_conversation_resolution: true
# disable squash button:
squash: false
# disable merge button:
merge: false
# enable rebase button:
rebase: true

View file

@ -1,16 +0,0 @@
mynewt-nimble/nimble/host/services/ans/src/ble_svc_ans.c
mynewt-nimble/nimble/host/services/ans/include
#include "services/ans/ble_svc_ans.h"
#include "crypto/controlse/ccertificate.hxx"
* notifications for the ANS Unread Alert Status characteristic
object = new Controlse::CCertificate(
Controlse::CCertificate cert(se, settings->key_id);
auto certificate = Controlse::CCertificate(
* |---------- [-rw-r--r-- 15] afile.txt
g_afile.name = "afile.txt";
"*.deh", "*.hhe", "*.seh", NULL);
MUSIC("introa"), MUSIC("runnin"), MUSIC("stalks"), MUSIC("countd"),
MUSIC("betwee"), MUSIC("doom"), MUSIC("the_da"), MUSIC("shawn"),
MUSIC("messag"), MUSIC("count2"), MUSIC("ddtbl3"), MUSIC("ampie"),
MUSIC("tense"), MUSIC("shawn3"), MUSIC("openin"), MUSIC("evil"),
/* ANS service */

View file

@ -1,16 +0,0 @@
[codespell]
# Add complete lines to be ignored to this file.
# Example for ignoring all current occurrences of (verifiably correct) word usage:
# grep -hirw "emac" | sort | uniq >>.codespell-ignore-lines
exclude-file = .codespell-ignore-lines
# Ignore complete files (e.g. legal text or other immutable material).
skip =
LICENSE,
examples/webpanel/content/www/xterm.min.js,
**/games/NXDoom/src/doom/d_englsh.h,
**/games/NXDoom/src/doom/d_french.h
# Ignore words list (FTP protocol commands and technical terms)
ignore-words-list = ALLO, ARCHTYPE, parm, shiftIn

View file

@ -1,166 +0,0 @@
# 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.
#
name: Bug report
description: Report a bug to improve NuttX stability
title: "[BUG] <title>"
labels: [👀 needs triage, "Type: Bug"]
body:
- type: markdown
attributes:
value: |
Hello NuttX Community member! Please keep things tidy by putting your post in the proper place:
Reporting a bug: use this form.
Asking a question or getting help: use the [General Help](https://github.com/apache/nuttx-apps/issues/new?assignees=&labels=Community%3A+Question&projects=&template=003_help.yml&title=%5BHELP%5D+%3Ctitle%3E) form or [Mailing list](https://nuttx.apache.org/community/).
Requesting a new feature: use the [Feature request](https://github.com/apache/nuttx-apps/issues/new?assignees=&labels=Type%3A+Enhancement&projects=&template=002_feature_request.yml&title=%5BFEATURE%5D+%3Ctitle%3E) form.
- type: textarea
attributes:
label: "Description / Steps to reproduce the issue"
description: "A clear and concise description of what the bug is, and why you consider it to be a bug, and steps for how to reproduce it"
placeholder: |
A description with steps to reproduce the issue.
May include logs, images, or videos.
1. Step 1
2. Step 2
validations:
required: true
- type: markdown
attributes:
value: |
### Environment
Please specify your environment.
- type: dropdown
id: os
attributes:
label: On which OS does this issue occur?
multiple: true
options:
- "[OS: BSD]"
- "[OS: Linux]"
- "[OS: Mac]"
- "[OS: Windows]"
- "[OS: Other]"
validations:
required: true
- type: input
id: os_version
attributes:
label: What is the version of your OS?
description: Please fill out the distro or OS version from the previous dropdown
placeholder: "MacOS 14, Ubuntu 23.10, Windows 10/MSYS_NT-10.0-19045, ecc"
validations:
required: true
- type: input
attributes:
label: NuttX Version
placeholder: "e.g., master, 12.5.1, ecc"
validations:
required: true
- type: dropdown
id: architecture
attributes:
label: Issue Architecture
description: What architecture(s) are you seeing the problem on?
multiple: true
options:
- "[Arch: all]"
- "[Arch: arm]"
- "[Arch: arm64]"
- "[Arch: avr]"
- "[Arch: ceva]"
- "[Arch: hc]"
- "[Arch: mips]"
- "[Arch: misoc]"
- "[Arch: openrisc]"
- "[Arch: renesas]"
- "[Arch: risc-v]"
- "[Arch: simulator]"
- "[Arch: sparc]"
- "[Arch: tricore]"
- "[Arch: x86]"
- "[Arch: x86_64]"
- "[Arch: xtensa]"
- "[Arch: z16]"
- "[Arch: z80]"
validations:
required: true
- type: dropdown
id: area
attributes:
label: Issue Area
description: What area(s) are you seeing the problem on?
multiple: true
options:
- "[Area: Audio]"
- "[Area: Benchmarks]"
- "[Area: Boot]"
- "[Area: CAN]"
- "[Area: Binfmt]"
- "[Area: Crypto]"
- "[Area: Database]"
- "[Area: Examples]"
- "[Area: File System]"
- "[Area: Games]"
- "[Area: Graphics]"
- "[Area: Industry]"
- "[Area: Inertial]"
- "[Area: Interpreters]"
- "[Area: Logging]"
- "[Area: LTE]"
- "[Area: Math]"
- "[Area: Mlearing]"
- "[Area: Modbus]"
- "[Area: Networking]"
- "[Area: NSH]"
- "[Area: SDR]"
- "[Area: System]"
- "[Area: Testing]"
- "[Area: Video]"
- "[Area: Wireless]"
- "[Area: Build System]"
- "[Area: Tools]"
- "[Area: Other]"
- "[Area: Posix]"
validations:
required: true
- type: textarea
attributes:
label: "Host information"
description: "What is the output of `make host_info` command while your buggy configuration selected and if possible device connected to your system?"
validations:
required: false
- type: markdown
attributes:
value: |
### Before You Submit
Please verify that you've followed these steps:
- Confirm the problem is reproducible on [**master**](https://github.com/apache/nuttx-apps) or [**latest stable**](https://nuttx.apache.org/download) release.
- Run `make distclean` when encountering build issues.
- Search [existing issues](https://github.com/apache/nuttx-apps/issues) (including [closed](https://github.com/apache/nuttx-apps/issues?q=is%3Aissue+is%3Aclosed))
- Read the [FAQ](https://nuttx.apache.org/docs/latest/faq/index.html).
- type: checkboxes
attributes:
label: "Verification"
options:
- label: "I have verified before submitting the report."
required: true

View file

@ -1,62 +0,0 @@
# 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.
#
name: Feature request
description: Request an enhancement for NuttX
title: "[FEATURE] <title>"
labels: ["Type: Enhancement"]
body:
- type: markdown
attributes:
value: |
Hello NuttX Community member! Please keep things tidy by putting your post in the proper place:
Requesting a new feature: use this form.
Asking a question or getting help: use the [General Help](https://github.com/apache/nuttx-apps/issues/new?assignees=&labels=Community%3A+Question&projects=&template=003_help.yml&title=%5BHELP%5D+%3Ctitle%3E) form or [Mailing list](https://nuttx.apache.org/community/).
Reporting a bug: use the [Bug report](https://github.com/apache/nuttx-apps/issues/new?assignees=&labels=%F0%9F%91%80+needs+triage%2CType%3A+Bug&projects=&template=001_bug_report.yml&title=%5BBUG%5D+%3Ctitle%3E) form.
- type: textarea
id: question-description
attributes:
label: Is your feature request related to a problem? Please describe.
description: Please provide a clear and concise description of what the problem is. Add relevant issue link.
validations:
required: true
- type: textarea
id: solution
attributes:
label: Describe the solution you'd like
description: Please provide a clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Describe alternatives you've considered
description: Please provide a clear and concise description of any alternative solutions or features you've considered.
- type: markdown
attributes:
value: |
### Before You Submit
Please verify that you've followed these steps:
- Search [existing feature requests](https://github.com/apache/nuttx-apps/issues) (including [closed](https://github.com/apache/nuttx-apps/issues?q=is%3Aissue+is%3Aclosed))
- type: checkboxes
attributes:
label: "Verification"
options:
- label: "I have verified before submitting the report."
required: true

View file

@ -1,54 +0,0 @@
# 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.
#
name: General Help
description: Get general support regarding NuttX
title: "[HELP] <title>"
labels: ["Community: Question"]
body:
- type: markdown
attributes:
value: |
Hello NuttX Community member! Please keep things tidy by putting your post in the proper place:
Asking a question or getting help: use this form or [Mailing list](https://nuttx.apache.org/community/).
Reporting a bug: use the [Bug report](https://github.com/apache/nuttx-apps/issues/new?assignees=&labels=%F0%9F%91%80+needs+triage%2CType%3A+Bug&projects=&template=001_bug_report.yml&title=%5BBUG%5D+%3Ctitle%3E) form.
Requesting a new feature: use the [Feature request](https://github.com/apache/nuttx-apps/issues/new?assignees=&labels=Type%3A+Enhancement&projects=&template=002_feature_request.yml&title=%5BFEATURE%5D+%3Ctitle%3E) form
- type: markdown
attributes:
value: |
### Whether you're a beginner or an experienced developer, NuttX Help is here to assist you with all your NuttX questions and concerns.
- type: textarea
id: question-description
attributes:
label: Description
description: Explain the background or context of your question. This helps others understand your problem or inquiry better.
validations:
required: true
- type: markdown
attributes:
value: |
### Before You Submit
Please verify that you've followed these steps:
- I have searched [NuttX Documentation](https://nuttx.apache.org/docs/latest/) and didn't find an answer to my question.
- Search [existing issues](https://github.com/apache/nuttx-apps/issues) (including [closed](https://github.com/apache/nuttx-apps/issues?q=is%3Aissue+is%3Aclosed))
- type: checkboxes
attributes:
label: "Verification"
options:
- label: "I have verified before submitting the report."
required: true

View file

@ -1 +0,0 @@
blank_issues_enabled: false

View file

@ -1,21 +1,6 @@
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
## Summary
*Update this section with information on why change is necessary,
what it exactly does and how, if new feature shows up, provide
references (dependencies, similar problems and solutions), etc.*
## Impact
*Update this section, where applicable, on how change affects users,
build process, hardware, documentation, security, compatibility, etc.*
## Testing
*Update this section with details on how did you verify the change,
what Host was used for build (OS, CPU, compiler, ..), what Target was
used for verification (arch, board:config, ..), etc. Providing build
and runtime logs from before and after change is highly appreciated.*

21
.github/SECURITY.md vendored
View file

@ -1,21 +0,0 @@
# Security Policy
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 11.0.x | :heavy_check_mark: |
| 10.3.x | :heavy_check_mark: |
| 10.2.x | :heavy_check_mark: |
| 10.1.x | :heavy_check_mark: |
| 10.0.x | :heavy_check_mark: |
| 9.1.x | :heavy_check_mark: |
| < 9.1 | :x: |
## Reporting a Vulnerability
If you think you have found a possible vulnerability please reach out to the _private_ project mailing list
private@nuttx.apache.org or the Apache Security list security@apache.org.
Please **DO NOT** create a GitHub issue or email the project dev list as they are public.
This project follows the Apache Vulnerability Handling Policy documented [here](https://www.apache.org/security/committers.html#vulnerability-handling).

View file

@ -1,6 +0,0 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

171
.github/labeler.yml vendored
View file

@ -1,171 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
# Note: NuttX PR Labeler only supports a subset of the
# `actions/labeler` syntax: `changed-files` and
# `any-glob-to-any-file`. See .github/workflows/labeler.yml
# add arch labels
"Area: Audio":
- changed-files:
- any-glob-to-any-file: 'audioutils/**'
- any-glob-to-any-file: 'include/audioutils/**'
"Area: Benchmarks":
- changed-files:
- any-glob-to-any-file: 'benchmarks/**'
- any-glob-to-any-file: 'include/benchmarks/**'
"Area: Boot":
- changed-files:
- any-glob-to-any-file: 'boot/**'
- any-glob-to-any-file: 'include/boot/**'
"Area: CAN":
- changed-files:
- any-glob-to-any-file: 'canutils/**'
- any-glob-to-any-file: 'include/canutils/**'
"Area: Binfmt":
- changed-files:
- any-glob-to-any-file: 'builtin/**'
- any-glob-to-any-file: 'include/builtin/**'
"Area: Crypto":
- changed-files:
- any-glob-to-any-file: 'crypto/**'
- any-glob-to-any-file: 'include/crypto/**'
"Area: Database":
- changed-files:
- any-glob-to-any-file: 'database/**'
- any-glob-to-any-file: 'include/database/**'
"Area: Examples":
- changed-files:
- any-glob-to-any-file: 'examples/**'
"Area: File System":
- changed-files:
- any-glob-to-any-file: 'fsutils/**'
- any-glob-to-any-file: 'include/fsutils/**'
"Area: Games":
- changed-files:
- any-glob-to-any-file: 'games/**'
- any-glob-to-any-file: 'include/games/**'
"Area: Graphics":
- changed-files:
- any-glob-to-any-file: 'graphics/**'
- any-glob-to-any-file: 'include/graphics/**'
"Area: Industry":
- changed-files:
- any-glob-to-any-file: 'industry/**'
- any-glob-to-any-file: 'include/industry/**'
"Area: Inertial":
- changed-files:
- any-glob-to-any-file: 'inertial/**'
- any-glob-to-any-file: 'include/inertial/**'
"Area: Interpreters":
- changed-files:
- any-glob-to-any-file: 'interpreters/**'
- any-glob-to-any-file: 'include/interpreters/**'
"Area: Logging":
- changed-files:
- any-glob-to-any-file: 'logging/**'
- any-glob-to-any-file: 'include/logging/**'
"Area: LTE":
- changed-files:
- any-glob-to-any-file: 'lte/**'
- any-glob-to-any-file: 'include/lte/**'
"Area: Math":
- changed-files:
- any-glob-to-any-file: 'math/**'
- any-glob-to-any-file: 'include/math/**'
"Area: Mlearning":
- changed-files:
- any-glob-to-any-file: 'mlearning/**'
- any-glob-to-any-file: 'include/mlearning/**'
"Area: Modbus":
- changed-files:
- any-glob-to-any-file: 'modbus/**'
- any-glob-to-any-file: 'include/modbus/**'
"Area: Networking":
- changed-files:
- any-glob-to-any-file: 'netutils/**'
- any-glob-to-any-file: 'include/netuitls/**'
"Area: NSH":
- changed-files:
- any-glob-to-any-file: 'nshlib/**'
- any-glob-to-any-file: 'include/nshlib/**'
"Area: SDR":
- changed-files:
- any-glob-to-any-file: 'sdr/**'
- any-glob-to-any-file: 'include/sdr/**'
"Area: System":
- changed-files:
- any-glob-to-any-file: 'system/**'
- any-glob-to-any-file: 'include/system/**'
"Area: Testing":
- changed-files:
- any-glob-to-any-file: 'testing/**'
- any-glob-to-any-file: 'include/testing/**'
"Area: Video":
- changed-files:
- any-glob-to-any-file: 'videotuils/**'
- any-glob-to-any-file: 'include/videotuils/**'
"Area: Wireless":
- changed-files:
- any-glob-to-any-file: 'wireless/**'
- any-glob-to-any-file: 'include/wireless/**'
"Area: Build system":
- changed-files:
- any-glob-to-any-file: 'Makefile'
- any-glob-to-any-file: 'Make.defs'
- any-glob-to-any-file: '*.mk'
- any-glob-to-any-file: 'CMakeLists.txt'
- any-glob-to-any-file: 'cmake/**'
- any-glob-to-any-file: 'import/**'
- any-glob-to-any-file: 'staging/**'
"Area: Tools":
- changed-files:
- any-glob-to-any-file: 'tools/**'
"Area: CI":
- changed-files:
- any-glob-to-any-file: '.github/**'

View file

@ -1,10 +0,0 @@
[flake8]
ignore = W503,W605,E203,E704
max-complexity = 27
max-line-length = 125
multi_line_output=3
show-source = True
statistics = True
[isort]
profile = black

View file

@ -1,260 +0,0 @@
# Identify the Arch for the PR and select the applicable builds
name: Arch
on:
workflow_call:
inputs:
os:
description: "Operating System hosting the build: Linux, macOS or msys2"
required: true
type: string
boards:
description: "List of All Builds: [arm-01, risc-v-01, xtensa-01, ...]"
required: true
type: string
outputs:
skip_all_builds:
description: "Set to 1 if all builds should be skipped"
value: ${{ jobs.Select-Builds.outputs.skip_all_builds }}
selected_builds:
description: "Selected Builds for the PR: [arm-01, risc-v-01, xtensa-01, ...]"
value: ${{ jobs.Select-Builds.outputs.selected_builds }}
jobs:
Select-Builds:
runs-on: ubuntu-latest
outputs:
skip_all_builds: ${{ steps.select-builds.outputs.skip_all_builds }}
selected_builds: ${{ steps.select-builds.outputs.selected_builds }}
steps:
# Get the Arch for the PR: arm, arm64, risc-v, xtensa, ...
- name: Get arch
id: get-arch
run: |
# If PR is Not Created or Modified: Build all targets
pr=${{github.event.pull_request.number}}
if [[ "$pr" == "" ]]; then
echo "Not a Created or Modified PR, will build all targets"
exit
fi
# Ignore the Label "Area: Documentation", because it won't affect the Build Targets
query='.labels | map(select(.name != "Area: Documentation")) | '
select_name='.[].name'
select_length='length'
# Get the Labels for the PR: "Arch: risc-v \n Board: risc-v \n Size: XS"
# If GitHub CLI Fails: Build all targets
labels=$(gh pr view $pr --repo $GITHUB_REPOSITORY --json labels --jq "$query$select_name" || echo "")
numlabels=$(gh pr view $pr --repo $GITHUB_REPOSITORY --json labels --jq "$query$select_length" || echo "")
echo "labels=$labels"
echo "numlabels=$numlabels" | tee -a $GITHUB_OUTPUT
# Identify the Size, Arch and Board Labels
if [[ "$labels" == *"Size: "* ]]; then
echo 'labels_contain_size=1' | tee -a $GITHUB_OUTPUT
fi
if [[ "$labels" == *"Arch: "* ]]; then
echo 'labels_contain_arch=1' | tee -a $GITHUB_OUTPUT
fi
if [[ "$labels" == *"Board: "* ]]; then
echo 'labels_contain_board=1' | tee -a $GITHUB_OUTPUT
fi
# Get the Arch Label
if [[ "$labels" == *"Arch: arm64"* ]]; then
echo 'arch_contains_arm64=1' | tee -a $GITHUB_OUTPUT
elif [[ "$labels" == *"Arch: arm"* ]]; then
echo 'arch_contains_arm=1' | tee -a $GITHUB_OUTPUT
elif [[ "$labels" == *"Arch: risc-v"* ]]; then
echo 'arch_contains_riscv=1' | tee -a $GITHUB_OUTPUT
elif [[ "$labels" == *"Arch: simulator"* ]]; then
echo 'arch_contains_sim=1' | tee -a $GITHUB_OUTPUT
elif [[ "$labels" == *"Arch: x86_64"* ]]; then
echo 'arch_contains_x86_64=1' | tee -a $GITHUB_OUTPUT
elif [[ "$labels" == *"Arch: x86"* ]]; then
echo 'arch_contains_x86=1' | tee -a $GITHUB_OUTPUT
elif [[ "$labels" == *"Arch: xtensa"* ]]; then
echo 'arch_contains_xtensa=1' | tee -a $GITHUB_OUTPUT
fi
# Get the Board Label
if [[ "$labels" == *"Board: arm64"* ]]; then
echo 'board_contains_arm64=1' | tee -a $GITHUB_OUTPUT
elif [[ "$labels" == *"Board: arm"* ]]; then
echo 'board_contains_arm=1' | tee -a $GITHUB_OUTPUT
elif [[ "$labels" == *"Board: risc-v"* ]]; then
echo 'board_contains_riscv=1' | tee -a $GITHUB_OUTPUT
elif [[ "$labels" == *"Board: simulator"* ]]; then
echo 'board_contains_sim=1' | tee -a $GITHUB_OUTPUT
elif [[ "$labels" == *"Board: x86_64"* ]]; then
echo 'board_contains_x86_64=1' | tee -a $GITHUB_OUTPUT
elif [[ "$labels" == *"Board: x86"* ]]; then
echo 'board_contains_x86=1' | tee -a $GITHUB_OUTPUT
elif [[ "$labels" == *"Board: xtensa"* ]]; then
echo 'board_contains_xtensa=1' | tee -a $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Select the Builds for the PR: arm-01, risc-v-01, xtensa-01, ...
- name: Select builds
id: select-builds
run: |
# Skip all macOS Builds
if [[ "${{ inputs.os }}" == "macOS" ]]; then
echo "Skipping all macOS Builds"
echo "skip_all_builds=1" | tee -a $GITHUB_OUTPUT
exit
fi
# Fetch the outputs from the previous step
numlabels=${{ steps.get-arch.outputs.numlabels }}
labels_contain_size=${{ steps.get-arch.outputs.labels_contain_size }}
labels_contain_arch=${{ steps.get-arch.outputs.labels_contain_arch }}
labels_contain_board=${{ steps.get-arch.outputs.labels_contain_board }}
arch_contains_arm=${{ steps.get-arch.outputs.arch_contains_arm }}
arch_contains_arm64=${{ steps.get-arch.outputs.arch_contains_arm64 }}
arch_contains_riscv=${{ steps.get-arch.outputs.arch_contains_riscv }}
arch_contains_sim=${{ steps.get-arch.outputs.arch_contains_sim }}
arch_contains_x86=${{ steps.get-arch.outputs.arch_contains_x86 }}
arch_contains_x86_64=${{ steps.get-arch.outputs.arch_contains_x86_64 }}
arch_contains_xtensa=${{ steps.get-arch.outputs.arch_contains_xtensa }}
board_contains_arm=${{ steps.get-arch.outputs.board_contains_arm }}
board_contains_arm64=${{ steps.get-arch.outputs.board_contains_arm64 }}
board_contains_riscv=${{ steps.get-arch.outputs.board_contains_riscv }}
board_contains_sim=${{ steps.get-arch.outputs.board_contains_sim }}
board_contains_x86=${{ steps.get-arch.outputs.board_contains_x86 }}
board_contains_x86_64=${{ steps.get-arch.outputs.board_contains_x86_64 }}
board_contains_xtensa=${{ steps.get-arch.outputs.board_contains_xtensa }}
# inputs.boards is a JSON Array: ["arm-01", "risc-v-01", "xtensa-01", ...]
# We compact and remove the newlines
boards=$( echo '${{ inputs.boards }}' | jq --compact-output ".")
numboards=$( echo "$boards" | jq "length" )
# We consider only Simple PRs with:
# Arch + Size Labels Only
# Board + Size Labels Only
# Arch + Board + Size Labels Only
if [[ "$labels_contain_size" != "1" ]]; then
echo "Size Label Missing, will build all targets"
quit=1
elif [[ "$numlabels" == "2" && "$labels_contain_arch" == "1" ]]; then
echo "Arch + Size Labels Only"
elif [[ "$numlabels" == "2" && "$labels_contain_board" == "1" ]]; then
echo "Board + Size Labels Only"
elif [[ "$numlabels" == "3" && "$labels_contain_arch" == "1" && "$labels_contain_board" == "1" ]]; then
# Arch and Board must be the same
if [[
"$arch_contains_arm" != "$board_contains_arm" ||
"$arch_contains_arm64" != "$board_contains_arm64" ||
"$arch_contains_riscv" != "$board_contains_riscv" ||
"$arch_contains_sim" != "$board_contains_sim" ||
"$arch_contains_x86" != "$board_contains_x86" ||
"$arch_contains_x86_64" != "$board_contains_x86_64" ||
"$arch_contains_xtensa" != "$board_contains_xtensa"
]]; then
echo "Arch and Board are not the same, will build all targets"
quit=1
else
echo "Arch + Board + Size Labels Only"
fi
else
echo "Not a Simple PR, will build all targets"
quit=1
fi
# If Not a Simple PR: Build all targets
if [[ "$quit" == "1" ]]; then
# If PR was Created or Modified: Include all boards
pr=${{github.event.pull_request.number}}
if [[ "$pr" != "" ]]; then
echo "Include all boards"
boards=$(
echo '${{ inputs.boards }}' |
jq --compact-output \
'.'
)
fi
echo "selected_builds=$boards" | tee -a $GITHUB_OUTPUT
exit
fi
# For every board
for (( i=0; i<numboards; i++ ))
do
# Fetch the board
board=$( echo "$boards" | jq ".[$i]" )
skip_build=0
# For "Arch / Board: arm": Build arm-01, arm-02, ...
if [[ "$arch_contains_arm" == "1" || "$board_contains_arm" == "1" ]]; then
if [[ "$board" != *"arm-"* ]]; then
skip_build=1
fi
# For "Arch / Board: arm64": Build arm64-01
elif [[ "$arch_contains_arm64" == "1" || "$board_contains_arm64" == "1" ]]; then
if [[ "$board" != *"arm64-"* ]]; then
skip_build=1
fi
# For "Arch / Board: risc-v": Build risc-v-01, risc-v-02, ...
elif [[ "$arch_contains_riscv" == "1" || "$board_contains_riscv" == "1" ]]; then
if [[ "$board" != *"risc-v-"* ]]; then
skip_build=1
fi
# For "Arch / Board: simulator": Build sim-01, sim-02
elif [[ "$arch_contains_sim" == "1" || "$board_contains_sim" == "1" ]]; then
if [[ "$board" != *"sim-"* ]]; then
skip_build=1
fi
# For "Arch / Board: x86": Build other
elif [[ "$arch_contains_x86" == "1" || "$board_contains_x86" == "1" ]]; then
if [[ "$board" != *"other"* ]]; then
skip_build=1
fi
# For "Arch / Board: x86_64": Build x86_64-01
elif [[ "$arch_contains_x86_64" == "1" || "$board_contains_x86_64" == "1" ]]; then
if [[ "$board" != *"x86_64-"* ]]; then
skip_build=1
fi
# For "Arch / Board: xtensa": Build xtensa-01, xtensa-02, xtensa-03
elif [[ "$arch_contains_xtensa" == "1" || "$board_contains_xtensa" == "1" ]]; then
if [[ "$board" != *"xtensa-"* ]]; then
skip_build=1
fi
# For Other Arch: Allow the build
else
echo Build by default: $board
fi
# Add the board to the selected builds
if [[ "$skip_build" == "0" ]]; then
echo Add $board to selected_builds
if [[ "$selected_builds" == "" ]]; then
selected_builds=$board
else
selected_builds=$selected_builds,$board
fi
fi
done
# Return the selected builds as JSON Array
# If Selected Builds is empty: Skip all builds
echo "selected_builds=[$selected_builds]" | tee -a $GITHUB_OUTPUT
if [[ "$selected_builds" == "" ]]; then
echo "skip_all_builds=1" | tee -a $GITHUB_OUTPUT
fi

View file

@ -16,19 +16,15 @@ on:
pull_request:
push:
branches:
- master
- 'releases/*'
tags:
permissions:
contents: read
concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# Fetch the source from nuttx and nuttx-apps repos
Fetch-Source:
runs-on: ubuntu-latest
steps:
@ -63,13 +59,13 @@ jobs:
# Determine the repo and leave that unset to use the normal checkout behavior
# of using the merge commit instead of HEAD
case $GITHUB_REPOSITORY in
"apache/nuttx")
"apache/incubator-nuttx")
# OS
echo "Triggered by change in OS"
APPS_REF=$REF_NAME
;;
"apache/nuttx-apps" )
"apache/incubator-nuttx-apps" )
# APPS
OS_REF=$REF_NAME
echo "Triggered by change in APPS"
@ -81,13 +77,13 @@ jobs:
esac
fi
echo "os_ref=$OS_REF" >> $GITHUB_OUTPUT
echo "apps_ref=$APPS_REF" >> $GITHUB_OUTPUT
echo ::set-output name=os_ref::$OS_REF
echo ::set-output name=apps_ref::$APPS_REF
- name: Checkout nuttx repo
uses: actions/checkout@v7
uses: actions/checkout@v2
with:
repository: apache/nuttx
repository: apache/incubator-nuttx
ref: ${{ steps.gittargets.outputs.os_ref }}
path: sources/nuttx
fetch-depth: 1
@ -95,390 +91,105 @@ jobs:
run: git -C sources/nuttx fetch --tags
- name: Checkout apps repo
uses: actions/checkout@v7
uses: actions/checkout@v2
with:
repository: apache/nuttx-apps
repository: apache/incubator-nuttx-apps
ref: ${{ steps.gittargets.outputs.apps_ref }}
path: sources/apps
fetch-depth: 1
- name: Tar sources
run: tar zcf sources.tar.gz sources
- name: Archive Source Bundle
uses: actions/upload-artifact@v7.0.1
uses: actions/upload-artifact@v1
with:
name: source-bundle
path: sources.tar.gz
# Select the Linux Builds based on PR Arch Label
Linux-Arch:
uses: apache/nuttx-apps/.github/workflows/arch.yml@master
needs: Fetch-Source
with:
os: Linux
boards: |
[
"arm-01", "risc-v-01", "sim-01", "xtensa-01", "arm64-01", "x86_64-01", "other",
"arm-02", "risc-v-02", "sim-02", "xtensa-02",
"arm-03", "risc-v-03", "sim-03", "xtensa-03",
"arm-04", "risc-v-04",
"arm-05", "risc-v-05",
"arm-06", "risc-v-06",
"arm-07", "arm-08", "arm-09", "arm-10", "arm-11", "arm-12", "arm-13", "arm-14"
]
# Run the selected Linux Builds
Linux:
needs: Linux-Arch
if: ${{ needs.Linux-Arch.outputs.skip_all_builds != '1' }}
needs: Fetch-Source
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
# Documented sim/login CI test credential (not a production secret).
# Used when CONFIG_BOARD_ETC_ROMFS_PASSWD_ENABLE=y and defconfig omits
# the password. See nuttx tools/update_romfs_password.sh.
NUTTX_ROMFS_PASSWD_PASSWORD: NuttXSimLogin1!
strategy:
max-parallel: 12
matrix:
boards: ${{ fromJSON(needs.Linux-Arch.outputs.selected_builds) }}
boards: [arm-01, arm-02, arm-03, arm-04, arm-05, arm-06, arm-07, arm-08, arm-09, arm-10, arm-11, arm-12, arm-13, other, risc-v, sim-01, sim-02, xtensa]
steps:
- name: Show Disk Space
run: df -h
- name: Free Disk Space (Ubuntu)
run: |
sudo rm -rf /usr/local/lib/android
- name: After CLEAN-UP Disk Space
run: df -h
- name: Download Source Artifact
uses: actions/download-artifact@v8
uses: actions/download-artifact@v1
with:
name: source-bundle
path: .
- name: Extract sources
run: tar zxf sources.tar.gz
- name: Docker Login
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
uses: azure/docker-login@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
login-server: ghcr.io
username: ${GITHUB_ACTOR}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Pull
run: docker pull ghcr.io/apache/nuttx/apache-nuttx-ci-linux
run: docker pull ghcr.io/apache/incubator-nuttx/apache-nuttx-ci-linux
- name: Export NuttX Repo SHA
run: echo "nuttx_sha=`git -C sources/nuttx rev-parse HEAD`" >> $GITHUB_ENV
- name: Run builds
uses: ./sources/nuttx/.github/actions/ci-container
env:
BLOBDIR: /tools/blobs
NUTTX_ROMFS_PASSWD_PASSWORD: NuttXSimLogin1!
with:
run: |
export NUTTX_ROMFS_PASSWD_PASSWORD=NuttXSimLogin1!
export ARTIFACTDIR=`pwd`/buildartifacts
for i in 1 2 3; do
python -m pip install \
--default-timeout=100 \
--retries 10 \
ntfc==0.0.1 && break
echo "Retry $i failed..."
sleep 5
done
mkdir /github/workspace/nuttx-ntfc
mkdir /github/workspace/nuttx-ntfc/external
cd /github/workspace/nuttx-ntfc
# get NTFC test cases
cd external
for i in 1 2 3 4 5; do
git clone -b release-0.0.1 https://github.com/apache/nuttx-ntfc-testing && break
if [ "$i" -eq 5 ]; then
echo "Failed to clone nuttx-ntfc-testing after $i attempts"
exit 1
fi
delay=$((i * 10))
echo "Clone attempt $i failed; retrying in ${delay}s..."
rm -rf nuttx-ntfc-testing
sleep "$delay"
done
mv nuttx-ntfc-testing nuttx-testing
export NTFCDIR=/github/workspace/nuttx-ntfc
echo "::add-matcher::sources/nuttx/.github/gcc.json"
git config --global --add safe.directory /github/workspace/sources/nuttx
git config --global --add safe.directory /github/workspace/sources/apps
cd /github/workspace/sources/nuttx/tools/ci
if [ "X${{matrix.boards}}" = "Xcodechecker" ]; then
./cibuild.sh -c -A -N -R --codechecker testlist/${{matrix.boards}}.dat
else
( sleep 7200 ; echo Killing pytest after timeout... ; pkill -f pytest )&
./cibuild.sh -c -A -N -R -S testlist/${{matrix.boards}}.dat
fi
- name: Post-build Disk Space
if: always()
run: df -h
- uses: actions/upload-artifact@v7.0.1
if: ${{ always() }}
export CCACHE_DIR=`pwd`/ccache
mkdir $CCACHE_DIR
export ARTIFACTDIR=`pwd`/buildartifacts
cd sources/nuttx/tools/ci
./cibuild.sh -A -c testlist/${{matrix.boards}}.dat
ccache -s
- uses: actions/upload-artifact@v2
with:
name: linux-${{matrix.boards}}-builds
name: linux-builds
path: buildartifacts/
continue-on-error: true
# Test the out-of-tree build
OOT-Build:
needs: Linux
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
steps:
- name: Download Source Artifact
uses: actions/download-artifact@v8
with:
name: source-bundle
path: .
- name: Extract sources
run: tar zxf sources.tar.gz
- name: Docker Login
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Export NuttX Repo SHA
run: echo "nuttx_sha=`git -C sources/nuttx rev-parse HEAD`" >> $GITHUB_ENV
- name: Run Out-of-Tree Build Test
uses: ./sources/nuttx/.github/actions/ci-container
env:
BLOBDIR: /tools/blobs
with:
run: |
echo "::add-matcher::sources/nuttx/.github/gcc.json"
git config --global --add safe.directory /github/workspace/sources/nuttx
git config --global --add safe.directory /github/workspace/sources/apps
cd sources/nuttx
./tools/ci/cibuild-oot.sh
- uses: actions/upload-artifact@v7.0.1
if: ${{ always() }}
with:
name: oot-build-artifacts
path: sources/apps/testing/cxx-oot-build
continue-on-error: true
# Select the macOS Builds based on PR Arch Label
macOS-Arch:
uses: apache/nuttx-apps/.github/workflows/arch.yml@master
needs: Fetch-Source
with:
os: macOS
boards: |
["macos", "sim-01", "sim-02", "sim-03"]
# Run the selected macOS Builds
macOS:
permissions:
contents: none
runs-on: macos-15-intel
needs: macOS-Arch
if: ${{ needs.macOS-Arch.outputs.skip_all_builds != '1' }}
env:
NUTTX_ROMFS_PASSWD_PASSWORD: NuttXSimLogin1!
runs-on: macos-10.15
needs: Fetch-Source
strategy:
max-parallel: 2
matrix:
boards: ${{ fromJSON(needs.macOS-Arch.outputs.selected_builds) }}
boards: [macos, sim-01, sim-02]
steps:
- name: Download Source Artifact
uses: actions/download-artifact@v8
uses: actions/download-artifact@v1
with:
name: source-bundle
path: .
- name: Extract sources
run: tar zxf sources.tar.gz
- name: Restore Tools Cache
id: cache-tools
uses: actions/cache@v6
uses: actions/cache@v2
env:
cache-name: ${{ runner.os }}-cache-tools
with:
path: ./sources/tools
key: ${{ runner.os }}-tools-${{ hashFiles('./sources/nuttx/tools/ci/platforms/darwin.sh') }}
path: prebuilt
key: ${{ runner.os }}-tools-${{ hashFiles('./sources/nuttx/tools/ci/cibuild.sh') }}
- name: Export NuttX Repo SHA
run: echo "nuttx_sha=`git -C sources/nuttx rev-parse HEAD`" >> $GITHUB_ENV
# Released version of Cython has issues with Python 11. Set runner to use Python 3.10
# https://github.com/cython/cython/issues/4500
- uses: actions/setup-python@v7
with:
python-version: '3.10'
- name: Run Builds
run: |
echo "::add-matcher::sources/nuttx/.github/gcc.json"
export NUTTX_ROMFS_PASSWD_PASSWORD=NuttXSimLogin1!
export CCACHE_DIR=`pwd`/ccache
mkdir $CCACHE_DIR
export ARTIFACTDIR=`pwd`/buildartifacts
cd sources/nuttx/tools/ci
./cibuild.sh -i -c -A -R testlist/${{matrix.boards}}.dat
- uses: actions/upload-artifact@v7.0.1
./cibuild.sh -i -A -c testlist/${{matrix.boards}}.dat
ccache -s
- uses: actions/upload-artifact@v2
with:
name: macos-${{matrix.boards}}-builds
name: macos-builds
path: buildartifacts/
continue-on-error: true
# Select the msys2 Builds based on PR Arch Label
msys2-Arch:
uses: apache/nuttx-apps/.github/workflows/arch.yml@master
needs: Fetch-Source
with:
os: msys2
boards: |
["msys2"]
# Run the selected msys2 Builds
msys2:
needs: msys2-Arch
if: ${{ needs.msys2-Arch.outputs.skip_all_builds != '1' }}
runs-on: windows-latest
strategy:
fail-fast: false
max-parallel: 1
matrix:
boards: ${{ fromJSON(needs.msys2-Arch.outputs.selected_builds) }}
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v7
- uses: msys2/setup-msys2@v2
with:
msystem: MSYS
update: false
cache: false
install: >-
base-devel
gcc
gperf
automake
autoconf
git
python3
ncurses-devel
unzip
zip
tio
zlib-devel
cmake
ninja
python-pip
vim
genromfs
- name: pip3 install
run: |
python3 -m venv --system-site-packages /usr/local
pip3 install --root-user-action=ignore --no-cache-dir pyelftools cxxfilt kconfiglib
- run: git config --global core.autocrlf false
- name: Download Source Artifact
uses: actions/download-artifact@v8
with:
name: source-bundle
path: .
- name: Extract sources
run: tar zxf sources.tar.gz
- name: Export NuttX Repo SHA
run: echo "nuttx_sha=`git -C sources/nuttx rev-parse HEAD`" >> $GITHUB_ENV
- name: Run Builds
run: |
echo "::add-matcher::sources/nuttx/.github/gcc.json"
export ARTIFACTDIR=`pwd`/buildartifacts
git config --global --add safe.directory /github/workspace/sources/nuttx
git config --global --add safe.directory /github/workspace/sources/apps
cd sources/nuttx/tools/ci
./cibuild.sh -g -i -A -C -N -R testlist/${{matrix.boards}}.dat
- uses: actions/upload-artifact@v7.0.1
with:
name: msys2-${{matrix.boards}}-builds
path: buildartifacts/
continue-on-error: true
# Select the msvc Builds based on PR Arch Label
msvc-Arch:
uses: apache/nuttx-apps/.github/workflows/arch.yml@master
needs: Fetch-Source
with:
os: msvc
boards: |
["msvc_placeholder_with_sim_keyword"]
# Build with MSVC in Windows native
msvc:
needs: msvc-Arch
if: ${{ needs.msvc-Arch.outputs.skip_all_builds != '1' }}
runs-on: windows-2022
steps:
- uses: actions/checkout@v7
# Set up Python environment and install kconfiglib
- name: Set up Python and install kconfiglib
uses: actions/setup-python@v7
with:
python-version: '3.10'
- name: Install kconfiglib
run: |
pip install kconfiglib
- run: git config --global core.autocrlf false
- name: Download Source Artifact
uses: actions/download-artifact@v8
with:
name: source-bundle
path: .
- name: Extract sources
run: |
7z x sources.tar.gz -y
7z x sources.tar -y -snld
- name: Run Builds
run: |
"ARTIFACTDIR=${{github.workspace}}\sources\buildartifacts" >> $env:GITHUB_ENV
git config --global --add safe.directory ${{github.workspace}}\sources\nuttx
git config --global --add safe.directory ${{github.workspace}}\sources\apps
cd sources\nuttx\tools\ci
.\cibuild.ps1 -n -i -A -C -N testlist\windows.dat
- uses: actions/upload-artifact@v7.0.1
with:
name: msvc-builds
path: ./sources/buildartifacts/
continue-on-error: true

View file

@ -19,36 +19,30 @@ concurrency:
group: check-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps:
- name: Checkout nuttx repo
uses: actions/checkout@v7
uses: actions/checkout@v2
with:
repository: apache/nuttx
repository: apache/incubator-nuttx
path: nuttx
fetch-depth: 0
- name: Checkout apps repo
uses: actions/checkout@v7
uses: actions/checkout@v2
with:
repository: apache/nuttx-apps
repository: apache/incubator-nuttx-apps
path: apps
fetch-depth: 0
- name: Check Pull Request
run: |
echo "::add-matcher::nuttx/.github/nxstyle.json"
python3 -m venv .venv
source .venv/bin/activate
pip install codespell cmake-format black isort flake8 cvt2utf
cd apps
commits="${{ github.event.pull_request.base.sha }}..HEAD"
git log --oneline $commits
echo "../nuttx/tools/checkpatch.sh -c -u -m -g $commits"
../nuttx/tools/checkpatch.sh -c -u -m -g $commits
echo "../nuttx/tools/checkpatch.sh -g $commits"
../nuttx/tools/checkpatch.sh -g $commits

View file

@ -1,53 +0,0 @@
# 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.
#
name: Issue Labeler
on:
issues:
types: [opened]
jobs:
label:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Add labels issues automatically based on their body.
uses: actions/github-script@v9.0.0
with:
script: |
const body = context.payload.issue.body;
const bodySplit = body.split(/\[|\]/).map(e => e.toLowerCase());
const oskeywords = ['os: other', 'os: bsd', 'os: linux', 'os: mac', 'os: windows'];
const archkeywords1 = ['arch: all', 'arch: arm', 'arch: arm64', 'arch: avr', 'arch: ceva'];
const archkeywords2 = ['arch: hc', 'arch: mips', 'arch: misoc', 'arch: openrisc', 'arch:renesas'];
const archkeywords3 = ['arch: risc-v', 'arch: simulator', 'arch: sparc', 'arch: tricore'];
const archkeywords4 = ['arch: x86', 'arch: x86_64', 'arch: xtensa', 'arch: z16', 'arch: z80', 'arch:renesas'];
const areakeywords1 = ['area: applications', 'area: api', 'area: board support', 'area: build system'];
const areakeywords2 = ['area: configuring', 'area: debugging', 'area: drivers', 'area: file system', 'area: installing', 'area: kconfig'];
const areakeywords3 = ['area: kernel', 'area: memory management', 'area: native port', 'area: networking'];
const areakeywords4 = ['area: os components', 'area: posix', 'area: sensors', 'area: specific peripheral'];
var keywordsfound = new Set();
for (const keyword of keywords) {
if (bodySplit.includes(keyword)) {
keywordsfound.add(keyword)
}
}
if (keywordsfound.size !== 0) {
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: Array.from(keywordsfound)
})
}

View file

@ -1,150 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
#
# 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.
#
# This workflow will fetch the updated PR filenames, compute the Size Label
# and Arch Labels, then save the PR Labels into a PR Artifact. The
# PR Labels will be written to the PR inside the "workflow_run" trigger
# (pr_labeler.yml), because this "pull_request" trigger has read-only
# permission. Don't use "pull_request_target", it's unsafe.
# See https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=321719166#GitHubActionsSecurity-Buildstriggeredwithpull_request_target
name: "Pull Request Labeler"
on:
- pull_request
jobs:
labeler:
permissions:
contents: read
pull-requests: read
issues: read
runs-on: ubuntu-latest
steps:
# Checkout one file from our trusted source: .github/labeler.yml
# Never checkout and execute any untrusted code from the PR.
- name: Checkout labeler config
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: apache/nuttx-apps
ref: master
path: labeler
fetch-depth: 1
persist-credentials: false
sparse-checkout: .github/labeler.yml
sparse-checkout-cone-mode: false
# Fetch the updated PR filenames. Compute the Size Label and Arch Labels.
- name: Compute PR labels
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const pull_number = context.issue.number;
// Fetch the array of updated PR filenames:
// { status: 'added', filename: 'arch/arm/test.txt', additions: 3, deletions: 0, changes: 3 }
// { status: 'removed', filename: 'Documentation/legacy_README.md', additions: 0, deletions: 2531, changes: 2531 }
// { status: 'modified', filename: 'Documentation/security.rst', additions: 1, deletions: 0, changes: 1 }
const listFilesOptions = github.rest.pulls.listFiles
.endpoint.merge({ owner, repo, pull_number });
const listFilesResponse = await github.paginate(listFilesOptions);
// Sum up the number of lines changed
const sizeFiles = listFilesResponse
.filter(f => (f.status != 'removed')); // Ignore deleted files
var linesChanged = 0;
for (const file of sizeFiles) {
linesChanged += file.changes;
}
console.log({ linesChanged });
// Compute the Size Label
const sizeLabel =
(linesChanged <= 10) ? 'Size: XS'
: (linesChanged <= 100) ? 'Size: S'
: (linesChanged <= 500) ? 'Size: M'
: (linesChanged <= 1000) ? 'Size: L'
: 'Size: XL';
var prLabels = [ sizeLabel ];
// Parse the Arch Label Patterns in .github/labeler.yml. Condense into:
// "Arch: arm":
// - any-glob-to-any-file: 'arch/arm/**'
// - any-glob-to-any-file: ...
const fs = require('fs');
const config = fs.readFileSync('labeler/.github/labeler.yml', 'utf8')
.split('\n') // Split by newline
.map(s => s.trim()) // Remove leading and trailing spaces
.filter(s => (s != '')) // Remove empty lines
.filter(s => !s.startsWith('#')) // Remove comments
.filter(s => !s.startsWith('- changed-files:')); // Remove "changed-files"
// Convert the Arch Label Patterns from config to archLabels.
// archLabels will contain the mappings for Arch Label and Filename Pattern:
// { label: "Arch: arm", pattern: "arch/arm/.*" },
// { label: "Arch: arm64", pattern: "arch/arm64/.*" }, ...
var archLabels = [];
var label = "";
for (const c of config) {
// Get the Arch Label
if (c.startsWith('"')) { // "Arch: arm":
label = c.split('"')[1]; // Arch: arm
} else if (c.startsWith('- any-glob-to-any-file:')) { // - any-glob-to-any-file: 'arch/arm/**'
// Convert the Glob Pattern to Regex Pattern
const pattern = c.split("'")[1] // arch/arm/**
.split('.').join('\\.') // . becomes \.
.split('*').join('[^/]*') // * becomes [^/]*
.split('[^/]*[^/]*').join('.*'); // ** becomes .*
archLabels.push({
label, // Arch: arm
pattern: '^' + pattern + '$' // Match the Line Start and Line End
});
} else {
// We don't support all rules of `actions/labeler`
throw new Error('.github/labeler.yml should contain only changed-files and any-glob-to-any-file, not: ' + c);
}
}
// Search the filenames for matching Arch Labels
for (const archLabel of archLabels) {
if (prLabels.includes(archLabel.label)) {
break;
}
for (const file of listFilesResponse) {
const re = new RegExp(archLabel.pattern);
const match = re.test(file.filename);
if (match && !prLabels.includes(archLabel.label)) {
prLabels.push(archLabel.label);
break;
}
}
}
console.log({ prLabels });
// Save the PR Number and PR Labels into a PR Artifact
// e.g. 'Size: XS\nArch: avr\n'
const dir = 'pr';
fs.mkdirSync(dir);
fs.writeFileSync(dir + '/pr-id.txt', pull_number + '\n');
fs.writeFileSync(dir + '/pr-labels.txt', prLabels.join('\n') + '\n');
# Upload the PR Artifact as pr.zip
- name: Upload PR artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pr
path: pr/

View file

@ -1,4 +1,4 @@
name: Lint
name: ❄️ Lint
on: [pull_request]
@ -6,29 +6,14 @@ concurrency:
group: lint-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
lint:
permissions:
contents: read # for actions/checkout to fetch code
statuses: write # for github/super-linter to mark status of each linter run
name: Lint
yamllint:
name: 🍺 YAML
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- run: mkdir super-linter.report
- name: Lint
uses: github/super-linter@v7
- uses: actions/checkout@v2
- name: 🧹 YAML Lint
uses: github/super-linter@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false
VALIDATE_PYTHON_BLACK: true
VALIDATE_PYTHON_FLAKE8: true
PYTHON_FLAKE8_CONFIG_FILE: setup.cfg
VALIDATE_PYTHON_ISORT: true
PYTHON_ISORT_CONFIG_FILE: setup.cfg
VALIDATE_YAML: true
FILTER_REGEX_INCLUDE: .*\.github/.*

View file

@ -1,90 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
#
# 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.
#
# This workflow will fetch the PR Labels from the PR Artifact, and write
# the PR Labels into the PR. The workflow is called after the
# "pull_request" trigger (labeler.yml). This "workflow_run" trigger uses a
# GitHub Token with Write Permission, so we must never run any untrusted
# code from the PR, and we must always extract and use the PR Artifact
# safely. See https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=321719166#GitHubActionsSecurity-Buildstriggeredwithworkflow_run
name: "Set Pull Request Labels"
on:
workflow_run:
workflows: ["Pull Request Labeler"]
types:
- completed
jobs:
pr_labeler:
permissions:
contents: read
pull-requests: write
issues: write
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
# Download the PR Artifact, containing PR Number and PR Labels
- name: Download PR artifact
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
# Unzip the PR Artifact
- name: Unzip PR artifact
run: unzip pr.zip
# Write the PR Labels into the PR
- name: Write PR labels
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const fs = require('fs');
// Read the PR Number and PR Labels from the PR Artifact
// e.g. 'Size: XS\nArch: avr\n'
const issue_number = Number(fs.readFileSync('pr-id.txt'));
const labels = fs.readFileSync('pr-labels.txt', 'utf8')
.split('\n') // Split by newline
.filter(s => (s != '')); // Remove empty lines
console.log({ issue_number, labels });
// Write the PR Labels into the PR
// e.g. [ 'Size: XS', 'Arch: avr' ]
await github.rest.issues.setLabels({
owner,
repo,
issue_number,
labels
});

23
.gitignore vendored
View file

@ -1,51 +1,30 @@
*.a
*.dbo
*.dba
*.adb
*.asm
*.d
*.dSYM
*.exe
*.gcno
*.gcda
*.hobj
*.i
*.inf
*.lib
*.lst
*.o
*.wo
*.obj
*.rel
*.src
*.swp
*.sym
*.su
*.map
*~
.built
.context
.depend
.kconfig
*.lock
/bin
/bin_debug
/boot_romfsimg.h
/external
/Kconfig
/romfs.img
/staging
/symtab_apps.c
/wasm
cscope.out
Make.dep
.context
# nuttx/$(TOPDIR)/Makefile.[unix|win]::$(DIRLINKS_EXTERNAL_DIRS)
.dirlinks
.vscode
.DS_Store
build
.ccls-cache
compile_commands.json
.aider*
.clang-format
.cache

View file

@ -1,8 +1,6 @@
############################################################################
# apps/Application.mk
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
@ -25,18 +23,12 @@
# has the value "m"
ifneq ($(MAINSRC),)
ifeq ($(DYNLIB),y)
ifeq ($(MODULE),m)
BUILD_MODULE = y
endif
ifeq ($(CONFIG_BUILD_KERNEL),y)
BUILD_MODULE = y
MODAELFFLAGS = $(CMODULELFFLAGS)
MODCFLAGS = $(CMODULEFLAGS)
MODCXXFLAGS = $(CXXMODULEFLAGS)
MODLDFLAGS = $(LDMODULEFLAGS)
else ifneq ($(or $(filter y,$(CONFIG_BUILD_KERNEL)), $(filter m,$(MODULE))),)
BUILD_MODULE = y
MODAELFFLAGS = $(AELFFLAGS)
MODCFLAGS = $(CELFFLAGS)
MODCXXFLAGS = $(CXXELFFLAGS)
MODLDFLAGS = $(LDELFFLAGS)
endif
endif
@ -45,18 +37,16 @@ endif
# we need to fix up the path so the DELIM will match the actual delimiter.
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
CWD = $(strip ${shell echo %CD% | cut -d: -f2})
CWD = $(strip ${shell echo %CD% | cut -d: -f2})
else
CWD = $(CURDIR)
CWD = $(CURDIR)
endif
SUFFIX ?= $(subst $(DELIM),.,$(CWD))
PROGNAME := $(subst ",,$(PROGNAME))
# Add the static application library to the linked libraries.
LDLIBS += $(call CONVERT_PATH,$(BIN))
# Add the static application library to the linked libraries. Don't do this
# with CONFIG_BUILD_KERNEL as there is no static app library
ifneq ($(CONFIG_BUILD_KERNEL),y)
LDLIBS += $(call CONVERT_PATH,$(BIN))
endif
# When building a module, link with the compiler runtime.
# This should be linked after libapps. Consider that mbedtls in libapps
@ -65,125 +55,39 @@ ifeq ($(BUILD_MODULE),y)
# Revisit: This only works for gcc and clang.
# Do other compilers have similar?
COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)
ifeq ($(wildcard $(COMPILER_RT_LIB)),)
# if "--print-libgcc-file-name" unable to find the correct libgcc PATH
# then go ahead and try "--print-file-name"
COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB))))
ifneq ($(COMPILER_RT_LIB),)
LDLIBS += $(COMPILER_RT_LIB)
endif
LDLIBS += $(COMPILER_RT_LIB)
endif
# Apps compilation can achieve out-of-tree intermediate products
# by specifying "PREFIX" to a directory in its own Makefile.
# Default value is NULL,
# Make sure the out-of-tree directory exists and ends with $(DELIM) when setting it.
PREFIX ?=
SUFFIX = $(subst $(DELIM),.,$(CWD))
PROGNAME := $(shell echo $(PROGNAME))
# Object files
RASRCS = $(filter %.s,$(ASRCS))
CASRCS = $(filter %.S,$(ASRCS))
RAOBJS = $(RASRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
CAOBJS = $(CASRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
COBJS = $(CSRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
CXXOBJS = $(CXXSRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
RUSTOBJS = $(RUSTSRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
ZIGOBJS = $(ZIGSRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
DOBJS = $(DSRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
SWIFTOBJS = $(SWIFTSRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
RAOBJS = $(RASRCS:=$(SUFFIX)$(OBJEXT))
CAOBJS = $(CASRCS:=$(SUFFIX)$(OBJEXT))
COBJS = $(CSRCS:=$(SUFFIX)$(OBJEXT))
CXXOBJS = $(CXXSRCS:=$(SUFFIX)$(OBJEXT))
RUSTOBJS = $(RUSTSRCS:=$(SUFFIX)$(OBJEXT))
MAINCXXSRCS = $(filter %$(CXXEXT),$(MAINSRC))
MAINCSRCS = $(filter %.c,$(MAINSRC))
MAINRUSTSRCS = $(filter %$(RUSTEXT),$(MAINSRC))
MAINZIGSRCS = $(filter %$(ZIGEXT),$(MAINSRC))
MAINDSRCS = $(filter %$(DEXT),$(MAINSRC))
MAINSWIFTSRCS = $(filter %$(SWIFTEXT),$(MAINSRC))
MAINCXXOBJ = $(MAINCXXSRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
MAINCOBJ = $(MAINCSRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
MAINRUSTOBJ = $(MAINRUSTSRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
MAINZIGOBJ = $(MAINZIGSRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
MAINDOBJ = $(MAINDSRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
MAINSWIFTOBJ = $(MAINSWIFTSRCS:%=$(PREFIX)%$(SUFFIX)$(OBJEXT))
MAINCXXOBJ = $(MAINCXXSRCS:=$(SUFFIX)$(OBJEXT))
MAINCOBJ = $(MAINCSRCS:=$(SUFFIX)$(OBJEXT))
MAINRUSTOBJ = $(MAINRUSTSRCS:=$(SUFFIX)$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(MAINSRC)
OBJS = $(RAOBJS) $(CAOBJS) $(COBJS) $(CXXOBJS) $(RUSTOBJS) $(ZIGOBJS) $(DOBJS) $(SWIFTOBJS) $(EXTOBJS)
OBJS = $(RAOBJS) $(CAOBJS) $(COBJS) $(CXXOBJS) $(RUSTOBJS)
ifneq ($(BUILD_MODULE),y)
OBJS += $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ) $(MAINZIGOBJ) $(MAINDOBJ) $(MAINSWIFTOBJ)
OBJS += $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ)
endif
ifneq ($(strip $(PROGNAME)),)
PROGOBJ := $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ) $(MAINZIGOBJ) $(MAINDOBJ) $(MAINSWIFTOBJ)
PROGLIST := $(addprefix $(BINDIR)$(DELIM),$(PROGNAME))
REGLIST := $(addprefix $(BUILTIN_REGISTRY)$(DELIM),$(addsuffix .bdat,$(PROGNAME)))
NLIST := $(shell seq 1 $(words $(PROGNAME)))
$(foreach i, $(NLIST), \
$(eval PROGNAME_$(word $i,$(PROGOBJ)) := $(word $i,$(PROGNAME))) \
$(eval PROGSYM_$(word $i,$(PROGOBJ)) := $(subst -,_,$(word $i,$(PROGNAME)))) \
$(eval PROGOBJ_$(word $i,$(PROGLIST)) := $(word $i,$(PROGOBJ))) \
$(eval PRIORITY_$(word $i,$(REGLIST)) := \
$(if $(word $i,$(PRIORITY)),$(word $i,$(PRIORITY)),$(lastword $(PRIORITY)))) \
$(eval STACKSIZE_$(word $i,$(REGLIST)) := \
$(if $(word $i,$(STACKSIZE)),$(word $i,$(STACKSIZE)),$(lastword $(STACKSIZE)))) \
$(eval UID_$(word $i,$(REGLIST)) := \
$(if $(word $i,$(UID)),$(word $i,$(UID)),$(lastword $(UID)))) \
$(eval GID_$(word $i,$(REGLIST)) := \
$(if $(word $i,$(GID)),$(word $i,$(GID)),$(lastword $(GID)))) \
$(eval MODE_$(word $i,$(REGLIST)) := \
$(if $(word $i,$(MODE)),$(word $i,$(MODE)),$(lastword $(MODE)))) \
$(eval STACKSIZE_$(word $i,$(PROGLIST)) := $(STACKSIZE_$(word $i,$(REGLIST)))) \
$(eval PRIORITY_$(word $i,$(PROGLIST)) := $(PRIORITY_$(word $i,$(REGLIST)))) \
$(eval UID_$(word $i,$(PROGLIST)) := $(UID_$(word $i,$(REGLIST)))) \
$(eval GID_$(word $i,$(PROGLIST)) := $(GID_$(word $i,$(REGLIST)))) \
$(eval MODE_$(word $i,$(PROGLIST)) := $(MODE_$(word $i,$(REGLIST)))) \
)
# Emit the application's configured attributes as absolute ELF symbols
# (nx_stacksize, nx_priority, and nx_uid/nx_gid/nx_mode under
# CONFIG_SCHED_USER_IDENTITY) so the binary loader can recover them.
# Per-target so each PROGLIST entry picks up its own STACKSIZE_/PRIORITY_.
$(PROGLIST): MODLDFLAGS += \
$(if $(STACKSIZE_$@),--defsym nx_stacksize=$(STACKSIZE_$@)) \
$(if $(filter-out SCHED_PRIORITY_DEFAULT,$(PRIORITY_$@)),--defsym nx_priority=$(PRIORITY_$@))
ifeq ($(CONFIG_SCHED_USER_IDENTITY),y)
$(PROGLIST): MODLDFLAGS += \
$(if $(UID_$@),--defsym nx_uid=$(UID_$@)) \
$(if $(GID_$@),--defsym nx_gid=$(GID_$@)) \
$(if $(MODE_$@),--defsym nx_mode=$(MODE_$@))
endif
# Keep the attribute symbols through --strip-unneeded so the binary loader
# can still read them from the stripped runtime image in bin/.
$(PROGLIST): NX_KEEP = $(if $(STACKSIZE_$@),-K nx_stacksize) $(if $(filter-out SCHED_PRIORITY_DEFAULT,$(PRIORITY_$@)),-K nx_priority) $(if $(UID_$@),-K nx_uid) $(if $(GID_$@),-K nx_gid) $(if $(MODE_$@),-K nx_mode)
endif
# Condition flags
DO_REGISTRATION ?= y
ifeq ($(PROGNAME),)
DO_REGISTRATION = n
endif
ifeq ($(WASM_BUILD),y)
DO_REGISTRATION = n
endif
ifeq ($(BUILD_MODULE),y)
DO_REGISTRATION = n
endif
# Compile flags, notice the default flags only suitable for flat build
ZIGELFFLAGS ?= $(ZIGFLAGS)
RUSTELFFLAGS ?= $(RUSTFLAGS)
DELFFLAGS ?= $(DFLAGS)
SWIFTELFFLAGS ?= $(SWIFTFLAGS)
DEPPATH += --dep-path .
DEPPATH += --obj-path .
@ -191,239 +95,141 @@ VPATH += :.
# Targets follow
all:: $(PREFIX).built
@:
all:: $(OBJS)
.PHONY: clean depend distclean
.PRECIOUS: $(BIN)
define ELFASSEMBLE
$(ECHO_BEGIN)"AS: $1 "
$(Q) $(MODULECC) -c $(MODAELFFLAGS) $($(strip $1)_AELFFLAGS) $1 -o $2
$(ECHO_END)
@echo "AS: $1"
$(Q) $(CC) -c $(AELFFLAGS) $($(strip $1)_AELFFLAGS) $1 -o $2
endef
define ELFCOMPILE
$(ECHO_BEGIN)"CC: $1 "
$(Q) $(MODULECC) -c $(MODCFLAGS) $($(strip $1)_CELFFLAGS) $1 -o $2
$(ECHO_END)
@echo "CC: $1"
$(Q) $(CC) -c $(CELFFLAGS) $($(strip $1)_CELFFLAGS) $1 -o $2
endef
define ELFCOMPILEXX
$(ECHO_BEGIN)"CXX: $1 "
$(Q) $(CXX) -c $(MODCXXFLAGS) $($(strip $1)_CXXELFFLAGS) $1 -o $2
$(ECHO_END)
@echo "CXX: $1"
$(Q) $(CXX) -c $(CXXELFFLAGS) $($(strip $1)_CXXELFFLAGS) $1 -o $2
endef
define ELFCOMPILERUST
$(ECHO_BEGIN)"RUSTC: $1 "
@echo "RUSTC: $1"
$(Q) $(RUSTC) --emit obj $(RUSTELFFLAGS) $($(strip $1)_RUSTELFFLAGS) $1 -o $2
$(ECHO_END)
endef
# Remove target suffix here since zig compiler add .o automatically
define ELFCOMPILEZIG
$(ECHO_BEGIN)"ZIG: $1 "
$(Q) $(ZIG) build-obj $(ZIGELFFLAGS) $($(strip $1)_ZIGELFFLAGS) --name $(basename $2) $1
$(ECHO_END)
endef
define ELFCOMPILED
$(ECHO_BEGIN)"DC: $1 "
$(Q) $(DC) -c $(DELFFLAGS) $($(strip $1)_DELFFLAGS) $1 -of $2
$(ECHO_END)
endef
define ELFCOMPILESWIFT
$(ECHO_BEGIN)"SWIFTC: $1 "
$(Q) $(SWIFTC) -c $(SWIFTELFFLAGS) $($(strip $1)_SWIFTELFFLAGS) $1 -o $2
$(ECHO_END)
endef
define ELFLD
$(ECHO_BEGIN)"LD: $2 "
$(Q) $(MODULELD) $(MODLDFLAGS) $(LDMAP) $(LDLIBPATH) $(ARCHCRT0OBJ) $1 $(LDSTARTGROUP) $(LDLIBS) $(LDENDGROUP) -o $2
$(ECHO_END)
@echo "LD: $2"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) $(ARCHCRT0OBJ) $1 $(LDLIBS) -o $2
endef
# rename "main()" in $1 to "xxx_main()" and save to $2
define RENAMEMAIN
$(ECHO_BEGIN)"Rename main() in $1 and save to $2"
$(Q) ${shell cat $1 | sed -e "s/fn[ ]\+main/fn $(addsuffix _main,$(PROGSYM_$@))/" > $2}
$(ECHO_END)
endef
$(RAOBJS): $(PREFIX)%.s$(SUFFIX)$(OBJEXT): %.s
$(if $(and $(CONFIG_MODULES),$(MODAELFFLAGS)), \
$(RAOBJS): %.s$(SUFFIX)$(OBJEXT): %.s
$(if $(and $(CONFIG_BUILD_LOADABLE),$(AELFFLAGS)), \
$(call ELFASSEMBLE, $<, $@), $(call ASSEMBLE, $<, $@))
$(CAOBJS): $(PREFIX)%.S$(SUFFIX)$(OBJEXT): %.S
$(if $(and $(CONFIG_MODULES),$(MODAELFFLAGS)), \
$(CAOBJS): %.S$(SUFFIX)$(OBJEXT): %.S
$(if $(and $(CONFIG_BUILD_LOADABLE),$(AELFFLAGS)), \
$(call ELFASSEMBLE, $<, $@), $(call ASSEMBLE, $<, $@))
$(COBJS): $(PREFIX)%.c$(SUFFIX)$(OBJEXT): %.c
$(if $(and $(CONFIG_MODULES),$(MODCFLAGS)), \
$(COBJS): %.c$(SUFFIX)$(OBJEXT): %.c
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
$(call ELFCOMPILE, $<, $@), $(call COMPILE, $<, $@))
$(CXXOBJS): $(PREFIX)%$(CXXEXT)$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(if $(and $(CONFIG_MODULES),$(MODCXXFLAGS)), \
$(CXXOBJS): %$(CXXEXT)$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \
$(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@))
$(RUSTOBJS): $(PREFIX)%$(RUSTEXT)$(SUFFIX)$(OBJEXT): %$(RUSTEXT)
$(if $(and $(CONFIG_MODULES),$(CELFFLAGS)), \
$(RUSTOBJS): %$(RUSTEXT)$(SUFFIX)$(OBJEXT): %$(RUSTEXT)
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
$(call ELFCOMPILERUST, $<, $@), $(call COMPILERUST, $<, $@))
$(ZIGOBJS): $(PREFIX)%$(ZIGEXT)$(SUFFIX)$(OBJEXT): %$(ZIGEXT)
$(if $(and $(CONFIG_MODULES), $(CELFFLAGS)), \
$(call ELFCOMPILEZIG, $<, $@), $(call COMPILEZIG, $<, $@))
$(DOBJS): $(PREFIX)%$(DEXT)$(SUFFIX)$(OBJEXT): %$(DEXT)
$(if $(and $(CONFIG_MODULES), $(CELFFLAGS)), \
$(call ELFCOMPILED, $<, $@), $(call COMPILED, $<, $@))
$(SWIFTOBJS): $(PREFIX)%$(SWIFTEXT)$(SUFFIX)$(OBJEXT): %$(SWIFTEXT)
$(if $(and $(CONFIG_MODULES), $(CELFFLAGS)), \
$(call ELFCOMPILESWIFT, $<, $@), $(call COMPILESWIFT, $<, $@))
AROBJS :=
ifneq ($(OBJS),)
SORTOBJS := $(sort $(OBJS))
$(eval $(call SPLITVARIABLE,OBJS_SPILT,$(SORTOBJS),100))
$(foreach BATCH, $(OBJS_SPILT_TOTAL), \
$(foreach obj, $(OBJS_SPILT_$(BATCH)), \
$(eval substitute := $(patsubst %$(OBJEXT),%_$(BATCH)$(OBJEXT),$(obj))) \
$(eval AROBJS += $(substitute)) \
$(eval $(call AROBJSRULES, $(substitute),$(obj))) \
) \
)
endif
$(PREFIX).built: $(AROBJS)
$(call SPLITVARIABLE,ALL_OBJS,$(AROBJS),100)
$(foreach BATCH, $(ALL_OBJS_TOTAL), \
$(if $(strip $(ALL_OBJS_$(BATCH))), \
$(shell $(call ARLOCK, $(call CONVERT_PATH,$(BIN)), $(ALL_OBJS_$(BATCH)))) \
) \
)
$(Q) touch $@
archive:
$(call ARCHIVE_ADD, $(call CONVERT_PATH,$(BIN)), $(OBJS))
ifeq ($(BUILD_MODULE),y)
$(MAINCXXOBJ): $(PREFIX)%$(CXXEXT)$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(if $(and $(CONFIG_MODULES),$(MODCXXFLAGS)), \
$(MAINCXXOBJ): %$(CXXEXT)$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \
$(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@))
$(MAINCOBJ): $(PREFIX)%.c$(SUFFIX)$(OBJEXT): %.c
$(if $(and $(CONFIG_MODULES),$(MODCFLAGS)), \
$(MAINCOBJ): %.c$(SUFFIX)$(OBJEXT): %.c
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
$(call ELFCOMPILE, $<, $@), $(call COMPILE, $<, $@))
$(MAINZIGOBJ): $(PREFIX)%$(ZIGEXT)$(SUFFIX)$(OBJEXT): %$(ZIGEXT)
$(if $(and $(CONFIG_MODULES),$(CELFFLAGS)), \
$(call ELFCOMPILEZIG, $<, $@), $(call COMPILEZIG, $<, $@))
PROGLIST := $(wordlist 1,$(words $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ)),$(PROGNAME))
PROGLIST := $(addprefix $(BINDIR)$(DELIM),$(PROGLIST))
PROGOBJ := $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ)
$(MAINDOBJ): $(PREFIX)%$(DEXT)$(SUFFIX)$(OBJEXT): %$(DEXT)
$(if $(and $(CONFIG_MODULES),$(CELFFLAGS)), \
$(call ELFCOMPILED, $<, $@), $(call COMPILED, $<, $@))
$(MAINSWIFTOBJ): $(PREFIX)%$(SWIFTEXT)$(SUFFIX)$(OBJEXT): %$(SWIFTEXT)
$(if $(and $(CONFIG_MODULES),$(CELFFLAGS)), \
$(call ELFCOMPILESWIFT, $<, $@), $(call COMPILESWIFT, $<, $@))
$(PROGLIST): $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ) $(MAINZIGOBJ) $(MAINDOBJ) $(MAINSWIFTOBJ)
$(PROGLIST): $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ)
$(Q) mkdir -p $(BINDIR)
$(call ELFLD, $(PROGOBJ_$@), $(call CONVERT_PATH,$@))
$(Q) chmod +x $@
ifneq ($(CONFIG_DEBUG_SYMBOLS),)
$(Q) mkdir -p $(BINDIR_DEBUG)
$(Q) cp $@ $(BINDIR_DEBUG)
$(Q) $(MODULESTRIP) $(NX_KEEP) $@
$(call ELFLD,$(firstword $(PROGOBJ)),$(call CONVERT_PATH,$(firstword $(PROGLIST))))
$(Q) chmod +x $(firstword $(PROGLIST))
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(firstword $(PROGLIST))
endif
$(eval PROGLIST=$(filter-out $(firstword $(PROGLIST)),$(PROGLIST)))
$(eval PROGOBJ=$(filter-out $(firstword $(PROGOBJ)),$(PROGOBJ)))
install:: $(PROGLIST)
@:
else
$(MAINCXXOBJ): $(PREFIX)%$(CXXEXT)$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(eval $<_CXXFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(addsuffix _main,$(PROGSYM_$@))})
$(eval $<_CXXELFFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(addsuffix _main,$(PROGSYM_$@))})
$(if $(and $(CONFIG_MODULES),$(MODCXXFLAGS)), \
MAINNAME := $(addsuffix _main,$(PROGNAME))
$(MAINCXXOBJ): %$(CXXEXT)$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(eval $<_CXXFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(firstword $(MAINNAME))})
$(eval $<_CXXELFFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(firstword $(MAINNAME))})
$(eval MAINNAME=$(filter-out $(firstword $(MAINNAME)),$(MAINNAME)))
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \
$(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@))
$(MAINCOBJ): $(PREFIX)%.c$(SUFFIX)$(OBJEXT): %.c
$(eval $<_CFLAGS += ${DEFINE_PREFIX}main=$(addsuffix _main,$(PROGSYM_$@)))
$(eval $<_CELFFLAGS += ${DEFINE_PREFIX}main=$(addsuffix _main,$(PROGSYM_$@)))
$(if $(and $(CONFIG_MODULES),$(MODCFLAGS)), \
$(MAINCOBJ): %.c$(SUFFIX)$(OBJEXT): %.c
$(eval $<_CFLAGS += ${shell $(DEFINE) "$(CC)" main=$(firstword $(MAINNAME))})
$(eval $<_CELFFLAGS += ${shell $(DEFINE) "$(CC)" main=$(firstword $(MAINNAME))})
$(eval MAINNAME=$(filter-out $(firstword $(MAINNAME)),$(MAINNAME)))
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
$(call ELFCOMPILE, $<, $@), $(call COMPILE, $<, $@))
$(MAINRUSTOBJ): $(PREFIX)%$(RUSTEXT)$(SUFFIX)$(OBJEXT): %$(RUSTEXT)
$(if $(and $(CONFIG_MODULES),$(CELFFLAGS)), \
$(MAINRUSTOBJ): %$(RUSTEXT)$(SUFFIX)$(OBJEXT): %$(RUSTEXT)
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
$(call ELFCOMPILERUST, $<, $@), $(call COMPILERUST, $<, $@))
$(MAINZIGOBJ): $(PREFIX)%$(ZIGEXT)$(SUFFIX)$(OBJEXT): %$(ZIGEXT)
$(Q) $(call RENAMEMAIN, $<, $(basename $<)_tmp.zig)
$(if $(and $(CONFIG_MODULES),$(CELFFLAGS)), \
$(call ELFCOMPILEZIG, $(basename $<)_tmp.zig, $@), $(call COMPILEZIG, $(basename $<)_tmp.zig, $@))
$(Q) rm -f $(basename $<)_tmp.zig
$(MAINDOBJ): $(PREFIX)%$(DEXT)$(SUFFIX)$(OBJEXT): %$(DEXT)
$(if $(and $(CONFIG_MODULES),$(CELFFLAGS)), \
$(call ELFCOMPILED, $<, $@), $(call COMPILED, $<, $@))
$(MAINSWIFTOBJ): $(PREFIX)%$(SWIFTEXT)$(SUFFIX)$(OBJEXT): %$(SWIFTEXT)
$(if $(and $(CONFIG_MODULES),$(CELFFLAGS)), \
$(call ELFCOMPILESWIFT, $<, $@), $(call COMPILESWIFT, $<, $@))
install::
@:
endif # BUILD_MODULE
postinstall::
@:
context::
ifeq ($(DO_REGISTRATION),y)
ifneq ($(PROGNAME),)
REGLIST := $(addprefix $(BUILTIN_REGISTRY)$(DELIM),$(addsuffix .bdat,$(PROGNAME)))
APPLIST := $(PROGNAME)
$(REGLIST): $(DEPCONFIG) Makefile
$(eval PROGNAME_$@ := $(basename $(notdir $@)))
$(eval PROGSYM_$@ := $(subst -,_,$(PROGNAME_$@)))
ifeq ($(CONFIG_SCHED_USER_IDENTITY),y)
$(call REGISTER,$(PROGNAME_$@),$(PRIORITY_$@),$(STACKSIZE_$@),$(if $(BUILD_MODULE),,$(PROGSYM_$@)_main),$(UID_$@),$(GID_$@),$(MODE_$@))
else
$(call REGISTER,$(PROGNAME_$@),$(PRIORITY_$@),$(STACKSIZE_$@),$(if $(BUILD_MODULE),,$(PROGSYM_$@)_main))
endif
$(call REGISTER,$(firstword $(APPLIST)),$(firstword $(PRIORITY)),$(firstword $(STACKSIZE)),$(if $(BUILD_MODULE),,$(firstword $(APPLIST))_main))
$(eval APPLIST=$(filter-out $(firstword $(APPLIST)),$(APPLIST)))
$(if $(filter-out $(firstword $(PRIORITY)),$(PRIORITY)),$(eval PRIORITY=$(filter-out $(firstword $(PRIORITY)),$(PRIORITY))))
$(if $(filter-out $(firstword $(STACKSIZE)),$(STACKSIZE)),$(eval STACKSIZE=$(filter-out $(firstword $(STACKSIZE)),$(STACKSIZE))))
register:: $(REGLIST)
@:
else
register::
@:
endif
$(PREFIX).depend: Makefile $(wildcard $(foreach SRC, $(SRCS), $(addsuffix /$(SRC), $(subst :, ,$(VPATH))))) $(DEPCONFIG)
$(shell echo "# Gen Make.dep automatically" >$(PREFIX)Make.dep)
$(call SPLITVARIABLE,ALL_DEP_OBJS,$^,100)
$(foreach BATCH, $(ALL_DEP_OBJS_TOTAL), \
$(shell $(MKDEP) $(DEPPATH) --obj-suffix .c$(SUFFIX)$(OBJEXT) "$(CC)" -- $(CFLAGS) -- $(filter %.c,$(ALL_DEP_OBJS_$(BATCH))) >>$(PREFIX)Make.dep) \
$(shell $(MKDEP) $(DEPPATH) --obj-suffix .S$(SUFFIX)$(OBJEXT) "$(CC)" -- $(CFLAGS) -- $(filter %.S,$(ALL_DEP_OBJS_$(BATCH))) >>$(PREFIX)Make.dep) \
$(shell $(MKDEP) $(DEPPATH) --obj-suffix $(CXXEXT)$(SUFFIX)$(OBJEXT) "$(CXX)" -- $(CXXFLAGS) -- $(filter %$(CXXEXT),$(ALL_DEP_OBJS_$(BATCH))) >>$(PREFIX)Make.dep) \
)
.depend: Makefile $(wildcard $(foreach SRC, $(SRCS), $(addsuffix /$(SRC), $(subst :, ,$(VPATH))))) $(DEPCONFIG)
$(Q) $(MKDEP) $(DEPPATH) --obj-suffix .c$(SUFFIX)$(OBJEXT) "$(CC)" -- $(CFLAGS) -- $(filter %.c,$^) >Make.dep
$(Q) $(MKDEP) $(DEPPATH) --obj-suffix .S$(SUFFIX)$(OBJEXT) "$(CC)" -- $(CFLAGS) -- $(filter %.S,$^) >>Make.dep
$(Q) $(MKDEP) $(DEPPATH) --obj-suffix $(CXXEXT)$(SUFFIX)$(OBJEXT) "$(CXX)" -- $(CXXFLAGS) -- $(filter %$(CXXEXT),$^) >>Make.dep
$(Q) touch $@
depend:: $(PREFIX).depend
@:
depend:: .depend
clean::
$(call DELFILE, .built)
$(call CLEANAROBJS)
$(call CLEAN)
distclean:: clean
$(call DELFILE, .kconfig)
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
-include $(PREFIX)Make.dep
# Include Wasm specific definitions
include $(APPDIR)/tools/Wasm.mk
-include Make.dep

View file

@ -1,83 +0,0 @@
# ##############################################################################
# apps/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
# ~~~
# Important note:
# This CMakeLists.txt is not meant as a top-level CMakeLists.txt. Instead,
# CMake must be run using the top-level CMakeLists.txt from the nuttx
# repository and point to this directory via NUTTX_APPS_DIR. For example:
# cmake -S <nuttx-dir> -B <build-dir> [...] -DNUTTX_APPS_DIR=<apps-dir>
# ~~~
if(CONFIG_APPS_DIR)
# add apps cmake modules
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(nuttx_add_luamod)
include(nuttx_add_wamrmod)
include(nuttx_add_rust)
include(nuttx_wasm_interface)
nuttx_add_library(apps)
if(NOT EXISTS {NUTTX_APPS_BINDIR}/dummy.c)
file(TOUCH ${NUTTX_APPS_BINDIR}/dummy.c)
endif()
target_sources(apps PRIVATE ${NUTTX_APPS_BINDIR}/dummy.c)
endif()
file(MAKE_DIRECTORY ${NUTTX_APPS_BINDIR}/include)
include_directories(include)
include_directories(${NUTTX_APPS_BINDIR}/include)
add_subdirectory(audioutils)
add_subdirectory(benchmarks)
add_subdirectory(boot)
add_subdirectory(canutils)
add_subdirectory(crypto)
add_subdirectory(fsutils)
add_subdirectory(games)
add_subdirectory(graphics)
add_subdirectory(industry)
add_subdirectory(inertial)
add_subdirectory(interpreters)
add_subdirectory(logging)
add_subdirectory(lte)
add_subdirectory(math)
add_subdirectory(mlearning)
add_subdirectory(netutils)
add_subdirectory(nshlib)
add_subdirectory(platform)
add_subdirectory(sdr)
add_subdirectory(system)
add_subdirectory(tee)
add_subdirectory(testing)
add_subdirectory(videoutils)
add_subdirectory(wireless)
# add examples and external at the end to allow library dependencies
add_subdirectory(examples)
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/external)
add_subdirectory(external)
endif()
add_subdirectory(tools) # after traversing all subdirectories
add_subdirectory(builtin) # must be last
nuttx_generate_kconfig()

6
DISCLAIMER Normal file
View file

@ -0,0 +1,6 @@
Apache NuttX is an effort undergoing incubation at The Apache Software Foundation (ASF),
sponsored by the Apache Incubator. Incubation is required of all newly accepted projects
until a further review indicates that the infrastructure, communications, and decision
making process have stabilized in a manner consistent with other successful ASF projects.
While incubation status is not necessarily a reflection of the completeness or stability
of the code, it does indicate that the project has yet to be fully endorsed by the ASF.

View file

@ -1,8 +1,6 @@
############################################################################
# apps/Directory.mk
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
@ -24,16 +22,11 @@ include $(APPDIR)/Make.defs
# Sub-directories that have been built or configured.
SUBDIRS := $(dir $(wildcard */Makefile))
CONFIGSUBDIRS := $(filter-out $(dir $(wildcard */Kconfig)),$(SUBDIRS))
CLEANSUBDIRS := $(dir $(wildcard *$(DELIM).built))
CLEANSUBDIRS += $(dir $(wildcard */.depend))
CLEANSUBDIRS += $(dir $(wildcard */.kconfig))
SUBDIRS := $(dir $(wildcard *$(DELIM)Makefile))
CONFIGSUBDIRS := $(filter-out $(dir $(wildcard *$(DELIM)Kconfig)),$(SUBDIRS))
CLEANSUBDIRS += $(dir $(wildcard *$(DELIM).depend))
CLEANSUBDIRS += $(dir $(wildcard *$(DELIM).kconfig))
CLEANSUBDIRS := $(sort $(CLEANSUBDIRS))
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
CONFIGSUBDIRS := $(subst /,\,$(CONFIGSUBDIRS))
CLEANSUBDIRS := $(subst /,\,$(CLEANSUBDIRS))
endif
all: nothing
@ -50,16 +43,15 @@ install:
preconfig: $(foreach SDIR, $(CONFIGSUBDIRS), $(SDIR)_preconfig)
ifneq ($(MENUDESC),)
$(Q) $(MKKCONFIG) -m $(MENUDESC)
endif
$(Q) touch .kconfig
endif
clean: $(foreach SDIR, $(CLEANSUBDIRS), $(SDIR)_clean)
@:
distclean: $(foreach SDIR, $(CLEANSUBDIRS), $(SDIR)_distclean)
ifneq ($(MENUDESC),)
$(call DELFILE, Kconfig)
endif
$(call DELFILE, .kconfig)
endif
-include Make.dep

553
LICENSE
View file

@ -1282,7 +1282,7 @@ apps/system/telnet/telnet_client.c
Copyright (C) 2017 Gregory Nutt. All rights reserved.
Author: Gregory Nutt <gnutt@nuttx.org>
The original authors of libtelnet are listed below. Per their license,
The original authors of libtelnet are listed below. Per their licesne,
"The author or authors of this code dedicate any and all copyright
interest in this code to the public domain. We make this dedication for
the benefit of the public at large and to the detriment of our heirs and
@ -1723,554 +1723,3 @@ apps/netutils/chat/chat.h
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
apps/testing/crypto/3descbc.c
=========================
$OpenBSD: des3.c,v 1.8 2010/10/15 10:39:12 jsg Exp $
Copyright (c) 2002 Markus Friedl. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
apps/testing/crypto/aesctr.c
=========================
$OpenBSD: aesctr.c,v 1.1 2005/05/25 05:47:53 markus Exp $
Copyright (c) 2005 Markus Friedl <markus@openbsd.org>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
apps/testing/crypto/aesxts.c
=========================
$OpenBSD: aes_xts.c,v 1.2 2013/10/06 16:59:34 jsing Exp $
Copyright (c) 2002 Markus Friedl. All rights reserved.
Copyright (c) 2008 Damien Miller. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
apps/testing/crypto/hmac.c
=========================
Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
apps/crypto/tinydtls
======================
/*******************************************************************************
* Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016 Olaf Bergmann (TZI) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
* Contributors:
* Olaf Bergmann - initial API and implementation
* Hauke Mehrtens - memory optimization, ECC integration
*******************************************************************************/
apps/netutils/wakaama
=====================
*Eclipse Distribution License - v 1.0*
Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Eclipse Foundation, Inc. nor the names of
its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
apps/crypto/libsodium
=====================
ISC License
Copyright (c) 2013-2023
Frank Denis <j at pureftpd dot org>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
apps/crypto/wolfssl
===================
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
apps/testing/sd_stress
apps/testing/sd_bench
===================
Copyright (c) 2016-2021 PX4 Development Team. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name PX4 nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
netutils/bare/
==============
MIT License
Copyright (c) 2022 Frank Smit
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.

135
Make.defs
View file

@ -1,8 +1,6 @@
############################################################################
# apps/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
@ -21,7 +19,17 @@
############################################################################
TOPDIR ?= $(APPDIR)/import
-include $(TOPDIR)/Make.defs
include $(TOPDIR)/Make.defs
# The GNU make CURDIR will always be a POSIX-like path with forward slashes
# as path segment separators. This is fine for the above inclusions but
# will cause problems later for the native build. If we know that this is
# a native build, then we need to fix up the APPDIR path for subsequent
# use
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
APPDIR := ${shell echo %CD%}
endif
# Application Directories
@ -29,16 +37,11 @@ TOPDIR ?= $(APPDIR)/import
# CLEANDIRS is the list of all top-level directories containing Makefiles.
# It is used only for cleaning.
BUILDIRS := $(dir $(wildcard $(APPDIR)/*/Make.defs))
BUILDIRS := $(filter-out $(APPDIR)/import/,$(BUILDIRS))
CONFIGDIRS := $(filter-out $(APPDIR)/builtin/,$(BUILDIRS))
CONFIGDIRS := $(filter-out $(dir $(wildcard $(APPDIR)/*/Kconfig)),$(CONFIGDIRS))
CLEANDIRS := $(dir $(wildcard $(APPDIR)/*/Makefile))
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
BUILDIRS := $(subst /,\,$(BUILDIRS))
CONFIGDIRS := $(subst /,\,$(CONFIGDIRS))
CLEANDIRS := $(subst /,\,$(CLEANDIRS))
endif
BUILDIRS := $(dir $(wildcard $(APPDIR)$(DELIM)*$(DELIM)Make.defs))
BUILDIRS := $(filter-out $(APPDIR)$(DELIM)import$(DELIM),$(BUILDIRS))
CONFIGDIRS := $(filter-out $(APPDIR)$(DELIM)builtin$(DELIM),$(BUILDIRS))
CONFIGDIRS := $(filter-out $(dir $(wildcard $(APPDIR)$(DELIM)*$(DELIM)Kconfig)),$(CONFIGDIRS))
CLEANDIRS := $(dir $(wildcard $(APPDIR)$(DELIM)*$(DELIM)Makefile))
# CONFIGURED_APPS is the application directories that should be built in
# the current configuration.
@ -46,7 +49,7 @@ endif
CONFIGURED_APPS :=
define Add_Application
include $(1)Make.defs
include $(1)Make.defs
endef
$(foreach BDIR, $(BUILDIRS), $(eval $(call Add_Application,$(BDIR))))
@ -55,9 +58,6 @@ $(foreach BDIR, $(BUILDIRS), $(eval $(call Add_Application,$(BDIR))))
CXXEXT ?= .cxx
RUSTEXT ?= .rs
ZIGEXT ?= .zig
DEXT ?= .d
SWIFTEXT ?= .swift
# Library path
@ -66,12 +66,10 @@ LIBPATH ?= $(TOPDIR)$(DELIM)staging
# The install path
BINDIR ?= $(APPDIR)$(DELIM)bin
BINDIR_DEBUG ?= $(APPDIR)$(DELIM)bin_debug
# The final build target
BIN ?= $(APPDIR)$(DELIM)libapps$(LIBEXT)
WBIN ?= $(APPDIR)$(DELIM)wasm$(DELIM)libwasm$(LIBEXT)
BIN ?= $(APPDIR)$(DELIM)libapps$(LIBEXT)
# Tools
@ -83,108 +81,21 @@ endif
# Builtin Registration
BUILTIN_REGISTRY ?= $(APPDIR)$(DELIM)builtin$(DELIM)registry
DEPCONFIG ?= $(TOPDIR)$(DELIM).config
BUILTIN_REGISTRY = $(APPDIR)$(DELIM)builtin$(DELIM)registry
DEPCONFIG = $(TOPDIR)$(DELIM).config
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
ifeq ($(CONFIG_SCHED_USER_IDENTITY),y)
define REGISTER
$(Q) echo Register: $1
$(Q) echo { "$(subst ",,$(1))", $2, $3, $(patsubst ,0,$(subst ",,$(4))), $(patsubst ,0,$(5)), $(patsubst ,0,$(6)), $(patsubst ,0555,$(7))}, > "$(BUILTIN_REGISTRY)$(DELIM)$1.bdat"
$(Q) echo int $(subst ",,$(4))(int argc, char *argv[]); > "$(BUILTIN_REGISTRY)$(DELIM)$1.pdat"
$(Q) touch $(BUILTIN_REGISTRY)$(DELIM).updated"
endef
else
define REGISTER
$(Q) echo Register: $1
$(Q) echo { "$(subst ",,$(1))", $2, $3, $(subst ",,$(4)) }, > "$(BUILTIN_REGISTRY)$(DELIM)$1.bdat"
$(Q) echo int $(subst ",,$(4))(int argc, char *argv[]); > "$(BUILTIN_REGISTRY)$(DELIM)$1.pdat"
$(Q) touch $(BUILTIN_REGISTRY)$(DELIM).updated"
endef
endif
else
ifeq ($(CONFIG_SCHED_USER_IDENTITY),y)
define REGISTER
$(Q) echo "{ \"$1\", $2, $3, $(patsubst ,0,$(4)), $(patsubst ,0,$(5)), $(patsubst ,0,$(6)), $(patsubst ,0555,$(7)) }," > "$(BUILTIN_REGISTRY)$(DELIM)$1.bdat"
$(Q) echo { \"$1\", $2, $3, $4 }, > "$(BUILTIN_REGISTRY)$(DELIM)$1.bdat"
$(Q) if [ ! -z $4 ]; then \
echo "int $4(int argc, char *argv[]);" > "$(BUILTIN_REGISTRY)$(DELIM)$1.pdat"; \
fi;
$(Q) touch "$(BUILTIN_REGISTRY)$(DELIM).updated"
endef
else
define REGISTER
$(Q) echo "Register: $1"
$(Q) echo "{ \"$1\", $2, $3, $4 }," > "$(BUILTIN_REGISTRY)$(DELIM)$1.bdat"
$(Q) if [ ! -z $4 ]; then \
echo "int $4(int argc, char *argv[]);" > "$(BUILTIN_REGISTRY)$(DELIM)$1.pdat"; \
fi;
$(Q) touch "$(BUILTIN_REGISTRY)$(DELIM).updated"
endef
endif
endif
# Standard include path
CFLAGS += ${INCDIR_PREFIX}"$(APPDIR)$(DELIM)include"
CXXFLAGS += ${INCDIR_PREFIX}"$(APPDIR)$(DELIM)include"
CFLAGS += ${shell $(INCDIR) "$(CC)" "$(APPDIR)$(DELIM)include"}
CXXFLAGS += ${shell $(INCDIR) "$(CC)" "$(APPDIR)$(DELIM)include"}
NUTTXLIB ?= $(call CONVERT_PATH,$(TOPDIR)$(DELIM)staging)
# SPLITVARIABLE - Split long variables into specified batches
# Usage: $(call SPLITVARIABLE, variable-def, variable-ref, batch-size)
#
# Example: VAR:= a b c x y z foo bar
# $(call SPLITVARIABLE, VAR, $(VAR), 3)
# $(foreach, num, $(VAR_TOTAL), $(shell echo $(VAR_$(num))))
# Return new variable definition:
# $(variable-def)_TOTAL : total split sequence , start with 1.
# $(variable-def)_$(num) : newly defined variable , ended with batch num.
# In the case above:
# $(VAR_TOTAL) = 1 2 3
# $(VAR_1) = a b c
# $(VAR_2) = x y z
# $(VAR_3) = foo bar
define SPLITVARIABLE
$(eval SPLITVARIABLE_PREFIX = $(1))
$(eval BATCH_SIZE = $(3))
$(eval TOTAL_BATCH = $(shell expr $(words $(2)) / $(BATCH_SIZE) + 1))
$(eval $(SPLITVARIABLE_PREFIX)_TOTAL = $(shell seq 1 $(TOTAL_BATCH)))
$(foreach idx, $($(SPLITVARIABLE_PREFIX)_TOTAL), \
$(eval FROMINDEX=$(shell expr 1 + $(idx) \* $(BATCH_SIZE) - $(BATCH_SIZE))) \
$(eval $(SPLITVARIABLE_PREFIX)_$(idx)=$(wordlist $(FROMINDEX), $(shell expr $(FROMINDEX) + $(BATCH_SIZE) - 1), $(2))) \
)
endef
define ARLOCK
flock $1.lock $(call ARCHIVE, $1, $(2))
endef
# dynamic AR target
define AROBJSRULES
$(1) : $(2)
@ cp $(2) $(1)
endef
# CLEANAROBJS - del AR target files exclusively
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
define CLEANAROBJS
$(call DELFILE,$(subst /,\,$(AROBJS)))
$(call DELFILE,$(subst /,\,$(OBJS)))
$(eval OBJS :=)
endef
else
define CLEANAROBJS
$(call SPLITVARIABLE,CLEAN_AROBJS,${AROBJS},100)
$(foreach BATCH, $(CLEAN_AROBJS_TOTAL), \
$(shell rm -rf $(CLEAN_AROBJS_$(BATCH))))
$(call SPLITVARIABLE,CLEAN_OBJS,${OBJS},100)
$(foreach BATCH, $(CLEAN_OBJS_TOTAL), \
$(shell rm -rf $(CLEAN_OBJS_$(BATCH))))
$(eval OBJS :=)
endef
endif

107
Makefile
View file

@ -1,8 +1,6 @@
############################################################################
# apps/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
@ -22,20 +20,8 @@
export APPDIR = $(CURDIR)
include $(APPDIR)/Make.defs
include $(APPDIR)/tools/Wasm.mk
# The GNU make CURDIR will always be a POSIX-like path with forward slashes
# as path segment separators. This is fine for the above inclusions but
# will cause problems later for the native build. If we know that this is
# a native build, then we need to fix up the APPDIR path for subsequent
# use
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
export APPDIR = $(subst /,\,$(CURDIR))
endif
# Symbol table for loadable apps.
# SYMTABEXT: Extra arguments for mksymtab.sh
SYMTABSRC = symtab_apps.c
SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT))
@ -45,15 +31,16 @@ SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT))
# We first remove libapps.a before letting the other rules add objects to it
# so that we ensure libapps.a does not contain objects from prior build
all: $(BIN)
all:
$(RM) $(BIN)
$(MAKE) $(BIN)
.PHONY: import install dirlinks export .depdirs preconfig depend clean distclean
.PHONY: context postinstall clean_context context_all postinstall_all register register_all
.PHONY: context clean_context context_all register register_all
.PRECIOUS: $(BIN)
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),all)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),install)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),postinstall)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),context)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),register)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),depend)))
@ -68,25 +55,6 @@ $(INCDIR): $(TOPDIR)/tools/incdir.c
IMPORT_TOOLS = $(MKDEP) $(INCDIR)
ifeq ($(CONFIG_TOOLS_WASM_BUILD),y)
configure_wasm:
$(Q) cmake -B$(APPDIR)$(DELIM)tools$(DELIM)Wasm$(DELIM)build \
$(APPDIR)$(DELIM)tools$(DELIM)Wasm \
-DAPPDIR=$(APPDIR) -DTOPDIR=$(TOPDIR) \
-DWASI_SDK_PATH=$(WASI_SDK_PATH) \
-DKCONFIG_FILE_PATH=$(TOPDIR)$(DELIM).config
context_wasm: configure_wasm
$(Q) cmake --build $(APPDIR)$(DELIM)tools$(DELIM)Wasm$(DELIM)build
else
context_wasm:
endif
# In the KERNEL build, we must build and install all of the modules. No
# symbol table is needed
@ -94,12 +62,12 @@ ifeq ($(CONFIG_BUILD_KERNEL),y)
install: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_install)
$(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
.import: $(BIN)
.import: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
$(Q) for app in ${CONFIGURED_APPS}; do \
$(MAKE) -C "$${app}" archive ; \
done
$(Q) install libapps.a $(APPDIR)$(DELIM)import$(DELIM)libs
$(Q) $(MAKE) install
$(Q) $(MAKE) postinstall
import: $(IMPORT_TOOLS)
$(Q) $(MAKE) context TOPDIR="$(APPDIR)$(DELIM)import"
@ -112,37 +80,32 @@ else
# In FLAT and protected modes, the modules have already been created. A
# symbol table is required.
ifeq ($(CONFIG_MODULES),)
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
ifeq ($(CONFIG_BUILD_LOADABLE),)
$(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
else
$(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
$(call LINK_WASM)
endif
$(Q) for app in ${CONFIGURED_APPS}; do \
$(MAKE) -C "$${app}" archive ; \
done
else
$(SYMTABSRC): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
$(Q) for app in ${CONFIGURED_APPS}; do \
$(MAKE) -C "$${app}" archive ; \
done
$(Q) $(MAKE) install
$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) $(SYMTABEXT) >$@.tmp
$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) >$@.tmp
$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
ifneq ($(CONFIG_ARM_TOOLCHAIN_GHS),y)
$(SYMTABOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@, -fno-lto -fno-builtin)
else
$(SYMTABOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@, -Onolink)
endif
$(call COMPILE, -fno-lto $<, $@)
$(BIN): $(SYMTABOBJ)
$(call ARLOCK, $(call CONVERT_PATH,$(BIN)), $^)
$(call LINK_WASM)
$(call ARCHIVE_ADD, $(call CONVERT_PATH,$(BIN)), $^)
endif # !CONFIG_MODULES
endif # !CONFIG_BUILD_LOADABLE
install: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_install)
$(Q) $(MAKE) postinstall_all
# Link nuttx
@ -178,15 +141,10 @@ dirlinks:
context_all: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_context)
register_all: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_register)
postinstall_all: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_postinstall)
staging:
$(Q) mkdir -p $@
context: | staging
context:
$(Q) $(MAKE) context_all
$(Q) $(MAKE) register_all
$(Q) $(MAKE) context_wasm
Kconfig:
$(foreach SDIR, $(CONFIGDIRS), $(call MAKE_template,$(SDIR),preconfig))
@ -200,9 +158,7 @@ ifneq ($(EXPORTDIR),)
ifneq ($(CONFIG_BUILD_KERNEL),y)
ifneq ($(BUILTIN_REGISTRY),)
for f in "${BUILTIN_REGISTRY}"$(DELIM)*.bdat "${BUILTIN_REGISTRY}"$(DELIM)*.pdat ; do \
if [ -f "$${f}" ]; then \
cp -f "$${f}" "${EXPORTDIR}"$(DELIM)registry ; \
fi \
[ -f "$${f}" ] && cp -f "$${f}" "${EXPORTDIR}"$(DELIM)registry ; \
done
endif
endif
@ -225,18 +181,27 @@ clean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_clean)
$(call DELFILE, $(BIN))
$(call DELFILE, Kconfig)
$(call DELDIR, $(BINDIR))
$(call DELDIR, $(BINDIR_DEBUG))
$(call CLEAN)
distclean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_distclean)
$(call DELFILE, *.lock)
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
$(Q) ( if exist external ( \
echo ********************************************************" \
echo * The external directory/link must be removed manually *" \
echo ********************************************************" \
)
else
$(Q) ( if [ -e external ]; then \
echo "********************************************************"; \
echo "* The external directory/link must be removed manually *"; \
echo "********************************************************"; \
fi; \
)
endif
$(call DELFILE, .depend)
$(call DELFILE, $(SYMTABSRC))
$(call DELFILE, $(SYMTABOBJ))
$(call DELFILE, $(BIN))
$(call DELFILE, Kconfig)
$(call DELDIR, $(BINDIR))
$(call DELDIR, staging)
$(call DELDIR, wasm)
$(call DELDIR, $(APPDIR)$(DELIM)tools$(DELIM)Wasm$(DELIM)build)
$(call CLEAN)

View file

@ -34,7 +34,7 @@ NuttX directory. Like:
If all of the above conditions are TRUE, then NuttX will be able to find the
application directory. If your application directory has a different name or is
located at a different position, then you will have to inform the NuttX build
location at a different position, then you will have to inform the NuttX build
system of that location. There are several ways to do that:
1) You can define `CONFIG_APPS_DIR` to be the full path to your application
@ -140,7 +140,7 @@ project. One must:
main()
```
4. Set the requirements in the file: `Makefile`, specifically the lines:
4. Set the requirements in the file: `Makefile`, specially the lines:
```makefile
PROGNAME = progname
@ -181,8 +181,10 @@ A: Here are three:
You can copy any pieces that you like from the old apps/directory to your
custom apps directory as necessary.
This is documented in `NuttX/boards/README.txt` and `NuttX Porting Guide`
online at <https://cwiki.apache.org/confluence/display/NUTTX/Porting+Guide>.
This is documented in `NuttX/boards/README.txt` and
`nuttx/Documentation/NuttXPortingGuide.html` (Online at
https://bitbucket.org/nuttx/nuttx/src/master/Documentation/NuttXPortingGuide.html#apndxconfigs
under _Build options_). And in the `apps/README.txt` file.
3) If you like the random collection of stuff in the `apps/` directory but
just want to expand the existing components with your own, external
@ -254,5 +256,4 @@ Technology Software Unrestricted (TSU) exception (see the BIS Export Administrat
Regulations, Section 740.13) for both object code and source code.
The following provides more details on the included cryptographic software:
https://tls.mbed.org/supported-ssl-ciphersuites.
https://github.com/intel/tinycrypt
https://tls.mbed.org/supported-ssl-ciphersuites.

View file

@ -1,25 +0,0 @@
# ##############################################################################
# apps/audioutils/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
nuttx_add_subdirectory()
nuttx_generate_kconfig(MENUDESC "Audio Utility libraries")

View file

@ -1,23 +0,0 @@
############################################################################
# apps/audioutils/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
include $(wildcard $(APPDIR)/audioutils/*/Make.defs)

View file

@ -1,25 +0,0 @@
############################################################################
# apps/audioutils/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
MENUDESC = "Audio Utility libraries"
include $(APPDIR)/Directory.mk

View file

@ -1,25 +0,0 @@
# ##############################################################################
# apps/audioutils/fmsynth/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
if(CONFIG_AUDIOUTILS_FMSYNTH_LIB)
target_sources(apps PRIVATE fmsynth.c fmsynth_eg.c fmsynth_op.c)
endif()

View file

@ -1,10 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config AUDIOUTILS_FMSYNTH_LIB
bool "FM Synthesizer Library"
default n
---help---
Enable support for the FM Synthesizer library.

View file

@ -1,25 +0,0 @@
############################################################################
# apps/audioutils/fmsynth/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
ifneq ($(CONFIG_AUDIOUTILS_FMSYNTH_LIB),)
CONFIGURED_APPS += $(APPDIR)/audioutils/fmsynth
endif

View file

@ -1,27 +0,0 @@
############################################################################
# apps/audioutils/fmsynth/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
include $(APPDIR)/Make.defs
CSRCS = fmsynth.c fmsynth_eg.c fmsynth_op.c
include $(APPDIR)/Application.mk

View file

@ -1,270 +0,0 @@
/****************************************************************************
* apps/audioutils/fmsynth/fmsynth.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdlib.h>
#include <audioutils/fmsynth.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define WRAP_ROUND_TIME_SEC (10)
/****************************************************************************
* Private Data
****************************************************************************/
static int max_phase_time;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* name: fetch_feedback
****************************************************************************/
static void fetch_feedback(FAR fmsynth_op_t *ops)
{
while (ops != NULL)
{
fmsynthop_update_feedback(ops);
ops = ops->parallelop;
}
}
/****************************************************************************
* name: update_phase
****************************************************************************/
static void update_phase(FAR fmsynth_sound_t *snd)
{
snd->phase_time++;
if (snd->phase_time >= max_phase_time)
{
snd->phase_time = 0;
}
}
/****************************************************************************
* name: sound_modulate
****************************************************************************/
static int sound_modulate(FAR fmsynth_sound_t *snd)
{
int out = 0;
FAR fmsynth_op_t *op;
if (snd->operators == NULL)
{
return out;
}
fetch_feedback(snd->operators);
for (op = snd->operators; op != NULL; op = op->parallelop)
{
out += fmsynthop_operate(op, snd->phase_time);
}
update_phase(snd);
return out * snd->volume / FMSYNTH_MAX_VOLUME;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* name: fmsynth_initialize
****************************************************************************/
int fmsynth_initialize(int fs)
{
max_phase_time = fs * WRAP_ROUND_TIME_SEC;
return fmsynthop_set_samplerate(fs);
}
/****************************************************************************
* name: create_fmsynthsnd
****************************************************************************/
FAR fmsynth_sound_t *create_fmsynthsnd(FAR fmsynth_sound_t *snd)
{
if (snd)
{
snd->own_allocate = 0;
snd->phase_time = 0;
snd->volume = FMSYNTH_MAX_VOLUME;
snd->operators = NULL;
snd->next_sound = NULL;
}
return snd;
}
/****************************************************************************
* name: fmsynthsnd_create
****************************************************************************/
FAR fmsynth_sound_t *fmsynthsnd_create(void)
{
FAR fmsynth_sound_t *ret;
ret = (FAR fmsynth_sound_t *)malloc(sizeof(fmsynth_sound_t));
if (ret)
{
create_fmsynthsnd(ret);
ret->own_allocate = 1;
}
return ret;
}
/****************************************************************************
* name: fmsynthsnd_delete
****************************************************************************/
void fmsynthsnd_delete(FAR fmsynth_sound_t *snd)
{
if (snd != NULL && snd->own_allocate == 1)
{
free(snd);
}
}
/****************************************************************************
* name: fmsynthsnd_set_operator
****************************************************************************/
int fmsynthsnd_set_operator(FAR fmsynth_sound_t *snd, FAR fmsynth_op_t *op)
{
snd->operators = op;
return OK;
}
/****************************************************************************
* name: fmsynthsnd_set_soundfreq
****************************************************************************/
void fmsynthsnd_set_soundfreq(FAR fmsynth_sound_t *snd, float freq)
{
FAR fmsynth_op_t *op;
for (op = snd->operators; op != NULL; op = op->parallelop)
{
fmsynthop_set_soundfreq(op, freq);
fmsynthop_start(op);
}
}
/****************************************************************************
* name: fmsynthsnd_stop
****************************************************************************/
void fmsynthsnd_stop(FAR fmsynth_sound_t *snd)
{
FAR fmsynth_op_t *op;
for (op = snd->operators; op != NULL; op = op->parallelop)
{
fmsynthop_stop(op);
}
}
/****************************************************************************
* name: fmsynthsnd_set_volume
****************************************************************************/
void fmsynthsnd_set_volume(FAR fmsynth_sound_t *snd, float vol)
{
snd->volume = vol * FMSYNTH_MAX_VOLUME;
}
/****************************************************************************
* name: fmsynthsnd_add_subsound
****************************************************************************/
int fmsynthsnd_add_subsound(FAR fmsynth_sound_t *top,
FAR fmsynth_sound_t *sub)
{
FAR fmsynth_sound_t *s = top;
if (!top || !sub)
{
return ERROR;
}
for (s = top; s->next_sound; s = s->next_sound);
s->next_sound = sub;
return OK;
}
/****************************************************************************
* name: fmsynth_rendering
****************************************************************************/
int fmsynth_rendering(FAR fmsynth_sound_t *snd,
FAR int16_t *sample, int sample_num, int chnum,
fmsynth_tickcb_t cb, unsigned long cbarg)
{
int i;
int ch;
int out;
FAR fmsynth_sound_t *itr;
for (i = 0; i < sample_num; i += chnum)
{
out = 0;
for (itr = snd; itr != NULL; itr = itr->next_sound)
{
out = out + sound_modulate(itr);
}
for (ch = 0; ch < chnum; ch++)
{
*sample++ = (int16_t)out;
}
if (cb != NULL)
{
cb(cbarg);
}
}
if (i > sample_num)
{
i -= chnum;
}
/* Return total bytes stored in the buffer */
return i * sizeof(int16_t);
}

View file

@ -1,209 +0,0 @@
/****************************************************************************
* apps/audioutils/fmsynth/fmsynth_eg.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdlib.h>
#include <limits.h>
#include <audioutils/fmsynth_eg.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define CONVERT_INITVAL(lv) (int)((lv) * FMSYNTH_MAX_EGLEVEL)
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* name: set_egparams
****************************************************************************/
static int set_egparams(int fs,
FAR fmsynth_egparam_t *param,
FAR struct fmsynth_eglevel_s *target_level,
FAR struct fmsynth_eglevel_s *last_level)
{
param->initval = CONVERT_INITVAL(last_level->level);
param->period = fs * target_level->period_ms / 1000;
param->diff2next = CONVERT_INITVAL(target_level->level)
- CONVERT_INITVAL(last_level->level);
if (param->initval < -FMSYNTH_MAX_EGLEVEL ||
param->initval > FMSYNTH_MAX_EGLEVEL || param->period < 0)
{
return -1;
}
return 0;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* name: create_fmsyntheg
****************************************************************************/
FAR fmsynth_eg_t *create_fmsyntheg(FAR fmsynth_eg_t *eg)
{
int i;
if (eg)
{
eg->state = EGSTATE_RELEASED;
eg->state_counter = 0;
for (i = 0; i < EGSTATE_MAX; i++)
{
eg->state_params[i].initval = 0;
eg->state_params[i].period = 0;
}
eg->state_params[EGSTATE_RELEASED].initval = FMSYNTH_MAX_EGLEVEL;
}
return eg;
}
/****************************************************************************
* name: fmsyntheg_create
****************************************************************************/
FAR fmsynth_eg_t *fmsyntheg_create(void)
{
FAR fmsynth_eg_t *ret = (FAR fmsynth_eg_t *)malloc(sizeof(fmsynth_eg_t));
return create_fmsyntheg(ret);
}
/****************************************************************************
* name: fmsyntheg_delete
****************************************************************************/
void fmsyntheg_delete(FAR fmsynth_eg_t *eg)
{
if (eg != NULL)
{
free(eg);
}
}
/****************************************************************************
* name: fmsyntheg_set_param
****************************************************************************/
int fmsyntheg_set_param(FAR fmsynth_eg_t *eg,
int fs, FAR fmsynth_eglevels_t *levels)
{
int errcnt = 0;
if (fs <= 0)
{
return ERROR;
}
errcnt += set_egparams(fs, &eg->state_params[EGSTATE_ATTACK],
&levels->attack, &levels->release);
errcnt += set_egparams(fs, &eg->state_params[EGSTATE_DECAYBREAK],
&levels->decaybrk, &levels->attack);
errcnt += set_egparams(fs, &eg->state_params[EGSTATE_DECAY],
&levels->decay, &levels->decaybrk);
errcnt += set_egparams(fs, &eg->state_params[EGSTATE_SUSTAIN],
&levels->sustain, &levels->decay);
errcnt += set_egparams(fs, &eg->state_params[EGSTATE_RELEASE],
&levels->release, &levels->sustain);
eg->state_params[EGSTATE_RELEASED].initval =
CONVERT_INITVAL(levels->release.level);
return errcnt ? ERROR : OK;
}
/****************************************************************************
* name: fmsyntheg_start
****************************************************************************/
void fmsyntheg_start(FAR fmsynth_eg_t *eg)
{
eg->state = EGSTATE_ATTACK;
eg->state_counter = 0;
}
/****************************************************************************
* name: fmsyntheg_stop
****************************************************************************/
void fmsyntheg_stop(FAR fmsynth_eg_t *eg)
{
eg->state = EGSTATE_RELEASED;
eg->state_counter = 0;
}
/****************************************************************************
* name: fmsyntheg_operate
****************************************************************************/
int fmsyntheg_operate(FAR fmsynth_eg_t *eg)
{
int val;
FAR fmsynth_egparam_t *param = &eg->state_params[eg->state];
val = param->initval;
if (eg->state != EGSTATE_RELEASED)
{
if (eg->state_counter >= eg->state_params[eg->state].period)
{
/* Reset the counter */
eg->state_counter = 0;
/* Search next available state */
do
{
eg->state++;
}
while (eg->state < EGSTATE_RELEASED
&& eg->state_params[eg->state].period == 0);
val = eg->state_params[eg->state].initval;
}
else
{
val = val + param->diff2next * eg->state_counter / param->period;
eg->state_counter++;
}
}
return val;
}

View file

@ -1,548 +0,0 @@
/****************************************************************************
* apps/audioutils/fmsynth/fmsynth_op.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdlib.h>
#include <audioutils/fmsynth_op.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define PHASE_ADJUST(th) \
(((th) < 0 ? (FMSYNTH_PI) - (th) : (th)) % (FMSYNTH_PI * 2))
/****************************************************************************
* Private Data
****************************************************************************/
static const short s_sintbl[] =
{
0xff37, /* Extra data for linear completion */
/* Actual sin table of half PI [256] */
0x0000, 0x00c9, 0x0192, 0x025b,
0x0324, 0x03ed, 0x04b6, 0x057e,
0x0647, 0x0710, 0x07d9, 0x08a1,
0x096a, 0x0a32, 0x0afb, 0x0bc3,
0x0c8b, 0x0d53, 0x0e1b, 0x0ee3,
0x0fab, 0x1072, 0x1139, 0x1200,
0x12c7, 0x138e, 0x1455, 0x151b,
0x15e1, 0x16a7, 0x176d, 0x1833,
0x18f8, 0x19bd, 0x1a82, 0x1b46,
0x1c0b, 0x1ccf, 0x1d93, 0x1e56,
0x1f19, 0x1fdc, 0x209f, 0x2161,
0x2223, 0x22e4, 0x23a6, 0x2467,
0x2527, 0x25e7, 0x26a7, 0x2767,
0x2826, 0x28e5, 0x29a3, 0x2a61,
0x2b1e, 0x2bdb, 0x2c98, 0x2d54,
0x2e10, 0x2ecc, 0x2f86, 0x3041,
0x30fb, 0x31b4, 0x326d, 0x3326,
0x33de, 0x3496, 0x354d, 0x3603,
0x36b9, 0x376f, 0x3824, 0x38d8,
0x398c, 0x3a3f, 0x3af2, 0x3ba4,
0x3c56, 0x3d07, 0x3db7, 0x3e67,
0x3f16, 0x3fc5, 0x4073, 0x4120,
0x41cd, 0x4279, 0x4325, 0x43d0,
0x447a, 0x4523, 0x45cc, 0x4674,
0x471c, 0x47c3, 0x4869, 0x490e,
0x49b3, 0x4a57, 0x4afa, 0x4b9d,
0x4c3f, 0x4ce0, 0x4d80, 0x4e20,
0x4ebf, 0x4f5d, 0x4ffa, 0x5097,
0x5133, 0x51ce, 0x5268, 0x5301,
0x539a, 0x5432, 0x54c9, 0x555f,
0x55f4, 0x5689, 0x571d, 0x57b0,
0x5842, 0x58d3, 0x5963, 0x59f3,
0x5a81, 0x5b0f, 0x5b9c, 0x5c28,
0x5cb3, 0x5d3d, 0x5dc6, 0x5e4f,
0x5ed6, 0x5f5d, 0x5fe2, 0x6067,
0x60eb, 0x616e, 0x61f0, 0x6271,
0x62f1, 0x6370, 0x63ee, 0x646b,
0x64e7, 0x6562, 0x65dd, 0x6656,
0x66ce, 0x6745, 0x67bc, 0x6831,
0x68a5, 0x6919, 0x698b, 0x69fc,
0x6a6c, 0x6adb, 0x6b4a, 0x6bb7,
0x6c23, 0x6c8e, 0x6cf8, 0x6d61,
0x6dc9, 0x6e30, 0x6e95, 0x6efa,
0x6f5e, 0x6fc0, 0x7022, 0x7082,
0x70e1, 0x7140, 0x719d, 0x71f9,
0x7254, 0x72ae, 0x7306, 0x735e,
0x73b5, 0x740a, 0x745e, 0x74b1,
0x7503, 0x7554, 0x75a4, 0x75f3,
0x7640, 0x768d, 0x76d8, 0x7722,
0x776b, 0x77b3, 0x77f9, 0x783f,
0x7883, 0x78c6, 0x7908, 0x7949,
0x7989, 0x79c7, 0x7a04, 0x7a41,
0x7a7c, 0x7ab5, 0x7aee, 0x7b25,
0x7b5c, 0x7b91, 0x7bc4, 0x7bf7,
0x7c29, 0x7c59, 0x7c88, 0x7cb6,
0x7ce2, 0x7d0e, 0x7d38, 0x7d61,
0x7d89, 0x7db0, 0x7dd5, 0x7df9,
0x7e1c, 0x7e3e, 0x7e5e, 0x7e7e,
0x7e9c, 0x7eb9, 0x7ed4, 0x7eef,
0x7f08, 0x7f20, 0x7f37, 0x7f4c,
0x7f61, 0x7f74, 0x7f86, 0x7f96,
0x7fa6, 0x7fb4, 0x7fc1, 0x7fcd,
0x7fd7, 0x7fe0, 0x7fe8, 0x7fef,
0x7ff5, 0x7ff9, 0x7ffc, 0x7ffe,
0x7fff, /* Extra data for linear completion */
};
static int local_fs;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* name: pseudo_sin256
****************************************************************************/
static int pseudo_sin256(int theta)
{
int short_sin;
int rest;
int phase;
int tblidx;
theta = PHASE_ADJUST(theta);
rest = theta & 0x7f;
phase = theta / (FMSYNTH_PI / 2);
tblidx = (theta % (FMSYNTH_PI / 2)) >> 7;
if (phase & 0x01)
{
tblidx = 257 - tblidx;
short_sin = s_sintbl[tblidx];
short_sin = short_sin
+ (((s_sintbl[tblidx - 1] - short_sin) * rest) >> 7);
}
else
{
short_sin = s_sintbl[tblidx + 1];
short_sin = short_sin
+ (((s_sintbl[tblidx + 2] - short_sin) * rest) >> 7);
}
return phase & 0x02 ? -short_sin : short_sin;
}
/****************************************************************************
* name: triangle_wave
****************************************************************************/
static int triangle_wave(int theta)
{
int ret = 0;
int phase;
int offset;
int slope;
theta = PHASE_ADJUST(theta);
phase = theta / (FMSYNTH_PI / 2);
offset = theta % (FMSYNTH_PI / 2);
switch (phase)
{
case 0:
ret = 0;
slope = SHRT_MAX;
break;
case 1:
ret = SHRT_MAX;
slope = -SHRT_MAX;
break;
case 2:
ret = 0;
slope = -SHRT_MAX;
break;
case 3:
ret = -SHRT_MAX;
slope = SHRT_MAX;
break;
default:
ret = 0;
slope = SHRT_MAX;
break;
}
return ret + ((slope * offset) >> 15);
}
/****************************************************************************
* name: sawtooth_wave
****************************************************************************/
static int sawtooth_wave(int theta)
{
theta = PHASE_ADJUST(theta);
return (theta >> 1) - SHRT_MAX;
}
/****************************************************************************
* name: square_wave
****************************************************************************/
static int square_wave(int theta)
{
theta = PHASE_ADJUST(theta);
return theta < FMSYNTH_PI ? SHRT_MAX : -SHRT_MAX;
}
/****************************************************************************
* name: update_parameters
****************************************************************************/
static void update_parameters(FAR fmsynth_op_t *op)
{
if (local_fs != 0)
{
op->delta_phase = 2 * FMSYNTH_PI * op->sound_freq * op->freq_rate
/ (float)local_fs;
}
else
{
op->delta_phase = 0.f;
}
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* name: fmsynthop_set_samplerate
****************************************************************************/
int fmsynthop_set_samplerate(int fs)
{
if (fs < 0)
{
return ERROR;
}
local_fs = fs;
return OK;
}
/****************************************************************************
* name: create_fmsynthop
****************************************************************************/
FAR fmsynth_op_t *create_fmsynthop(FAR fmsynth_op_t *op,
FAR fmsynth_eg_t *eg)
{
if (op)
{
op->eg = eg;
op->own_allocate = 0;
op->wavegen = NULL;
op->cascadeop = NULL;
op->parallelop = NULL;
op->feedback_ref = NULL;
op->feedback_val = 0;
op->feedbackrate = 0;
op->last_sigval = 0;
op->freq_rate = 1.f;
op->sound_freq = 0.f;
op->delta_phase = 0.f;
op->current_phase = 0.f;
}
return op;
}
/****************************************************************************
* name: fmsynthop_create
****************************************************************************/
FAR fmsynth_op_t *fmsynthop_create(void)
{
FAR fmsynth_op_t *ret;
ret = (FAR fmsynth_op_t *)malloc(sizeof(fmsynth_op_t));
if (ret)
{
ret->eg = fmsyntheg_create();
if (!ret->eg)
{
free(ret);
return NULL;
}
create_fmsynthop(ret, ret->eg);
ret->own_allocate = 1;
}
return ret;
}
/****************************************************************************
* name: fmsynthop_delete
****************************************************************************/
void fmsynthop_delete(FAR fmsynth_op_t *op)
{
if (op != NULL && op->own_allocate == 1)
{
if (op->eg)
{
fmsyntheg_delete(op->eg);
}
free(op);
}
}
/****************************************************************************
* name: fmsynthop_select_opfunc
****************************************************************************/
int fmsynthop_select_opfunc(FAR fmsynth_op_t *op, int type)
{
int ret = ERROR;
if (op != NULL)
{
switch (type)
{
case FMSYNTH_OPFUNC_SIN:
op->wavegen = pseudo_sin256;
ret = OK;
break;
case FMSYNTH_OPFUNC_TRIANGLE:
op->wavegen = triangle_wave;
ret = OK;
break;
case FMSYNTH_OPFUNC_SAWTOOTH:
op->wavegen = sawtooth_wave;
ret = OK;
break;
case FMSYNTH_OPFUNC_SQUARE:
op->wavegen = square_wave;
ret = OK;
break;
}
}
return ret;
}
/****************************************************************************
* name: fmsynthop_set_envelope
****************************************************************************/
int fmsynthop_set_envelope(FAR fmsynth_op_t *op,
FAR fmsynth_eglevels_t *levels)
{
if (local_fs >= 0 && op && levels)
{
return fmsyntheg_set_param(op->eg, local_fs, levels);
}
return ERROR;
}
/****************************************************************************
* name: fmsynthop_cascade_subop
****************************************************************************/
int fmsynthop_cascade_subop(FAR fmsynth_op_t *op,
FAR fmsynth_op_t *subop)
{
FAR fmsynth_op_t *tmp;
if (!op || !subop)
{
return ERROR;
}
for (tmp = op; tmp->cascadeop; tmp = tmp->cascadeop);
tmp->cascadeop = subop;
return OK;
}
/****************************************************************************
* name: fmsynthop_parallel_subop
****************************************************************************/
int fmsynthop_parallel_subop(FAR fmsynth_op_t *op,
FAR fmsynth_op_t *subop)
{
FAR fmsynth_op_t *tmp;
if (!op || !subop)
{
return ERROR;
}
for (tmp = op; tmp->parallelop; tmp = tmp->parallelop);
tmp->parallelop = subop;
return OK;
}
/****************************************************************************
* name: fmsynthop_bind_feedback
****************************************************************************/
int fmsynthop_bind_feedback(FAR fmsynth_op_t *op,
FAR fmsynth_op_t *subop, float ratio)
{
if (!op || !subop)
{
return ERROR;
}
op->feedbackrate = (int)((float)FMSYNTH_MAX_EGLEVEL * ratio);
op->feedback_ref = &subop->last_sigval;
return OK;
}
/****************************************************************************
* name: fmsynthop_update_feedback
****************************************************************************/
int fmsynthop_update_feedback(FAR fmsynth_op_t *op)
{
FAR fmsynth_op_t *tmp;
for (tmp = op->cascadeop; tmp != NULL; tmp = tmp->parallelop)
{
fmsynthop_update_feedback(tmp);
}
if (op->feedback_ref)
{
op->feedback_val = *op->feedback_ref * op->feedbackrate
/ FMSYNTH_MAX_EGLEVEL;
}
return OK;
}
/****************************************************************************
* name: fmsynthop_set_soundfreq
****************************************************************************/
void fmsynthop_set_soundfreq(FAR fmsynth_op_t *op, float freq)
{
FAR fmsynth_op_t *tmp;
op->sound_freq = freq;
update_parameters(op);
for (tmp = op->cascadeop; tmp != NULL; tmp = tmp->parallelop)
{
fmsynthop_set_soundfreq(tmp, freq);
}
}
/****************************************************************************
* name: fmsynthop_set_soundfreqrate
****************************************************************************/
void fmsynthop_set_soundfreqrate(FAR fmsynth_op_t *op, float rate)
{
op->freq_rate = rate;
update_parameters(op);
}
/****************************************************************************
* name: fmsynthop_start
****************************************************************************/
void fmsynthop_start(FAR fmsynth_op_t *op)
{
FAR fmsynth_op_t *tmp;
fmsyntheg_start(op->eg);
for (tmp = op->cascadeop; tmp; tmp = tmp->parallelop)
{
fmsynthop_start(tmp);
}
}
/****************************************************************************
* name: fmsynthop_stop
****************************************************************************/
void fmsynthop_stop(FAR fmsynth_op_t *op)
{
FAR fmsynth_op_t *tmp;
fmsyntheg_stop(op->eg);
for (tmp = op->cascadeop; tmp; tmp = tmp->parallelop)
{
fmsynthop_stop(tmp);
}
}
/****************************************************************************
* name: fmsynthop_operate
****************************************************************************/
int fmsynthop_operate(FAR fmsynth_op_t *op, int phase_time)
{
int val;
int val2;
int phase;
FAR fmsynth_op_t *subop;
op->current_phase = phase_time ? op->current_phase + op->delta_phase : 0.f;
val = (int)op->current_phase;
val2 = (val / (2 * FMSYNTH_PI));
phase = (int)val + op->feedback_val;
op->current_phase = op->current_phase - (float)(val2 * (2 * FMSYNTH_PI));
subop = op->cascadeop;
while (subop)
{
phase += fmsynthop_operate(subop, phase_time);
subop = subop->parallelop;
}
op->last_sigval = fmsyntheg_operate(op->eg) * op->wavegen(phase)
/ FMSYNTH_MAX_EGLEVEL;
return op->last_sigval;
}

View file

@ -1,5 +0,0 @@
/fmsynth_alsa
/fmsynth_test
/fmsyntheg_test
/fmsynthop_test
/opfunctest

View file

@ -1,46 +0,0 @@
############################################################################
# apps/audioutils/fmsynth/test/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
SRCS = ../fmsynth_eg.c ../fmsynth_op.c ../fmsynth.c
CFLAGS = -DFAR= -DCODE= -DOK=0 -DERROR=-1 -I .. -I ../../../include -g
TARGETS = opfunctest fmsyntheg_test fmsynthop_test fmsynth_test fmsynth_alsa
all: $(TARGETS)
opfunctest: $(SRCS) opfunc_test.c
gcc $(CFLAGS) -o $@ $^ -lm
fmsyntheg_test: $(SRCS) fmsynth_eg_test.c
gcc $(CFLAGS) -o $@ $^
fmsynthop_test: $(SRCS) fmsynth_op_test.c
gcc $(CFLAGS) -o $@ $^
fmsynth_test: $(SRCS) fmsynth_test.c
gcc $(CFLAGS) -o $@ $^
fmsynth_alsa: $(SRCS) fmsynth_alsa_test.c
gcc $(CFLAGS) -o $@ $^ -lasound
clean:
rm -rf $(TARGETS)

View file

@ -1,326 +0,0 @@
/****************************************************************************
* apps/audioutils/fmsynth/test/fmsynth_alsa_test.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h>
#include <stdint.h>
#include <termios.h>
#include <fcntl.h>
#include <alsa/asoundlib.h>
#include <audioutils/fmsynth_eg.h>
#include <audioutils/fmsynth_op.h>
#include <audioutils/fmsynth.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define FS (48000)
#define CHANNEL_NUM (2)
#define RESAMPLING_ALSA (1)
#define LATENCY_ALSA (10000)
#define SAMPLE_NUM (FS / 20)
#define BUFF_LENGTH (SAMPLE_NUM * CHANNEL_NUM)
#define CODE_C_FREQ (261.625565f)
#define CODE_D_FREQ (293.6647674f)
#define CODE_E_FREQ (329.6275561f)
#define CODE_F_FREQ (349.2282305f)
#define CODE_G_FREQ (391.9954347f)
#define CODE_A_FREQ (440.f)
#define CODE_B_FREQ (493.8833009f)
/****************************************************************************
* Private Data
****************************************************************************/
static int16_t samples[BUFF_LENGTH];
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* name: init_alsa
****************************************************************************/
static snd_pcm_t *init_alsa(int fs)
{
int ret;
snd_pcm_t *hndl = NULL;
ret = snd_pcm_open(&hndl, "default", SND_PCM_STREAM_PLAYBACK, 0);
if (ret < 0)
{
printf("sdn_pcm_open error\n");
return NULL;
}
ret = snd_pcm_set_params(hndl,
SND_PCM_FORMAT_S16,
SND_PCM_ACCESS_RW_INTERLEAVED,
CHANNEL_NUM, fs, RESAMPLING_ALSA, LATENCY_ALSA);
if (ret != 0)
{
printf("sdn_pcm_set_params error\n");
snd_pcm_close(hndl);
return NULL;
}
return hndl;
}
/****************************************************************************
* name: set_nonblocking
****************************************************************************/
static int set_nonblocking(struct termios *saved)
{
struct termios settings;
tcgetattr(0, saved);
settings = *saved;
settings.c_lflag &= ~(ECHO | ICANON);
settings.c_cc[VTIME] = 0;
settings.c_cc[VMIN] = 1;
tcsetattr(0, TCSANOW, &settings);
fcntl(0, F_SETFL, O_NONBLOCK);
return OK;
}
/****************************************************************************
* name: store_setting
****************************************************************************/
static void store_setting(struct termios *saved)
{
tcsetattr(0, TCSANOW, saved);
}
/****************************************************************************
* name: set_levels
****************************************************************************/
static fmsynth_eglevels_t *set_levels(fmsynth_eglevels_t *level,
float atk_lvl, int atk_peri,
float decbrk_lvl, int decbrk_peri,
float dec_lvl, int dec_peri,
float sus_lvl, int sus_peri,
float rel_lvl, int rel_peri)
{
level->attack.level = atk_lvl;
level->attack.period_ms = atk_peri;
level->decaybrk.level = decbrk_lvl;
level->decaybrk.period_ms = decbrk_peri;
level->decay.level = dec_lvl;
level->decay.period_ms = dec_peri;
level->sustain.level = sus_lvl;
level->sustain.period_ms = sus_peri;
level->release.level = rel_lvl;
level->release.period_ms = rel_peri;
return level;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* name: main
****************************************************************************/
int main(void)
{
int running;
int dump_count = 0;
int dump_enable = 0;
fmsynth_eglevels_t levels;
fmsynth_sound_t *snd1;
fmsynth_op_t *envop;
fmsynth_op_t *fbop;
snd_pcm_t *hndl = NULL;
struct termios save_param;
hndl = init_alsa(FS);
if (!hndl)
{
printf("Init alsa error\n");
return -1;
}
/* Initialize FM synthesizer */
fmsynth_initialize(FS);
/* Operator setup */
envop = fmsynthop_create();
fbop = fmsynthop_create();
set_levels(&levels, 0.6f, 100, 0.3f, 300, 0.1f, 500, 0.f, 0, 0.f, 70);
fmsynthop_set_envelope(envop, &levels);
fmsynthop_select_opfunc(envop, FMSYNTH_OPFUNC_SIN);
fmsynthop_set_envelope(fbop, &levels);
fmsynthop_select_opfunc(fbop, FMSYNTH_OPFUNC_SIN);
fmsynthop_bind_feedback(fbop, fbop, 0.6f);
fmsynthop_parallel_subop(envop, fbop);
/* Sound setup */
snd1 = fmsynthsnd_create();
fmsynthsnd_set_operator(snd1, envop);
fmsynthsnd_set_soundfreq(snd1, CODE_C_FREQ);
set_nonblocking(&save_param);
running = 1;
while (running)
{
switch (getchar())
{
case 'c':
fmsynthsnd_set_soundfreq(snd1, CODE_C_FREQ);
if (dump_enable)
{
dump_count = FS;
dump_enable = 0;
printf("DUMP: ");
}
printf("Do\n");
break;
case 'd':
fmsynthsnd_set_soundfreq(snd1, CODE_D_FREQ);
if (dump_enable)
{
dump_count = FS;
dump_enable = 0;
printf("DUMP: ");
}
printf("Le\n");
break;
case 'e':
fmsynthsnd_set_soundfreq(snd1, CODE_E_FREQ);
if (dump_enable)
{
dump_count = FS;
dump_enable = 0;
printf("DUMP: ");
}
printf("Mi\n");
break;
case 'f':
fmsynthsnd_set_soundfreq(snd1, CODE_F_FREQ);
if (dump_enable)
{
dump_count = FS;
dump_enable = 0;
printf("DUMP: ");
}
printf("Fha\n");
break;
case 'g':
fmsynthsnd_set_soundfreq(snd1, CODE_G_FREQ);
if (dump_enable)
{
dump_count = FS;
dump_enable = 0;
printf("DUMP: ");
}
printf("So\n");
break;
case 'a':
fmsynthsnd_set_soundfreq(snd1, CODE_A_FREQ);
if (dump_enable)
{
dump_count = FS;
dump_enable = 0;
printf("DUMP: ");
}
printf("Ra\n");
break;
case 'b':
fmsynthsnd_set_soundfreq(snd1, CODE_B_FREQ);
if (dump_enable)
{
dump_count = FS;
dump_enable = 0;
printf("DUMP: ");
}
printf("Shi\n");
break;
case 'z':
dump_enable = 1;
printf("Dump next code\n");
break;
case 'q':
running = 0;
break;
}
fmsynth_rendering(snd1, samples, BUFF_LENGTH, CHANNEL_NUM, NULL, 0);
if (dump_count)
{
for (int i = 0; i < BUFF_LENGTH; i += 2)
{
printf("%d\n", samples[i]);
}
dump_count -= SAMPLE_NUM;
}
snd_pcm_writei(hndl, samples, SAMPLE_NUM);
}
snd_pcm_drain(hndl);
snd_pcm_close(hndl);
fmsynthop_delete(envop);
fmsynthop_delete(fbop);
fmsynthsnd_delete(snd1);
store_setting(&save_param);
return 0;
}

View file

@ -1,129 +0,0 @@
/****************************************************************************
* apps/audioutils/fmsynth/test/fmsynth_eg_test.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h>
#include <audioutils/fmsynth_eg.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define FS (48000)
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* name: state_name
****************************************************************************/
static const char *state_name(int s)
{
switch (s)
{
case EGSTATE_ATTACK:
return "Attack ";
case EGSTATE_DECAYBREAK:
return "DecayBreak";
case EGSTATE_DECAY:
return "Decay ";
case EGSTATE_SUSTAIN:
return "Sustain ";
case EGSTATE_RELEASE:
return "Release ";
case EGSTATE_RELEASED:
case -1:
return "RELEASED..";
}
return "";
}
/****************************************************************************
* name: dump_eg
****************************************************************************/
static void dump_eg(fmsynth_eg_t *env)
{
int i;
fmsynth_egparam_t *last = &env->state_params[EGSTATE_RELEASED];
printf("===== STATE : %s =======\n", state_name(env->state));
for (i = -1; i < EGSTATE_RELEASED; i++)
{
printf(" [%s] %5d <--------------> [%s] %5d\n",
state_name(i), last->initval,
state_name(i + 1), env->state_params[i + 1].initval);
printf(" per %d\n", env->state_params[i + 1].period);
printf(" dlt %d\n", env->state_params[i + 1].diff2next);
last = &env->state_params[i + 1];
}
printf("\n");
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* name: main
****************************************************************************/
int main(void)
{
fmsynth_eg_t *eg;
fmsynth_eglevels_t levels;
levels.attack.level = 0.6f;
levels.attack.period_ms = 10;
levels.decaybrk.level = 0.3f;
levels.decaybrk.period_ms = 20;
levels.decay.level = 0.5f;
levels.decay.period_ms = 15;
levels.sustain.level = 0.65f;
levels.sustain.period_ms = 5;
levels.release.level = 0.f;
levels.release.period_ms = 70;
eg = fmsyntheg_create();
fmsyntheg_set_param(eg, FS, &levels);
dump_eg(eg);
fmsyntheg_start(eg);
dump_eg(eg);
while (eg->state != EGSTATE_RELEASED)
{
printf("%d\n", fmsyntheg_operate(eg));
}
fmsyntheg_delete(eg);
return 0;
}

View file

@ -1,145 +0,0 @@
/****************************************************************************
* apps/audioutils/fmsynth/test/fmsynth_op_test.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h>
#include <audioutils/fmsynth_op.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define FS (48000)
#define SOUNDFREQ (261.f)
#define TEST_LOOP (FS * (30 + 10 + 100 + 30 + 1) / 1000)
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* name: set_levels
****************************************************************************/
static fmsynth_eglevels_t *set_levels(fmsynth_eglevels_t *level,
float atk_lvl, int atk_peri,
float decbrk_lvl, int decbrk_peri,
float dec_lvl, int dec_peri,
float sus_lvl, int sus_peri,
float rel_lvl, int rel_peri)
{
level->attack.level = atk_lvl;
level->attack.period_ms = atk_peri;
level->decaybrk.level = decbrk_lvl;
level->decaybrk.period_ms = decbrk_peri;
level->decay.level = dec_lvl;
level->decay.period_ms = dec_peri;
level->sustain.level = sus_lvl;
level->sustain.period_ms = sus_peri;
level->release.level = rel_lvl;
level->release.period_ms = rel_peri;
return level;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* name: main
****************************************************************************/
int main(void)
{
int phase_time;
fmsynth_eglevels_t levels;
fmsynth_op_t *envop;
fmsynth_op_t *fbop;
fmsynth_op_t *triop;
fmsynth_op_t *mainop;
fmsynth_op_t *subop;
fmsynth_op_t *conv1;
fmsynth_op_t *conv2;
phase_time = 0;
fmsynthop_set_samplerate(FS);
set_levels(&levels, 0.12f, 10, 0.06f, 20, 0.1f, 16, 0.1f, 5, 0.f, 70);
envop = fmsynthop_create();
fmsynthop_set_envelope(envop, &levels);
fmsynthop_select_opfunc(envop, FMSYNTH_OPFUNC_SIN);
fmsynthop_set_soundfreq(envop, SOUNDFREQ);
fmsynthop_start(envop);
triop = fmsynthop_create();
fmsynthop_select_opfunc(triop, FMSYNTH_OPFUNC_TRIANGLE);
fmsynthop_set_soundfreq(triop, SOUNDFREQ);
fmsynthop_start(triop);
fbop = fmsynthop_create();
fmsynthop_select_opfunc(fbop, FMSYNTH_OPFUNC_SIN);
fmsynthop_set_soundfreq(fbop, SOUNDFREQ);
fmsynthop_bind_feedback(fbop, fbop, 0.6f);
fmsynthop_start(fbop);
mainop = fmsynthop_create();
subop = fmsynthop_create();
fmsynthop_select_opfunc(mainop, FMSYNTH_OPFUNC_SIN);
fmsynthop_select_opfunc(subop, FMSYNTH_OPFUNC_SIN);
fmsynthop_cascade_subop(mainop, subop);
fmsynthop_set_soundfreq(mainop, SOUNDFREQ);
fmsynthop_set_soundfreqrate(subop, 2.f);
fmsynthop_start(mainop);
printf("idx,EnvTest,FeedbackTest,CascadeTest,Triangle\n");
while (phase_time < TEST_LOOP)
{
fmsynthop_update_feedback(envop);
fmsynthop_update_feedback(fbop);
fmsynthop_update_feedback(mainop);
fmsynthop_update_feedback(triop);
printf("%d,%d,%d,%d,%d\n",
phase_time,
fmsynthop_operate(envop, phase_time),
fmsynthop_operate(fbop, phase_time),
fmsynthop_operate(mainop, phase_time),
fmsynthop_operate(triop, phase_time));
phase_time++;
}
fmsynthop_delete(envop);
fmsynthop_delete(fbop);
fmsynthop_delete(mainop);
fmsynthop_delete(subop);
return 0;
}

View file

@ -1,132 +0,0 @@
/****************************************************************************
* apps/audioutils/fmsynth/test/fmsynth_test.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h>
#include <stdint.h>
#include <audioutils/fmsynth_eg.h>
#include <audioutils/fmsynth_op.h>
#include <audioutils/fmsynth.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define FS (48000)
#define SOUNDFREQ (3000.f)
#define TEST_LENGTH ((FS / 1000) * (10 + 20 + 16 + 5 + 30))
/****************************************************************************
* Private Data
****************************************************************************/
static int16_t my_sample[TEST_LENGTH];
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* name: set_levels
****************************************************************************/
static fmsynth_eglevels_t *set_levels(fmsynth_eglevels_t *level,
int atk_lvl, int atk_peri,
int decbrk_lvl, int decbrk_peri,
int dec_lvl, int dec_peri,
int sus_lvl, int sus_peri,
int rel_lvl, int rel_peri)
{
level->attack.level = atk_lvl;
level->attack.period_ms = atk_peri;
level->decaybrk.level = decbrk_lvl;
level->decaybrk.period_ms = decbrk_peri;
level->decay.level = dec_lvl;
level->decay.period_ms = dec_peri;
level->sustain.level = sus_lvl;
level->sustain.period_ms = sus_peri;
level->release.level = rel_lvl;
level->release.period_ms = rel_peri;
return level;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* name: main
****************************************************************************/
int main(void)
{
int phase_time;
fmsynth_eglevels_t levels;
fmsynth_sound_t *snd1;
fmsynth_op_t *envop;
fmsynth_op_t *fbop;
/* Initialize FM synthesizer */
fmsynth_initialize(FS);
/* Operator setup */
envop = fmsynthop_create();
fbop = fmsynthop_create();
set_levels(&levels, 0.12f, 10, 0.06f, 20, 0.1f, 16, 0.1f, 5, 0.f, 70);
fmsynthop_set_envelope(envop, &levels);
fmsynthop_select_opfunc(envop, FMSYNTH_OPFUNC_SIN);
fmsynthop_select_opfunc(fbop, FMSYNTH_OPFUNC_SIN);
fmsynthop_bind_feedback(fbop, fbop, 0.6f);
fmsynthop_parallel_subop(envop, fbop);
/* Sound setup */
snd1 = fmsynthsnd_create();
fmsynthsnd_set_operator(snd1, envop);
fmsynthsnd_set_soundfreq(snd1, SOUNDFREQ);
fmsynth_rendering(snd1, my_sample, TEST_LENGTH, 1, NULL, 0);
for (int i = 0; i < TEST_LENGTH; i++)
{
printf("%d\n", my_sample[i]);
}
fmsynthop_delete(envop);
fmsynthop_delete(fbop);
fmsynthsnd_delete(snd1);
return 0;
}

View file

@ -1,167 +0,0 @@
/****************************************************************************
* apps/audioutils/fmsynth/test/opfunc_test.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <audioutils/fmsynth_op.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define FS (48000)
#define DUMP_PERIOD (FS * 3 / 2000)
#define ACCURACY_TEST_PERIOD (FS * 3)
#define HZ (4186)
/****************************************************************************
* Private Data
****************************************************************************/
static opfunc_t func_sin;
static opfunc_t func_tri;
static opfunc_t func_saw;
static opfunc_t func_sqa;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* name: prepare_opfuncs
****************************************************************************/
static void prepare_opfuncs(void)
{
fmsynth_op_t *op;
op = fmsynthop_create();
fmsynthop_select_opfunc(op, FMSYNTH_OPFUNC_SIN);
func_sin = op->wavegen;
fmsynthop_select_opfunc(op, FMSYNTH_OPFUNC_TRIANGLE);
func_tri = op->wavegen;
fmsynthop_select_opfunc(op, FMSYNTH_OPFUNC_SAWTOOTH);
func_saw = op->wavegen;
fmsynthop_select_opfunc(op, FMSYNTH_OPFUNC_SQUARE);
func_sqa = op->wavegen;
fmsynthop_delete(op);
}
/****************************************************************************
* name: wavegen_dump
****************************************************************************/
static void wavegen_dump(void)
{
int t;
float deltaact;
deltaact = (float)FMSYNTH_PI * 2. * (float)HZ / (float)FS;
printf("===== Wave generator Dump ====\n");
printf("SIN, TRIANGLE, SAWTOOTH, SQUARE\n");
for (t = 0; t < DUMP_PERIOD; t++)
{
printf("%d, %d, %d, %d\n",
func_sin((int)(deltaact * t)),
func_tri((int)(deltaact * t)),
func_saw((int)(deltaact * t)),
func_sqa((int)(deltaact * t))
);
}
printf("\n");
}
/****************************************************************************
* name: sin_accuracy_test
****************************************************************************/
static void sin_accuracy_test(void)
{
int t;
float delta;
float deltaact;
float max_diff = 0.f;
float ref_sin;
int sin_val;
float norm_sin;
float diff;
delta = M_PI * 2. * (float)HZ / (float)FS;
deltaact = (float)FMSYNTH_PI * 2. * (float)HZ / (float)FS;
printf("===== Local SIN function ACCURACY TEST ====\n");
for (t = 0; t < ACCURACY_TEST_PERIOD; t++)
{
sin_val = func_sin((int)(deltaact * t));
ref_sin = sinf(delta * t);
norm_sin = (float)sin_val / (float)SHRT_MAX;
printf("t=%d, operator-sin(%d)=%d, norm_sin=%f, sinf(%f)=%f ",
t, (int)(deltaact * t), sin_val, norm_sin, delta * t, ref_sin);
diff = fabsf(norm_sin - ref_sin);
max_diff = max_diff < diff ? diff : max_diff;
if (diff >= 0.005)
{
printf(" BIG-DIFF : %f\n", diff);
}
else
{
printf("\n");
}
}
printf("\n\nMAX DIFF = %f\n\n", max_diff);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* name: main
****************************************************************************/
int main(void)
{
prepare_opfuncs();
sin_accuracy_test();
wavegen_dump();
return 0;
}

View file

@ -1 +0,0 @@
lame

View file

@ -1,139 +0,0 @@
# ##############################################################################
# apps/audioutils/lame/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
if(CONFIG_AUDIOUTILS_LAME)
# Determine destination path
if(NOT DEFINED DST_PATH)
set(DST_PATH ${CMAKE_CURRENT_BINARY_DIR}/lame)
else()
set(DST_PATH ${DST_PATH})
endif()
# Set configuration commands
set(CFG_CMDS "")
if(NOT "${CONFIG_ARCH}" STREQUAL "sim")
list(APPEND CFG_CMDS "--host=${CONFIG_ARCH}")
list(APPEND CFG_CMDS "--cross-prefix=${CROSSDEV}")
endif()
# The revision to check out. See the comment in Makefile: an unpinned
# checkout stops linking on the day lame's trunk grows its next vector tier.
# Raise this deliberately, together with the vector source list below.
if(NOT DEFINED LAME_VERSION)
set(LAME_VERSION 6720)
endif()
# # Download lame if no lame/configure found
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lame/configure")
execute_process(
COMMAND "svn" "checkout" "-r" "${LAME_VERSION}"
"https://svn.code.sf.net/p/lame/svn/trunk/lame" "lame"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
# Set source path
set(SRC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lame")
# Add compiler flags
set(CFLAGS -DHAVE_CONFIG_H -Dfast_log2=lame_fast_log2)
set(CFLAGS
${CFLAGS}
-Wno-address
-Wno-array-parameter
-Wno-builtin-declaration-mismatch
-Wno-incompatible-pointer-types
-Wno-implicit-function-declaration
-Wno-shadow
-Wno-stringop-overflow
-Wno-unused-variable
-Wno-unused-but-set-variable
-msse)
set(INCDIR ${INCDIR_PREFIX}${DST_PATH} ${INCDIR_PREFIX}${SRC_PATH}/include
${INCDIR_PREFIX}${SRC_PATH}/libmp3lame)
# Set source files
set(CSRCS
"${SRC_PATH}/libmp3lame/bitstream.c"
"${SRC_PATH}/libmp3lame/encoder.c"
"${SRC_PATH}/libmp3lame/fft.c"
"${SRC_PATH}/libmp3lame/gain_analysis.c"
"${SRC_PATH}/libmp3lame/id3tag.c"
"${SRC_PATH}/libmp3lame/lame.c"
"${SRC_PATH}/libmp3lame/newmdct.c"
"${SRC_PATH}/libmp3lame/psymodel.c"
"${SRC_PATH}/libmp3lame/quantize.c"
"${SRC_PATH}/libmp3lame/quantize_pvt.c"
"${SRC_PATH}/libmp3lame/set_get.c"
"${SRC_PATH}/libmp3lame/vbrquantize.c"
"${SRC_PATH}/libmp3lame/reservoir.c"
"${SRC_PATH}/libmp3lame/tables.c"
"${SRC_PATH}/libmp3lame/takehiro.c"
"${SRC_PATH}/libmp3lame/util.c"
"${SRC_PATH}/libmp3lame/VbrTag.c"
"${SRC_PATH}/libmp3lame/version.c"
"${SRC_PATH}/libmp3lame/presets.c")
if(CONFIG_HOST_X86 OR CONFIG_HOST_X86_64)
list(
APPEND
CSRCS
"${SRC_PATH}/libmp3lame/vector/xmm_quantize_sub.c"
"${SRC_PATH}/libmp3lame/vector/xmm_choose_table.c"
"${SRC_PATH}/libmp3lame/vector/xmm_quantize_lines.c"
"${SRC_PATH}/libmp3lame/vector/xmm_calc_sfb_noise.c"
"${SRC_PATH}/libmp3lame/vector/avx2_choose_table.c"
"${SRC_PATH}/libmp3lame/vector/avx2_quantize_lines.c"
"${SRC_PATH}/libmp3lame/vector/avx512_choose_table.c"
"${SRC_PATH}/libmp3lame/vector/avx512_quantize_lines.c"
"${SRC_PATH}/libmp3lame/vector/avx512_calc_sfb_noise.c")
endif()
# Add custom target to generate config_h
set(CONFIG_H_FILE "${CMAKE_CURRENT_SOURCE_DIR}/lame/configure")
set(CONFIG_OPTIONS
--disable-cpml
--disable-decoder
--disable-efence
--disable-frontend
--disable-mp3x
--disable-gtktest
--disable-ipv6
--disable-rpath
--enable-static
${CFG_CMDS})
add_custom_command(
OUTPUT "${DST_PATH}/config.h"
COMMAND ${CONFIG_H_FILE} ${CONFIG_OPTIONS}
WORKING_DIRECTORY "${DST_PATH}"
COMMENT "Generating config.h file")
add_custom_target(generate_config_h DEPENDS "${DST_PATH}/config.h")
nuttx_add_library(libmp3lame STATIC)
add_dependencies(libmp3lame generate_config_h)
target_sources(libmp3lame PRIVATE ${CSRCS})
target_include_directories(libmp3lame PRIVATE ${INCDIR})
target_compile_options(libmp3lame PRIVATE ${CFLAGS})
endif()

View file

@ -1,8 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config AUDIOUTILS_LAME
bool "Enable LAME MP3 Encoder"
default n

View file

@ -1,25 +0,0 @@
############################################################################
# apps/audioutils/lame/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
ifneq ($(CONFIG_AUDIOUTILS_LAME),)
CONFIGURED_APPS += $(APPDIR)/audioutils/lame
endif

View file

@ -1,132 +0,0 @@
############################################################################
# apps/audioutils/lame/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
# The revision to check out. lame's trunk grows vector tiers over time --
# SSE2, then AVX2, then AVX-512 -- and each one adds sources that this file
# and CMakeLists.txt have to name, so an unpinned checkout stops linking on
# the day upstream adds the next one. Raise this deliberately, together with
# the vector source list below.
LAME_VERSION ?= 6720
# Download lame if no lame/configure found
lame-svn:
$(Q) echo "svn checkout lame ..."
$(Q) svn checkout -r $(LAME_VERSION) \
https://svn.code.sf.net/p/lame/svn/trunk/lame lame
ifeq ($(wildcard lame/configure),)
context:: lame-svn
distclean::
$(call DELDIR, lame)
endif
ifeq ($(DST_PATH),)
include $(APPDIR)/Make.defs
# configure in place
DST_PATH := lame
else
# configure out of tree
DST_PATH := $(realpath $(DST_PATH))
include $(DST_PATH)/Make.defs
BIN := $(DST_PATH)/libmp3lame.a
# enable Application.mk PREFIX
PREFIX := $(DST_PATH)$(DELIM)
endif
ifneq ($(CONFIG_ARCH),sim)
CFG_CMDS += --host=$(CONFIG_ARCH)
CFG_CMDS += --cross-prefix=$(CROSSDEV)
endif
SRC_PATH := lame
CFLAGS += -DHAVE_CONFIG_H -D'fast_log2=lame_fast_log2'
CFLAGS += $(INCDIR_PREFIX)$(DST_PATH) \
$(INCDIR_PREFIX)$(SRC_PATH)/include \
$(INCDIR_PREFIX)$(SRC_PATH)/libmp3lame
CFLAGS += -Wno-address -Wno-array-parameter \
-Wno-builtin-declaration-mismatch \
-Wno-incompatible-pointer-types \
-Wno-implicit-function-declaration -Wno-shadow \
-Wno-stringop-overflow -Wno-unused-variable \
-Wno-unused-but-set-variable \
-msse
CSRCS += $(SRC_PATH)/libmp3lame/bitstream.c \
$(SRC_PATH)/libmp3lame/encoder.c \
$(SRC_PATH)/libmp3lame/fft.c \
$(SRC_PATH)/libmp3lame/gain_analysis.c \
$(SRC_PATH)/libmp3lame/id3tag.c \
$(SRC_PATH)/libmp3lame/lame.c \
$(SRC_PATH)/libmp3lame/newmdct.c \
$(SRC_PATH)/libmp3lame/psymodel.c \
$(SRC_PATH)/libmp3lame/quantize.c \
$(SRC_PATH)/libmp3lame/quantize_pvt.c \
$(SRC_PATH)/libmp3lame/set_get.c \
$(SRC_PATH)/libmp3lame/vbrquantize.c \
$(SRC_PATH)/libmp3lame/reservoir.c \
$(SRC_PATH)/libmp3lame/tables.c \
$(SRC_PATH)/libmp3lame/takehiro.c \
$(SRC_PATH)/libmp3lame/util.c \
$(SRC_PATH)/libmp3lame/VbrTag.c \
$(SRC_PATH)/libmp3lame/version.c \
$(SRC_PATH)/libmp3lame/presets.c
# lame's configure enables the SSE2, AVX2 and AVX-512 dispatch paths whenever
# the host compiler accepts their per-function target attributes, and the
# scalar code then calls into them, so the whole group has to be built on an
# x86 host. Other hosts keep lame's scalar implementation.
ifneq ($(CONFIG_HOST_X86)$(CONFIG_HOST_X86_64),)
CSRCS += $(SRC_PATH)/libmp3lame/vector/xmm_quantize_sub.c \
$(SRC_PATH)/libmp3lame/vector/xmm_choose_table.c \
$(SRC_PATH)/libmp3lame/vector/xmm_quantize_lines.c \
$(SRC_PATH)/libmp3lame/vector/xmm_calc_sfb_noise.c \
$(SRC_PATH)/libmp3lame/vector/avx2_choose_table.c \
$(SRC_PATH)/libmp3lame/vector/avx2_quantize_lines.c \
$(SRC_PATH)/libmp3lame/vector/avx512_choose_table.c \
$(SRC_PATH)/libmp3lame/vector/avx512_quantize_lines.c \
$(SRC_PATH)/libmp3lame/vector/avx512_calc_sfb_noise.c
endif
LAME_CONFIG_SCRIPT := $(CURDIR)$(DELIM)lame$(DELIM)configure
$(DST_PATH)/config.h:
$(Q)echo "lame configure... $(CONFIG_ARCH)"
$(Q)cd $(DST_PATH) && $(LAME_CONFIG_SCRIPT) \
--disable-cpml --disable-decoder --disable-efence \
--disable-frontend --disable-mp3x --disable-gtktest \
--disable-ipv6 --disable-rpath --enable-static \
$(CFG_CMDS)
context:: $(DST_PATH)/config.h
ifneq ($(PREFIX),)
@$(eval ALL_SRCS = $(CSRCS))
@$(foreach src,$(ALL_SRCS),$(shell mkdir -p $(PREFIX)$(dir $(src))))
endif
distclean::
$(Q)if [ -d $(DST_PATH) ]; then cd $(DST_PATH) && $(MAKE) distclean; fi
include $(APPDIR)/Application.mk

View file

@ -1,2 +0,0 @@
/libmad
/*.zip

View file

@ -1,60 +0,0 @@
# ##############################################################################
# apps/audioutils/libmad/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
if(CONFIG_AUDIOUTILS_LIBMAD)
# Download and unpack libmad if no libmad found
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libmad/configure)
set(VERSION "master")
set(LIBMAD_URL
"https://github.com/markjeee/libmad/archive/refs/heads/master.zip")
file(DOWNLOAD ${LIBMAD_URL} ${CMAKE_CURRENT_SOURCE_DIR}/libmad.zip)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar -xf ${CMAKE_CURRENT_SOURCE_DIR}/libmad.zip
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
execute_process(
COMMAND
${CMAKE_COMMAND} -E rename
${CMAKE_CURRENT_SOURCE_DIR}/libmad-${VERSION}
${CMAKE_CURRENT_SOURCE_DIR}/libmad)
add_custom_target(
distclean
COMMAND ${CMAKE_COMMAND} -E remove_directory
${CMAKE_CURRENT_SOURCE_DIR}/libmad
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/libmad.zip)
endif()
nuttx_add_library(libmad STATIC)
file(GLOB LIBMAD_SRCS libmad/*.c)
set(CSRCS ${LIBMAD_SRCS})
set(CFLAGS -Wno-shadow -Wno-stringop-overflow -DFPM_DEFAULT -DSIZEOF_INT=4)
set(INCDIR ${CMAKE_CURRENT_LIST_DIR}/libmad
${CMAKE_CURRENT_LIST_DIR}/libmad/msvc++)
target_sources(libmad PRIVATE ${CSRCS})
target_include_directories(libmad PRIVATE ${INCDIR})
target_compile_options(libmad PRIVATE ${CFLAGS})
endif()

View file

@ -1,8 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config AUDIOUTILS_LIBMAD
bool "Enable libmad"
default n

View file

@ -1,25 +0,0 @@
############################################################################
# apps/audioutils/libmad/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
ifneq ($(CONFIG_AUDIOUTILS_LIBMAD),)
CONFIGURED_APPS += $(APPDIR)/audioutils/libmad
endif

View file

@ -1,45 +0,0 @@
############################################################################
# apps/audioutils/libmad/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
include $(APPDIR)/Make.defs
CSRCS += $(wildcard libmad/*.c)
CFLAGS += -DFPM_DEFAULT -DSIZEOF_INT=4
CFLAGS += -Wno-shadow -Wno-stringop-overflow
# Download and unpack libmad if no git repo found
ifeq ($(wildcard libmad/.git),)
VERSION ?= master
libmad.zip:
$(Q) curl -L https://github.com/markjeee/libmad/archive/refs/heads/master.zip -o libmad.zip
$(Q) unzip -o libmad.zip
$(Q) mv libmad-$(VERSION) libmad
context:: libmad.zip
distclean::
$(call DELDIR, libmad)
$(call DELFILE, libmad.zip)
endif
include $(APPDIR)/Application.mk

View file

@ -1,24 +0,0 @@
# ##############################################################################
# apps/audioutils/mml_parser/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
if(CONFIG_AUDIOUTILS_MMLPARSER_LIB)
target_sources(apps PRIVATE mml_parser.c)
endif()

View file

@ -1,10 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config AUDIOUTILS_MMLPARSER_LIB
bool "Music Macro Language(MML) Library"
default n
---help---
Enable support for the Music Macro Language library.

View file

@ -1,25 +0,0 @@
############################################################################
# apps/audioutils/mml_parser/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
ifneq ($(CONFIG_AUDIOUTILS_MMLPARSER_LIB),)
CONFIGURED_APPS += $(APPDIR)/audioutils/mml_parser
endif

View file

@ -1,870 +0,0 @@
/****************************************************************************
* apps/audioutils/mml_parser/mml_parser.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <errno.h>
#include <audioutils/mml_parser.h>
#ifdef DEBUG_ON
#include <stdio.h>
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define LENGTH_STATE_IDLE (0)
#define LENGTH_STATE_NUMBERD (1)
#define LENGTH_STATE_PLUS (2)
#define CHORD_START '['
#define CHORD_END ']'
#define TUPLET_START '{'
#define TUPLET_END '}'
#ifdef DEBUG_ON
#define DEBUG printf
#else
#define DEBUG(...)
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* name: skip_space
****************************************************************************/
static char *skip_space(char *str)
{
while (isspace(*str))
{
str++;
}
return str;
}
/****************************************************************************
* name: next_code
****************************************************************************/
static char next_code(char **score)
{
char ret;
*score = skip_space(*score);
ret = **score;
*score += 1;
return ret;
}
/****************************************************************************
* name: note_index
****************************************************************************/
static int note_index(char code)
{
int i;
const char *code_types = "C+D+EF+G+A+B";
for (i = 0; i < 12; i++)
{
if (code_types[i] == code)
{
return i;
}
}
return -1;
}
/****************************************************************************
* name: halfscale
****************************************************************************/
static int halfscale(char **score)
{
int ret = 0;
while (1)
{
switch (**score)
{
case '+':
case '#':
ret++;
break;
case '-':
ret--;
break;
default:
return ret;
}
*score += 1;
}
return ret;
}
/****************************************************************************
* name: strlendigits
****************************************************************************/
static int strlendigits(FAR const char *str)
{
int ret = 0;
while (isdigit(*str))
{
str++;
ret++;
}
return ret;
}
/****************************************************************************
* name: calc_samples
****************************************************************************/
static int calc_samples(int fs, int tempo, int num, int dots)
{
int div = 0;
int n = 0;
int mul = 16;
DEBUG("fs=%d, tempo=%d, num=%d, dots=%d\n", fs, tempo, num, dots);
switch (num)
{
case 0:
n = 3;
break;
case 1:
n = 2;
break;
case 2:
n = 1;
break;
case 4:
n = 0;
break;
case 8:
div = 1;
break;
case 16:
div = 2;
break;
case 32:
div = 3;
break;
case 64:
div = 4;
break;
default:
div = -1;
break;
}
if (dots <= 4)
{
while (dots)
{
mul += (1 << (4 - dots));
dots--;
}
}
else
{
dots = -1;
}
if (div < 0 || dots < 0)
{
return -EINVAL;
}
return (((15 * fs * mul) << n) >> (2 + div)) / tempo;
}
/****************************************************************************
* name: get_samples
****************************************************************************/
static int get_samples(FAR struct music_macro_lang_s *mml,
int samples, int num, int dots, bool plus_mode)
{
int len;
num = num < 0 ? mml->def_length : num;
len = calc_samples(mml->fs, mml->cur_tempo, num, dots);
if (len > 0)
{
return plus_mode ? samples + len : len;
}
return len;
}
/****************************************************************************
* name: is_qualifire
****************************************************************************/
static bool is_qualifire(char c)
{
if (isdigit(c) || c == '.')
{
return true;
}
return false;
}
/****************************************************************************
* name: sample_length
****************************************************************************/
static int sample_length(FAR struct music_macro_lang_s *mml,
FAR char **score)
{
int dots = 0;
int samples = 0;
int state = LENGTH_STATE_IDLE;
bool plus_mode = false;
bool parsing = true;
int num = -1;
samples = get_samples(mml, samples, num, dots, plus_mode);
if (!is_qualifire(**score))
{
return samples;
}
while (parsing)
{
DEBUG("In Length parser\n");
switch (state)
{
case LENGTH_STATE_IDLE:
if (isdigit(**score))
{
DEBUG("state[IDLE]: Digits\n");
num = atoi(*score);
*score += strlendigits(*score);
state = LENGTH_STATE_NUMBERD;
}
else if (**score == '.')
{
DEBUG("state[IDLE]: Dot\n");
state = LENGTH_STATE_NUMBERD;
dots++;
*score += 1;
}
else
{
DEBUG("state[IDLE]: Other\n");
samples = get_samples(mml, samples, num, dots, plus_mode);
parsing = false;
}
case LENGTH_STATE_NUMBERD:
if (**score == '.')
{
DEBUG("state[NUM]: Dot\n");
dots++;
*score += 1;
}
else if (**score == '+')
{
DEBUG("state[NUM]: PLUS\n");
samples = get_samples(mml, samples, num, dots, plus_mode);
if (samples < 0)
{
parsing = false;
}
plus_mode = true;
num = -1;
*score += 1;
state = LENGTH_STATE_PLUS;
}
else
{
DEBUG("state[NUM]: Other\n");
samples = get_samples(mml, samples, num, dots, plus_mode);
parsing = false;
}
break;
case LENGTH_STATE_PLUS:
if (isdigit(**score))
{
num = atoi(*score);
*score += strlendigits(*score);
DEBUG("state[PLUS]: Digits num=%d, restscore=%s,"
" parsing=%s\n",
num, *score, parsing ? "True" : "False");
state = LENGTH_STATE_NUMBERD;
}
else
{
DEBUG("state[PLUS]: Other\n");
samples = -EINVAL;
parsing = false;
}
break;
default:
parsing = false;
samples = -EPROTO;
break;
}
DEBUG("Out switch : state[%s]: Digits num=%d, restscore=%s,"
" parse=%s\n",
state == LENGTH_STATE_IDLE ? "IDLE" :
state == LENGTH_STATE_NUMBERD ? "NUM" :
state == LENGTH_STATE_PLUS ? "PLUS" : "Unknown",
num, *score, parsing ? "True" : "False");
}
DEBUG("Out while\n");
return samples;
}
/****************************************************************************
* name: tuple_length
****************************************************************************/
static int tuplet_length(FAR struct music_macro_lang_s *mml)
{
int ret;
ret = mml->tuplet_length / mml->tuplet_notes;
mml->cur_tuplet++;
if (mml->cur_tuplet == mml->tuplet_notes)
{
/* Adjust surplus */
ret = mml->tuplet_length - (ret * (mml->tuplet_notes - 1));
}
return ret;
}
/****************************************************************************
* name: handle_note
****************************************************************************/
static int handle_note(FAR struct music_macro_lang_s *mml, char code,
FAR char **score, FAR struct mml_result_s *result)
{
result->note_idx[0] = note_index(code) + halfscale(score)
+ mml->cur_octave * 12;
result->length = sample_length(mml, score);
return result->length < 0 ? MML_TYPE_NOTE_ERROR : MML_TYPE_NOTE;
}
/****************************************************************************
* name: handle_rest
****************************************************************************/
static int handle_rest(FAR struct music_macro_lang_s *mml,
FAR char **score, FAR struct mml_result_s *result)
{
if (mml->state == MML_STATE_TUPLET)
{
DEBUG("Tuplet : TTL %d, CUR %d\n", mml->tuplet_notes, mml->cur_tuplet);
result->length = tuplet_length(mml);
return MML_TYPE_REST;
}
else
{
result->length = sample_length(mml, score);
return result->length < 0 ? MML_TYPE_REST_ERROR : MML_TYPE_REST;
}
}
/****************************************************************************
* name: handle_tempo
****************************************************************************/
static int handle_tempo(FAR struct music_macro_lang_s *mml,
FAR char **score, FAR struct mml_result_s *result)
{
int ret = MML_TYPE_TEMPO;
if (isdigit(**score))
{
mml->cur_tempo = result->length = atoi(*score);
*score += strlendigits(*score);
}
else
{
ret = MML_TYPE_TEMPO_ERROR;
}
return ret;
}
/****************************************************************************
* name: handle_length
****************************************************************************/
static int handle_length(FAR struct music_macro_lang_s *mml,
FAR char **score, FAR struct mml_result_s *result)
{
int ret = MML_TYPE_LENGTH_ERROR;
DEBUG("length str : %c\n", **score);
if (isdigit(**score))
{
mml->def_length = result->length = atoi(*score);
*score += strlendigits(*score);
ret = MML_TYPE_LENGTH;
}
return ret;
}
/****************************************************************************
* name: handle_octave
****************************************************************************/
static int handle_octave(FAR struct music_macro_lang_s *mml, char code,
FAR char **score, FAR struct mml_result_s *result)
{
int ret = MML_TYPE_OCTAVE;
switch (code)
{
case '>':
mml->cur_octave++;
result->length = mml->cur_octave;
break;
case '<':
mml->cur_octave--;
result->length = mml->cur_octave;
break;
default:
if (isdigit(**score))
{
mml->cur_octave = result->length = atoi(*score);
*score += strlendigits(*score);
}
else
{
ret = MML_TYPE_OCTAVE_ERROR;
}
break;
}
return ret;
}
/****************************************************************************
* name: handle_volume
****************************************************************************/
static int handle_volume(FAR struct music_macro_lang_s *mml,
FAR char **score, FAR struct mml_result_s *result)
{
int ret = MML_TYPE_VOLUME;
result->length = atoi(*score);
*score += strlendigits(*score);
if (result->length < 0 || result->length > 100)
{
ret = MML_TYPE_VOLUME_ERROR;
}
return ret;
}
/****************************************************************************
* name: skip_until
****************************************************************************/
static char *skip_until(FAR char *score, char until)
{
while (*score != until && *score != '\0')
{
score++;
}
return score;
}
/****************************************************************************
* name: count_tupletnotes
****************************************************************************/
static int count_tupletnotes(FAR struct music_macro_lang_s *mml,
FAR char *score)
{
const char *notes = "CDEFGABR";
score = skip_space(score);
while (*score != TUPLET_END)
{
if (strchr(notes, *score))
{
mml->tuplet_notes++;
}
else if (*score == CHORD_START)
{
score = skip_until(score, CHORD_END);
mml->tuplet_notes++;
}
if (*score == '\0')
{
return -EINVAL;
}
score++;
score = skip_space(score);
}
score++; /* Skip TUPLET_END */
mml->tuplet_length = sample_length(mml, &score);
return mml->tuplet_notes != 0 ? OK : -EINVAL;
}
/****************************************************************************
* name: handle_starttuplet
****************************************************************************/
static int handle_starttuplet(FAR struct music_macro_lang_s *mml,
FAR char **score,
FAR struct mml_result_s *result)
{
int ret;
if (mml->state != MML_STATE_NORMAL)
{
return MML_TYPE_ILLIGAL_DOUBLE_TUPLET;
}
mml->tuplet_notes = 0;
ret = count_tupletnotes(mml, *score);
if (ret < 0 || mml->tuplet_notes == 0)
{
return MML_TYPE_TUPLET_ERROR;
}
mml->state = MML_STATE_TUPLET;
mml->cur_tuplet = 0;
result->length = mml->tuplet_length;
return MML_TYPE_TUPLETSTART;
}
/****************************************************************************
* name: handle_stoptuplet
****************************************************************************/
static int handle_stoptuplet(FAR struct music_macro_lang_s *mml,
FAR char **score,
FAR struct mml_result_s *result)
{
int ret = MML_TYPE_TUPLETDONE;
mml->state = MML_STATE_NORMAL;
/* Just for skip of length block */
sample_length(mml, score);
if (mml->cur_tuplet != mml->tuplet_notes)
{
ret = MML_TYPE_ILLIGAL_TOOFEW_NOTES;
}
return ret;
}
/****************************************************************************
* name: handle_tupletnote
****************************************************************************/
static int handle_tupletnote(FAR struct music_macro_lang_s *mml, char code,
FAR char **score,
FAR struct mml_result_s *result)
{
int ret = MML_TYPE_NOTE;
DEBUG("Tuplet : TTL %d, CUR %d\n", mml->tuplet_notes, mml->cur_tuplet);
if (mml->cur_tuplet < mml->tuplet_notes)
{
result->note_idx[0] = note_index(code) + halfscale(score)
+ mml->cur_octave * 12;
result->length = tuplet_length(mml);
}
else
{
ret = MML_TYPE_ILLIGAL_TOOMANY_NOTES;
}
return ret;
}
/****************************************************************************
* name: handle_notes
****************************************************************************/
static int handle_notes(FAR struct music_macro_lang_s *mml, char code,
FAR char **score,
FAR struct mml_result_s *result)
{
int ret;
result->chord_notes = 1;
if (mml->state == MML_STATE_TUPLET)
{
ret = handle_tupletnote(mml, code, score, result);
}
else
{
ret = handle_note(mml, code, score, result);
}
return ret;
}
/****************************************************************************
* name: handle_startchord
****************************************************************************/
static int handle_startchord(FAR struct music_macro_lang_s *mml,
FAR char **score,
FAR struct mml_result_s *result)
{
char code;
int note_idx;
code = next_code(score);
while (code != CHORD_END && code != '\0')
{
DEBUG("CHORD: %c\n", code);
note_idx = note_index(code);
DEBUG("CHORD note_idx = %d\n", note_idx);
if (note_idx >= 0)
{
note_idx += halfscale(score) + mml->cur_octave * 12;
if (result->chord_notes < MAX_CHORD_NOTES)
{
result->note_idx[result->chord_notes] = note_idx;
result->chord_notes++;
}
/* In case of chord notes are over than MAX_CHORD_NOTES,
* just ignore overflowed notes. Not behave as an error.
*/
}
else
{
switch (code)
{
case 'O':
case '>':
case '<':
if (handle_octave(mml, code, score, result) < 0)
{
return MML_TYPE_CHORD_ERROR;
}
break;
default:
return MML_TYPE_CHORD_ERROR;
break;
}
}
code = next_code(score);
}
if (code == '\0')
{
return MML_TYPE_CHORD_ERROR;
}
if (mml->state == MML_STATE_TUPLET)
{
result->length = tuplet_length(mml);
}
else
{
result->length = sample_length(mml, score);
}
return result->length < 0 ? MML_TYPE_CHORD_ERROR : MML_TYPE_CHORD;
}
/****************************************************************************
* name: handle_tone
****************************************************************************/
static int handle_tone(FAR struct music_macro_lang_s *mml,
FAR char **score, FAR struct mml_result_s *result)
{
int ret = MML_TYPE_TONE_ERROR;
if (isdigit(**score))
{
result->note_idx[0] = atoi(*score);
*score += strlendigits(*score);
ret = MML_TYPE_TONE;
}
return ret;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* name: init_mml
****************************************************************************/
int init_mml(FAR struct music_macro_lang_s *mml, int fs,
int tempo, int octave, int length)
{
mml->fs = fs;
mml->cur_tempo = tempo;
mml->cur_octave = octave;
mml->def_length = length;
mml->state = MML_STATE_NORMAL;
mml->cur_tuplet = 0;
mml->tuplet_notes = 0;
mml->tuplet_length = 0;
return 0;
}
/****************************************************************************
* name: parse_mml
****************************************************************************/
int parse_mml(FAR struct music_macro_lang_s *mml, FAR char **score,
FAR struct mml_result_s *result)
{
int ret;
char code;
code = next_code(score);
DEBUG("code=%c\n", code);
result->chord_notes = 0;
switch (code)
{
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
ret = handle_notes(mml, code, score, result);
break;
case 'R':
ret = handle_rest(mml, score, result);
break;
case 'T':
ret = handle_tempo(mml, score, result);
break;
case 'L':
ret = handle_length(mml, score, result);
break;
case 'O':
case '>':
case '<':
ret = handle_octave(mml, code, score, result);
break;
case 'V':
ret = handle_volume(mml, score, result);
break;
case CHORD_START:
ret = handle_startchord(mml, score, result);
break;
case TUPLET_START:
ret = handle_starttuplet(mml, score, result);
break;
case TUPLET_END:
ret = handle_stoptuplet(mml, score, result);
break;
case '@':
ret = handle_tone(mml, score, result);
break;
case '\0':
ret = MML_TYPE_EOF;
*score -= 1; /* Backward */
break;
default:
ret = MML_TYPE_ILLIGAL_COMPOSITION;
break;
}
return ret;
}

View file

@ -1 +0,0 @@
morsey

View file

@ -1,6 +0,0 @@
config AUDIOUTILS_MORSEY
bool "Morse code playing library"
default n
---help---
Simple library for parsing ASCII text into playable Morse code. Not
necessarily restricted to audio.

View file

@ -1,25 +0,0 @@
############################################################################
# apps/audioutils/morsey/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
ifneq ($(CONFIG_AUDIOUTILS_MORSEY),)
CONFIGURED_APPS += $(APPDIR)/audioutils/morsey
endif

View file

@ -1,50 +0,0 @@
############################################################################
# apps/audioutils/morsey/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
include $(APPDIR)/Make.defs
CSRCS = $(MORSEY_DIR)/morsey.c
MORSEY_DIR = morsey
MORSEY_VERSION = v1.0.1
MORSEY_MORSEY_H_SHA256 = 55f45e7b9a4d810f928ffe3ee9bea4cc318e28b1f49abf9512aee2638bd1dbfa
MORSEY_MORSEY_C_SHA256 = 12babc90d3518e026c344c38dc3701287c41fd6b41a3ec96fb36c77907be78f8
$(MORSEY_DIR):
$(Q) echo "Cloning Morsey repo..."
$(Q) git clone --depth=1 --branch=$(MORSEY_VERSION) https://github.com/linguini1/morsey.git
$(Q) touch $(MORSEY_DIR)
$(Q) echo "Checking Morsey hashes..."
$(Q) $(APPDIR)/tools/check-hash.sh sha256 $(MORSEY_MORSEY_H_SHA256) $@/morsey.h
$(Q) $(APPDIR)/tools/check-hash.sh sha256 $(MORSEY_MORSEY_C_SHA256) $@/morsey.c
create_includes: $(MORSEY_DIR)/morsey.h
$(Q) cp $< $(APPDIR)/include/audioutils
context:: $(MORSEY_DIR)
$(Q) $(MAKE) create_includes
distclean::
$(call DELFILE, $(APPDIR)/include/audioutils/morsey.h)
$(call DELDIR, morsey)
include $(APPDIR)/Application.mk

View file

@ -1,25 +0,0 @@
# ##############################################################################
# apps/audioutils/nxaudio/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
if(CONFIG_AUDIOUTILS_NXAUDIO_LIB)
target_sources(apps PRIVATE nxaudio.c)
endif()

View file

@ -1,26 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config AUDIOUTILS_NXAUDIO_LIB
bool "NX Audio Library"
default n
---help---
Enable support for the NX Audio library.
if AUDIOUTILS_NXAUDIO_LIB
config AUDIOUTILS_NXAUDIO_DEVPATH
string "Audio Device file path"
default "/dev/audio/pcm1"
---help---
Audio device file path of target audio device.
config AUDIOUTILS_NXAUDIO_MSGQNAME
string "Message queue name"
default "/tmp/fmaudio_mq"
---help---
Message queue name (file path) to communicate with audio message loop.
endif

View file

@ -1,25 +0,0 @@
############################################################################
# apps/audioutils/nxaudio/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
ifneq ($(CONFIG_AUDIOUTILS_NXAUDIO_LIB),)
CONFIGURED_APPS += $(APPDIR)/audioutils/nxaudio
endif

View file

@ -1,27 +0,0 @@
############################################################################
# apps/audioutils/nxaudio/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
include $(APPDIR)/Make.defs
CSRCS = nxaudio.c
include $(APPDIR)/Application.mk

View file

@ -1,353 +0,0 @@
/****************************************************************************
* apps/audioutils/nxaudio/nxaudio.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <mqueue.h>
#include <sys/ioctl.h>
#include <nuttx/audio/audio.h>
#include <errno.h>
#include <audioutils/nxaudio.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* name: configure_audio
****************************************************************************/
static int configure_audio(int fd, int ch, int fs, int bps, int chmap)
{
struct audio_caps_desc_s cap;
cap.caps.ac_len = sizeof(struct audio_caps_s);
cap.caps.ac_type = AUDIO_TYPE_OUTPUT;
cap.caps.ac_channels = ch;
cap.caps.ac_chmap = chmap;
cap.caps.ac_controls.hw[0] = fs;
cap.caps.ac_controls.b[2] = bps;
cap.caps.ac_controls.b[3] = 0; /* Just set 0 */
return ioctl(fd, AUDIOIOC_CONFIGURE, (unsigned long)(uintptr_t)&cap);
}
/****************************************************************************
* name: create_audiomq
****************************************************************************/
static mqd_t create_audiomq(const char *mqname, int fd, int buf_num)
{
mqd_t ret;
struct mq_attr attr;
attr.mq_maxmsg = buf_num;
attr.mq_msgsize = sizeof(struct audio_msg_s);
attr.mq_curmsgs = 0;
attr.mq_flags = 0;
ret = mq_open(mqname, O_RDWR | O_CREAT, 0644, &attr);
if (ret >= (mqd_t)0)
{
int rr;
if ((rr = ioctl(fd, AUDIOIOC_REGISTERMQ, (unsigned long)ret)) < 0)
{
printf("mq register failed: %d, %d\n", rr, errno);
}
}
return ret;
}
/****************************************************************************
* name: create_audio_buffers
****************************************************************************/
static FAR struct ap_buffer_s **create_audio_buffers(int fd, int num, int sz)
{
int i;
struct audio_buf_desc_s desc;
FAR struct ap_buffer_s **ret;
ret = (FAR struct ap_buffer_s **)calloc(num, sizeof(FAR void *));
for (i = 0; i < num; i++)
{
desc.numbytes = sz;
desc.u.pbuffer = &ret[i];
ioctl(fd, AUDIOIOC_ALLOCBUFFER, (unsigned long)(uintptr_t)&desc);
}
return ret;
}
/****************************************************************************
* name: free_audio_buffers
****************************************************************************/
static void free_audio_buffers(FAR struct nxaudio_s *nxaudio)
{
int x;
struct audio_buf_desc_s desc;
for (x = 0; x < nxaudio->abufnum; x++)
{
if (nxaudio->abufs[x] != NULL)
{
desc.u.buffer = nxaudio->abufs[x];
ioctl(nxaudio->fd, AUDIOIOC_FREEBUFFER,
(unsigned long)(uintptr_t)&desc);
}
}
free(nxaudio->abufs);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* name: fin_nxaudio
****************************************************************************/
void fin_nxaudio(FAR struct nxaudio_s *nxaudio)
{
ioctl(nxaudio->fd, AUDIOIOC_SHUTDOWN, 0);
ioctl(nxaudio->fd, AUDIOIOC_UNREGISTERMQ, (unsigned long)nxaudio->mq);
ioctl(nxaudio->fd, AUDIOIOC_RELEASE, 0);
free_audio_buffers(nxaudio);
close(nxaudio->fd);
mq_close(nxaudio->mq);
mq_unlink(CONFIG_AUDIOUTILS_NXAUDIO_MSGQNAME);
}
/****************************************************************************
* name: init_nxaudio
****************************************************************************/
int init_nxaudio(FAR struct nxaudio_s *nxaudio,
int fs, int bps, int chnum)
{
return init_nxaudio_devname(nxaudio, fs, bps, chnum,
CONFIG_AUDIOUTILS_NXAUDIO_DEVPATH,
CONFIG_AUDIOUTILS_NXAUDIO_MSGQNAME);
}
/****************************************************************************
* name: init_nxaudio_devname
****************************************************************************/
int init_nxaudio_devname(FAR struct nxaudio_s *nxaudio,
int fs, int bps, int chnum,
const char *devname, const char *mqname)
{
struct ap_buffer_info_s buf_info;
nxaudio->fd = open(devname, O_RDWR | O_CLOEXEC);
if (nxaudio->fd >= 0)
{
if (ioctl(nxaudio->fd, AUDIOIOC_RESERVE, 0) < 0)
{
close(nxaudio->fd);
return -1;
}
/* Audio configuration: set channel num, FS and bps */
configure_audio(nxaudio->fd, chnum, fs, bps, 0);
nxaudio->chnum = chnum;
ioctl(nxaudio->fd, AUDIOIOC_GETBUFFERINFO,
(unsigned long)(uintptr_t)&buf_info);
/* Create message queue to communicate with audio driver */
nxaudio->mq = create_audiomq(mqname, nxaudio->fd,
buf_info.nbuffers + 8);
/* Create audio buffers to inject audio sample */
nxaudio->abufs = create_audio_buffers(nxaudio->fd,
buf_info.nbuffers, buf_info.buffer_size);
nxaudio->abufnum = buf_info.nbuffers;
return 0;
}
else
{
return -1;
}
}
/****************************************************************************
* name: nxaudio_enqbuffer
****************************************************************************/
int nxaudio_enqbuffer(FAR struct nxaudio_s *nxaudio,
FAR struct ap_buffer_s *apb)
{
struct audio_buf_desc_s desc;
desc.numbytes = apb->nbytes;
desc.u.buffer = apb;
return ioctl(nxaudio->fd, AUDIOIOC_ENQUEUEBUFFER,
(unsigned long)(uintptr_t)&desc);
}
/****************************************************************************
* name: nxaudio_pause
****************************************************************************/
int nxaudio_pause(FAR struct nxaudio_s *nxaudio)
{
return ioctl(nxaudio->fd, AUDIOIOC_PAUSE, 0);
}
/****************************************************************************
* name: nxaudio_resume
****************************************************************************/
int nxaudio_resume(FAR struct nxaudio_s *nxaudio)
{
return ioctl(nxaudio->fd, AUDIOIOC_RESUME, 0);
}
/****************************************************************************
* name: nxaudio_setvolume
****************************************************************************/
int nxaudio_setvolume(FAR struct nxaudio_s *nxaudio, uint16_t vol)
{
struct audio_caps_desc_s cap_desc;
cap_desc.caps.ac_len = sizeof(struct audio_caps_s);
cap_desc.caps.ac_type = AUDIO_TYPE_FEATURE;
cap_desc.caps.ac_format.hw = AUDIO_FU_VOLUME;
cap_desc.caps.ac_controls.hw[0] = vol;
return ioctl(nxaudio->fd, AUDIOIOC_CONFIGURE,
(unsigned long)(uintptr_t)&cap_desc);
}
/****************************************************************************
* name: nxaudio_start
****************************************************************************/
int nxaudio_start(FAR struct nxaudio_s *nxaudio)
{
return ioctl(nxaudio->fd, AUDIOIOC_START, 0);
}
/****************************************************************************
* name: nxaudio_start
****************************************************************************/
int nxaudio_stop(FAR struct nxaudio_s *nxaudio)
{
struct audio_msg_s term_msg;
term_msg.msg_id = AUDIO_MSG_STOP;
term_msg.u.data = 0;
mq_send(nxaudio->mq, (FAR const char *)&term_msg, sizeof(term_msg), 0);
ioctl(nxaudio->fd, AUDIOIOC_STOP, 0);
return OK;
}
/****************************************************************************
* name: nxaudio_msgloop
****************************************************************************/
int nxaudio_msgloop(FAR struct nxaudio_s *nxaudio,
FAR struct nxaudio_callbacks_s *cbs,
unsigned long arg)
{
bool running = true;
struct audio_msg_s msg;
unsigned int prio;
ssize_t size;
if (!cbs)
{
return -1;
}
while (running)
{
size = mq_receive(nxaudio->mq, (FAR char *)&msg, sizeof(msg), &prio);
if (size != sizeof(msg))
{
continue;
}
switch (msg.msg_id)
{
case AUDIO_MSG_DEQUEUE:
if (cbs->dequeue)
{
cbs->dequeue(arg, msg.u.ptr);
}
break;
case AUDIO_MSG_COMPLETE:
if (cbs->complete)
{
cbs->complete(arg);
}
break;
case AUDIO_MSG_STOP:
running = false;
break;
case AUDIO_MSG_USER:
if (cbs->user)
{
cbs->user(arg, &msg, &running);
}
break;
default:
break;
}
}
return 0;
}

View file

@ -1 +0,0 @@
/rtttl-c

View file

@ -1,21 +0,0 @@
config AUDIOUTILS_RTTTL_C
bool "RTTTL parsing library"
default n
---help---
Simple library for parsing Ring Tone Text Transfer Language (RTTTL)
Define how to make a sound:
void
play_tone(struct rtttl_tone tone)
{
/* TODO: Make a sound with
* tone.frequency_100hz
* tone.period_us
* tone.duration_us
*/
}
and then play RTTTL string:
rtttl_play("...", play_tone);

View file

@ -1,25 +0,0 @@
############################################################################
# apps/audioutils/rtttl-c/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
ifneq ($(CONFIG_AUDIOUTILS_RTTTL_C),)
CONFIGURED_APPS += $(APPDIR)/audioutils/rtttl-c
endif

View file

@ -1,50 +0,0 @@
############################################################################
# apps/audioutils/rtttl-c/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
include $(APPDIR)/Make.defs
CSRCS = $(RTTTL_C_DIR)/rtttl.c
RTTTL_C_DIR = rtttl-c
RTTTL_C_VERSION = v0.1.0
RTTTL_C_RTTTL_H_SHA256 = 6331174ae34a419ad427d9755f8ba9d3b6a92c09ecc4f36bbe07ec5e4d0cc007
RTTTL_C_RTTTL_C_SHA256 = f0db64ef0b68136bac24616a3d62508bcc54ccdd68265d6447d99b264653b7b9
$(RTTTL_C_DIR):
$(Q) echo "Cloning rtttl-c repo..."
$(Q) git clone --depth=1 --branch=$(RTTTL_C_VERSION) https://git.sr.ht/~qeef/rtttl-c
$(Q) touch $(RTTTL_C_DIR)
$(Q) echo "Checking rtttl-c hashes..."
$(Q) $(APPDIR)/tools/check-hash.sh sha256 $(RTTTL_C_RTTTL_H_SHA256) $@/rtttl.h
$(Q) $(APPDIR)/tools/check-hash.sh sha256 $(RTTTL_C_RTTTL_C_SHA256) $@/rtttl.c
create_includes: $(RTTTL_C_DIR)/rtttl.h
$(Q) cp $< $(APPDIR)/include/audioutils
context:: $(RTTTL_C_DIR)
$(Q) $(MAKE) create_includes
distclean::
$(call DELFILE, $(APPDIR)/include/audioutils/rtttl.h)
$(call DELDIR, rtttl-c)
include $(APPDIR)/Application.mk

View file

@ -1 +0,0 @@
/Kconfig

View file

@ -1,25 +0,0 @@
# ##############################################################################
# apps/benchmarks/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
nuttx_add_subdirectory()
nuttx_generate_kconfig(MENUDESC "Benchmark Applications")

View file

@ -1,23 +0,0 @@
############################################################################
# apps/benchmarks/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
include $(wildcard $(APPDIR)/benchmarks/*/Make.defs)

View file

@ -1,25 +0,0 @@
############################################################################
# apps/benchmarks/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
MENUDESC = "Benchmark Applications"
include $(APPDIR)/Directory.mk

View file

@ -1,33 +0,0 @@
# ##############################################################################
# apps/benchmarks/cachespeed/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
if(CONFIG_BENCHMARK_CACHESPEED)
nuttx_add_application(
NAME
${CONFIG_BENCHMARK_CACHESPEED_PROGNAME}
SRCS
cachespeed_main.c
STACKSIZE
${CONFIG_BENCHMARK_CACHESPEED_STACKSIZE}
PRIORITY
${CONFIG_BENCHMARK_CACHESPEED_PRIORITY})
endif()

View file

@ -1,44 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config BENCHMARK_CACHESPEED
tristate "CACHE Speed Test"
depends on ARCH_ICACHE && ARCH_DCACHE
default n
---help---
Enable a simple CACHE speed test.
if BENCHMARK_CACHESPEED
config BENCHMARK_CACHESPEED_PROGNAME
string "Program name"
default "cachespeed"
---help---
This is the name of the program that will be used when the NSH ELF
program is installed.
config BENCHMARK_CACHESPEED_PRIORITY
int "CACHE speed test task priority"
default 100
config BENCHMARK_CACHESPEED_STACKSIZE
int "CACHE speed test stack size"
default DEFAULT_TASK_STACKSIZE
config CACHESPEED_MONOTONIC_TIME
bool "Using Clock Gettime"
default n
---help---
When you turn on this option, your test loop will go from 10000 -> 1000 times
Please consider the following scenario:
1. By default (PERFTIME) will have a relatively high precision, but this also
tends to cause failure in getting values on some smaller bytes, so reducing
the precision with this option can make it easier to get data values.
2. whether to compare data with the content of other tools (using CLOCK
GETTIME method), if so, it is recommended to turn on, so as to ensure that
the data precision of both consistent.
endif

View file

@ -1,25 +0,0 @@
############################################################################
# apps/benchmarks/cachespeed/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
ifneq ($(CONFIG_BENCHMARK_CACHESPEED),)
CONFIGURED_APPS += $(APPDIR)/benchmarks/cachespeed
endif

View file

@ -1,38 +0,0 @@
############################################################################
# apps/benchmarks/cachespeed/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
include $(APPDIR)/Make.defs
#CACHE speed test
ifneq ($(CONFIG_CACHESPEED_MONOTONIC_TIME),y)
CFLAGS += -DCACHESPEED_PERFTIME
endif
PROGNAME = $(CONFIG_BENCHMARK_CACHESPEED_PROGNAME)
PRIORITY = $(CONFIG_BENCHMARK_CACHESPEED_PRIORITY)
STACKSIZE = $(CONFIG_BENCHMARK_CACHESPEED_STACKSIZE)
MODULE = $(CONFIG_BENCHMARK_CACHESPEED)
MAINSRC = cachespeed_main.c
include $(APPDIR)/Application.mk

View file

@ -1,254 +0,0 @@
/****************************************************************************
* apps/benchmarks/cachespeed/cachespeed_main.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/arch.h>
#include <nuttx/cache.h>
#include <nuttx/config.h>
#include <nuttx/irq.h>
#include <inttypes.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define CACHESPEED_PREFIX "CACHE Speed: "
#define REPEAT_NUM 1000
#ifdef CACHESPEED_PERFTIME
#define TIME uint64_t
#define CONVERT(cost) \
do \
{ \
struct timespec ts; \
perf_convert(cost, &ts); \
cost = ts.tv_sec * 1000000000 + ts.tv_nsec; \
} while (0)
#define TIMESTAMP(x) (x) = perf_gettime()
#else
#define TIME time_t
#define CONVERT(cost)
#define TIMESTAMP(x) \
do \
{ \
struct timespec ts; \
clock_gettime(CLOCK_MONOTONIC, &ts); \
x = ts.tv_sec * 1000000000 + ts.tv_nsec; \
} while (0)
#endif
#define GET_DCACHE_LINE up_get_dcache_linesize()
#define GET_ICACHE_LINE up_get_icache_linesize()
#define GET_DCACHE_SIZE up_get_dcache_size()
#define GET_ICACHE_SIZE up_get_icache_size()
/****************************************************************************
* Private Types
****************************************************************************/
struct cachespeed_s
{
uintptr_t addr;
size_t alloc;
};
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: setup
****************************************************************************/
static void setup(FAR struct cachespeed_s *cs)
{
struct mallinfo info = mallinfo();
/* Get the currently available memory from the system. We want the
* memset range to be as large as possible in our tests to ensure
* that the cache is filled with our dirty data
*/
cs->alloc = info.fordblks / 2;
cs->addr = (uintptr_t)malloc(cs->alloc);
if (cs->addr == 0)
{
printf(CACHESPEED_PREFIX "Unable to request memory.\n");
exit(EXIT_FAILURE);
}
/* Let's export the test message */
printf(CACHESPEED_PREFIX "address src: %" PRIxPTR "\n", cs->addr);
}
/****************************************************************************
* Name: teardown
****************************************************************************/
static void teardown(FAR struct cachespeed_s *cs)
{
free((void *)cs->addr);
printf(CACHESPEED_PREFIX "Done!\n");
}
/****************************************************************************
* Name: report_line
****************************************************************************/
static void report_line(size_t bytes, TIME cost)
{
double rate;
/* There is a situation: if the time is 0, then the
* calculated speed is wrong.
*/
CONVERT(cost);
if (cost == 0)
{
printf(CACHESPEED_PREFIX "%zu bytes cost time too small!\n", bytes);
return;
}
/* rate = Test Data Size / Execution Time */
rate = 1.00 * bytes * REPEAT_NUM / cost;
printf("%zu Bytes: %4lf, %4" PRIu64", %4" PRIu64"\n\r",
bytes, rate, cost / REPEAT_NUM, cost);
}
/****************************************************************************
* Name: test_skeleton
****************************************************************************/
static void test_skeleton(FAR struct cachespeed_s *cs,
const size_t cache_size,
const size_t cache_line_size, int align,
void (*func)(uintptr_t, uintptr_t),
const char *name)
{
size_t update_size;
printf("** %s [rate, avg, cost] in nanoseconds(bytes/nesc) %s **\n",
name, align ? "align" : "unalign");
if (!align)
{
update_size = cache_line_size - 1;
}
else
{
update_size = cache_line_size;
}
for (size_t bytes = update_size;
bytes <= cache_size; bytes = 2 * bytes)
{
irqstate_t irq;
TIME start;
TIME end;
TIME cost = 0;
/* Make sure that test with all the contents
* of our address in the cache.
*/
up_flush_dcache_all();
irq = enter_critical_section();
for (int i = 0; i < REPEAT_NUM; i++)
{
memset((void *)cs->addr, 1, cs->alloc);
TIMESTAMP(start);
func(cs->addr, (uintptr_t)(cs->addr + bytes));
TIMESTAMP(end);
cost += end - start;
}
leave_critical_section(irq);
report_line(bytes, cost);
}
}
/****************************************************************************
* Name: cachespeed_common
****************************************************************************/
static void cachespeed_common(struct cachespeed_s *cs)
{
test_skeleton(cs, GET_DCACHE_SIZE, GET_DCACHE_LINE, 1,
up_invalidate_dcache, "dcache invalidate");
test_skeleton(cs, GET_DCACHE_SIZE, GET_DCACHE_LINE, 0,
up_invalidate_dcache, "dcache invalidate");
test_skeleton(cs, GET_DCACHE_SIZE, GET_DCACHE_LINE, 1,
up_clean_dcache, "dcache clean");
test_skeleton(cs, GET_DCACHE_SIZE, GET_DCACHE_LINE, 0,
up_clean_dcache, "dcache clean");
test_skeleton(cs, GET_DCACHE_SIZE, GET_DCACHE_LINE, 1,
up_flush_dcache, "dcache flush");
test_skeleton(cs, GET_DCACHE_SIZE, GET_DCACHE_LINE, 0,
up_flush_dcache, "dcache flush");
test_skeleton(cs, GET_ICACHE_SIZE, GET_ICACHE_LINE, 1,
up_invalidate_icache, "icache invalidate");
test_skeleton(cs, GET_ICACHE_SIZE, GET_ICACHE_LINE, 0,
up_invalidate_icache, "icache invalidate");
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: cachespeed_main
****************************************************************************/
int main(int argc, FAR char *argv[])
{
struct cachespeed_s cs =
{
.addr = 0,
.alloc = 0
};
setup(&cs);
cachespeed_common(&cs);
teardown(&cs);
return 0;
}

View file

@ -1 +0,0 @@
/coremark-pro

View file

@ -1,333 +0,0 @@
# ##############################################################################
# apps/benchmarks/coremark-pro/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
if(CONFIG_BENCHMARK_COREMARK_PRO)
set(COREMARKAPP_DIR ${CMAKE_CURRENT_LIST_DIR}/coremark-pro)
if(NOT EXISTS ${COREMARKAPP_DIR})
FetchContent_Declare(
coremark_fetch
URL https://github.com/eembc/coremark-pro/archive/refs/heads/main.zip
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/coremark-pro BINARY_DIR
${CMAKE_BINARY_DIR}/apps/benchmarks/coremark/coremark-pro
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)
FetchContent_GetProperties(coremark_fetch)
if(NOT coremark_fetch_POPULATED)
FetchContent_Populate(coremark_fetch)
endif()
endif()
nuttx_add_library(coremark_pro STATIC)
set(CSRCS
coremark-pro/mith/src/md5.c
coremark-pro/mith/src/mith_lib.c
coremark-pro/mith/src/mith_workload.c
coremark-pro/mith/src/th_bignum.c
coremark-pro/mith/src/th_encode.c
coremark-pro/mith/src/th_lib.c
coremark-pro/mith/src/th_math.c
coremark-pro/mith/src/th_rand.c)
file(GLOB MITH_AL_SRCS coremark-pro/mith/al/src/*.c)
list(APPEND CSRCS ${MITH_AL_SRCS})
set(CFLAGS
-Wno-undef
-Wno-strict-prototypes
-Wno-unused-variable
-Wno-pointer-sign
-Wno-unused-but-set-variable
-Wno-shadow
-DNDEBUG
-DHOST_EXAMPLE_CODE=1
-DHAVE_SYS_STAT_H=1
-DGCC_INLINE_MACRO=1
-DMAX_CONTEXTS=100
-DEE_SIZEOF_INT=4
-DUSE_FP128=0)
set(INCDIR ${CMAKE_CURRENT_LIST_DIR}/coremark-pro/mith/include
${CMAKE_CURRENT_LIST_DIR}/coremark-pro/mith/al/include)
if(CONFIG_BENCHMARK_COREMARK_PRO_USE_SINGLE_CONTEXT)
list(APPEND CFLAGS -DUSE_SINGLE_CONTEXT=1 -DHAVE_PTHREAD=0
-DUSE_NATIVE_PTHREAD=0)
else()
list(APPEND CFLAGS -DUSE_SINGLE_CONTEXT=0 -DHAVE_PTHREAD=1
-DUSE_NATIVE_PTHREAD=1)
endif()
if(CONFIG_BENCHMARK_COREMARK_PRO_SMP)
list(APPEND CFLAGS -DHAVE_PTHREAD_SETAFFINITY_NP=1 -DHAVE_PTHREAD_SELF=1)
endif()
if(CONFIG_BENCHMARK_COREMARK_PRO_64BIT)
list(APPEND CFLAGS -DEE_SIZEOF_PTR=8 -DEE_PTR_ALIGN=8 -DEE_SIZEOF_LONG=8)
endif()
if(CONFIG_BENCHMARK_COREMARK_PRO_USE_FP64)
list(APPEND CFLAGS -DUSE_FP64=1 -DUSE_FP32=0)
list(APPEND CSRCS coremark-pro/benchmarks/fp/linpack/ref/inputs_f64.c)
else()
list(APPEND CFLAGS -DUSE_FP32=1 -DUSE_FP64=0)
list(APPEND CSRCS coremark-pro/benchmarks/fp/linpack/ref/inputs_f32.c)
endif()
if(CONFIG_BENCHMARK_COREMARK_PRO_CORE_TEST)
file(GLOB CORE_TEST_SRCS coremark-pro/benchmarks/core/*.c)
set(CORE_TEST_CSRCS coremark-pro/workloads/core/core.c ${CORE_TEST_SRCS})
nuttx_add_application(
NAME
core
PRIORITY
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
STACKSIZE
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
MODULE
${CONFIG_BENCHMARK_COREMARK_PRO}
COMPILE_FLAGS
${CFLAGS}
SRCS
${CORE_TEST_CSRCS}
INCLUDE_DIRECTORIES
${INCDIR}
DEPENDS
coremark_pro)
endif()
if(CONFIG_BENCHMARK_COREMARK_PRO_CJPEG_TEST)
file(GLOB CJPEG_SRCS coremark-pro/benchmarks/consumer_v2/cjpeg/*.c)
set(CJPEG_CSRCS
coremark-pro/workloads/cjpeg-rose7-preset/cjpeg-rose7-preset.c
coremark-pro/benchmarks/consumer_v2/cjpeg/data/Rose256_bmp.c
${CJPEG_SRCS})
nuttx_add_application(
NAME
cjpeg_rose7_preset
PRIORITY
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
STACKSIZE
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
MODULE
${CONFIG_BENCHMARK_COREMARK_PRO}
COMPILE_FLAGS
${CFLAGS}
SRCS
${CJPEG_CSRCS}
INCLUDE_DIRECTORIES
${INCDIR}
DEPENDS
coremark_pro)
endif()
if(CONFIG_BENCHMARK_COREMARK_PRO_SHA_TEST)
file(GLOB SHA_TEST_SRCS coremark-pro/benchmarks/darkmark/sha/*.c)
set(SHA_TEST_CSRCS coremark-pro/workloads/sha-test/sha-test.c
${SHA_TEST_SRCS})
nuttx_add_application(
NAME
sha_test
PRIORITY
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
STACKSIZE
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
MODULE
${CONFIG_BENCHMARK_COREMARK_PRO}
COMPILE_FLAGS
${CFLAGS}
SRCS
${SHA_TEST_CSRCS}
INCLUDE_DIRECTORIES
${INCDIR}
DEPENDS
coremark_pro)
endif()
if(CONFIG_BENCHMARK_COREMARK_PRO_ZIP_TEST)
set(ZIP_TEST_CSRCS coremark-pro/workloads/zip-test/zip-test.c
coremark-pro/benchmarks/darkmark/zip/zip_darkmark.c)
set(ZIP_TEST_FLAGS ${CFLAGS} -Dgzclose_r=coremark_zip_gzclose_r
-Dgzclose_w=coremark_zip_gzclose_w)
set(ZIP_TEST_INCDIR ${INCDIR} ${NUTTX_APPS_DIR}/system/zlib/zlib)
nuttx_add_application(
NAME
zip_test
PRIORITY
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
STACKSIZE
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
MODULE
${CONFIG_BENCHMARK_COREMARK_PRO}
COMPILE_FLAGS
${ZIP_TEST_FLAGS}
SRCS
${ZIP_TEST_CSRCS}
INCLUDE_DIRECTORIES
${ZIP_TEST_INCDIR}
DEPENDS
coremark_pro)
endif()
if(CONFIG_BENCHMARK_COREMARK_PRO_LINEAR_ALG_MID_TEST)
set(ALG_MID_CSRCS
coremark-pro/workloads/linear_alg-mid-100x100-sp/linear_alg-mid-100x100-sp.c
coremark-pro/benchmarks/fp/linpack/linpack.c)
nuttx_add_application(
NAME
linear_alg_mid_100x100_sp
PRIORITY
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
STACKSIZE
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
MODULE
${CONFIG_BENCHMARK_COREMARK_PRO}
COMPILE_FLAGS
${CFLAGS}
SRCS
${ALG_MID_CSRCS}
INCLUDE_DIRECTORIES
${INCDIR}
DEPENDS
coremark_pro)
endif()
if(CONFIG_BENCHMARK_COREMARK_PRO_RADIX_TEST)
if(CONFIG_BENCHMARK_COREMARK_PRO_USE_FP64)
file(GLOB RADIX_SRCS coremark-pro/benchmarks/fp/fft_radix2/ref/*.c)
else()
file(GLOB RADIX_SRCS coremark-pro/benchmarks/fp/fft_radix2/ref-sp/*.c)
endif()
set(RADIX_CSRCS
coremark-pro/workloads/radix2-big-64k/radix2-big-64k.c
coremark-pro/benchmarks/fp/fft_radix2/fft_radix2.c ${RADIX_SRCS})
nuttx_add_application(
NAME
radix2_big_64k
PRIORITY
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
STACKSIZE
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
MODULE
${CONFIG_BENCHMARK_COREMARK_PRO}
COMPILE_FLAGS
${CFLAGS}
SRCS
${RADIX_CSRCS}
INCLUDE_DIRECTORIES
${INCDIR}
DEPENDS
coremark_pro)
endif()
if(CONFIG_BENCHMARK_COREMARK_PRO_LOOPS_ALL_MID_TEST)
if(CONFIG_BENCHMARK_COREMARK_PRO_USE_FP64)
file(GLOB MID_SRCS coremark-pro/benchmarks/fp/loops/ref/*.c)
else()
file(GLOB MID_SRCS coremark-pro/benchmarks/fp/loops/ref-sp/*.c)
endif()
set(MID_CSRCS
coremark-pro/workloads/loops-all-mid-10k-sp/loops-all-mid-10k-sp.c
coremark-pro/benchmarks/fp/loops/loops.c ${MID_SRCS})
nuttx_add_application(
NAME
loops_all_mid_10k_sp
PRIORITY
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
STACKSIZE
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
MODULE
${CONFIG_BENCHMARK_COREMARK_PRO}
COMPILE_FLAGS
${CFLAGS}
SRCS
${MID_CSRCS}
INCLUDE_DIRECTORIES
${INCDIR}
DEPENDS
coremark_pro)
endif()
if(CONFIG_BENCHMARK_COREMARK_PRO_NNET_TEST)
if(CONFIG_BENCHMARK_COREMARK_PRO_USE_FP64)
file(GLOB NNET_SRCS coremark-pro/benchmarks/fp/nnet/ref/*.c)
else()
file(GLOB NNET_SRCS coremark-pro/benchmarks/fp/nnet/ref-sp/*.c)
endif()
file(GLOB FP_NNET_SRCS coremark-pro/benchmarks/fp/nnet/*.c)
set(NNET_CSRCS coremark-pro/workloads/nnet_test/nnet_test.c ${FP_NNET_SRCS}
${NNET_SRCS})
nuttx_add_application(
NAME
nnet_test
PRIORITY
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
STACKSIZE
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
MODULE
${CONFIG_BENCHMARK_COREMARK_PRO}
COMPILE_FLAGS
${CFLAGS}
SRCS
${NNET_CSRCS}
INCLUDE_DIRECTORIES
${INCDIR}
DEPENDS
coremark_pro)
endif()
if(CONFIG_BENCHMARK_COREMARK_PRO_PARSER_125K)
file(GLOB PARSER_SRCS coremark-pro/benchmarks/darkmark/parser/*.c)
set(PARSER_CSRCS coremark-pro/workloads/parser-125k/parser-125k.c
${PARSER_SRCS})
nuttx_add_application(
NAME
parser_125k
PRIORITY
${CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY}
STACKSIZE
${CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE}
MODULE
${CONFIG_BENCHMARK_COREMARK_PRO}
COMPILE_FLAGS
${CFLAGS}
SRCS
${PARSER_CSRCS}
INCLUDE_DIRECTORIES
${INCDIR}
DEPENDS
coremark_pro)
endif()
target_sources(coremark_pro PRIVATE ${CSRCS})
target_include_directories(coremark_pro PRIVATE ${INCDIR})
target_compile_options(coremark_pro PRIVATE ${CFLAGS})
endif()

View file

@ -1,81 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menuconfig BENCHMARK_COREMARK_PRO
tristate "Coremark Pro Benchmark"
default n
depends on LIBC_FLOATINGPOINT
if BENCHMARK_COREMARK_PRO
config BENCHMARK_COREMARK_PRO_STACKSIZE
int "Coremark Pro stack size"
default 131072
config BENCHMARK_COREMARK_PRO_PRIORITY
int "Coremark Pro priority"
default 100
config BENCHMARK_COREMARK_PRO_USE_SINGLE_CONTEXT
bool "use single context"
default n
config BENCHMARK_COREMARK_PRO_SMP
bool "Relevant configurations in case of SMP"
default n
depends on SMP && !BENCHMARK_COREMARK_PRO_USE_SINGLE_CONTEXT
config BENCHMARK_COREMARK_PRO_64BIT
bool "Running on 64-bit operating systems"
default n
config BENCHMARK_COREMARK_PRO_USE_FP64
bool "USE FP64 Data for Test"
default n
config BENCHMARK_COREMARK_PRO_CORE_TEST
bool "Core Test"
default n
config BENCHMARK_COREMARK_PRO_CJPEG_TEST
bool "cjpeg-rose7-preset"
default n
---help---
Before using this case, place the files in coremark-pro/benchmarks/libbmp
and coremark-pro/benchmarks/libjpeg in /data/libbmp and /data/libjpeg
respectively
config BENCHMARK_COREMARK_PRO_LINEAR_ALG_MID_TEST
bool "Linear_alg_mid TEST"
default n
config BENCHMARK_COREMARK_PRO_SHA_TEST
bool "SHA Test"
default n
config BENCHMARK_COREMARK_PRO_ZIP_TEST
bool "Zip Test"
depends on LIB_ZLIB
default n
choice
prompt "Coremark Pro FP Test Case configuration"
default BENCHMARK_COREMARK_PRO_RADIX_TEST
config BENCHMARK_COREMARK_PRO_RADIX_TEST
bool "Radix Test"
config BENCHMARK_COREMARK_PRO_LOOPS_ALL_MID_TEST
bool "Loops-all-mid test"
config BENCHMARK_COREMARK_PRO_NNET_TEST
bool "Nnet Test"
config BENCHMARK_COREMARK_PRO_PARSER_125K
bool "Parser 125K Test"
endchoice
endif

View file

@ -1,25 +0,0 @@
############################################################################
# apps/benchmarks/coremark-pro/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO),)
CONFIGURED_APPS += $(APPDIR)/benchmarks/coremark-pro
endif

View file

@ -1,160 +0,0 @@
############################################################################
# apps/benchmarks/coremark-pro/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
include $(APPDIR)/Make.defs
PRIORITY = $(CONFIG_BENCHMARK_COREMARK_PRO_PRIORITY)
STACKSIZE = $(CONFIG_BENCHMARK_COREMARK_PRO_STACKSIZE)
MODULE = $(CONFIG_BENCHMARK_COREMARK_PRO)
CFLAGS += -Wno-undef -Wno-strict-prototypes -Wno-unused-variable \
-Wno-pointer-sign -Wno-unused-but-set-variable -Wno-shadow
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/benchmarks/coremark-pro/coremark-pro/mith/include
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/benchmarks/coremark-pro/coremark-pro/mith/al/include
CFLAGS += -DNDEBUG -DHOST_EXAMPLE_CODE=1 -DHAVE_SYS_STAT_H=1 \
-DGCC_INLINE_MACRO=1 -DMAX_CONTEXTS=100 -DEE_SIZEOF_INT=4 \
-DUSE_FP128=0
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_USE_SINGLE_CONTEXT),)
CFLAGS += -DUSE_SINGLE_CONTEXT=1 -DHAVE_PTHREAD=0 -DUSE_NATIVE_PTHREAD=0
else
CFLAGS += -DUSE_SINGLE_CONTEXT=0 -DHAVE_PTHREAD=1 -DUSE_NATIVE_PTHREAD=1
endif
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_SMP),)
CFLAGS += -DHAVE_PTHREAD_SETAFFINITY_NP=1 -DHAVE_PTHREAD_SELF=1
endif
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_64BIT),)
CFLAGS += -DEE_SIZEOF_PTR=8 -DEE_PTR_ALIGN=8 -DEE_SIZEOF_LONG=8
endif
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_USE_FP64),)
CFLAGS += -DUSE_FP64=1 -DUSE_FP32=0
CSRCS += coremark-pro/benchmarks/fp/linpack/ref/inputs_f64.c
else
CFLAGS += -DUSE_FP32=1 -DUSE_FP64=0
CSRCS += coremark-pro/benchmarks/fp/linpack/ref/inputs_f32.c
endif
CSRCS += coremark-pro/mith/src/md5.c
CSRCS += coremark-pro/mith/src/mith_lib.c
CSRCS += coremark-pro/mith/src/mith_workload.c
CSRCS += coremark-pro/mith/src/th_bignum.c
CSRCS += coremark-pro/mith/src/th_encode.c
CSRCS += coremark-pro/mith/src/th_lib.c
CSRCS += coremark-pro/mith/src/th_math.c
CSRCS += coremark-pro/mith/src/th_rand.c
CSRCS += $(wildcard coremark-pro/mith/al/src/*.c)
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_CORE_TEST),)
CSRCS += $(wildcard coremark-pro/benchmarks/core/*.c)
MAINSRC += coremark-pro/workloads/core/core.c
PROGNAME += core
endif
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_CJPEG_TEST),)
CSRCS += $(wildcard coremark-pro/benchmarks/consumer_v2/cjpeg/*.c)
CSRCS += $(wildcard coremark-pro/benchmarks/consumer_v2/cjpeg/data/Rose256_bmp.c)
MAINSRC += coremark-pro/workloads/cjpeg-rose7-preset/cjpeg-rose7-preset.c
PROGNAME += cjpeg_rose7_preset
endif
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_SHA_TEST),)
CSRCS += $(wildcard coremark-pro/benchmarks/darkmark/sha/*.c)
MAINSRC += coremark-pro/workloads/sha-test/sha-test.c
PROGNAME += sha_test
endif
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_ZIP_TEST),)
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/system/zlib/zlib
CFLAGS += -Dgzclose_r=coremark_zip_gzclose_r -Dgzclose_w=coremark_zip_gzclose_w
CSRCS += coremark-pro/benchmarks/darkmark/zip/zip_darkmark.c
MAINSRC += coremark-pro/workloads/zip-test/zip-test.c
PROGNAME += zip_test
endif
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_LINEAR_ALG_MID_TEST),)
CSRCS += coremark-pro/benchmarks/fp/linpack/linpack.c
MAINSRC += coremark-pro/workloads/linear_alg-mid-100x100-sp/linear_alg-mid-100x100-sp.c
PROGNAME += linear_alg_mid_100x100_sp
endif
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_RADIX_TEST),)
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_USE_FP64),)
CSRCS += $(wildcard coremark-pro/benchmarks/fp/fft_radix2/ref/*.c)
else
CSRCS += $(wildcard coremark-pro/benchmarks/fp/fft_radix2/ref-sp/*.c)
endif
CSRCS += coremark-pro/benchmarks/fp/fft_radix2/fft_radix2.c
MAINSRC += coremark-pro/workloads/radix2-big-64k/radix2-big-64k.c
PROGNAME += radix2_big_64k
endif
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_LOOPS_ALL_MID_TEST),)
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_USE_FP64),)
CSRCS += $(wildcard coremark-pro/benchmarks/fp/loops/ref/*.c)
else
CSRCS += $(wildcard coremark-pro/benchmarks/fp/loops/ref-sp/*.c)
endif
CSRCS += coremark-pro/benchmarks/fp/loops/loops.c
MAINSRC += coremark-pro/workloads/loops-all-mid-10k-sp/loops-all-mid-10k-sp.c
PROGNAME += loops_all_mid_10k_sp
endif
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_NNET_TEST),)
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_USE_FP64),)
CSRCS += $(wildcard coremark-pro/benchmarks/fp/nnet/ref/*.c)
else
CSRCS += $(wildcard coremark-pro/benchmarks/fp/nnet/ref-sp/*.c)
endif
CSRCS += $(wildcard coremark-pro/benchmarks/fp/nnet/*.c)
MAINSRC += coremark-pro/workloads/nnet_test/nnet_test.c
PROGNAME += nnet_test
endif
ifneq ($(CONFIG_BENCHMARK_COREMARK_PRO_PARSER_125K),)
CSRCS += $(wildcard coremark-pro/benchmarks/darkmark/parser/*.c)
MAINSRC += coremark-pro/workloads/parser-125k/parser-125k.c
PROGNAME += parser_125k
endif
ifeq ($(wildcard coremark-pro/.git),)
VERSION ?= main
coremark-pro.zip:
$(Q) curl -L https://github.com/eembc/coremark-pro/archive/refs/heads/main.zip -o coremark-pro.zip
$(Q) unzip -o coremark-pro.zip
$(Q) mv coremark-pro-$(VERSION) coremark-pro
context:: coremark-pro.zip
distclean::
$(call DELDIR, coremark-pro)
$(call DELFILE, coremark-pro.zip)
endif
include $(APPDIR)/Application.mk

View file

@ -1,2 +0,0 @@
/coremark
/*.zip

View file

@ -1,153 +0,0 @@
# ##############################################################################
# apps/benchmarks/coremark/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
if(CONFIG_BENCHMARK_COREMARK)
# ############################################################################
# Config and Fetch Coremark application
# ############################################################################
set(COREMARKAPP_DIR ${CMAKE_CURRENT_LIST_DIR}/coremark)
if(NOT EXISTS ${COREMARKAPP_DIR})
FetchContent_Declare(
coremark_fetch
URL https://github.com/eembc/coremark/archive/main.zip SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/coremark BINARY_DIR
${CMAKE_BINARY_DIR}/apps/benchmarks/coremark/coremark
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)
FetchContent_GetProperties(coremark_fetch)
if(NOT coremark_fetch_POPULATED)
FetchContent_Populate(coremark_fetch)
endif()
endif()
if(CONFIG_COREMARK_MULTITHREAD_OVERRIDE)
set(COREMARK_NTHREADS ${CONFIG_COREMARK_MULTITHREAD_COUNT})
endif()
if(CONFIG_SMP_NCPUS)
set(COREMARK_NTHREADS ${CONFIG_SMP_NCPUS})
else()
set(COREMARK_NTHREADS 1)
endif()
if(CONFIG_COREMARK_PRINT_ARGS)
set(COREMARK_PRINT_ARGS 1)
else()
set(COREMARK_PRINT_ARGS 0)
endif()
# ############################################################################
# Flags
# ############################################################################
if(CONFIG_COREMARK_MULTITHREAD_OVERRIDE)
set(COREMARK_NTHREADS ${CONFIG_COREMARK_MULTITHREAD_COUNT})
else()
if(CONFIG_SMP_NCPUS)
set(COREMARK_NTHREADS ${CONFIG_SMP_NCPUS})
else()
set(COREMARK_NTHREADS 1)
endif()
endif()
if(CONFIG_COREMARK_PRINT_ARGS)
set(COREMARK_PRINT_ARGS 1)
else()
set(COREMARK_PRINT_ARGS 0)
endif()
get_target_property(FLAGS_STR_LIST nuttx COMPILE_OPTIONS)
list(JOIN FLAGS_STR_LIST " " FLAGS_STR)
set(CFLAGS -Dcrc16=coremark_crc16 -Wno-strict-prototypes -Wno-undef)
if("${CONFIG_COREMARK_MEM_METHOD}" STREQUAL "1")
list(APPEND CFLAGS -DMEM_LOCATION=\"HEAP\")
elseif("${CONFIG_COREMARK_MEM_METHOD}" STREQUAL "2")
list(APPEND CFLAGS -DMEM_LOCATION=\"STACK\")
else()
list(APPEND CFLAGS -DMEM_LOCATION=\"GLOBAL\")
endif()
list(
APPEND
CFLAGS
-DCALLGRIND_RUN=0
-DCOMPILER_REQUIRES_SORT_RETURN=0
-DCORE_DEBUG=${CONFIG_COREMARK_DEBUG}
-DFLAGS_STR="${FLAGS_STR}"
-DMEM_METHOD=${CONFIG_COREMARK_MEM_METHOD}
-DMICA=0
-DMULTITHREAD=${COREMARK_NTHREADS}
-DPERFORMANCE_RUN=1
-DPRINT_ARGS=${COREMARK_PRINT_ARGS}
-DSEED_METHOD=${CONFIG_COREMARK_SEED_METHOD}
-DUSE_CLOCK=1
-DUSE_PTHREAD)
if(CONFIG_COREMARK_ITERATIONS_OVERRIDE)
list(APPEND CFLAGS -DITERATIONS=${CONFIG_COREMARK_ITERATIONS_COUNT})
else()
list(APPEND CFLAGS -DITERATIONS=0)
endif()
# ############################################################################
# Sources
# ############################################################################
set(CSRCS
${COREMARKAPP_DIR}/core_main.c ${COREMARKAPP_DIR}/core_list_join.c
${COREMARKAPP_DIR}/core_matrix.c ${COREMARKAPP_DIR}/core_state.c
${COREMARKAPP_DIR}/core_util.c ${COREMARKAPP_DIR}/posix/core_portme.c)
# ############################################################################
# Include Directory
# ############################################################################
set(INCDIR ${COREMARKAPP_DIR} ${COREMARKAPP_DIR}/posix)
# ############################################################################
# Applications Configuration
# ############################################################################
nuttx_add_application(
NAME
${CONFIG_COREMARK_PROGNAME}
PRIORITY
${CONFIG_COREMARK_PRIORITY}
STACKSIZE
${CONFIG_COREMARK_STACKSIZE}
MODULE
${CONFIG_BENCHMARK_COREMARK}
COMPILE_FLAGS
${CFLAGS}
SRCS
${CSRCS}
INCLUDE_DIRECTORIES
${INCDIR})
endif()

View file

@ -1,86 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menuconfig BENCHMARK_COREMARK
tristate "CoreMark Benchmark"
select LIBC_FLOATINGPOINT
default n
---help---
Enable support for the EEMBC's CoreMark benchmark application.
if BENCHMARK_COREMARK
config COREMARK_PROGNAME
string "CoreMark program name"
default "coremark"
---help---
This is the name of the program that will be used when the NSH ELF
program is installed.
config COREMARK_PRIORITY
int "CoreMark task priority"
default 100
config COREMARK_STACKSIZE
int "CoreMark task stack size"
default 4096
config COREMARK_SEED_METHOD
int "Coremark Seed Method"
default 2
---help---
Set Coremark Seed Method:
0: SEED_ARG
1: SEED_FUNC
2: SEED_VOLATILE
config COREMARK_MEM_METHOD
int "Coremark Memory Method"
default 1
---help---
Set Coremark Memory Method:
0: MEM_STATIC
1: MEM_MALLOC
2: MEM_STACK
config COREMARK_DEBUG
int "Coremark Core Debug"
default 0
---help---
Enable the Core Debug:
0: Disable
1: Enable
config COREMARK_PRINT_ARGS
bool "Print CoreMark arguments when executing"
default n
---help---
Print the command line arguments passed on to coremark.
config COREMARK_MULTITHREAD_OVERRIDE
bool "Override number of threads"
default n
---help---
Override the default number of threads to be executed.
The default value is the same as the number of CPU cores.
config COREMARK_MULTITHREAD_COUNT
depends on COREMARK_MULTITHREAD_OVERRIDE
int "Number of threads to be executed"
default 1
config COREMARK_ITERATIONS_OVERRIDE
bool "Override number of iterations"
default n
---help---
Override the default number of iterations for the benchmark.
The default value is defined by the application based on the system.
config COREMARK_ITERATIONS_COUNT
depends on COREMARK_ITERATIONS_OVERRIDE
int "Number of iterations"
default 100
endif # BENCHMARK_COREMARK

View file

@ -1,27 +0,0 @@
############################################################################
# apps/benchmarks/coremark/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
ifneq ($(CONFIG_BENCHMARK_COREMARK),)
CONFIGURED_APPS += $(APPDIR)/benchmarks/coremark
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/benchmarks/coremark/coremark
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/benchmarks/coremark/coremark/posix
endif

View file

@ -1,145 +0,0 @@
############################################################################
# apps/benchmarks/coremark/Makefile
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
include $(APPDIR)/Make.defs
# Coremark application
############################################################################
# Flags
############################################################################
COREMARK_URL ?= "https://github.com/eembc/coremark/archive"
COREMARK_VERSION = main
COREMARK_ZIP = $(COREMARK_VERSION).zip
COREMARK_UNPACKNAME = coremark
UNPACK ?= unzip -q -o
VPATH += $(COREMARK_UNPACKNAME)
VPATH += $(COREMARK_UNPACKNAME)$(DELIM)posix
DEPPATH += --dep-path $(COREMARK_UNPACKNAME)
DEPPATH += --dep-path $(COREMARK_UNPACKNAME)$(DELIM)posix
CFLAGS += -Dcrc16=coremark_crc16
CFLAGS += -Wno-strict-prototypes -Wno-undef
ifeq ($(CONFIG_COREMARK_MULTITHREAD_OVERRIDE),y)
COREMARK_NTHREADS = $(CONFIG_COREMARK_MULTITHREAD_COUNT)
else
ifneq ($(CONFIG_SMP_NCPUS),)
COREMARK_NTHREADS = $(CONFIG_SMP_NCPUS)
else
COREMARK_NTHREADS = 1
endif
endif
ifeq ($(CONFIG_COREMARK_PRINT_ARGS),y)
COREMARK_PRINT_ARGS = 1
else
COREMARK_PRINT_ARGS = 0
endif
ifeq ($(CONFIG_COREMARK_MEM_METHOD), 1)
CFLAGS += ${DEFINE_PREFIX}MEM_LOCATION=\"HEAP\"
else ifeq ($(CONFIG_COREMARK_MEM_METHOD), 2)
CFLAGS += ${DEFINE_PREFIX}MEM_LOCATION=\"STACK\"
else
CFLAGS += ${DEFINE_PREFIX}MEM_LOCATION=\"GLOBAL\"
endif
CFLAGS += ${DEFINE_PREFIX}CALLGRIND_RUN=0
CFLAGS += ${DEFINE_PREFIX}COMPILER_REQUIRES_SORT_RETURN=0
CFLAGS += ${DEFINE_PREFIX}CORE_DEBUG=$(CONFIG_COREMARK_DEBUG)
CFLAGS += ${DEFINE_PREFIX}FLAGS_STR=\""$(ARCHOPTIMIZATION)\""
CFLAGS += ${DEFINE_PREFIX}MEM_METHOD=$(CONFIG_COREMARK_MEM_METHOD)
CFLAGS += ${DEFINE_PREFIX}MICA=0
CFLAGS += ${DEFINE_PREFIX}MULTITHREAD=$(COREMARK_NTHREADS)
CFLAGS += ${DEFINE_PREFIX}PERFORMANCE_RUN=1
CFLAGS += ${DEFINE_PREFIX}PRINT_ARGS=$(COREMARK_PRINT_ARGS)
CFLAGS += ${DEFINE_PREFIX}SEED_METHOD=$(CONFIG_COREMARK_SEED_METHOD)
CFLAGS += ${DEFINE_PREFIX}USE_CLOCK=1
CFLAGS += ${DEFINE_PREFIX}USE_PTHREAD
ifeq ($(CONFIG_COREMARK_ITERATIONS_OVERRIDE),y)
CFLAGS += ${DEFINE_PREFIX}ITERATIONS=$(CONFIG_COREMARK_ITERATIONS_COUNT)
else
CFLAGS += ${DEFINE_PREFIX}ITERATIONS=0
endif
CFLAGS += ${DEFINE_PREFIX}crcu8=coremark_crcu8
CFLAGS += ${DEFINE_PREFIX}crcu16=coremark_crcu16
CFLAGS += ${DEFINE_PREFIX}crcu32=coremark_crcu32
CFLAGS += ${DEFINE_PREFIX}crc16=coremark_crc16
CSRCS += core_list_join.c
CSRCS += core_matrix.c
CSRCS += core_state.c
CSRCS += core_util.c
CSRCS += core_portme.c
############################################################################
# Targets
############################################################################
$(COREMARK_ZIP):
@echo "Downloading: $(COREMARK_URL)/$(COREMARK_ZIP)"
$(Q) curl -O -L $(COREMARK_URL)/$(COREMARK_ZIP)
$(COREMARK_UNPACKNAME): $(COREMARK_ZIP)
@echo "Unpacking: $(COREMARK_ZIP) -> $(COREMARK_UNPACKNAME)"
$(Q) $(UNPACK) $(COREMARK_ZIP)
$(Q) mv coremark-$(COREMARK_VERSION) $(COREMARK_UNPACKNAME)
$(Q) patch -p0 < add_init_message.patch # Update init message
$(Q) touch $(COREMARK_UNPACKNAME)
clean::
$(call DELFILE, $(OBJS))
# Download and unpack tarball if no git repo found
ifeq ($(wildcard $(COREMARK_UNPACKNAME)/.git),)
context:: $(COREMARK_UNPACKNAME)
distclean::
$(call DELDIR, $(COREMARK_UNPACKNAME))
$(call DELFILE, $(COREMARK_ZIP))
endif
############################################################################
# Applications Configuration
############################################################################
MODULE = $(CONFIG_BENCHMARK_COREMARK)
PROGNAME += $(CONFIG_COREMARK_PROGNAME)
PRIORITY += $(CONFIG_COREMARK_PRIORITY)
STACKSIZE += $(CONFIG_COREMARK_STACKSIZE)
MAINSRC += core_main.c
# Build with WebAssembly when CONFIG_INTERPRETERS_WAMR is enabled
WASM_BUILD = both
include $(APPDIR)/Application.mk

View file

@ -1,12 +0,0 @@
--- coremark/posix/core_portme.c
+++ coremark/posix/core_portme.c
@@ -208,6 +208,9 @@ ee_u32 default_num_contexts = MULTITHREAD;
void
portable_init(core_portable *p, int *argc, char *argv[])
{
+
+ ee_printf("Running CoreMark...\n");
+
#if PRINT_ARGS
int i;
for (i = 0; i < *argc; i++)

View file

@ -1,55 +0,0 @@
# ##############################################################################
# apps/benchmarks/cyclictest/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
if(CONFIG_BENCHMARK_CYCLICTEST)
# ############################################################################
# Config and Fetch Coremark application
# ############################################################################
set(CYCLICTEST_DIR ${CMAKE_CURRENT_LIST_DIR})
# ############################################################################
# Sources
# ############################################################################
set(CSRCS ${CYCLICTEST_DIR}/cyclictest.c)
# ############################################################################
# Applications Configuration
# ############################################################################
nuttx_add_application(
NAME
cyclictest
PRIORITY
${CONFIG_CYCLICTEST_PRIORITY}
STACKSIZE
${CONFIG_CYCLICTEST_STACKSIZE}
MODULE
${CONFIG_BENCHMARK_CYCLICTEST}
COMPILE_FLAGS
${CFLAGS}
SRCS
${CSRCS}
INCLUDE_DIRECTORIES
${INCDIR})
endif()

View file

@ -1,29 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menuconfig BENCHMARK_CYCLICTEST
bool "Cyclictest"
default n
---help---
Enable the cyclictest application.
if BENCHMARK_CYCLICTEST
config BENCHMARK_CYCLICTEST_PROGNAME
string "Cyclictest App Name"
default "cyclictest"
---help---
This is the name of the program that will be used when the NSH ELF
program is installed.
config BENCHMARK_CYCLICTEST_PRIORITY
int "Cyclictest task priority"
default 100
config BENCHMARK_CYCLICTEST_STACKSIZE
int "Cyclictest task stack size"
default 4096
endif # BENCHMARK_CYCLICTEST

View file

@ -1,39 +0,0 @@
############################################################################
# apps/benchmarks/cyclictest/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################
include $(APPDIR)/Make.defs
# spinlock_bench application
############################################################################
# Applications Configuration
############################################################################
MODULE = $(CONFIG_BENCHMARK_CYCLICTEST)
PROGNAME += $(CONFIG_BENCHMARK_CYCLICTEST_PROGNAME)
PRIORITY += $(CONFIG_BENCHMARK_CYCLICTEST_PRIORITY)
STACKSIZE += $(CONFIG_BENCHMARK_CYCLICTEST_STACKSIZE)
MAINSRC += cyclictest.c
# Build with WebAssembly when CONFIG_INTERPRETERS_WAMR is enabled
include $(APPDIR)/Application.mk

File diff suppressed because it is too large Load diff

View file

@ -1,2 +0,0 @@
/dhrystone
/dhrystone.zip

View file

@ -1,28 +0,0 @@
From b5376f06c41e9460044500b24137928c83e06244 Mon Sep 17 00:00:00 2001
From: chenrun1 <chenrun1@xiaomi.com>
Date: Mon, 12 Jun 2023 23:07:37 +0800
Subject: [PATCH 1/2] dry2.2:Fix 'malloc' type mismatch
'extern char *malloc' is a form from the early days of c that is no longer recommended in modern C implementations. This type of declaration can lead to type mismatch problems
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
---
v2.2/dry.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2.2/dry.c b/v2.2/dry.c
index 602572a..e0fa391 100644
--- dhrystone/v2.2/dry.c
+++ dhrystone/v2.2/dry.c
@@ -500,7 +500,7 @@ char Ch_1_Glob,
int Arr_1_Glob [50];
int Arr_2_Glob [50] [50];
-extern char *malloc ();
+extern void *malloc ();
Enumeration Func_1 ();
/* forward declaration necessary since Enumeration may not simply be int */
--
2.34.1

View file

@ -1,67 +0,0 @@
From ed7f8720aed17febe5d802cda53b38b80d0d5164 Mon Sep 17 00:00:00 2001
From: chenrun1 <chenrun1@xiaomi.com>
Date: Fri, 29 Mar 2024 10:48:37 +0800
Subject: [PATCH 2/2] dhrystone:fix redefine warning
redefine:
dhrystone/v2.2/dry.c:458: warning: "true" redefined
458 | #define true 1
|
In file included from /home/crafcat7/ext2/vela/vela-dev/nuttx/include/nuttx/fs/fs.h:34,
from /home/crafcat7/ext2/vela/vela-dev/nuttx/include/stdio.h:34,
from dhrystone/v2.2/dry.c:453:
/home/crafcat7/ext2/vela/vela-dev/nuttx/include/stdbool.h:77: note: this is the location of the previous definition
77 | # define true (bool)1
|
dhrystone/v2.2/dry.c:459: warning: "false" redefined
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
---
v2.1/dhry.h | 8 ++++++++
v2.2/dry.c | 7 +++++++
2 files changed, 15 insertions(+)
diff --git a/v2.1/dhry.h b/v2.1/dhry.h
index 404adb4..ee848d8 100644
--- dhrystone/v2.1/dhry.h
+++ dhrystone/v2.1/dhry.h
@@ -396,8 +396,16 @@
#define Null 0
/* Value of a Null pointer */
+
+#ifdef true
+#undef true
#define true 1
+#endif
+
+#ifdef false
+#undef false
#define false 0
+#endif
typedef int One_Thirty;
typedef int One_Fifty;
diff --git a/v2.2/dry.c b/v2.2/dry.c
index e0fa391..2994c13 100644
--- dhrystone/v2.2/dry.c
+++ dhrystone/v2.2/dry.c
@@ -455,8 +455,15 @@ struct tms time_info;
#define Null 0
/* Value of a Null pointer */
+#ifdef true
+#undef true
#define true 1
+#endif
+
+#ifdef false
+#undef false
#define false 0
+#endif
typedef int One_Thirty;
typedef int One_Fifty;
--
2.34.1

View file

@ -1,68 +0,0 @@
# ##############################################################################
# apps/benchmarks/dhrystone/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################
if(CONFIG_BENCHMARK_DHRYSTONE)
set(DHRYSTONE_DIR ${CMAKE_CURRENT_LIST_DIR}/dhrystone)
if(NOT EXISTS ${DHRYSTONE_DIR})
FetchContent_Declare(
dhrystone_fetch
URL https://github.com/Keith-S-Thompson/dhrystone/archive/refs/heads/master.zip
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/dhrystone
BINARY_DIR
${CMAKE_BINARY_DIR}/apps/benchmarks/coremark/dhrystone
PATCH_COMMAND
patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
${CMAKE_CURRENT_LIST_DIR}/0001-dry2.2-Fix-malloc-type-mismatch.patch &&
patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
${CMAKE_CURRENT_LIST_DIR}/0002-dhrystone-fix-redefine-warning.patch
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)
FetchContent_GetProperties(dhrystone_fetch)
if(NOT dhrystone_fetch_POPULATED)
FetchContent_Populate(dhrystone_fetch)
endif()
endif()
set(CFLAGS
-DMSC_CLOCK -Wno-maybe-uninitialized -Wno-implicit-int
-Wno-strict-prototypes -Wno-implicit-function-declaration
-Wno-return-type)
set(SRCS dhrystone/v2.2/dry.c dhrystone/v2.1/dhry_2.c)
nuttx_add_application(
NAME
${CONFIG_BENCHMARK_DHRYSTONE_PROGNAME}
PRIORITY
${CONFIG_BENCHMARK_DHRYSTONE_PRIORITY}
STACKSIZE
${CONFIG_BENCHMARK_DHRYSTONE_STACKSIZE}
MODULE
${CONFIG_BENCHMARK_DHRYSTONE}
COMPILE_FLAGS
${CFLAGS}
SRCS
${SRCS})
endif()

Some files were not shown because too many files have changed in this diff Show more