Skip to content

Commit 7c71684

Browse files
author
Marti Bolivar
authored
Merge pull request zephyrproject-rtos#19 from mbolivar/master-upstream-dev-17.05
Master upstream dev 17.05
2 parents 43fbe8e + 7d95848 commit 7c71684

File tree

768 files changed

+37748
-5853
lines changed

Some content is hidden

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

768 files changed

+37748
-5853
lines changed

.shippable.yml

+7-22
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ env:
66
global:
77
- SDK=0.9
88
- SANITYCHECK_OPTIONS=" --inline-logs -R"
9-
- SANITYCHECK_OPTIONS_RETRY=" --inline-logs --only-failed --outdir=out-2nd-pass"
9+
- SANITYCHECK_OPTIONS_RETRY="${SANITYCHECK_OPTIONS} --only-failed --outdir=out-2nd-pass"
1010
- ZEPHYR_SDK_INSTALL_DIR=/opt/sdk/zephyr-sdk-0.9
1111
- ZEPHYR_GCC_VARIANT=zephyr
1212
- USE_CCACHE=1
13+
- MATRIX_BUILDS="2"
1314
matrix:
14-
- ARCH="-a x86 -a riscv32" RUN_COMPLIANCE="1"
15-
- ARCH="-a arm -a arc -a nios2"
15+
- MATRIX_BUILD="1"
16+
- MATRIX_BUILD="2"
1617

1718
build:
1819
cache: true
@@ -27,7 +28,7 @@ build:
2728
ci:
2829
- export CCACHE_DIR=${SHIPPABLE_BUILD_DIR}/ccache/.ccache
2930
- source zephyr-env.sh
30-
- ccache -s --max-size=2000M
31+
- ccache -c -s --max-size=2000M
3132
- make host-tools
3233
- export PREBUILT_HOST_TOOLS=${ZEPHYR_BASE}/bin
3334
- >
@@ -43,7 +44,7 @@ build:
4344
S3_PATH="s3://zephyr-logs/${LOG_TYPE}/${REPO_FULL_NAME}/${BUILD_NUMBER}";
4445
fi;
4546
- >
46-
if [ "$RUN_COMPLIANCE" = "1" -a "$IS_PULL_REQUEST" = "true" ]; then
47+
if [ "$MATRIX_BUILD" = "1" -a "$IS_PULL_REQUEST" = "true" ]; then
4748
export COMMIT_RANGE=origin/${PULL_REQUEST_BASE_BRANCH}..${COMMIT}
4849
echo "Building a Pull Request";
4950
echo "- Building Documentation";
@@ -56,29 +57,13 @@ build:
5657
echo "- Verify commit message and coding style";
5758
./scripts/ci/check-compliance.py || true;
5859
fi;
59-
- >
60-
if [ "$JOB_TRIGGERED_BY_NAME" = "daily-verify-asserts" ]; then
61-
echo "- Building with --all --enable-slow -R";
62-
COVERAGE="--all --enable-slow -R";
63-
fi;
6460
- >
6561
if [ "$JOB_TRIGGERED_BY_NAME" = "daily-verify" ]; then
6662
echo "- Building with --all --enable-slow";
6763
COVERAGE="--all --enable-slow";
6864
fi;
6965
- >
70-
if [ "$JOB_TRIGGERED_BY_NAME" = "code-scan" ]; then
71-
echo "- Building basic sanitycheck";
72-
wget https://scan.coverity.com/download/linux64 --post-data "token=${COVERITY_TOKEN}&project=Zephyr" -O coverity_tool.tgz;
73-
tar xvf coverity_tool.tgz;
74-
rm -f coverity_tool.tgz;
75-
mv cov-* cov-analysis;
76-
./scripts/ci/run-coverity.sh
77-
fi;
78-
- >
79-
if [ "$JOB_TRIGGERED_BY_NAME" != "code-scan" ]; then
80-
./scripts/sanitycheck ${PLATFORMS} ${ARCH} ${COVERAGE} ${SANITYCHECK_OPTIONS} || ./scripts/sanitycheck ${PLATFORMS} ${ARCH} ${COVERAGE} ${SANITYCHECK_OPTIONS_RETRY};
81-
fi
66+
./scripts/sanitycheck ${PLATFORMS} --subset ${MATRIX_BUILD}/${MATRIX_BUILDS} ${COVERAGE} ${SANITYCHECK_OPTIONS} || ./scripts/sanitycheck ${PLATFORMS} --subset ${MATRIX_BUILD}/${MATRIX_BUILDS} ${COVERAGE} ${SANITYCHECK_OPTIONS_RETRY};
8267
- ccache -s
8368
on_success:
8469
- rm -rf sanity-out out-2nd-pass

