Skip to content

Commit ab3eefb

Browse files
committed
CMSIS-Driver_USBD supports HSUSBD IP for HID/MSC/VCOM.
1 parent 0ce132d commit ab3eefb

File tree

17 files changed

+1103
-910
lines changed

17 files changed

+1103
-910
lines changed

.github/copilot-instructions.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copilot Code Review Instructions
2+
3+
## General Guidelines
4+
- Focus on readability and maintainability.
5+
- Suggest improvements for performance only if they are safe and simple.
6+
- Prefer clear and concise code over clever tricks.
7+
8+
## Language-specific Guidelines
9+
10+
### C/C++
11+
- Ensure proper memory management.
12+
- Follow existing coding style in the project.
13+
- Check for potential buffer overflows or null pointer dereferences.
14+
15+
### Python
16+
- Follow PEP8 style guide.
17+
- Check for unnecessary loops or inefficient list operations.
18+
- Suggest idiomatic Python solutions where appropriate.
19+
20+
## Pull Request Comments
21+
- When suggesting a change, explain *why* it is needed.
22+
- If a suggestion is optional, indicate it clearly.

.github/workflows/Eclipse.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: Eclipse building
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
pull_request:
8+
branches-ignore:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest]
18+
19+
steps:
20+
- name: Checkout repo
21+
uses: actions/checkout@v4
22+
with:
23+
submodules: recursive
24+
25+
- name: Install dependencies (Linux)
26+
if: matrix.os == 'ubuntu-latest'
27+
shell: bash
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y wget unzip default-jre make
31+
32+
echo "🌍 Downloading arm-none-eabi-toolchain for Linux x64"
33+
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
34+
tar -jxf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
35+
echo "$PWD/gcc-arm-none-eabi-10.3-2021.10/bin" >> $GITHUB_PATH
36+
ls -al $PWD
37+
38+
echo "🌍 Downloading aarch64-elf-toolchain for Linux x64"
39+
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
40+
tar -xf gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
41+
echo "$PWD/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin" >> $GITHUB_PATH
42+
ls -al $PWD
43+
44+
echo "🌍 Downloading Eclipse for Linux"
45+
46+
#wget -q https://ftp.yz.yamagata-u.ac.jp/pub/eclipse/technology/epp/downloads/release/2025-06/M3/eclipse-embedcpp-2025-06-M3-linux-gtk-x86_64.tar.gz
47+
#tar -xzf eclipse-embedcpp-2025-06-M3-linux-gtk-x86_64.tar.gz
48+
#mv eclipse eclipse-cdt
49+
50+
#wget -q https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2021-03/R/eclipse-embedcpp-2021-03-R-linux-gtk-x86_64.tar.gz -O eclipse-embedcpp-2021-03-R-linux-gtk-x86_64.tar.gz
51+
#tar -xzf eclipse-embedcpp-2021-03-R-linux-gtk-x86_64.tar.gz
52+
#mv eclipse eclipse-cdt
53+
#ls -al $PWD
54+
55+
wget -q -O NuEclipse.tar.gz --no-check-certificate https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW132023052507200264
56+
tar -xzf NuEclipse.tar.gz
57+
find . -name eclipse
58+
mv NuEclipse_V1.02.029_Linux_Setup/eclipse ./eclipse-cdt
59+
ls -al $PWD
60+
61+
- name: Install dependencies (Windows)
62+
if: matrix.os == 'windows-latest'
63+
shell: bash
64+
run: |
65+
choco install unzip jre8 -y
66+
67+
echo "🌍 Downloading arm-none-eabi-toolchain for Windows"
68+
curl -LO https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-win32.zip
69+
unzip -q gcc-arm-none-eabi-10.3-2021.10-win32.zip -d toolchain_arm
70+
echo "${PWD}/toolchain_arm/gcc-arm-none-eabi-10.3-2021.10/bin" >> $GITHUB_PATH
71+
ls -al toolchain_arm/gcc-arm-none-eabi-10.3-2021.10/bin
72+
73+
echo "🌍 Downloading aarch64-none-elf-toolchain for Windows"
74+
curl -LO https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf.tar.xz
75+
tar -xf gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf.tar.xz
76+
echo "${PWD}/gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf/bin" >> $GITHUB_PATH
77+
ls -al gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf/bin
78+
79+
echo "🌍 Downloading Eclipse for Windows"
80+
#curl -LO https://ftp.yz.yamagata-u.ac.jp/pub/eclipse/technology/epp/downloads/release/2025-06/M3/eclipse-embedcpp-2025-06-M3-win32-x86_64.zip
81+
#unzip -q eclipse-embedcpp-2025-06-M3-win32-x86_64.zip
82+
#mv eclipse eclipse-cdt
83+
curl -LO https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2021-03/R/eclipse-embedcpp-2021-03-R-win32-x86_64.zip
84+
unzip -q eclipse-embedcpp-2021-03-R-win32-x86_64.zip
85+
mv eclipse eclipse-cdt
86+
ls -al eclipse-cdt
87+
echo $GITHUB_PATH
88+
89+
- name: Build all Eclipse projects
90+
shell: bash
91+
run: |
92+
REPO_ROOT="$GITHUB_WORKSPACE"
93+
chmod +x "$GITHUB_WORKSPACE/.github/workflows/vcpkg_blacklist_check.sh"
94+
95+
echo "✅ Version check"
96+
arm-none-eabi-gcc --version
97+
aarch64-none-elf-gcc --version
98+
99+
mapfile -t solutions < <(find ./SampleCode -type f -name .cproject -exec dirname {} \;)
100+
declare -a failed_logs=()
101+
102+
set +e
103+
for sol_path in "${solutions[@]}"; do
104+
105+
dir=$(dirname "$sol_path")
106+
sol_name=$(basename "$dir")
107+
log_path="$dir/$sol_name.txt"
108+
109+
mkdir -p "$GITHUB_WORKSPACE/workspace"
110+
111+
#echo "🔨 Building $dir on $RUNNER_OS"
112+
timeout 5m ./eclipse-cdt/eclipse \
113+
-nosplash \
114+
-application org.eclipse.cdt.managedbuilder.core.headlessbuild \
115+
-data "$GITHUB_WORKSPACE/workspace" \
116+
-import "$GITHUB_WORKSPACE/$sol_path" \
117+
-build all > "$log_path" 2>&1
118+
ret1=$?
119+
120+
# Check log file
121+
$REPO_ROOT/.github/workflows/vcpkg_blacklist_check.sh $log_path
122+
ret2=$?
123+
124+
if [[ $ret1 -ne 0 || $ret2 -ne 0 ]]; then
125+
echo "❌ Build failed: $sol_path"
126+
echo "🔍 Log:"
127+
cat "$log_path"
128+
failed_logs+=("$log_path") #add log into the set.
129+
else
130+
echo "✅ Build success: $sol_path"
131+
fi
132+
133+
rm -rf "$GITHUB_WORKSPACE/workspace"
134+
135+
done
136+
set -e
137+
138+
# List all the paths of failed logs at the end (if any)
139+
if [[ ${#failed_logs[@]} -ne 0 ]]; then
140+
echo "🚨 The following builds failed:"
141+
for log in "${failed_logs[@]}"; do
142+
echo " - $log"
143+
done
144+
printf "%s," "${failed_logs[@]}" | sed 's/,$//' > failed_logs.txt
145+
echo "Wrote failed_logs.txt"
146+
exit 1
147+
else
148+
echo "🎉 All builds succeeded!"
149+
fi
150+

.github/workflows/VSCode.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: VSCode building
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
pull_request:
8+
branches-ignore:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Install Packages on Windows
23+
if: matrix.os == 'windows-latest'
24+
run: choco install jq python
25+
26+
- name: Install Packages on Linux
27+
if: matrix.os == 'ubuntu-latest'
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y python3 python3-pip python-is-python3
31+
pip install -r "$GITHUB_WORKSPACE/.github/workflows/requirements.txt"
32+
33+
- name: Install tools
34+
uses: ARM-software/cmsis-actions/vcpkg@v1
35+
with:
36+
config: ".github/workflows/vcpkg-configuration.json"
37+
38+
- name: Activate Arm tool license
39+
uses: ARM-software/cmsis-actions/armlm@v1
40+
41+
- name: Activate & Build each csolution
42+
shell: bash
43+
run: |
44+
REPO_ROOT="$GITHUB_WORKSPACE"
45+
chmod +x "$GITHUB_WORKSPACE/.github/workflows/vcpkg_build.sh"
46+
chmod +x "$GITHUB_WORKSPACE/.github/workflows/vcpkg_blacklist_check.sh"
47+
48+
mapfile -t solutions < <(find ./SampleCode -name '*.csolution.yml')
49+
50+
declare -a failed_logs=()
51+
52+
set +e
53+
for sol_path in "${solutions[@]}"; do
54+
sol_dir=$(dirname "$sol_path")
55+
sol_name=$(basename "$sol_path")
56+
log_path="$sol_dir/$sol_name.txt"
57+
58+
# Build & Produce log file
59+
$REPO_ROOT/.github/workflows/vcpkg_build.sh "$sol_path" > $log_path
60+
ret1=$?
61+
62+
# Check log file
63+
$REPO_ROOT/.github/workflows/vcpkg_blacklist_check.sh $log_path
64+
ret2=$?
65+
66+
if [[ $ret1 -ne 0 || $ret2 -ne 0 ]]; then
67+
echo "❌ Build failed: $sol_path"
68+
echo "🔍 Log:"
69+
cat "$log_path"
70+
failed_logs+=("$log_path") #add log into the set.
71+
else
72+
echo "✅ Build success: $sol_path"
73+
fi
74+
75+
done
76+
set -e
77+
78+
# List all the paths of failed logs at the end (if any)
79+
if [[ ${#failed_logs[@]} -ne 0 ]]; then
80+
echo "🚨 The following builds failed:"
81+
for log in "${failed_logs[@]}"; do
82+
echo " - $log"
83+
done
84+
printf "%s," "${failed_logs[@]}" | sed 's/,$//' > failed_logs.txt
85+
echo "Wrote failed_logs.txt"
86+
exit 1
87+
else
88+
echo "🎉 All builds succeeded!"
89+
fi
90+

.github/workflows/requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cbor
2+
cbor2
3+
intelhex
4+
ecdsa
5+
cryptography
6+
click
7+
cffi
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"registries": [
3+
{
4+
"kind": "artifact",
5+
"location": "https://aka.ms/vcpkg-ce-default",
6+
"name": "microsoft"
7+
},
8+
{
9+
"kind": "artifact",
10+
"location": "https://artifacts.tools.arm.com/vcpkg-registry",
11+
"name": "arm"
12+
}
13+
],
14+
"requires": {
15+
"arm:tools/kitware/cmake": "3.31.5",
16+
"arm:tools/ninja-build/ninja": "1.12.0",
17+
"arm:compilers/arm/armclang": "^ 6.24.0",
18+
"arm:tools/open-cmsis-pack/cmsis-toolbox": "2.5.0",
19+
"microsoft:compilers/arm-none-eabi-gcc": "* 10.3.1-2021.10"
20+
}
21+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
BUILDLOG="$1"
4+
TMPFILE=$(mktemp)
5+
FOUND=0
6+
7+
# Define blacklist keywords to search for
8+
BLACKLIST=(
9+
"[Fatal Error]"
10+
"An error has occurred."
11+
" error: "
12+
" warning: "
13+
" Error: "
14+
" Warning: "
15+
" Warning[ "
16+
"warning csolution: "
17+
)
18+
19+
# Read the build log file line by line
20+
while IFS= read -r line; do
21+
echo "$line" >> "$TMPFILE"
22+
for keyword in "${BLACKLIST[@]}"; do
23+
# Check if the line contains the blacklist keyword
24+
if [[ "$line" == *"$keyword"* ]]; then
25+
# Find the position of the keyword in the line (0-based index)
26+
pos=$(awk -v a="$line" -v b="$keyword" 'BEGIN{print index(a, b) - 1}')
27+
# Create a pointer line with spaces and '^' characters
28+
arrow=$(printf '%*s' "$pos" '' | tr ' ' ' ')
29+
arrow+="$(printf '%*s' "${#keyword}" '' | tr ' ' '^') <- Received a blacklist rule."
30+
# Append the pointer line
31+
echo "$arrow" >> "$TMPFILE"
32+
echo "" >> "$TMPFILE"
33+
# Increase the counter and break out of the loop
34+
FOUND=$((FOUND + 1))
35+
break
36+
fi
37+
done
38+
done < "$BUILDLOG"
39+
40+
# If any blacklist rule was found, update the original log file
41+
if [[ $FOUND -gt 0 ]]; then
42+
mv "$TMPFILE" "$BUILDLOG"
43+
else
44+
rm "$TMPFILE"
45+
fi
46+
47+
# Return number of violations as exit code
48+
exit $FOUND

0 commit comments

Comments
 (0)