Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .devcontainer/ubuntu-22.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ RUN pip install \
lit \
python-matrix-runner

RUN pushd /root && \
curl -LO http://files.iar.com/ftp/pub/box/bxarm-9.40.2.deb && \
dpkg -i bxarm-9.40.2.deb && \
rm bxarm-9.40.2.deb

ENV PATH=$PATH:/opt/iarsystems/bxarm/arm/bin
ENV IAR_TOOLCHAIN_9_40_2=/opt/iarsystems/bxarm/arm/bin
ENV IAR_LMS_SETTINGS_DIR=/home/$USERNAME/.iarlm

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
Expand Down
25 changes: 23 additions & 2 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
IAR_VERSION: '9.40.2'

jobs:
lit:
runs-on: ubuntu-latest
Expand All @@ -36,7 +39,7 @@ jobs:
- name: Cache vcpkg
uses: actions/cache@v3
with:
key: vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ matrix.compiler }}
key: vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}
restore-keys: |
vcpkg-${{ runner.os }}-${{ runner.arch }}-
path: /home/runner/.vcpkg
Expand All @@ -54,7 +57,25 @@ jobs:
. <(curl https://aka.ms/vcpkg-init.sh -L)
vcpkg x-update-registry --all
vcpkg activate


- name: Cache IAR Toolchain
uses: actions/cache@v3
with:
key: bxarm-${{env.IAR_VERSION}}-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}
restore-keys: |
bxarm-${{env.IAR_VERSION}}-${{ runner.os }}-${{ runner.arch }}-
path: bxarm-${{env.IAR_VERSION}}.deb

- name: Install IAR Toolchain
run: |
if [ ! -f bxarm-${{env.IAR_VERSION}}.deb ]; then
curl -LO http://files.iar.com/ftp/pub/box/bxarm-${{env.IAR_VERSION}}.deb
fi
sudo dpkg -i bxarm-${{env.IAR_VERSION}}.deb
echo "/opt/iarsystems/bxarm/arm/bin" >> "$GITHUB_PATH"
echo "IAR_TOOLCHAIN_${IAR_VERSION//./_}=/opt/iarsystems/bxarm/arm/bin" >> "$GITHUB_ENV"
# TODO: activate license

- name: Activate Arm tool license
working-directory: ./CMSIS/Core/Test
run: |
Expand Down
25 changes: 24 additions & 1 deletion .github/workflows/corevalidation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
IAR_VERSION: '9.40.2'

jobs:
build-and-run:

strategy:
fail-fast: true
matrix:
compiler: [AC6, GCC, Clang]
compiler: [AC6, GCC, Clang, IAR]

runs-on: ubuntu-latest

Expand Down Expand Up @@ -78,6 +81,26 @@ jobs:
vcpkg x-update-registry --all
vcpkg activate

- name: Cache IAR Toolchain
uses: actions/cache@v3
if: matrix.compiler == 'IAR'
with:
key: bxarm-${{env.IAR_VERSION}}-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}
restore-keys: |
bxarm-${{env.IAR_VERSION}}-${{ runner.os }}-${{ runner.arch }}-
path: bxarm-${{env.IAR_VERSION}}.deb

- name: Install IAR Toolchain
if: matrix.compiler == 'IAR'
run: |
if [ ! -f bxarm-${{env.IAR_VERSION}}.deb ]; then
curl -LO http://files.iar.com/ftp/pub/box/bxarm-${{env.IAR_VERSION}}.deb
fi
sudo dpkg -i bxarm-${{env.IAR_VERSION}}.deb
echo "/opt/iarsystems/bxarm/arm/bin" >> "$GITHUB_PATH"
echo "IAR_TOOLCHAIN_${IAR_VERSION//./_}=/opt/iarsystems/bxarm/arm/bin" >> "$GITHUB_ENV"
# TODO: activate license

- name: Activate Arm tool license
working-directory: ./CMSIS/CoreValidation/Project
run: |
Expand Down
11 changes: 4 additions & 7 deletions CMSIS/Core/Include/m-profile/cmsis_iccarm_m.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ __STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) {
#define __get_CONTROL() (__arm_rsr("CONTROL"))
#define __get_FAULTMASK() (__arm_rsr("FAULTMASK"))

#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
#if (defined(__ARM_FP) && (__ARM_FP >= 1))
#define __get_FPSCR() (__arm_rsr("FPSCR"))
#define __set_FPSCR(VALUE) (__arm_wsr("FPSCR", (VALUE)))
#else
Expand Down Expand Up @@ -545,8 +544,7 @@ __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control)
#endif