Makefile

+38-11
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ KERNEL_ELF_NAME = $(KERNEL_NAME).elf
364364
KERNEL_BIN_NAME = $(KERNEL_NAME).bin
365365
KERNEL_HEX_NAME = $(KERNEL_NAME).hex
366366
KERNEL_STAT_NAME = $(KERNEL_NAME).stat
367+
PREBUILT_KERNEL = $(KERNEL_NAME)_prebuilt.elf
367368

368369
export SOC_FAMILY SOC_SERIES SOC_PATH SOC_NAME BOARD_NAME
369370
export ARCH KERNEL_NAME KERNEL_ELF_NAME KERNEL_BIN_NAME KERNEL_HEX_NAME
@@ -852,13 +853,14 @@ $(KERNEL_NAME).lnk: $(zephyr-deps)
852853

853854
linker.cmd: $(zephyr-deps)
854855
$(Q)$(CC) -x assembler-with-cpp -nostdinc -undef -E -P \
855-
$(LDFLAG_LINKERCMD) $(LD_TOOLCHAIN) -I$(srctree)/include \
856-
-I$(SOURCE_DIR) \
857-
-I$(objtree)/include/generated $(EXTRA_LINKER_CMD_OPT) $(KBUILD_LDS) -o $@
856+
$(LDFLAG_LINKERCMD) $(LD_TOOLCHAIN) \
857+
-I$(srctree)/include -I$(SOURCE_DIR) \
858+
-I$(objtree)/include/generated \
859+
$(EXTRA_LINKER_CMD_OPT) $(KBUILD_LDS) -o $@
858860

859-
PREBUILT_KERNEL = $(KERNEL_NAME)_prebuilt.elf
860861

861-
$(PREBUILT_KERNEL): $(zephyr-deps) libzephyr.a $(KBUILD_ZEPHYR_APP) $(app-y) linker.cmd $(KERNEL_NAME).lnk
862+
$(PREBUILT_KERNEL): $(zephyr-deps) libzephyr.a $(KBUILD_ZEPHYR_APP) $(app-y) \
863+
linker.cmd $(KERNEL_NAME).lnk
862864
$(Q)$(CC) -T linker.cmd @$(KERNEL_NAME).lnk -o $@
863865

864866
ASSERT_WARNING_STR := \
@@ -878,15 +880,39 @@ WARN_ABOUT_DEPRECATION := $(if $(CONFIG_BOARD_DEPRECATED),echo -e \
878880
-n $(DEPRECATION_WARNING_STR),true)
879881

880882
ifeq ($(ARCH),x86)
881-
# X86 with its IDT has very special handling for interrupt tables
882883
include $(srctree)/arch/x86/Makefile.idt
883-
else ifeq ($(CONFIG_GEN_ISR_TABLES),y)
884-
# Logic for interrupt tables created by scripts/gen_isr_tables.py
884+
endif
885+
886+
ifeq ($(CONFIG_GEN_ISR_TABLES),y)
885887
include $(srctree)/arch/common/Makefile.gen_isr_tables
886-
else
888+
endif
889+
890+
ifneq ($(GENERATED_KERNEL_OBJECT_FILES),)
891+
892+
# Identical rule to linker.cmd, but we also define preprocessor LINKER_PASS2.
893+
# For arches that place special metadata in $(PREBUILT_KERNEL) not intended
894+
# for the final binary, it can be #ifndef'd around this.
895+
linker-pass2.cmd: $(zephyr-deps)
896+
$(Q)$(CC) -x assembler-with-cpp -nostdinc -undef -E -P \
897+
-DLINKER_PASS2 \
898+
$(LDFLAG_LINKERCMD) $(LD_TOOLCHAIN) \
899+
-I$(srctree)/include -I$(SOURCE_DIR) \
900+
-I$(objtree)/include/generated \
901+
$(EXTRA_LINKER_CMD_OPT) $(KBUILD_LDS) -o $@
902+
903+
$(KERNEL_ELF_NAME): $(GENERATED_KERNEL_OBJECT_FILES) linker-pass2.cmd
904+
$(Q)$(CC) -T linker-pass2.cmd $(GENERATED_KERNEL_OBJECT_FILES) \
905+
@$(KERNEL_NAME).lnk -o $@
906+
$(Q)$(srctree)/scripts/check_link_map.py $(KERNEL_NAME).map
907+
@$(WARN_ABOUT_ASSERT)
908+
@$(WARN_ABOUT_DEPRECATION)
909+
910+
else # GENERATED_KERNEL_OBJECT_FILES
911+
887912
# Otherwise, nothing to do, prebuilt kernel is the real one
888913
$(KERNEL_ELF_NAME): $(PREBUILT_KERNEL)
889-
@cp $(PREBUILT_KERNEL) $(KERNEL_ELF_NAME)
914+
$(Q)cp $(PREBUILT_KERNEL) $(KERNEL_ELF_NAME)
915+
$(Q)$(srctree)/scripts/check_link_map.py $(KERNEL_NAME).map
890916
@$(WARN_ABOUT_ASSERT)
891917
@$(WARN_ABOUT_DEPRECATION)
892918
endif
@@ -1066,7 +1092,8 @@ CLEAN_DIRS += $(MODVERDIR)
10661092
CLEAN_FILES += include/generated/generated_dts_board.h \
10671093
.old_version .tmp_System.map .tmp_version \
10681094
.tmp_* System.map *.lnk *.map *.elf *.lst \
1069-
*.bin *.hex *.stat *.strip staticIdt.o linker.cmd
1095+
*.bin *.hex *.stat *.strip staticIdt.o linker.cmd \
1096+
linker-pass2.cmd
10701097

10711098
# Directories & files removed with 'make mrproper'
10721099
MRPROPER_DIRS += bin include/config usr/include include/generated \

README.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Zephyr Project
2-
###############
1+
Zephyr Project
2+
##############
33

4-
The Zephyr Project is a scalable real-time operating system (RTOS) supporting
4+
The Zephyr Project is a scalable real-time operating system (RTOS) supporting
55
multiple hardware architectures, optimized for resource constrained devices,
66
and built with security in mind.
77

@@ -29,11 +29,11 @@ Welcome to the Zephyr community!
2929
Resources
3030
*********
3131

32-
Heres a quick summary of resources to find your way around the Zephyr Project
32+
Here's a quick summary of resources to find your way around the Zephyr Project
3333
support systems:
3434

3535
* **Zephyr Project Website**: The https://zephyrproject.org website is the
36-
central source of information about the Zephyr Project. On this site, youll
36+
central source of information about the Zephyr Project. On this site, you'll
3737
find background and current information about the project as well as all the
3838
relevant links to project material. For a quick start, refer to the
3939
`Zephyr Introduction`_ and `Getting Started Guide`_.

arch/arc/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ config FIRQ_STACK_SIZE
111111
config ARC_STACK_CHECKING
112112
bool "Enable Stack Checking"
113113
depends on CPU_ARCV2
114+
select THREAD_STACK_INFO
114115
default n
115116
help
116117
ARCV2 has a special feature allowing to check stack overflows. This

arch/arc/Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ cflags-y += $(call cc-option,-ffunction-sections,) $(call cc-option,-fdata-secti
55
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63691
66
cflags-y += $(call cc-option,-fno-delete-null-pointer-checks)
77

8-
cflags-$(CONFIG_ARC_STACK_CHECKING) = $(call cc-option,-fomit-frame-pointer)
98
cflags-$(CONFIG_LTO) = $(call cc-option,-flto,)
109

1110
include $(srctree)/arch/$(ARCH)/soc/$(SOC_PATH)/Makefile

arch/arc/core/fast_irq.S

+4-4
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ _firq_reschedule:
227227
st_s r2, [r1, _kernel_offset_to_current]
228228

229229
#ifdef CONFIG_ARC_STACK_CHECKING
230-
/* Use stack top and down registers from restored context */
231-
add r3, r2, _K_THREAD_NO_FLOAT_SIZEOF
232-
sr r3, [_ARC_V2_KSTACK_TOP]
233-
ld_s r3, [r2, _thread_offset_to_stack_top]
230+
/* Use stack top and base registers from restored context */
231+
ld r3, [r2, _thread_offset_to_stack_base]
234232
sr r3, [_ARC_V2_KSTACK_BASE]
233+
ld r3, [r2, _thread_offset_to_stack_top]
234+
sr r3, [_ARC_V2_KSTACK_TOP]
235235
#endif
236236
/*
237237
* _load_callee_saved_regs expects incoming thread in r2.

arch/arc/core/fatal.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ FUNC_NORETURN void _NanoFatalErrorHandler(unsigned int reason,
4141
const NANO_ESF *pEsf)
4242
{
4343
switch (reason) {
44+
case _NANO_ERR_HW_EXCEPTION:
45+
break;
46+
4447
case _NANO_ERR_INVALID_TASK_EXIT:
4548
printk("***** Invalid Exit Software Error! *****\n");
4649
break;
4750

48-
#if defined(CONFIG_STACK_CANARIES)
51+
#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_ARC_STACK_CHECKING)
4952
case _NANO_ERR_STACK_CHK_FAIL:
5053
printk("***** Stack Check Fail! *****\n");
5154
break;

arch/arc/core/fault.c

+18-46
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,7 @@
1717

1818
#include <kernel.h>
1919
#include <kernel_structs.h>
20-
21-
#ifdef CONFIG_PRINTK
2220
#include <misc/printk.h>
23-
#define PR_EXC(...) printk(__VA_ARGS__)
24-
#else
25-
#define PR_EXC(...)
26-
#endif /* CONFIG_PRINTK */
27-
28-
#if (CONFIG_FAULT_DUMP > 0)
29-
#define FAULT_DUMP(esf, fault) _FaultDump(esf, fault)
30-
#else
31-
#define FAULT_DUMP(esf, fault) \
32-
do { \
33-
(void) esf; \
34-
(void) fault; \
35-
} while ((0))
36-
#endif
37-
38-
#if (CONFIG_FAULT_DUMP > 0)
39-
/*
40-
* @brief Dump information regarding fault (FAULT_DUMP > 0)
41-
*
42-
* Dump information regarding the fault when CONFIG_FAULT_DUMP is set to 1
43-
* (short form).
44-
*
45-
* @return N/A
46-
*/
47-
void _FaultDump(const NANO_ESF *esf, int fault)
48-
{
49-
ARG_UNUSED(esf);
50-
ARG_UNUSED(fault);
51-
52-
#ifdef CONFIG_PRINTK
53-
u32_t exc_addr = _arc_v2_aux_reg_read(_ARC_V2_EFA);
54-
u32_t ecr = _arc_v2_aux_reg_read(_ARC_V2_ECR);
55-
56-
PR_EXC("Exception vector: 0x%x, cause code: 0x%x, parameter 0x%x\n",
57-
_ARC_V2_ECR_VECTOR(ecr),
58-
_ARC_V2_ECR_CODE(ecr),
59-
_ARC_V2_ECR_PARAMETER(ecr));
60-
PR_EXC("Address 0x%x\n", exc_addr);
61-
#endif
62-
}
63-
#endif /* CONFIG_FAULT_DUMP */
6421

6522
/*
6623
* @brief Fault handler
@@ -74,9 +31,24 @@ void _FaultDump(const NANO_ESF *esf, int fault)
7431
*/
7532
void _Fault(void)
7633
{
34+
u32_t vector, code, parameter;
35+
u32_t exc_addr = _arc_v2_aux_reg_read(_ARC_V2_EFA);
7736
u32_t ecr = _arc_v2_aux_reg_read(_ARC_V2_ECR);
7837

79-
FAULT_DUMP(&_default_esf, ecr);
80-
81-
_SysFatalErrorHandler(_NANO_ERR_HW_EXCEPTION, &_default_esf);
38+
vector = _ARC_V2_ECR_VECTOR(ecr);
39+
code = _ARC_V2_ECR_CODE(ecr);
40+
parameter = _ARC_V2_ECR_PARAMETER(ecr);
41+
42+
printk("Exception vector: 0x%x, cause code: 0x%x, parameter 0x%x\n",
43+
vector, code, parameter);
44+
printk("Address 0x%x\n", exc_addr);
45+
#ifdef CONFIG_ARC_STACK_CHECKING
46+
/* Vector 6 = EV_ProV. Regardless of code, parameter 2 means stack
47+
* check violation
48+
*/
49+
if (vector == 6 && parameter == 2) {
50+
_NanoFatalErrorHandler(_NANO_ERR_STACK_CHK_FAIL, &_default_esf);
51+
}
52+
#endif
53+
_NanoFatalErrorHandler(_NANO_ERR_HW_EXCEPTION, &_default_esf);
8254
}

arch/arc/core/offsets/offsets.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ GEN_OFFSET_SYM(_thread_arch_t, intlock_key);
3030
GEN_OFFSET_SYM(_thread_arch_t, relinquish_cause);
3131
GEN_OFFSET_SYM(_thread_arch_t, return_value);
3232
#ifdef CONFIG_ARC_STACK_CHECKING
33-
GEN_OFFSET_SYM(_thread_arch_t, stack_top);
33+
GEN_OFFSET_SYM(_thread_arch_t, stack_base);
3434
#endif
3535

3636
/* ARCv2-specific IRQ stack frame structure member offsets */

arch/arc/core/regular_irq.S

+4-4
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ _rirq_common_interrupt_swap:
158158
/* r2 contains pointer to new thread */
159159

160160
#ifdef CONFIG_ARC_STACK_CHECKING
161-
/* Use stack top and down registers from restored context */
162-
add r3, r2, _K_THREAD_NO_FLOAT_SIZEOF
163-
sr r3, [_ARC_V2_KSTACK_TOP]
164-
ld_s r3, [r2, _thread_offset_to_stack_top]
161+
/* Use stack top and base registers from restored context */
162+
ld r3, [r2, _thread_offset_to_stack_base]
165163
sr r3, [_ARC_V2_KSTACK_BASE]
164+
ld r3, [r2, _thread_offset_to_stack_top]
165+
sr r3, [_ARC_V2_KSTACK_TOP]
166166
#endif
167167
/*
168168
* _load_callee_saved_regs expects incoming thread in r2.

arch/arc/core/swap.S

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ SECTION_FUNC(TEXT, __swap)
9999

100100
/* entering here, r2 contains the new current thread */
101101
#ifdef CONFIG_ARC_STACK_CHECKING
102-
/* Use stack top and down registers from restored context */
103-
add r3, r2, _K_THREAD_NO_FLOAT_SIZEOF
104-
sr r3, [_ARC_V2_KSTACK_TOP]
105-
ld_s r3, [r2, _thread_offset_to_stack_top]
102+
/* Use stack top and base registers from restored context */
103+
ld r3, [r2, _thread_offset_to_stack_base]
106104
sr r3, [_ARC_V2_KSTACK_BASE]
105+
ld r3, [r2, _thread_offset_to_stack_top]
106+
sr r3, [_ARC_V2_KSTACK_TOP]
107107
#endif
108108
/* XXX - can be moved to delay slot of _CAUSE_RIRQ ? */
109109
st_s r2, [r1, _kernel_offset_to_current]

arch/arc/core/thread.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct init_stack_frame {
5454
*
5555
* @return N/A
5656
*/
57-
void _new_thread(char *pStackMem, size_t stackSize,
57+
void _new_thread(struct k_thread *thread, char *pStackMem, size_t stackSize,
5858
_thread_entry_t pEntry,
5959
void *parameter1, void *parameter2, void *parameter3,
6060
int priority, unsigned int options)
@@ -64,12 +64,9 @@ void _new_thread(char *pStackMem, size_t stackSize,
6464
char *stackEnd = pStackMem + stackSize;
6565
struct init_stack_frame *pInitCtx;
6666

67-
struct k_thread *thread;
68-
69-
thread = _new_thread_init(pStackMem, stackSize, priority, options);
67+
_new_thread_init(thread, pStackMem, stackSize, priority, options);
7068

7169
/* carve the thread entry struct from the "base" of the stack */
72-
7370
pInitCtx = (struct init_stack_frame *)(STACK_ROUND_DOWN(stackEnd) -
7471
sizeof(struct init_stack_frame));
7572

@@ -87,7 +84,7 @@ void _new_thread(char *pStackMem, size_t stackSize,
8784
*/
8885
#ifdef CONFIG_ARC_STACK_CHECKING
8986
pInitCtx->status32 = _ARC_V2_STATUS32_SC | _ARC_V2_STATUS32_E(_ARC_V2_DEF_IRQ_LEVEL);
90-
thread->arch.stack_top = (u32_t) stackEnd;
87+
thread->arch.stack_base = (u32_t) stackEnd;
9188
#else
9289
pInitCtx->status32 = _ARC_V2_STATUS32_E(_ARC_V2_DEF_IRQ_LEVEL);
9390
#endif

arch/arc/include/kernel_arch_thread.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ struct _thread_arch {
5858
unsigned int return_value;
5959

6060
#ifdef CONFIG_ARC_STACK_CHECKING
61-
/* top of stack for hardware stack checking */
62-
u32_t stack_top;
61+
/* High address of stack region, stack grows downward from this
62+
* location. Usesd for hardware stack checking
63+
*/
64+
u32_t stack_base;
6365
#endif
6466
};
6567

0 commit comments

Comments
 (0)