Skip to content

Commit 310b865

Browse files
authored
try to run arm-iar with circleci with new token (#2890)
* try to run arm-iar with circleci with new token * limit iar ci parallel build to 4 for medium+ and 6 for large * add hil-hfp to compile and test with IAR
1 parent eabf68b commit 310b865

File tree

6 files changed

+93
-41
lines changed

6 files changed

+93
-41
lines changed

.circleci/config.yml

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
2121
BUILDSYSTEM_TOOLCHAIN=(
2222
"cmake arm-clang"
23+
"cmake arm-iar"
2324
"make aarch64-gcc"
2425
"make arm-gcc"
2526
"make msp430-gcc"
@@ -28,7 +29,27 @@ jobs:
2829
"cmake esp-idf"
2930
)
3031
31-
RESOURCE_LARGE='["nrf", "imxrt"]'
32+
RESOURCE_LARGE='["nrf", "imxrt", "stm32f4", "stm32h7"]'
33+
34+
gen_build_entry() {
35+
local build_system="$1"
36+
local toolchain="$2"
37+
local family="$3"
38+
local resource_class="$4"
39+
40+
if [[ "$toolchain" == "esp-idf" ]]; then
41+
echo " - build-vm:" >> .circleci/config2.yml
42+
else
43+
echo " - build:" >> .circleci/config2.yml
44+
fi
45+
46+
echo " matrix:" >> .circleci/config2.yml
47+
echo " parameters:" >> .circleci/config2.yml
48+
echo " build-system: ['$build_system']" >> .circleci/config2.yml
49+
echo " toolchain: ['$toolchain']" >> .circleci/config2.yml
50+
echo " family: $family" >> .circleci/config2.yml
51+
echo " resource_class: ['$resource_class']" >> .circleci/config2.yml
52+
}
3253
3354
for e in "${BUILDSYSTEM_TOOLCHAIN[@]}"; do
3455
e_arr=($e)
@@ -43,26 +64,14 @@ jobs:
4364
FAMILY=$(jq -n --argjson family "$FAMILY" --argjson resource "$RESOURCE_LARGE" '$family | map(select(IN($resource[]) | not))')
4465
4566
if [[ $toolchain == esp-idf ]]; then
46-
echo " - build-vm:" >> .circleci/config2.yml
67+
gen_build_entry "$build_system" "$toolchain" "$FAMILY" "large"
4768
else
48-
echo " - build:" >> .circleci/config2.yml
49-
fi
50-
echo " matrix:" >> .circleci/config2.yml
51-
echo " parameters:" >> .circleci/config2.yml
52-
echo " build-system: ['$build_system']" >> .circleci/config2.yml
53-
echo " toolchain: ['$toolchain']" >> .circleci/config2.yml
54-
echo " family: $FAMILY" >> .circleci/config2.yml
55-
#echo " resource_class: ['medium+']" >> .circleci/config2.yml
69+
gen_build_entry "$build_system" "$toolchain" "$FAMILY" "medium+"
5670
57-
# add large resources
58-
if [ "$(echo $FAMILY_LARGE | jq 'length')" -gt 0 ]; then
59-
echo " - build:" >> .circleci/config2.yml
60-
echo " matrix:" >> .circleci/config2.yml
61-
echo " parameters:" >> .circleci/config2.yml
62-
echo " build-system: ['$build_system']" >> .circleci/config2.yml
63-
echo " toolchain: ['$toolchain']" >> .circleci/config2.yml
64-
echo " family: $FAMILY_LARGE" >> .circleci/config2.yml
65-
echo " resource_class: ['large']" >> .circleci/config2.yml
71+
# add large resources if available
72+
if [ "$(echo $FAMILY_LARGE | jq 'length')" -gt 0 ]; then
73+
gen_build_entry "$build_system" "$toolchain" "$FAMILY_LARGE" "large"
74+
fi
6675
fi
6776
done
6877

.circleci/config2.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ commands:
1616
"arm-gcc": "https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v13.2.1-1.1/xpack-arm-none-eabi-gcc-13.2.1-1.1-linux-x64.tar.gz",
1717
"msp430-gcc": "http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2",
1818
"riscv-gcc": "https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v13.2.0-2/xpack-riscv-none-elf-gcc-13.2.0-2-linux-x64.tar.gz",
19-
"rx-gcc": "https://llvm-gcc-renesas.com/downloads/get.php?f=rx/8.3.0.202004-gnurx/gcc-8.3.0.202004-GNURX-ELF.run"
19+
"rx-gcc": "https://llvm-gcc-renesas.com/downloads/get.php?f=rx/8.3.0.202004-gnurx/gcc-8.3.0.202004-GNURX-ELF.run",
20+
"arm-iar": "https://updates.iar.com/FileStore/STANDARD/001/003/322/cxarm-9.60.3.deb"
2021
}'
2122
toolchain_url=$(echo $TOOLCHAIN_JSON | jq -r '.["<< parameters.toolchain >>"]')
2223
@@ -38,18 +39,26 @@ commands:
3839
# download if folder does not exist (not cached)
3940
if [ ! -d ~/cache/<< parameters.toolchain >> ]; then
4041
mkdir -p ~/cache/<< parameters.toolchain >>
41-
wget --progress=dot:giga $toolchain_url -O toolchain.tar.gz
4242
if [[ << parameters.toolchain >> == rx-gcc ]]; then
43-
mv toolchain.tar.gz toolchain.run
43+
wget --progress=dot:giga $toolchain_url -O toolchain.run
4444
chmod +x toolchain.run
4545
./toolchain.run -p ~/cache/<< parameters.toolchain >>/gnurx -y
46+
elif [[ << parameters.toolchain >> == arm-iar ]]; then
47+
wget --progress=dot:giga $toolchain_url -O ~/cache/<< parameters.toolchain >>/toolchain.deb
4648
else
49+
wget --progress=dot:giga $toolchain_url -O toolchain.tar.gz
4750
tar -C ~/cache/<< parameters.toolchain >> -xaf toolchain.tar.gz
4851
fi
4952
fi
5053
5154
# Add toolchain to PATH
52-
echo "export PATH=$PATH:`echo ~/cache/<< parameters.toolchain >>/*/bin`" >> $BASH_ENV
55+
if [[ << parameters.toolchain >> == arm-iar ]]; then
56+
# Install IAR since we only cache deb file
57+
sudo dpkg --ignore-depends=libusb-1.0-0 -i ~/cache/<< parameters.toolchain >>/toolchain.deb
58+
echo "export PATH=$PATH:/opt/iar/cxarm/arm/bin" >> $BASH_ENV
59+
else
60+
echo "export PATH=$PATH:`echo ~/cache/<< parameters.toolchain >>/*/bin`" >> $BASH_ENV
61+
fi
5362
5463
- save_cache:
5564
name: Save Toolchain Cache
@@ -110,6 +119,9 @@ commands:
110119
# Toolchain option default is gcc
111120
if [ << parameters.toolchain >> == arm-clang ]; then
112121
TOOLCHAIN_OPTION="--toolchain clang"
122+
elif [ << parameters.toolchain >> == arm-iar ]; then
123+
TOOLCHAIN_OPTION="--toolchain iar"
124+
iccarm --version
113125
elif [ << parameters.toolchain >> == arm-gcc ]; then
114126
TOOLCHAIN_OPTION="--toolchain gcc"
115127
fi