#if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) ))
#if (!defined(__ARM_FP) || (__ARM_FP == 0))
#define __get_FPSCR __cmsis_iar_get_FPSR_not_active
#define __set_FPSCR __cmsis_iar_set_FPSR_not_active
#endif
Expand Down Expand Up @@ -602,8 +600,7 @@ __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control)

#endif

#if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) ))
#if (!defined(__ARM_FP) || (__ARM_FP == 0))
#undef __get_FPSCR
#undef __set_FPSCR
#define __get_FPSCR() (0)
Expand Down Expand Up @@ -881,7 +878,7 @@ __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control)
}
#endif

#if (__CORTEX_M >= 0x03) /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
#if (__ARM_ARCH_ISA_THUMB >= 2)

__IAR_FT uint8_t __LDRBT(volatile uint8_t *addr)
{
Expand Down
15 changes: 6 additions & 9 deletions CMSIS/Core/Test/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def timestamp():


@matrix_action
def lit(config, results):
def lit(config, results, extra_args = None):
"""Run tests for the selected configurations using llvm's lit."""
yield run_lit(config.compiler[0], config.device[1], config.optimize[0])
yield run_lit(config.compiler[0], config.device[1], config.optimize[0], extra_args)
results[0].test_report.write(f"lit-{config.compiler[0]}-{config.optimize[0]}-{config.device[1]}-{timestamp()}.xunit")


Expand All @@ -75,13 +75,10 @@ def timestamp():


@matrix_command(test_report=FileReport(f"lit.xml") | JUnitReport())
def run_lit(toolchain, device, optimize):
return ["lit", "--xunit-xml-output", f"lit.xml", "-D", f"toolchain={toolchain}", "-D", f"device={device}", "-D", f"optimize={optimize}", "src" ]


@matrix_filter
def filter_iar(config):
return config.compiler == CompilerAxis.IAR
def run_lit(toolchain, device, optimize, extra_args = None):
if not extra_args:
extra_args = ["src"]
return ["lit", "--xunit-xml-output", f"lit.xml", "-D", f"toolchain={toolchain}", "-D", f"device={device}", "-D", f"optimize={optimize}"]+extra_args


if __name__ == "__main__":
Expand Down
77 changes: 76 additions & 1 deletion CMSIS/Core/Test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
'triple': 'thumbv7-em',
'abi': 'eabi',
'mcpu': 'cortex-m7',
'mfpu': 'fpv4-sp-d16',
'mfpu': 'fpv5-sp-d16',
'mpu': True,
'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumb-2', 'sat', 'ldrex', 'clz'],
'header': 'core_cm7.h',
Expand Down Expand Up @@ -640,6 +640,11 @@
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)

# environment
preserv_env_vars = ['IAR_LMS_SETTINGS_DIR']
for var in preserv_env_vars:
if var in os.environ:
config.environment[var] = os.environ[var]

# clang_path = get_toolchain_from_env('CLANG')

Expand Down Expand Up @@ -717,6 +722,7 @@ def get_ccflags(self):
ccflags += list(sum([('-D', f'{define}={value}') for (define, value) in DEVICES[self.device]['defines'].items()], ()))
return ccflags


