mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-03 13:19:03 +00:00
Compare commits
No commits in common. "master" and "nuttx-12.12.0-RC0" have entirely different histories.
master
...
nuttx-12.1
1660 changed files with 7752 additions and 181897 deletions
|
|
@ -1,16 +1,2 @@
|
|||
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 */
|
||||
|
|
|
|||
|
|
@ -8,9 +8,3 @@ 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
|
||||
|
|
|
|||
3
.github/labeler.yml
vendored
3
.github/labeler.yml
vendored
|
|
@ -17,9 +17,6 @@
|
|||
# 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
|
||||
|
||||
|
|
|
|||
2
.github/workflows/arch.yml
vendored
2
.github/workflows/arch.yml
vendored
|
|
@ -230,7 +230,7 @@ jobs:
|
|||
skip_build=1
|
||||
fi
|
||||
|
||||
# For "Arch / Board: xtensa": Build xtensa-01, xtensa-02, xtensa-03
|
||||
# For "Arch / Board: xtensa": Build xtensa-01, xtensa-02
|
||||
elif [[ "$arch_contains_xtensa" == "1" || "$board_contains_xtensa" == "1" ]]; then
|
||||
if [[ "$board" != *"xtensa-"* ]]; then
|
||||
skip_build=1
|
||||
|
|
|
|||
101
.github/workflows/build.yml
vendored
101
.github/workflows/build.yml
vendored
|
|
@ -85,7 +85,7 @@ jobs:
|
|||
echo "apps_ref=$APPS_REF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Checkout nuttx repo
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: apache/nuttx
|
||||
ref: ${{ steps.gittargets.outputs.os_ref }}
|
||||
|
|
@ -95,7 +95,7 @@ jobs:
|
|||
run: git -C sources/nuttx fetch --tags
|
||||
|
||||
- name: Checkout apps repo
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: apache/nuttx-apps
|
||||
ref: ${{ steps.gittargets.outputs.apps_ref }}
|
||||
|
|
@ -106,7 +106,7 @@ jobs:
|
|||
run: tar zcf sources.tar.gz sources
|
||||
|
||||
- name: Archive Source Bundle
|
||||
uses: actions/upload-artifact@v7.0.1
|
||||
uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: source-bundle
|
||||
path: sources.tar.gz
|
||||
|
|
@ -121,7 +121,7 @@ jobs:
|
|||
[
|
||||
"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-03", "risc-v-03", "sim-03",
|
||||
"arm-04", "risc-v-04",
|
||||
"arm-05", "risc-v-05",
|
||||
"arm-06", "risc-v-06",
|
||||
|
|
@ -135,10 +135,6 @@ jobs:
|
|||
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
|
||||
|
|
@ -147,18 +143,8 @@ jobs:
|
|||
|
||||
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@v6
|
||||
with:
|
||||
name: source-bundle
|
||||
path: .
|
||||
|
|
@ -167,7 +153,7 @@ jobs:
|
|||
run: tar zxf sources.tar.gz
|
||||
|
||||
- name: Docker Login
|
||||
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
|
|
@ -183,45 +169,13 @@ jobs:
|
|||
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"
|
||||
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 /github/workspace/sources/nuttx/tools/ci
|
||||
cd sources/nuttx/tools/ci
|
||||
if [ "X${{matrix.boards}}" = "Xcodechecker" ]; then
|
||||
./cibuild.sh -c -A -N -R --codechecker testlist/${{matrix.boards}}.dat
|
||||
else
|
||||
|
|
@ -229,11 +183,7 @@ jobs:
|
|||
./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
|
||||
- uses: actions/upload-artifact@v5
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: linux-${{matrix.boards}}-builds
|
||||
|
|
@ -248,7 +198,7 @@ jobs:
|
|||
DOCKER_BUILDKIT: 1
|
||||
steps:
|
||||
- name: Download Source Artifact
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v6
|
||||
with:
|
||||
name: source-bundle
|
||||
path: .
|
||||
|
|
@ -257,7 +207,7 @@ jobs:
|
|||
run: tar zxf sources.tar.gz
|
||||
|
||||
- name: Docker Login
|
||||
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
|
|
@ -278,7 +228,7 @@ jobs:
|
|||
cd sources/nuttx
|
||||
./tools/ci/cibuild-oot.sh
|
||||
|
||||
- uses: actions/upload-artifact@v7.0.1
|
||||
- uses: actions/upload-artifact@v5
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: oot-build-artifacts
|
||||
|
|
@ -301,15 +251,13 @@ jobs:
|
|||
runs-on: macos-15-intel
|
||||
needs: macOS-Arch
|
||||
if: ${{ needs.macOS-Arch.outputs.skip_all_builds != '1' }}
|
||||
env:
|
||||
NUTTX_ROMFS_PASSWD_PASSWORD: NuttXSimLogin1!
|
||||
strategy:
|
||||
max-parallel: 2
|
||||
matrix:
|
||||
boards: ${{ fromJSON(needs.macOS-Arch.outputs.selected_builds) }}
|
||||
steps:
|
||||
- name: Download Source Artifact
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v6
|
||||
with:
|
||||
name: source-bundle
|
||||
path: .
|
||||
|
|
@ -319,7 +267,7 @@ jobs:
|
|||
|
||||
- name: Restore Tools Cache
|
||||
id: cache-tools
|
||||
uses: actions/cache@v6
|
||||
uses: actions/cache@v4
|
||||
env:
|
||||
cache-name: ${{ runner.os }}-cache-tools
|
||||
with:
|
||||
|
|
@ -331,18 +279,17 @@ jobs:
|
|||
|
||||
# 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
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- name: Run Builds
|
||||
run: |
|
||||
echo "::add-matcher::sources/nuttx/.github/gcc.json"
|
||||
export NUTTX_ROMFS_PASSWD_PASSWORD=NuttXSimLogin1!
|
||||
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
|
||||
- uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: macos-${{matrix.boards}}-builds
|
||||
path: buildartifacts/
|
||||
|
|
@ -372,7 +319,7 @@ jobs:
|
|||
run:
|
||||
shell: msys2 {0}
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v6
|
||||
- uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: MSYS
|
||||
|
|
@ -405,7 +352,7 @@ jobs:
|
|||
- run: git config --global core.autocrlf false
|
||||
|
||||
- name: Download Source Artifact
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v6
|
||||
with:
|
||||
name: source-bundle
|
||||
path: .
|
||||
|
|
@ -425,7 +372,7 @@ jobs:
|
|||
cd sources/nuttx/tools/ci
|
||||
./cibuild.sh -g -i -A -C -N -R testlist/${{matrix.boards}}.dat
|
||||
|
||||
- uses: actions/upload-artifact@v7.0.1
|
||||
- uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: msys2-${{matrix.boards}}-builds
|
||||
path: buildartifacts/
|
||||
|
|
@ -444,12 +391,12 @@ jobs:
|
|||
msvc:
|
||||
needs: msvc-Arch
|
||||
if: ${{ needs.msvc-Arch.outputs.skip_all_builds != '1' }}
|
||||
runs-on: windows-2022
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v6
|
||||
# Set up Python environment and install kconfiglib
|
||||
- name: Set up Python and install kconfiglib
|
||||
uses: actions/setup-python@v7
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- name: Install kconfiglib
|
||||
|
|
@ -459,7 +406,7 @@ jobs:
|
|||
- run: git config --global core.autocrlf false
|
||||
|
||||
- name: Download Source Artifact
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v6
|
||||
with:
|
||||
name: source-bundle
|
||||
path: .
|
||||
|
|
@ -477,7 +424,7 @@ jobs:
|
|||
cd sources\nuttx\tools\ci
|
||||
.\cibuild.ps1 -n -i -A -C -N testlist\windows.dat
|
||||
|
||||
- uses: actions/upload-artifact@v7.0.1
|
||||
- uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: msvc-builds
|
||||
path: ./sources/buildartifacts/
|
||||
|
|
|
|||
4
.github/workflows/check.yml
vendored
4
.github/workflows/check.yml
vendored
|
|
@ -28,14 +28,14 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout nuttx repo
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: apache/nuttx
|
||||
path: nuttx
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Checkout apps repo
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: apache/nuttx-apps
|
||||
path: apps
|
||||
|
|
|
|||
2
.github/workflows/issue_labeler.yml
vendored
2
.github/workflows/issue_labeler.yml
vendored
|
|
@ -23,7 +23,7 @@ jobs:
|
|||
issues: write
|
||||
steps:
|
||||
- name: Add labels issues automatically based on their body.
|
||||
uses: actions/github-script@v9.0.0
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const body = context.payload.issue.body;
|
||||
|
|
|
|||
143
.github/workflows/labeler.yml
vendored
143
.github/workflows/labeler.yml
vendored
|
|
@ -12,139 +12,34 @@
|
|||
# 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
|
||||
- pull_request_target
|
||||
|
||||
jobs:
|
||||
labeler:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
issues: read
|
||||
pull-requests: write
|
||||
issues: write
|
||||
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
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Assign labels based on paths
|
||||
uses: actions/labeler@main
|
||||
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
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
sync-labels: true
|
||||
|
||||
# Fetch the updated PR filenames. Compute the Size Label and Arch Labels.
|
||||
- name: Compute PR labels
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
- name: Assign labels based on the PR's size
|
||||
uses: codelytv/pr-size-labeler@v1.10.3
|
||||
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/
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
ignore_file_deletions: true
|
||||
xs_label: 'Size: XS'
|
||||
s_label: 'Size: S'
|
||||
m_label: 'Size: M'
|
||||
l_label: 'Size: L'
|
||||
xl_label: 'Size: XL'
|
||||
|
|
|
|||
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
|
|
@ -17,7 +17,7 @@ jobs:
|
|||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: mkdir super-linter.report
|
||||
|
|
|
|||
90
.github/workflows/pr_labeler.yml
vendored
90
.github/workflows/pr_labeler.yml
vendored
|
|
@ -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
|
||||
});
|
||||
|
|
@ -122,7 +122,6 @@ ifneq ($(strip $(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)))) \
|
||||
|
|
@ -134,31 +133,7 @@ ifneq ($(strip $(PROGNAME)),)
|
|||
$(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
|
||||
|
|
@ -173,7 +148,7 @@ ifeq ($(WASM_BUILD),y)
|
|||
DO_REGISTRATION = n
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_MODULE),y)
|
||||
ifeq ($(DYNLIB),y)
|
||||
DO_REGISTRATION = n
|
||||
endif
|
||||
|
||||
|
|
@ -248,7 +223,7 @@ 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}
|
||||
$(Q) ${shell cat $1 | sed -e "s/fn[ ]\+main/fn $(addsuffix _main,$(PROGNAME_$@))/" > $2}
|
||||
$(ECHO_END)
|
||||
endef
|
||||
|
||||
|
|
@ -335,7 +310,7 @@ $(PROGLIST): $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ) $(MAINZIGOBJ) $(MAINDOBJ)
|
|||
ifneq ($(CONFIG_DEBUG_SYMBOLS),)
|
||||
$(Q) mkdir -p $(BINDIR_DEBUG)
|
||||
$(Q) cp $@ $(BINDIR_DEBUG)
|
||||
$(Q) $(MODULESTRIP) $(NX_KEEP) $@
|
||||
$(Q) $(MODULESTRIP) $@
|
||||
endif
|
||||
|
||||
install:: $(PROGLIST)
|
||||
|
|
@ -344,14 +319,14 @@ 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_$@))})
|
||||
$(eval $<_CXXFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(addsuffix _main,$(PROGNAME_$@))})
|
||||
$(eval $<_CXXELFFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(addsuffix _main,$(PROGNAME_$@))})
|
||||
$(if $(and $(CONFIG_MODULES),$(MODCXXFLAGS)), \
|
||||
$(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_$@)))
|
||||
$(eval $<_CFLAGS += ${DEFINE_PREFIX}main=$(addsuffix _main,$(PROGNAME_$@)))
|
||||
$(eval $<_CELFFLAGS += ${DEFINE_PREFIX}main=$(addsuffix _main,$(PROGNAME_$@)))
|
||||
$(if $(and $(CONFIG_MODULES),$(MODCFLAGS)), \
|
||||
$(call ELFCOMPILE, $<, $@), $(call COMPILE, $<, $@))
|
||||
|
||||
|
|
@ -387,11 +362,10 @@ ifeq ($(DO_REGISTRATION),y)
|
|||
|
||||
$(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_$@))
|
||||
$(call REGISTER,$(PROGNAME_$@),$(PRIORITY_$@),$(STACKSIZE_$@),$(if $(BUILD_MODULE),,$(PROGNAME_$@)_main),$(UID_$@),$(GID_$@),$(MODE_$@))
|
||||
else
|
||||
$(call REGISTER,$(PROGNAME_$@),$(PRIORITY_$@),$(STACKSIZE_$@),$(if $(BUILD_MODULE),,$(PROGSYM_$@)_main))
|
||||
$(call REGISTER,$(PROGNAME_$@),$(PRIORITY_$@),$(STACKSIZE_$@),$(if $(BUILD_MODULE),,$(PROGNAME_$@)_main))
|
||||
endif
|
||||
|
||||
register:: $(REGLIST)
|
||||
|
|
@ -419,7 +393,6 @@ clean::
|
|||
$(call CLEANAROBJS)
|
||||
$(call CLEAN)
|
||||
distclean:: clean
|
||||
$(call DELFILE, .kconfig)
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
|
|
|
|||
|
|
@ -55,12 +55,12 @@ 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(modbus)
|
||||
add_subdirectory(netutils)
|
||||
add_subdirectory(nshlib)
|
||||
add_subdirectory(platform)
|
||||
|
|
|
|||
28
LICENSE
28
LICENSE
|
|
@ -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
|
||||
|
|
@ -2248,29 +2248,3 @@ 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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -36,20 +36,11 @@ if(CONFIG_AUDIOUTILS_LAME)
|
|||
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}")
|
||||
COMMAND "svn" "checkout" "https://svn.code.sf.net/p/lame/svn/trunk/lame"
|
||||
"lame" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
# Set source path
|
||||
|
|
@ -84,6 +75,7 @@ if(CONFIG_AUDIOUTILS_LAME)
|
|||
"${SRC_PATH}/libmp3lame/newmdct.c"
|
||||
"${SRC_PATH}/libmp3lame/psymodel.c"
|
||||
"${SRC_PATH}/libmp3lame/quantize.c"
|
||||
"${SRC_PATH}/libmp3lame/vector/xmm_quantize_sub.c"
|
||||
"${SRC_PATH}/libmp3lame/quantize_pvt.c"
|
||||
"${SRC_PATH}/libmp3lame/set_get.c"
|
||||
"${SRC_PATH}/libmp3lame/vbrquantize.c"
|
||||
|
|
@ -95,21 +87,6 @@ if(CONFIG_AUDIOUTILS_LAME)
|
|||
"${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
|
||||
|
|
|
|||
|
|
@ -20,19 +20,10 @@
|
|||
#
|
||||
############################################################################
|
||||
|
||||
# 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
|
||||
$(Q) svn checkout https://svn.code.sf.net/p/lame/svn/trunk/lame lame
|
||||
|
||||
ifeq ($(wildcard lame/configure),)
|
||||
context:: lame-svn
|
||||
|
|
@ -81,6 +72,7 @@ CSRCS += $(SRC_PATH)/libmp3lame/bitstream.c \
|
|||
$(SRC_PATH)/libmp3lame/newmdct.c \
|
||||
$(SRC_PATH)/libmp3lame/psymodel.c \
|
||||
$(SRC_PATH)/libmp3lame/quantize.c \
|
||||
$(SRC_PATH)/libmp3lame/vector/xmm_quantize_sub.c \
|
||||
$(SRC_PATH)/libmp3lame/quantize_pvt.c \
|
||||
$(SRC_PATH)/libmp3lame/set_get.c \
|
||||
$(SRC_PATH)/libmp3lame/vbrquantize.c \
|
||||
|
|
@ -92,23 +84,6 @@ CSRCS += $(SRC_PATH)/libmp3lame/bitstream.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:
|
||||
|
|
@ -127,6 +102,6 @@ ifneq ($(PREFIX),)
|
|||
endif
|
||||
|
||||
distclean::
|
||||
$(Q)if [ -d $(DST_PATH) ]; then cd $(DST_PATH) && $(MAKE) distclean; fi
|
||||
$(Q)cd $(DST_PATH) && make distclean
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
|
|
|
|||
|
|
@ -169,33 +169,15 @@ static int calc_samples(int fs, int tempo, int num, int 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;
|
||||
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)
|
||||
|
|
|
|||
1
audioutils/morsey/.gitignore
vendored
1
audioutils/morsey/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
|||
morsey
|
||||
|
|
@ -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.
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
1
audioutils/rtttl-c/.gitignore
vendored
1
audioutils/rtttl-c/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
|||
/rtttl-c
|
||||
|
|
@ -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);
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -443,8 +443,8 @@ static inline void tsnorm(struct timespec *ts)
|
|||
static inline int64_t timediff_us(struct timespec t1, struct timespec t2)
|
||||
{
|
||||
int64_t ret;
|
||||
ret = 1000000 * (t1.tv_sec - t2.tv_sec);
|
||||
ret += (t1.tv_nsec - t2.tv_nsec) / 1000;
|
||||
ret = 1000000 * (int64_t) ((int) t1.tv_sec - (int) t2.tv_sec);
|
||||
ret += (int64_t) ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -458,11 +458,11 @@ static inline int64_t timediff_us_timer(struct timer_status_s after,
|
|||
t2 = after.timeleft;
|
||||
if (t2 < t1)
|
||||
{
|
||||
ret = t1 - t2;
|
||||
ret = (int64_t) (t1 - t2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = after.timeout - (t2 - t1);
|
||||
ret = (int64_t) (after.timeout - (t2 - t1));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -102,10 +102,10 @@ int main(int argc, FAR char *argv[])
|
|||
/* Report the device structure */
|
||||
|
||||
printf("FLASH device parameters:\n");
|
||||
printf(" Sector size: %10d\n", info.sectorsize);
|
||||
printf(" Sector count: %10d\n", info.numsectors);
|
||||
printf(" Erase block size: %10" PRIu32 "\n", geo.erasesize);
|
||||
printf(" Total size: %10d\n", info.sectorsize * info.numsectors);
|
||||
printf(" Sector size: %10d\n", info.sectorsize);
|
||||
printf(" Sector count: %10d\n", info.numsectors);
|
||||
printf(" Erase block: %10" PRIx32 "\n", geo.erasesize);
|
||||
printf(" Total size: %10d\n", info.sectorsize * info.numsectors);
|
||||
|
||||
if (info.sectorsize != geo.erasesize)
|
||||
{
|
||||
|
|
@ -124,7 +124,7 @@ int main(int argc, FAR char *argv[])
|
|||
goto errout_with_driver;
|
||||
}
|
||||
|
||||
/* Fill the buffer with known data */
|
||||
/* Fill the buffer with known data and print it in hex format */
|
||||
|
||||
for (int i = 0; i < info.sectorsize; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
#include <sys/poll.h>
|
||||
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
|
|
@ -130,7 +129,7 @@ static size_t performance_gettime(FAR struct performance_time_s *result)
|
|||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Pthread switch performance
|
||||
* Pthread swtich performance
|
||||
****************************************************************************/
|
||||
|
||||
static FAR void *pthread_switch_task(FAR void *arg)
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
# ##############################################################################
|
||||
# apps/benchmarks/ramspeed/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_RAMSPEED)
|
||||
nuttx_add_application(
|
||||
NAME
|
||||
${CONFIG_BENCHMARK_RAMSPEED_PROGNAME}
|
||||
SRCS
|
||||
ramspeed_main.c
|
||||
STACKSIZE
|
||||
${CONFIG_BENCHMARK_RAMSPEED_STACKSIZE}
|
||||
PRIORITY
|
||||
${CONFIG_BENCHMARK_RAMSPEED_PRIORITY})
|
||||
endif()
|
||||
|
|
@ -130,8 +130,8 @@ static uint64_t get_time_delta_us(const struct timespec *start,
|
|||
const struct timespec *end)
|
||||
{
|
||||
uint64_t elapsed;
|
||||
elapsed = (end->tv_sec * NSEC_PER_SEC) + end->tv_nsec;
|
||||
elapsed -= (start->tv_sec * NSEC_PER_SEC) + start->tv_nsec;
|
||||
elapsed = (((uint64_t)end->tv_sec * NSEC_PER_SEC) + end->tv_nsec);
|
||||
elapsed -= (((uint64_t)start->tv_sec * NSEC_PER_SEC) + start->tv_nsec);
|
||||
return elapsed / 1000.;
|
||||
}
|
||||
|
||||
|
|
@ -451,7 +451,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
cfg.run_duration *= 1000;
|
||||
bench_fd = open(BENCHMARK_FILE,
|
||||
O_CREAT | (verify ? O_RDWR : O_WRONLY) | O_TRUNC, 0666);
|
||||
O_CREAT | (verify ? O_RDWR : O_WRONLY) | O_TRUNC);
|
||||
|
||||
if (bench_fd < 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
From 6d0be04a4b4208447e75c369e9811d089f466739 Mon Sep 17 00:00:00 2001
|
||||
From 71f51cd5ca4f492a464fb12d5bce91e5fbba300a Mon Sep 17 00:00:00 2001
|
||||
From: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
|
||||
Date: Thu, 3 Apr 2025 11:59:02 +0800
|
||||
Date: Tue, 11 Jun 2024 16:01:23 +0800
|
||||
Subject: [PATCH] tacle-bench: add makefile and all-in-one main file
|
||||
|
||||
The original taclebench is used for WCET analysis. This commit allows most taclebench test cases (except parallel test cases) to be compiled and executed.
|
||||
|
||||
Change-Id: I707b8ac58d3ddc4b7974c5bedecac1a7b5c887f9
|
||||
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
|
||||
---
|
||||
Makefile | 12 +
|
||||
|
|
@ -66,14 +65,14 @@ Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
|
|||
bench/test/cover/cover.c | 3 +
|
||||
bench/test/duff/duff.c | 3 +
|
||||
bench/test/test3/test3.c | 3 +
|
||||
taclebench.c | 366 ++++++++++++++++++
|
||||
59 files changed, 549 insertions(+)
|
||||
taclebench.c | 349 ++++++++++++++++++
|
||||
59 files changed, 532 insertions(+)
|
||||
create mode 100644 Makefile
|
||||
create mode 100644 taclebench.c
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
new file mode 100644
|
||||
index 0000000..75ca0a1
|
||||
index 0000000..2385c61
|
||||
--- /dev/null
|
||||
+++ b/Makefile
|
||||
@@ -0,0 +1,12 @@
|
||||
|
|
@ -84,7 +83,7 @@ index 0000000..75ca0a1
|
|||
+TEST_SRCS := $(shell find bench/test -name "*.c")
|
||||
+
|
||||
+all:
|
||||
+ cc -DALL_IN_ONE ${APP_SRCS} ${KERNEL_SRCS} ${SEQUENTIAL_SRCS} ${TEST_SRCS} bench/kernel/cosf/wcclibm.c taclebench.c -static -o taclebench -O3
|
||||
+ cc -DALL_IN_ONE ${APP_SRCS} ${KERNEL_SRCS} ${SEQUENTIAL_SRCS} ${TEST_SRCS} bench/kernel/cosf/wcclibm.c taclebench.c -static -o taclebench
|
||||
+
|
||||
+clean:
|
||||
+ rm -f taclebench
|
||||
|
|
@ -889,12 +888,11 @@ index 0235738..6eaf8c2 100755
|
|||
|
||||
diff --git a/taclebench.c b/taclebench.c
|
||||
new file mode 100644
|
||||
index 0000000..aaff1bb
|
||||
index 0000000..1231b87
|
||||
--- /dev/null
|
||||
+++ b/taclebench.c
|
||||
@@ -0,0 +1,366 @@
|
||||
@@ -0,0 +1,349 @@
|
||||
+#include <stdio.h>
|
||||
+#include <time.h>
|
||||
+
|
||||
+int main_epic(void);
|
||||
+int main_mpeg2(void);
|
||||
|
|
@ -956,10 +954,6 @@ index 0000000..aaff1bb
|
|||
+
|
||||
+int main(void)
|
||||
+{
|
||||
+ struct timespec start_ts;
|
||||
+ struct timespec end_ts;
|
||||
+ clock_gettime(CLOCK_MONOTONIC, &start_ts);
|
||||
+
|
||||
+ if (main_epic() != 0)
|
||||
+ {
|
||||
+ printf("main_epic error\n");
|
||||
|
|
@ -1245,18 +1239,6 @@ index 0000000..aaff1bb
|
|||
+ printf("main_bitonic error\n");
|
||||
+ }
|
||||
+
|
||||
+ clock_gettime(CLOCK_MONOTONIC, &end_ts);
|
||||
+ long sec_diff = end_ts.tv_sec - start_ts.tv_sec;
|
||||
+ long nsec_diff = end_ts.tv_nsec - start_ts.tv_nsec;
|
||||
+
|
||||
+ if (nsec_diff < 0)
|
||||
+ {
|
||||
+ sec_diff -= 1;
|
||||
+ nsec_diff += 1000000000;
|
||||
+ }
|
||||
+
|
||||
+ printf("%ld.%09ld seconds\n", sec_diff, nsec_diff);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
--
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
# ##############################################################################
|
||||
# apps/benchmarks/whetstone/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_WHETSTONE)
|
||||
nuttx_add_application(
|
||||
NAME
|
||||
${CONFIG_BENCHMARK_WHETSTONE_PROGNAME}
|
||||
SRCS
|
||||
whetstone.c
|
||||
STACKSIZE
|
||||
${CONFIG_BENCHMARK_WHETSTONE_STACKSIZE}
|
||||
PRIORITY
|
||||
${CONFIG_BENCHMARK_WHETSTONE_PRIORITY})
|
||||
endif()
|
||||
|
|
@ -1,34 +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_WHETSTONE
|
||||
tristate "Double Precision Benchmark"
|
||||
default n
|
||||
depends on ALLOW_CUSTOM_PERMISSIVE_COMPONENTS
|
||||
---help---
|
||||
Enable a Whetstone test.
|
||||
|
||||
This benchmark is based on the C converted version from
|
||||
https://www.netlib.org/benchmark/whetstone.c which has a
|
||||
custom permissive license requiring attribution.
|
||||
|
||||
if BENCHMARK_WHETSTONE
|
||||
|
||||
config BENCHMARK_WHETSTONE_PROGNAME
|
||||
string "Program name"
|
||||
default "whetstone"
|
||||
---help---
|
||||
This is the name of the program that will be used when the NSH ELF
|
||||
program is installed.
|
||||
|
||||
config BENCHMARK_WHETSTONE_PRIORITY
|
||||
int "Whetstone test task priority"
|
||||
default 100
|
||||
|
||||
config BENCHMARK_WHETSTONE_STACKSIZE
|
||||
int "Whetstone test stack size"
|
||||
default DEFAULT_TASK_STACKSIZE
|
||||
|
||||
endif
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
############################################################################
|
||||
# apps/benchmarks/whetstone/Make.defs
|
||||
#
|
||||
# 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_WHETSTONE),)
|
||||
CONFIGURED_APPS += $(APPDIR)/benchmarks/whetstone
|
||||
endif
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
############################################################################
|
||||
# apps/benchmarks/whetstone/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
|
||||
|
||||
# WHETSTONE speed test
|
||||
|
||||
PROGNAME = $(CONFIG_BENCHMARK_WHETSTONE_PROGNAME)
|
||||
PRIORITY = $(CONFIG_BENCHMARK_WHETSTONE_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_BENCHMARK_WHETSTONE_STACKSIZE)
|
||||
MODULE = $(CONFIG_BENCHMARK_WHETSTONE)
|
||||
|
||||
MAINSRC = whetstone.c
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
|
|
@ -1,520 +0,0 @@
|
|||
/****************************************************************************
|
||||
* apps/benchmarks/whetstone/whetstone.c
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-Painter-Engineering-Whetstone
|
||||
*
|
||||
* Converted Whetstone Double Precision Benchmark
|
||||
* Version 1.2 22 March 1998
|
||||
*
|
||||
* (c) Copyright 1998 Painter Engineering, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is granted to use, duplicate, and
|
||||
* publish this text and program as long as it
|
||||
* includes this entire comment block and limited
|
||||
* rights reference.
|
||||
*
|
||||
* Converted by Rich Painter, Painter Engineering, Inc. based on the
|
||||
* www.netlib.org benchmark/whetstoned version obtained 16 March 1998.
|
||||
*
|
||||
* A novel approach was used here to keep the look and feel of the
|
||||
* FORTRAN version. Altering the FORTRAN-based array indices,
|
||||
* starting at element 1, to start at element 0 for C, would require
|
||||
* numerous changes, including decrementing the variable indices by 1.
|
||||
* Instead, the array e1[] was declared 1 element larger in C. This
|
||||
* allows the FORTRAN index range to function without any literal or
|
||||
* variable indices changes. The array element e1[0] is simply never
|
||||
* used and does not alter the benchmark results.
|
||||
*
|
||||
* The major FORTRAN comment blocks were retained to minimize
|
||||
* differences between versions. Modules N5 and N12, like in the
|
||||
* FORTRAN version, have been eliminated here.
|
||||
*
|
||||
* An optional command-line argument has been provided [-c] to
|
||||
* offer continuous repetition of the entire benchmark.
|
||||
* An optional argument for setting an alternate loop count is also
|
||||
* provided. Define PRINTOUT to cause the pout() function to print
|
||||
* outputs at various stages. Final timing measurements should be
|
||||
* made with the PRINTOUT undefined.
|
||||
*
|
||||
* Questions and comments may be directed to the author at
|
||||
* r.painter@ieee.org
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Benchmark #2 -- Double Precision Whetstone (A001)
|
||||
*
|
||||
* o This is a REAL*8 version of
|
||||
* the Whetstone benchmark program.
|
||||
*
|
||||
* o DO-loop semantics are ANSI-66 compatible.
|
||||
*
|
||||
* o Final measurements are to be made with all
|
||||
* WRITE statements and FORMAT sttements removed.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/* standard C library headers required */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
/* the following is optional depending on the timing function used */
|
||||
|
||||
#include <time.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* map the FORTRAN math functions, etc. to the C versions */
|
||||
|
||||
#define DSIN sin
|
||||
#define DCOS cos
|
||||
#define DATAN atan
|
||||
#define DLOG log
|
||||
#define DEXP exp
|
||||
#define DSQRT sqrt
|
||||
#define IF if
|
||||
#define USAGE "usage: whetdc [-c] [loops]\n"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
void pout(long n, long j, long k, double x1,
|
||||
double x2, double x3, double x4);
|
||||
void pa(double e[]);
|
||||
void p0(void);
|
||||
void p3(double x, double y, FAR double *z);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* COMMON t,t1,t2,e1(4),j,k,l */
|
||||
|
||||
double t;
|
||||
double t1;
|
||||
double t2;
|
||||
double e1[5];
|
||||
int j;
|
||||
int k;
|
||||
int l;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, FAR char *argv[])
|
||||
{
|
||||
/* used in the FORTRAN version */
|
||||
|
||||
long loop;
|
||||
long i;
|
||||
long n1;
|
||||
long n2;
|
||||
long n3;
|
||||
long n4;
|
||||
long n6;
|
||||
long n7;
|
||||
long n8;
|
||||
long n9;
|
||||
long n10;
|
||||
long n11;
|
||||
double x1;
|
||||
double x2;
|
||||
double x3;
|
||||
double x4;
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
int ii;
|
||||
int jj;
|
||||
|
||||
/* added for this version */
|
||||
|
||||
long loopstart;
|
||||
long startmsec;
|
||||
long finimsec;
|
||||
float KIPS;
|
||||
int continuous;
|
||||
struct timespec ts;
|
||||
|
||||
loopstart = 1000; /* see the note about loop below */
|
||||
continuous = 0;
|
||||
|
||||
ii = 1; /* start at the first arg (temp use of ii here) */
|
||||
while (ii < argc)
|
||||
{
|
||||
if (strncmp(argv[ii], "-c", 2) == 0 || argv[ii][0] == 'c')
|
||||
{
|
||||
continuous = 1;
|
||||
}
|
||||
else if (atol(argv[ii]) > 0)
|
||||
{
|
||||
loopstart = atol(argv[ii]);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, USAGE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ii++;
|
||||
}
|
||||
|
||||
LCONT:
|
||||
|
||||
/* Start benchmark timing at this point. */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
startmsec = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
|
||||
|
||||
/* The actual benchmark starts here. */
|
||||
|
||||
t = .499975;
|
||||
t1 = 0.50025;
|
||||
t2 = 2.0;
|
||||
|
||||
/* With loopcount loop=10, one million Whetstone instructions
|
||||
* will be executed in EACH MAJOR loop..A MAJOR loop IS EXECUTED
|
||||
* 'ii' TIMES TO INCREASE WALL-CLOCK TIMING ACCURACY.
|
||||
*
|
||||
* loop = 1000;
|
||||
*/
|
||||
|
||||
loop = loopstart;
|
||||
ii = 1;
|
||||
|
||||
jj = 1;
|
||||
|
||||
IILOOP:
|
||||
n1 = 0;
|
||||
n2 = 12 * loop;
|
||||
n3 = 14 * loop;
|
||||
n4 = 345 * loop;
|
||||
n6 = 210 * loop;
|
||||
n7 = 32 * loop;
|
||||
n8 = 899 * loop;
|
||||
n9 = 616 * loop;
|
||||
n10 = 0;
|
||||
n11 = 93 * loop;
|
||||
|
||||
/* Module 1: Simple identifiers */
|
||||
|
||||
x1 = 1.0;
|
||||
x2 = -1.0;
|
||||
x3 = -1.0;
|
||||
x4 = -1.0;
|
||||
|
||||
for (i = 1; i <= n1; i++)
|
||||
{
|
||||
x1 = (x1 + x2 + x3 - x4) * t;
|
||||
x2 = (x1 + x2 - x3 + x4) * t;
|
||||
x3 = (x1 - x2 + x3 + x4) * t;
|
||||
x4 = (-x1 + x2 + x3 + x4) * t;
|
||||
}
|
||||
|
||||
#ifdef PRINTOUT
|
||||
IF (jj == ii)
|
||||
{
|
||||
pout(n1, n1, n1, x1, x2, x3, x4);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Module 2: Array elements */
|
||||
|
||||
e1[1] = 1.0;
|
||||
e1[2] = -1.0;
|
||||
e1[3] = -1.0;
|
||||
e1[4] = -1.0;
|
||||
|
||||
for (i = 1; i <= n2; i++)
|
||||
{
|
||||
e1[1] = (e1[1] + e1[2] + e1[3] - e1[4]) * t;
|
||||
e1[2] = (e1[1] + e1[2] - e1[3] + e1[4]) * t;
|
||||
e1[3] = (e1[1] - e1[2] + e1[3] + e1[4]) * t;
|
||||
e1[4] = (-e1[1] + e1[2] + e1[3] + e1[4]) * t;
|
||||
}
|
||||
|
||||
#ifdef PRINTOUT
|
||||
IF (jj == ii)
|
||||
{
|
||||
pout(n2, n3, n2, e1[1], e1[2], e1[3], e1[4]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Module 3: Array as parameter */
|
||||
|
||||
for (i = 1; i <= n3; i++)
|
||||
{
|
||||
pa(e1);
|
||||
}
|
||||
|
||||
#ifdef PRINTOUT
|
||||
IF (jj == ii)
|
||||
{
|
||||
pout(n3, n2, n2, e1[1], e1[2], e1[3], e1[4]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Module 4: Conditional jumps */
|
||||
|
||||
j = 1;
|
||||
for (i = 1; i <= n4; i++)
|
||||
{
|
||||
if (j == 1)
|
||||
{
|
||||
j = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
j = 3;
|
||||
}
|
||||
|
||||
if (j > 2)
|
||||
{
|
||||
j = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
j = 1;
|
||||
}
|
||||
|
||||
if (j < 1)
|
||||
{
|
||||
j = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PRINTOUT
|
||||
IF (jj == ii)
|
||||
{
|
||||
pout(n4, j, j, x1, x2, x3, x4);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Module 5: Omitted
|
||||
* Module 6: Integer arithmetic
|
||||
*/
|
||||
|
||||
j = 1;
|
||||
k = 2;
|
||||
l = 3;
|
||||
|
||||
for (i = 1; i <= n6; i++)
|
||||
{
|
||||
j = j * (k - j) * (l - k);
|
||||
k = l * k - (l - j) * k;
|
||||
l = (l - k) * (k + j);
|
||||
e1[l - 1] = j + k + l;
|
||||
e1[k - 1] = j * k * l;
|
||||
}
|
||||
|
||||
#ifdef PRINTOUT
|
||||
IF (jj == ii)
|
||||
{
|
||||
pout(n6, j, k, e1[1], e1[2], e1[3], e1[4]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Module 7: Trigonometric functions */
|
||||
|
||||
x = 0.5;
|
||||
y = 0.5;
|
||||
|
||||
for (i = 1; i <= n7; i++)
|
||||
{
|
||||
x = t * DATAN(t2 * DSIN(x) * DCOS(x) /
|
||||
(DCOS(x + y) + DCOS(x - y) - 1.0));
|
||||
y = t * DATAN(t2 * DSIN(y) * DCOS(y) /
|
||||
(DCOS(x + y) + DCOS(x - y) - 1.0));
|
||||
}
|
||||
|
||||
#ifdef PRINTOUT
|
||||
IF (jj == ii)
|
||||
{
|
||||
pout(n7, j, k, x, x, y, y);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Module 8: Procedure calls */
|
||||
|
||||
x = 1.0;
|
||||
y = 1.0;
|
||||
z = 1.0;
|
||||
|
||||
for (i = 1; i <= n8; i++)
|
||||
{
|
||||
p3(x, y, &z);
|
||||
}
|
||||
|
||||
#ifdef PRINTOUT
|
||||
IF (jj == ii)
|
||||
{
|
||||
pout(n8, j, k, x, y, z, z);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Module 9: Array references */
|
||||
|
||||
j = 1;
|
||||
k = 2;
|
||||
l = 3;
|
||||
e1[1] = 1.0;
|
||||
e1[2] = 2.0;
|
||||
e1[3] = 3.0;
|
||||
|
||||
for (i = 1; i <= n9; i++)
|
||||
{
|
||||
p0();
|
||||
}
|
||||
|
||||
#ifdef PRINTOUT
|
||||
IF (jj == ii)
|
||||
{
|
||||
pout(n9, j, k, e1[1], e1[2], e1[3], e1[4]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Module 10: Integer arithmetic */
|
||||
|
||||
j = 2;
|
||||
k = 3;
|
||||
|
||||
for (i = 1; i <= n10; i++)
|
||||
{
|
||||
j = j + k;
|
||||
k = j + k;
|
||||
j = k - j;
|
||||
k = k - j - j;
|
||||
}
|
||||
|
||||
#ifdef PRINTOUT
|
||||
IF (jj == ii)
|
||||
{
|
||||
pout(n10, j, k, x1, x2, x3, x4);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Module 11: Standard functions */
|
||||
|
||||
x = 0.75;
|
||||
|
||||
for (i = 1; i <= n11; i++)
|
||||
x = DSQRT(DEXP(DLOG(x) / t1));
|
||||
|
||||
#ifdef PRINTOUT
|
||||
IF (jj == ii)
|
||||
{
|
||||
pout(n11, j, k, x, x, x, x);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* THIS IS THE END OF THE MAJOR loop. */
|
||||
|
||||
if (++jj <= ii)
|
||||
{
|
||||
goto IILOOP;
|
||||
}
|
||||
|
||||
/* Stop benchmark timing at this point. */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
finimsec = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
|
||||
|
||||
/* Performance in Whetstone KIP's per second is given by
|
||||
*
|
||||
* (100*loop*ii)/TIME
|
||||
*
|
||||
* where TIME is in seconds.
|
||||
*/
|
||||
|
||||
printf("\n");
|
||||
if (finimsec - startmsec <= 0)
|
||||
{
|
||||
printf("Insufficient duration- Increase the loop count\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Loops: %ld, Iterations: %d, Duration: %ld millisecond.\n",
|
||||
loop, ii, finimsec - startmsec);
|
||||
|
||||
KIPS = (100.0 * loop * ii) / ((float)(finimsec - startmsec) * 1000);
|
||||
if (KIPS >= 1000.0)
|
||||
{
|
||||
printf("C Converted Double Precision Whetstones: %.1f MIPS\n",
|
||||
KIPS / 1000.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("C Converted Double Precision Whetstones: %.1f KIPS\n", KIPS);
|
||||
}
|
||||
|
||||
if (continuous)
|
||||
{
|
||||
goto LCONT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
pa(double e[])
|
||||
{
|
||||
j = 0;
|
||||
|
||||
L10:
|
||||
e[1] = (e[1] + e[2] + e[3] - e[4]) * t;
|
||||
e[2] = (e[1] + e[2] - e[3] + e[4]) * t;
|
||||
e[3] = (e[1] - e[2] + e[3] + e[4]) * t;
|
||||
e[4] = (-e[1] + e[2] + e[3] + e[4]) / t2;
|
||||
j += 1;
|
||||
|
||||
if (j < 6)
|
||||
{
|
||||
goto L10;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
p0(void)
|
||||
{
|
||||
e1[j] = e1[k];
|
||||
e1[k] = e1[l];
|
||||
e1[l] = e1[j];
|
||||
}
|
||||
|
||||
void p3(double x, double y, FAR double *z)
|
||||
{
|
||||
double x1;
|
||||
double y1;
|
||||
|
||||
x1 = x;
|
||||
y1 = y;
|
||||
x1 = t * (x1 + y1);
|
||||
y1 = t * (x1 + y1);
|
||||
*z = (x1 + y1) / t2;
|
||||
}
|
||||
|
||||
#ifdef PRINTOUT
|
||||
void
|
||||
pout(long n, long j, long k, double x1, double x2, double x3, double x4)
|
||||
{
|
||||
printf("%7ld %7ld %7ld %12.4e %12.4e %12.4e %12.4e\n",
|
||||
n, j, k, x1, x2, x3, x4);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -45,9 +45,6 @@ if(CONFIG_BOOT_MCUBOOT)
|
|||
|
||||
set(SRCS
|
||||
mcuboot/boot/bootutil/src/boot_record.c
|
||||
mcuboot/boot/bootutil/src/bootutil_area.c
|
||||
mcuboot/boot/bootutil/src/bootutil_img_hash.c
|
||||
mcuboot/boot/bootutil/src/bootutil_loader.c
|
||||
mcuboot/boot/bootutil/src/bootutil_misc.c
|
||||
mcuboot/boot/bootutil/src/bootutil_public.c
|
||||
mcuboot/boot/bootutil/src/caps.c
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ config MCUBOOT_REPOSITORY
|
|||
|
||||
config MCUBOOT_VERSION
|
||||
string "MCUboot version"
|
||||
default "e36d3c8d6ca5e0ed1f510f2a7d110f405a7c396b"
|
||||
default "fefc398cc13ebbc527e297fe9df78cd98a359d75"
|
||||
---help---
|
||||
Defines MCUboot version to be downloaded. Either release tag
|
||||
or commit hash should be specified. Using newer MCUboot version
|
||||
may cause compatibility issues.
|
||||
may cause compatability issues.
|
||||
|
||||
config MCUBOOT_ENABLE_LOGGING
|
||||
bool "Enable MCUboot logging"
|
||||
|
|
|
|||
|
|
@ -44,9 +44,6 @@ endif
|
|||
CFLAGS += -Wno-undef -Wno-unused-but-set-variable
|
||||
|
||||
CSRCS := $(MCUBOOT_UNPACK)/boot/bootutil/src/boot_record.c \
|
||||
$(MCUBOOT_UNPACK)/boot/bootutil/src/bootutil_area.c \
|
||||
$(MCUBOOT_UNPACK)/boot/bootutil/src/bootutil_img_hash.c \
|
||||
$(MCUBOOT_UNPACK)/boot/bootutil/src/bootutil_loader.c \
|
||||
$(MCUBOOT_UNPACK)/boot/bootutil/src/bootutil_misc.c \
|
||||
$(MCUBOOT_UNPACK)/boot/bootutil/src/bootutil_public.c \
|
||||
$(MCUBOOT_UNPACK)/boot/bootutil/src/caps.c \
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
* Name: miniboot_main
|
||||
*
|
||||
* Description:
|
||||
* Minimal bootloader entry point.
|
||||
* Minimal bootlaoder entry point.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
@ -49,6 +49,10 @@ int main(int argc, FAR char *argv[])
|
|||
|
||||
syslog(LOG_INFO, "*** miniboot ***\n");
|
||||
|
||||
/* Perform architecture-specific initialization (if configured) */
|
||||
|
||||
boardctl(BOARDIOC_INIT, 0);
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_FINALINIT
|
||||
/* Perform architecture-specific final-initialization (if configured) */
|
||||
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ enum progress_msg_e
|
|||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NXBOOT_PROGRESS
|
||||
void nxboot_progress(int type, ...);
|
||||
void nxboot_progress(enum progress_type_e type, ...);
|
||||
#else
|
||||
#define nxboot_progress(type, ...) do {} while (0)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -417,7 +417,6 @@ static int perform_update(struct nxboot_state *state, bool check_only)
|
|||
syslog(LOG_INFO, "Creating recovery image.\n");
|
||||
nxboot_progress(nxboot_progress_start, recovery_create);
|
||||
copy_partition(primary, recovery, state, false);
|
||||
flash_partition_flush(recovery);
|
||||
nxboot_progress(nxboot_progress_end);
|
||||
nxboot_progress(nxboot_progress_start, validate_recovery);
|
||||
successful = validate_image(recovery);
|
||||
|
|
@ -445,8 +444,6 @@ static int perform_update(struct nxboot_state *state, bool check_only)
|
|||
nxboot_progress(nxboot_progress_start, update_from_update);
|
||||
if (copy_partition(update, primary, state, true) >= 0)
|
||||
{
|
||||
flash_partition_flush(primary);
|
||||
|
||||
/* Erase the first sector of update partition. This marks the
|
||||
* partition as updated so we don't end up in an update loop.
|
||||
* The sector is written back again during the image
|
||||
|
|
@ -887,6 +884,7 @@ int nxboot_perform_update(bool check_only)
|
|||
int ret;
|
||||
int primary;
|
||||
struct nxboot_state state;
|
||||
struct nxboot_img_header header;
|
||||
|
||||
ret = nxboot_get_state(&state);
|
||||
if (ret < 0)
|
||||
|
|
@ -910,9 +908,9 @@ int nxboot_perform_update(bool check_only)
|
|||
}
|
||||
}
|
||||
|
||||
/* Check whether there is a valid image in the primary slot. Validates
|
||||
* both the header and the full image CRC to ensure integrity before
|
||||
* booting.
|
||||
/* Check whether there is a valid image in the primary slot. This just
|
||||
* checks whether the header is valid, but does not calculate the CRC
|
||||
* of the image as this would prolong the boot process.
|
||||
*/
|
||||
|
||||
primary = flash_partition_open(CONFIG_NXBOOT_PRIMARY_SLOT_PATH);
|
||||
|
|
@ -921,7 +919,8 @@ int nxboot_perform_update(bool check_only)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
if (!validate_image(primary))
|
||||
get_image_header(primary, &header);
|
||||
if (!validate_image_header(&header))
|
||||
{
|
||||
ret = ERROR;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <fcntl.h>
|
||||
|
|
@ -76,26 +75,6 @@ int flash_partition_open(const char *path)
|
|||
return fd;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: flash_partition_flush
|
||||
*
|
||||
* Description:
|
||||
* Flushes any buffered writes to the underlying storage. This ensures
|
||||
* data is physically committed to flash before the caller proceeds.
|
||||
*
|
||||
* Input parameters:
|
||||
* fd: Valid file descriptor.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success, -1 on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int flash_partition_flush(int fd)
|
||||
{
|
||||
return fsync(fd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: flash_partition_close
|
||||
*
|
||||
|
|
@ -158,15 +137,14 @@ int flash_partition_write(int fd, const void *buf, size_t count, off_t off)
|
|||
pos = lseek(fd, off, SEEK_SET);
|
||||
if (pos != off)
|
||||
{
|
||||
syslog(LOG_ERR, "Could not seek to %" PRIdOFF ": %s\n",
|
||||
off, strerror(errno));
|
||||
syslog(LOG_ERR, "Could not seek to %ld: %s\n", off, strerror(errno));
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
nbytes = write(fd, buf, count);
|
||||
if (nbytes != count)
|
||||
{
|
||||
syslog(LOG_ERR, "Write to offset %" PRIdOFF " failed %s\n",
|
||||
syslog(LOG_ERR, "Write to offset %ld failed %s\n",
|
||||
off, strerror(errno));
|
||||
return ERROR;
|
||||
}
|
||||
|
|
@ -217,16 +195,15 @@ int flash_partition_read(int fd, void *buf, size_t count, off_t off)
|
|||
pos = lseek(fd, off, SEEK_SET);
|
||||
if (pos != off)
|
||||
{
|
||||
syslog(LOG_ERR, "Could not seek to %" PRIdOFF ": %s\n",
|
||||
off, strerror(errno));
|
||||
syslog(LOG_ERR, "Could not seek to %ld: %s\n", off, strerror(errno));
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
nbytes = read(fd, buf, count);
|
||||
if (nbytes != count)
|
||||
{
|
||||
syslog(LOG_ERR, "Read from offset %" PRIdOFF " failed %s\n",
|
||||
off, strerror(errno));
|
||||
syslog(LOG_ERR, "Read from offset %ld failed %s\n", off,
|
||||
strerror(errno));
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,22 +79,6 @@ int flash_partition_open(const char *path);
|
|||
|
||||
int flash_partition_close(int fd);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: flash_partition_flush
|
||||
*
|
||||
* Description:
|
||||
* Flushes any buffered writes to the underlying storage.
|
||||
*
|
||||
* Input parameters:
|
||||
* fd: Valid file descriptor.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success, -1 on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int flash_partition_flush(int fd);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: flash_partition_write
|
||||
*
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ static const char *progress_msgs[] =
|
|||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NXBOOT_PROGRESS
|
||||
void nxboot_progress(int type, ...)
|
||||
void nxboot_progress(enum progress_type_e type, ...)
|
||||
{
|
||||
#ifdef CONFIG_NXBOOT_PRINTF_PROGRESS
|
||||
va_list arg;
|
||||
|
|
@ -264,10 +264,16 @@ int main(int argc, FAR char *argv[])
|
|||
FAR struct boardioc_reset_cause_s cause;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BOARDCTL) && !defined(CONFIG_NSH_ARCHINIT)
|
||||
/* Perform architecture-specific initialization (if configured) */
|
||||
|
||||
boardctl(BOARDIOC_INIT, 0);
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_FINALINIT
|
||||
/* Perform architecture-specific final-initialization (if configured) */
|
||||
|
||||
boardctl(BOARDIOC_FINALINIT, 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
syslog(LOG_INFO, "*** nxboot ***\n");
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#include <spawn.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <nuttx/debug.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "builtin/builtin.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
config CANUTILS_CANDUMP
|
||||
tristate "SocketCAN candump tool"
|
||||
default n
|
||||
depends on NET_CAN && CANUTILS_LIBCANUTILS && ENABLE_ALL_SIGNALS
|
||||
depends on NET_CAN && CANUTILS_LIBCANUTILS
|
||||
---help---
|
||||
Enable the SocketCAN candump tool ported from
|
||||
https://github.com/linux-can/can-utils
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <nuttx/debug.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/can/can.h>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <nuttx/debug.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/can/can.h>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <nuttx/debug.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/can/can.h>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <nuttx/debug.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/can/can.h>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <nuttx/debug.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/can/can.h>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <nuttx/debug.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/can/can.h>
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ config CANUTILS_LELYCANOPEN_OBJUPLOAD
|
|||
config CANUTILS_LELYCANOPEN_SDEV
|
||||
bool "Lely CANopen enable static device description support"
|
||||
default n
|
||||
depends on CANUTILS_LELYCANOPEN_OBJNAME
|
||||
|
||||
config CANUTILS_LELYCANOPEN_CSDO
|
||||
bool "Lely CANopen enable Client-SDO support"
|
||||
|
|
@ -68,7 +67,6 @@ config CANUTILS_LELYCANOPEN_TPDO
|
|||
config CANUTILS_LELYCANOPEN_MPDO
|
||||
bool "Lely CANopen enable Multiplex PDO support"
|
||||
default n
|
||||
depends on CANUTILS_LELYCANOPEN_TPDO
|
||||
|
||||
config CANUTILS_LELYCANOPEN_SYNC
|
||||
bool "Lely CANopen enable SYNC support"
|
||||
|
|
@ -97,17 +95,14 @@ config CANUTILS_LELYCANOPEN_MASTER
|
|||
config CANUTILS_LELYCANOPEN_NG
|
||||
bool "Lely CANopen enable node guardian support"
|
||||
default n
|
||||
depends on CANUTILS_LELYCANOPEN_EMCY
|
||||
|
||||
config CANUTILS_LELYCANOPEN_NMTBOOT
|
||||
bool "Lely CANopen enable NMT boot slave support"
|
||||
default n
|
||||
depends on CANUTILS_LELYCANOPEN_MASTER && CANUTILS_LELYCANOPEN_CSDO
|
||||
|
||||
config CANUTILS_LELYCANOPEN_NMTCFG
|
||||
bool "Lely CANopen enable NMT configuration request support"
|
||||
default n
|
||||
depends on CANUTILS_LELYCANOPEN_MASTER && CANUTILS_LELYCANOPEN_CSDO
|
||||
|
||||
config CANUTILS_LELYCANOPEN_GW
|
||||
bool "Lely CANopen enable gateway support"
|
||||
|
|
|
|||
|
|
@ -31,16 +31,11 @@ WD := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'}
|
|||
LELYCANOPEN_VERSION = $(patsubst "%",%,$(strip $(CONFIG_CANUTILS_LELYCANOPEN_VERSION)))
|
||||
|
||||
LELYCANOPEN_TARBALL = lely-core-$(LELYCANOPEN_VERSION).tar.gz
|
||||
LELYCANOPEN_UNPACKNAME = lely-core-master-$(LELYCANOPEN_VERSION)
|
||||
LELYCANOPEN_SRCNAME = lely-core
|
||||
UNPACK ?= tar -zxf
|
||||
LELYCANOPEN_SRCDIR = $(WD)/$(LELYCANOPEN_SRCNAME)
|
||||
|
||||
# The GitLab "archive/master" tarball unpacks to a directory named
|
||||
# lely-core-master-<sha>, where <sha> is the current tip of master
|
||||
|
||||
LELYCANOPEN_UNPACKGLOB = lely-core-master-*
|
||||
LELYCANOPEN_PATCHES = $(sort $(wildcard *.patch))
|
||||
|
||||
# CAN network object
|
||||
|
||||
CSRCS += $(LELYCANOPEN_SRCDIR)/src/can/buf.c
|
||||
|
|
@ -174,34 +169,37 @@ STACKSIZE = $(CONFIG_CANUTILS_LELYCANOPEN_TOOLS_COCTL_STACKSIZE)
|
|||
MAINSRC = $(LELYCANOPEN_SRCDIR)/tools/coctl.c
|
||||
endif
|
||||
|
||||
# Download, unpack and patch the Lely CANopen sources.
|
||||
|
||||
# Download and unpack tarball if no git repo found
|
||||
ifeq ($(wildcard $(LELYCANOPEN_SRCNAME)/.git),)
|
||||
|
||||
$(LELYCANOPEN_TARBALL):
|
||||
@echo "Downloading: $(LELYCANOPEN_TARBALL)"
|
||||
$(Q) curl -fL -o $@.tmp $(CONFIG_CANUTILS_LELYCANOPEN_URL)/$(LELYCANOPEN_TARBALL)
|
||||
$(Q) mv $@.tmp $@
|
||||
$(Q) curl -L -O $(CONFIG_CANUTILS_LELYCANOPEN_URL)/$(LELYCANOPEN_TARBALL)
|
||||
|
||||
$(LELYCANOPEN_SRCNAME)/.patched: $(LELYCANOPEN_TARBALL) $(LELYCANOPEN_PATCHES)
|
||||
@echo "Unpacking: $(LELYCANOPEN_TARBALL) -> $(LELYCANOPEN_SRCNAME)"
|
||||
$(Q) rm -rf $(LELYCANOPEN_SRCNAME) $(LELYCANOPEN_UNPACKGLOB)
|
||||
$(LELYCANOPEN_SRCNAME): $(LELYCANOPEN_TARBALL)
|
||||
@echo "Unpacking: $(LELYCANOPEN_TARBALL) -> $(LELYCANOPEN_UNPACKNAME)"
|
||||
$(Q) $(UNPACK) $(LELYCANOPEN_TARBALL)
|
||||
$(Q) mv $(LELYCANOPEN_UNPACKGLOB) $(LELYCANOPEN_SRCNAME)
|
||||
$(Q) for patch in $(LELYCANOPEN_PATCHES); do \
|
||||
echo "Patching: $$patch"; \
|
||||
patch -s -N -p1 -d $(LELYCANOPEN_SRCNAME) < $$patch || exit 1; \
|
||||
done
|
||||
$(Q) touch $@
|
||||
|
||||
context:: $(LELYCANOPEN_SRCNAME)/.patched
|
||||
|
||||
distclean::
|
||||
$(Q) rm -rf $(LELYCANOPEN_SRCNAME) $(LELYCANOPEN_UNPACKGLOB)
|
||||
$(call DELFILE, $(LELYCANOPEN_TARBALL))
|
||||
patch_src: $(LELYCANOPEN_SRCNAME)
|
||||
# Get the name of the directory created by the tar command
|
||||
$(eval LELYCANOPEN_UNPACKNAME := $(shell ls -d lely-core-master*))
|
||||
$(Q) mv $(LELYCANOPEN_UNPACKNAME) $(LELYCANOPEN_SRCNAME)
|
||||
$(Q) cat 0001-tools-eliminate-multiple-definitions-of-poll-compile.patch | patch -s -N -d $(LELYCANOPEN_SRCNAME) -p1
|
||||
$(Q) cat 0002-tools-coctl.c-fix-printf-issues.patch | patch -s -N -d $(LELYCANOPEN_SRCNAME) -p1
|
||||
$(Q) cat 0003-src-co-nmt.c-fix-compilation.patch | patch -s -N -d $(LELYCANOPEN_SRCNAME) -p1
|
||||
$(Q) cat 0004-tools-coctl.c-add-missing-mutex-init.patch | patch -s -N -d $(LELYCANOPEN_SRCNAME) -p1
|
||||
$(Q) cat 0005-add-NuttX-support.patch | patch -s -N -d $(LELYCANOPEN_SRCNAME) -p1
|
||||
$(Q) echo "Patching $(LELYCANOPEN_SRCNAME)"
|
||||
|
||||
context:: patch_src
|
||||
else
|
||||
context:: $(LELYCANOPEN_SRCNAME)
|
||||
endif
|
||||
|
||||
|
||||
distclean::
|
||||
ifeq ($(wildcard $(LELYCANOPEN_SRCNAME)/.git),)
|
||||
$(call DELDIR, $(LELYCANOPEN_SRCNAME))
|
||||
$(call DELFILE, $(LELYCANOPEN_TARBALL))
|
||||
endif
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
|
|
|
|||
|
|
@ -34,10 +34,7 @@ include(nuttx_parse_function_args)
|
|||
# - riscv32: riscv32imc/imac/imafc-unknown-nuttx-elf
|
||||
# - riscv64: riscv64imac/imafdc-unknown-nuttx-elf
|
||||
# - x86: i686-unknown-nuttx
|
||||
# - x86_64: x86_64-unknown-nuttx-macho for sim on macOS,
|
||||
# x86_64-unknown-nuttx otherwise
|
||||
# - aarch64: aarch64-unknown-nuttx-macho for sim on macOS,
|
||||
# aarch64-unknown-nuttx otherwise
|
||||
# - x86_64: x86_64-unknown-nuttx
|
||||
#
|
||||
# Inputs:
|
||||
# ARCHTYPE - Architecture type (e.g. thumbv7m, riscv32)
|
||||
|
|
@ -51,22 +48,9 @@ include(nuttx_parse_function_args)
|
|||
|
||||
function(nuttx_rust_target_triple ARCHTYPE ABITYPE CPUTYPE OUTPUT)
|
||||
if(ARCHTYPE STREQUAL "x86_64")
|
||||
if(CONFIG_ARCH_SIM AND CONFIG_HOST_MACOS)
|
||||
set(TARGET_TRIPLE
|
||||
"${PROJECT_SOURCE_DIR}/tools/x86_64-unknown-nuttx-macho.json")
|
||||
else()
|
||||
set(TARGET_TRIPLE "${PROJECT_SOURCE_DIR}/tools/x86_64-unknown-nuttx.json")
|
||||
endif()
|
||||
set(TARGET_TRIPLE "x86_64-unknown-nuttx")
|
||||
elseif(ARCHTYPE STREQUAL "x86")
|
||||
set(TARGET_TRIPLE "${PROJECT_SOURCE_DIR}/tools/i486-unknown-nuttx.json")
|
||||
elseif(ARCHTYPE STREQUAL "aarch64")
|
||||
if(CONFIG_ARCH_SIM AND CONFIG_HOST_MACOS)
|
||||
set(TARGET_TRIPLE
|
||||
"${PROJECT_SOURCE_DIR}/tools/aarch64-unknown-nuttx-macho.json")
|
||||
else()
|
||||
set(TARGET_TRIPLE
|
||||
"${PROJECT_SOURCE_DIR}/tools/aarch64-unknown-nuttx.json")
|
||||
endif()
|
||||
set(TARGET_TRIPLE "i686-unknown-nuttx")
|
||||
elseif(ARCHTYPE MATCHES "thumb")
|
||||
if(ARCHTYPE MATCHES "thumbv8m")
|
||||
# Extract just the base architecture type (thumbv8m.main or thumbv8m.base)
|
||||
|
|
@ -106,13 +90,6 @@ function(nuttx_rust_target_triple ARCHTYPE ABITYPE CPUTYPE OUTPUT)
|
|||
set(TARGET_TRIPLE "riscv64imac-unknown-nuttx-elf")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET_TRIPLE)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Unsupported Rust target: LLVM_ARCHTYPE=${ARCHTYPE}, LLVM_ABITYPE=${ABITYPE}, LLVM_CPUTYPE=${CPUTYPE}"
|
||||
)
|
||||
endif()
|
||||
set(${OUTPUT}
|
||||
${TARGET_TRIPLE}
|
||||
PARENT_SCOPE)
|
||||
|
|
@ -130,8 +107,6 @@ endfunction()
|
|||
# hello
|
||||
# CRATE_PATH
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/hello
|
||||
# FEATURES
|
||||
# sim
|
||||
# )
|
||||
# ~~~
|
||||
|
||||
|
|
@ -144,8 +119,6 @@ function(nuttx_add_rust)
|
|||
ONE_VALUE
|
||||
CRATE_NAME
|
||||
CRATE_PATH
|
||||
MULTI_VALUE
|
||||
FEATURES
|
||||
REQUIRED
|
||||
CRATE_NAME
|
||||
CRATE_PATH
|
||||
|
|
@ -154,60 +127,34 @@ function(nuttx_add_rust)
|
|||
|
||||
# Determine build profile based on CONFIG_DEBUG_FULLOPT
|
||||
if(CONFIG_DEBUG_FULLOPT)
|
||||
set(RUST_PROFILE_FLAG "--release")
|
||||
set(RUST_PROFILE "release")
|
||||
set(RUST_PANIC_FLAGS "-Zunstable-options -Cpanic=immediate-abort")
|
||||
set(RUST_DEBUG_FLAGS "-Zbuild-std-features=panic_immediate_abort")
|
||||
else()
|
||||
set(RUST_PROFILE_FLAG "")
|
||||
set(RUST_PROFILE "debug")
|
||||
set(RUST_PANIC_FLAGS "")
|
||||
set(RUST_DEBUG_FLAGS "")
|
||||
endif()
|
||||
|
||||
foreach(feature ${FEATURES})
|
||||
list(APPEND RUST_FEATURE_FLAGS --features ${feature})
|
||||
endforeach()
|
||||
|
||||
# Get the Rust target triple
|
||||
nuttx_rust_target_triple(${LLVM_ARCHTYPE} ${LLVM_ABITYPE} ${LLVM_CPUTYPE}
|
||||
RUST_TARGET)
|
||||
|
||||
# Get binary directory path using target triple base name if it's a JSON file
|
||||
if(RUST_TARGET MATCHES ".json$")
|
||||
get_filename_component(TARGET_BASE ${RUST_TARGET} NAME_WE)
|
||||
else()
|
||||
set(TARGET_BASE ${RUST_TARGET})
|
||||
endif()
|
||||
|
||||
set(RUST_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CRATE_NAME}/target)
|
||||
# Set up build directory in current binary dir
|
||||
set(RUST_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CRATE_NAME})
|
||||
set(RUST_LIB_PATH
|
||||
${RUST_BUILD_DIR}/${TARGET_BASE}/${RUST_PROFILE}/lib${CRATE_NAME}.a)
|
||||
${RUST_BUILD_DIR}/${RUST_TARGET}/${RUST_PROFILE}/lib${CRATE_NAME}.a)
|
||||
|
||||
# Create build directory
|
||||
file(MAKE_DIRECTORY ${RUST_BUILD_DIR})
|
||||
|
||||
# Collect Rust source files and manifests as dependencies so that changes in
|
||||
# the crate trigger a rebuild via CMake/Ninja.
|
||||
file(
|
||||
GLOB_RECURSE
|
||||
RUST_CRATE_SOURCES
|
||||
CONFIGURE_DEPENDS
|
||||
"${CRATE_PATH}/Cargo.toml"
|
||||
"${CRATE_PATH}/Cargo.lock"
|
||||
"${CRATE_PATH}/build.rs"
|
||||
"${CRATE_PATH}/src/*.rs"
|
||||
"${CRATE_PATH}/src/**/*.rs")
|
||||
|
||||
# Add a custom command to build the Rust crate
|
||||
add_custom_command(
|
||||
OUTPUT ${RUST_LIB_PATH}
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E env
|
||||
NUTTX_INCLUDE_DIR=${PROJECT_SOURCE_DIR}/include:${CMAKE_BINARY_DIR}/include:${CMAKE_BINARY_DIR}/include/arch
|
||||
RUSTFLAGS=${RUST_PANIC_FLAGS} cargo build ${RUST_PROFILE_FLAG}
|
||||
-Zbuild-std=std,panic_abort -Zjson-target-spec --manifest-path
|
||||
${CRATE_PATH}/Cargo.toml --target ${RUST_TARGET} --target-dir
|
||||
${RUST_BUILD_DIR} ${RUST_FEATURE_FLAGS}
|
||||
DEPENDS ${RUST_CRATE_SOURCES}
|
||||
cargo build --${RUST_PROFILE} -Zbuild-std=std,panic_abort
|
||||
${RUST_DEBUG_FLAGS} --manifest-path ${CRATE_PATH}/Cargo.toml --target
|
||||
${RUST_TARGET} --target-dir ${RUST_BUILD_DIR}
|
||||
COMMENT "Building Rust crate ${CRATE_NAME}"
|
||||
VERBATIM)
|
||||
|
||||
|
|
|
|||
|
|
@ -701,12 +701,8 @@ int main(int argc, FAR char *argv[])
|
|||
#ifdef CONFIG_STACK_COLORATION
|
||||
FAR struct tcb_s *tcb;
|
||||
tcb = nxsched_get_tcb(getpid());
|
||||
if (tcb != NULL)
|
||||
{
|
||||
fprintf(stderr, "\nStack used: %zu / %zu\n", up_check_tcbstack(tcb),
|
||||
tcb->adj_stack_size);
|
||||
nxsched_put_tcb(tcb);
|
||||
}
|
||||
fprintf(stderr, "\nStack used: %zu / %zu\n", up_check_tcbstack(tcb),
|
||||
tcb->adj_stack_size);
|
||||
#else
|
||||
fprintf(stderr, "\nStack used: unknown"
|
||||
" (STACK_COLORATION must be enabled)\n");
|
||||
|
|
|
|||
|
|
@ -451,7 +451,6 @@ ifneq ($(CONFIG_LIBTOMCRYPT_DEMOS),)
|
|||
ifneq ($(CONFIG_LIBTOMCRYPT_LTCRYPT),)
|
||||
MAINSRC += $(LIBTOMCRYPT_UNPACKNAME)/demos/ltcrypt.c
|
||||
|
||||
MODULE += $(CONFIG_LIBTOMCRYPT_LTCRYPT)
|
||||
PROGNAME += $(CONFIG_LIBTOMCRYPT_LTCRYPT_PROGNAME)
|
||||
PRIORITY += $(CONFIG_LIBTOMCRYPT_LTCRYPT_PRIORITY)
|
||||
STACKSIZE += $(CONFIG_LIBTOMCRYPT_LTCRYPT_STACKSIZE)
|
||||
|
|
@ -460,7 +459,6 @@ endif
|
|||
ifneq ($(CONFIG_LIBTOMCRYPT_HASHSUM),)
|
||||
MAINSRC += $(LIBTOMCRYPT_UNPACKNAME)/demos/hashsum.c
|
||||
|
||||
MODULE += $(CONFIG_LIBTOMCRYPT_HASHSUM)
|
||||
PROGNAME += $(CONFIG_LIBTOMCRYPT_HASHSUM_PROGNAME)
|
||||
PRIORITY += $(CONFIG_LIBTOMCRYPT_HASHSUM_PRIORITY)
|
||||
STACKSIZE += $(CONFIG_LIBTOMCRYPT_HASHSUM_STACKSIZE)
|
||||
|
|
@ -480,7 +478,6 @@ NEWSRC := $(wildcard libtomcrypt/tests/*.c)
|
|||
CSRCS += $(filter-out $(LIBTOMCRYPT_UNPACKNAME)/tests/test.c, $(NEWSRC))
|
||||
MAINSRC += $(LIBTOMCRYPT_UNPACKNAME)/tests/test.c
|
||||
|
||||
MODULE += $(CONFIG_LIBTOMCRYPT_TEST)
|
||||
PROGNAME += $(CONFIG_LIBTOMCRYPT_TEST_PROGNAME)
|
||||
PRIORITY += $(CONFIG_LIBTOMCRYPT_TEST_PRIORITY)
|
||||
STACKSIZE += $(CONFIG_LIBTOMCRYPT_TEST_STACKSIZE)
|
||||
|
|
|
|||
|
|
@ -129,16 +129,18 @@ if(CONFIG_CRYPTO_MBEDTLS)
|
|||
# Library Configuration
|
||||
# ############################################################################
|
||||
|
||||
set_property(
|
||||
TARGET nuttx
|
||||
APPEND
|
||||
PROPERTY NUTTX_INCLUDE_DIRECTORIES ${INCDIR})
|
||||
set_property(
|
||||
TARGET nuttx
|
||||
APPEND
|
||||
PROPERTY NUTTX_CXX_INCLUDE_DIRECTORIES ${INCDIR})
|
||||
|
||||
nuttx_add_library(mbedtls STATIC)
|
||||
target_sources(mbedtls PRIVATE ${CSRCS})
|
||||
target_include_directories(mbedtls PUBLIC ${INCDIR})
|
||||
nuttx_export_header(TARGET mbedtls INCLUDE_DIRECTORIES ${MBEDTLS_DIR}/include)
|
||||
# Overlay mbedtls_config.h cannot be in the same nuttx_export_header() as
|
||||
# ${MBEDTLS_DIR}/include (duplicate path). Alt headers need no export; INCDIR
|
||||
# supplies them for this library only.
|
||||
nuttx_create_symlink(
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/mbedtls/mbedtls_config.h
|
||||
${NUTTX_APPS_BINDIR}/include/mbedtls/mbedtls/mbedtls_config.h)
|
||||
target_include_directories(mbedtls PRIVATE ${INCDIR})
|
||||
target_compile_definitions(mbedtls PRIVATE unix)
|
||||
|
||||
if(CONFIG_ARCH_SIM)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ MBEDTLS_FRAMEWORK_UNPACKNAME = mbedtls-framework
|
|||
CFLAGS += ${DEFINE_PREFIX}unix
|
||||
|
||||
mbedtls/library/bignum.c_CFLAGS += -fno-lto
|
||||
mbedtls/library/ctr_drbg.c_CFLAGS += -Wno-array-bounds
|
||||
|
||||
# Build break on Assemble compiler if -fno-omit-frame-pointer and -O3 enabled at same time
|
||||
# {standard input}: Assembler messages:
|
||||
|
|
|
|||
|
|
@ -7,25 +7,3 @@ config OPENSSL_MBEDTLS_WRAPPER
|
|||
depends on CRYPTO_MBEDTLS
|
||||
bool "openssl mbedtls wrapper"
|
||||
default n
|
||||
|
||||
if OPENSSL_MBEDTLS_WRAPPER
|
||||
|
||||
choice
|
||||
prompt "Openssl Mbedtls Wrapper Assert Debug"
|
||||
default OPENSSL_ASSERT_EXIT
|
||||
|
||||
config OPENSSL_ASSERT_DEBUG
|
||||
bool "SSL_ASSERT* will show error file name and line"
|
||||
|
||||
config OPENSSL_ASSERT_EXIT
|
||||
bool "SSL_ASSERT* will just return error code"
|
||||
|
||||
config OPENSSL_ASSERT_DEBUG_EXIT
|
||||
bool "SSL_ASSERT* will show error file name and line, then return error code"
|
||||
|
||||
config OPENSSL_ASSERT_DEBUG_BLOCK
|
||||
bool "SSL_ASSERT* will show error file name and line, then block here with 'while (1)'"
|
||||
|
||||
endchoice
|
||||
|
||||
endif # OPENSSL_MBEDTLS_WRAPPER
|
||||
|
|
|
|||
|
|
@ -27,86 +27,16 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <openssl/base.h>
|
||||
#include <openssl/types.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* There are the classes of BIOs */
|
||||
|
||||
#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */
|
||||
#define BIO_TYPE_FILTER 0x0200
|
||||
#define BIO_TYPE_SOURCE_SINK 0x0400
|
||||
|
||||
#define BIO_FLAGS_BASE64_NO_NL 0x100
|
||||
|
||||
/* This is used with memory BIOs: BIO_FLAGS_MEM_RDONLY
|
||||
* means we shouldn't free up or change the data in any way;
|
||||
* BIO_FLAGS_NONCLEAR_RST means we shouldn't clear data on reset.
|
||||
*/
|
||||
|
||||
#define BIO_FLAGS_MEM_RDONLY 0x200
|
||||
#define BIO_FLAGS_NONCLEAR_RST 0x400
|
||||
#define BIO_FLAGS_IN_EOF 0x800
|
||||
|
||||
#define BIO_TYPE_NONE 0
|
||||
#define BIO_TYPE_MEM (1 | BIO_TYPE_SOURCE_SINK)
|
||||
#define BIO_TYPE_FILE (2 | BIO_TYPE_SOURCE_SINK)
|
||||
#define BIO_TYPE_BASE64 (11 | BIO_TYPE_FILTER)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct bio_method_st
|
||||
{
|
||||
int type;
|
||||
char *name;
|
||||
int (*bwrite_old) (BIO *, const char *, int);
|
||||
int (*bread_old) (BIO *, char *, int);
|
||||
int (*create) (BIO *);
|
||||
int (*destroy) (BIO *);
|
||||
};
|
||||
|
||||
struct bio_st
|
||||
{
|
||||
const BIO_METHOD *method;
|
||||
int flags; /* extra storage */
|
||||
void *ptr;
|
||||
struct bio_st *next_bio; /* used by filter BIOs */
|
||||
struct bio_st *prev_bio; /* used by filter BIOs */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
const BIO_METHOD *BIO_f_base64(void);
|
||||
|
||||
const BIO_METHOD *BIO_s_mem(void);
|
||||
|
||||
BIO *BIO_new(const BIO_METHOD *method);
|
||||
|
||||
BIO *BIO_push(BIO *b, BIO *bio);
|
||||
|
||||
void BIO_set_flags(BIO *b, int flags);
|
||||
|
||||
int BIO_write(BIO *b, const void *data, int dlen);
|
||||
|
||||
int BIO_read(BIO *b, void *data, int dlen);
|
||||
|
||||
void BIO_free_all(BIO *bio);
|
||||
|
||||
BIO *BIO_next(BIO *b);
|
||||
|
||||
int BIO_flush(BIO *b);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
/****************************************************************************
|
||||
* apps/crypto/openssl_mbedtls_wrapper/include/openssl/crypto.h
|
||||
*
|
||||
* 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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef OPENSSL_MBEDTLS_WRAPPER_CRYPTO_H
|
||||
#define OPENSSL_MBEDTLS_WRAPPER_CRYPTO_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <openssl/base.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define CRYPTO_num_locks() 1
|
||||
#define CRYPTO_set_locking_callback(func)
|
||||
|
||||
#define CRYPTO_set_id_callback(func)
|
||||
|
||||
/* These defines where used in combination with the old locking callbacks,
|
||||
* they are not called anymore, but old code that's not called might still
|
||||
* use them.
|
||||
*/
|
||||
|
||||
#define CRYPTO_LOCK 1
|
||||
#define CRYPTO_UNLOCK 2
|
||||
#define CRYPTO_READ 4
|
||||
#define CRYPTO_WRITE 8
|
||||
|
||||
#endif /* OPENSSL_MBEDTLS_WRAPPER_CRYPTO_H */
|
||||
|
|
@ -49,12 +49,6 @@ unsigned long ERR_peek_last_error(void);
|
|||
void ERR_error_string_n(unsigned long e, char *buf, size_t len);
|
||||
void ERR_free_strings(void);
|
||||
char *ERR_error_string(unsigned long e, char *buf);
|
||||
void ERR_clear_error(void);
|
||||
unsigned long ERR_get_error(void);
|
||||
void ERR_remove_state(unsigned long pid);
|
||||
int ERR_load_crypto_strings(void);
|
||||
void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
|
||||
void *u);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,10 +44,6 @@
|
|||
|
||||
#define EVP_PKEY_X25519 NID_X25519
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct evp_pkey_st
|
||||
{
|
||||
void *pkey_pm;
|
||||
|
|
@ -170,10 +166,6 @@ int PKCS5_PBKDF2_HMAC(const char *password, size_t password_len,
|
|||
|
||||
const PKEY_METHOD *EVP_PKEY_method(void);
|
||||
|
||||
int OpenSSL_add_all_algorithms(void);
|
||||
|
||||
void EVP_cleanup(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,19 +25,13 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <openssl/ex_data.h>
|
||||
#include <openssl/types.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/x509_vfy.h>
|
||||
#include <openssl/tls1.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
|
||||
#define SSL_SENT_SHUTDOWN 1
|
||||
#define SSL_RECEIVED_SHUTDOWN 2
|
||||
#define SSL_SENT_SHUTDOWN 1
|
||||
#define SSL_RECEIVED_SHUTDOWN 2
|
||||
|
||||
#define SSL_VERIFY_NONE 0x00
|
||||
#define SSL_VERIFY_PEER 0x01
|
||||
|
|
@ -63,134 +57,52 @@
|
|||
#define SSL_ERROR_WANT_READ 2
|
||||
#define SSL_ERROR_WANT_WRITE 3
|
||||
#define SSL_ERROR_WANT_X509_LOOKUP 4
|
||||
#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */
|
||||
#define SSL_ERROR_SYSCALL 5/* look at error stack/return value/errno */
|
||||
#define SSL_ERROR_ZERO_RETURN 6
|
||||
#define SSL_ERROR_WANT_CONNECT 7
|
||||
#define SSL_ERROR_WANT_ACCEPT 8
|
||||
#define SSL_ERROR_WANT_ASYNC 9
|
||||
#define SSL_ERROR_WANT_ASYNC_JOB 10
|
||||
|
||||
#define SSL_ST_CONNECT 0x1000
|
||||
#define SSL_ST_ACCEPT 0x2000
|
||||
|
||||
#define SSL_ST_MASK 0x0FFF
|
||||
|
||||
#define SSL_CB_LOOP 0x01
|
||||
#define SSL_CB_EXIT 0x02
|
||||
#define SSL_CB_READ 0x04
|
||||
#define SSL_CB_WRITE 0x08
|
||||
#define SSL_CB_ALERT 0x4000 /* used in callback */
|
||||
#define SSL_CB_READ_ALERT (SSL_CB_ALERT | SSL_CB_READ)
|
||||
#define SSL_CB_WRITE_ALERT (SSL_CB_ALERT | SSL_CB_WRITE)
|
||||
#define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT | SSL_CB_LOOP)
|
||||
#define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT | SSL_CB_EXIT)
|
||||
#define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT | SSL_CB_LOOP)
|
||||
#define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT | SSL_CB_EXIT)
|
||||
#define SSL_CB_HANDSHAKE_START 0x10
|
||||
#define SSL_CB_HANDSHAKE_DONE 0x20
|
||||
|
||||
#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1
|
||||
#define SSL_FILETYPE_PEM X509_FILETYPE_PEM
|
||||
|
||||
/* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success
|
||||
* when just a single record has been written):
|
||||
*/
|
||||
|
||||
#define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001U
|
||||
|
||||
/* Make it possible to retry SSL_write() with changed buffer location (buffer
|
||||
* contents must stay the same!); this is not the default to avoid the
|
||||
* misconception that non-blocking SSL_write() behaves like non-blocking
|
||||
* write():
|
||||
*/
|
||||
|
||||
#define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002U
|
||||
|
||||
#define SSLEAY_VERSION 0
|
||||
#define SSLEAY_CFLAGS 1
|
||||
#define SSLEAY_BUILT_ON 2
|
||||
#define SSLEAY_PLATFORM 3
|
||||
#define SSLEAY_DIR 4
|
||||
|
||||
#define SSL2_VERSION 0x0002
|
||||
|
||||
#define SSL2_MT_CLIENT_HELLO 1
|
||||
|
||||
#define SSLv23_client_method TLS_client_method
|
||||
#define SSL_library_init() 1
|
||||
#define SSL_load_error_strings()
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
typedef unsigned int (*SSL_psk_client_cb_func)(SSL *ssl,
|
||||
const char *hint,
|
||||
char *identity,
|
||||
unsigned int max_identity_len,
|
||||
unsigned char *psk,
|
||||
unsigned int max_psk_len);
|
||||
|
||||
typedef void (*ossl_msg_cb)(
|
||||
int write_p, int version, int content_type,
|
||||
const void *buf, size_t len, SSL *ssl, void *arg);
|
||||
#define SSL_ERROR_WANT_ASYNC_JOB 10
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TLS_ST_BEFORE,
|
||||
TLS_ST_OK,
|
||||
DTLS_ST_CR_HELLO_VERIFY_REQUEST,
|
||||
TLS_ST_CR_SRVR_HELLO,
|
||||
TLS_ST_CR_CERT,
|
||||
TLS_ST_CR_COMP_CERT,
|
||||
TLS_ST_CR_CERT_STATUS,
|
||||
TLS_ST_CR_KEY_EXCH,
|
||||
TLS_ST_CR_CERT_REQ,
|
||||
TLS_ST_CR_SRVR_DONE,
|
||||
TLS_ST_CR_SESSION_TICKET,
|
||||
TLS_ST_CR_CHANGE,
|
||||
TLS_ST_CR_FINISHED,
|
||||
TLS_ST_CW_CLNT_HELLO,
|
||||
TLS_ST_CW_CERT,
|
||||
TLS_ST_CW_COMP_CERT,
|
||||
TLS_ST_CW_KEY_EXCH,
|
||||
TLS_ST_CW_CERT_VRFY,
|
||||
TLS_ST_CW_CHANGE,
|
||||
TLS_ST_CW_NEXT_PROTO,
|
||||
TLS_ST_CW_FINISHED,
|
||||
TLS_ST_SW_HELLO_REQ,
|
||||
TLS_ST_SR_CLNT_HELLO,
|
||||
DTLS_ST_SW_HELLO_VERIFY_REQUEST,
|
||||
TLS_ST_SW_SRVR_HELLO,
|
||||
TLS_ST_SW_CERT,
|
||||
TLS_ST_SW_COMP_CERT,
|
||||
TLS_ST_SW_KEY_EXCH,
|
||||
TLS_ST_SW_CERT_REQ,
|
||||
TLS_ST_SW_SRVR_DONE,
|
||||
TLS_ST_SR_CERT,
|
||||
TLS_ST_SR_COMP_CERT,
|
||||
TLS_ST_SR_KEY_EXCH,
|
||||
TLS_ST_SR_CERT_VRFY,
|
||||
TLS_ST_SR_NEXT_PROTO,
|
||||
TLS_ST_SR_CHANGE,
|
||||
TLS_ST_SR_FINISHED,
|
||||
TLS_ST_SW_SESSION_TICKET,
|
||||
TLS_ST_SW_CERT_STATUS,
|
||||
TLS_ST_SW_CHANGE,
|
||||
TLS_ST_SW_FINISHED,
|
||||
TLS_ST_SW_ENCRYPTED_EXTENSIONS,
|
||||
TLS_ST_CR_ENCRYPTED_EXTENSIONS,
|
||||
TLS_ST_CR_CERT_VRFY,
|
||||
TLS_ST_SW_CERT_VRFY,
|
||||
TLS_ST_CR_HELLO_REQ,
|
||||
TLS_ST_SW_KEY_UPDATE,
|
||||
TLS_ST_CW_KEY_UPDATE,
|
||||
TLS_ST_SR_KEY_UPDATE,
|
||||
TLS_ST_CR_KEY_UPDATE,
|
||||
TLS_ST_EARLY_DATA,
|
||||
TLS_ST_PENDING_EARLY_DATA_END,
|
||||
TLS_ST_CW_END_OF_EARLY_DATA,
|
||||
TLS_ST_SR_END_OF_EARLY_DATA
|
||||
TLS_ST_BEFORE,
|
||||
TLS_ST_OK,
|
||||
DTLS_ST_CR_HELLO_VERIFY_REQUEST,
|
||||
TLS_ST_CR_SRVR_HELLO,
|
||||
TLS_ST_CR_CERT,
|
||||
TLS_ST_CR_CERT_STATUS,
|
||||
TLS_ST_CR_KEY_EXCH,
|
||||
TLS_ST_CR_CERT_REQ,
|
||||
TLS_ST_CR_SRVR_DONE,
|
||||
TLS_ST_CR_SESSION_TICKET,
|
||||
TLS_ST_CR_CHANGE,
|
||||
TLS_ST_CR_FINISHED,
|
||||
TLS_ST_CW_CLNT_HELLO,
|
||||
TLS_ST_CW_CERT,
|
||||
TLS_ST_CW_KEY_EXCH,
|
||||
TLS_ST_CW_CERT_VRFY,
|
||||
TLS_ST_CW_CHANGE,
|
||||
TLS_ST_CW_NEXT_PROTO,
|
||||
TLS_ST_CW_FINISHED,
|
||||
TLS_ST_SW_HELLO_REQ,
|
||||
TLS_ST_SR_CLNT_HELLO,
|
||||
DTLS_ST_SW_HELLO_VERIFY_REQUEST,
|
||||
TLS_ST_SW_SRVR_HELLO,
|
||||
TLS_ST_SW_CERT,
|
||||
TLS_ST_SW_KEY_EXCH,
|
||||
TLS_ST_SW_CERT_REQ,
|
||||
TLS_ST_SW_SRVR_DONE,
|
||||
TLS_ST_SR_CERT,
|
||||
TLS_ST_SR_KEY_EXCH,
|
||||
TLS_ST_SR_CERT_VRFY,
|
||||
TLS_ST_SR_NEXT_PROTO,
|
||||
TLS_ST_SR_CHANGE,
|
||||
TLS_ST_SR_FINISHED,
|
||||
TLS_ST_SW_SESSION_TICKET,
|
||||
TLS_ST_SW_CERT_STATUS,
|
||||
TLS_ST_SW_CHANGE,
|
||||
TLS_ST_SW_FINISHED
|
||||
}
|
||||
OSSL_HANDSHAKE_STATE;
|
||||
|
||||
|
|
@ -229,8 +141,6 @@ int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len);
|
|||
|
||||
int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type);
|
||||
|
||||
int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file);
|
||||
|
||||
int SSL_use_certificate_file(SSL *ssl, const char *file, int type);
|
||||
|
||||
X509 *SSL_get_peer_certificate(const SSL *ssl);
|
||||
|
|
@ -251,7 +161,7 @@ int SSL_get_error(const SSL *ssl, int ret_code);
|
|||
|
||||
OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl);
|
||||
|
||||
SSL_CTX *SSL_CTX_new(const SSL_METHOD *method);
|
||||
SSL_CTX *SSL_CTX_new(const SSL_METHOD *method, void *rngctx);
|
||||
|
||||
void SSL_CTX_free(SSL_CTX *ctx);
|
||||
|
||||
|
|
@ -389,78 +299,6 @@ int SSL_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type);
|
|||
int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d,
|
||||
long len);
|
||||
|
||||
const SSL_METHOD *TLS_method(void);
|
||||
const SSL_METHOD *TLS_server_method(void);
|
||||
const SSL_METHOD *TLS_client_method(void);
|
||||
|
||||
const SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */
|
||||
const SSL_METHOD *TLSv1_server_method(void);
|
||||
const SSL_METHOD *TLSv1_client_method(void);
|
||||
|
||||
const SSL_METHOD *TLSv1_1_method(void); /* TLSv1.1 */
|
||||
const SSL_METHOD *TLSv1_1_server_method(void);
|
||||
const SSL_METHOD *TLSv1_1_client_method(void);
|
||||
|
||||
const SSL_METHOD *TLSv1_2_method(void); /* TLSv1.2 */
|
||||
const SSL_METHOD *TLSv1_2_server_method(void);
|
||||
const SSL_METHOD *TLSv1_2_client_method(void);
|
||||
|
||||
SSL_SESSION *SSL_get1_session(SSL *ssl);
|
||||
|
||||
void SSL_SESSION_free(SSL_SESSION *session);
|
||||
|
||||
int SSL_set_session(SSL *s, SSL_SESSION *session);
|
||||
|
||||
const char *SSLeay_version(int t);
|
||||
|
||||
const char *SSL_state_string_long(const SSL *s);
|
||||
|
||||
const char *SSL_get_cipher_name(const SSL *s);
|
||||
|
||||
const char *SSL_alert_type_string_long(int value);
|
||||
|
||||
const char *SSL_alert_desc_string_long(int value);
|
||||
|
||||
void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb);
|
||||
|
||||
void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);
|
||||
|
||||
int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);
|
||||
|
||||
void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx,
|
||||
SSL_psk_client_cb_func cb);
|
||||
|
||||
long SSL_CTX_set_mode(SSL_CTX *ctx, long larg);
|
||||
|
||||
void SSL_CTX_set_info_callback(SSL_CTX *ctx,
|
||||
void (*cb)(const SSL *ssl, int type, int val));
|
||||
|
||||
void SSL_CTX_set_msg_callback(SSL_CTX *ctx,
|
||||
void (*cb)(int write_p, int version,
|
||||
int content_type, const void *buf,
|
||||
size_t len, SSL *ssl, void *arg));
|
||||
|
||||
const char *SSL_get_cipher_list(const SSL *s, int n);
|
||||
|
||||
long SSL_set_tlsext_host_name(SSL *s, void *parg);
|
||||
|
||||
int SSL_get_ex_new_index(long argl, void *argp,
|
||||
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
|
||||
CRYPTO_EX_free *free_func);
|
||||
|
||||
const char *SSL_get_cipher_list(const SSL *s, int n);
|
||||
|
||||
int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str);
|
||||
|
||||
int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg);
|
||||
|
||||
int SSL_CTX_load_verify_file(SSL_CTX *ctx, const char *CAfile);
|
||||
|
||||
int SSL_CTX_load_verify_dir(SSL_CTX *ctx, const char *CApath);
|
||||
|
||||
int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
|
||||
const char *CApath);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,6 +30,11 @@
|
|||
#include <openssl/x509_local.h>
|
||||
#include <openssl/x509_vfy.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
|
@ -56,24 +61,6 @@ struct ssl_ctx_st
|
|||
int read_ahead;
|
||||
int read_buffer_len;
|
||||
X509_VERIFY_PARAM param;
|
||||
|
||||
/* Default password callback. */
|
||||
|
||||
pem_password_cb *default_passwd_callback;
|
||||
|
||||
/* Default password callback user data. */
|
||||
|
||||
void *default_passwd_callback_userdata;
|
||||
uint32_t mode;
|
||||
|
||||
/* optional informational callback */
|
||||
|
||||
void (*info_callback)(const SSL *ssl, int type, int val);
|
||||
|
||||
/* callback that allows applications to peek at protocol messages */
|
||||
|
||||
ossl_msg_cb msg_callback;
|
||||
SSL_psk_client_cb_func psk_client_callback;
|
||||
};
|
||||
|
||||
struct ssl_method_func_st
|
||||
|
|
@ -110,22 +97,16 @@ struct ssl_session_st
|
|||
long timeout;
|
||||
long time;
|
||||
X509 *peer;
|
||||
const SSL_CIPHER *cipher;
|
||||
int references;
|
||||
struct
|
||||
{
|
||||
char hostname[TLSEXT_MAXLEN_host_name];
|
||||
} ext;
|
||||
};
|
||||
|
||||
struct ssl_st
|
||||
{
|
||||
/* protocol version(one of SSL3.0, TLS1.0, etc.) */
|
||||
/* protocol version(one of SSL3.0, TLS1.0, etc.) */
|
||||
|
||||
int version;
|
||||
unsigned long options;
|
||||
|
||||
/* shut things down(0x01 : sent, 0x02 : received) */
|
||||
/* shut things down(0x01 : sent, 0x02 : received) */
|
||||
|
||||
int shutdown;
|
||||
CERT *cert;
|
||||
|
|
@ -135,7 +116,7 @@ struct ssl_st
|
|||
const char **alpn_protos;
|
||||
RECORD_LAYER rlayer;
|
||||
|
||||
/* where we are */
|
||||
/* where we are */
|
||||
|
||||
OSSL_STATEM statem;
|
||||
SSL_SESSION *session;
|
||||
|
|
@ -148,22 +129,11 @@ struct ssl_st
|
|||
int err;
|
||||
void (*info_callback) (const SSL *ssl, int type, int val);
|
||||
|
||||
/* SSL low-level system arch point */
|
||||
/* SSL low-level system arch point */
|
||||
|
||||
void *ssl_pm;
|
||||
SSL_CIPHER *cipher_list;
|
||||
};
|
||||
|
||||
struct ssl_cipher_st
|
||||
{
|
||||
const char *name; /* text name */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -20,63 +20,42 @@
|
|||
#ifndef OPENSSL_MBEDTLS_WRAPPER_TLS1_H
|
||||
#define OPENSSL_MBEDTLS_WRAPPER_TLS1_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define TLS1_AD_DECRYPTION_FAILED 21
|
||||
#define TLS1_AD_RECORD_OVERFLOW 22
|
||||
#define TLS1_AD_UNKNOWN_CA 48 /* fatal */
|
||||
#define TLS1_AD_ACCESS_DENIED 49 /* fatal */
|
||||
#define TLS1_AD_DECODE_ERROR 50 /* fatal */
|
||||
#define TLS1_AD_UNKNOWN_CA 48/* fatal */
|
||||
#define TLS1_AD_ACCESS_DENIED 49/* fatal */
|
||||
#define TLS1_AD_DECODE_ERROR 50/* fatal */
|
||||
#define TLS1_AD_DECRYPT_ERROR 51
|
||||
#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */
|
||||
#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */
|
||||
#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */
|
||||
#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */
|
||||
#define TLS1_AD_INAPPROPRIATE_FALLBACK 86 /* fatal */
|
||||
#define TLS1_AD_EXPORT_RESTRICTION 60/* fatal */
|
||||
#define TLS1_AD_PROTOCOL_VERSION 70/* fatal */
|
||||
#define TLS1_AD_INSUFFICIENT_SECURITY 71/* fatal */
|
||||
#define TLS1_AD_INTERNAL_ERROR 80/* fatal */
|
||||
#define TLS1_AD_INAPPROPRIATE_FALLBACK 86/* fatal */
|
||||
#define TLS1_AD_USER_CANCELLED 90
|
||||
#define TLS1_AD_NO_RENEGOTIATION 100
|
||||
|
||||
/* codes 110-114 are from RFC3546 */
|
||||
|
||||
#define TLS1_AD_UNSUPPORTED_EXTENSION 110
|
||||
#define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111
|
||||
#define TLS1_AD_UNRECOGNIZED_NAME 112
|
||||
#define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113
|
||||
#define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114
|
||||
#define TLS1_AD_UNKNOWN_PSK_IDENTITY 115 /* fatal */
|
||||
#define TLS1_AD_NO_APPLICATION_PROTOCOL 120 /* fatal */
|
||||
#define TLS1_AD_UNKNOWN_PSK_IDENTITY 115/* fatal */
|
||||
#define TLS1_AD_NO_APPLICATION_PROTOCOL 120/* fatal */
|
||||
|
||||
/* Special value for method supporting multiple versions */
|
||||
|
||||
#define TLS_ANY_VERSION 0x10000
|
||||
|
||||
#define TLS1_VERSION 0x0301
|
||||
#define TLS1_1_VERSION 0x0302
|
||||
#define TLS1_2_VERSION 0x0303
|
||||
|
||||
#define SSL_TLSEXT_ERR_OK 0
|
||||
#define SSL_TLSEXT_ERR_NOACK 3
|
||||
|
||||
#define TLSEXT_MAXLEN_host_name 255
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
long SSL_set_tlsext_host_name(SSL *s, void *parg);
|
||||
#define SSL_TLSEXT_ERR_OK 0
|
||||
#define SSL_TLSEXT_ERR_NOACK 3
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,22 +20,19 @@
|
|||
#ifndef OPENSSL_MBEDTLS_WRAPPER_TYPES_H
|
||||
#define OPENSSL_MBEDTLS_WRAPPER_TYPES_H
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef void CRYPTO_EX_new;
|
||||
typedef void CRYPTO_THREADID;
|
||||
typedef void SSL_CIPHER;
|
||||
typedef void X509_STORE;
|
||||
|
||||
typedef void RSA;
|
||||
typedef void BIO;
|
||||
|
||||
typedef int (*OPENSSL_sk_compfunc)(const void *, const void *);
|
||||
typedef int pem_password_cb(char *buf, int size,
|
||||
int rwflag, void *userdata);
|
||||
|
||||
typedef struct bio_buf_mem_st BIO_BUF_MEM;
|
||||
typedef struct bio_method_st BIO_METHOD;
|
||||
typedef struct bio_st BIO;
|
||||
typedef struct stack_st OPENSSL_STACK;
|
||||
typedef struct ssl_method_st SSL_METHOD;
|
||||
typedef struct ssl_method_func_st SSL_METHOD_FUNC;
|
||||
|
|
@ -44,7 +41,6 @@ typedef struct ossl_statem_st OSSL_STATEM;
|
|||
typedef struct ssl_session_st SSL_SESSION;
|
||||
typedef struct ssl_ctx_st SSL_CTX;
|
||||
typedef struct ssl_st SSL;
|
||||
typedef struct ssl_cipher_st SSL_CIPHER;
|
||||
typedef struct cert_st CERT;
|
||||
typedef struct x509_st X509;
|
||||
typedef struct X509_VERIFY_PARAM_st X509_VERIFY_PARAM;
|
||||
|
|
@ -70,4 +66,8 @@ struct pkey_method_st
|
|||
int (*pkey_load)(EVP_PKEY *pkey, const unsigned char *buf, int len);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* OPENSSL_MBEDTLS_WRAPPER_TYPES_H */
|
||||
|
|
|
|||
|
|
@ -34,13 +34,10 @@
|
|||
#include <openssl/obj.h>
|
||||
#include <openssl/types.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define X509_FILETYPE_PEM 1
|
||||
#define X509_FILETYPE_ASN1 2
|
||||
#define X509_FILETYPE_DEFAULT 3
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
|
|
@ -48,7 +45,7 @@
|
|||
|
||||
struct x509_st
|
||||
{
|
||||
/* X509 certification platform private point */
|
||||
/* X509 certification platform private point */
|
||||
|
||||
void *x509_pm;
|
||||
const X509_METHOD *method;
|
||||
|
|
@ -59,8 +56,6 @@ struct x509_method_st
|
|||
int (*x509_new)(X509 *x, X509 *m_x);
|
||||
void (*x509_free)(X509 *x);
|
||||
int (*x509_load)(X509 *x, const unsigned char *buf, int len);
|
||||
int (*x509_load_file)(X509 *x, const char *file);
|
||||
int (*x509_load_path)(X509 *x, const char *path);
|
||||
int (*x509_show_info)(X509 *x);
|
||||
};
|
||||
|
||||
|
|
@ -71,11 +66,6 @@ struct cert_st
|
|||
EVP_PKEY *pkey;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -1,147 +0,0 @@
|
|||
/****************************************************************************
|
||||
* apps/crypto/openssl_mbedtls_wrapper/mbedtls/bio_b64.c
|
||||
*
|
||||
* 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 <sys/param.h>
|
||||
|
||||
#include <mbedtls/base64.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/types.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define BIO_B64_BUFSIZE ((BIO_B64_ENC_LEN / 3) * 4 + 1)
|
||||
#define BIO_B64_ENC_LEN 192
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int b64_write(BIO *h, const char *buf, int num);
|
||||
static int b64_read(BIO *h, char *buf, int size);
|
||||
static int b64_new(BIO *h);
|
||||
static int b64_free(BIO *data);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const BIO_METHOD g_methods_b64 =
|
||||
{
|
||||
BIO_TYPE_BASE64,
|
||||
"base64 encoding",
|
||||
b64_write,
|
||||
b64_read,
|
||||
b64_new,
|
||||
b64_free,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static int b64_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
BIO *next;
|
||||
int len;
|
||||
int offset = 0;
|
||||
int ret = 0;
|
||||
size_t n;
|
||||
unsigned char out[BIO_B64_BUFSIZE];
|
||||
|
||||
next = BIO_next(b);
|
||||
if (next == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (inl > 0)
|
||||
{
|
||||
len = MIN(inl, BIO_B64_ENC_LEN);
|
||||
ret = mbedtls_base64_encode(out, BIO_B64_BUFSIZE, &n,
|
||||
(const unsigned char *)in + offset, len);
|
||||
if (ret < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ret = BIO_write(next, out, n);
|
||||
inl -= len;
|
||||
offset += len;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int b64_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
BIO *next;
|
||||
int ret;
|
||||
size_t n;
|
||||
|
||||
if (out == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
next = BIO_next(b);
|
||||
if (next == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = BIO_read(next, out, outl);
|
||||
if (ret > 0)
|
||||
{
|
||||
ret = mbedtls_base64_decode((unsigned char *)out, outl, &n,
|
||||
(const unsigned char *)out, ret);
|
||||
if (ret == 0)
|
||||
{
|
||||
ret = n;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int b64_new(BIO *bi)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int b64_free(BIO *a)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
const BIO_METHOD *BIO_f_base64(void)
|
||||
{
|
||||
return &g_methods_b64;
|
||||
}
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
/****************************************************************************
|
||||
* apps/crypto/openssl_mbedtls_wrapper/mbedtls/bio_lib.c
|
||||
*
|
||||
* 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 <openssl/bio.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
BIO *BIO_new(const BIO_METHOD *method)
|
||||
{
|
||||
BIO *bio = zalloc(sizeof(*bio));
|
||||
|
||||
if (bio == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bio->method = method;
|
||||
|
||||
if (method->create != NULL && !method->create(bio))
|
||||
{
|
||||
free(bio);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return bio;
|
||||
}
|
||||
|
||||
BIO *BIO_push(BIO *b, BIO *bio)
|
||||
{
|
||||
BIO *lb;
|
||||
|
||||
if (b == NULL)
|
||||
{
|
||||
return bio;
|
||||
}
|
||||
else if (bio == NULL)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
lb = b;
|
||||
while (lb->next_bio != NULL)
|
||||
{
|
||||
lb = lb->next_bio;
|
||||
}
|
||||
|
||||
lb->next_bio = bio;
|
||||
bio->prev_bio = lb;
|
||||
return b;
|
||||
}
|
||||
|
||||
void BIO_set_flags(BIO *b, int flags)
|
||||
{
|
||||
b->flags |= flags;
|
||||
}
|
||||
|
||||
int BIO_write(BIO *b, const void *data, int dlen)
|
||||
{
|
||||
if (b == NULL || dlen <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (b->method == NULL || b->method->bwrite_old == NULL)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
return b->method->bwrite_old(b, data, dlen);
|
||||
}
|
||||
|
||||
int BIO_read(BIO *b, void *data, int dlen)
|
||||
{
|
||||
if (b == NULL || dlen <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (b->method == NULL || b->method->bread_old == NULL)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
return b->method->bread_old(b, data, dlen);
|
||||
}
|
||||
|
||||
int BIO_free(BIO *a)
|
||||
{
|
||||
if (a == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (a->method != NULL && a->method->destroy != NULL)
|
||||
{
|
||||
a->method->destroy(a);
|
||||
}
|
||||
|
||||
free(a);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void BIO_free_all(BIO *bio)
|
||||
{
|
||||
while (bio != NULL)
|
||||
{
|
||||
BIO *b = bio;
|
||||
bio = bio->next_bio;
|
||||
BIO_free(b);
|
||||
}
|
||||
}
|
||||
|
||||
BIO *BIO_next(BIO *b)
|
||||
{
|
||||
if (b == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b->next_bio;
|
||||
}
|
||||
|
||||
int BIO_flush(BIO *b)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -1,236 +0,0 @@
|
|||
/****************************************************************************
|
||||
* apps/crypto/openssl_mbedtls_wrapper/mbedtls/bss_mem.c
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <openssl/bio.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That
|
||||
* function is applied in several functions in this file and this limit
|
||||
* ensures that the result fits in an int.
|
||||
*/
|
||||
|
||||
#define LIMIT_BEFORE_EXPANSION 0x5ffffffc
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int mem_write(BIO *h, const char *buf, int num);
|
||||
static int mem_read(BIO *h, char *buf, int size);
|
||||
static int mem_new(BIO *h);
|
||||
static int mem_free(BIO *data);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct bio_buf_mem_st
|
||||
{
|
||||
unsigned long flags;
|
||||
char *data;
|
||||
size_t length; /* current number of bytes */
|
||||
size_t max; /* size of buffer */
|
||||
size_t offset; /* has been read */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const BIO_METHOD g_mem_method =
|
||||
{
|
||||
BIO_TYPE_MEM,
|
||||
"memory buffer",
|
||||
mem_write,
|
||||
mem_read,
|
||||
mem_new,
|
||||
mem_free,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static int mem_buf_sync(BIO *b)
|
||||
{
|
||||
if (b != NULL && b->ptr != NULL)
|
||||
{
|
||||
BIO_BUF_MEM *bbm = (BIO_BUF_MEM *)b->ptr;
|
||||
|
||||
if (bbm->offset)
|
||||
{
|
||||
bbm->length = bbm->length - bbm->offset;
|
||||
memmove(bbm->data, bbm->data + bbm->offset, bbm->length);
|
||||
bbm->offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t BUF_MEM_grow_clean(BIO_BUF_MEM *bbm, size_t len)
|
||||
{
|
||||
char *ret;
|
||||
size_t n;
|
||||
|
||||
if (bbm->length >= len)
|
||||
{
|
||||
if (bbm->data != NULL)
|
||||
{
|
||||
memset(&bbm->data[len], 0, bbm->length - len);
|
||||
}
|
||||
|
||||
bbm->length = len;
|
||||
return len;
|
||||
}
|
||||
|
||||
if (bbm->max >= len)
|
||||
{
|
||||
memset(&bbm->data[bbm->length], 0, len - bbm->length);
|
||||
bbm->length = len;
|
||||
return len;
|
||||
}
|
||||
|
||||
/* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */
|
||||
|
||||
if (len > LIMIT_BEFORE_EXPANSION)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = MAX((len + 3) / 3 * 4, bbm->max);
|
||||
ret = realloc(bbm->data, n);
|
||||
if (ret == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bbm->data = ret;
|
||||
bbm->max = n;
|
||||
bbm->length = len;
|
||||
return len;
|
||||
}
|
||||
|
||||
static int mem_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
BIO_BUF_MEM *bbm = (BIO_BUF_MEM *)b->ptr;
|
||||
int blen;
|
||||
|
||||
if (b->flags & BIO_FLAGS_MEM_RDONLY)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (inl <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (in == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
blen = bbm->length - bbm->offset;
|
||||
mem_buf_sync(b);
|
||||
if (BUF_MEM_grow_clean(bbm, blen + inl) == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(bbm->data + blen, in, inl);
|
||||
return inl;
|
||||
}
|
||||
|
||||
static int mem_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
BIO_BUF_MEM *bbm = (BIO_BUF_MEM *)b->ptr;
|
||||
|
||||
if (outl <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (out == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (outl > bbm->length - bbm->offset)
|
||||
{
|
||||
outl = bbm->length - bbm->offset;
|
||||
}
|
||||
|
||||
memcpy(out, bbm->data + bbm->offset, outl);
|
||||
bbm->offset += outl;
|
||||
return outl;
|
||||
}
|
||||
|
||||
static int mem_new(BIO *bi)
|
||||
{
|
||||
BIO_BUF_MEM *bbm = zalloc(sizeof(*bbm));
|
||||
|
||||
if (bbm == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bi->ptr = bbm;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mem_free(BIO *a)
|
||||
{
|
||||
BIO_BUF_MEM *bbm;
|
||||
|
||||
if (a == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bbm = (BIO_BUF_MEM *)a->ptr;
|
||||
if (bbm->data)
|
||||
{
|
||||
free(bbm->data);
|
||||
}
|
||||
|
||||
free(bbm);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
const BIO_METHOD *BIO_s_mem(void)
|
||||
{
|
||||
return &g_mem_method;
|
||||
}
|
||||
|
|
@ -38,34 +38,7 @@ unsigned long ERR_peek_last_error(void)
|
|||
return errno;
|
||||
}
|
||||
|
||||
void ERR_free_strings(void)
|
||||
{
|
||||
}
|
||||
|
||||
void ERR_error_string_n(unsigned long e, char *buf, size_t len)
|
||||
{
|
||||
mbedtls_strerror(e, buf, len);
|
||||
}
|
||||
|
||||
void ERR_clear_error(void)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned long ERR_get_error(void)
|
||||
{
|
||||
return errno;
|
||||
}
|
||||
|
||||
void ERR_remove_state(unsigned long pid)
|
||||
{
|
||||
}
|
||||
|
||||
int ERR_load_crypto_strings(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
|
||||
void *u)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -344,12 +344,3 @@ int EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey,
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OpenSSL_add_all_algorithms(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EVP_cleanup(void)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,22 +21,13 @@
|
|||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/atomic.h>
|
||||
#include <openssl/ssl_dbg.h>
|
||||
#include <openssl/ssl3.h>
|
||||
#include <openssl/ssl_local.h>
|
||||
#include "ssl_port.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define SSL_SEND_DATA_MAX_LENGTH 1460
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct alpn_ctx
|
||||
{
|
||||
unsigned char data[23];
|
||||
|
|
@ -65,7 +56,6 @@ static SSL_SESSION *SSL_SESSION_new(void)
|
|||
goto failed2;
|
||||
}
|
||||
|
||||
session->references = 1;
|
||||
return session;
|
||||
|
||||
failed2:
|
||||
|
|
@ -74,6 +64,12 @@ failed1:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void SSL_SESSION_free(SSL_SESSION *session)
|
||||
{
|
||||
X509_free(session->peer);
|
||||
ssl_mem_free(session);
|
||||
}
|
||||
|
||||
static void
|
||||
_openssl_alpn_to_mbedtls(struct alpn_ctx *ac, char ***palpn_protos)
|
||||
{
|
||||
|
|
@ -260,7 +256,7 @@ int SSL_get_error(const SSL *ssl, int ret_code)
|
|||
return ret;
|
||||
}
|
||||
|
||||
SSL_CTX *SSL_CTX_new(const SSL_METHOD *method)
|
||||
SSL_CTX *SSL_CTX_new(const SSL_METHOD *method, void *rngctx)
|
||||
{
|
||||
SSL_CTX *ctx;
|
||||
CERT *cert;
|
||||
|
|
@ -1018,389 +1014,3 @@ void SSL_set_alpn_select_cb(SSL *ssl, void *arg)
|
|||
|
||||
_ssl_set_alpn_list(ssl);
|
||||
}
|
||||
|
||||
SSL_SESSION *SSL_get1_session(SSL *ssl)
|
||||
{
|
||||
SSL_ASSERT2(ssl);
|
||||
|
||||
atomic_fetch_add(&ssl->session->references, 1);
|
||||
return ssl->session;
|
||||
}
|
||||
|
||||
void SSL_SESSION_free(SSL_SESSION *session)
|
||||
{
|
||||
SSL_ASSERT3(session);
|
||||
|
||||
if (atomic_fetch_sub(&session->references, 1) == 1)
|
||||
{
|
||||
X509_free(session->peer);
|
||||
ssl_mem_free(session);
|
||||
}
|
||||
}
|
||||
|
||||
int SSL_set_session(SSL *s, SSL_SESSION *session)
|
||||
{
|
||||
SSL_ASSERT1(s);
|
||||
SSL_ASSERT1(session);
|
||||
|
||||
SSL_SESSION_free(s->session);
|
||||
s->session = session;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *SSLeay_version(int t)
|
||||
{
|
||||
return "not available";
|
||||
}
|
||||
|
||||
const char *SSL_state_string_long(const SSL *s)
|
||||
{
|
||||
SSL_ASSERT2(s);
|
||||
|
||||
switch (SSL_get_state(s))
|
||||
{
|
||||
case TLS_ST_CR_CERT_STATUS:
|
||||
return "SSLv3/TLS read certificate status";
|
||||
case TLS_ST_CW_NEXT_PROTO:
|
||||
return "SSLv3/TLS write next proto";
|
||||
case TLS_ST_SR_NEXT_PROTO:
|
||||
return "SSLv3/TLS read next proto";
|
||||
case TLS_ST_SW_CERT_STATUS:
|
||||
return "SSLv3/TLS write certificate status";
|
||||
case TLS_ST_BEFORE:
|
||||
return "before SSL initialization";
|
||||
case TLS_ST_OK:
|
||||
return "SSL negotiation finished successfully";
|
||||
case TLS_ST_CW_CLNT_HELLO:
|
||||
return "SSLv3/TLS write client hello";
|
||||
case TLS_ST_CR_SRVR_HELLO:
|
||||
return "SSLv3/TLS read server hello";
|
||||
case TLS_ST_CR_CERT:
|
||||
return "SSLv3/TLS read server certificate";
|
||||
case TLS_ST_CR_COMP_CERT:
|
||||
return "TLSv1.3 read server compressed certificate";
|
||||
case TLS_ST_CR_KEY_EXCH:
|
||||
return "SSLv3/TLS read server key exchange";
|
||||
case TLS_ST_CR_CERT_REQ:
|
||||
return "SSLv3/TLS read server certificate request";
|
||||
case TLS_ST_CR_SESSION_TICKET:
|
||||
return "SSLv3/TLS read server session ticket";
|
||||
case TLS_ST_CR_SRVR_DONE:
|
||||
return "SSLv3/TLS read server done";
|
||||
case TLS_ST_CW_CERT:
|
||||
return "SSLv3/TLS write client certificate";
|
||||
case TLS_ST_CW_COMP_CERT:
|
||||
return "TLSv1.3 write client compressed certificate";
|
||||
case TLS_ST_CW_KEY_EXCH:
|
||||
return "SSLv3/TLS write client key exchange";
|
||||
case TLS_ST_CW_CERT_VRFY:
|
||||
return "SSLv3/TLS write certificate verify";
|
||||
case TLS_ST_CW_CHANGE:
|
||||
case TLS_ST_SW_CHANGE:
|
||||
return "SSLv3/TLS write change cipher spec";
|
||||
case TLS_ST_CW_FINISHED:
|
||||
case TLS_ST_SW_FINISHED:
|
||||
return "SSLv3/TLS write finished";
|
||||
case TLS_ST_CR_CHANGE:
|
||||
case TLS_ST_SR_CHANGE:
|
||||
return "SSLv3/TLS read change cipher spec";
|
||||
case TLS_ST_CR_FINISHED:
|
||||
case TLS_ST_SR_FINISHED:
|
||||
return "SSLv3/TLS read finished";
|
||||
case TLS_ST_SR_CLNT_HELLO:
|
||||
return "SSLv3/TLS read client hello";
|
||||
case TLS_ST_SW_HELLO_REQ:
|
||||
return "SSLv3/TLS write hello request";
|
||||
case TLS_ST_SW_SRVR_HELLO:
|
||||
return "SSLv3/TLS write server hello";
|
||||
case TLS_ST_SW_CERT:
|
||||
return "SSLv3/TLS write certificate";
|
||||
case TLS_ST_SW_COMP_CERT:
|
||||
return "TLSv1.3 write server compressed certificate";
|
||||
case TLS_ST_SW_KEY_EXCH:
|
||||
return "SSLv3/TLS write key exchange";
|
||||
case TLS_ST_SW_CERT_REQ:
|
||||
return "SSLv3/TLS write certificate request";
|
||||
case TLS_ST_SW_SESSION_TICKET:
|
||||
return "SSLv3/TLS write session ticket";
|
||||
case TLS_ST_SW_SRVR_DONE:
|
||||
return "SSLv3/TLS write server done";
|
||||
case TLS_ST_SR_CERT:
|
||||
return "SSLv3/TLS read client certificate";
|
||||
case TLS_ST_SR_COMP_CERT:
|
||||
return "TLSv1.3 read client compressed certificate";
|
||||
case TLS_ST_SR_KEY_EXCH:
|
||||
return "SSLv3/TLS read client key exchange";
|
||||
case TLS_ST_SR_CERT_VRFY:
|
||||
return "SSLv3/TLS read certificate verify";
|
||||
case DTLS_ST_CR_HELLO_VERIFY_REQUEST:
|
||||
return "DTLS1 read hello verify request";
|
||||
case DTLS_ST_SW_HELLO_VERIFY_REQUEST:
|
||||
return "DTLS1 write hello verify request";
|
||||
case TLS_ST_SW_ENCRYPTED_EXTENSIONS:
|
||||
return "TLSv1.3 write encrypted extensions";
|
||||
case TLS_ST_CR_ENCRYPTED_EXTENSIONS:
|
||||
return "TLSv1.3 read encrypted extensions";
|
||||
case TLS_ST_CR_CERT_VRFY:
|
||||
return "TLSv1.3 read server certificate verify";
|
||||
case TLS_ST_SW_CERT_VRFY:
|
||||
return "TLSv1.3 write server certificate verify";
|
||||
case TLS_ST_CR_HELLO_REQ:
|
||||
return "SSLv3/TLS read hello request";
|
||||
case TLS_ST_SW_KEY_UPDATE:
|
||||
return "TLSv1.3 write server key update";
|
||||
case TLS_ST_CW_KEY_UPDATE:
|
||||
return "TLSv1.3 write client key update";
|
||||
case TLS_ST_SR_KEY_UPDATE:
|
||||
return "TLSv1.3 read client key update";
|
||||
case TLS_ST_CR_KEY_UPDATE:
|
||||
return "TLSv1.3 read server key update";
|
||||
case TLS_ST_EARLY_DATA:
|
||||
return "TLSv1.3 early data";
|
||||
case TLS_ST_PENDING_EARLY_DATA_END:
|
||||
return "TLSv1.3 pending early data end";
|
||||
case TLS_ST_CW_END_OF_EARLY_DATA:
|
||||
return "TLSv1.3 write end of early data";
|
||||
case TLS_ST_SR_END_OF_EARLY_DATA:
|
||||
return "TLSv1.3 read end of early data";
|
||||
default:
|
||||
return "unknown state";
|
||||
}
|
||||
}
|
||||
|
||||
const char *SSL_get_cipher_name(const SSL *s)
|
||||
{
|
||||
SSL_ASSERT2(s);
|
||||
SSL_ASSERT2(s->session);
|
||||
|
||||
return s->session->cipher->name ? s->session->cipher->name : "(NONE)";
|
||||
}
|
||||
|
||||
const char *SSL_alert_type_string_long(int value)
|
||||
{
|
||||
switch (value >> 8)
|
||||
{
|
||||
case SSL3_AL_WARNING:
|
||||
return "warning";
|
||||
case SSL3_AL_FATAL:
|
||||
return "fatal";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
const char *SSL_alert_desc_string_long(int value)
|
||||
{
|
||||
switch (value & 0xff)
|
||||
{
|
||||
case SSL3_AD_CLOSE_NOTIFY:
|
||||
return "close notify";
|
||||
case SSL3_AD_UNEXPECTED_MESSAGE:
|
||||
return "unexpected message";
|
||||
case SSL3_AD_BAD_RECORD_MAC:
|
||||
return "bad record mac";
|
||||
case SSL3_AD_DECOMPRESSION_FAILURE:
|
||||
return "decompression failure";
|
||||
case SSL3_AD_HANDSHAKE_FAILURE:
|
||||
return "handshake failure";
|
||||
case SSL3_AD_NO_CERTIFICATE:
|
||||
return "no certificate";
|
||||
case SSL3_AD_BAD_CERTIFICATE:
|
||||
return "bad certificate";
|
||||
case SSL3_AD_UNSUPPORTED_CERTIFICATE:
|
||||
return "unsupported certificate";
|
||||
case SSL3_AD_CERTIFICATE_REVOKED:
|
||||
return "certificate revoked";
|
||||
case SSL3_AD_CERTIFICATE_EXPIRED:
|
||||
return "certificate expired";
|
||||
case SSL3_AD_CERTIFICATE_UNKNOWN:
|
||||
return "certificate unknown";
|
||||
case SSL3_AD_ILLEGAL_PARAMETER:
|
||||
return "illegal parameter";
|
||||
case TLS1_AD_DECRYPTION_FAILED:
|
||||
return "decryption failed";
|
||||
case TLS1_AD_RECORD_OVERFLOW:
|
||||
return "record overflow";
|
||||
case TLS1_AD_UNKNOWN_CA:
|
||||
return "unknown CA";
|
||||
case TLS1_AD_ACCESS_DENIED:
|
||||
return "access denied";
|
||||
case TLS1_AD_DECODE_ERROR:
|
||||
return "decode error";
|
||||
case TLS1_AD_DECRYPT_ERROR:
|
||||
return "decrypt error";
|
||||
case TLS1_AD_EXPORT_RESTRICTION:
|
||||
return "export restriction";
|
||||
case TLS1_AD_PROTOCOL_VERSION:
|
||||
return "protocol version";
|
||||
case TLS1_AD_INSUFFICIENT_SECURITY:
|
||||
return "insufficient security";
|
||||
case TLS1_AD_INTERNAL_ERROR:
|
||||
return "internal error";
|
||||
case TLS1_AD_USER_CANCELLED:
|
||||
return "user canceled";
|
||||
case TLS1_AD_NO_RENEGOTIATION:
|
||||
return "no renegotiation";
|
||||
case TLS1_AD_UNSUPPORTED_EXTENSION:
|
||||
return "unsupported extension";
|
||||
case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
|
||||
return "certificate unobtainable";
|
||||
case TLS1_AD_UNRECOGNIZED_NAME:
|
||||
return "unrecognized name";
|
||||
case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
|
||||
return "bad certificate status response";
|
||||
case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
|
||||
return "bad certificate hash value";
|
||||
case TLS1_AD_UNKNOWN_PSK_IDENTITY:
|
||||
return "unknown PSK identity";
|
||||
case TLS1_AD_NO_APPLICATION_PROTOCOL:
|
||||
return "no application protocol";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb)
|
||||
{
|
||||
ctx->default_passwd_callback = cb;
|
||||
}
|
||||
|
||||
void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u)
|
||||
{
|
||||
ctx->default_passwd_callback_userdata = u;
|
||||
}
|
||||
|
||||
void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, SSL_psk_client_cb_func cb)
|
||||
{
|
||||
ctx->psk_client_callback = cb;
|
||||
}
|
||||
|
||||
int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
long SSL_CTX_set_mode(SSL_CTX *ctx, long larg)
|
||||
{
|
||||
return ctx->mode |= larg;
|
||||
}
|
||||
|
||||
void SSL_CTX_set_info_callback(SSL_CTX *ctx,
|
||||
void (*cb)(const SSL *ssl, int type, int val))
|
||||
{
|
||||
ctx->info_callback = cb;
|
||||
}
|
||||
|
||||
void SSL_CTX_set_msg_callback(SSL_CTX *ctx,
|
||||
void (*cb)(int write_p, int version,
|
||||
int content_type, const void *buf,
|
||||
size_t len, SSL *ssl, void *arg))
|
||||
{
|
||||
ctx->msg_callback = cb;
|
||||
}
|
||||
|
||||
long SSL_set_tlsext_host_name(SSL *s, void *parg)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
SSL_ASSERT1(s);
|
||||
SSL_ASSERT1(s->session);
|
||||
|
||||
if (parg == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
len = strlen(parg);
|
||||
if (len == 0 || len > TLSEXT_MAXLEN_host_name)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(s->session->ext.hostname, 0, TLSEXT_MAXLEN_host_name);
|
||||
memcpy(s->session->ext.hostname, parg, len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SSL_CTX_load_verify_file(SSL_CTX *ctx, const char *CAfile)
|
||||
{
|
||||
X509 *x;
|
||||
int ret;
|
||||
|
||||
SSL_ASSERT1(ctx);
|
||||
SSL_ASSERT1(CAfile);
|
||||
|
||||
x = X509_new();
|
||||
ret = X509_METHOD_CALL(load_file, x, CAfile);
|
||||
if (ret)
|
||||
{
|
||||
X509_free(x);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SSL_CTX_add_client_CA(ctx, x);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SSL_CTX_load_verify_dir(SSL_CTX *ctx, const char *CApath)
|
||||
{
|
||||
X509 *x;
|
||||
int ret;
|
||||
|
||||
SSL_ASSERT1(ctx);
|
||||
SSL_ASSERT1(CApath);
|
||||
|
||||
x = X509_new();
|
||||
ret = X509_METHOD_CALL(load_path, x, CApath);
|
||||
if (ret)
|
||||
{
|
||||
X509_free(x);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SSL_CTX_add_client_CA(ctx, x);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
|
||||
const char *CApath)
|
||||
{
|
||||
if (CAfile == NULL && CApath == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (CAfile != NULL && !SSL_CTX_load_verify_file(ctx, CAfile))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (CApath != NULL && !SSL_CTX_load_verify_dir(ctx, CApath))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SSL_get_ex_new_index(long argl, void *argp,
|
||||
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
|
||||
CRYPTO_EX_free *free_func)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *SSL_get_cipher_list(const SSL *s, int n)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,8 +95,7 @@ IMPLEMENT_SSL_METHOD(SSL3_VERSION, -1, TLS_method_func, SSLv3_method);
|
|||
|
||||
IMPLEMENT_X509_METHOD(X509_method,
|
||||
x509_pm_new, x509_pm_free,
|
||||
x509_pm_load, x509_pm_load_file,
|
||||
x509_pm_load_path, x509_pm_show_info);
|
||||
x509_pm_load, x509_pm_show_info);
|
||||
|
||||
/**
|
||||
* @brief get private key object method
|
||||
|
|
|
|||
|
|
@ -27,9 +27,10 @@
|
|||
#include <openssl/ssl.h>
|
||||
#include "ssl_pm.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* TLS method function implement */
|
||||
|
||||
|
|
@ -41,7 +42,7 @@
|
|||
set_bufflen, \
|
||||
get_verify_result, \
|
||||
get_state) \
|
||||
static const SSL_METHOD_FUNC func_name = \
|
||||
static const SSL_METHOD_FUNC func_name LOCAL_ATRR = \
|
||||
{ \
|
||||
new, \
|
||||
free, \
|
||||
|
|
@ -61,7 +62,7 @@
|
|||
#define IMPLEMENT_TLS_METHOD(ver, mode, fun, func_name) \
|
||||
const SSL_METHOD* func_name(void) \
|
||||
{ \
|
||||
static const SSL_METHOD func_name##_data = \
|
||||
static const SSL_METHOD func_name##_data LOCAL_ATRR = \
|
||||
{ \
|
||||
ver, \
|
||||
mode, \
|
||||
|
|
@ -73,7 +74,7 @@
|
|||
#define IMPLEMENT_SSL_METHOD(ver, mode, fun, func_name) \
|
||||
const SSL_METHOD* func_name(void) \
|
||||
{ \
|
||||
static const SSL_METHOD func_name##_data = \
|
||||
static const SSL_METHOD func_name##_data LOCAL_ATRR = \
|
||||
{ \
|
||||
ver, \
|
||||
mode, \
|
||||
|
|
@ -86,18 +87,14 @@
|
|||
new, \
|
||||
free, \
|
||||
load, \
|
||||
load_file, \
|
||||
load_path, \
|
||||
show_info) \
|
||||
const X509_METHOD* func_name(void) \
|
||||
{ \
|
||||
static const X509_METHOD func_name##_data = \
|
||||
static const X509_METHOD func_name##_data LOCAL_ATRR = \
|
||||
{ \
|
||||
new, \
|
||||
free, \
|
||||
load, \
|
||||
load_file, \
|
||||
load_path, \
|
||||
show_info \
|
||||
}; \
|
||||
return &func_name##_data; \
|
||||
|
|
@ -109,7 +106,7 @@
|
|||
load) \
|
||||
const PKEY_METHOD* func_name(void) \
|
||||
{ \
|
||||
static const PKEY_METHOD func_name##_data = \
|
||||
static const PKEY_METHOD func_name##_data LOCAL_ATRR = \
|
||||
{ \
|
||||
new, \
|
||||
free, \
|
||||
|
|
@ -118,15 +115,6 @@
|
|||
return &func_name##_data; \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief get X509 object method
|
||||
*
|
||||
|
|
|
|||
|
|
@ -38,16 +38,7 @@
|
|||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/error.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define X509_INFO_STRING_LENGTH 8192
|
||||
#define READ_TIMEOUT_MS 50000 /* 50 seconds */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct ssl_pm
|
||||
{
|
||||
|
|
@ -67,7 +58,7 @@ struct ssl_pm
|
|||
|
||||
struct x509_pm
|
||||
{
|
||||
mbedtls_x509_crt x509_crt;
|
||||
mbedtls_x509_crt *x509_crt;
|
||||
mbedtls_x509_crt *ex_crt;
|
||||
};
|
||||
|
||||
|
|
@ -77,15 +68,10 @@ struct pkey_pm
|
|||
mbedtls_pk_context *ex_pkey;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
unsigned int max_content_len;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
/* mbedtls debug level */
|
||||
#define MBEDTLS_DEBUG_LEVEL 4
|
||||
|
||||
/**
|
||||
* @brief mbedtls debug function
|
||||
|
|
@ -148,7 +134,6 @@ int ssl_pm_new(SSL *ssl)
|
|||
mbedtls_ctr_drbg_init(&ssl_pm->ctr_drbg);
|
||||
mbedtls_entropy_init(&ssl_pm->entropy);
|
||||
mbedtls_ssl_init(&ssl_pm->ssl);
|
||||
mbedtls_ssl_conf_read_timeout(&ssl_pm->conf, READ_TIMEOUT_MS);
|
||||
|
||||
ret = mbedtls_ctr_drbg_seed(&ssl_pm->ctr_drbg, mbedtls_entropy_func,
|
||||
&ssl_pm->entropy, pers, pers_len);
|
||||
|
|
@ -225,8 +210,7 @@ int ssl_pm_new(SSL *ssl)
|
|||
}
|
||||
|
||||
mbedtls_ssl_set_bio(&ssl_pm->ssl, &ssl_pm->fd,
|
||||
mbedtls_net_send, mbedtls_net_recv,
|
||||
mbedtls_net_recv_timeout);
|
||||
mbedtls_net_send, mbedtls_net_recv, NULL);
|
||||
|
||||
ssl->ssl_pm = ssl_pm;
|
||||
|
||||
|
|
@ -265,7 +249,7 @@ void ssl_pm_free(SSL *ssl)
|
|||
|
||||
static int ssl_pm_reload_crt(SSL *ssl)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret;
|
||||
int mode;
|
||||
struct ssl_pm *ssl_pm = ssl->ssl_pm;
|
||||
struct x509_pm *ca_pm = (struct x509_pm *)ssl->client_CA->x509_pm;
|
||||
|
|
@ -291,16 +275,29 @@ static int ssl_pm_reload_crt(SSL *ssl)
|
|||
}
|
||||
|
||||
mbedtls_ssl_conf_authmode(&ssl_pm->conf, mode);
|
||||
mbedtls_ssl_conf_ca_chain(&ssl_pm->conf, &ca_pm->x509_crt, NULL);
|
||||
if (ca_pm->ex_crt)
|
||||
|
||||
if (ca_pm->x509_crt)
|
||||
{
|
||||
mbedtls_ssl_conf_ca_chain(&ssl_pm->conf, ca_pm->x509_crt, NULL);
|
||||
}
|
||||
else if (ca_pm->ex_crt)
|
||||
{
|
||||
mbedtls_ssl_conf_ca_chain(&ssl_pm->conf, ca_pm->ex_crt, NULL);
|
||||
}
|
||||
|
||||
if (pkey_pm->pkey)
|
||||
if (crt_pm->x509_crt && pkey_pm->pkey)
|
||||
{
|
||||
ret = mbedtls_ssl_conf_own_cert(&ssl_pm->conf,
|
||||
&crt_pm->x509_crt, pkey_pm->pkey);
|
||||
crt_pm->x509_crt, pkey_pm->pkey);
|
||||
}
|
||||
else if (crt_pm->ex_crt && pkey_pm->ex_pkey)
|
||||
{
|
||||
ret = mbedtls_ssl_conf_own_cert(&ssl_pm->conf,
|
||||
crt_pm->ex_crt, pkey_pm->ex_pkey);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
if (ret)
|
||||
|
|
@ -345,8 +342,7 @@ int ssl_pm_handshake(SSL *ssl)
|
|||
ret = ssl_pm_reload_crt(ssl);
|
||||
if (ret)
|
||||
{
|
||||
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
|
||||
"%s: cert reload failed\n", __func__);
|
||||
printf("%s: cert reload failed\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -368,21 +364,17 @@ int ssl_pm_handshake(SSL *ssl)
|
|||
}
|
||||
|
||||
/* OpenSSL return codes:
|
||||
* 0 = The TLS/SSL handshake was not successful but was shut down
|
||||
* controlled and by the specifications of the TLS/SSL protocol.
|
||||
* 0 = did not complete, but may be retried
|
||||
* 1 = successfully completed
|
||||
* <0 = The TLS/SSL handshake was not successful because a fatal error
|
||||
* occurred either at the protocol level or a connection failure
|
||||
* occurred.
|
||||
* <0 = death
|
||||
*/
|
||||
|
||||
if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE)
|
||||
{
|
||||
ssl->err = (ret == MBEDTLS_ERR_SSL_WANT_READ) ? SSL_ERROR_WANT_READ :
|
||||
SSL_ERROR_WANT_WRITE;
|
||||
ssl->err = ret;
|
||||
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
|
||||
"mbedtls_ssl_handshake() return -0x%x", -ret);
|
||||
return -1;
|
||||
return 0; /* OpenSSL: did not complete but may be retried */
|
||||
}
|
||||
|
||||
if (ret == 0)
|
||||
|
|
@ -401,11 +393,10 @@ int ssl_pm_handshake(SSL *ssl)
|
|||
{
|
||||
ssl->err = ret == MBEDTLS_ERR_SSL_WANT_READ;
|
||||
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
|
||||
"%s: mbedtls_ssl_handshake() returned -0x%x\n", __func__, -ret);
|
||||
printf("%s: mbedtls_ssl_handshake() returned -0x%x\n", __func__, -ret);
|
||||
|
||||
/* it's had it */
|
||||
|
||||
|
|
@ -424,7 +415,7 @@ ssl_ctx_get_mbedtls_x509_crt(SSL_CTX *ssl_ctx)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return &x509_pm->x509_crt;
|
||||
return x509_pm->x509_crt;
|
||||
}
|
||||
|
||||
mbedtls_x509_crt *
|
||||
|
|
@ -460,7 +451,7 @@ int ssl_pm_shutdown(SSL *ssl)
|
|||
else
|
||||
{
|
||||
struct x509_pm *x509_pm =
|
||||
(struct x509_pm *)ssl->session->peer->x509_pm;
|
||||
(struct x509_pm *)ssl->session->peer->x509_pm;
|
||||
|
||||
x509_pm->ex_crt = NULL;
|
||||
ret = 1; /* OpenSSL: "The shutdown was successfully completed"
|
||||
|
|
@ -490,22 +481,6 @@ int ssl_pm_read(SSL *ssl, void *buffer, int len)
|
|||
{
|
||||
ssl->err = SSL_ERROR_SYSCALL;
|
||||
}
|
||||
else if (ret == MBEDTLS_ERR_SSL_WANT_READ)
|
||||
{
|
||||
ssl->err = SSL_ERROR_WANT_READ;
|
||||
}
|
||||
else if (ret == MBEDTLS_ERR_SSL_WANT_WRITE)
|
||||
{
|
||||
ssl->err = SSL_ERROR_WANT_WRITE;
|
||||
}
|
||||
else if (ret == MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS)
|
||||
{
|
||||
ssl->err = SSL_ERROR_WANT_ASYNC;
|
||||
}
|
||||
else
|
||||
{
|
||||
ssl->err = SSL_ERROR_SSL;
|
||||
}
|
||||
|
||||
ret = -1;
|
||||
}
|
||||
|
|
@ -638,7 +613,7 @@ OSSL_HANDSHAKE_STATE ssl_pm_get_state(const SSL *ssl)
|
|||
case MBEDTLS_SSL_HANDSHAKE_OVER:
|
||||
state = TLS_ST_OK;
|
||||
break;
|
||||
default:
|
||||
default :
|
||||
state = TLS_ST_BEFORE;
|
||||
break;
|
||||
}
|
||||
|
|
@ -653,8 +628,20 @@ int x509_pm_show_info(X509 *x)
|
|||
mbedtls_x509_crt *x509_crt;
|
||||
struct x509_pm *x509_pm = x->x509_pm;
|
||||
|
||||
x509_crt = &x509_pm->x509_crt;
|
||||
if (x509_crt->version == 0)
|
||||
if (x509_pm->x509_crt)
|
||||
{
|
||||
x509_crt = x509_pm->x509_crt;
|
||||
}
|
||||
else if (x509_pm->ex_crt)
|
||||
{
|
||||
x509_crt = x509_pm->ex_crt;
|
||||
}
|
||||
else
|
||||
{
|
||||
x509_crt = NULL;
|
||||
}
|
||||
|
||||
if (!x509_crt)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -706,7 +693,7 @@ int x509_pm_new(X509 *x, X509 *m_x)
|
|||
{
|
||||
struct x509_pm *m_x509_pm = (struct x509_pm *)m_x->x509_pm;
|
||||
|
||||
x509_pm->ex_crt = &m_x509_pm->x509_crt;
|
||||
x509_pm->ex_crt = m_x509_pm->x509_crt;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -719,7 +706,14 @@ void x509_pm_free(X509 *x)
|
|||
{
|
||||
struct x509_pm *x509_pm = (struct x509_pm *)x->x509_pm;
|
||||
|
||||
mbedtls_x509_crt_free(&x509_pm->x509_crt);
|
||||
if (x509_pm->x509_crt)
|
||||
{
|
||||
mbedtls_x509_crt_free(x509_pm->x509_crt);
|
||||
|
||||
ssl_mem_free(x509_pm->x509_crt);
|
||||
x509_pm->x509_crt = NULL;
|
||||
}
|
||||
|
||||
ssl_mem_free(x->x509_pm);
|
||||
x->x509_pm = NULL;
|
||||
}
|
||||
|
|
@ -730,8 +724,23 @@ int x509_pm_load(X509 *x, const unsigned char *buffer, int len)
|
|||
unsigned char *load_buf;
|
||||
struct x509_pm *x509_pm = (struct x509_pm *)x->x509_pm;
|
||||
|
||||
mbedtls_x509_crt_free(&x509_pm->x509_crt);
|
||||
mbedtls_x509_crt_init(&x509_pm->x509_crt);
|
||||
if (x509_pm->x509_crt)
|
||||
{
|
||||
mbedtls_x509_crt_free(x509_pm->x509_crt);
|
||||
}
|
||||
|
||||
if (!x509_pm->x509_crt)
|
||||
{
|
||||
x509_pm->x509_crt = ssl_mem_malloc(sizeof(mbedtls_x509_crt));
|
||||
if (!x509_pm->x509_crt)
|
||||
{
|
||||
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
|
||||
"no enough memory > (x509_pm->x509_crt)");
|
||||
goto no_mem;
|
||||
}
|
||||
}
|
||||
|
||||
mbedtls_x509_crt_init(x509_pm->x509_crt);
|
||||
if (buffer[0] != 0x30)
|
||||
{
|
||||
load_buf = ssl_mem_malloc(len + 1);
|
||||
|
|
@ -745,67 +754,32 @@ int x509_pm_load(X509 *x, const unsigned char *buffer, int len)
|
|||
ssl_memcpy(load_buf, buffer, len);
|
||||
load_buf[len] = '\0';
|
||||
|
||||
ret = mbedtls_x509_crt_parse(&x509_pm->x509_crt, load_buf, len + 1);
|
||||
ret = mbedtls_x509_crt_parse(x509_pm->x509_crt, load_buf, len + 1);
|
||||
ssl_mem_free(load_buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL, "parsing as der\n");
|
||||
ret = mbedtls_x509_crt_parse_der(&x509_pm->x509_crt, buffer, len);
|
||||
printf("parsing as der\n");
|
||||
|
||||
ret = mbedtls_x509_crt_parse_der(x509_pm->x509_crt, buffer, len);
|
||||
}
|
||||
|
||||
if (ret)
|
||||
{
|
||||
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
|
||||
"mbedtls_x509_crt_parse return -0x%x", -ret);
|
||||
printf("mbedtls_x509_crt_parse return -0x%x", -ret);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
failed:
|
||||
mbedtls_x509_crt_free(&x509_pm->x509_crt);
|
||||
mbedtls_x509_crt_free(x509_pm->x509_crt);
|
||||
ssl_mem_free(x509_pm->x509_crt);
|
||||
x509_pm->x509_crt = NULL;
|
||||
no_mem:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int x509_pm_load_file(X509 *x, const char *path)
|
||||
{
|
||||
int ret;
|
||||
struct x509_pm *x509_pm = (struct x509_pm *)x->x509_pm;
|
||||
|
||||
mbedtls_x509_crt_free(&x509_pm->x509_crt);
|
||||
mbedtls_x509_crt_init(&x509_pm->x509_crt);
|
||||
ret = mbedtls_x509_crt_parse_file(&x509_pm->x509_crt, path);
|
||||
if (ret)
|
||||
{
|
||||
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
|
||||
"mbedtls_x509_crt_parse_file return -0x%x", -ret);
|
||||
mbedtls_x509_crt_free(&x509_pm->x509_crt);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int x509_pm_load_path(X509 *x, const char *path)
|
||||
{
|
||||
int ret;
|
||||
struct x509_pm *x509_pm = (struct x509_pm *)x->x509_pm;
|
||||
|
||||
mbedtls_x509_crt_free(&x509_pm->x509_crt);
|
||||
mbedtls_x509_crt_init(&x509_pm->x509_crt);
|
||||
ret = mbedtls_x509_crt_parse_path(&x509_pm->x509_crt, path);
|
||||
if (ret)
|
||||
{
|
||||
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
|
||||
"mbedtls_x509_crt_parse_file return -0x%x", -ret);
|
||||
mbedtls_x509_crt_free(&x509_pm->x509_crt);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pkey_pm_new(EVP_PKEY *pk, EVP_PKEY *m_pkey)
|
||||
{
|
||||
struct pkey_pm *pkey_pm;
|
||||
|
|
@ -1003,8 +977,7 @@ void _ssl_set_alpn_list(const SSL *ssl)
|
|||
&((struct ssl_pm *)(ssl->ssl_pm))->conf,
|
||||
ssl->alpn_protos))
|
||||
{
|
||||
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
|
||||
"mbedtls_ssl_conf_alpn_protocols failed\n");
|
||||
fprintf(stderr, "mbedtls_ssl_conf_alpn_protocols failed\n");
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
@ -1019,8 +992,7 @@ void _ssl_set_alpn_list(const SSL *ssl)
|
|||
&((struct ssl_pm *)(ssl->ssl_pm))->conf,
|
||||
ssl->ctx->alpn_protos))
|
||||
{
|
||||
SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL,
|
||||
"mbedtls_ssl_conf_alpn_protocols failed\n");
|
||||
fprintf(stderr, "mbedtls_ssl_conf_alpn_protocols failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1098,8 +1070,8 @@ void SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
|
|||
|
||||
ssl->verify_mode = ctx->verify_mode;
|
||||
|
||||
mbedtls_ssl_set_hs_ca_chain(&ssl_pm->ssl, &x509_pm_ca->x509_crt, NULL);
|
||||
mbedtls_ssl_set_hs_own_cert(&ssl_pm->ssl, &x509_pm->x509_crt,
|
||||
mbedtls_ssl_set_hs_ca_chain(&ssl_pm->ssl, x509_pm_ca->x509_crt, NULL);
|
||||
mbedtls_ssl_set_hs_own_cert(&ssl_pm->ssl, x509_pm->x509_crt,
|
||||
pkey_pm->pkey);
|
||||
mbedtls_ssl_set_hs_authmode(&ssl_pm->ssl, mode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,9 +33,7 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
#define LOCAL_ATRR
|
||||
|
||||
int ssl_pm_new(SSL *ssl);
|
||||
void ssl_pm_free(SSL *ssl);
|
||||
|
|
@ -59,8 +57,6 @@ int x509_pm_show_info(X509 *x);
|
|||
int x509_pm_new(X509 *x, X509 *m_x);
|
||||
void x509_pm_free(X509 *x);
|
||||
int x509_pm_load(X509 *x, const unsigned char *buffer, int len);
|
||||
int x509_pm_load_file(X509 *x, const char *path);
|
||||
int x509_pm_load_path(X509 *x, const char *path);
|
||||
|
||||
int pkey_pm_new(EVP_PKEY *pk, EVP_PKEY *m_pk);
|
||||
void pkey_pm_free(EVP_PKEY *pk);
|
||||
|
|
|
|||
|
|
@ -124,11 +124,6 @@ int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SSL_use_certificate_file(SSL *ssl, const char *file, int type)
|
||||
{
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ if(CONFIG_TINYCRYPT)
|
|||
# Sources
|
||||
# ############################################################################
|
||||
|
||||
list(APPEND CFLAGS -Dunix)
|
||||
set(CSRCS
|
||||
${TINYCRYPT_DIR}/lib/source/utils.c ${TINYCRYPT_DIR}/lib/source/ecc.c
|
||||
${TINYCRYPT_DIR}/lib/source/ecc_platform_specific.c)
|
||||
|
|
@ -121,7 +120,7 @@ if(CONFIG_TINYCRYPT)
|
|||
if(CONFIG_TINYCRYPT_TEST)
|
||||
list(APPEND CSRCS ${TINYCRYPT_DIR}/tests/test_ecc_utils.c)
|
||||
list(APPEND INCDIR ${TINYCRYPT_DIR}/tests/include)
|
||||
list(APPEND CFLAGS -DENABLE_TESTS)
|
||||
set(CFLAGS -Dhex2bin=ltp_hex2bin -DENABLE_TESTS)
|
||||
|
||||
nuttx_add_application(
|
||||
NAME
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ distclean::
|
|||
$(Q) rm -rf $(TINYCRYPT_UNPACKNAME)
|
||||
endif
|
||||
|
||||
CFLAGS += ${DEFINE_PREFIX}unix
|
||||
CSRCS += tinycrypt/lib/source/utils.c
|
||||
|
||||
ifeq ($(CONFIG_TINYCRYPT_ECC),y)
|
||||
|
|
@ -104,11 +103,11 @@ ifeq ($(CONFIG_TINYCRYPT_CTR_PRNG),y)
|
|||
CSRCS += tinycrypt/lib/source/ctr_prng.c
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_TINYCRYPT_TEST),)
|
||||
ifeq ($(CONFIG_TINYCRYPT_TEST),y)
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/crypto/tinycrypt/tinycrypt/tests/include
|
||||
CFLAGS += -DENABLE_TESTS
|
||||
CFLAGS +=-Dhex2bin=ltp_hex2bin
|
||||
CFLAGS +=-DENABLE_TESTS
|
||||
CSRCS += tinycrypt/tests/test_ecc_utils.c
|
||||
MODULE += $(CONFIG_TINYCRYPT_TEST)
|
||||
PRIORITY = $(CONFIG_TINYCRYPT_TEST_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_TINYCRYPT_TEST_STACKSIZE)
|
||||
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ distclean::
|
|||
$(call DELDIR, $(WOLFSSL_UNPACKNAME))
|
||||
$(call DELDIR, $(WOLFSSL_EXAMPLESNAME))
|
||||
else
|
||||
distclean::
|
||||
distclean:
|
||||
$(call DELDIR, $(WOLFSSL_UNPACKNAME))
|
||||
endif
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ ifneq ($(CONFIG_UTILS_SQLITE),)
|
|||
PROGNAME = sqlite3
|
||||
PRIORITY = 100
|
||||
STACKSIZE = ${CONFIG_UTILS_SQLITE_STACKSIZE}
|
||||
MODULE = $(CONFIG_UTILS_SQLITE)
|
||||
MAINSRC = ${BUILDDIR}/shell.c
|
||||
endif
|
||||
|
||||
|
|
@ -68,3 +67,4 @@ ifeq ($(wildcard sqlite/.git),)
|
|||
endif
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <nuttx/debug.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/analog/adc.h>
|
||||
#include <nuttx/analog/ioctl.h>
|
||||
|
|
@ -95,7 +95,7 @@ static void adc_help(FAR struct adc_state_s *adc)
|
|||
printf("Usage: adc [OPTIONS]\n");
|
||||
printf("\nArguments are \"sticky\". "
|
||||
"For example, once the ADC device is\n");
|
||||
printf("specified, that device will be reused until it is changed.\n");
|
||||
printf("specified, that device will be re-used until it is changed.\n");
|
||||
printf("\n\"sticky\" OPTIONS include:\n");
|
||||
printf(" [-p devpath] selects the ADC device. "
|
||||
"Default: %s Current: %s\n",
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
|
@ -150,8 +149,8 @@ int main(int argc, FAR char *argv[])
|
|||
|
||||
parse_args(&delta, argc, argv);
|
||||
|
||||
printf("Delta time is %jd seconds and %ld micro seconds.\n",
|
||||
(intmax_t)delta.tv_sec, delta.tv_usec);
|
||||
printf("Delta time is %ld seconds and %ld micro seconds.\n",
|
||||
(long)delta.tv_sec, delta.tv_usec);
|
||||
|
||||
/* Call adjtime function. */
|
||||
|
||||
|
|
@ -162,8 +161,8 @@ int main(int argc, FAR char *argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
printf("Returned olddelta is %jd seconds and %ld micro seconds.\n",
|
||||
(intmax_t)olddelta.tv_sec, olddelta.tv_usec);
|
||||
printf("Returned olddelta is %ld seconds and %ld micro seconds.\n",
|
||||
(long)olddelta.tv_sec, olddelta.tv_usec);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <fixedmath.h>
|
||||
#include <nuttx/debug.h>
|
||||
#include <debug.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <nuttx/input/ajoystick.h>
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ int main(int argc, FAR char *argv[])
|
|||
|
||||
setrel.id = alarmid;
|
||||
setrel.pid = g_alarm_daemon_pid;
|
||||
setrel.reltime = seconds;
|
||||
setrel.reltime = (time_t)seconds;
|
||||
|
||||
setrel.event.sigev_notify = SIGEV_SIGNAL;
|
||||
setrel.event.sigev_signo = CONFIG_EXAMPLES_ALARM_SIGNO;
|
||||
|
|
|
|||
|
|
@ -29,5 +29,5 @@ if(CONFIG_EXAMPLES_AUDIO_SOUND)
|
|||
STACKSIZE
|
||||
${CONFIG_EXAMPLES_AUDIO_SOUND_STACKSIZE}
|
||||
SRCS
|
||||
audio_rttl_main.c)
|
||||
audio_rttl.cxx)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@
|
|||
|
||||
config EXAMPLES_AUDIO_SOUND
|
||||
bool "Audio tone generator example (RTTL player)"
|
||||
depends on AUDIO
|
||||
depends on AUDIOUTILS_RTTTL_C
|
||||
default n
|
||||
---help---
|
||||
Enable the audio RTTL player example.
|
||||
Enable the audio RTTL player example
|
||||
|
||||
if EXAMPLES_AUDIO_SOUND
|
||||
|
||||
|
|
@ -25,12 +23,4 @@ config EXAMPLES_AUDIO_SOUND_STACKSIZE
|
|||
int "Audio sound stack size"
|
||||
default DEFAULT_TASK_STACKSIZE
|
||||
|
||||
comment "Program options"
|
||||
|
||||
config EXAMPLES_AUDIO_SOUND_MAXLEN
|
||||
int "Maximum RTTL string length"
|
||||
default 256
|
||||
---help---
|
||||
The maximum length of an RTTL string that can be read from a file.
|
||||
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -30,6 +30,6 @@ STACKSIZE = $(CONFIG_EXAMPLES_AUDIO_SOUND_STACKSIZE)
|
|||
|
||||
# Audio Example
|
||||
|
||||
MAINSRC = audio_rttl_main.c
|
||||
MAINSRC = audio_rttl.cxx
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
|
|
|
|||
361
examples/audio_rttl/audio_rttl.cxx
Normal file
361
examples/audio_rttl/audio_rttl.cxx
Normal file
|
|
@ -0,0 +1,361 @@
|
|||
/****************************************************************************
|
||||
* apps/examples/audio_rttl/audio_rttl.cxx
|
||||
*
|
||||
* 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 <math.h>
|
||||
#include <string.h>
|
||||
#include <arch/board/board.h>
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
#include "audio_rttl.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Note - note freq on octave 1 */
|
||||
|
||||
#define C 16.35
|
||||
#define CD 17.32
|
||||
#define D 18.35
|
||||
#define DE 19.45
|
||||
#define E 20.60
|
||||
#define F 21.83
|
||||
#define FG 23.12
|
||||
#define G 24.50
|
||||
#define A 27.50
|
||||
#define AB 29.14
|
||||
#define B 30.84
|
||||
|
||||
/* Octave - base freq multiplier for the base freq */
|
||||
|
||||
#define OCT2 4
|
||||
#define OCT3 8
|
||||
#define OCT4 16
|
||||
#define OCT5 32
|
||||
#define OCT6 64
|
||||
#define OCT7 128
|
||||
#define OCT8 256
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
extern "C" int main(int argc, FAR char *argv[])
|
||||
{
|
||||
int freq;
|
||||
float base_freq;
|
||||
char temp_note;
|
||||
int octave;
|
||||
int duration;
|
||||
int note_duration;
|
||||
int base_duration;
|
||||
int bpm;
|
||||
int cnt;
|
||||
|
||||
/* Set I/O parameters for power on. */
|
||||
|
||||
if (!board_audio_power_control(true))
|
||||
{
|
||||
printf("Error: board_audio_power_control() failure.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Start Audio RTTL player\n");
|
||||
|
||||
bpm = 0;
|
||||
octave = 0;
|
||||
base_duration = 0;
|
||||
note_duration = 0;
|
||||
|
||||
while (*g_song != ':')
|
||||
{
|
||||
g_song++;
|
||||
}
|
||||
|
||||
g_song++;
|
||||
|
||||
if (*g_song == 'd')
|
||||
{
|
||||
g_song = g_song + 2;
|
||||
base_duration = *g_song - '0';
|
||||
g_song++;
|
||||
if ((*g_song >= '0') && (*g_song <= '9'))
|
||||
{
|
||||
base_duration = (base_duration * 10) + (*g_song - '0');
|
||||
g_song++;
|
||||
}
|
||||
|
||||
g_song++;
|
||||
}
|
||||
|
||||
if (*g_song == 'o')
|
||||
{
|
||||
g_song = g_song + 2;
|
||||
octave = *g_song - '0';
|
||||
g_song = g_song + 2;
|
||||
}
|
||||
|
||||
if (octave == 2)
|
||||
{
|
||||
octave = OCT2;
|
||||
}
|
||||
else if (octave == 3)
|
||||
{
|
||||
octave = OCT3;
|
||||
}
|
||||
else if (octave == 4)
|
||||
{
|
||||
octave = OCT4;
|
||||
}
|
||||
else if (octave == 5)
|
||||
{
|
||||
octave = OCT5;
|
||||
}
|
||||
else if (octave == 6)
|
||||
{
|
||||
octave = OCT6;
|
||||
}
|
||||
else if (octave == 7)
|
||||
{
|
||||
octave = OCT7;
|
||||
}
|
||||
else if (octave == 8)
|
||||
{
|
||||
octave = OCT8;
|
||||
}
|
||||
|
||||
if (*g_song == 'b')
|
||||
{
|
||||
g_song = g_song + 2;
|
||||
bpm = 0;
|
||||
for (cnt = 1; cnt <= 3; cnt++)
|
||||
{
|
||||
if (*g_song != ':')
|
||||
{
|
||||
bpm = bpm * 10 + (*g_song - '0');
|
||||
g_song++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
g_song++;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ((*g_song >= '0') && (*g_song <= '9'))
|
||||
{
|
||||
note_duration = *g_song - '0';
|
||||
g_song++;
|
||||
}
|
||||
|
||||
if ((*g_song >= '0') && (*g_song <= '9'))
|
||||
{
|
||||
note_duration = (note_duration * 10) + (*g_song - '0');
|
||||
g_song++;
|
||||
}
|
||||
|
||||
if (note_duration > 0)
|
||||
{
|
||||
duration = ((60 * 1000L / bpm) * 4) / note_duration;
|
||||
}
|
||||
else
|
||||
{
|
||||
duration = ((60 * 1000L / bpm) * 4) / base_duration;
|
||||
}
|
||||
|
||||
base_freq = 0;
|
||||
temp_note = ' ';
|
||||
switch (*g_song)
|
||||
{
|
||||
case 'c':
|
||||
{
|
||||
temp_note = 'c';
|
||||
base_freq = C;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'd':
|
||||
{
|
||||
temp_note = 'd';
|
||||
base_freq = D;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'e':
|
||||
{
|
||||
temp_note = 'e';
|
||||
base_freq = E;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'f':
|
||||
{
|
||||
temp_note = 'f';
|
||||
base_freq = F;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'g':
|
||||
{
|
||||
temp_note = 'g';
|
||||
base_freq = G;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'a':
|
||||
{
|
||||
temp_note = 'a';
|
||||
base_freq = A;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'b':
|
||||
{
|
||||
temp_note = 'b';
|
||||
base_freq = B;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'p':
|
||||
{
|
||||
temp_note = 'p';
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
g_song++;
|
||||
|
||||
if (*g_song == '.')
|
||||
{
|
||||
duration += duration / 2;
|
||||
g_song++;
|
||||
}
|
||||
|
||||
if (*g_song == '#')
|
||||
{
|
||||
if (temp_note == 'c')
|
||||
{
|
||||
base_freq = CD;
|
||||
}
|
||||
|
||||
if (temp_note == 'd')
|
||||
{
|
||||
base_freq = DE;
|
||||
}
|
||||
|
||||
if (temp_note == 'f')
|
||||
{
|
||||
base_freq = FG;
|
||||
}
|
||||
|
||||
if (temp_note == 'a')
|
||||
{
|
||||
base_freq = AB;
|
||||
}
|
||||
|
||||
g_song++;
|
||||
}
|
||||
|
||||
if ((*g_song - '0') == '2')
|
||||
{
|
||||
octave = OCT2;
|
||||
}
|
||||
|
||||
if ((*g_song - '0') == '3')
|
||||
{
|
||||
octave = OCT3;
|
||||
}
|
||||
|
||||
if ((*g_song - '0') == '4')
|
||||
{
|
||||
octave = OCT4;
|
||||
}
|
||||
|
||||
if ((*g_song - '0') == '5')
|
||||
{
|
||||
octave = OCT5;
|
||||
}
|
||||
|
||||
if ((*g_song - '0') == '6')
|
||||
{
|
||||
octave = OCT6;
|
||||
}
|
||||
|
||||
if ((*g_song - '0') == '7')
|
||||
{
|
||||
octave = OCT7;
|
||||
}
|
||||
|
||||
if ((*g_song - '0') == '8')
|
||||
{
|
||||
octave = OCT8;
|
||||
}
|
||||
|
||||
g_song++;
|
||||
|
||||
if (*g_song == ',')
|
||||
{
|
||||
g_song++;
|
||||
}
|
||||
|
||||
/* play the sound */
|
||||
|
||||
freq = ceil(base_freq * octave);
|
||||
|
||||
if (!board_audio_tone_generator(1, -40, freq))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
usleep(duration * 1000L);
|
||||
}
|
||||
while (*g_song);
|
||||
|
||||
/* Sound off. */
|
||||
|
||||
if (!board_audio_tone_generator(0, 0, 0))
|
||||
{
|
||||
printf("Error: board_audio_tone_generator() failure.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Set I/O parameters for power off. */
|
||||
|
||||
if (!board_audio_power_control(false))
|
||||
{
|
||||
printf("Error: board_audio_power_control() failure.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Done.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/****************************************************************************
|
||||
* apps/testing/nuts/tests.h
|
||||
* apps/examples/audio_rttl/audio_rttl.h
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
|
|
@ -20,14 +20,5 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_TESTING_NUTS_TESTS_H
|
||||
#define __APPS_TESTING_NUTS_TESTS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "dstructs/tests.h"
|
||||
#include "devices/tests.h"
|
||||
|
||||
#endif /* __APPS_TESTING_NUTS_TESTS_H */
|
||||
FAR char *g_song = (FAR char *)
|
||||
"Test:d=4,o=6,b=90:c,c#,d,d#,e,f,f#,g,a,a#,b,p,b,a#,a,g,f#,f,e,d#,d,c#,c";
|
||||
|
|
@ -1,305 +0,0 @@
|
|||
/****************************************************************************
|
||||
* apps/examples/audio_rttl/audio_rttl_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 <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifdef CONFIG_PWM
|
||||
#include <nuttx/timers/pwm.h>
|
||||
#endif
|
||||
|
||||
#include <audioutils/rtttl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct player_s
|
||||
{
|
||||
void (*play)(struct rtttl_tone); /* Play RTTTL sound function */
|
||||
void (*teardown)(void); /* Clean-up function */
|
||||
void *arg; /* Private data for functions */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* Default song if none was passed. Otherwise, used as buffer for reading
|
||||
* from a file.
|
||||
*/
|
||||
|
||||
static char g_default_song[CONFIG_EXAMPLES_AUDIO_SOUND_MAXLEN] =
|
||||
"Test:d=4,o=6,b=90:c,c#,d,d#,e,f,f#,g,a,a#,b,p,b,a#,a,g,"
|
||||
"f#,f,e,d#,d,c#,c";
|
||||
|
||||
/* The selected player is a global variable so it can be accessed from within
|
||||
* the player functions properly.
|
||||
*/
|
||||
|
||||
static struct player_s g_player;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: play_default
|
||||
*
|
||||
* Description:
|
||||
* The default player choice; prints an error and exits.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sound - The sound to play
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void play_default(struct rtttl_tone sound)
|
||||
{
|
||||
fprintf(stderr, "No player selected!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: teardown_default
|
||||
*
|
||||
* Description:
|
||||
* Default tear-down function. Does nothing.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void teardown_default(void)
|
||||
{
|
||||
/* No-op */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PWM
|
||||
|
||||
/****************************************************************************
|
||||
* Name: play_pwm
|
||||
*
|
||||
* Description:
|
||||
* RTTTL player for audio sinks using PWM devices
|
||||
*
|
||||
* Input Parameters:
|
||||
* sound - The sound to play
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void play_pwm(struct rtttl_tone sound)
|
||||
{
|
||||
int err;
|
||||
int i;
|
||||
struct pwm_info_s info;
|
||||
int fd = *((int *)g_player.arg);
|
||||
|
||||
info.channels[0].channel = 1;
|
||||
info.channels[0].duty = b16divi(uitoub16(50) - 1, 100); /* 50% duty cycle */
|
||||
info.channels[0].cpol = PWM_CPOL_NDEF; /* Default */
|
||||
info.channels[0].dcpol = PWM_DCPOL_NDEF; /* Default */
|
||||
info.frequency = sound.frequency_100hz / 100;
|
||||
|
||||
/* Copy settings to all channels */
|
||||
|
||||
for (i = 1; i < CONFIG_PWM_NCHANNELS; i++)
|
||||
{
|
||||
info.channels[i] = info.channels[0];
|
||||
info.channels[i].channel = i + 1;
|
||||
}
|
||||
|
||||
err = ioctl(fd, PWMIOC_SETCHARACTERISTICS, &info);
|
||||
if (err < 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to set PWM characteristics: %d\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
err = ioctl(fd, PWMIOC_START, 0);
|
||||
if (err < 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to start PWM: %d\n", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
usleep(sound.duration_us); /* Wait */
|
||||
|
||||
err = ioctl(fd, PWMIOC_STOP, 0);
|
||||
if (err < 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to stop PWM: %d\n", errno);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: teardown_pwm
|
||||
*
|
||||
* Description:
|
||||
* Teardown function for PWM players
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void teardown_pwm(void)
|
||||
{
|
||||
int fd = *((int *)g_player.arg);
|
||||
close(fd);
|
||||
}
|
||||
#endif /* CONFIG_PWM */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: print_usage
|
||||
*
|
||||
* Description:
|
||||
* Prints out the usage information for the program.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sink - The stream to output the usage information
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void print_usage(FILE *sink)
|
||||
{
|
||||
fprintf(sink, "USAGE: audio_rttl <device path> [-s string] [-f file]\n");
|
||||
fprintf(sink, "Ex: audio_rttl /dev/tone0\n");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, FAR char *argv[])
|
||||
{
|
||||
int err;
|
||||
int fd;
|
||||
int c;
|
||||
FILE *fptr;
|
||||
size_t bread;
|
||||
const char *song = g_default_song;
|
||||
const char *device = NULL;
|
||||
const char *file = NULL;
|
||||
|
||||
g_player.play = play_default;
|
||||
g_player.teardown = teardown_default;
|
||||
g_player.arg = NULL;
|
||||
|
||||
while ((c = getopt(argc, argv, ":hs:f:")) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'h':
|
||||
print_usage(stdout);
|
||||
break;
|
||||
case 's':
|
||||
song = optarg;
|
||||
break;
|
||||
case 'f':
|
||||
file = optarg;
|
||||
break;
|
||||
case '?':
|
||||
fprintf(stderr, "Unknown option -%c\n", optopt);
|
||||
print_usage(stderr);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc <= optind)
|
||||
{
|
||||
fprintf(stderr, "Missing argument for device path.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
device = argv[optind++];
|
||||
|
||||
/* Based on the device path, we choose which player should be used and
|
||||
* perform the setup.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_PWM
|
||||
if (strstr(device, "pwm"))
|
||||
{
|
||||
fd = open(device, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to open %s: %d\n", device, errno);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_player.arg = &fd;
|
||||
}
|
||||
|
||||
g_player.play = play_pwm;
|
||||
g_player.teardown = teardown_pwm;
|
||||
}
|
||||
#endif /* CONFIG_PWM */
|
||||
|
||||
/* If the user passed a file and a song string, use the string. Otherwise,
|
||||
* read from the file
|
||||
*/
|
||||
|
||||
if (file != NULL && song == g_default_song)
|
||||
{
|
||||
fptr = fopen(file, "r");
|
||||
if (fptr == NULL)
|
||||
{
|
||||
fprintf(stderr, "Couldn't open file '%s': %d", file, errno);
|
||||
g_player.teardown();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
bread =
|
||||
fread(g_default_song, sizeof(char), sizeof(g_default_song), fptr);
|
||||
|
||||
/* Ensure null termination of the string. */
|
||||
|
||||
if (bread <= sizeof(g_default_song))
|
||||
{
|
||||
g_default_song[bread - 1] = '\0';
|
||||
}
|
||||
|
||||
fclose(fptr);
|
||||
}
|
||||
|
||||
/* Play the song */
|
||||
|
||||
err = rtttl_play(song, g_player.play);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to play song: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Tear down the player and exit */
|
||||
|
||||
g_player.teardown();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
# ##############################################################################
|
||||
# apps/examples/baromonitor/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_EXAMPLES_BAROMONITOR)
|
||||
nuttx_add_application(
|
||||
NAME
|
||||
${CONFIG_EXAMPLES_BAROMONITOR_PROGNAME}
|
||||
PRIORITY
|
||||
${CONFIG_EXAMPLES_BAROMONITOR_PRIORITY}
|
||||
STACKSIZE
|
||||
${CONFIG_EXAMPLES_BAROMONITOR_STACKSIZE}
|
||||
MODULE
|
||||
${CONFIG_EXAMPLES_BAROMONITOR}
|
||||
SRCS
|
||||
baromonitor_main.c)
|
||||
endif()
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config EXAMPLES_BAROMONITOR
|
||||
tristate "Barometer monitoring dashboard example"
|
||||
default n
|
||||
depends on UORB
|
||||
depends on LIBC_FLOATINGPOINT
|
||||
depends on GRAPHICS_LVGL
|
||||
depends on LV_USE_NUTTX
|
||||
depends on LV_FONT_MONTSERRAT_24
|
||||
depends on LV_FONT_MONTSERRAT_32
|
||||
---help---
|
||||
Enable the barometer monitoring dashboard.
|
||||
|
||||
if EXAMPLES_BAROMONITOR
|
||||
|
||||
config EXAMPLES_BAROMONITOR_PROGNAME
|
||||
string "Program name"
|
||||
default "baromonitor"
|
||||
|
||||
config EXAMPLES_BAROMONITOR_PRIORITY
|
||||
int "Barometer monitor task priority"
|
||||
default 100
|
||||
|
||||
config EXAMPLES_BAROMONITOR_STACKSIZE
|
||||
int "Baromonitor stack size"
|
||||
default DEFAULT_TASK_STACKSIZE
|
||||
|
||||
config EXAMPLES_BAROMONITOR_SAMPLERATE
|
||||
int "Sample rate (ms)"
|
||||
default 50
|
||||
---help---
|
||||
Sample rate in milliseconds of barometer data.
|
||||
|
||||
endif # EXAMPLES_BARO_DASHBOARD
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
############################################################################
|
||||
# apps/examples/baromonitor/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_EXAMPLES_BAROMONITOR),)
|
||||
CONFIGURED_APPS += $(APPDIR)/examples/baromonitor
|
||||
endif
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
############################################################################
|
||||
# apps/examples/baromonitor/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
|
||||
|
||||
# BAROMONITOR Barometer sensor example built-in application info
|
||||
|
||||
PROGNAME = $(CONFIG_EXAMPLES_BAROMONITOR_PROGNAME)
|
||||
PRIORITY = $(CONFIG_EXAMPLES_BAROMONITOR_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_EXAMPLES_BAROMONITOR_STACKSIZE)
|
||||
MODULE = $(CONFIG_EXAMPLES_BAROMONITOR)
|
||||
|
||||
# BAROMONITOR Barometer sensor example
|
||||
|
||||
MAINSRC = baromonitor_main.c
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
|
|
@ -1,419 +0,0 @@
|
|||
/****************************************************************************
|
||||
* apps/examples/baromonitor/baromonitor_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/config.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
#include <nuttx/sensors/sensor.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define PRESSURE_COLOUR 0xef4444
|
||||
#define TEMPERATURE_COLOUR 0x6366f1
|
||||
|
||||
#define LINE_WIDTH (8)
|
||||
#define GAUGE_SIZE (600)
|
||||
|
||||
/* Axis limits */
|
||||
|
||||
#define PRESS_MIN (960)
|
||||
#define PRESS_MAX (1010)
|
||||
|
||||
#define TEMP_MIN (-30)
|
||||
#define TEMP_MAX (60)
|
||||
#define TEMP_THRESH (TEMP_MAX - 10)
|
||||
|
||||
#define PRESS_MAJOR_TICKS_EVERY (5)
|
||||
#define TEMP_MAJOR_TICKS_EVERY (5)
|
||||
|
||||
#define NUM_TEMP_LABELS ((TEMP_MAX - TEMP_MIN) / TEMP_MAJOR_TICKS_EVERY)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const char *g_temp_labels[NUM_TEMP_LABELS + 1];
|
||||
static char g_label_buf[NUM_TEMP_LABELS][8];
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
|
||||
static void lv_nuttx_uv_loop(uv_loop_t *loop, lv_nuttx_result_t *result)
|
||||
{
|
||||
lv_nuttx_uv_t uv_info;
|
||||
void *data;
|
||||
|
||||
uv_loop_init(loop);
|
||||
|
||||
lv_memset(&uv_info, 0, sizeof(uv_info));
|
||||
uv_info.loop = loop;
|
||||
uv_info.disp = result->disp;
|
||||
uv_info.indev = result->indev;
|
||||
#ifdef CONFIG_UINPUT_TOUCH
|
||||
uv_info.uindev = result->utouch_indev;
|
||||
#endif
|
||||
|
||||
data = lv_nuttx_uv_init(&uv_info);
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
lv_nuttx_uv_deinit(&data);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void set_column_flex(lv_obj_t *obj)
|
||||
{
|
||||
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_style_flex_main_place(obj, LV_FLEX_ALIGN_CENTER, 0);
|
||||
lv_obj_set_style_flex_cross_place(obj, LV_FLEX_ALIGN_CENTER, 0);
|
||||
lv_obj_set_style_flex_track_place(obj, LV_FLEX_ALIGN_CENTER, 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* baromonitor_main
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, FAR char *argv[])
|
||||
{
|
||||
lv_nuttx_dsc_t info;
|
||||
lv_nuttx_result_t result;
|
||||
lv_obj_t *screen;
|
||||
lv_obj_t *gauge_cont;
|
||||
lv_obj_t *press_gauge;
|
||||
lv_obj_t *press_line;
|
||||
lv_obj_t *press_cont;
|
||||
lv_obj_t *press_label;
|
||||
lv_obj_t *temp_gauge;
|
||||
lv_obj_t *temp_line;
|
||||
lv_obj_t *temp_cont;
|
||||
lv_obj_t *temp_label;
|
||||
lv_obj_t *title_cont;
|
||||
lv_obj_t *title;
|
||||
lv_scale_section_t *section;
|
||||
lv_style_t indicator_style;
|
||||
lv_style_t minor_ticks_style;
|
||||
lv_style_t main_line_style;
|
||||
lv_style_t section_label_style;
|
||||
lv_style_t section_minor_ticks_style;
|
||||
lv_style_t section_main_line_style;
|
||||
|
||||
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
|
||||
uv_loop_t ui_loop;
|
||||
#endif
|
||||
|
||||
int err;
|
||||
int fd;
|
||||
bool got_data;
|
||||
struct sensor_baro sensor_data;
|
||||
unsigned instance = 0;
|
||||
char topic[32];
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
instance = atoi(argv[1]);
|
||||
}
|
||||
|
||||
snprintf(topic, sizeof(topic), "sensor_baro%u", instance);
|
||||
|
||||
fd = orb_open("sensor_baro", instance, O_RDONLY | O_NONBLOCK);
|
||||
if (fd < 0)
|
||||
{
|
||||
fprintf(stderr, "Could not open %s: %d\n", topic, errno);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printf("Subscribed to %s\n", topic);
|
||||
|
||||
/* LVGL setup */
|
||||
|
||||
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
|
||||
lv_memzero(&ui_loop, sizeof(ui_loop));
|
||||
#endif
|
||||
|
||||
if (!lv_is_initialized())
|
||||
{
|
||||
printf("Initializing LVGL...\n");
|
||||
lv_init();
|
||||
printf("LVGL initialized...\n");
|
||||
}
|
||||
|
||||
lv_nuttx_dsc_init(&info);
|
||||
lv_nuttx_init(&info, &result);
|
||||
|
||||
if (result.disp == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to initialize LVGL.\n");
|
||||
close(fd);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Set up stuff to render */
|
||||
|
||||
screen = lv_screen_active();
|
||||
set_column_flex(screen);
|
||||
|
||||
/* Create containers for layout. We want a spanning title, followed by two
|
||||
* side-by-side containers for the gauges.
|
||||
*
|
||||
* Gauge container is therefore a ROW flex, while its inner containers are
|
||||
* column flex (scale followed by a label below)
|
||||
*/
|
||||
|
||||
title_cont = lv_obj_create(screen);
|
||||
lv_obj_set_size(title_cont, LV_PCT(100), LV_PCT(10));
|
||||
lv_obj_align(title_cont, LV_ALIGN_CENTER, 0, 0);
|
||||
title = lv_label_create(title_cont);
|
||||
lv_label_set_text(title, "Barometer monitor");
|
||||
lv_obj_set_style_text_font(title, &lv_font_montserrat_32, 0);
|
||||
lv_obj_align(title, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
gauge_cont = lv_obj_create(screen);
|
||||
lv_obj_set_size(gauge_cont, LV_PCT(100), LV_PCT(90));
|
||||
lv_obj_set_flex_flow(gauge_cont, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_style_flex_main_place(gauge_cont, LV_FLEX_ALIGN_CENTER, 0);
|
||||
lv_obj_set_style_flex_cross_place(gauge_cont, LV_FLEX_ALIGN_CENTER, 0);
|
||||
lv_obj_set_style_flex_track_place(gauge_cont, LV_FLEX_ALIGN_CENTER, 0);
|
||||
|
||||
press_cont = lv_obj_create(gauge_cont);
|
||||
temp_cont = lv_obj_create(gauge_cont);
|
||||
set_column_flex(press_cont);
|
||||
set_column_flex(temp_cont);
|
||||
lv_obj_set_size(press_cont, LV_PCT(50), LV_PCT(100));
|
||||
lv_obj_set_size(temp_cont, LV_PCT(50), LV_PCT(100));
|
||||
|
||||
/* TODO: Get the text labels on the gauges to be padded better */
|
||||
|
||||
/* Pressure gauge */
|
||||
|
||||
press_gauge = lv_scale_create(press_cont);
|
||||
|
||||
lv_obj_set_size(press_gauge, GAUGE_SIZE, GAUGE_SIZE);
|
||||
lv_scale_set_mode(press_gauge, LV_SCALE_MODE_ROUND_INNER);
|
||||
lv_obj_set_style_bg_opa(press_gauge, LV_OPA_COVER, 0);
|
||||
lv_obj_set_style_bg_color(press_gauge,
|
||||
lv_palette_lighten(LV_PALETTE_RED, 4), 0);
|
||||
lv_obj_set_style_radius(press_gauge, LV_RADIUS_CIRCLE, 0);
|
||||
lv_obj_set_style_clip_corner(press_gauge, true, 0);
|
||||
lv_obj_set_style_text_font(press_gauge, &lv_font_montserrat_24, 0);
|
||||
lv_obj_align(press_gauge, LV_ALIGN_LEFT_MID, LV_PCT(5), 0);
|
||||
|
||||
lv_scale_set_label_show(press_gauge, true);
|
||||
|
||||
lv_scale_set_total_tick_count(press_gauge, (PRESS_MAX - PRESS_MIN));
|
||||
lv_scale_set_major_tick_every(press_gauge, PRESS_MAJOR_TICKS_EVERY);
|
||||
|
||||
lv_obj_set_style_length(press_gauge, 5, LV_PART_ITEMS);
|
||||
lv_obj_set_style_length(press_gauge, 10, LV_PART_INDICATOR);
|
||||
lv_scale_set_range(press_gauge, PRESS_MIN, PRESS_MAX);
|
||||
|
||||
lv_scale_set_angle_range(press_gauge, 270);
|
||||
lv_scale_set_rotation(press_gauge, 135);
|
||||
|
||||
press_line = lv_line_create(press_gauge);
|
||||
|
||||
lv_obj_set_style_line_width(press_line, LINE_WIDTH, LV_PART_MAIN);
|
||||
lv_obj_set_style_line_rounded(press_line, true, LV_PART_MAIN);
|
||||
lv_obj_set_style_line_color(press_line, lv_color_black(), LV_PART_MAIN);
|
||||
lv_obj_center(press_line);
|
||||
|
||||
/* Temperature gauge */
|
||||
|
||||
temp_gauge = lv_scale_create(temp_cont);
|
||||
lv_obj_set_size(temp_gauge, GAUGE_SIZE, GAUGE_SIZE);
|
||||
lv_scale_set_label_show(temp_gauge, true);
|
||||
lv_scale_set_mode(temp_gauge, LV_SCALE_MODE_ROUND_OUTER);
|
||||
lv_obj_align(temp_gauge, LV_ALIGN_RIGHT_MID, LV_PCT(-5), 0);
|
||||
|
||||
lv_scale_set_total_tick_count(temp_gauge, (TEMP_MAX - TEMP_MIN));
|
||||
lv_scale_set_major_tick_every(temp_gauge, TEMP_MAJOR_TICKS_EVERY);
|
||||
lv_obj_set_style_length(temp_gauge, 5, LV_PART_ITEMS);
|
||||
lv_obj_set_style_length(temp_gauge, 10, LV_PART_INDICATOR);
|
||||
lv_scale_set_range(temp_gauge, TEMP_MIN, TEMP_MAX);
|
||||
|
||||
lv_scale_set_angle_range(temp_gauge, 270);
|
||||
lv_scale_set_rotation(temp_gauge, 135);
|
||||
|
||||
temp_line = lv_line_create(temp_gauge);
|
||||
|
||||
lv_obj_set_style_line_width(temp_line, LINE_WIDTH, LV_PART_MAIN);
|
||||
lv_obj_set_style_line_rounded(temp_line, true, LV_PART_MAIN);
|
||||
lv_obj_center(temp_line);
|
||||
|
||||
/* Generate labels */
|
||||
|
||||
for (unsigned i = 0; i < NUM_TEMP_LABELS; i++)
|
||||
{
|
||||
snprintf(g_label_buf[i], sizeof(g_label_buf[i]), "%d °C",
|
||||
TEMP_MIN + i * (TEMP_MAX - TEMP_MIN) / NUM_TEMP_LABELS);
|
||||
g_temp_labels[i] = (const char *)g_label_buf[i];
|
||||
}
|
||||
|
||||
g_temp_labels[NUM_TEMP_LABELS] = NULL;
|
||||
|
||||
lv_scale_set_text_src(temp_gauge, g_temp_labels);
|
||||
|
||||
/* Temp gauge styles */
|
||||
|
||||
lv_style_init(&indicator_style);
|
||||
|
||||
lv_style_set_text_font(&indicator_style, &lv_font_montserrat_24);
|
||||
lv_style_set_text_color(&indicator_style,
|
||||
lv_palette_darken(LV_PALETTE_BLUE, 3));
|
||||
|
||||
lv_style_set_line_color(&indicator_style,
|
||||
lv_palette_darken(LV_PALETTE_BLUE, 3));
|
||||
lv_style_set_width(&indicator_style, 10U); /* Tick length */
|
||||
lv_style_set_line_width(&indicator_style, 2U); /* Tick width */
|
||||
lv_obj_add_style(temp_gauge, &indicator_style, LV_PART_INDICATOR);
|
||||
|
||||
lv_style_init(&minor_ticks_style);
|
||||
lv_style_set_line_color(&minor_ticks_style,
|
||||
lv_palette_lighten(LV_PALETTE_BLUE, 2));
|
||||
lv_style_set_width(&minor_ticks_style, 5U); /* Tick length */
|
||||
lv_style_set_line_width(&minor_ticks_style, 2U); /* Tick width */
|
||||
lv_obj_add_style(temp_gauge, &minor_ticks_style, LV_PART_ITEMS);
|
||||
|
||||
lv_style_init(&main_line_style);
|
||||
lv_style_set_arc_color(&main_line_style,
|
||||
lv_palette_darken(LV_PALETTE_BLUE, 3));
|
||||
lv_style_set_arc_width(&main_line_style, 2U); /* Tick width */
|
||||
|
||||
/* Section on temperature gauge */
|
||||
|
||||
lv_style_init(§ion_label_style);
|
||||
lv_style_init(§ion_minor_ticks_style);
|
||||
lv_style_init(§ion_main_line_style);
|
||||
|
||||
lv_style_set_text_font(§ion_label_style, &lv_font_montserrat_24);
|
||||
lv_style_set_text_color(§ion_label_style,
|
||||
lv_palette_darken(LV_PALETTE_RED, 3));
|
||||
|
||||
lv_style_set_line_color(§ion_label_style,
|
||||
lv_palette_darken(LV_PALETTE_RED, 3));
|
||||
lv_style_set_line_width(§ion_label_style, 5U); /* Tick width */
|
||||
|
||||
lv_style_set_line_color(§ion_minor_ticks_style,
|
||||
lv_palette_lighten(LV_PALETTE_RED, 2));
|
||||
lv_style_set_line_width(§ion_minor_ticks_style, 4U); /* Tick width */
|
||||
|
||||
lv_style_set_arc_color(§ion_main_line_style,
|
||||
lv_palette_darken(LV_PALETTE_RED, 3));
|
||||
lv_style_set_arc_width(§ion_main_line_style, 4U); /* Tick width */
|
||||
|
||||
section = lv_scale_add_section(temp_gauge);
|
||||
lv_scale_section_set_range(section, TEMP_THRESH, TEMP_MAX);
|
||||
lv_scale_section_set_style(section, LV_PART_INDICATOR,
|
||||
§ion_label_style);
|
||||
lv_scale_section_set_style(section, LV_PART_ITEMS,
|
||||
§ion_minor_ticks_style);
|
||||
lv_scale_section_set_style(section, LV_PART_MAIN,
|
||||
§ion_main_line_style);
|
||||
|
||||
/* Data labels */
|
||||
|
||||
press_label = lv_label_create(press_cont);
|
||||
lv_obj_align(press_label, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_text_font(press_label, &lv_font_montserrat_24, 0);
|
||||
temp_label = lv_label_create(temp_cont);
|
||||
lv_obj_align(temp_label, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_style_text_font(temp_label, &lv_font_montserrat_24, 0);
|
||||
|
||||
/* Main loop */
|
||||
|
||||
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
|
||||
lv_nuttx_uv_loop(&ui_loop, &result);
|
||||
#else
|
||||
for (; ; )
|
||||
{
|
||||
err = read(fd, &sensor_data, sizeof(sensor_data));
|
||||
if (err < 0)
|
||||
{
|
||||
fprintf(stderr, "Failed read data from %s: %d\n", topic, errno);
|
||||
}
|
||||
else if (err == 0)
|
||||
{
|
||||
fprintf(stderr, "No data from %s\n", topic);
|
||||
}
|
||||
else
|
||||
{
|
||||
got_data = true;
|
||||
}
|
||||
|
||||
if (got_data)
|
||||
{
|
||||
/* Update display if we obtained it successfully */
|
||||
|
||||
lv_label_set_text_fmt(temp_label, "Temperature: %2.f °C",
|
||||
sensor_data.temperature);
|
||||
lv_label_set_text_fmt(press_label, "Pressure: %2.f mbar",
|
||||
sensor_data.pressure);
|
||||
|
||||
lv_scale_set_line_needle_value(press_gauge, press_line, -10,
|
||||
(int32_t)sensor_data.pressure);
|
||||
lv_scale_set_line_needle_value(temp_gauge, temp_line, -10,
|
||||
(int32_t)sensor_data.temperature);
|
||||
|
||||
if (sensor_data.temperature < TEMP_THRESH)
|
||||
{
|
||||
lv_obj_set_style_line_color(
|
||||
temp_line, lv_palette_darken(LV_PALETTE_BLUE, 3),
|
||||
LV_PART_MAIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_obj_set_style_line_color(
|
||||
temp_line, lv_palette_darken(LV_PALETTE_RED, 3),
|
||||
LV_PART_MAIN);
|
||||
}
|
||||
|
||||
got_data = false; /* Reset for next loop */
|
||||
}
|
||||
|
||||
lv_timer_handler();
|
||||
usleep(CONFIG_EXAMPLES_BAROMONITOR_SAMPLERATE * 1000);
|
||||
|
||||
/* TODO: make this equivalent in LIBUV loop */
|
||||
}
|
||||
#endif
|
||||
|
||||
orb_close(fd);
|
||||
lv_nuttx_deinit(&result);
|
||||
lv_deinit();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue