Skip to content

Commit 7166bb3

Browse files
authored
Merge pull request #1876 from hathach/support-iar
Support iar build
2 parents 8681dbb + 25603c7 commit 7166bb3

File tree

73 files changed

+885
-227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+885
-227
lines changed

.github/workflows/build_iar.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build IAR
2+
3+
on:
4+
push:
5+
paths:
6+
- 'src/**'
7+
- 'examples/**'
8+
- 'lib/**'
9+
- 'hw/**'
10+
pull_request:
11+
branches: [ master ]
12+
paths:
13+
- 'src/**'
14+
- 'examples/**'
15+
- 'lib/**'
16+
- 'hw/**'
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
build-arm:
24+
runs-on: [self-hosted, Linux, X64, hifiphile]
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
family:
29+
# Alphabetical order
30+
- 'stm32f0'
31+
- 'stm32f1'
32+
- 'stm32f4'
33+
- 'stm32f7'
34+
- 'stm32g4'
35+
- 'stm32h7'
36+
- 'stm32l4'
37+
steps:
38+
- name: Clean workspace
39+
run: |
40+
echo "Cleaning up previous run"
41+
rm -rf "${{ github.workspace }}"
42+
mkdir -p "${{ github.workspace }}"
43+
44+
- name: Checkout TinyUSB
45+
uses: actions/checkout@v3
46+
47+
- name: Checkout submodules and dependencies
48+
run: |
49+
git submodule update --init lib/FreeRTOS-Kernel lib/lwip lib/sct_neopixel
50+
python3 tools/get_dependencies.py ${{ matrix.family }}
51+
52+
- name: Checkout pico-sdk for rp2040
53+
if: matrix.family == 'rp2040'
54+
run: |
55+
git clone --depth 1 -b develop https://github.com/raspberrypi/pico-sdk ~/pico-sdk
56+
echo >> $GITHUB_ENV PICO_SDK_PATH=~/pico-sdk
57+
58+
- name: Build
59+
run: python3 tools/build_family.py ${{ matrix.family }} CC=iccarm