class Toolchain_Clang(Toolchain):
TARGET = {
'CM0': 'thumbv6m-none-unknown-eabi',
Expand Down Expand Up @@ -772,13 +778,82 @@ def get_ccflags(self):

return ccflags


class Toolchain_IAR(Toolchain):
OPTIMIZE = {
'none': '-Ol',
'balanced': '-Oh',
'speed': '-Ohs',
'size': '-Ohz'
}

CPU = {
'CM0': 'cortex-m0',
'CM0plus': 'cortex-m0+',
'CM3': 'cortex-m3',
'CM4': 'cortex-m4',
'CM4FP': 'cortex-m4.fp.sp',
'CM7': 'cortex-m7',
'CM7SP': 'cortex-m7.fp.sp',
'CM7DP': 'cortex-m7.fp.dp',
'CM23': 'cortex-m.no_se',
'CM23S': 'cortex-m',
'CM23NS': 'cortex-m',
'CM33': 'cortex-m.no_se',
'CM33S': 'cortex-m',
'CM33NS': 'cortex-m',
'CM35P': 'cortex-m.no_se',
'CM35PS': 'cortex-m',
'CM35PNS': 'cortex-m',
'CM55': 'cortex-m.no_se',
'CM55S': 'cortex-m',
'CM55NS': 'cortex-m',
'CM85': 'cortex-m.no_se',
'CM85S': 'cortex-m',
'CM85NS': 'cortex-m',
'CA5': 'cortex-a5',
'CA5neon': 'cortex-a5.neon',
'CA7': 'cortex-a7.no_neon.no_vfp',
'CA7neon': 'cortex-a7',
'CA9': 'cortex-a9.no_neon.no_vfp',
'CA9neon': 'cortex-a9'
}

FPU = {
'none': 'none',
'fpv3-d16': 'vfpv3_d16',
'fpv4-sp-d16': 'vfpv4-sp',
'fpv5-sp-d16': 'vfpv5-sp',
'fpv5-d16': 'vfpv5_d16',
'neon-vfpv3': 'vfpv3',
'neon-vfpv4': 'vfpv4'
}

def __init__(self, **args):
super().__init__('IAR', **args)

def get_cc(self):
return os.path.join(self.get_root(), 'iccarm')

def get_ccflags(self):
ccflags = [
'-e', f'--cpu={self.CPU[self.device]}', f'--fpu={self.FPU[DEVICES[self.device]["mfpu"]]}',
self.OPTIMIZE[self.optimize], '-I', '../Include', '-c', '-D', f'CORE_HEADER=\\"{DEVICES[device]["header"]}\\"']
if device.endswith('S') and not device.endswith('NS'):
ccflags += ["--cmse"]
ccflags += list(sum([('-D', f'{define}={value}') for (define, value) in DEVICES[self.device]['defines'].items()], ()))
return ccflags


tc = None
if toolchain == 'AC6':
tc = Toolchain_AC6(device=device, optimize=optimize)
elif toolchain == 'GCC':
tc = Toolchain_GCC(device=device, optimize=optimize)
elif toolchain == 'Clang':
tc = Toolchain_Clang(device=device, optimize=optimize)
elif toolchain == 'IAR':
tc = Toolchain_IAR(device=device, optimize=optimize)

prefixes = ['CHECK']
if device.endswith('NS'):
Expand Down
6 changes: 1 addition & 5 deletions CMSIS/Core/Test/src/noreturn.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
#include "cmsis_compiler.h"

__NO_RETURN
static void func() {
while(1);
}

void noreturn() {
// CHECK-LABEL: <noreturn>:
// CHECK: b 0x0 <noreturn>
func();
while(1);
// CHECK-NOT: bx lr
}
2 changes: 1 addition & 1 deletion CMSIS/Core/Test/src/ror.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static volatile uint32_t b = 2u;

void ror() {
// CHECK-LABEL: <ror>:
// CHECK-THUMB: ror{{s|.w}} {{r[0-9]+}}, {{r[0-9]+}}
// CHECK-THUMB: ror{{(s)?(.w)?}} {{r[0-9]+}}, {{r[0-9]+}}
// CHECK-ARM: ror {{r[0-9]+}}, {{r[0-9]+}}, {{r[0-9]+}}
volatile uint32_t c = __ROR(a, b);
// CHECK: {{(bx lr)|(pop {.*pc})}}
Expand Down
2 changes: 1 addition & 1 deletion CMSIS/Core/Test/src/rrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static volatile uint32_t a = 10u;

void rrx() {
// CHECK-LABEL: <rrx>:
// CHECK: rrx {{r[0-9]+}}, {{r[0-9]+}}
// CHECK: rrx{{(s)?}} {{r[0-9]+}}, {{r[0-9]+}}
volatile uint32_t c = __RRX(a);
// CHECK: {{(bx lr)|(pop {.*pc})}}
}
5 changes: 0 additions & 5 deletions CMSIS/CoreValidation/Project/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,5 @@ def model_exec(config):
return cmdline


@matrix_filter
def filter_iar(config):
return config.compiler == CompilerAxis.IAR


if __name__ == "__main__":
main()