.github/workflows/build.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,12 @@ jobs:
113113
# Build IAR on HFP self-hosted
114114
# ---------------------------------------
115115
arm-iar:
116-
if: github.repository_owner == 'hathach'
116+
if: github.repository_owner == 'hathach' && github.event_name == 'push'
117117
needs: set-matrix
118118
runs-on: [self-hosted, Linux, X64, hifiphile]
119119
env:
120120
BUILD_ARGS: ${{ join(fromJSON(needs.set-matrix.outputs.json)['arm-iar'], ' ') }}
121-
IAR_LMS_CLOUD_URL: https://license.cloud.iar.com
122-
IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }}
121+
# IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }}
123122
steps:
124123
- name: Clean workspace
125124
run: |
@@ -138,8 +137,3 @@ jobs:
138137

139138
- name: Build
140139
run: python3 tools/build.py --one-per-family --toolchain iar $BUILD_ARGS
141-
142-
- name: Test on actual hardware (hardware in the loop)
143-
if: github.event_name == 'pull_request'
144-
run: |
145-
python3 test/hil/hil_test.py hfp.json

.github/workflows/ci_set_matrix.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ def set_matrix_json():
5555
for toolchain in toolchain_list:
5656
filtered_families = [family for family, supported_toolchain in family_list.items() if
5757
toolchain in supported_toolchain]
58-
59-
# always add board in hfp.json for arm-iar
60-
if toolchain == 'arm-iar':
61-
with open('test/hil/hfp.json') as f:
62-
hfp_data = json.load(f)
63-
hfp_boards = [f"-b{board['name']}" for board in hfp_data['boards']]
64-
filtered_families = filtered_families + hfp_boards
65-
6658
matrix[toolchain] = filtered_families
6759