examples/device/board_test/Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,4 @@ INC += \
99
EXAMPLE_SOURCE += $(wildcard src/*.c)
1010
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
1111

12-
# board_test example is special example that doesn't enable device or host stack
13-
# This can cause some TinyUSB API missing, this hack to allow us to fill those API
14-
# to pass the compilation process
15-
CFLAGS += \
16-
-D"tud_int_handler(x)= " \
17-
1812
include ../../rules.mk

examples/device/board_test/src/tusb_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
extern "C" {
3131
#endif
3232

33+
// board_test example is special example that doesn't enable device or host stack
34+
// This can cause some TinyUSB API missing, this define hack to allow us to fill those API
35+
// to pass the compilation process
36+
#define tud_int_handler(x)
37+
3338
//--------------------------------------------------------------------
3439
// COMMON CONFIGURATION
3540
//--------------------------------------------------------------------

examples/device/cdc_msc_freertos/Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ include ../../../tools/top.mk
44
include ../../make.mk
55

66
FREERTOS_SRC = lib/FreeRTOS-Kernel
7+
FREERTOS_PORTABLE_SRC= $(FREERTOS_SRC)/portable/$(if $(USE_IAR),IAR,GCC)/$(FREERTOS_PORT)
78

89
INC += \
910
src \
1011
src/FreeRTOSConfig \
1112
$(TOP)/hw \
1213
$(TOP)/$(FREERTOS_SRC)/include \
13-
$(TOP)/$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)
14+
$(TOP)/$(FREERTOS_PORTABLE_SRC)
1415

1516
# Example source
1617
EXAMPLE_SOURCE = \
@@ -27,17 +28,20 @@ SRC_C += \
2728
$(FREERTOS_SRC)/queue.c \
2829
$(FREERTOS_SRC)/tasks.c \
2930
$(FREERTOS_SRC)/timers.c \
30-
$(subst ../../../,,$(wildcard ../../../$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)/*.c))
31+
$(subst ../../../,,$(wildcard ../../../$(FREERTOS_PORTABLE_SRC)/*.c))
32+
33+
SRC_S += \
34+
$(subst ../../../,,$(wildcard ../../../$(FREERTOS_PORTABLE_SRC)/*.s))
3135

3236
# include heap manage if configSUPPORT_DYNAMIC_ALLOCATION = 1
3337
# SRC_C += $(FREERTOS_SRC)/portable/MemMang/heap_1.c
3438
# CFLAGS += -Wno-error=sign-compare
3539

3640
# Suppress FreeRTOSConfig.h warnings
37-
CFLAGS += -Wno-error=redundant-decls
41+
GCC_CFLAGS += -Wno-error=redundant-decls
3842

3943
# Suppress FreeRTOS source warnings
40-
CFLAGS += -Wno-error=cast-qual
44+
GCC_CFLAGS += -Wno-error=cast-qual
4145

4246
# FreeRTOS (lto + Os) linker issue
4347
LDFLAGS += -Wl,--undefined=vTaskSwitchContext

examples/device/cdc_msc_freertos/src/FreeRTOSConfig/FreeRTOSConfig.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
* See http://www.freertos.org/a00110.html.
4343
*----------------------------------------------------------*/
4444

45+
// skip if included from IAR assembler
46+
#ifndef __IASMARM__
47+
4548
// Include MCU header
4649
#include "bsp/board_mcu.h"
4750

@@ -57,6 +60,8 @@
5760
extern uint32_t SystemCoreClock;
5861
#endif
5962

63+
#endif
64+
6065
/* Cortex M23/M33 port configuration. */
6166
#define configENABLE_MPU 0
6267
#define configENABLE_FPU 1
@@ -144,10 +149,10 @@
144149

145150
#ifdef __RX__
146151
/* Renesas RX series */
147-
#define vSoftwareInterruptISR INT_Excep_ICU_SWINT
148-
#define vTickISR INT_Excep_CMT0_CMI0
149-
#define configPERIPHERAL_CLOCK_HZ (configCPU_CLOCK_HZ/2)
150-
#define configKERNEL_INTERRUPT_PRIORITY 1
152+
#define vSoftwareInterruptISR INT_Excep_ICU_SWINT
153+
#define vTickISR INT_Excep_CMT0_CMI0
154+
#define configPERIPHERAL_CLOCK_HZ (configCPU_CLOCK_HZ/2)
155+
#define configKERNEL_INTERRUPT_PRIORITY 1
151156
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 4
152157

153158
#else
@@ -163,9 +168,18 @@
163168
#if defined(__NVIC_PRIO_BITS)
164169
// For Cortex-M specific: __NVIC_PRIO_BITS is defined in core_cmx.h
165170
#define configPRIO_BITS __NVIC_PRIO_BITS
171+
166172
#elif defined(__ECLIC_INTCTLBITS)
167173
// RISC-V Bumblebee core from nuclei
168174
#define configPRIO_BITS __ECLIC_INTCTLBITS
175+
176+
#elif defined(__IASMARM__)
177+
// FIXME: IAR Assembler cannot include mcu header directly to get __NVIC_PRIO_BITS.
178+
// Therefore we will hard coded it to minimum value of 2 to get pass ci build.
179+
// IAR user must update this to correct value of the target MCU
180+
#message "configPRIO_BITS is hard coded to 2 to pass IAR build only. User should update it per MCU"
181+
#define configPRIO_BITS 2
182+
169183
#else
170184
#error "FreeRTOS configPRIO_BITS to be defined"
171185
#endif

examples/device/dfu/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ INC += \
66
$(TOP)/hw \
77

88
# Example source
9-
EXAMPLE_SOURCE += $(wildcard src/*.c)
9+
EXAMPLE_SOURCE = \
10+
src/main.c \
11+
src/usb_descriptors.c
12+
1013
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
1114

1215
include ../../rules.mk

examples/device/hid_composite_freertos/Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ include ../../../tools/top.mk
44
include ../../make.mk
55

66
FREERTOS_SRC = lib/FreeRTOS-Kernel
7+
FREERTOS_PORTABLE_SRC= $(FREERTOS_SRC)/portable/$(if $(USE_IAR),IAR,GCC)/$(FREERTOS_PORT)
78

89
INC += \
910
src \
1011
src/FreeRTOSConfig \
1112
$(TOP)/hw \
1213
$(TOP)/$(FREERTOS_SRC)/include \
13-
$(TOP)/$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)
14+
$(TOP)/$(FREERTOS_PORTABLE_SRC)
1415

1516
# Example source
1617
EXAMPLE_SOURCE = \
@@ -26,17 +27,20 @@ SRC_C += \
2627
$(FREERTOS_SRC)/queue.c \
2728
$(FREERTOS_SRC)/tasks.c \
2829
$(FREERTOS_SRC)/timers.c \
29-
$(subst ../../../,,$(wildcard ../../../$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)/*.c))
30+
$(subst ../../../,,$(wildcard ../../../$(FREERTOS_PORTABLE_SRC)/*.c))
31+
32+
SRC_S += \
33+
$(subst ../../../,,$(wildcard ../../../$(FREERTOS_PORTABLE_SRC)/*.s))
3034

3135
# include heap manage if configSUPPORT_DYNAMIC_ALLOCATION = 1
3236
# SRC_C += $(FREERTOS_SRC)/portable/MemMang/heap_1.c
3337
# CFLAGS += -Wno-error=sign-compare
3438

3539
# Suppress FreeRTOSConfig.h warnings
36-
CFLAGS += -Wno-error=redundant-decls
40+
GCC_CFLAGS += -Wno-error=redundant-decls
3741

3842
# Suppress FreeRTOS source warnings
39-
CFLAGS += -Wno-error=cast-qual
43+
GCC_CFLAGS += -Wno-error=cast-qual
4044

4145
# FreeRTOS (lto + Os) linker issue
4246
LDFLAGS += -Wl,--undefined=vTaskSwitchContext

examples/device/hid_composite_freertos/src/FreeRTOSConfig/FreeRTOSConfig.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
* See http://www.freertos.org/a00110.html.
4343
*----------------------------------------------------------*/
4444

45+
// skip if included from IAR assembler
46+
#ifndef __IASMARM__
47+
4548
// Include MCU header
4649
#include "bsp/board_mcu.h"
4750

@@ -57,6 +60,8 @@
5760
extern uint32_t SystemCoreClock;
5861
#endif
5962

63+
#endif
64+
6065
/* Cortex M23/M33 port configuration. */
6166
#define configENABLE_MPU 0
6267
#define configENABLE_FPU 1
@@ -144,10 +149,10 @@
144149

145150
#ifdef __RX__
146151
/* Renesas RX series */
147-
#define vSoftwareInterruptISR INT_Excep_ICU_SWINT
148-
#define vTickISR INT_Excep_CMT0_CMI0
149-
#define configPERIPHERAL_CLOCK_HZ (configCPU_CLOCK_HZ/2)
150-
#define configKERNEL_INTERRUPT_PRIORITY 1
152+
#define vSoftwareInterruptISR INT_Excep_ICU_SWINT
153+
#define vTickISR INT_Excep_CMT0_CMI0
154+
#define configPERIPHERAL_CLOCK_HZ (configCPU_CLOCK_HZ/2)
155+
#define configKERNEL_INTERRUPT_PRIORITY 1
151156
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 4
152157

153158
#else
@@ -163,9 +168,18 @@
163168
#if defined(__NVIC_PRIO_BITS)
164169
// For Cortex-M specific: __NVIC_PRIO_BITS is defined in core_cmx.h
165170
#define configPRIO_BITS __NVIC_PRIO_BITS
171+
166172
#elif defined(__ECLIC_INTCTLBITS)
167173
// RISC-V Bumblebee core from nuclei
168174
#define configPRIO_BITS __ECLIC_INTCTLBITS
175+
176+
#elif defined(__IASMARM__)
177+
// FIXME: IAR Assembler cannot include mcu header directly to get __NVIC_PRIO_BITS.
178+
// Therefore we will hard coded it to minimum value of 2 to get pass ci build.
179+
// IAR user must update this to correct value of the target MCU
180+
#message "configPRIO_BITS is hard coded to 2 to pass IAR build only. User should update it per MCU"
181+
#define configPRIO_BITS 2
182+
169183
#else
170184
#error "FreeRTOS configPRIO_BITS to be defined"
171185
#endif

examples/device/net_lwip_webserver/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include ../../../tools/top.mk
44
include ../../make.mk
55

66
# suppress warning caused by lwip
7-
CFLAGS += \
7+
GCC_CFLAGS += \
88
-Wno-error=null-dereference \
99
-Wno-error=unused-parameter \
1010
-Wno-error=unused-variable
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without modification,
6+
* are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice,
9+
* this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation
12+
* and/or other materials provided with the distribution.
13+
* 3. The name of the author may not be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19+
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21+
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24+
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25+
* OF SUCH DAMAGE.
26+
*
27+
* This file is part of the lwIP TCP/IP stack.
28+
*
29+
* Author: Adam Dunkels <[email protected]>
30+
*
31+
*/
32+
33+
#if defined(__ICCARM__)
34+
#pragma pack(1)
35+
#endif

0 commit comments

Comments
 (0)