6860
print(json.dumps(matrix))

.github/workflows/hil_test.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858

5959
# ---------------------------------------
6060
# Hardware in the loop (HIL)
61-
# self-hosted running on an VM. For attached hardware checkout HIL_JSON
61+
# self-hosted on local VM, for attached hardware checkout HIL_JSON
6262
# ---------------------------------------
6363
hil-tinyusb:
6464
if: github.repository_owner == 'hathach'
@@ -86,3 +86,41 @@ jobs:
8686
run: |
8787
ls cmake-build/
8888
python3 test/hil/hil_test.py ${{ env.HIL_JSON }}
89+
90+
# ---------------------------------------
91+
# Hardware in the loop (HIL)
92+
# self-hosted by HFP, build with IAR toolchain, for attached hardware checkout test/hil/hfp.json
93+
# ---------------------------------------
94+
hil-hfp:
95+
if: github.repository_owner == 'hathach'
96+
runs-on: [self-hosted, Linux, X64, hifiphile]
97+
#env:
98+
# IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }}
99+
steps:
100+
- name: Clean workspace
101+
run: |
102+
echo "Cleaning up previous run"
103+
rm -rf "${{ github.workspace }}"
104+
mkdir -p "${{ github.workspace }}"
105+
106+
- name: Toolchain version
107+
run: iccarm --version
108+
109+
- name: Checkout TinyUSB
110+
uses: actions/checkout@v4
111+
112+
- name: Get build boards
113+
run: |
114+
MATRIX_JSON=$(python test/hil/hil_ci_set_matrix.py test/hil/hfp.json)
115+
BUILD_ARGS=$(echo $MATRIX_JSON | jq -r '.["arm-gcc"] | join(" ")')
116+
echo "BUILD_ARGS=$BUILD_ARGS"
117+
echo "BUILD_ARGS=$BUILD_ARGS" >> $GITHUB_ENV
118+
119+
- name: Get Dependencies
120+
run: python3 tools/get_deps.py $BUILD_ARGS
121+
122+
- name: Build
123+
run: python3 tools/build.py --toolchain iar $BUILD_ARGS
124+
125+
- name: Test on actual hardware (hardware in the loop)
126+
run: python3 test/hil/hil_test.py hfp.json

tools/build.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,14 @@ def cmake_board(board, toolchain, build_flags_on):
109109
rcmd = run_cmd(f'cmake examples -B {build_dir} -G "Ninja" -DBOARD={board} -DCMAKE_BUILD_TYPE=MinSizeRel '
110110
f'-DTOOLCHAIN={toolchain} {build_flags}')
111111
if rcmd.returncode == 0:
112-
rcmd = run_cmd(f"cmake --build {build_dir}")
112+
cmd = f"cmake --build {build_dir}"
113+
# Due to IAR capability, limit parallel build to 4 (medium+) or 6 (large) docker
114+
if toolchain == 'iar' and os.getenv('CIRCLECI'):
115+
if 'large' in os.getenv('CIRCLE_JOB'):
116+
cmd += ' --parallel 6'
117+
else:
118+
cmd += ' --parallel 4'
119+
rcmd = run_cmd(cmd)
113120
ret[0 if rcmd.returncode == 0 else 1] += 1
114121

115122
example = 'all'

0 commit comments

Comments
 (0)