Compare commits
71 Commits
collab-rus
...
v1.8.0-rc2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d8dde77df | ||
|
|
80881be124 | ||
|
|
dbdbe9b38f | ||
|
|
8cc329b97b | ||
|
|
057fbc8cb9 | ||
|
|
c16b0f12ca | ||
|
|
08c58b50d4 | ||
|
|
f083787f5c | ||
|
|
e2b8a7b149 | ||
|
|
81e9303367 | ||
|
|
271e115b18 | ||
|
|
0cd9f3f8f2 | ||
|
|
d1ef064c2e | ||
|
|
b76eb5b461 | ||
|
|
6d59a378e7 | ||
|
|
1a1a19f17d | ||
|
|
37bbe406a5 | ||
|
|
de7fb4d44b | ||
|
|
df3d38caa4 | ||
|
|
70253f2fff | ||
|
|
3f2a412707 | ||
|
|
46f26e1350 | ||
|
|
6add190cda | ||
|
|
900d404260 | ||
|
|
82a630e50c | ||
|
|
a1a97d3ebf | ||
|
|
1dbe98d7fb | ||
|
|
9ac9d4ac56 | ||
|
|
740d7e034f | ||
|
|
a6ca48d77e | ||
|
|
fc9ba5feb4 | ||
|
|
064e79b816 | ||
|
|
b4e94aee4c | ||
|
|
de0568905e | ||
|
|
2fa3b65ed4 | ||
|
|
6edd521818 | ||
|
|
f37eab2ea3 | ||
|
|
5eb8da7c50 | ||
|
|
bdeae8e12b | ||
|
|
b72f23cd6d | ||
|
|
ee64472a90 | ||
|
|
ba38320fb0 | ||
|
|
752a440ed8 | ||
|
|
c87d6c636d | ||
|
|
46354fe197 | ||
|
|
1f5e93aa1d | ||
|
|
c140e27c9d | ||
|
|
f20555c06c | ||
|
|
d4021f87e6 | ||
|
|
8fa9c9719a | ||
|
|
06fe443f70 | ||
|
|
660886affa | ||
|
|
7bfe4f58f0 | ||
|
|
8cac266902 | ||
|
|
eaa1bffaa7 | ||
|
|
f4ad56299d | ||
|
|
2b951bb3fd | ||
|
|
ec67534959 | ||
|
|
b400199240 | ||
|
|
8bc2d64c5b | ||
|
|
debf010d05 | ||
|
|
29c5a9a073 | ||
|
|
07792c17bd | ||
|
|
0a87a851b5 | ||
|
|
5210f872f3 | ||
|
|
9a00383f3b | ||
|
|
e3fd14b6d5 | ||
|
|
c87492dbe1 | ||
|
|
ce4117deb4 | ||
|
|
2a7a1c84b4 | ||
|
|
98e14bc67d |
50
Makefile
50
Makefile
@@ -1,7 +1,7 @@
|
||||
VERSION_MAJOR = 1
|
||||
VERSION_MINOR = 7
|
||||
PATCHLEVEL = 99
|
||||
VERSION_RESERVED = 0
|
||||
VERSION_MINOR = 8
|
||||
PATCHLEVEL = 0
|
||||
VERSION_RESERVED = rc2
|
||||
EXTRAVERSION =
|
||||
NAME = Zephyr Kernel
|
||||
|
||||
@@ -577,6 +577,17 @@ ifeq ($(dot-config),1)
|
||||
# oldconfig if changes are detected.
|
||||
-include include/config/auto.conf.cmd
|
||||
|
||||
# Read in DTS derived configuration, if it exists
|
||||
#
|
||||
# We check to see if the ARCH is correctly sourced before doing the -include
|
||||
# The reason for this is due to implicit rules kicking in to create this file.
|
||||
# If this occurs before the above auto.conf is sourced correctly, the build
|
||||
# will iterate over the dts conf file 2-3 times before settling down to the
|
||||
# correct output.
|
||||
ifneq ($(ARCH),)
|
||||
-include include/generated/generated_dts_board.conf
|
||||
endif
|
||||
|
||||
# To avoid any implicit rule to kick in, define an empty command
|
||||
$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
|
||||
|
||||
@@ -950,28 +961,46 @@ zephyr: $(zephyr-deps) $(KERNEL_BIN_NAME)
|
||||
ifeq ($(CONFIG_HAS_DTS),y)
|
||||
define filechk_generated_dts_board.h
|
||||
(echo "/* WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY! */"; \
|
||||
$(ZEPHYR_BASE)/scripts/extract_dts_includes.py dts/$(ARCH)/$(BOARD_NAME).dts_compiled $(ZEPHYR_BASE)/dts/$(ARCH)/yaml; \
|
||||
if test -e $(ZEPHYR_BASE)/dts/$(ARCH)/$(BOARD_NAME).fixup; then \
|
||||
echo; echo; \
|
||||
echo "/* Following definitions fixup the generated include */"; \
|
||||
echo; \
|
||||
cat $(ZEPHYR_BASE)/dts/$(ARCH)/$(BOARD_NAME).fixup; \
|
||||
$(ZEPHYR_BASE)/scripts/extract_dts_includes.py \
|
||||
-d dts/$(ARCH)/$(BOARD_NAME).dts_compiled \
|
||||
-y $(ZEPHYR_BASE)/dts/$(ARCH)/yaml \
|
||||
-f $(ZEPHYR_BASE)/dts/$(ARCH)/$(BOARD_NAME).fixup; \
|
||||
else \
|
||||
$(ZEPHYR_BASE)/scripts/extract_dts_includes.py \
|
||||
-d dts/$(ARCH)/$(BOARD_NAME).dts_compiled \
|
||||
-y $(ZEPHYR_BASE)/dts/$(ARCH)/yaml; \
|
||||
fi; \
|
||||
)
|
||||
endef
|
||||
define filechk_generated_dts_board.conf
|
||||
(echo "# WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY!"; \
|
||||
$(ZEPHYR_BASE)/scripts/extract_dts_includes.py \
|
||||
-d dts/$(ARCH)/$(BOARD_NAME).dts_compiled \
|
||||
-y $(ZEPHYR_BASE)/dts/$(ARCH)/yaml -k; \
|
||||
)
|
||||
endef
|
||||
else
|
||||
define filechk_generated_dts_board.h
|
||||
(echo "/* WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY! */";)
|
||||
endef
|
||||
define filechk_generated_dts_board.conf
|
||||
(echo "# WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY!";)
|
||||
endef
|
||||
endif
|
||||
|
||||
|
||||
include/generated/generated_dts_board.h: include/config/auto.conf FORCE
|
||||
ifeq ($(CONFIG_HAS_DTS),y)
|
||||
$(Q)$(MAKE) $(build)=dts/$(ARCH)
|
||||
endif
|
||||
$(call filechk,generated_dts_board.h)
|
||||
|
||||
include/generated/generated_dts_board.conf: include/config/auto.conf FORCE
|
||||
ifeq ($(CONFIG_HAS_DTS),y)
|
||||
$(Q)$(MAKE) $(build)=dts/$(ARCH)
|
||||
endif
|
||||
$(call filechk,generated_dts_board.conf)
|
||||
|
||||
dts: include/generated/generated_dts_board.h
|
||||
|
||||
# The actual objects are generated when descending,
|
||||
@@ -1088,7 +1117,8 @@ depend dep:
|
||||
# Directories & files removed with 'make clean'
|
||||
CLEAN_DIRS += $(MODVERDIR)
|
||||
|
||||
CLEAN_FILES += include/generated/generated_dts_board.h \
|
||||
CLEAN_FILES += include/generated/generated_dts_board.conf \
|
||||
include/generated/generated_dts_board.h \
|
||||
.old_version .tmp_System.map .tmp_version \
|
||||
.tmp_* System.map *.lnk *.map *.elf *.lst \
|
||||
*.bin *.hex *.stat *.strip staticIdt.o linker.cmd \
|
||||
|
||||
@@ -24,7 +24,7 @@ config MPU_STACK_GUARD
|
||||
config ARM_MPU
|
||||
bool "ARM MPU Support"
|
||||
depends on CPU_HAS_MPU
|
||||
depends on SOC_FAMILY_ARM || SOC_FAMILY_STM32
|
||||
depends on SOC_FAMILY_ARM || SOC_FAMILY_STM32 || SOC_FAMILY_NRF5
|
||||
select ARM_CORE_MPU
|
||||
default n
|
||||
help
|
||||
|
||||
@@ -13,6 +13,29 @@
|
||||
#include <logging/sys_log.h>
|
||||
#include <misc/__assert.h>
|
||||
|
||||
#define STACK_GUARD_REGION_SIZE 32
|
||||
|
||||
/* NXP MPU Enabled state */
|
||||
static u8_t nxp_mpu_enabled;
|
||||
|
||||
/**
|
||||
* This internal function is utilized by the MPU driver to parse the intent
|
||||
* type (i.e. THREAD_STACK_REGION) and return the correct parameter set.
|
||||
*/
|
||||
static inline u32_t _get_region_attr_by_type(u32_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case THREAD_STACK_REGION:
|
||||
return 0;
|
||||
case THREAD_STACK_GUARD_REGION:
|
||||
/* The stack guard region has to be not accessible */
|
||||
return REGION_RO_ATTR;
|
||||
default:
|
||||
/* Size 0 region */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline u8_t _get_num_regions(void)
|
||||
{
|
||||
u32_t type = (SYSMPU->CESR & SYSMPU_CESR_NRGD_MASK)
|
||||
@@ -48,6 +71,108 @@ static void _region_init(u32_t index, u32_t region_base,
|
||||
SYSMPU->WORD[index][3]);
|
||||
}
|
||||
|
||||
/* ARM Core MPU Driver API Implementation for NXP MPU */
|
||||
|
||||
/**
|
||||
* @brief enable the MPU
|
||||
*/
|
||||
void arm_core_mpu_enable(void)
|
||||
{
|
||||
if (nxp_mpu_enabled == 0) {
|
||||
/* Enable MPU */
|
||||
SYSMPU->CESR |= SYSMPU_CESR_VLD_MASK;
|
||||
|
||||
nxp_mpu_enabled = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief disable the MPU
|
||||
*/
|
||||
void arm_core_mpu_disable(void)
|
||||
{
|
||||
if (nxp_mpu_enabled == 1) {
|
||||
/* Disable MPU */
|
||||
SYSMPU->CESR &= ~SYSMPU_CESR_VLD_MASK;
|
||||
/* Clear Interrupts */
|
||||
SYSMPU->CESR |= SYSMPU_CESR_SPERR_MASK;
|
||||
|
||||
nxp_mpu_enabled = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief configure the base address and size for an MPU region
|
||||
*
|
||||
* @param type MPU region type
|
||||
* @param base base address in RAM
|
||||
* @param size size of the region
|
||||
*/
|
||||
void arm_core_mpu_configure(u8_t type, u32_t base, u32_t size)
|
||||
{
|
||||
SYS_LOG_DBG("Region info: 0x%x 0x%x", base, size);
|
||||
/*
|
||||
* The new MPU regions are are allocated per type after the statically
|
||||
* configured regions.
|
||||
*/
|
||||
u32_t region_index = mpu_config.num_regions + type;
|
||||
u32_t region_attr = _get_region_attr_by_type(type);
|
||||
u32_t last_region = _get_num_regions() - 1;
|
||||
|
||||
/*
|
||||
* The NXP MPU manages the permissions of the overlapping regions
|
||||
* doing the logic OR in between them, hence they can't be used
|
||||
* for stack/stack guard protection. For this reason the last region of
|
||||
* the MPU will be reserved.
|
||||
*
|
||||
* A consequence of this is that the SRAM is splitted in different
|
||||
* regions. In example if THREAD_STACK_GUARD_REGION is selected:
|
||||
* - SRAM before THREAD_STACK_GUARD_REGION: RW
|
||||
* - SRAM THREAD_STACK_GUARD_REGION: RO
|
||||
* - SRAM after THREAD_STACK_GUARD_REGION: RW
|
||||
*/
|
||||
/* NXP MPU supports up to 16 Regions */
|
||||
if (region_index > _get_num_regions() - 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Configure SRAM_0 region */
|
||||
/*
|
||||
* The mpu_config.sram_region contains the index of the region in
|
||||
* the mpu_config.mpu_regions array but the region 0 on the NXP MPU
|
||||
* is the background region, so on this MPU the regions are mapped
|
||||
* starting from 1, hence the mpu_config.sram_region on the data
|
||||
* structure is mapped on the mpu_config.sram_region + 1 region of
|
||||
* the MPU.
|
||||
*/
|
||||
_region_init(mpu_config.sram_region + 1,
|
||||
mpu_config.mpu_regions[mpu_config.sram_region].base,
|
||||
ENDADDR_ROUND(base),
|
||||
mpu_config.mpu_regions[mpu_config.sram_region].attr);
|
||||
|
||||
switch (type) {
|
||||
case THREAD_STACK_REGION:
|
||||
break;
|
||||
case THREAD_STACK_GUARD_REGION:
|
||||
_region_init(region_index, base,
|
||||
ENDADDR_ROUND(base + STACK_GUARD_REGION_SIZE),
|
||||
region_attr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Configure SRAM_1 region */
|
||||
_region_init(last_region,
|
||||
base + STACK_GUARD_REGION_SIZE,
|
||||
ENDADDR_ROUND(
|
||||
mpu_config.mpu_regions[mpu_config.sram_region].end),
|
||||
mpu_config.mpu_regions[mpu_config.sram_region].attr);
|
||||
|
||||
}
|
||||
|
||||
/* NXP MPU Driver Initial Setup */
|
||||
|
||||
/*
|
||||
* @brief MPU default configuration
|
||||
*
|
||||
@@ -75,6 +200,12 @@ static void _nxp_mpu_config(void)
|
||||
/* Disable Region 0 */
|
||||
SYSMPU->WORD[0][2] = 0;
|
||||
|
||||
SYS_LOG_DBG("[0] 0x%08x 0x%08x 0x%08x 0x%08x",
|
||||
SYSMPU->WORD[0][0],
|
||||
SYSMPU->WORD[0][1],
|
||||
SYSMPU->WORD[0][2],
|
||||
SYSMPU->WORD[0][3]);
|
||||
|
||||
/*
|
||||
* Configure regions:
|
||||
* r_index starts from 0 but is passed to region_init as r_index + 1,
|
||||
@@ -90,6 +221,8 @@ static void _nxp_mpu_config(void)
|
||||
/* Enable MPU */
|
||||
SYSMPU->CESR |= SYSMPU_CESR_VLD_MASK;
|
||||
|
||||
nxp_mpu_enabled = 1;
|
||||
|
||||
/* Make sure that all the registers are set before proceeding */
|
||||
__DSB();
|
||||
__ISB();
|
||||
|
||||
@@ -25,6 +25,6 @@ config NUM_IRQS
|
||||
|
||||
config SYS_CLOCK_HW_CYCLES_PER_SEC
|
||||
int
|
||||
default 84000000
|
||||
default 120000000
|
||||
|
||||
endif # SOC_SERIES_SAM4S
|
||||
|
||||
@@ -45,18 +45,9 @@ config SOC_ATMEL_SAM4S_EXT_MAINCK
|
||||
Says n here will use the internal fast RC oscillator
|
||||
running at 12 MHz.
|
||||
|
||||
config SOC_ATMEL_SAM4S_MDIV
|
||||
int "MDIV"
|
||||
default 1
|
||||
range 1 4
|
||||
help
|
||||
This divisor defines a ratio between processor clock (HCLK)
|
||||
and master clock (MCK):
|
||||
MCK = HCLK / MDIV
|
||||
|
||||
config SOC_ATMEL_SAM4S_PLLA_MULA
|
||||
hex "PLL MULA"
|
||||
default 0x06
|
||||
default 0x09
|
||||
help
|
||||
This is the multiplier (MULA) used by the PLL.
|
||||
The processor clock is (MAINCK * (MULA + 1) / DIVA).
|
||||
@@ -64,8 +55,8 @@ config SOC_ATMEL_SAM4S_PLLA_MULA
|
||||
Board config file can override this settings
|
||||
for a particular board.
|
||||
|
||||
With default of MULA == 6, and DIVA == 1,
|
||||
PLL is running at 7 times of main clock.
|
||||
With default of MULA == 9, and DIVA == 1,
|
||||
PLL is running at 10 times of main clock.
|
||||
|
||||
config SOC_ATMEL_SAM4S_PLLA_DIVA
|
||||
hex "PLL DIVA"
|
||||
@@ -77,8 +68,8 @@ config SOC_ATMEL_SAM4S_PLLA_DIVA
|
||||
Board config file can override this settings
|
||||
for a particular board.
|
||||
|
||||
With default of MULA == 6, and DIVA == 1,
|
||||
PLL is running at 7 times of main clock.
|
||||
With default of MULA == 9, and DIVA == 1,
|
||||
PLL is running at 10 times of main clock.
|
||||
|
||||
config SOC_ATMEL_SAM4S_WAIT_MODE
|
||||
bool "Atmel SAM4S goes to Wait mode instead of Sleep mode"
|
||||
@@ -89,30 +80,4 @@ config SOC_ATMEL_SAM4S_WAIT_MODE
|
||||
to achieve this, make CPU go to Wait mode instead of Sleep
|
||||
mode while using external crystal oscillator for main clock.
|
||||
|
||||
config SOC_ATMEL_SAM4S_PLLB_MULB
|
||||
hex "PLL MULB"
|
||||
default 0x03
|
||||
help
|
||||
This is the multiplier (MULA) used by the PLL.
|
||||
The processor clock is (MAINCK * (MULA + 1) / DIVA).
|
||||
|
||||
Board config file can override this settings
|
||||
for a particular board.
|
||||
|
||||
With default of MULA == 6, and DIVA == 1,
|
||||
PLL is running at 7 times of main clock.
|
||||
|
||||
config SOC_ATMEL_SAM4S_PLLB_DIVB
|
||||
hex "PLL DIVB"
|
||||
default 0x01
|
||||
help
|
||||
This is the divider (DIVB) used by the PLL.
|
||||
The processor clock is (MAINCK * (MULB + 1) / DIVB).
|
||||
|
||||
Board config file can override this settings
|
||||
for a particular board.
|
||||
|
||||
With default of MULB == 6, and DIVB == 1,
|
||||
PLL is running at 7 times of main clock.
|
||||
|
||||
endif # SOC_SERIES_SAM4S
|
||||
|
||||
@@ -17,52 +17,9 @@
|
||||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <soc.h>
|
||||
|
||||
#include <arch/cpu.h>
|
||||
#include <cortex_m/exc.h>
|
||||
|
||||
/*
|
||||
* PLL clock = Main * (MULA + 1) / DIVA
|
||||
*
|
||||
* By default, MULA == 6, DIVA == 1.
|
||||
* With main crystal running at 12 MHz,
|
||||
* PLL = 12 * (6 + 1) / 1 = 84 MHz
|
||||
*
|
||||
* With processor clock prescaler at 1,
|
||||
* the processor clock is at 84 MHz.
|
||||
*/
|
||||
#define PMC_CKGR_PLLAR_MULA \
|
||||
((CONFIG_SOC_ATMEL_SAM4S_PLLA_MULA) << 16)
|
||||
#define PMC_CKGR_PLLAR_DIVA \
|
||||
((CONFIG_SOC_ATMEL_SAM4S_PLLA_DIVA) << 0)
|
||||
|
||||
/*
|
||||
* PLL clock = Main * (MULB + 1) / DIVB
|
||||
*
|
||||
* By default, MULB == 6, DIVB == 1.
|
||||
* With main crystal running at 12 MHz,
|
||||
* PLL = 12 * (6 + 1) / 1 = 84 MHz
|
||||
*
|
||||
* With processor clock prescaler at 1,
|
||||
* the processor clock is at 84 MHz.
|
||||
*/
|
||||
#define PMC_CKGR_PLLBR_MULB \
|
||||
((CONFIG_SOC_ATMEL_SAM4S_PLLB_MULB) << 16)
|
||||
#define PMC_CKGR_PLLBR_DIVB \
|
||||
((CONFIG_SOC_ATMEL_SAM4S_PLLB_DIVB) << 0)
|
||||
|
||||
#if CONFIG_SOC_ATMEL_SAM4S_MDIV == 1
|
||||
#define SOC_ATMEL_SAM4S_MDIV PMC_MCKR_MDIV_EQ_PCK
|
||||
#elif CONFIG_SOC_ATMEL_SAM4S_MDIV == 2
|
||||
#define SOC_ATMEL_SAM4S_MDIV PMC_MCKR_MDIV_PCK_DIV2
|
||||
#elif CONFIG_SOC_ATMEL_SAM4S_MDIV == 3
|
||||
#define SOC_ATMEL_SAM4S_MDIV PMC_MCKR_MDIV_PCK_DIV3
|
||||
#elif CONFIG_SOC_ATMEL_SAM4S_MDIV == 4
|
||||
#define SOC_ATMEL_SAM4S_MDIV PMC_MCKR_MDIV_PCK_DIV4
|
||||
#else
|
||||
#error "Invalid CONFIG_SOC_ATMEL_SAM4S_MDIV define value"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Setup various clock on SoC at boot time.
|
||||
*
|
||||
@@ -77,11 +34,12 @@ static ALWAYS_INLINE void clock_init(void)
|
||||
|
||||
#ifdef CONFIG_SOC_ATMEL_SAM4S_EXT_SLCK
|
||||
/* Switch slow clock to the external 32 KHz crystal oscillator. */
|
||||
SUPC->SUPC_CR = SUPC_CR_KEY | SUPC_CR_XTALSEL;
|
||||
SUPC->SUPC_CR = SUPC_CR_KEY_PASSWD | SUPC_CR_XTALSEL_CRYSTAL_SEL;
|
||||
|
||||
/* Wait for oscillator to be stabilized. */
|
||||
while (!(SUPC->SUPC_SR & SUPC_SR_OSCSEL))
|
||||
while (!(SUPC->SUPC_SR & SUPC_SR_OSCSEL)) {
|
||||
;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SOC_ATMEL_SAM4S_EXT_SLCK */
|
||||
|
||||
@@ -93,67 +51,74 @@ static ALWAYS_INLINE void clock_init(void)
|
||||
/* Start the external crystal oscillator. */
|
||||
PMC->CKGR_MOR = CKGR_MOR_KEY_PASSWD
|
||||
/* Fast RC oscillator frequency is at 4 MHz. */
|
||||
| CKGR_MOR_MOSCRCF_4MHz
|
||||
| CKGR_MOR_MOSCRCF_4_MHz
|
||||
/*
|
||||
* We select maximum setup time. While start up time
|
||||
* could be shortened this optimization is not deemed
|
||||
* critical right now.
|
||||
*/
|
||||
| CKGR_MOR_MOSCXTST(0xFFu)
|
||||
/* RC OSC must stay on. */
|
||||
| PMC_CKGR_MOR_MOSCRCEN
|
||||
| PMC_CKGR_MOR_MOSCXTEN;
|
||||
/* RC oscillator must stay on. */
|
||||
| CKGR_MOR_MOSCRCEN
|
||||
| CKGR_MOR_MOSCXTEN;
|
||||
|
||||
/* Wait for oscillator to be stabilized. */
|
||||
while (!(PMC->PMC_SR & PMC_SR_MOSCXTS))
|
||||
while (!(PMC->PMC_SR & PMC_SR_MOSCXTS)) {
|
||||
;
|
||||
}
|
||||
|
||||
/* Select the external crystal oscillator as the main clock source. */
|
||||
PMC->CKGR_MOR = PMC_CKGR_MOR_KEY
|
||||
| PMC_CKGR_MOR_MOSCRCF_4MHZ
|
||||
| PMC_CKGR_MOR_MOSCRCEN
|
||||
| PMC_CKGR_MOR_MOSCXTEN
|
||||
| PMC_CKGR_MOR_MOSCXTST
|
||||
| PMC_CKGR_MOR_MOSCSEL;
|
||||
PMC->CKGR_MOR = CKGR_MOR_KEY_PASSWD
|
||||
| CKGR_MOR_MOSCRCF_4_MHz
|
||||
| CKGR_MOR_MOSCRCEN
|
||||
| CKGR_MOR_MOSCXTEN
|
||||
| CKGR_MOR_MOSCXTST(0xFFu)
|
||||
| CKGR_MOR_MOSCSEL;
|
||||
|
||||
/* Wait for external oscillator to be selected. */
|
||||
while (!(PMC->PMC_SR & PMC_INT_MOSCSELS))
|
||||
while (!(PMC->PMC_SR & PMC_SR_MOSCSELS)) {
|
||||
;
|
||||
}
|
||||
|
||||
/* Turn off RC OSC, not used any longer, to save power */
|
||||
/* Turn off RC oscillator, not used any longer, to save power */
|
||||
PMC->CKGR_MOR = CKGR_MOR_KEY_PASSWD
|
||||
| CKGR_MOR_MOSCSEL
|
||||
| CKGR_MOR_MOSCXTST(0xFFu)
|
||||
| CKGR_MOR_MOSCXTEN;
|
||||
|
||||
/* Wait for the RC oscillator to be turned off. */
|
||||
while (PMC->PMC_SR & PMC_SR_MOSCRCS)
|
||||
while (PMC->PMC_SR & PMC_SR_MOSCRCS) {
|
||||
;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SOC_ATMEL_SAM4S_WAIT_MODE
|
||||
/*
|
||||
* Instruct CPU to enter Wait mode instead of Sleep mode to
|
||||
* keep Processor Clock (HCLK) and thus be able to debug
|
||||
* CPU using JTAG
|
||||
* CPU using JTAG.
|
||||
*/
|
||||
PMC->PMC_FSMR |= PMC_FSMR_LPM;
|
||||
#endif
|
||||
#else
|
||||
/*
|
||||
* Set main fast RC oscillator.
|
||||
*/
|
||||
/* Setup main fast RC oscillator. */
|
||||
|
||||
/*
|
||||
* NOTE: MOSCREF must be changed only if MOSCRCS is set in the PMC_SR
|
||||
* NOTE: MOSCRCF must be changed only if MOSCRCS is set in the PMC_SR
|
||||
* register, should normally be the case.
|
||||
*/
|
||||
while (!(PMC->PMC_SR & PMC_SR_MOSCRCS)) {
|
||||
;
|
||||
}
|
||||
|
||||
/* Set main fast RC oscillator to 12 MHz. */
|
||||
PMC->CKGR_MOR = CKGR_MOR_KEY_PASSWD
|
||||
| CKGR_MOR_MOSCRCF_12MHZ
|
||||
| CKGR_MOR_MOSCRCF_12_MHz
|
||||
| CKGR_MOR_MOSCRCEN;
|
||||
|
||||
/* Wait for RC oscillator to stabilize. */
|
||||
while (!(PMC->PMC_SR & PMC_SR_MOSCRCS))
|
||||
while (!(PMC->PMC_SR & PMC_SR_MOSCRCS)) {
|
||||
;
|
||||
}
|
||||
#endif /* CONFIG_SOC_ATMEL_SAM4S_EXT_MAINCK */
|
||||
|
||||
/*
|
||||
@@ -165,14 +130,15 @@ static ALWAYS_INLINE void clock_init(void)
|
||||
PMC->PMC_MCKR = reg_val | PMC_MCKR_CSS_MAIN_CLK;
|
||||
|
||||
/* Wait for clock selection to complete. */
|
||||
while (!(PMC->PMC_SR & PMC_SR_MCKRDY))
|
||||
while (!(PMC->PMC_SR & PMC_SR_MCKRDY)) {
|
||||
;
|
||||
}
|
||||
|
||||
/* Setup PLLA. */
|
||||
PMC->CKGR_PLLAR = CKGR_PLLAR_ONE
|
||||
| PMC_CKGR_PLLAR_MULA
|
||||
| CKGR_PLLAR_MULA(CONFIG_SOC_ATMEL_SAM4S_PLLA_MULA)
|
||||
| CKGR_PLLAR_PLLACOUNT(0x3Fu)
|
||||
| PMC_CKGR_PLLAR_DIVA;
|
||||
| CKGR_PLLAR_DIVA(CONFIG_SOC_ATMEL_SAM4S_PLLA_DIVA);
|
||||
|
||||
/*
|
||||
* NOTE: Both MULA and DIVA must be set to a value greater than 0 or
|
||||
@@ -181,23 +147,9 @@ static ALWAYS_INLINE void clock_init(void)
|
||||
*/
|
||||
|
||||
/* Wait for PLL lock. */
|
||||
while (!(PMC->PMC_SR & PMC_SR_LOCKA))
|
||||
;
|
||||
|
||||
/* Setup PLLB. */
|
||||
PMC->CKGR_PLLBR = PMC_CKGR_PLLBR_MULB
|
||||
| CKGR_PLLBR_PLLBCOUNT(0x3Fu)
|
||||
| PMC_CKGR_PLLBR_DIVB;
|
||||
|
||||
/*
|
||||
* NOTE: Both MULB and DIVB must be set to a value greater than 0 or
|
||||
* otherwise PLL will be disabled. In this case we would get stuck in
|
||||
* the following loop.
|
||||
*/
|
||||
|
||||
/* Wait for PLL lock. */
|
||||
while (!(PMC->PMC_SR & PMC_SR_LOCKB))
|
||||
while (!(PMC->PMC_SR & PMC_SR_LOCKA)) {
|
||||
;
|
||||
}
|
||||
|
||||
/*
|
||||
* Final setup of the Master Clock
|
||||
@@ -205,7 +157,7 @@ static ALWAYS_INLINE void clock_init(void)
|
||||
|
||||
/*
|
||||
* NOTE: PMC_MCKR must not be programmed in a single write operation.
|
||||
* If CSS, MDIV or PRES are modified we must wait for MCKRDY bit to be
|
||||
* If CSS or PRES are modified we must wait for MCKRDY bit to be
|
||||
* set again.
|
||||
*/
|
||||
|
||||
@@ -214,24 +166,18 @@ static ALWAYS_INLINE void clock_init(void)
|
||||
PMC->PMC_MCKR = reg_val | PMC_MCKR_PRES_CLK_1;
|
||||
|
||||
/* Wait for Master Clock setup to complete */
|
||||
while (!(PMC->PMC_SR & PMC_SR_MCKRDY))
|
||||
;
|
||||
|
||||
/* Setup divider - Processor Clock (HCLK) / Master Clock (MCK). */
|
||||
reg_val = PMC->PMC_MCKR & ~PMC_MCKR_MDIV_Msk;
|
||||
PMC->PMC_MCKR = reg_val | SOC_ATMEL_SAM4S_MDIV;
|
||||
|
||||
/* Wait for Master Clock setup to complete. */
|
||||
while (!(PMC->PMC_SR & PMC_SR_MCKRDY))
|
||||
while (!(PMC->PMC_SR & PMC_SR_MCKRDY)) {
|
||||
;
|
||||
}
|
||||
|
||||
/* Finally select PLL as Master Clock source. */
|
||||
reg_val = PMC->PMC_MCKR & ~PMC_MCKR_CSS_Msk;
|
||||
PMC->PMC_MCKR = reg_val | PMC_MCKR_CSS_PLLA_CLK;
|
||||
|
||||
/* Wait for Master Clock setup to complete. */
|
||||
while (!(PMC->PMC_SR & PMC_SR_MCKRDY))
|
||||
while (!(PMC->PMC_SR & PMC_SR_MCKRDY)) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,14 +201,16 @@ static int atmel_sam4s_init(struct device *arg)
|
||||
|
||||
/*
|
||||
* Set FWS (Flash Wait State) value before increasing Master Clock
|
||||
* (MCK) frequency.
|
||||
* TODO: set FWS based on the actual MCK frequency and VDDIO value
|
||||
* rather than maximum supported 150 MHz at standard VDDIO=2.7V
|
||||
* (MCK) frequency. Look at table 44.73 in the SAM4S datasheet.
|
||||
* This is set to the highest number of read cycles because it won't
|
||||
* hurt lower clock frequencies. However, a high frequency with too
|
||||
* few read cycles could cause flash read problems. FWS 5 (6 cycles)
|
||||
* is the safe setting for all of this SoCs usable frequencies.
|
||||
* TODO: Add code to handle SAM4SD devices that have 2 EFCs.
|
||||
*/
|
||||
EFC0->EEFC_FMR = EEFC_FMR_FWS(4);
|
||||
EFC1->EEFC_FMR = EEFC_FMR_FWS(4);
|
||||
EFC0->EEFC_FMR = EEFC_FMR_FWS(5);
|
||||
|
||||
/* Setup master clock */
|
||||
/* Setup system clocks. */
|
||||
clock_init();
|
||||
|
||||
/*
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#define SOC_ATMEL_SAM_HCLK_FREQ_HZ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC
|
||||
|
||||
/** Master Clock (MCK) Frequency */
|
||||
#define SOC_ATMEL_SAM_MCK_FREQ_HZ \
|
||||
(SOC_ATMEL_SAM_HCLK_FREQ_HZ / CONFIG_SOC_ATMEL_SAM4S_MDIV)
|
||||
#define SOC_ATMEL_SAM_MCK_FREQ_HZ SOC_ATMEL_SAM_HCLK_FREQ_HZ
|
||||
|
||||
#endif /* _ATMEL_SAM4S_SOC_H_ */
|
||||
|
||||
@@ -10,21 +10,21 @@
|
||||
* modules to correctly configure GPIO controller.
|
||||
*/
|
||||
|
||||
#ifndef _ATMEL_SAM_SOC_PINMAP_H_
|
||||
#define _ATMEL_SAM_SOC_PINMAP_H_
|
||||
#ifndef _ATMEL_SAM4S_SOC_PINMAP_H_
|
||||
#define _ATMEL_SAM4S_SOC_PINMAP_H_
|
||||
|
||||
#include <soc.h>
|
||||
|
||||
/* Universal Asynchronous Receiver Transmitter (UART) */
|
||||
|
||||
#define PIN_UART0_RXD {PIO_PA9A_UART0_URXD0, PIOA, ID_PIOA, SOC_GPIO_FUNC_A}
|
||||
#define PIN_UART0_TXD {PIO_PA10A_UART0_UTXD0, PIOA, ID_PIOA, SOC_GPIO_FUNC_A}
|
||||
#define PIN_UART0_RXD {PIO_PA9A_URXD0, PIOA, ID_PIOA, SOC_GPIO_FUNC_A}
|
||||
#define PIN_UART0_TXD {PIO_PA10A_UTXD0, PIOA, ID_PIOA, SOC_GPIO_FUNC_A}
|
||||
|
||||
#define PINS_UART0 {PIN_UART0_RXD, PIN_UART0_TXD}
|
||||
|
||||
#define PIN_UART1_RXD {PIO_PB2A_UART1_URXD1, PIOA, ID_PIOA, SOC_GPIO_FUNC_A}
|
||||
#define PIN_UART1_TXD {PIO_PB3A_UART1_UTXD1, PIOA, ID_PIOA, SOC_GPIO_FUNC_A}
|
||||
#define PIN_UART1_RXD {PIO_PB2A_URXD1, PIOB, ID_PIOB, SOC_GPIO_FUNC_A}
|
||||
#define PIN_UART1_TXD {PIO_PB3A_UTXD1, PIOB, ID_PIOB, SOC_GPIO_FUNC_A}
|
||||
|
||||
#define PINS_UART1 {PIN_UART1_RXD, PIN_UART1_TXD}
|
||||
|
||||
#endif /* _ATMEL_SAM_SOC_PINMAP_H_ */
|
||||
#endif /* _ATMEL_SAM4S_SOC_PINMAP_H_ */
|
||||
|
||||
@@ -10,6 +10,7 @@ config SOC_SERIES_NRF52X
|
||||
select CPU_CORTEX_M
|
||||
select CPU_CORTEX_M4
|
||||
select CPU_HAS_FPU
|
||||
select CPU_HAS_MPU
|
||||
select SOC_FAMILY_NRF5
|
||||
select NRF_RTC_TIMER
|
||||
select CLOCK_CONTROL
|
||||
|
||||
@@ -26,3 +26,11 @@ config SOC_NRF52840_QIAA
|
||||
select SOC_NRF52840
|
||||
|
||||
endchoice
|
||||
|
||||
config ARM_MPU_NRF52X
|
||||
bool "Enable MPU on nRF52"
|
||||
depends on CPU_HAS_MPU
|
||||
select ARM_MPU
|
||||
default n
|
||||
help
|
||||
Enable MPU support on Nordic Semiconductor nRF52x series ICs.
|
||||
|
||||
@@ -10,6 +10,7 @@ soc-cflags += -DNRF52840_XXAA
|
||||
endif
|
||||
|
||||
obj-y += soc.o
|
||||
obj-$(CONFIG_ARM_MPU_NRF52X) += mpu_regions.o
|
||||
|
||||
zephyr: $(KERNEL_HEX_NAME)
|
||||
all: $(KERNEL_HEX_NAME)
|
||||
|
||||
42
arch/arm/soc/nordic_nrf5/nrf52/mpu_mem_cfg.h
Normal file
42
arch/arm/soc/nordic_nrf5/nrf52/mpu_mem_cfg.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Linaro Limited.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef _NRF52X_MPU_MEM_CFG_H_
|
||||
#define _NRF52X_MPU_MEM_CFG_H_
|
||||
|
||||
#include <soc.h>
|
||||
#include <arch/arm/cortex_m/mpu/arm_mpu.h>
|
||||
|
||||
/* Flash Region Definitions */
|
||||
#if CONFIG_FLASH_SIZE == 64
|
||||
#define REGION_FLASH_SIZE REGION_64K
|
||||
#elif CONFIG_FLASH_SIZE == 128
|
||||
#define REGION_FLASH_SIZE REGION_128K
|
||||
#elif CONFIG_FLASH_SIZE == 256
|
||||
#define REGION_FLASH_SIZE REGION_256K
|
||||
#elif CONFIG_FLASH_SIZE == 512
|
||||
#define REGION_FLASH_SIZE REGION_512K
|
||||
#elif CONFIG_FLASH_SIZE == 1024
|
||||
#define REGION_FLASH_SIZE REGION_1M
|
||||
#elif CONFIG_FLASH_SIZE == 2048
|
||||
#define REGION_FLASH_SIZE REGION_2M
|
||||
#else
|
||||
#error "Unsupported configuration"
|
||||
#endif
|
||||
|
||||
/* SRAM Region Definitions */
|
||||
#if CONFIG_SRAM_SIZE == 32
|
||||
#define REGION_SRAM_0_SIZE REGION_32K
|
||||
#elif CONFIG_SRAM_SIZE == 64
|
||||
#define REGION_SRAM_0_SIZE REGION_64K
|
||||
#elif CONFIG_SRAM_SIZE == 128
|
||||
#define REGION_SRAM_0_SIZE REGION_128K
|
||||
#elif CONFIG_SRAM_SIZE == 256
|
||||
#define REGION_SRAM_0_SIZE REGION_256K
|
||||
#else
|
||||
#error "Unsupported configuration"
|
||||
#endif
|
||||
|
||||
#endif /* _NRF52X_MPU_MEM_CFG_H_ */
|
||||
42
arch/arm/soc/nordic_nrf5/nrf52/mpu_regions.c
Normal file
42
arch/arm/soc/nordic_nrf5/nrf52/mpu_regions.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Linaro Limited.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <soc.h>
|
||||
#include <arch/arm/cortex_m/mpu/arm_mpu.h>
|
||||
|
||||
#include "mpu_mem_cfg.h"
|
||||
|
||||
#define XICR_BASE 0x10000000
|
||||
#define PERIPH_BASE 0x40000000
|
||||
#define M4_PPB_BASE 0xE0000000
|
||||
|
||||
static struct arm_mpu_region mpu_regions[] = {
|
||||
/* Region 0 */
|
||||
MPU_REGION_ENTRY("FLASH_0",
|
||||
CONFIG_FLASH_BASE_ADDRESS,
|
||||
REGION_FLASH_ATTR(REGION_FLASH_SIZE)),
|
||||
/* Region 1 */
|
||||
MPU_REGION_ENTRY("SRAM_0",
|
||||
CONFIG_SRAM_BASE_ADDRESS,
|
||||
REGION_RAM_ATTR(REGION_SRAM_0_SIZE)),
|
||||
/* Region 2 */
|
||||
MPU_REGION_ENTRY("FACTUSERCFG_0",
|
||||
XICR_BASE,
|
||||
REGION_IO_ATTR(REGION_8K)),
|
||||
/* Region 3 */
|
||||
MPU_REGION_ENTRY("PERIPH_0",
|
||||
PERIPH_BASE,
|
||||
REGION_IO_ATTR(REGION_512M)),
|
||||
/* Region 4 */
|
||||
MPU_REGION_ENTRY("PPB_0",
|
||||
M4_PPB_BASE,
|
||||
REGION_PPB_ATTR(REGION_64K)),
|
||||
};
|
||||
|
||||
struct arm_mpu_config mpu_config = {
|
||||
.num_regions = ARRAY_SIZE(mpu_regions),
|
||||
.mpu_regions = mpu_regions,
|
||||
};
|
||||
@@ -46,4 +46,5 @@ static struct nxp_mpu_region mpu_regions[] = {
|
||||
struct nxp_mpu_config mpu_config = {
|
||||
.num_regions = ARRAY_SIZE(mpu_regions),
|
||||
.mpu_regions = mpu_regions,
|
||||
.sram_region = 3,
|
||||
};
|
||||
|
||||
@@ -3,6 +3,9 @@ CONFIG_SOC_FAMILY_NRF5=y
|
||||
CONFIG_SOC_SERIES_NRF52X=y
|
||||
CONFIG_BOARD_96B_NITROGEN=y
|
||||
|
||||
# Enable MPU
|
||||
CONFIG_ARM_MPU_NRF52X=y
|
||||
|
||||
# enable uart driver
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_NRF5=y
|
||||
|
||||
4
boards/arm/bbc_microbit/Makefile.board
Normal file
4
boards/arm/bbc_microbit/Makefile.board
Normal file
@@ -0,0 +1,4 @@
|
||||
PYOCD_TARGET = nrf51
|
||||
FLASH_SCRIPT=pyocd.sh
|
||||
|
||||
export PYOCD_TARGET FLASH_SCRIPT
|
||||
@@ -4,6 +4,9 @@ CONFIG_SOC_SERIES_NRF52X=y
|
||||
CONFIG_SOC_NRF52840_QIAA=y
|
||||
CONFIG_BOARD_NRF52840_PCA10056=y
|
||||
|
||||
# Enable MPU
|
||||
CONFIG_ARM_MPU_NRF52X=y
|
||||
|
||||
# enable uart driver
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_NRF5=y
|
||||
|
||||
@@ -4,6 +4,9 @@ CONFIG_SOC_SERIES_NRF52X=y
|
||||
CONFIG_SOC_NRF52832_QFAA=y
|
||||
CONFIG_BOARD_NRF52_BLENANO2=y
|
||||
|
||||
# Enable MPU
|
||||
CONFIG_ARM_MPU_NRF52X=y
|
||||
|
||||
# enable uart driver
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_NRF5=y
|
||||
|
||||
@@ -4,6 +4,9 @@ CONFIG_SOC_SERIES_NRF52X=y
|
||||
CONFIG_SOC_NRF52832_QFAA=y
|
||||
CONFIG_BOARD_NRF52_PCA10040=y
|
||||
|
||||
# Enable MPU
|
||||
CONFIG_ARM_MPU_NRF52X=y
|
||||
|
||||
# enable uart driver
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_NRF5=y
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
Supported Boards
|
||||
################
|
||||
|
||||
To add support documentation for a new board, please use the template available
|
||||
under :file:`doc/templates/board.tmpl`
|
||||
|
||||
X86 Boards
|
||||
**********
|
||||
@@ -48,11 +50,3 @@ XTENSA Boards
|
||||
:glob:
|
||||
|
||||
xtensa/**/*
|
||||
|
||||
A list of additional supported boards can be found on the `Zephyr project wiki`_.
|
||||
|
||||
To add a new board, please use the template available under
|
||||
:file:`doc/templates/board.tmpl`
|
||||
|
||||
|
||||
.. _Zephyr project wiki: https://wiki.zephyrproject.org/view/Supported_Boards
|
||||
|
||||
@@ -41,8 +41,6 @@ The project's documentation currently comprises the following items:
|
||||
* Script-generated material for kernel configuration options based on kconfig
|
||||
files found in the source code tree
|
||||
|
||||
* Additional material on https://wiki.zephyrproject.org
|
||||
|
||||
The reStructuredText files are processed by the Sphinx documentation system,
|
||||
and make use of the breathe extension for including the doxygen-generated API
|
||||
material. Additional tools are required to generate the
|
||||
|
||||
@@ -502,7 +502,8 @@ depth is needed. The developer must supply a :file:`Makefile` for the
|
||||
Application-specific source code should not use symbol name prefixes that have
|
||||
been reserved by the kernel for its own use. For more information, see
|
||||
|
||||
`Naming Conventions <https://wiki.zephyrproject.org/view/Coding_conventions#Naming_Conventions>`_.
|
||||
`Naming Conventions
|
||||
<https://github.com/zephyrproject-rtos/zephyr/wiki/Naming-Conventions>`_.
|
||||
|
||||
|
||||
The following requirements apply to all Makefiles in the :file:`src`
|
||||
|
||||
@@ -8,7 +8,7 @@ licenses, the naming conventions, the code submission infrastructure, the
|
||||
review process and the code documentation can be found on the
|
||||
Zephyr Project wiki.
|
||||
|
||||
* https://wiki.zephyrproject.org/view/Collaboration_Guidelines
|
||||
* https://github.com/zephyrproject-rtos/zephyr/wiki/Contribution-Guide
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
@@ -149,7 +149,7 @@ failures, etc., should be handled by assertions.
|
||||
|
||||
When it is appropriate to return error conditions for the caller to check, 0
|
||||
should be returned on success and a POSIX errno.h code returned on failure.
|
||||
See https://wiki.zephyrproject.org/view/Coding_conventions#Return_Codes for
|
||||
See https://github.com/zephyrproject-rtos/zephyr/wiki/Naming-Conventions#return-codes for
|
||||
details about this.
|
||||
|
||||
A driver implementing a particular subsystem will define the real implementation
|
||||
|
||||
@@ -55,7 +55,7 @@ Install the required packages in a Ubuntu host system with:
|
||||
.. code-block:: console
|
||||
|
||||
$ sudo apt-get install git make gcc g++ python3-ply ncurses-dev \
|
||||
python3-yaml python2.7 dfu-util
|
||||
python3-yaml dfu-util dtc
|
||||
|
||||
Install the required packages in a Fedora host system with:
|
||||
|
||||
@@ -64,7 +64,7 @@ Install the required packages in a Fedora host system with:
|
||||
$ sudo dnf group install "Development Tools"
|
||||
$ sudo dnf install git make gcc glibc-static \
|
||||
libstdc++-static python3-ply ncurses-devel \
|
||||
python-yaml python2 dfu-util
|
||||
python-yaml dfu-util dtc
|
||||
|
||||
.. _zephyr_sdk:
|
||||
|
||||
@@ -87,6 +87,8 @@ following architectures:
|
||||
|
||||
* :abbr:`NIOS II`
|
||||
|
||||
* :abbr:`Xtensa`
|
||||
|
||||
Follow these steps to install the SDK on your Linux host system.
|
||||
|
||||
#. Download the latest SDK self-extractable binary.
|
||||
|
||||
@@ -9,17 +9,17 @@ After completing these steps, you will be able to compile and run your Zephyr
|
||||
applications on the following Mac OS version:
|
||||
|
||||
* Mac OS X 10.11 (El Capitan)
|
||||
* macOS Sierra 10.12
|
||||
|
||||
Developing for Zephyr on OS X generally requires you to build the
|
||||
toolchain yourself. However, if there is already an OS X toolchain for your
|
||||
Developing for Zephyr on macOS generally requires you to build the
|
||||
toolchain yourself. However, if there is already an macOS toolchain for your
|
||||
target architecture you can use it directly.
|
||||
|
||||
Using a 3rd Party toolchain
|
||||
***************************
|
||||
|
||||
If a toolchain is available for the architecture you plan to build for, then
|
||||
you can use it as explained in:
|
||||
:ref:`third_party_x_compilers`.
|
||||
you can use it as explained in: :ref:`third_party_x_compilers`.
|
||||
|
||||
An example of an available 3rd party toolchain is GCC ARM Embedded for the
|
||||
Cortex-M family of cores.
|
||||
@@ -40,8 +40,8 @@ build for and install tools that the build system requires.
|
||||
Before proceeding with the build, ensure your OS is up to date.
|
||||
|
||||
First, install the :program:`Homebrew` (The missing package manager for
|
||||
OS X). Homebrew is a free and open-source software package management system
|
||||
that simplifies the installation of software on Apple's OS X operating
|
||||
macOS). Homebrew is a free and open-source software package management system
|
||||
that simplifies the installation of software on Apple's macOS operating
|
||||
system.
|
||||
|
||||
To install :program:`Homebrew`, visit the `Homebrew site`_ and follow the
|
||||
@@ -53,12 +53,28 @@ missing dependency. If so, follow please follow the instructions provided.
|
||||
After Homebrew was successfully installed, install the following tools using
|
||||
the brew command line.
|
||||
|
||||
Install tools to build Zephyr binaries:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ brew install gettext qemu help2man mpfr gmp coreutils wget python3 dfu-util
|
||||
$ brew install dfu-util qemu dtc python3
|
||||
$ pip3 install ply pyyaml
|
||||
|
||||
Install tools needed for building the toolchain (if needed):
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ brew install gettext help2man mpfr gmp coreutils wget
|
||||
$ brew tap homebrew/dupes
|
||||
$ brew install grep --with-default-names
|
||||
$ pip3 install ply
|
||||
|
||||
|
||||
To build the toolchain, you will need the latest version of crosstool-ng (1.23).
|
||||
This version was not available via brew when writing this documentation, you can
|
||||
however try and see if you get 1.23 installed:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ brew install crosstool-ng
|
||||
|
||||
Alternatively you can install the latest version of :program:`crosstool-ng`
|
||||
@@ -67,9 +83,9 @@ latest version usually supports the latest released compilers.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2
|
||||
$ tar xvf crosstool-ng-1.22.0.tar.bz2
|
||||
$ cd crosstool-ng/
|
||||
$ wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.23.0.tar.bz2
|
||||
$ tar xvf crosstool-ng-1.23.0.tar.bz2
|
||||
$ cd crosstool-ng-1.23.0/
|
||||
$ ./configure
|
||||
$ make
|
||||
$ make install
|
||||
@@ -92,7 +108,8 @@ Alternatively you can use the script below to create the image:
|
||||
.. code-block:: bash
|
||||
|
||||
#!/bin/bash
|
||||
ImageName=CrossToolNG ImageNameExt=${ImageName}.sparseimage
|
||||
ImageName=CrossToolNG
|
||||
ImageNameExt=${ImageName}.sparseimage
|
||||
diskutil umount force /Volumes/${ImageName} && true
|
||||
rm -f ${ImageNameExt} && true
|
||||
hdiutil create ${ImageName} -volname ${ImageName} -type SPARSE -size 8g -fs HFSX
|
||||
@@ -116,15 +133,22 @@ both ARM and X86 that can be used to pre-select the options needed
|
||||
for building the toolchain.
|
||||
The configuration files can be found in :file:`${ZEPHYR_BASE}/scripts/cross_compiler/`.
|
||||
|
||||
Currently the following configurations are provided:
|
||||
|
||||
* i586.config: for standard ABI, for example for Galileo and qemu_x86
|
||||
* iamcu.config: for IAMCU ABI, for example for the Arduino 101
|
||||
* nios2.config: for Nios II boards
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ cp ${ZEPHYR_BASE}/scripts/cross_compiler/x86.config .config
|
||||
$ cp ${ZEPHYR_BASE}/scripts/cross_compiler/i586.config .config
|
||||
|
||||
You can create a toolchain configuration or customize an existing configuration
|
||||
yourself using the configuration menus:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ export CT_PREFIX=/Volumes/CrossToolNG
|
||||
$ ct-ng menuconfig
|
||||
|
||||
Verifying the Configuration of the Toolchain
|
||||
|
||||
@@ -34,7 +34,11 @@ environment for Windows. Follow the steps below to set it up:
|
||||
|
||||
#. Launch the ``MSYS2 MSYS Shell`` desktop app from your start menu (if it's not still open).
|
||||
|
||||
.. note::
|
||||
.. note::
|
||||
|
||||
Make sure you start ``MSYS2 MSYS Shell``, not ``MSYS2 MinGW Shell``.
|
||||
|
||||
.. note::
|
||||
There are multiple ``export`` statements in this tutorial. You can avoid
|
||||
typing them every time by placing them at the bottom of your
|
||||
``~/.bash_profile`` file.
|
||||
|
||||
@@ -44,7 +44,6 @@ Sections
|
||||
LICENSING.rst
|
||||
glossary.rst
|
||||
|
||||
You can find further information on the `Zephyr Project Wiki`_.
|
||||
|
||||
Indices and Tables
|
||||
******************
|
||||
@@ -53,7 +52,6 @@ Indices and Tables
|
||||
|
||||
* :ref:`search`
|
||||
|
||||
.. _Zephyr Project Wiki: https://wiki.zephyrproject.org/view/Main_Page
|
||||
.. _Zephyr 1.7.0: https://www.zephyrproject.org/doc/1.7.0/
|
||||
.. _Zephyr 1.6.0: https://www.zephyrproject.org/doc/1.6.0/
|
||||
.. _Zephyr 1.5.0: https://www.zephyrproject.org/doc/1.5.0/
|
||||
|
||||
@@ -17,8 +17,8 @@ menuconfig ETH_MCUX
|
||||
if ETH_MCUX
|
||||
config ETH_MCUX_PROMISCUOUS_MODE
|
||||
bool "Enable promiscuous mode"
|
||||
default false if !NET_IPV6
|
||||
default true if NET_IPV6
|
||||
default n if !NET_IPV6
|
||||
default y if NET_IPV6
|
||||
help
|
||||
Place the ethernet receiver in promiscuous mode.
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ static void eth_mcux_phy_enter_reset(struct eth_context *context)
|
||||
|
||||
static void eth_mcux_phy_start(struct eth_context *context)
|
||||
{
|
||||
#ifdef CONFIG_ETH_MCUX_PHY_DETAILED_DEBUG
|
||||
#ifdef CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG
|
||||
SYS_LOG_DBG("phy_state=%s", phy_state_name(context->phy_state));
|
||||
#endif
|
||||
|
||||
@@ -166,7 +166,7 @@ static void eth_mcux_phy_start(struct eth_context *context)
|
||||
|
||||
void eth_mcux_phy_stop(struct eth_context *context)
|
||||
{
|
||||
#ifdef CONFIG_ETH_MCUX_PHY_DETAILED_DEBUG
|
||||
#ifdef CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG
|
||||
SYS_LOG_DBG("phy_state=%s", phy_state_name(context->phy_state));
|
||||
#endif
|
||||
|
||||
@@ -203,7 +203,7 @@ static void eth_mcux_phy_event(struct eth_context *context)
|
||||
phy_speed_t phy_speed = kPHY_Speed100M;
|
||||
const u32_t phy_addr = 0;
|
||||
|
||||
#ifdef CONFIG_ETH_MCUX_PHY_DETAILED_DEBUG
|
||||
#ifdef CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG
|
||||
SYS_LOG_DBG("phy_state=%s", phy_state_name(context->phy_state));
|
||||
#endif
|
||||
switch (context->phy_state) {
|
||||
|
||||
@@ -77,6 +77,10 @@ static int spi_mcux_configure(struct device *dev, struct spi_config *spi_config)
|
||||
word_size, spi_config->max_sys_freq);
|
||||
|
||||
clock_freq = CLOCK_GetFreq(config->clock_source);
|
||||
if (!clock_freq) {
|
||||
SYS_LOG_ERR("Got frequency of 0");
|
||||
return -EINVAL;
|
||||
}
|
||||
DSPI_MasterInit(base, &master_config, clock_freq);
|
||||
|
||||
DSPI_MasterTransferCreateHandle(base, &data->handle,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
menuconfig WDT_SAM
|
||||
bool "Atmel SAM MCU Family Watchdog (WDT) Driver"
|
||||
depends on SOC_SERIES_SAME70
|
||||
depends on SOC_FAMILY_SAM
|
||||
default y
|
||||
help
|
||||
Enable WDT driver for Atmel SAM MCUs.
|
||||
|
||||
@@ -13,23 +13,70 @@
|
||||
|
||||
#define NXP_MPU_REGION_NUMBER 12
|
||||
|
||||
/* Bus Master User Mode Access */
|
||||
#define UM_READ 4
|
||||
#define UM_WRITE 2
|
||||
#define UM_EXEC 1
|
||||
|
||||
#define BM0_UM_SHIFT 0
|
||||
#define BM1_UM_SHIFT 6
|
||||
#define BM2_UM_SHIFT 12
|
||||
#define BM3_UM_SHIFT 18
|
||||
|
||||
/* Bus Master Supervisor Mode Access */
|
||||
#define SM_RWX_ALLOW 0
|
||||
#define SM_RX_ALLOW 1
|
||||
#define SM_RW_ALLOW 2
|
||||
#define SM_SAME_AS_UM 3
|
||||
|
||||
#define BM0_SM_SHIFT 3
|
||||
#define BM1_SM_SHIFT 9
|
||||
#define BM2_SM_SHIFT 15
|
||||
#define BM3_SM_SHIFT 21
|
||||
|
||||
/* Read Attribute */
|
||||
#define MPU_REGION_READ ((1 << 2) | (1 << 8) | (1 << 14))
|
||||
#define MPU_REGION_READ ((UM_READ << BM0_UM_SHIFT) | \
|
||||
(UM_READ << BM1_UM_SHIFT) | \
|
||||
(UM_READ << BM2_UM_SHIFT) | \
|
||||
(UM_READ << BM3_UM_SHIFT))
|
||||
|
||||
/* Write Attribute */
|
||||
#define MPU_REGION_WRITE ((1 << 1) | (1 << 7) | (1 << 13))
|
||||
#define MPU_REGION_WRITE ((UM_WRITE << BM0_UM_SHIFT) | \
|
||||
(UM_WRITE << BM1_UM_SHIFT) | \
|
||||
(UM_WRITE << BM2_UM_SHIFT) | \
|
||||
(UM_WRITE << BM3_UM_SHIFT))
|
||||
|
||||
/* Execute Attribute */
|
||||
#define MPU_REGION_EXEC ((1 << 0) | (1 << 6) | (1 << 12))
|
||||
#define MPU_REGION_EXEC ((UM_EXEC << BM0_UM_SHIFT) | \
|
||||
(UM_EXEC << BM1_UM_SHIFT) | \
|
||||
(UM_EXEC << BM2_UM_SHIFT) | \
|
||||
(UM_EXEC << BM3_UM_SHIFT))
|
||||
|
||||
/* Super User Attributes */
|
||||
#define MPU_REGION_SU ((3 << 3) | (3 << 9) | (3 << 15) | (3 << 21))
|
||||
#define MPU_REGION_SU ((SM_SAME_AS_UM << BM0_SM_SHIFT) | \
|
||||
(SM_SAME_AS_UM << BM1_SM_SHIFT) | \
|
||||
(SM_SAME_AS_UM << BM2_SM_SHIFT) | \
|
||||
(SM_SAME_AS_UM << BM3_SM_SHIFT))
|
||||
|
||||
/* The ENDADDR field has the last 5 bit reserved and set to 1 */
|
||||
#define ENDADDR_ROUND(x) (x - 0x1F)
|
||||
|
||||
/* Some helper defines for common regions */
|
||||
#define REGION_RAM_ATTR (MPU_REGION_READ | MPU_REGION_WRITE | MPU_REGION_SU)
|
||||
#define REGION_FLASH_ATTR (MPU_REGION_READ | MPU_REGION_EXEC | MPU_REGION_SU)
|
||||
#define REGION_IO_ATTR (MPU_REGION_READ | MPU_REGION_WRITE | \
|
||||
MPU_REGION_EXEC | MPU_REGION_SU)
|
||||
#define REGION_RAM_ATTR (MPU_REGION_READ | \
|
||||
MPU_REGION_WRITE | \
|
||||
MPU_REGION_SU)
|
||||
|
||||
#define REGION_FLASH_ATTR (MPU_REGION_READ | \
|
||||
MPU_REGION_EXEC | \
|
||||
MPU_REGION_SU)
|
||||
|
||||
#define REGION_IO_ATTR (MPU_REGION_READ | \
|
||||
MPU_REGION_WRITE | \
|
||||
MPU_REGION_EXEC | \
|
||||
MPU_REGION_SU)
|
||||
|
||||
#define REGION_RO_ATTR (MPU_REGION_READ | \
|
||||
MPU_REGION_SU)
|
||||
|
||||
/* Region definition data structure */
|
||||
struct nxp_mpu_region {
|
||||
@@ -57,6 +104,8 @@ struct nxp_mpu_config {
|
||||
u32_t num_regions;
|
||||
/* Regions */
|
||||
struct nxp_mpu_region *mpu_regions;
|
||||
/* SRAM Region */
|
||||
u32_t sram_region;
|
||||
};
|
||||
|
||||
/* Reference to the MPU configuration */
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _MISC_STACK_H_
|
||||
#define _MISC_STACK_H_
|
||||
|
||||
#include <misc/printk.h>
|
||||
|
||||
#if defined(CONFIG_INIT_STACKS)
|
||||
@@ -69,3 +72,5 @@ static inline void stack_analyze(const char *name, const char *stack,
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MISC_STACK_H_ */
|
||||
|
||||
@@ -567,6 +567,13 @@ struct http_server_ctx {
|
||||
/** From which net_context the request came from */
|
||||
struct net_context *net_ctx;
|
||||
|
||||
/** HTTP request timer. After sending a response to the
|
||||
* client, it is possible to wait for any request back via
|
||||
* the same socket. If no response is received, then this
|
||||
* timeout is activated and connection is tore down.
|
||||
*/
|
||||
struct k_delayed_work timer;
|
||||
|
||||
/** HTTP parser */
|
||||
struct http_parser parser;
|
||||
|
||||
@@ -596,6 +603,9 @@ struct http_server_ctx {
|
||||
|
||||
/** URL's length */
|
||||
u16_t url_len;
|
||||
|
||||
/** Has the request timer been cancelled. */
|
||||
u8_t timer_cancelled;
|
||||
} req;
|
||||
|
||||
#if defined(CONFIG_HTTPS)
|
||||
@@ -833,6 +843,25 @@ int http_server_del_default(struct http_server_urls *urls);
|
||||
/**
|
||||
* @brief Send HTTP response to client.
|
||||
*
|
||||
* @detail After sending a response, an optional timeout is started
|
||||
* which will wait for any new requests from the peer.
|
||||
*
|
||||
* @param ctx HTTP context.
|
||||
* @param http_header HTTP headers to send.
|
||||
* @param html_payload HTML payload to send.
|
||||
* @param timeout Timeout to wait until the connection is shutdown.
|
||||
*
|
||||
* @return 0 if ok, <0 if error.
|
||||
*/
|
||||
int http_response_wait(struct http_server_ctx *ctx, const char *http_header,
|
||||
const char *html_payload, s32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Send HTTP response to client.
|
||||
*
|
||||
* @detail The connection to peer is torn down right after the response
|
||||
* is sent.
|
||||
*
|
||||
* @param ctx HTTP context.
|
||||
* @param http_header HTTP headers to send.
|
||||
* @param html_payload HTML payload to send.
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <zephyr/types.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <net/net_ip.h>
|
||||
|
||||
#include <misc/slist.h>
|
||||
|
||||
|
||||
@@ -154,7 +154,8 @@ typedef int (*json_append_bytes_t)(const u8_t *bytes, size_t len,
|
||||
* };
|
||||
*
|
||||
* struct json_obj_descr array[] = {
|
||||
* JSON_OBJ_DESCR_ARRAY(struct example, foo, JSON_TOK_NUMBER)
|
||||
* JSON_OBJ_DESCR_ARRAY(struct example, foo, 10, foo_len,
|
||||
* JSON_TOK_NUMBER)
|
||||
* };
|
||||
*/
|
||||
#define JSON_OBJ_DESCR_ARRAY(struct_, field_name_, max_len_, \
|
||||
@@ -171,6 +172,95 @@ typedef int (*json_append_bytes_t)(const u8_t *bytes, size_t len,
|
||||
.n_elements = (max_len_), \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Variant of JSON_OBJ_DESCR_PRIM that can be used when the
|
||||
* structure and JSON field names differ.
|
||||
*
|
||||
* This is useful when the JSON field is not a valid C identifier.
|
||||
*
|
||||
* @param struct_ Struct packing the values.
|
||||
*
|
||||
* @param json_field_name_ String, field name in JSON strings
|
||||
*
|
||||
* @param struct_field_name_ Field name in the struct
|
||||
*
|
||||
* @param type_ Token type for JSON value corresponding to a primitive
|
||||
* type.
|
||||
*
|
||||
* @see JSON_OBJ_DESCR_PRIM
|
||||
*/
|
||||
#define JSON_OBJ_DESCR_PRIM_NAMED(struct_, json_field_name_, \
|
||||
struct_field_name_, type_) \
|
||||
{ \
|
||||
.field_name = (json_field_name_), \
|
||||
.field_name_len = sizeof(json_field_name_) - 1, \
|
||||
.offset = offsetof(struct_, struct_field_name_), \
|
||||
.type = type_, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Variant of JSON_OBJ_DESCR_OBJECT that can be used when the
|
||||
* structure and JSON field names differ.
|
||||
*
|
||||
* This is useful when the JSON field is not a valid C identifier.
|
||||
*
|
||||
* @param struct_ Struct packing the values
|
||||
*
|
||||
* @param json_field_name_ String, field name in JSON strings
|
||||
*
|
||||
* @param struct_field_name_ Field name in the struct
|
||||
*
|
||||
* @param sub_descr_ Array of json_obj_descr describing the subobject
|
||||
*
|
||||
* @see JSON_OBJ_DESCR_OBJECT
|
||||
*/
|
||||
#define JSON_OBJ_DESCR_OBJECT_NAMED(struct_, json_field_name_, \
|
||||
struct_field_name_, sub_descr_) \
|
||||
{ \
|
||||
.field_name = (json_field_name_), \
|
||||
.field_name_len = (sizeof(json_field_name_) - 1), \
|
||||
.offset = offsetof(struct_, struct_field_name_), \
|
||||
.type = JSON_TOK_OBJECT_START, \
|
||||
.sub_descr = sub_descr_, \
|
||||
.sub_descr_len = ARRAY_SIZE(sub_descr_) \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Variant of JSON_OBJ_DESCR_ARRAY that can be used when the
|
||||
* structure and JSON field names differ.
|
||||
*
|
||||
* This is useful when the JSON field is not a valid C identifier.
|
||||
*
|
||||
* @param struct_ Struct packing the values
|
||||
*
|
||||
* @param json_field_name_ String, field name in JSON strings
|
||||
*
|
||||
* @param struct_field_name_ Field name in the struct
|
||||
*
|
||||
* @param max_len_ Maximum number of elements in array
|
||||
*
|
||||
* @param len_field_ Field name in the struct for the number of elements
|
||||
* in the array
|
||||
*
|
||||
* @param elem_type_ Element type
|
||||
*
|
||||
* @see JSON_OBJ_DESCR_ARRAY
|
||||
*/
|
||||
#define JSON_OBJ_DESCR_ARRAY_NAMED(struct_, json_field_name_,\
|
||||
struct_field_name_, max_len_, len_field_, \
|
||||
elem_type_) \
|
||||
{ \
|
||||
.field_name = (json_field_name_), \
|
||||
.field_name_len = sizeof(json_field_name_) - 1, \
|
||||
.offset = offsetof(struct_, struct_field_name_), \
|
||||
.type = JSON_TOK_LIST_START, \
|
||||
.element_descr = &(struct json_obj_descr) { \
|
||||
.type = elem_type_, \
|
||||
.offset = offsetof(struct_, len_field_), \
|
||||
}, \
|
||||
.n_elements = (max_len_), \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Parses the JSON-encoded object pointer to by @param json, with
|
||||
* size @param len, according to the descriptor pointed to by @param descr.
|
||||
|
||||
@@ -7,4 +7,4 @@ build_only = true
|
||||
extra_args = CONF_FILE=prj_stack_guard.conf
|
||||
tags = apps
|
||||
arch_whitelist = arm
|
||||
filter = CONFIG_MPU_STACK_GUARD and CONFIG_ARM_MPU
|
||||
filter = CONFIG_MPU_STACK_GUARD
|
||||
|
||||
@@ -184,7 +184,7 @@ void dtls_client(void)
|
||||
int ret;
|
||||
struct udp_context ctx;
|
||||
struct dtls_timing_context timer;
|
||||
struct zoap_packet request, zkt;
|
||||
struct zoap_packet request, zpkt;
|
||||
struct zoap_reply *reply;
|
||||
struct net_pkt *pkt;
|
||||
struct net_buf *frag;
|
||||
|
||||
@@ -82,7 +82,7 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
int udp_rx(void *context, unsigned char *buf, size_t size, u32_t timeout)
|
||||
int udp_rx(void *context, unsigned char *buf, size_t size)
|
||||
{
|
||||
struct udp_context *ctx = context;
|
||||
struct net_buf *rx_buf = NULL;
|
||||
@@ -92,10 +92,7 @@ int udp_rx(void *context, unsigned char *buf, size_t size, u32_t timeout)
|
||||
int len;
|
||||
int rc;
|
||||
|
||||
rc = k_sem_take(&ctx->rx_sem, timeout == 0 ? K_FOREVER : timeout);
|
||||
if (rc != 0) {
|
||||
return MBEDTLS_ERR_SSL_TIMEOUT;
|
||||
}
|
||||
k_sem_take(&ctx->rx_sem, K_FOREVER);
|
||||
|
||||
read_bytes = net_pkt_appdatalen(ctx->rx_pkt);
|
||||
if (read_bytes > size) {
|
||||
|
||||
@@ -18,6 +18,6 @@ struct udp_context {
|
||||
|
||||
int udp_init(struct udp_context *ctx);
|
||||
int udp_tx(void *ctx, const unsigned char *buf, size_t size);
|
||||
int udp_rx(void *ctx, unsigned char *buf, size_t size, u32_t timeout);
|
||||
int udp_rx(void *ctx, unsigned char *buf, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[test]
|
||||
tags = net
|
||||
build_only = true
|
||||
arch_whitelist = qemu_x86 arduino_101
|
||||
platform_whitelist = qemu_x86
|
||||
|
||||
@@ -217,6 +217,27 @@ and this is the HTML message that wget will save:
|
||||
<body><h1><center>404 Not Found</center></h1></body>
|
||||
</html>
|
||||
|
||||
To test the HTTP Basic Authentication functionality, use the
|
||||
following command:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
wget 192.168.1.120/auth -O index.html --user=zephyr --password=0123456789
|
||||
|
||||
the :file:`index.html` file will contain the following information:
|
||||
|
||||
.. code-block:: html
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Zephyr HTTP Server</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><center>Zephyr HTTP server</center></h1>
|
||||
<h2><center>user: zephyr, password: 0123456789</center></h2>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
HTTPS Server
|
||||
============
|
||||
|
||||
@@ -274,4 +295,3 @@ Known Issues and Limitations
|
||||
|
||||
- Currently, this sample application only generates HTTP responses in
|
||||
chunk transfer mode.
|
||||
- Basic authentication is not yet implemented.
|
||||
|
||||
@@ -30,4 +30,12 @@
|
||||
#define ZEPHYR_PORT 8080
|
||||
#endif
|
||||
|
||||
#define HTTP_AUTH_URL "/auth"
|
||||
#define HTTP_AUTH_TYPE "Basic"
|
||||
|
||||
/* HTTP Basic Auth, see https://tools.ietf.org/html/rfc7617 */
|
||||
#define HTTP_AUTH_REALM "Zephyr"
|
||||
#define HTTP_AUTH_USERNAME "zephyr"
|
||||
#define HTTP_AUTH_PASSWORD "0123456789"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
#include <zephyr.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* For Basic auth, we need base64 decoder which can be found
|
||||
* in mbedtls library.
|
||||
*/
|
||||
#include <mbedtls/base64.h>
|
||||
|
||||
#include <net/net_context.h>
|
||||
#include <net/http.h>
|
||||
|
||||
@@ -77,6 +82,10 @@ void panic(const char *msg)
|
||||
"Transfer-Encoding: chunked\r\n" \
|
||||
"\r\n"
|
||||
|
||||
#define HTTP_401_STATUS_US "HTTP/1.1 401 Unauthorized status\r\n" \
|
||||
"WWW-Authenticate: Basic realm=" \
|
||||
"\""HTTP_AUTH_REALM"\"\r\n\r\n"
|
||||
|
||||
#define HTML_HEADER "<html><head>" \
|
||||
"<title>Zephyr HTTP Server</title>" \
|
||||
"</head><body><h1>" \
|
||||
@@ -155,9 +164,12 @@ int http_response_header_fields(struct http_server_ctx *ctx)
|
||||
|
||||
static int http_response_it_works(struct http_server_ctx *ctx)
|
||||
{
|
||||
return http_response(ctx, HTTP_STATUS_200_OK, HTML_HEADER
|
||||
"<body><h2><center>It Works!</center></h2>"
|
||||
HTML_FOOTER);
|
||||
/* Let the peer close the connection but if it does not do it
|
||||
* close it ourselves after 1 sec.
|
||||
*/
|
||||
return http_response_wait(ctx, HTTP_STATUS_200_OK, HTML_HEADER
|
||||
"<body><h2><center>It Works!</center></h2>"
|
||||
HTML_FOOTER, K_SECONDS(1));
|
||||
}
|
||||
|
||||
static int http_response_soft_404(struct http_server_ctx *ctx)
|
||||
@@ -167,6 +179,65 @@ static int http_response_soft_404(struct http_server_ctx *ctx)
|
||||
HTML_FOOTER);
|
||||
}
|
||||
|
||||
static int http_response_auth(struct http_server_ctx *ctx)
|
||||
{
|
||||
return http_response(ctx, HTTP_STATUS_200_OK, HTML_HEADER
|
||||
"<h2><center>user: "HTTP_AUTH_USERNAME
|
||||
", password: "HTTP_AUTH_PASSWORD
|
||||
"</center></h2>" HTML_FOOTER);
|
||||
}
|
||||
|
||||
int http_response_401(struct http_server_ctx *ctx, s32_t timeout)
|
||||
{
|
||||
return http_response_wait(ctx, HTTP_401_STATUS_US, NULL, timeout);
|
||||
}
|
||||
|
||||
static int http_basic_auth(struct http_server_ctx *ctx)
|
||||
{
|
||||
const char auth_str[] = HTTP_CRLF "Authorization: Basic ";
|
||||
char *ptr;
|
||||
|
||||
ptr = strstr(ctx->req.field_values[0].key, auth_str);
|
||||
if (ptr) {
|
||||
char output[sizeof(HTTP_AUTH_USERNAME) +
|
||||
sizeof(":") +
|
||||
sizeof(HTTP_AUTH_PASSWORD)];
|
||||
size_t olen, ilen, alen;
|
||||
char *end, *colon;
|
||||
int ret;
|
||||
|
||||
memset(output, 0, sizeof(output));
|
||||
|
||||
end = strstr(ptr + 2, HTTP_CRLF);
|
||||
if (!end) {
|
||||
return http_response_401(ctx, K_NO_WAIT);
|
||||
}
|
||||
|
||||
alen = sizeof(auth_str) - 1;
|
||||
ilen = end - (ptr + alen);
|
||||
|
||||
ret = mbedtls_base64_decode(output, sizeof(output) - 1,
|
||||
&olen, ptr + alen, ilen);
|
||||
if (ret) {
|
||||
return http_response_401(ctx, K_NO_WAIT);
|
||||
}
|
||||
|
||||
colon = memchr(output, ':', olen);
|
||||
|
||||
if (colon && colon > output && colon < (output + olen) &&
|
||||
memcmp(output, HTTP_AUTH_USERNAME, colon - output) == 0 &&
|
||||
memcmp(colon + 1, HTTP_AUTH_PASSWORD,
|
||||
output + olen - colon) == 0) {
|
||||
return http_response_auth(ctx);
|
||||
}
|
||||
|
||||
return http_response_401(ctx, K_NO_WAIT);
|
||||
}
|
||||
|
||||
/* Wait 2 secs for the reply with proper credentials */
|
||||
return http_response_401(ctx, K_SECONDS(2));
|
||||
}
|
||||
|
||||
#if defined(CONFIG_HTTPS)
|
||||
/* Load the certificates and private RSA key. */
|
||||
|
||||
@@ -271,6 +342,8 @@ void main(void)
|
||||
#endif
|
||||
|
||||
http_server_add_default(&http_urls, http_response_soft_404);
|
||||
http_server_add_url(&http_urls, HTTP_AUTH_URL, HTTP_URL_STANDARD,
|
||||
http_basic_auth);
|
||||
http_server_add_url(&http_urls, "/headers", HTTP_URL_STANDARD,
|
||||
http_response_header_fields);
|
||||
http_server_add_url(&http_urls, "/index.html", HTTP_URL_STANDARD,
|
||||
|
||||
@@ -45,7 +45,7 @@ static void set_destination(struct sockaddr *addr)
|
||||
#endif
|
||||
|
||||
static void udp_received(struct net_context *context,
|
||||
struct net_buf *buf, int status, void *user_data)
|
||||
struct net_pkt *pkt, int status, void *user_data)
|
||||
{
|
||||
struct udp_context *ctx = user_data;
|
||||
|
||||
@@ -58,14 +58,14 @@ static void udp_received(struct net_context *context,
|
||||
|
||||
if (ctx->rx_pkt) {
|
||||
printk("Packet %p is still being handled, "
|
||||
"dropping %p\n", ctx->rx_pkt, buf);
|
||||
"dropping %p\n", ctx->rx_pkt, pkt);
|
||||
|
||||
net_pkt_unref(buf);
|
||||
net_pkt_unref(pkt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ctx->rx_pkt = buf;
|
||||
ctx->rx_pkt = pkt;
|
||||
k_sem_give(&ctx->rx_sem);
|
||||
k_yield();
|
||||
}
|
||||
@@ -74,34 +74,34 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
|
||||
{
|
||||
struct udp_context *ctx = context;
|
||||
struct net_context *udp_ctx;
|
||||
struct net_buf *send_buf;
|
||||
struct net_pkt *send_pkt;
|
||||
struct sockaddr dst_addr;
|
||||
int rc, len;
|
||||
|
||||
udp_ctx = ctx->net_ctx;
|
||||
|
||||
send_buf = net_pkt_get_tx(udp_ctx, K_FOREVER);
|
||||
if (!send_buf) {
|
||||
send_pkt = net_pkt_get_tx(udp_ctx, K_FOREVER);
|
||||
if (!send_pkt) {
|
||||
printk("cannot create buf\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
rc = net_pkt_append_all(send_buf, size, (u8_t *) buf, K_FOREVER);
|
||||
rc = net_pkt_append_all(send_pkt, size, (u8_t *) buf, K_FOREVER);
|
||||
if (!rc) {
|
||||
printk("cannot write buf\n");
|
||||
net_pkt_unref(send_buf);
|
||||
net_pkt_unref(send_pkt);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
set_destination(&dst_addr);
|
||||
len = net_buf_frags_len(send_buf);
|
||||
len = net_pkt_get_len(send_pkt);
|
||||
k_sleep(UDP_TX_TIMEOUT);
|
||||
|
||||
rc = net_context_sendto(send_buf, &dst_addr,
|
||||
rc = net_context_sendto(send_pkt, &dst_addr,
|
||||
addrlen, NULL, K_FOREVER, NULL, NULL);
|
||||
if (rc < 0) {
|
||||
printk("Cannot send data to peer (%d)\n", rc);
|
||||
net_pkt_unref(send_buf);
|
||||
net_pkt_unref(send_pkt);
|
||||
return -EIO;
|
||||
} else {
|
||||
return len;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
struct udp_context {
|
||||
struct net_context *net_ctx;
|
||||
struct net_buf *rx_pkt;
|
||||
struct net_pkt *rx_pkt;
|
||||
struct k_sem rx_sem;
|
||||
int remaining;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[test]
|
||||
tags = net
|
||||
build_only = true
|
||||
arch_whitelist = qemu_x86 arduino_101
|
||||
platform_whitelist = qemu_x86 arduino_101
|
||||
|
||||
@@ -78,7 +78,7 @@ MQTT Client Identifier:
|
||||
This sample application supports the IBM Bluemix Watson topic format that can
|
||||
be enabled by changing the default value of APP_BLUEMIX_TOPIC from 0 to 1:
|
||||
|
||||
.. code block:: c
|
||||
.. code-block:: c
|
||||
|
||||
#define APP_BLUEMIX_TOPIC 1
|
||||
|
||||
@@ -86,7 +86,7 @@ The Bluemix topic may include some parameters like device type, device
|
||||
identifier, event type and message format. This application uses the
|
||||
following macros to specify those values:
|
||||
|
||||
.. code block:: c
|
||||
.. code-block:: c
|
||||
|
||||
#define BLUEMIX_DEVTYPE "sensor"
|
||||
#define BLUEMIX_DEVID "carbon"
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define CONN_TRIES 20
|
||||
|
||||
/* Container for some structures used by the MQTT publisher app. */
|
||||
struct mqtt_client_ctx {
|
||||
/**
|
||||
@@ -243,12 +245,18 @@ static void publisher(void)
|
||||
|
||||
/* The net_ctx variable must be ready BEFORE passing it to the MQTT API.
|
||||
*/
|
||||
rc = network_setup(&net_ctx, ZEPHYR_ADDR, SERVER_ADDR, SERVER_PORT);
|
||||
PRINT_RESULT("network_setup", rc);
|
||||
if (rc != 0) {
|
||||
goto exit_app;
|
||||
for (i = 0; i < CONN_TRIES; i++) {
|
||||
rc = network_setup(&net_ctx, ZEPHYR_ADDR, SERVER_ADDR,
|
||||
SERVER_PORT);
|
||||
if (!rc) {
|
||||
goto connected;
|
||||
}
|
||||
}
|
||||
|
||||
PRINT_RESULT("network_setup", rc);
|
||||
goto exit_app;
|
||||
|
||||
connected:
|
||||
/* Set everything to 0 and later just assign the required fields. */
|
||||
memset(&client_ctx, 0x00, sizeof(client_ctx));
|
||||
|
||||
@@ -453,8 +461,7 @@ static int network_setup(struct net_context **net_ctx, const char *local_addr,
|
||||
rc = net_context_connect(*net_ctx, &server_sock, addr_len, NULL,
|
||||
APP_SLEEP_MSECS, NULL);
|
||||
if (rc) {
|
||||
printk("net_context_connect error\n"
|
||||
"Is the server (broker) up and running?\n");
|
||||
printk("net_context_connect error\n");
|
||||
goto lb_exit;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +1,27 @@
|
||||
ifndef XTOOLS_TOOLCHAIN_PATH
|
||||
|
||||
ifeq ($(CROSS_COMPILE),)
|
||||
$(error XTOOLS_TOOLCHAIN_PATH is not set)
|
||||
else
|
||||
CROSS_COMPILE_TARGET = $(patsubst %-,%,${CROSS_COMPILE})
|
||||
CROSS_COMPILE_ROOT = $(dir $(shell which ${CROSS_COMPILE}gcc))/..
|
||||
endif
|
||||
|
||||
ifndef MAKEFILE_TOOLCHAIN_DO_PASS2
|
||||
|
||||
# arm
|
||||
CROSS_COMPILE_TARGET_arm = arm-none-eabi
|
||||
|
||||
# x86
|
||||
CROSS_COMPILE_TARGET_x86 = i586-unknown-elf
|
||||
|
||||
CROSS_COMPILE_TARGET = ${CROSS_COMPILE_TARGET_${ARCH}}
|
||||
CROSS_COMPILE_ROOT = ${XTOOLS_TOOLCHAIN_PATH}/${CROSS_COMPILE_TARGET}
|
||||
|
||||
else
|
||||
|
||||
CROSS_COMPILE_TARGET_arm = arm-none-eabi
|
||||
CROSS_COMPILE_TARGET_x86 = i586-pc-elf
|
||||
|
||||
CROSS_COMPILE_TARGET = ${CROSS_COMPILE_TARGET_${ARCH}}
|
||||
CROSS_COMPILE_ROOT = ${XTOOLS_TOOLCHAIN_PATH}/${CROSS_COMPILE_TARGET}
|
||||
CROSS_COMPILE = ${CROSS_COMPILE_ROOT}/bin/${CROSS_COMPILE_TARGET}-
|
||||
|
||||
endif
|
||||
|
||||
TOOLCHAIN_CFLAGS = -I${CROSS_COMPILE_ROOT}/${CROSS_COMPILE_TARGET}/sysroot/usr/include
|
||||
TOOLCHAIN_LIBS = gcc
|
||||
|
||||
CROSS_COMPILE_version = $(shell $(CROSS_COMPILE)gcc -dumpversion)
|
||||
LIB_INCLUDE_DIR += -L ${CROSS_COMPILE_ROOT}/lib/gcc/${CROSS_COMPILE_TARGET}/${CROSS_COMPILE_version}/
|
||||
|
||||
endif
|
||||
|
||||
export CROSS_COMPILE TOOLCHAIN_LIBS LIB_INCLUDE_DIR TOOLCHAIN_CFLAGS
|
||||
|
||||
ifndef MAKEFILE_TOOLCHAIN_DO_PASS2
|
||||
MAKEFILE_TOOLCHAIN_DO_PASS2=true
|
||||
endif
|
||||
|
||||
@@ -2,9 +2,19 @@
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Crosstool-NG Configuration
|
||||
#
|
||||
CT_CONFIGURE_has_xz=y
|
||||
CT_CONFIGURE_has_wget=y
|
||||
CT_CONFIGURE_has_curl=y
|
||||
CT_CONFIGURE_has_stat_flavor_GNU=y
|
||||
CT_CONFIGURE_has_make_3_81_or_newer=y
|
||||
CT_CONFIGURE_has_libtool_2_4_or_newer=y
|
||||
CT_CONFIGURE_has_libtoolize_2_4_or_newer=y
|
||||
CT_CONFIGURE_has_autoconf_2_63_or_newer=y
|
||||
CT_CONFIGURE_has_autoreconf_2_63_or_newer=y
|
||||
CT_CONFIGURE_has_automake_1_15_or_newer=y
|
||||
CT_CONFIGURE_has_gnu_m4_1_4_12_or_newer=y
|
||||
CT_CONFIGURE_has_cvs=y
|
||||
CT_CONFIGURE_has_svn=y
|
||||
CT_CONFIGURE_has_git=y
|
||||
CT_MODULES=y
|
||||
|
||||
#
|
||||
@@ -21,23 +31,27 @@ CT_MODULES=y
|
||||
#
|
||||
# Paths
|
||||
#
|
||||
CT_LOCAL_TARBALLS_DIR="${HOME}/xtools/src"
|
||||
CT_LOCAL_TARBALLS_DIR="${CT_PREFIX:-${HOME}/x-tools}/sources"
|
||||
CT_SAVE_TARBALLS=y
|
||||
CT_WORK_DIR="${CT_TOP_DIR}/.build"
|
||||
CT_PREFIX_DIR="${HOME}/xtools/build/${CT_TARGET}"
|
||||
CT_INSTALL_DIR="${CT_PREFIX_DIR}"
|
||||
CT_BUILD_TOP_DIR="${CT_WORK_DIR}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}"
|
||||
CT_PREFIX_DIR="${CT_PREFIX:-${HOME}/x-tools}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}"
|
||||
CT_RM_RF_PREFIX_DIR=y
|
||||
CT_REMOVE_DOCS=y
|
||||
CT_INSTALL_DIR_RO=y
|
||||
# CT_PREFIX_DIR_RO is not set
|
||||
CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES=y
|
||||
# CT_STRIP_TARGET_TOOLCHAIN_EXECUTABLES is not set
|
||||
|
||||
#
|
||||
# Downloading
|
||||
#
|
||||
CT_DOWNLOAD_AGENT_WGET=y
|
||||
# CT_DOWNLOAD_AGENT_CURL is not set
|
||||
# CT_DOWNLOAD_AGENT_NONE is not set
|
||||
# CT_FORBID_DOWNLOAD is not set
|
||||
# CT_FORCE_DOWNLOAD is not set
|
||||
CT_CONNECT_TIMEOUT=10
|
||||
CT_DOWNLOAD_WGET_OPTIONS="--passive-ftp --tries=3 -nc --progress=dot:binary"
|
||||
# CT_ONLY_DOWNLOAD is not set
|
||||
# CT_USE_MIRROR is not set
|
||||
|
||||
@@ -45,7 +59,7 @@ CT_CONNECT_TIMEOUT=10
|
||||
# Extracting
|
||||
#
|
||||
# CT_FORCE_EXTRACT is not set
|
||||
CT_OVERIDE_CONFIG_GUESS_SUB=y
|
||||
CT_OVERRIDE_CONFIG_GUESS_SUB=y
|
||||
# CT_ONLY_EXTRACT is not set
|
||||
CT_PATCH_BUNDLED=y
|
||||
# CT_PATCH_LOCAL is not set
|
||||
@@ -83,7 +97,7 @@ CT_LOG_EXTRA=y
|
||||
# CT_LOG_DEBUG is not set
|
||||
CT_LOG_LEVEL_MAX="EXTRA"
|
||||
# CT_LOG_SEE_TOOLS_WARN is not set
|
||||
CT_LOG_PROGRESS_BAR=y
|
||||
# CT_LOG_PROGRESS_BAR is not set
|
||||
CT_LOG_TO_FILE=y
|
||||
CT_LOG_FILE_COMPRESS=y
|
||||
|
||||
@@ -91,20 +105,6 @@ CT_LOG_FILE_COMPRESS=y
|
||||
# Target options
|
||||
#
|
||||
CT_ARCH="x86"
|
||||
CT_ARCH_SUPPORTS_32=y
|
||||
CT_ARCH_SUPPORTS_64=y
|
||||
CT_ARCH_SUPPORTS_WITH_ARCH=y
|
||||
CT_ARCH_SUPPORTS_WITH_CPU=y
|
||||
CT_ARCH_SUPPORTS_WITH_TUNE=y
|
||||
CT_ARCH_DEFAULT_32=y
|
||||
CT_ARCH_ARCH="pentium"
|
||||
CT_ARCH_CPU=""
|
||||
CT_ARCH_TUNE=""
|
||||
CT_ARCH_32=y
|
||||
# CT_ARCH_64 is not set
|
||||
CT_ARCH_BITNESS=32
|
||||
CT_TARGET_CFLAGS=""
|
||||
CT_TARGET_LDFLAGS=""
|
||||
# CT_ARCH_alpha is not set
|
||||
# CT_ARCH_arm is not set
|
||||
# CT_ARCH_avr is not set
|
||||
@@ -136,13 +136,29 @@ CT_ARCH_SUFFIX=""
|
||||
# Generic target options
|
||||
#
|
||||
# CT_MULTILIB is not set
|
||||
CT_DEMULTILIB=y
|
||||
CT_ARCH_USE_MMU=y
|
||||
CT_ARCH_SUPPORTS_32=y
|
||||
CT_ARCH_SUPPORTS_64=y
|
||||
CT_ARCH_DEFAULT_32=y
|
||||
CT_ARCH_BITNESS=32
|
||||
CT_ARCH_32=y
|
||||
# CT_ARCH_64 is not set
|
||||
|
||||
#
|
||||
# Target optimisations
|
||||
#
|
||||
CT_ARCH_SUPPORTS_WITH_ARCH=y
|
||||
CT_ARCH_SUPPORTS_WITH_CPU=y
|
||||
CT_ARCH_SUPPORTS_WITH_TUNE=y
|
||||
CT_ARCH_ARCH=""
|
||||
CT_ARCH_CPU=""
|
||||
CT_ARCH_TUNE="pentium"
|
||||
CT_TARGET_CFLAGS="-m32"
|
||||
CT_TARGET_LDFLAGS=""
|
||||
CT_ARCH_FLOAT=""
|
||||
|
||||
|
||||
#
|
||||
# Toolchain options
|
||||
#
|
||||
@@ -150,19 +166,13 @@ CT_ARCH_FLOAT=""
|
||||
#
|
||||
# General toolchain options
|
||||
#
|
||||
CT_FORCE_SYSROOT=y
|
||||
CT_USE_SYSROOT=y
|
||||
CT_SYSROOT_NAME="sysroot"
|
||||
CT_SYSROOT_DIR_PREFIX=""
|
||||
CT_WANTS_STATIC_LINK=y
|
||||
# CT_STATIC_TOOLCHAIN is not set
|
||||
CT_TOOLCHAIN_PKGVERSION=""
|
||||
CT_TOOLCHAIN_BUGURL=""
|
||||
|
||||
#
|
||||
# Tuple completion and aliasing
|
||||
#
|
||||
CT_TARGET_VENDOR=""
|
||||
CT_TARGET_VENDOR="zephyr"
|
||||
CT_TARGET_ALIAS_SED_EXPR=""
|
||||
CT_TARGET_ALIAS=""
|
||||
|
||||
@@ -210,24 +220,17 @@ CT_BINUTILS_binutils=y
|
||||
#
|
||||
# GNU binutils
|
||||
#
|
||||
# CT_CC_BINUTILS_SHOW_LINARO is not set
|
||||
# CT_BINUTILS_V_2_25_1 is not set
|
||||
# CT_BINUTILS_V_2_25 is not set
|
||||
# CT_BINUTILS_V_2_24 is not set
|
||||
# CT_BINUTILS_V_2_23_2 is not set
|
||||
# CT_BINUTILS_V_2_23_1 is not set
|
||||
CT_BINUTILS_V_2_22=y
|
||||
# CT_BINUTILS_V_2_21_53 is not set
|
||||
# CT_BINUTILS_V_2_21_1a is not set
|
||||
# CT_BINUTILS_V_2_20_1a is not set
|
||||
# CT_BINUTILS_V_2_19_1a is not set
|
||||
# CT_BINUTILS_V_2_18a is not set
|
||||
CT_BINUTILS_VERSION="2.22"
|
||||
CT_BINUTILS_2_22_or_later=y
|
||||
CT_BINUTILS_2_21_or_later=y
|
||||
CT_BINUTILS_2_20_or_later=y
|
||||
CT_BINUTILS_2_19_or_later=y
|
||||
CT_BINUTILS_2_18_or_later=y
|
||||
CT_BINUTILS_VERSION="2.28"
|
||||
# CT_BINUTILS_SHOW_LINARO is not set
|
||||
CT_BINUTILS_V_2_28=y
|
||||
# CT_BINUTILS_V_2_27 is not set
|
||||
# CT_BINUTILS_V_2_26 is not set
|
||||
CT_BINUTILS_2_27_or_later=y
|
||||
CT_BINUTILS_2_26_or_later=y
|
||||
CT_BINUTILS_2_25_1_or_later=y
|
||||
CT_BINUTILS_2_25_or_later=y
|
||||
CT_BINUTILS_2_24_or_later=y
|
||||
CT_BINUTILS_2_23_2_or_later=y
|
||||
CT_BINUTILS_HAS_HASH_STYLE=y
|
||||
CT_BINUTILS_HAS_GOLD=y
|
||||
CT_BINUTILS_GOLD_SUPPORTS_ARCH=y
|
||||
@@ -251,7 +254,7 @@ CT_BINUTILS_EXTRA_CONFIG_ARRAY=""
|
||||
# C-library
|
||||
#
|
||||
CT_LIBC="newlib"
|
||||
CT_LIBC_VERSION="2.2.0"
|
||||
CT_LIBC_VERSION="2.5.0.20170323"
|
||||
CT_LIBC_newlib=y
|
||||
# CT_LIBC_none is not set
|
||||
CT_LIBC_avr_libc_AVAILABLE=y
|
||||
@@ -261,14 +264,20 @@ CT_LIBC_mingw_AVAILABLE=y
|
||||
CT_LIBC_musl_AVAILABLE=y
|
||||
CT_LIBC_newlib_AVAILABLE=y
|
||||
# CT_CC_NEWLIB_SHOW_LINARO is not set
|
||||
CT_LIBC_NEWLIB_V_2_2_0=y
|
||||
CT_LIBC_NEWLIB_V_2_5_0=y
|
||||
# CT_LIBC_NEWLIB_V_2_4_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_2_3_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_2_2_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_2_1_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_2_0_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_1_20_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_1_19_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_1_18_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_1_17_0 is not set
|
||||
CT_LIBC_NEWLIB_2_2=y
|
||||
CT_LIBC_NEWLIB_2_5=y
|
||||
CT_LIBC_NEWLIB_2_5_or_later=y
|
||||
CT_LIBC_NEWLIB_2_4_or_later=y
|
||||
CT_LIBC_NEWLIB_2_3_or_later=y
|
||||
CT_LIBC_NEWLIB_2_2_or_later=y
|
||||
CT_LIBC_NEWLIB_2_1_or_later=y
|
||||
CT_LIBC_NEWLIB_2_0_or_later=y
|
||||
@@ -288,9 +297,25 @@ CT_THREADS_NONE=y
|
||||
#
|
||||
# CT_LIBC_NEWLIB_IO_C99FMT is not set
|
||||
# CT_LIBC_NEWLIB_IO_LL is not set
|
||||
# CT_LIBC_NEWLIB_IO_FLOAT is not set
|
||||
# CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS is not set
|
||||
CT_LIBC_NEWLIB_IO_FLOAT=y
|
||||
# CT_LIBC_NEWLIB_IO_LDBL is not set
|
||||
# CT_LIBC_NEWLIB_IO_POS_ARGS is not set
|
||||
CT_LIBC_NEWLIB_FVWRITE_IN_STREAMIO=y
|
||||
CT_LIBC_NEWLIB_UNBUF_STREAM_OPT=y
|
||||
# CT_LIBC_NEWLIB_FSEEK_OPTIMIZATION is not set
|
||||
CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS=y
|
||||
# CT_LIBC_NEWLIB_REGISTER_FINI is not set
|
||||
CT_LIBC_NEWLIB_ATEXIT_DYNAMIC_ALLOC=y
|
||||
CT_LIBC_NEWLIB_GLOBAL_ATEXIT=y
|
||||
CT_LIBC_NEWLIB_LITE_EXIT=y
|
||||
# CT_LIBC_NEWLIB_REENT_SMALL is not set
|
||||
# CT_LIBC_NEWLIB_MULTITHREAD is not set
|
||||
# CT_LIBC_NEWLIB_EXTRA_SECTIONS is not set
|
||||
# CT_LIBC_NEWLIB_WIDE_ORIENT is not set
|
||||
CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE=y
|
||||
# CT_LIBC_NEWLIB_LTO is not set
|
||||
CT_LIBC_NEWLIB_NANO_MALLOC=y
|
||||
CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y
|
||||
CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY=""
|
||||
|
||||
#
|
||||
@@ -299,59 +324,38 @@ CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY=""
|
||||
CT_CC="gcc"
|
||||
CT_CC_CORE_PASS_2_NEEDED=y
|
||||
CT_CC_gcc=y
|
||||
CT_CC_GCC_VERSION="6.3.0"
|
||||
# CT_CC_GCC_SHOW_LINARO is not set
|
||||
CT_CC_GCC_V_5_2_0=y
|
||||
# CT_CC_GCC_V_4_9_3 is not set
|
||||
# CT_CC_GCC_V_4_8_5 is not set
|
||||
# CT_CC_GCC_V_4_7_4 is not set
|
||||
# CT_CC_GCC_V_4_6_4 is not set
|
||||
# CT_CC_GCC_V_4_5_4 is not set
|
||||
# CT_CC_GCC_V_4_4_7 is not set
|
||||
# CT_CC_GCC_V_4_3_6 is not set
|
||||
# CT_CC_GCC_V_4_2_4 is not set
|
||||
CT_CC_GCC_4_2_or_later=y
|
||||
CT_CC_GCC_4_3_or_later=y
|
||||
CT_CC_GCC_4_4_or_later=y
|
||||
CT_CC_GCC_4_5_or_later=y
|
||||
CT_CC_GCC_4_6_or_later=y
|
||||
CT_CC_GCC_4_7_or_later=y
|
||||
CT_CC_GCC_V_6_3_0=y
|
||||
# CT_CC_GCC_V_5_4_0 is not set
|
||||
# CT_CC_GCC_V_4_9_4 is not set
|
||||
CT_CC_GCC_4_8_or_later=y
|
||||
CT_CC_GCC_4_9_or_later=y
|
||||
CT_CC_GCC_5=y
|
||||
CT_CC_GCC_5_or_later=y
|
||||
CT_CC_GCC_HAS_GRAPHITE=y
|
||||
CT_CC_GCC_USE_GRAPHITE=y
|
||||
CT_CC_GCC_HAS_LTO=y
|
||||
# CT_CC_GCC_USE_LTO is not set
|
||||
CT_CC_GCC_HAS_PKGVERSION_BUGURL=y
|
||||
CT_CC_GCC_HAS_BUILD_ID=y
|
||||
CT_CC_GCC_HAS_LNK_HASH_STYLE=y
|
||||
CT_CC_GCC_USE_GMP_MPFR=y
|
||||
CT_CC_GCC_USE_MPC=y
|
||||
CT_CC_GCC_HAS_LIBQUADMATH=y
|
||||
CT_CC_GCC_HAS_LIBSANITIZER=y
|
||||
CT_CC_GCC_VERSION="5.2.0"
|
||||
# CT_CC_LANG_FORTRAN is not set
|
||||
CT_CC_GCC_6=y
|
||||
CT_CC_GCC_6_or_later=y
|
||||
CT_CC_GCC_HAS_LIBMPX=y
|
||||
CT_CC_GCC_ENABLE_CXX_FLAGS=""
|
||||
CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY=""
|
||||
CT_CC_GCC_EXTRA_CONFIG_ARRAY=""
|
||||
CT_CC_GCC_EXTRA_ENV_ARRAY=""
|
||||
# CT_CC_GCC_TARGET_FINAL is not set
|
||||
CT_CC_GCC_STATIC_LIBSTDCXX=y
|
||||
# CT_CC_GCC_SYSTEM_ZLIB is not set
|
||||
CT_CC_GCC_CONFIG_TLS=m
|
||||
|
||||
#
|
||||
# Optimisation features
|
||||
#
|
||||
CT_CC_GCC_USE_GRAPHITE=y
|
||||
CT_CC_GCC_USE_LTO=y
|
||||
|
||||
#
|
||||
# Settings for libraries running on target
|
||||
#
|
||||
CT_CC_GCC_ENABLE_TARGET_OPTSPACE=y
|
||||
# CT_CC_GCC_LIBMUDFLAP is not set
|
||||
# CT_CC_GCC_LIBGOMP is not set
|
||||
# CT_CC_GCC_LIBSSP is not set
|
||||
# CT_CC_GCC_LIBQUADMATH is not set
|
||||
CT_CC_GCC_LIBMPX=y
|
||||
|
||||
#
|
||||
# Misc. obscure options.
|
||||
@@ -381,17 +385,16 @@ CT_CC_SUPPORT_GOLANG=y
|
||||
# Additional supported languages:
|
||||
#
|
||||
CT_CC_LANG_CXX=y
|
||||
# CT_CC_LANG_FORTRAN is not set
|
||||
|
||||
#
|
||||
# Debug facilities
|
||||
#
|
||||
# CT_DEBUG_dmalloc is not set
|
||||
# CT_DEBUG_duma is not set
|
||||
CT_DEBUG_gdb=y
|
||||
CT_GDB_CROSS=y
|
||||
# CT_GDB_CROSS_STATIC is not set
|
||||
# CT_GDB_CROSS_SIM is not set
|
||||
CT_GDB_CROSS_PYTHON=y
|
||||
CT_GDB_CROSS_PYTHON_BINARY=""
|
||||
CT_GDB_CROSS_EXTRA_CONFIG_ARRAY=""
|
||||
|
||||
#
|
||||
@@ -405,32 +408,15 @@ CT_GDB_CROSS_EXTRA_CONFIG_ARRAY=""
|
||||
#
|
||||
# gdb version
|
||||
#
|
||||
# CT_DEBUG_GDB_SHOW_LINARO is not set
|
||||
# CT_GDB_V_7_10 is not set
|
||||
CT_GDB_V_7_9_1=y
|
||||
# CT_GDB_V_7_9 is not set
|
||||
# CT_GDB_V_7_8_2 is not set
|
||||
# CT_GDB_V_7_8_1 is not set
|
||||
# CT_GDB_V_7_8 is not set
|
||||
# CT_GDB_V_7_7_1 is not set
|
||||
# CT_GDB_V_7_7 is not set
|
||||
# CT_GDB_V_7_6_1 is not set
|
||||
# CT_GDB_V_7_5_1 is not set
|
||||
# CT_GDB_V_7_4_1 is not set
|
||||
# CT_GDB_V_7_4 is not set
|
||||
# CT_GDB_V_7_3_1 is not set
|
||||
# CT_GDB_V_7_3a is not set
|
||||
# CT_GDB_V_7_2a is not set
|
||||
# CT_GDB_V_7_1a is not set
|
||||
# CT_GDB_V_7_0_1a is not set
|
||||
# CT_GDB_V_7_0a is not set
|
||||
# CT_GDB_V_6_8a is not set
|
||||
CT_GDB_VERSION="7.12.1"
|
||||
CT_GDB_V_7_12_1=y
|
||||
# CT_GDB_V_7_11_1 is not set
|
||||
CT_GDB_7_12_or_later=y
|
||||
CT_GDB_7_2_or_later=y
|
||||
CT_GDB_7_0_or_later=y
|
||||
CT_GDB_HAS_PKGVERSION_BUGURL=y
|
||||
CT_GDB_HAS_PYTHON=y
|
||||
CT_GDB_INSTALL_GDBINIT=y
|
||||
CT_GDB_VERSION="7.9.1"
|
||||
# CT_DEBUG_ltrace is not set
|
||||
# CT_DEBUG_strace is not set
|
||||
|
||||
@@ -438,6 +424,7 @@ CT_GDB_VERSION="7.9.1"
|
||||
# Companion libraries
|
||||
#
|
||||
CT_COMPLIBS_NEEDED=y
|
||||
CT_LIBICONV_NEEDED=y
|
||||
CT_GMP_NEEDED=y
|
||||
CT_MPFR_NEEDED=y
|
||||
CT_ISL_NEEDED=y
|
||||
@@ -445,48 +432,46 @@ CT_MPC_NEEDED=y
|
||||
CT_EXPAT_NEEDED=y
|
||||
CT_NCURSES_NEEDED=y
|
||||
CT_COMPLIBS=y
|
||||
CT_LIBICONV=y
|
||||
CT_GETTEXT=y
|
||||
CT_GMP=y
|
||||
CT_MPFR=y
|
||||
CT_ISL=y
|
||||
CT_MPC=y
|
||||
CT_EXPAT=y
|
||||
CT_NCURSES=y
|
||||
# CT_GMP_V_6_0_0 is not set
|
||||
# CT_GMP_V_5_1_3 is not set
|
||||
# CT_GMP_V_5_1_1 is not set
|
||||
# CT_GMP_V_5_0_2 is not set
|
||||
# CT_GMP_V_5_0_1 is not set
|
||||
CT_GMP_V_4_3_2=y
|
||||
# CT_GMP_V_4_3_1 is not set
|
||||
# CT_GMP_V_4_3_0 is not set
|
||||
CT_GMP_VERSION="4.3.2"
|
||||
# CT_MPFR_V_3_1_3 is not set
|
||||
# CT_MPFR_V_3_1_2 is not set
|
||||
# CT_MPFR_V_3_1_0 is not set
|
||||
CT_MPFR_V_3_0_1=y
|
||||
# CT_MPFR_V_3_0_0 is not set
|
||||
# CT_MPFR_V_2_4_2 is not set
|
||||
# CT_MPFR_V_2_4_1 is not set
|
||||
# CT_MPFR_V_2_4_0 is not set
|
||||
CT_MPFR_VERSION="3.0.1"
|
||||
CT_ISL_V_0_14=y
|
||||
# CT_ISL_V_0_12_2 is not set
|
||||
CT_ZLIB=y
|
||||
CT_ZLIB_V_1_2_11=y
|
||||
CT_ZLIB_VERSION="1.2.11"
|
||||
CT_LIBICONV_V_1_15=y
|
||||
# CT_LIBICONV_V_1_14 is not set
|
||||
CT_LIBICONV_VERSION="1.15"
|
||||
CT_GETTEXT_V_0_19_8_1=y
|
||||
CT_GETTEXT_VERSION="0.19.8.1"
|
||||
CT_GMP_V_6_1_2=y
|
||||
CT_GMP_5_0_2_or_later=y
|
||||
CT_GMP_VERSION="6.1.2"
|
||||
CT_MPFR_V_3_1_5=y
|
||||
CT_MPFR_VERSION="3.1.5"
|
||||
CT_ISL_V_0_16_1=y
|
||||
# CT_ISL_V_0_15 is not set
|
||||
CT_ISL_V_0_16_or_later=y
|
||||
CT_ISL_V_0_15_or_later=y
|
||||
CT_ISL_V_0_14_or_later=y
|
||||
CT_ISL_V_0_12_or_later=y
|
||||
CT_ISL_VERSION="0.14"
|
||||
# CT_MPC_V_1_0_3 is not set
|
||||
# CT_MPC_V_1_0_2 is not set
|
||||
CT_MPC_V_1_0_1=y
|
||||
# CT_MPC_V_1_0 is not set
|
||||
# CT_MPC_V_0_9 is not set
|
||||
# CT_MPC_V_0_8_2 is not set
|
||||
# CT_MPC_V_0_8_1 is not set
|
||||
# CT_MPC_V_0_7 is not set
|
||||
CT_MPC_VERSION="1.0.1"
|
||||
CT_EXPAT_V_2_1_0=y
|
||||
CT_EXPAT_VERSION="2.1.0"
|
||||
CT_ISL_VERSION="0.16.1"
|
||||
CT_MPC_V_1_0_3=y
|
||||
CT_MPC_VERSION="1.0.3"
|
||||
CT_EXPAT_V_2_2_0=y
|
||||
CT_EXPAT_VERSION="2.2.0"
|
||||
CT_NCURSES_V_6_0=y
|
||||
CT_NCURSES_VERSION="6.0"
|
||||
CT_NCURSES_HOST_CONFIG_ARGS=""
|
||||
CT_NCURSES_HOST_DISABLE_DB=y
|
||||
CT_NCURSES_HOST_FALLBACKS="linux,xterm,xterm-color,xterm-256color,vt100"
|
||||
CT_NCURSES_TARGET_CONFIG_ARGS=""
|
||||
# CT_NCURSES_TARGET_DISABLE_DB is not set
|
||||
CT_NCURSES_TARGET_FALLBACKS=""
|
||||
|
||||
#
|
||||
# Companion libraries common options
|
||||
@@ -496,8 +481,11 @@ CT_NCURSES_VERSION="6.0"
|
||||
#
|
||||
# Companion tools
|
||||
#
|
||||
|
||||
#
|
||||
# READ HELP before you say 'Y' below !!!
|
||||
#
|
||||
# CT_COMP_TOOLS is not set
|
||||
# CT_COMP_TOOLS_FOR_HOST is not set
|
||||
# CT_COMP_TOOLS_autoconf is not set
|
||||
# CT_COMP_TOOLS_automake is not set
|
||||
# CT_COMP_TOOLS_libtool is not set
|
||||
CT_COMP_TOOLS_m4=y
|
||||
CT_M4_V_1_4_18=y
|
||||
CT_M4_VERSION="1.4.18"
|
||||
# CT_COMP_TOOLS_make is not set
|
||||
@@ -2,9 +2,19 @@
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Crosstool-NG Configuration
|
||||
#
|
||||
CT_CONFIGURE_has_xz=y
|
||||
CT_CONFIGURE_has_wget=y
|
||||
CT_CONFIGURE_has_curl=y
|
||||
CT_CONFIGURE_has_stat_flavor_GNU=y
|
||||
CT_CONFIGURE_has_make_3_81_or_newer=y
|
||||
CT_CONFIGURE_has_libtool_2_4_or_newer=y
|
||||
CT_CONFIGURE_has_libtoolize_2_4_or_newer=y
|
||||
CT_CONFIGURE_has_autoconf_2_63_or_newer=y
|
||||
CT_CONFIGURE_has_autoreconf_2_63_or_newer=y
|
||||
CT_CONFIGURE_has_automake_1_15_or_newer=y
|
||||
CT_CONFIGURE_has_gnu_m4_1_4_12_or_newer=y
|
||||
CT_CONFIGURE_has_cvs=y
|
||||
CT_CONFIGURE_has_svn=y
|
||||
CT_CONFIGURE_has_git=y
|
||||
CT_MODULES=y
|
||||
|
||||
#
|
||||
@@ -21,23 +31,27 @@ CT_MODULES=y
|
||||
#
|
||||
# Paths
|
||||
#
|
||||
CT_LOCAL_TARBALLS_DIR="${HOME}/xtools/src"
|
||||
CT_LOCAL_TARBALLS_DIR="${CT_PREFIX:-${HOME}/x-tools}/sources"
|
||||
CT_SAVE_TARBALLS=y
|
||||
CT_WORK_DIR="${CT_TOP_DIR}/.build"
|
||||
CT_PREFIX_DIR="${HOME}/xtools/build/${CT_TARGET}"
|
||||
CT_INSTALL_DIR="${CT_PREFIX_DIR}"
|
||||
CT_BUILD_TOP_DIR="${CT_WORK_DIR}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}"
|
||||
CT_PREFIX_DIR="${CT_PREFIX:-${HOME}/x-tools}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}"
|
||||
CT_RM_RF_PREFIX_DIR=y
|
||||
CT_REMOVE_DOCS=y
|
||||
CT_INSTALL_DIR_RO=y
|
||||
# CT_PREFIX_DIR_RO is not set
|
||||
CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES=y
|
||||
# CT_STRIP_TARGET_TOOLCHAIN_EXECUTABLES is not set
|
||||
|
||||
#
|
||||
# Downloading
|
||||
#
|
||||
CT_DOWNLOAD_AGENT_WGET=y
|
||||
# CT_DOWNLOAD_AGENT_CURL is not set
|
||||
# CT_DOWNLOAD_AGENT_NONE is not set
|
||||
# CT_FORBID_DOWNLOAD is not set
|
||||
# CT_FORCE_DOWNLOAD is not set
|
||||
CT_CONNECT_TIMEOUT=10
|
||||
CT_DOWNLOAD_WGET_OPTIONS="--passive-ftp --tries=3 -nc --progress=dot:binary"
|
||||
# CT_ONLY_DOWNLOAD is not set
|
||||
# CT_USE_MIRROR is not set
|
||||
|
||||
@@ -45,7 +59,7 @@ CT_CONNECT_TIMEOUT=10
|
||||
# Extracting
|
||||
#
|
||||
# CT_FORCE_EXTRACT is not set
|
||||
CT_OVERIDE_CONFIG_GUESS_SUB=y
|
||||
CT_OVERRIDE_CONFIG_GUESS_SUB=y
|
||||
# CT_ONLY_EXTRACT is not set
|
||||
CT_PATCH_BUNDLED=y
|
||||
# CT_PATCH_LOCAL is not set
|
||||
@@ -83,42 +97,16 @@ CT_LOG_EXTRA=y
|
||||
# CT_LOG_DEBUG is not set
|
||||
CT_LOG_LEVEL_MAX="EXTRA"
|
||||
# CT_LOG_SEE_TOOLS_WARN is not set
|
||||
CT_LOG_PROGRESS_BAR=y
|
||||
# CT_LOG_PROGRESS_BAR is not set
|
||||
CT_LOG_TO_FILE=y
|
||||
CT_LOG_FILE_COMPRESS=y
|
||||
|
||||
#
|
||||
# Target options
|
||||
#
|
||||
CT_ARCH="arm"
|
||||
CT_ARCH_SUPPORTS_BOTH_MMU=y
|
||||
CT_ARCH_SUPPORTS_BOTH_ENDIAN=y
|
||||
CT_ARCH_SUPPORTS_32=y
|
||||
CT_ARCH_SUPPORTS_64=y
|
||||
CT_ARCH_SUPPORTS_WITH_ARCH=y
|
||||
CT_ARCH_SUPPORTS_WITH_CPU=y
|
||||
CT_ARCH_SUPPORTS_WITH_TUNE=y
|
||||
CT_ARCH_SUPPORTS_WITH_FLOAT=y
|
||||
CT_ARCH_SUPPORTS_WITH_FPU=y
|
||||
CT_ARCH_SUPPORTS_SOFTFP=y
|
||||
CT_ARCH_DEFAULT_HAS_MMU=y
|
||||
CT_ARCH_DEFAULT_LE=y
|
||||
CT_ARCH_DEFAULT_32=y
|
||||
CT_ARCH_ARCH=""
|
||||
CT_ARCH_CPU=""
|
||||
CT_ARCH_TUNE=""
|
||||
CT_ARCH_FPU=""
|
||||
# CT_ARCH_BE is not set
|
||||
CT_ARCH_LE=y
|
||||
CT_ARCH_32=y
|
||||
# CT_ARCH_64 is not set
|
||||
CT_ARCH_BITNESS=32
|
||||
# CT_ARCH_FLOAT_HW is not set
|
||||
CT_ARCH_FLOAT_SW=y
|
||||
CT_TARGET_CFLAGS=""
|
||||
CT_TARGET_LDFLAGS=""
|
||||
CT_ARCH="x86"
|
||||
# CT_ARCH_alpha is not set
|
||||
CT_ARCH_arm=y
|
||||
# CT_ARCH_arm is not set
|
||||
# CT_ARCH_avr is not set
|
||||
# CT_ARCH_m68k is not set
|
||||
# CT_ARCH_mips is not set
|
||||
@@ -127,7 +115,7 @@ CT_ARCH_arm=y
|
||||
# CT_ARCH_s390 is not set
|
||||
# CT_ARCH_sh is not set
|
||||
# CT_ARCH_sparc is not set
|
||||
# CT_ARCH_x86 is not set
|
||||
CT_ARCH_x86=y
|
||||
# CT_ARCH_xtensa is not set
|
||||
CT_ARCH_alpha_AVAILABLE=y
|
||||
CT_ARCH_arm_AVAILABLE=y
|
||||
@@ -148,26 +136,32 @@ CT_ARCH_SUFFIX=""
|
||||
# Generic target options
|
||||
#
|
||||
# CT_MULTILIB is not set
|
||||
CT_DEMULTILIB=y
|
||||
CT_ARCH_USE_MMU=y
|
||||
CT_ARCH_ENDIAN="little"
|
||||
CT_ARCH_SUPPORTS_32=y
|
||||
CT_ARCH_SUPPORTS_64=y
|
||||
CT_ARCH_DEFAULT_32=y
|
||||
CT_ARCH_BITNESS=32
|
||||
CT_ARCH_32=y
|
||||
# CT_ARCH_64 is not set
|
||||
|
||||
#
|
||||
# Target optimisations
|
||||
#
|
||||
CT_ARCH_EXCLUSIVE_WITH_CPU=y
|
||||
# CT_ARCH_FLOAT_AUTO is not set
|
||||
# CT_ARCH_FLOAT_SOFTFP is not set
|
||||
CT_ARCH_FLOAT="soft"
|
||||
CT_ARCH_SUPPORTS_WITH_ARCH=y
|
||||
CT_ARCH_SUPPORTS_WITH_CPU=y
|
||||
CT_ARCH_SUPPORTS_WITH_TUNE=y
|
||||
CT_ARCH_ARCH=""
|
||||
CT_ARCH_CPU=""
|
||||
CT_ARCH_TUNE="lakemont"
|
||||
CT_TARGET_CFLAGS="-miamcu -m32"
|
||||
CT_TARGET_LDFLAGS=""
|
||||
CT_ARCH_FLOAT=""
|
||||
|
||||
#
|
||||
# arm other options
|
||||
# x86 other options
|
||||
#
|
||||
CT_ARCH_ARM_MODE="arm"
|
||||
CT_ARCH_ARM_MODE_ARM=y
|
||||
# CT_ARCH_ARM_MODE_THUMB is not set
|
||||
# CT_ARCH_ARM_INTERWORKING is not set
|
||||
CT_ARCH_ARM_EABI_FORCE=y
|
||||
CT_ARCH_ARM_EABI=y
|
||||
CT_ARCH_X86_IAMCU=y
|
||||
|
||||
#
|
||||
# Toolchain options
|
||||
@@ -176,19 +170,13 @@ CT_ARCH_ARM_EABI=y
|
||||
#
|
||||
# General toolchain options
|
||||
#
|
||||
CT_FORCE_SYSROOT=y
|
||||
CT_USE_SYSROOT=y
|
||||
CT_SYSROOT_NAME="sysroot"
|
||||
CT_SYSROOT_DIR_PREFIX=""
|
||||
CT_WANTS_STATIC_LINK=y
|
||||
# CT_STATIC_TOOLCHAIN is not set
|
||||
CT_TOOLCHAIN_PKGVERSION=""
|
||||
CT_TOOLCHAIN_BUGURL=""
|
||||
|
||||
#
|
||||
# Tuple completion and aliasing
|
||||
#
|
||||
CT_TARGET_VENDOR="none"
|
||||
CT_TARGET_VENDOR="zephyr"
|
||||
CT_TARGET_ALIAS_SED_EXPR=""
|
||||
CT_TARGET_ALIAS=""
|
||||
|
||||
@@ -236,24 +224,17 @@ CT_BINUTILS_binutils=y
|
||||
#
|
||||
# GNU binutils
|
||||
#
|
||||
# CT_CC_BINUTILS_SHOW_LINARO is not set
|
||||
# CT_BINUTILS_V_2_25_1 is not set
|
||||
# CT_BINUTILS_V_2_25 is not set
|
||||
# CT_BINUTILS_V_2_24 is not set
|
||||
# CT_BINUTILS_V_2_23_2 is not set
|
||||
# CT_BINUTILS_V_2_23_1 is not set
|
||||
CT_BINUTILS_V_2_22=y
|
||||
# CT_BINUTILS_V_2_21_53 is not set
|
||||
# CT_BINUTILS_V_2_21_1a is not set
|
||||
# CT_BINUTILS_V_2_20_1a is not set
|
||||
# CT_BINUTILS_V_2_19_1a is not set
|
||||
# CT_BINUTILS_V_2_18a is not set
|
||||
CT_BINUTILS_VERSION="2.22"
|
||||
CT_BINUTILS_2_22_or_later=y
|
||||
CT_BINUTILS_2_21_or_later=y
|
||||
CT_BINUTILS_2_20_or_later=y
|
||||
CT_BINUTILS_2_19_or_later=y
|
||||
CT_BINUTILS_2_18_or_later=y
|
||||
CT_BINUTILS_VERSION="2.28"
|
||||
# CT_BINUTILS_SHOW_LINARO is not set
|
||||
CT_BINUTILS_V_2_28=y
|
||||
# CT_BINUTILS_V_2_27 is not set
|
||||
# CT_BINUTILS_V_2_26 is not set
|
||||
CT_BINUTILS_2_27_or_later=y
|
||||
CT_BINUTILS_2_26_or_later=y
|
||||
CT_BINUTILS_2_25_1_or_later=y
|
||||
CT_BINUTILS_2_25_or_later=y
|
||||
CT_BINUTILS_2_24_or_later=y
|
||||
CT_BINUTILS_2_23_2_or_later=y
|
||||
CT_BINUTILS_HAS_HASH_STYLE=y
|
||||
CT_BINUTILS_HAS_GOLD=y
|
||||
CT_BINUTILS_GOLD_SUPPORTS_ARCH=y
|
||||
@@ -277,7 +258,7 @@ CT_BINUTILS_EXTRA_CONFIG_ARRAY=""
|
||||
# C-library
|
||||
#
|
||||
CT_LIBC="newlib"
|
||||
CT_LIBC_VERSION="2.2.0"
|
||||
CT_LIBC_VERSION="2.5.0.20170323"
|
||||
CT_LIBC_newlib=y
|
||||
# CT_LIBC_none is not set
|
||||
CT_LIBC_avr_libc_AVAILABLE=y
|
||||
@@ -287,14 +268,20 @@ CT_LIBC_mingw_AVAILABLE=y
|
||||
CT_LIBC_musl_AVAILABLE=y
|
||||
CT_LIBC_newlib_AVAILABLE=y
|
||||
# CT_CC_NEWLIB_SHOW_LINARO is not set
|
||||
CT_LIBC_NEWLIB_V_2_2_0=y
|
||||
CT_LIBC_NEWLIB_V_2_5_0=y
|
||||
# CT_LIBC_NEWLIB_V_2_4_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_2_3_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_2_2_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_2_1_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_2_0_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_1_20_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_1_19_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_1_18_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_1_17_0 is not set
|
||||
CT_LIBC_NEWLIB_2_2=y
|
||||
CT_LIBC_NEWLIB_2_5=y
|
||||
CT_LIBC_NEWLIB_2_5_or_later=y
|
||||
CT_LIBC_NEWLIB_2_4_or_later=y
|
||||
CT_LIBC_NEWLIB_2_3_or_later=y
|
||||
CT_LIBC_NEWLIB_2_2_or_later=y
|
||||
CT_LIBC_NEWLIB_2_1_or_later=y
|
||||
CT_LIBC_NEWLIB_2_0_or_later=y
|
||||
@@ -314,9 +301,25 @@ CT_THREADS_NONE=y
|
||||
#
|
||||
# CT_LIBC_NEWLIB_IO_C99FMT is not set
|
||||
# CT_LIBC_NEWLIB_IO_LL is not set
|
||||
# CT_LIBC_NEWLIB_IO_FLOAT is not set
|
||||
# CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS is not set
|
||||
CT_LIBC_NEWLIB_IO_FLOAT=y
|
||||
# CT_LIBC_NEWLIB_IO_LDBL is not set
|
||||
# CT_LIBC_NEWLIB_IO_POS_ARGS is not set
|
||||
CT_LIBC_NEWLIB_FVWRITE_IN_STREAMIO=y
|
||||
CT_LIBC_NEWLIB_UNBUF_STREAM_OPT=y
|
||||
# CT_LIBC_NEWLIB_FSEEK_OPTIMIZATION is not set
|
||||
CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS=y
|
||||
# CT_LIBC_NEWLIB_REGISTER_FINI is not set
|
||||
CT_LIBC_NEWLIB_ATEXIT_DYNAMIC_ALLOC=y
|
||||
CT_LIBC_NEWLIB_GLOBAL_ATEXIT=y
|
||||
CT_LIBC_NEWLIB_LITE_EXIT=y
|
||||
# CT_LIBC_NEWLIB_REENT_SMALL is not set
|
||||
# CT_LIBC_NEWLIB_MULTITHREAD is not set
|
||||
# CT_LIBC_NEWLIB_EXTRA_SECTIONS is not set
|
||||
# CT_LIBC_NEWLIB_WIDE_ORIENT is not set
|
||||
CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE=y
|
||||
# CT_LIBC_NEWLIB_LTO is not set
|
||||
CT_LIBC_NEWLIB_NANO_MALLOC=y
|
||||
CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y
|
||||
CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY=""
|
||||
|
||||
#
|
||||
@@ -325,59 +328,38 @@ CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY=""
|
||||
CT_CC="gcc"
|
||||
CT_CC_CORE_PASS_2_NEEDED=y
|
||||
CT_CC_gcc=y
|
||||
CT_CC_GCC_VERSION="6.3.0"
|
||||
# CT_CC_GCC_SHOW_LINARO is not set
|
||||
CT_CC_GCC_V_5_2_0=y
|
||||
# CT_CC_GCC_V_4_9_3 is not set
|
||||
# CT_CC_GCC_V_4_8_5 is not set
|
||||
# CT_CC_GCC_V_4_7_4 is not set
|
||||
# CT_CC_GCC_V_4_6_4 is not set
|
||||
# CT_CC_GCC_V_4_5_4 is not set
|
||||
# CT_CC_GCC_V_4_4_7 is not set
|
||||
# CT_CC_GCC_V_4_3_6 is not set
|
||||
# CT_CC_GCC_V_4_2_4 is not set
|
||||
CT_CC_GCC_4_2_or_later=y
|
||||
CT_CC_GCC_4_3_or_later=y
|
||||
CT_CC_GCC_4_4_or_later=y
|
||||
CT_CC_GCC_4_5_or_later=y
|
||||
CT_CC_GCC_4_6_or_later=y
|
||||
CT_CC_GCC_4_7_or_later=y
|
||||
CT_CC_GCC_V_6_3_0=y
|
||||
# CT_CC_GCC_V_5_4_0 is not set
|
||||
# CT_CC_GCC_V_4_9_4 is not set
|
||||
CT_CC_GCC_4_8_or_later=y
|
||||
CT_CC_GCC_4_9_or_later=y
|
||||
CT_CC_GCC_5=y
|
||||
CT_CC_GCC_5_or_later=y
|
||||
CT_CC_GCC_HAS_GRAPHITE=y
|
||||
CT_CC_GCC_USE_GRAPHITE=y
|
||||
CT_CC_GCC_HAS_LTO=y
|
||||
CT_CC_GCC_USE_LTO=y
|
||||
CT_CC_GCC_HAS_PKGVERSION_BUGURL=y
|
||||
CT_CC_GCC_HAS_BUILD_ID=y
|
||||
CT_CC_GCC_HAS_LNK_HASH_STYLE=y
|
||||
CT_CC_GCC_USE_GMP_MPFR=y
|
||||
CT_CC_GCC_USE_MPC=y
|
||||
CT_CC_GCC_HAS_LIBQUADMATH=y
|
||||
CT_CC_GCC_HAS_LIBSANITIZER=y
|
||||
CT_CC_GCC_VERSION="5.2.0"
|
||||
# CT_CC_LANG_FORTRAN is not set
|
||||
CT_CC_GCC_6=y
|
||||
CT_CC_GCC_6_or_later=y
|
||||
CT_CC_GCC_HAS_LIBMPX=y
|
||||
CT_CC_GCC_ENABLE_CXX_FLAGS=""
|
||||
CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY=""
|
||||
CT_CC_GCC_EXTRA_CONFIG_ARRAY=""
|
||||
CT_CC_GCC_EXTRA_ENV_ARRAY=""
|
||||
# CT_CC_GCC_TARGET_FINAL is not set
|
||||
CT_CC_GCC_STATIC_LIBSTDCXX=y
|
||||
# CT_CC_GCC_SYSTEM_ZLIB is not set
|
||||
CT_CC_GCC_CONFIG_TLS=m
|
||||
|
||||
#
|
||||
# Optimisation features
|
||||
#
|
||||
CT_CC_GCC_USE_GRAPHITE=y
|
||||
CT_CC_GCC_USE_LTO=y
|
||||
|
||||
#
|
||||
# Settings for libraries running on target
|
||||
#
|
||||
CT_CC_GCC_ENABLE_TARGET_OPTSPACE=y
|
||||
# CT_CC_GCC_LIBMUDFLAP is not set
|
||||
# CT_CC_GCC_LIBGOMP is not set
|
||||
# CT_CC_GCC_LIBSSP is not set
|
||||
# CT_CC_GCC_LIBQUADMATH is not set
|
||||
CT_CC_GCC_LIBMPX=y
|
||||
|
||||
#
|
||||
# Misc. obscure options.
|
||||
@@ -406,14 +388,39 @@ CT_CC_SUPPORT_GOLANG=y
|
||||
#
|
||||
# Additional supported languages:
|
||||
#
|
||||
# CT_CC_LANG_CXX is not set
|
||||
CT_CC_LANG_CXX=y
|
||||
# CT_CC_LANG_FORTRAN is not set
|
||||
|
||||
#
|
||||
# Debug facilities
|
||||
#
|
||||
# CT_DEBUG_dmalloc is not set
|
||||
# CT_DEBUG_duma is not set
|
||||
# CT_DEBUG_gdb is not set
|
||||
CT_DEBUG_gdb=y
|
||||
CT_GDB_CROSS=y
|
||||
# CT_GDB_CROSS_SIM is not set
|
||||
CT_GDB_CROSS_PYTHON=y
|
||||
CT_GDB_CROSS_PYTHON_BINARY=""
|
||||
CT_GDB_CROSS_EXTRA_CONFIG_ARRAY=""
|
||||
|
||||
#
|
||||
# In bare-metal, you'll need to
|
||||
#
|
||||
|
||||
#
|
||||
# provide your own gdbserver stub.
|
||||
#
|
||||
|
||||
#
|
||||
# gdb version
|
||||
#
|
||||
CT_GDB_VERSION="7.12.1"
|
||||
CT_GDB_V_7_12_1=y
|
||||
# CT_GDB_V_7_11_1 is not set
|
||||
CT_GDB_7_12_or_later=y
|
||||
CT_GDB_7_2_or_later=y
|
||||
CT_GDB_7_0_or_later=y
|
||||
CT_GDB_HAS_PKGVERSION_BUGURL=y
|
||||
CT_GDB_HAS_PYTHON=y
|
||||
CT_GDB_INSTALL_GDBINIT=y
|
||||
# CT_DEBUG_ltrace is not set
|
||||
# CT_DEBUG_strace is not set
|
||||
|
||||
@@ -421,47 +428,54 @@ CT_CC_SUPPORT_GOLANG=y
|
||||
# Companion libraries
|
||||
#
|
||||
CT_COMPLIBS_NEEDED=y
|
||||
CT_LIBICONV_NEEDED=y
|
||||
CT_GMP_NEEDED=y
|
||||
CT_MPFR_NEEDED=y
|
||||
CT_ISL_NEEDED=y
|
||||
CT_MPC_NEEDED=y
|
||||
CT_EXPAT_NEEDED=y
|
||||
CT_NCURSES_NEEDED=y
|
||||
CT_COMPLIBS=y
|
||||
CT_LIBICONV=y
|
||||
CT_GETTEXT=y
|
||||
CT_GMP=y
|
||||
CT_MPFR=y
|
||||
CT_ISL=y
|
||||
CT_MPC=y
|
||||
# CT_GMP_V_6_0_0 is not set
|
||||
CT_GMP_V_5_1_3=y
|
||||
# CT_GMP_V_5_1_1 is not set
|
||||
# CT_GMP_V_5_0_2 is not set
|
||||
# CT_GMP_V_5_0_1 is not set
|
||||
# CT_GMP_V_4_3_2 is not set
|
||||
# CT_GMP_V_4_3_1 is not set
|
||||
# CT_GMP_V_4_3_0 is not set
|
||||
CT_EXPAT=y
|
||||
CT_NCURSES=y
|
||||
CT_ZLIB=y
|
||||
CT_ZLIB_V_1_2_11=y
|
||||
CT_ZLIB_VERSION="1.2.11"
|
||||
CT_LIBICONV_V_1_15=y
|
||||
# CT_LIBICONV_V_1_14 is not set
|
||||
CT_LIBICONV_VERSION="1.15"
|
||||
CT_GETTEXT_V_0_19_8_1=y
|
||||
CT_GETTEXT_VERSION="0.19.8.1"
|
||||
CT_GMP_V_6_1_2=y
|
||||
CT_GMP_5_0_2_or_later=y
|
||||
CT_GMP_VERSION="5.1.3"
|
||||
# CT_MPFR_V_3_1_3 is not set
|
||||
CT_MPFR_V_3_1_2=y
|
||||
# CT_MPFR_V_3_1_0 is not set
|
||||
# CT_MPFR_V_3_0_1 is not set
|
||||
# CT_MPFR_V_3_0_0 is not set
|
||||
# CT_MPFR_V_2_4_2 is not set
|
||||
# CT_MPFR_V_2_4_1 is not set
|
||||
# CT_MPFR_V_2_4_0 is not set
|
||||
CT_MPFR_VERSION="3.1.2"
|
||||
# CT_ISL_V_0_14 is not set
|
||||
CT_ISL_V_0_12_2=y
|
||||
CT_GMP_VERSION="6.1.2"
|
||||
CT_MPFR_V_3_1_5=y
|
||||
CT_MPFR_VERSION="3.1.5"
|
||||
CT_ISL_V_0_16_1=y
|
||||
# CT_ISL_V_0_15 is not set
|
||||
CT_ISL_V_0_16_or_later=y
|
||||
CT_ISL_V_0_15_or_later=y
|
||||
CT_ISL_V_0_14_or_later=y
|
||||
CT_ISL_V_0_12_or_later=y
|
||||
CT_ISL_VERSION="0.12.2"
|
||||
# CT_MPC_V_1_0_3 is not set
|
||||
CT_MPC_V_1_0_2=y
|
||||
# CT_MPC_V_1_0_1 is not set
|
||||
# CT_MPC_V_1_0 is not set
|
||||
# CT_MPC_V_0_9 is not set
|
||||
# CT_MPC_V_0_8_2 is not set
|
||||
# CT_MPC_V_0_8_1 is not set
|
||||
# CT_MPC_V_0_7 is not set
|
||||
CT_MPC_VERSION="1.0.2"
|
||||
CT_ISL_VERSION="0.16.1"
|
||||
CT_MPC_V_1_0_3=y
|
||||
CT_MPC_VERSION="1.0.3"
|
||||
CT_EXPAT_V_2_2_0=y
|
||||
CT_EXPAT_VERSION="2.2.0"
|
||||
CT_NCURSES_V_6_0=y
|
||||
CT_NCURSES_VERSION="6.0"
|
||||
CT_NCURSES_HOST_CONFIG_ARGS=""
|
||||
CT_NCURSES_HOST_DISABLE_DB=y
|
||||
CT_NCURSES_HOST_FALLBACKS="linux,xterm,xterm-color,xterm-256color,vt100"
|
||||
CT_NCURSES_TARGET_CONFIG_ARGS=""
|
||||
# CT_NCURSES_TARGET_DISABLE_DB is not set
|
||||
CT_NCURSES_TARGET_FALLBACKS=""
|
||||
|
||||
#
|
||||
# Companion libraries common options
|
||||
@@ -471,8 +485,11 @@ CT_MPC_VERSION="1.0.2"
|
||||
#
|
||||
# Companion tools
|
||||
#
|
||||
|
||||
#
|
||||
# READ HELP before you say 'Y' below !!!
|
||||
#
|
||||
# CT_COMP_TOOLS is not set
|
||||
# CT_COMP_TOOLS_FOR_HOST is not set
|
||||
# CT_COMP_TOOLS_autoconf is not set
|
||||
# CT_COMP_TOOLS_automake is not set
|
||||
# CT_COMP_TOOLS_libtool is not set
|
||||
CT_COMP_TOOLS_m4=y
|
||||
CT_M4_V_1_4_18=y
|
||||
CT_M4_VERSION="1.4.18"
|
||||
# CT_COMP_TOOLS_make is not set
|
||||
483
scripts/cross_compiler/nios2.config
Normal file
483
scripts/cross_compiler/nios2.config
Normal file
@@ -0,0 +1,483 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Crosstool-NG Configuration
|
||||
#
|
||||
CT_CONFIGURE_has_wget=y
|
||||
CT_CONFIGURE_has_curl=y
|
||||
CT_CONFIGURE_has_stat_flavor_GNU=y
|
||||
CT_CONFIGURE_has_make_3_81_or_newer=y
|
||||
CT_CONFIGURE_has_libtool_2_4_or_newer=y
|
||||
CT_CONFIGURE_has_libtoolize_2_4_or_newer=y
|
||||
CT_CONFIGURE_has_autoconf_2_63_or_newer=y
|
||||
CT_CONFIGURE_has_autoreconf_2_63_or_newer=y
|
||||
CT_CONFIGURE_has_automake_1_15_or_newer=y
|
||||
CT_CONFIGURE_has_gnu_m4_1_4_12_or_newer=y
|
||||
CT_CONFIGURE_has_cvs=y
|
||||
CT_CONFIGURE_has_svn=y
|
||||
CT_CONFIGURE_has_git=y
|
||||
CT_MODULES=y
|
||||
|
||||
#
|
||||
# Paths and misc options
|
||||
#
|
||||
|
||||
#
|
||||
# crosstool-NG behavior
|
||||
#
|
||||
# CT_OBSOLETE is not set
|
||||
# CT_EXPERIMENTAL is not set
|
||||
# CT_DEBUG_CT is not set
|
||||
|
||||
#
|
||||
# Paths
|
||||
#
|
||||
CT_LOCAL_TARBALLS_DIR="${CT_PREFIX:-${HOME}/x-tools}/sources"
|
||||
CT_SAVE_TARBALLS=y
|
||||
CT_WORK_DIR="${CT_TOP_DIR}/.build"
|
||||
CT_BUILD_TOP_DIR="${CT_WORK_DIR}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}"
|
||||
CT_PREFIX_DIR="${CT_PREFIX:-${HOME}/x-tools}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}"
|
||||
CT_RM_RF_PREFIX_DIR=y
|
||||
CT_REMOVE_DOCS=y
|
||||
# CT_PREFIX_DIR_RO is not set
|
||||
CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES=y
|
||||
# CT_STRIP_TARGET_TOOLCHAIN_EXECUTABLES is not set
|
||||
|
||||
#
|
||||
# Downloading
|
||||
#
|
||||
CT_DOWNLOAD_AGENT_WGET=y
|
||||
# CT_DOWNLOAD_AGENT_CURL is not set
|
||||
# CT_DOWNLOAD_AGENT_NONE is not set
|
||||
# CT_FORBID_DOWNLOAD is not set
|
||||
# CT_FORCE_DOWNLOAD is not set
|
||||
CT_CONNECT_TIMEOUT=10
|
||||
CT_DOWNLOAD_WGET_OPTIONS="--passive-ftp --tries=3 -nc --progress=dot:binary"
|
||||
# CT_ONLY_DOWNLOAD is not set
|
||||
# CT_USE_MIRROR is not set
|
||||
|
||||
#
|
||||
# Extracting
|
||||
#
|
||||
# CT_FORCE_EXTRACT is not set
|
||||
CT_OVERRIDE_CONFIG_GUESS_SUB=y
|
||||
# CT_ONLY_EXTRACT is not set
|
||||
CT_PATCH_BUNDLED=y
|
||||
# CT_PATCH_LOCAL is not set
|
||||
# CT_PATCH_BUNDLED_LOCAL is not set
|
||||
# CT_PATCH_LOCAL_BUNDLED is not set
|
||||
# CT_PATCH_BUNDLED_FALLBACK_LOCAL is not set
|
||||
# CT_PATCH_LOCAL_FALLBACK_BUNDLED is not set
|
||||
# CT_PATCH_NONE is not set
|
||||
CT_PATCH_ORDER="bundled"
|
||||
|
||||
#
|
||||
# Build behavior
|
||||
#
|
||||
CT_PARALLEL_JOBS=0
|
||||
CT_LOAD=""
|
||||
CT_USE_PIPES=y
|
||||
CT_EXTRA_CFLAGS_FOR_BUILD=""
|
||||
CT_EXTRA_LDFLAGS_FOR_BUILD=""
|
||||
CT_EXTRA_CFLAGS_FOR_HOST=""
|
||||
CT_EXTRA_LDFLAGS_FOR_HOST=""
|
||||
# CT_CONFIG_SHELL_SH is not set
|
||||
# CT_CONFIG_SHELL_ASH is not set
|
||||
CT_CONFIG_SHELL_BASH=y
|
||||
# CT_CONFIG_SHELL_CUSTOM is not set
|
||||
CT_CONFIG_SHELL="${bash}"
|
||||
|
||||
#
|
||||
# Logging
|
||||
#
|
||||
# CT_LOG_ERROR is not set
|
||||
# CT_LOG_WARN is not set
|
||||
# CT_LOG_INFO is not set
|
||||
CT_LOG_EXTRA=y
|
||||
# CT_LOG_ALL is not set
|
||||
# CT_LOG_DEBUG is not set
|
||||
CT_LOG_LEVEL_MAX="EXTRA"
|
||||
# CT_LOG_SEE_TOOLS_WARN is not set
|
||||
# CT_LOG_PROGRESS_BAR is not set
|
||||
CT_LOG_TO_FILE=y
|
||||
CT_LOG_FILE_COMPRESS=y
|
||||
|
||||
#
|
||||
# Target options
|
||||
#
|
||||
CT_ARCH="nios2"
|
||||
# CT_ARCH_alpha is not set
|
||||
# CT_ARCH_arm is not set
|
||||
# CT_ARCH_avr is not set
|
||||
# CT_ARCH_m68k is not set
|
||||
# CT_ARCH_mips is not set
|
||||
CT_ARCH_nios2=y
|
||||
# CT_ARCH_powerpc is not set
|
||||
# CT_ARCH_s390 is not set
|
||||
# CT_ARCH_sh is not set
|
||||
# CT_ARCH_sparc is not set
|
||||
# CT_ARCH_x86 is not set
|
||||
# CT_ARCH_xtensa is not set
|
||||
CT_ARCH_alpha_AVAILABLE=y
|
||||
CT_ARCH_arm_AVAILABLE=y
|
||||
CT_ARCH_avr_AVAILABLE=y
|
||||
CT_ARCH_m68k_AVAILABLE=y
|
||||
CT_ARCH_microblaze_AVAILABLE=y
|
||||
CT_ARCH_mips_AVAILABLE=y
|
||||
CT_ARCH_nios2_AVAILABLE=y
|
||||
CT_ARCH_powerpc_AVAILABLE=y
|
||||
CT_ARCH_s390_AVAILABLE=y
|
||||
CT_ARCH_sh_AVAILABLE=y
|
||||
CT_ARCH_sparc_AVAILABLE=y
|
||||
CT_ARCH_x86_AVAILABLE=y
|
||||
CT_ARCH_xtensa_AVAILABLE=y
|
||||
CT_ARCH_SUFFIX=""
|
||||
|
||||
#
|
||||
# Generic target options
|
||||
#
|
||||
# CT_MULTILIB is not set
|
||||
CT_DEMULTILIB=y
|
||||
CT_ARCH_DEFAULT_LE=y
|
||||
CT_ARCH_SUPPORTS_32=y
|
||||
CT_ARCH_DEFAULT_32=y
|
||||
CT_ARCH_BITNESS=32
|
||||
CT_ARCH_32=y
|
||||
|
||||
#
|
||||
# Target optimisations
|
||||
#
|
||||
CT_ARCH_SUPPORTS_WITH_CPU=y
|
||||
CT_ARCH_CPU=""
|
||||
CT_TARGET_CFLAGS=""
|
||||
CT_TARGET_LDFLAGS=""
|
||||
CT_ARCH_FLOAT=""
|
||||
|
||||
#
|
||||
# Toolchain options
|
||||
#
|
||||
|
||||
#
|
||||
# General toolchain options
|
||||
#
|
||||
CT_TOOLCHAIN_PKGVERSION=""
|
||||
CT_TOOLCHAIN_BUGURL=""
|
||||
|
||||
#
|
||||
# Tuple completion and aliasing
|
||||
#
|
||||
CT_TARGET_VENDOR="zephyr"
|
||||
CT_TARGET_ALIAS_SED_EXPR=""
|
||||
CT_TARGET_ALIAS=""
|
||||
|
||||
#
|
||||
# Toolchain type
|
||||
#
|
||||
CT_CROSS=y
|
||||
# CT_CANADIAN is not set
|
||||
CT_TOOLCHAIN_TYPE="cross"
|
||||
|
||||
#
|
||||
# Build system
|
||||
#
|
||||
CT_BUILD=""
|
||||
CT_BUILD_PREFIX=""
|
||||
CT_BUILD_SUFFIX=""
|
||||
|
||||
#
|
||||
# Misc options
|
||||
#
|
||||
# CT_TOOLCHAIN_ENABLE_NLS is not set
|
||||
|
||||
#
|
||||
# Operating System
|
||||
#
|
||||
CT_BARE_METAL=y
|
||||
CT_KERNEL="bare-metal"
|
||||
CT_KERNEL_bare_metal=y
|
||||
# CT_KERNEL_linux is not set
|
||||
CT_KERNEL_bare_metal_AVAILABLE=y
|
||||
CT_KERNEL_linux_AVAILABLE=y
|
||||
CT_KERNEL_windows_AVAILABLE=y
|
||||
|
||||
#
|
||||
# Common kernel options
|
||||
#
|
||||
|
||||
#
|
||||
# Binary utilities
|
||||
#
|
||||
CT_ARCH_BINFMT_ELF=y
|
||||
# CT_ARCH_BINFMT_FLAT is not set
|
||||
# CT_ARCH_BINFMT_FDPIC is not set
|
||||
CT_BINUTILS="binutils"
|
||||
CT_BINUTILS_binutils=y
|
||||
|
||||
#
|
||||
# GNU binutils
|
||||
#
|
||||
CT_BINUTILS_VERSION="2.28"
|
||||
# CT_BINUTILS_SHOW_LINARO is not set
|
||||
CT_BINUTILS_V_2_28=y
|
||||
# CT_BINUTILS_V_2_27 is not set
|
||||
# CT_BINUTILS_V_2_26 is not set
|
||||
CT_BINUTILS_2_27_or_later=y
|
||||
CT_BINUTILS_2_26_or_later=y
|
||||
CT_BINUTILS_2_25_1_or_later=y
|
||||
CT_BINUTILS_2_25_or_later=y
|
||||
CT_BINUTILS_2_24_or_later=y
|
||||
CT_BINUTILS_2_23_2_or_later=y
|
||||
CT_BINUTILS_HAS_HASH_STYLE=y
|
||||
CT_BINUTILS_HAS_GOLD=y
|
||||
CT_BINUTILS_HAS_PLUGINS=y
|
||||
CT_BINUTILS_HAS_PKGVERSION_BUGURL=y
|
||||
CT_BINUTILS_LINKER_LD=y
|
||||
CT_BINUTILS_LINKERS_LIST="ld"
|
||||
CT_BINUTILS_LINKER_DEFAULT="bfd"
|
||||
# CT_BINUTILS_PLUGINS is not set
|
||||
CT_BINUTILS_EXTRA_CONFIG_ARRAY=""
|
||||
|
||||
#
|
||||
# binutils other options
|
||||
#
|
||||
|
||||
#
|
||||
# C-library
|
||||
#
|
||||
CT_LIBC="newlib"
|
||||
CT_LIBC_VERSION="2.5.0.20170323"
|
||||
CT_LIBC_newlib=y
|
||||
# CT_LIBC_none is not set
|
||||
CT_LIBC_avr_libc_AVAILABLE=y
|
||||
CT_LIBC_glibc_AVAILABLE=y
|
||||
CT_THREADS="none"
|
||||
CT_LIBC_mingw_AVAILABLE=y
|
||||
CT_LIBC_musl_AVAILABLE=y
|
||||
CT_LIBC_newlib_AVAILABLE=y
|
||||
# CT_CC_NEWLIB_SHOW_LINARO is not set
|
||||
CT_LIBC_NEWLIB_V_2_5_0=y
|
||||
# CT_LIBC_NEWLIB_V_2_4_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_2_3_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_2_2_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_2_1_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_2_0_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_1_20_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_1_19_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_1_18_0 is not set
|
||||
# CT_LIBC_NEWLIB_V_1_17_0 is not set
|
||||
CT_LIBC_NEWLIB_2_5=y
|
||||
CT_LIBC_NEWLIB_2_5_or_later=y
|
||||
CT_LIBC_NEWLIB_2_4_or_later=y
|
||||
CT_LIBC_NEWLIB_2_3_or_later=y
|
||||
CT_LIBC_NEWLIB_2_2_or_later=y
|
||||
CT_LIBC_NEWLIB_2_1_or_later=y
|
||||
CT_LIBC_NEWLIB_2_0_or_later=y
|
||||
CT_LIBC_NEWLIB_TARGET_CFLAGS=""
|
||||
CT_LIBC_none_AVAILABLE=y
|
||||
CT_LIBC_uClibc_AVAILABLE=y
|
||||
CT_LIBC_SUPPORT_THREADS_NONE=y
|
||||
CT_LIBC_PROVIDES_CXA_ATEXIT=y
|
||||
|
||||
#
|
||||
# Common C library options
|
||||
#
|
||||
CT_THREADS_NONE=y
|
||||
|
||||
#
|
||||
# newlib other options
|
||||
#
|
||||
# CT_LIBC_NEWLIB_IO_C99FMT is not set
|
||||
# CT_LIBC_NEWLIB_IO_LL is not set
|
||||
CT_LIBC_NEWLIB_IO_FLOAT=y
|
||||
# CT_LIBC_NEWLIB_IO_LDBL is not set
|
||||
# CT_LIBC_NEWLIB_IO_POS_ARGS is not set
|
||||
CT_LIBC_NEWLIB_FVWRITE_IN_STREAMIO=y
|
||||
CT_LIBC_NEWLIB_UNBUF_STREAM_OPT=y
|
||||
# CT_LIBC_NEWLIB_FSEEK_OPTIMIZATION is not set
|
||||
CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS=y
|
||||
# CT_LIBC_NEWLIB_REGISTER_FINI is not set
|
||||
CT_LIBC_NEWLIB_ATEXIT_DYNAMIC_ALLOC=y
|
||||
CT_LIBC_NEWLIB_GLOBAL_ATEXIT=y
|
||||
CT_LIBC_NEWLIB_LITE_EXIT=y
|
||||
# CT_LIBC_NEWLIB_REENT_SMALL is not set
|
||||
# CT_LIBC_NEWLIB_MULTITHREAD is not set
|
||||
# CT_LIBC_NEWLIB_EXTRA_SECTIONS is not set
|
||||
# CT_LIBC_NEWLIB_WIDE_ORIENT is not set
|
||||
CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE=y
|
||||
# CT_LIBC_NEWLIB_LTO is not set
|
||||
CT_LIBC_NEWLIB_NANO_MALLOC=y
|
||||
CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y
|
||||
CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY=""
|
||||
|
||||
#
|
||||
# C compiler
|
||||
#
|
||||
CT_CC="gcc"
|
||||
CT_CC_CORE_PASS_2_NEEDED=y
|
||||
CT_CC_gcc=y
|
||||
CT_CC_GCC_VERSION="6.3.0"
|
||||
# CT_CC_GCC_SHOW_LINARO is not set
|
||||
CT_CC_GCC_V_6_3_0=y
|
||||
# CT_CC_GCC_V_5_4_0 is not set
|
||||
# CT_CC_GCC_V_4_9_4 is not set
|
||||
CT_CC_GCC_4_8_or_later=y
|
||||
CT_CC_GCC_4_9_or_later=y
|
||||
CT_CC_GCC_5_or_later=y
|
||||
CT_CC_GCC_6=y
|
||||
CT_CC_GCC_6_or_later=y
|
||||
CT_CC_GCC_HAS_LIBMPX=y
|
||||
CT_CC_GCC_ENABLE_CXX_FLAGS=""
|
||||
CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY=""
|
||||
CT_CC_GCC_EXTRA_CONFIG_ARRAY=""
|
||||
# CT_CC_GCC_TARGET_FINAL is not set
|
||||
# CT_CC_GCC_SYSTEM_ZLIB is not set
|
||||
CT_CC_GCC_CONFIG_TLS=m
|
||||
|
||||
#
|
||||
# Optimisation features
|
||||
#
|
||||
CT_CC_GCC_USE_GRAPHITE=y
|
||||
CT_CC_GCC_USE_LTO=y
|
||||
|
||||
#
|
||||
# Settings for libraries running on target
|
||||
#
|
||||
CT_CC_GCC_ENABLE_TARGET_OPTSPACE=y
|
||||
# CT_CC_GCC_LIBMUDFLAP is not set
|
||||
# CT_CC_GCC_LIBSSP is not set
|
||||
# CT_CC_GCC_LIBQUADMATH is not set
|
||||
|
||||
#
|
||||
# Misc. obscure options.
|
||||
#
|
||||
CT_CC_CXA_ATEXIT=y
|
||||
# CT_CC_GCC_DISABLE_PCH is not set
|
||||
CT_CC_GCC_LDBL_128=m
|
||||
# CT_CC_GCC_BUILD_ID is not set
|
||||
CT_CC_GCC_LNK_HASH_STYLE_DEFAULT=y
|
||||
# CT_CC_GCC_LNK_HASH_STYLE_SYSV is not set
|
||||
# CT_CC_GCC_LNK_HASH_STYLE_GNU is not set
|
||||
# CT_CC_GCC_LNK_HASH_STYLE_BOTH is not set
|
||||
CT_CC_GCC_LNK_HASH_STYLE=""
|
||||
CT_CC_GCC_DEC_FLOAT_AUTO=y
|
||||
# CT_CC_GCC_DEC_FLOAT_BID is not set
|
||||
# CT_CC_GCC_DEC_FLOAT_DPD is not set
|
||||
# CT_CC_GCC_DEC_FLOATS_NO is not set
|
||||
CT_CC_SUPPORT_CXX=y
|
||||
CT_CC_SUPPORT_FORTRAN=y
|
||||
CT_CC_SUPPORT_JAVA=y
|
||||
CT_CC_SUPPORT_ADA=y
|
||||
CT_CC_SUPPORT_OBJC=y
|
||||
CT_CC_SUPPORT_OBJCXX=y
|
||||
CT_CC_SUPPORT_GOLANG=y
|
||||
|
||||
#
|
||||
# Additional supported languages:
|
||||
#
|
||||
CT_CC_LANG_CXX=y
|
||||
# CT_CC_LANG_FORTRAN is not set
|
||||
|
||||
#
|
||||
# Debug facilities
|
||||
#
|
||||
CT_DEBUG_gdb=y
|
||||
CT_GDB_CROSS=y
|
||||
# CT_GDB_CROSS_SIM is not set
|
||||
CT_GDB_CROSS_PYTHON=y
|
||||
CT_GDB_CROSS_PYTHON_BINARY=""
|
||||
CT_GDB_CROSS_EXTRA_CONFIG_ARRAY=""
|
||||
|
||||
#
|
||||
# In bare-metal, you'll need to
|
||||
#
|
||||
|
||||
#
|
||||
# provide your own gdbserver stub.
|
||||
#
|
||||
|
||||
#
|
||||
# gdb version
|
||||
#
|
||||
CT_GDB_VERSION="7.12.1"
|
||||
CT_GDB_V_7_12_1=y
|
||||
# CT_GDB_V_7_11_1 is not set
|
||||
CT_GDB_7_12_or_later=y
|
||||
CT_GDB_7_2_or_later=y
|
||||
CT_GDB_7_0_or_later=y
|
||||
CT_GDB_HAS_PKGVERSION_BUGURL=y
|
||||
CT_GDB_HAS_PYTHON=y
|
||||
CT_GDB_INSTALL_GDBINIT=y
|
||||
# CT_DEBUG_ltrace is not set
|
||||
# CT_DEBUG_strace is not set
|
||||
|
||||
#
|
||||
# Companion libraries
|
||||
#
|
||||
CT_COMPLIBS_NEEDED=y
|
||||
CT_LIBICONV_NEEDED=y
|
||||
CT_GMP_NEEDED=y
|
||||
CT_MPFR_NEEDED=y
|
||||
CT_ISL_NEEDED=y
|
||||
CT_MPC_NEEDED=y
|
||||
CT_EXPAT_NEEDED=y
|
||||
CT_NCURSES_NEEDED=y
|
||||
CT_COMPLIBS=y
|
||||
CT_LIBICONV=y
|
||||
CT_GETTEXT=y
|
||||
CT_GMP=y
|
||||
CT_MPFR=y
|
||||
CT_ISL=y
|
||||
CT_MPC=y
|
||||
CT_EXPAT=y
|
||||
CT_NCURSES=y
|
||||
CT_ZLIB=y
|
||||
CT_ZLIB_V_1_2_11=y
|
||||
CT_ZLIB_VERSION="1.2.11"
|
||||
CT_LIBICONV_V_1_15=y
|
||||
# CT_LIBICONV_V_1_14 is not set
|
||||
CT_LIBICONV_VERSION="1.15"
|
||||
CT_GETTEXT_V_0_19_8_1=y
|
||||
CT_GETTEXT_VERSION="0.19.8.1"
|
||||
CT_GMP_V_6_1_2=y
|
||||
CT_GMP_5_0_2_or_later=y
|
||||
CT_GMP_VERSION="6.1.2"
|
||||
CT_MPFR_V_3_1_5=y
|
||||
CT_MPFR_VERSION="3.1.5"
|
||||
CT_ISL_V_0_16_1=y
|
||||
# CT_ISL_V_0_15 is not set
|
||||
CT_ISL_V_0_16_or_later=y
|
||||
CT_ISL_V_0_15_or_later=y
|
||||
CT_ISL_V_0_14_or_later=y
|
||||
CT_ISL_V_0_12_or_later=y
|
||||
CT_ISL_VERSION="0.16.1"
|
||||
CT_MPC_V_1_0_3=y
|
||||
CT_MPC_VERSION="1.0.3"
|
||||
CT_EXPAT_V_2_2_0=y
|
||||
CT_EXPAT_VERSION="2.2.0"
|
||||
CT_NCURSES_V_6_0=y
|
||||
CT_NCURSES_VERSION="6.0"
|
||||
CT_NCURSES_HOST_CONFIG_ARGS=""
|
||||
CT_NCURSES_HOST_DISABLE_DB=y
|
||||
CT_NCURSES_HOST_FALLBACKS="linux,xterm,xterm-color,xterm-256color,vt100"
|
||||
CT_NCURSES_TARGET_CONFIG_ARGS=""
|
||||
# CT_NCURSES_TARGET_DISABLE_DB is not set
|
||||
CT_NCURSES_TARGET_FALLBACKS=""
|
||||
|
||||
#
|
||||
# Companion libraries common options
|
||||
#
|
||||
# CT_COMPLIBS_CHECK is not set
|
||||
|
||||
#
|
||||
# Companion tools
|
||||
#
|
||||
# CT_COMP_TOOLS_FOR_HOST is not set
|
||||
# CT_COMP_TOOLS_autoconf is not set
|
||||
# CT_COMP_TOOLS_automake is not set
|
||||
# CT_COMP_TOOLS_libtool is not set
|
||||
CT_COMP_TOOLS_m4=y
|
||||
CT_M4_V_1_4_18=y
|
||||
CT_M4_VERSION="1.4.18"
|
||||
CT_COMP_TOOLS_make=y
|
||||
CT_MAKE_V_4_2_1=y
|
||||
# CT_MAKE_GMAKE_SYMLINK is not set
|
||||
CT_MAKE_VERSION="4.2.1"
|
||||
@@ -1,10 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# vim: ai:ts=4:sw=4
|
||||
|
||||
import sys
|
||||
from os import walk
|
||||
import os
|
||||
import re
|
||||
import yaml
|
||||
import pprint
|
||||
import argparse
|
||||
|
||||
from devicetree import parse_file
|
||||
|
||||
@@ -503,7 +507,26 @@ def print_key_value(k, v, tabstop):
|
||||
|
||||
return
|
||||
|
||||
def generate_include_file(defs):
|
||||
def generate_keyvalue_file(defs, args):
|
||||
compatible = reduced['/']['props']['compatible'][0]
|
||||
|
||||
node_keys = sorted(defs.keys())
|
||||
for node in node_keys:
|
||||
sys.stdout.write('# ' + node.split('/')[-1] )
|
||||
sys.stdout.write("\n")
|
||||
|
||||
prop_keys = sorted(defs[node].keys())
|
||||
for prop in prop_keys:
|
||||
if prop == 'aliases':
|
||||
for entry in sorted(defs[node][prop]):
|
||||
a = defs[node][prop].get(entry)
|
||||
sys.stdout.write("%s=%s\n" %(entry, defs[node].get(a)))
|
||||
else:
|
||||
sys.stdout.write("%s=%s\n" %(prop,defs[node].get(prop)))
|
||||
|
||||
sys.stdout.write("\n")
|
||||
|
||||
def generate_include_file(defs, args):
|
||||
compatible = reduced['/']['props']['compatible'][0]
|
||||
|
||||
sys.stdout.write("/**************************************************\n")
|
||||
@@ -534,23 +557,50 @@ def generate_include_file(defs):
|
||||
for prop in prop_keys:
|
||||
if prop == 'aliases':
|
||||
for entry in sorted(defs[node][prop]):
|
||||
print_key_value(entry, defs[node][prop].get(entry), maxtabstop)
|
||||
a = defs[node][prop].get(entry)
|
||||
print_key_value(entry, a, maxtabstop)
|
||||
else:
|
||||
print_key_value(prop, defs[node].get(prop), maxtabstop)
|
||||
|
||||
sys.stdout.write("\n")
|
||||
|
||||
sys.stdout.write("#endif\n");
|
||||
if args.fixup and os.path.exists(args.fixup):
|
||||
sys.stdout.write("\n")
|
||||
sys.stdout.write("/* Following definitions fixup the generated include */\n")
|
||||
try:
|
||||
with open(args.fixup, "r") as fd:
|
||||
for line in fd.readlines():
|
||||
sys.stdout.write(line)
|
||||
sys.stdout.write("\n")
|
||||
except:
|
||||
raise Exception("Input file " + os.path.abspath(args.fixup) + " does not exist.")
|
||||
|
||||
def main(args):
|
||||
if len(args) < 2:
|
||||
print('Usage: %s filename.dts path_to_yaml' % args[0])
|
||||
sys.stdout.write("#endif\n")
|
||||
|
||||
def parse_arguments():
|
||||
|
||||
parser = argparse.ArgumentParser(description = __doc__,
|
||||
formatter_class = argparse.RawDescriptionHelpFormatter)
|
||||
|
||||
parser.add_argument("-d", "--dts", help="DTS file")
|
||||
parser.add_argument("-y", "--yaml", help="YAML file")
|
||||
parser.add_argument("-f", "--fixup", help="Fixup file")
|
||||
parser.add_argument("-k", "--keyvalue", action="store_true",
|
||||
help="Generate file to be included by the build system")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
def main():
|
||||
args = parse_arguments()
|
||||
if not args.dts or not args.yaml:
|
||||
print('Usage: %s -d filename.dts -y path_to_yaml' % sys.argv[0])
|
||||
return 1
|
||||
|
||||
try:
|
||||
with open(args[1], "r") as fd:
|
||||
with open(args.dts, "r") as fd:
|
||||
d = parse_file(fd)
|
||||
except:
|
||||
raise Exception("Input file " + os.path.abspath(args[1]) + " does not exist.")
|
||||
raise Exception("Input file " + os.path.abspath(args.dts) + " does not exist.")
|
||||
|
||||
# compress list to nodes w/ paths, add interrupt parent
|
||||
compress_nodes(d['/'], '/')
|
||||
@@ -572,7 +622,7 @@ def main(args):
|
||||
|
||||
# scan YAML files and find the ones we are interested in
|
||||
yaml_files = []
|
||||
for (dirpath, dirnames, filenames) in walk(args[2]):
|
||||
for (dirpath, dirnames, filenames) in walk(args.yaml):
|
||||
yaml_files.extend([f for f in filenames if re.match('.*\.yaml\Z', f)])
|
||||
yaml_files = [dirpath + '/' + t for t in yaml_files]
|
||||
break
|
||||
@@ -628,9 +678,10 @@ def main(args):
|
||||
extract_reg_prop(chosen['zephyr,sram'], None, defs, "CONFIG_SRAM", 1024)
|
||||
|
||||
# generate include file
|
||||
generate_include_file(defs)
|
||||
if args.keyvalue:
|
||||
generate_keyvalue_file(defs, args)
|
||||
else:
|
||||
generate_include_file(defs, args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
# test1.py executed as script
|
||||
# do something
|
||||
sys.exit(main(sys.argv))
|
||||
main()
|
||||
|
||||
@@ -57,6 +57,29 @@ config BLUETOOTH_CENTRAL
|
||||
help
|
||||
Select this for LE Central role support.
|
||||
|
||||
menu "Broadcaster"
|
||||
visible if !BLUETOOTH_PERIPHERAL
|
||||
|
||||
config BLUETOOTH_BROADCASTER
|
||||
bool "Broadcaster Role support"
|
||||
default y if BLUETOOTH_PERIPHERAL
|
||||
default y if !BLUETOOTH_OBSERVER
|
||||
help
|
||||
Select this for LE Broadcaster role support.
|
||||
|
||||
endmenu
|
||||
|
||||
menu "Observer"
|
||||
visible if !BLUETOOTH_CENTRAL
|
||||
|
||||
config BLUETOOTH_OBSERVER
|
||||
bool "Observer Role support"
|
||||
default y if BLUETOOTH_CENTRAL
|
||||
help
|
||||
Select this for LE Observer role support.
|
||||
|
||||
endmenu
|
||||
|
||||
config BLUETOOTH_CONN
|
||||
# Virtual/hidden option
|
||||
bool
|
||||
|
||||
@@ -30,33 +30,10 @@ endchoice
|
||||
|
||||
comment "BLE Controller configuration"
|
||||
|
||||
menu "Advertiser"
|
||||
visible if !BLUETOOTH_PERIPHERAL
|
||||
|
||||
config BLUETOOTH_CONTROLLER_STATE_ADV
|
||||
bool "Enable Advertiser"
|
||||
default y if BLUETOOTH_PERIPHERAL
|
||||
default y if !BLUETOOTH_CONTROLLER_STATE_SCAN
|
||||
help
|
||||
Enable support for advertising state in the Controller.
|
||||
|
||||
endmenu
|
||||
|
||||
menu "Scanner"
|
||||
visible if !BLUETOOTH_CENTRAL
|
||||
|
||||
config BLUETOOTH_CONTROLLER_STATE_SCAN
|
||||
bool "Enable Scanner"
|
||||
default y if BLUETOOTH_CENTRAL
|
||||
help
|
||||
Enable support for scanning state in the Controller.
|
||||
|
||||
endmenu
|
||||
|
||||
config BLUETOOTH_CONTROLLER_DUP_FILTER_LEN
|
||||
prompt "Number of addresses in the scan duplicate filter"
|
||||
int
|
||||
depends on BLUETOOTH_CONTROLLER_STATE_SCAN
|
||||
depends on BLUETOOTH_OBSERVER
|
||||
default 16
|
||||
help
|
||||
Set the number of unique BLE addresses that can be filtered as
|
||||
@@ -116,10 +93,12 @@ config BLUETOOTH_CONTROLLER_SUBVERSION_NUMBER
|
||||
|
||||
config BLUETOOTH_CONTROLLER_RX_PRIO_STACK_SIZE
|
||||
int
|
||||
default 320
|
||||
default 448
|
||||
|
||||
comment "BLE Controller features"
|
||||
|
||||
if BLUETOOTH_CONN
|
||||
|
||||
config BLUETOOTH_CONTROLLER_LE_PING
|
||||
bool "LE Ping"
|
||||
default y
|
||||
@@ -156,6 +135,8 @@ config BLUETOOTH_CONTROLLER_CHAN_SEL_2
|
||||
Enable support for Bluetooth 5.0 LE Channel Selection Algorithm #2 in
|
||||
the Controller.
|
||||
|
||||
endif # BLUETOOTH_CONN
|
||||
|
||||
config BLUETOOTH_CONTROLLER_ADVANCED_FEATURES
|
||||
bool "Show advanced features"
|
||||
help
|
||||
@@ -267,6 +248,8 @@ config BLUETOOTH_CONTROLLER_TIFS_HW
|
||||
help
|
||||
Enable use of hardware accelerated tIFS Trx switching.
|
||||
|
||||
if BLUETOOTH_CONN
|
||||
|
||||
config BLUETOOTH_CONTROLLER_FAST_ENC
|
||||
bool "Fast Encryption Setup"
|
||||
help
|
||||
@@ -285,6 +268,8 @@ config BLUETOOTH_CONTROLLER_CONN_RSSI
|
||||
help
|
||||
Enable connection RSSI measurement.
|
||||
|
||||
endif # BLUETOOTH_CONN
|
||||
|
||||
config BLUETOOTH_CONTROLLER_ADV_INDICATION
|
||||
bool "Advertisement indications"
|
||||
help
|
||||
|
||||
@@ -566,7 +566,7 @@ static void le_read_supp_states(struct net_buf *buf, struct net_buf **evt)
|
||||
sys_put_le64(0x000003ffffffffff, rp->le_states);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_STATE_ADV)
|
||||
#if defined(CONFIG_BLUETOOTH_BROADCASTER)
|
||||
static void le_set_adv_param(struct net_buf *buf, struct net_buf **evt)
|
||||
{
|
||||
struct bt_hci_cp_le_set_adv_param *cmd = (void *)buf->data;
|
||||
@@ -628,9 +628,9 @@ static void le_set_adv_enable(struct net_buf *buf, struct net_buf **evt)
|
||||
ccst = cmd_complete(evt, sizeof(*ccst));
|
||||
ccst->status = (!status) ? 0x00 : BT_HCI_ERR_CMD_DISALLOWED;
|
||||
}
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_ADV */
|
||||
#endif /* CONFIG_BLUETOOTH_BROADCASTER */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN)
|
||||
#if defined(CONFIG_BLUETOOTH_OBSERVER)
|
||||
static void le_set_scan_param(struct net_buf *buf, struct net_buf **evt)
|
||||
{
|
||||
struct bt_hci_cp_le_set_scan_param *cmd = (void *)buf->data;
|
||||
@@ -668,7 +668,7 @@ static void le_set_scan_enable(struct net_buf *buf, struct net_buf **evt)
|
||||
ccst = cmd_complete(evt, sizeof(*ccst));
|
||||
ccst->status = (!status) ? 0x00 : BT_HCI_ERR_CMD_DISALLOWED;
|
||||
}
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN */
|
||||
#endif /* CONFIG_BLUETOOTH_OBSERVER */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONN)
|
||||
#if defined(CONFIG_BLUETOOTH_CENTRAL)
|
||||
@@ -1030,7 +1030,7 @@ static int controller_cmd_handle(u8_t ocf, struct net_buf *cmd,
|
||||
le_read_supp_states(cmd, evt);
|
||||
break;
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_STATE_ADV)
|
||||
#if defined(CONFIG_BLUETOOTH_BROADCASTER)
|
||||
case BT_OCF(BT_HCI_OP_LE_SET_ADV_PARAM):
|
||||
le_set_adv_param(cmd, evt);
|
||||
break;
|
||||
@@ -1050,9 +1050,9 @@ static int controller_cmd_handle(u8_t ocf, struct net_buf *cmd,
|
||||
case BT_OCF(BT_HCI_OP_LE_SET_ADV_ENABLE):
|
||||
le_set_adv_enable(cmd, evt);
|
||||
break;
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_ADV */
|
||||
#endif /* CONFIG_BLUETOOTH_BROADCASTER */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN)
|
||||
#if defined(CONFIG_BLUETOOTH_OBSERVER)
|
||||
case BT_OCF(BT_HCI_OP_LE_SET_SCAN_PARAM):
|
||||
le_set_scan_param(cmd, evt);
|
||||
break;
|
||||
@@ -1060,7 +1060,7 @@ static int controller_cmd_handle(u8_t ocf, struct net_buf *cmd,
|
||||
case BT_OCF(BT_HCI_OP_LE_SET_SCAN_ENABLE):
|
||||
le_set_scan_enable(cmd, evt);
|
||||
break;
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN */
|
||||
#endif /* CONFIG_BLUETOOTH_OBSERVER */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONN)
|
||||
#if defined(CONFIG_BLUETOOTH_CENTRAL)
|
||||
|
||||
@@ -3,6 +3,6 @@ ccflags-y += -I$(srctree)/subsys/bluetooth/controller
|
||||
ccflags-y += -I$(srctree)/subsys/bluetooth
|
||||
|
||||
obj-y += crypto.o ctrl.o ll.o
|
||||
obj-$(CONFIG_BLUETOOTH_CONTROLLER_STATE_ADV) += ll_adv.o
|
||||
obj-$(CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN) += ll_scan.o
|
||||
obj-$(CONFIG_BLUETOOTH_BROADCASTER) += ll_adv.o
|
||||
obj-$(CONFIG_BLUETOOTH_OBSERVER) += ll_scan.o
|
||||
obj-$(CONFIG_BLUETOOTH_CENTRAL) += ll_master.o
|
||||
|
||||
@@ -738,8 +738,7 @@ static inline u32_t isr_rx_adv(u8_t devmatch_ok, u8_t irkmatch_ok,
|
||||
struct connection *conn;
|
||||
u32_t ticker_status;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLUETOOTH_CONTROLLER_CHAN_SEL_2) &&
|
||||
pdu_adv->chan_sel) {
|
||||
if (IS_ENABLED(CONFIG_BLUETOOTH_CONTROLLER_CHAN_SEL_2)) {
|
||||
radio_pdu_node_rx = packet_rx_reserve_get(4);
|
||||
} else {
|
||||
radio_pdu_node_rx = packet_rx_reserve_get(3);
|
||||
@@ -1005,8 +1004,7 @@ static inline u32_t isr_rx_obs(u8_t irkmatch_id, u8_t rssi_ready)
|
||||
u32_t ticker_status;
|
||||
u32_t conn_space_us;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLUETOOTH_CONTROLLER_CHAN_SEL_2) &&
|
||||
pdu_adv_rx->chan_sel) {
|
||||
if (IS_ENABLED(CONFIG_BLUETOOTH_CONTROLLER_CHAN_SEL_2)) {
|
||||
radio_pdu_node_rx = packet_rx_reserve_get(4);
|
||||
} else {
|
||||
radio_pdu_node_rx = packet_rx_reserve_get(3);
|
||||
@@ -1498,6 +1496,48 @@ isr_rx_conn_pkt_ctrl_rej_conn_upd(struct radio_pdu_node_rx *radio_pdu_node_rx,
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH)
|
||||
static inline void
|
||||
isr_rx_conn_pkt_ctrl_rej_dle(struct radio_pdu_node_rx *radio_pdu_node_rx,
|
||||
u8_t *rx_enqueue)
|
||||
{
|
||||
struct pdu_data_llctrl_reject_ext_ind *rej_ext_ind;
|
||||
struct pdu_data *pdu_data_rx;
|
||||
|
||||
pdu_data_rx = (struct pdu_data *)radio_pdu_node_rx->pdu_data;
|
||||
rej_ext_ind = (struct pdu_data_llctrl_reject_ext_ind *)
|
||||
&pdu_data_rx->payload.llctrl.ctrldata.reject_ext_ind;
|
||||
if (rej_ext_ind->reject_opcode == PDU_DATA_LLCTRL_TYPE_LENGTH_REQ) {
|
||||
struct pdu_data_llctrl_length_req_rsp *lr;
|
||||
|
||||
/* Procedure complete */
|
||||
_radio.conn_curr->llcp_length.ack =
|
||||
_radio.conn_curr->llcp_length.req;
|
||||
_radio.conn_curr->procedure_expire = 0;
|
||||
|
||||
/* Resume data packet tx */
|
||||
_radio.conn_curr->pause_tx = 0;
|
||||
|
||||
/* prepare length rsp structure */
|
||||
pdu_data_rx->len = offsetof(struct pdu_data_llctrl,
|
||||
ctrldata) +
|
||||
sizeof(struct pdu_data_llctrl_length_req_rsp);
|
||||
pdu_data_rx->payload.llctrl.opcode =
|
||||
PDU_DATA_LLCTRL_TYPE_LENGTH_RSP;
|
||||
|
||||
lr = (struct pdu_data_llctrl_length_req_rsp *)
|
||||
&pdu_data_rx->payload.llctrl.ctrldata.length_req;
|
||||
lr->max_rx_octets = _radio.conn_curr->max_rx_octets;
|
||||
lr->max_rx_time = ((_radio.conn_curr->max_rx_octets + 14) << 3);
|
||||
lr->max_tx_octets = _radio.conn_curr->max_tx_octets;
|
||||
lr->max_tx_time = ((_radio.conn_curr->max_tx_octets + 14) << 3);
|
||||
|
||||
/* enqueue a length rsp */
|
||||
*rx_enqueue = 1;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PHY)
|
||||
static inline void
|
||||
isr_rx_conn_pkt_ctrl_rej_phy_upd(struct radio_pdu_node_rx *radio_pdu_node_rx,
|
||||
@@ -1563,6 +1603,13 @@ isr_rx_conn_pkt_ctrl_rej(struct radio_pdu_node_rx *radio_pdu_node_rx,
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH)
|
||||
} else if (_radio.conn_curr->llcp_length.ack !=
|
||||
_radio.conn_curr->llcp_length.req) {
|
||||
isr_rx_conn_pkt_ctrl_rej_dle(radio_pdu_node_rx,
|
||||
rx_enqueue);
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PHY)
|
||||
} else if (_radio.conn_curr->llcp_phy.ack !=
|
||||
_radio.conn_curr->llcp_phy.req) {
|
||||
@@ -1583,30 +1630,35 @@ static inline u8_t isr_rx_conn_pkt_ctrl_dle(struct pdu_data *pdu_data_rx,
|
||||
eff_rx_octets = _radio.conn_curr->max_rx_octets;
|
||||
eff_tx_octets = _radio.conn_curr->max_tx_octets;
|
||||
|
||||
if (/* Local idle, and peer request; complete the peer procedure
|
||||
if (/* Local idle, and Peer request then complete the Peer procedure
|
||||
* with response.
|
||||
*/
|
||||
((_radio.conn_curr->llcp_length.req ==
|
||||
_radio.conn_curr->llcp_length.ack) &&
|
||||
(PDU_DATA_LLCTRL_TYPE_LENGTH_REQ ==
|
||||
pdu_data_rx->payload.llctrl.opcode)) ||
|
||||
/* or Local has requested... */
|
||||
(pdu_data_rx->payload.llctrl.opcode ==
|
||||
PDU_DATA_LLCTRL_TYPE_LENGTH_REQ)) ||
|
||||
/* or Local has active... */
|
||||
((_radio.conn_curr->llcp_length.req !=
|
||||
_radio.conn_curr->llcp_length.ack) &&
|
||||
/* and Local request, and peer request; override with peer
|
||||
* procedure, and complete the peer procedure with response.
|
||||
/* with Local requested and Peer request then complete the
|
||||
* Peer procedure with response.
|
||||
*/
|
||||
(((LLCP_LENGTH_STATE_REQ == _radio.conn_curr->llcp_length.state) &&
|
||||
(PDU_DATA_LLCTRL_TYPE_LENGTH_REQ ==
|
||||
pdu_data_rx->payload.llctrl.opcode)) ||
|
||||
/* and Local wait, and peer response; complete the
|
||||
* local procedure.
|
||||
((((_radio.conn_curr->llcp_length.state ==
|
||||
LLCP_LENGTH_STATE_REQ) ||
|
||||
(_radio.conn_curr->llcp_length.state ==
|
||||
LLCP_LENGTH_STATE_ACK_WAIT)) &&
|
||||
(pdu_data_rx->payload.llctrl.opcode ==
|
||||
PDU_DATA_LLCTRL_TYPE_LENGTH_REQ)) ||
|
||||
/* with Local waiting for response, and Peer response then
|
||||
* complete the Local procedure or Peer request then complete the
|
||||
* Peer procedure with response.
|
||||
*/
|
||||
((LLCP_LENGTH_STATE_RSP_WAIT ==
|
||||
_radio.conn_curr->llcp_length.state) &&
|
||||
(PDU_DATA_LLCTRL_TYPE_LENGTH_RSP ==
|
||||
pdu_data_rx->payload.llctrl.opcode))))) {
|
||||
|
||||
((_radio.conn_curr->llcp_length.state ==
|
||||
LLCP_LENGTH_STATE_RSP_WAIT) &&
|
||||
((pdu_data_rx->payload.llctrl.opcode ==
|
||||
PDU_DATA_LLCTRL_TYPE_LENGTH_RSP) ||
|
||||
(pdu_data_rx->payload.llctrl.opcode ==
|
||||
PDU_DATA_LLCTRL_TYPE_LENGTH_REQ)))))) {
|
||||
struct pdu_data_llctrl_length_req_rsp *lr;
|
||||
|
||||
lr = (struct pdu_data_llctrl_length_req_rsp *)
|
||||
@@ -1684,7 +1736,9 @@ static inline u8_t isr_rx_conn_pkt_ctrl_dle(struct pdu_data *pdu_data_rx,
|
||||
*rx_enqueue = 1;
|
||||
}
|
||||
} else {
|
||||
LL_ASSERT(0);
|
||||
/* Drop response with no Local initiated request. */
|
||||
LL_ASSERT(pdu_data_rx->payload.llctrl.opcode ==
|
||||
PDU_DATA_LLCTRL_TYPE_LENGTH_RSP);
|
||||
}
|
||||
|
||||
if ((PDU_DATA_LLCTRL_TYPE_LENGTH_REQ ==
|
||||
@@ -5549,8 +5603,15 @@ static inline void event_enc_prep(struct connection *conn)
|
||||
/* send enc start resp */
|
||||
start_enc_rsp_send(conn, pdu_ctrl_tx);
|
||||
}
|
||||
|
||||
/* slave send reject ind or start enc req at control priority */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC)
|
||||
else {
|
||||
#else /* !CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
|
||||
else if (!conn->pause_tx || conn->refresh) {
|
||||
#endif /* !CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
|
||||
|
||||
/* ll ctrl packet */
|
||||
pdu_ctrl_tx->ll_id = PDU_DATA_LLID_CTRL;
|
||||
|
||||
@@ -5575,7 +5636,7 @@ static inline void event_enc_prep(struct connection *conn)
|
||||
* controller.
|
||||
*/
|
||||
enc_rsp_send(conn);
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
|
||||
#endif /* !CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
|
||||
|
||||
/* calc the Session Key */
|
||||
ecb_encrypt(&conn->llcp.encryption.ltk[0],
|
||||
@@ -5614,9 +5675,9 @@ static inline void event_enc_prep(struct connection *conn)
|
||||
pdu_ctrl_tx->payload.llctrl.opcode =
|
||||
PDU_DATA_LLCTRL_TYPE_START_ENC_REQ;
|
||||
}
|
||||
} else {
|
||||
|
||||
#if !defined(CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC)
|
||||
} else {
|
||||
/* enable transmit encryption */
|
||||
_radio.conn_curr->enc_tx = 1;
|
||||
|
||||
@@ -5625,13 +5686,7 @@ static inline void event_enc_prep(struct connection *conn)
|
||||
/* resume data packet rx and tx */
|
||||
_radio.conn_curr->pause_rx = 0;
|
||||
_radio.conn_curr->pause_tx = 0;
|
||||
#else /* CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
|
||||
/* Fast Enc implementation shall have enqueued the
|
||||
* start enc rsp in the radio ISR itself, we should
|
||||
* not get here.
|
||||
*/
|
||||
LL_ASSERT(0);
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
|
||||
#endif /* !CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
|
||||
|
||||
}
|
||||
|
||||
@@ -5963,7 +6018,7 @@ static inline void event_len_prep(struct connection *conn)
|
||||
node_rx->hdr.handle = conn->handle;
|
||||
node_rx->hdr.type = NODE_RX_TYPE_DC_PDU;
|
||||
|
||||
/* prepare version ind structure */
|
||||
/* prepare length rsp structure */
|
||||
pdu_ctrl_rx = (struct pdu_data *) node_rx->pdu_data;
|
||||
pdu_ctrl_rx->ll_id = PDU_DATA_LLID_CTRL;
|
||||
pdu_ctrl_rx->len = offsetof(struct pdu_data_llctrl,
|
||||
|
||||
@@ -97,6 +97,8 @@ static struct bt_att bt_req_pool[CONFIG_BLUETOOTH_MAX_CONN];
|
||||
|
||||
static void att_req_destroy(struct bt_att_req *req)
|
||||
{
|
||||
BT_DBG("req %p", req);
|
||||
|
||||
if (req->buf) {
|
||||
net_buf_unref(req->buf);
|
||||
}
|
||||
@@ -148,7 +150,7 @@ static void att_req_sent(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_att *att = att_get(conn);
|
||||
|
||||
BT_DBG("conn %p att %p", conn, att);
|
||||
BT_DBG("conn %p att %p att->req %p", conn, att, att->req);
|
||||
|
||||
k_sem_give(&att->tx_sem);
|
||||
|
||||
@@ -298,13 +300,13 @@ static u8_t att_handle_rsp(struct bt_att *att, void *pdu, u16_t len,
|
||||
{
|
||||
bt_att_func_t func;
|
||||
|
||||
/* Cancel timeout if ongoing */
|
||||
k_delayed_work_cancel(&att->timeout_work);
|
||||
|
||||
if (!att->req) {
|
||||
goto process;
|
||||
}
|
||||
|
||||
/* Cancel timeout if ongoing */
|
||||
k_delayed_work_cancel(&att->timeout_work);
|
||||
|
||||
/* Release original buffer */
|
||||
if (att->req->buf) {
|
||||
net_buf_unref(att->req->buf);
|
||||
@@ -2164,6 +2166,8 @@ int bt_att_send(struct bt_conn *conn, struct net_buf *buf)
|
||||
|
||||
hdr = (void *)buf->data;
|
||||
|
||||
BT_DBG("code 0x%02x", hdr->code);
|
||||
|
||||
if (hdr->code == BT_ATT_OP_SIGNED_WRITE_CMD) {
|
||||
int err;
|
||||
|
||||
@@ -2209,6 +2213,8 @@ void bt_att_req_cancel(struct bt_conn *conn, struct bt_att_req *req)
|
||||
{
|
||||
struct bt_att *att;
|
||||
|
||||
BT_DBG("req %p", req);
|
||||
|
||||
if (!conn || !req) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,10 +161,6 @@ void bt_avdtp_l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
||||
msgtype, sigid, tid);
|
||||
net_buf_pull(buf, sizeof(*hdr));
|
||||
|
||||
if (msgtype > BT_AVDTP_REJECT) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* validate if there is an outstanding resp expected*/
|
||||
if (msgtype != BT_AVDTP_CMD) {
|
||||
if (session->req == NULL) {
|
||||
|
||||
@@ -25,6 +25,7 @@ enum {
|
||||
BT_CONN_BR_PAIRING_INITIATOR, /* local host starts authentication */
|
||||
BT_CONN_CLEANUP, /* Disconnected, pending cleanup */
|
||||
BT_CONN_AUTO_PHY_UPDATE, /* Auto-update PHY */
|
||||
BT_CONN_AUTO_DATA_LEN, /* Auto data len change in progress */
|
||||
|
||||
/* Total number of flags - must be at the end of the enum */
|
||||
BT_CONN_NUM_FLAGS,
|
||||
|
||||
@@ -644,6 +644,41 @@ static int hci_le_read_remote_features(struct bt_conn *conn)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hci_le_set_data_len(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_hci_rp_le_read_max_data_len *rp;
|
||||
struct bt_hci_cp_le_set_data_len *cp;
|
||||
struct net_buf *buf, *rsp;
|
||||
u16_t tx_octets, tx_time;
|
||||
int err;
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_MAX_DATA_LEN, NULL, &rsp);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
rp = (void *)rsp->data;
|
||||
tx_octets = sys_le16_to_cpu(rp->max_tx_octets);
|
||||
tx_time = sys_le16_to_cpu(rp->max_tx_time);
|
||||
net_buf_unref(rsp);
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_DATA_LEN, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
cp->handle = sys_cpu_to_le16(conn->handle);
|
||||
cp->tx_octets = sys_cpu_to_le16(tx_octets);
|
||||
cp->tx_time = sys_cpu_to_le16(tx_time);
|
||||
err = bt_hci_cmd_send(BT_HCI_OP_LE_SET_DATA_LEN, buf);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hci_le_set_phy(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_hci_cp_le_set_phy *cp;
|
||||
@@ -810,6 +845,14 @@ static void le_conn_complete(struct net_buf *buf)
|
||||
}
|
||||
}
|
||||
|
||||
if (BT_FEAT_LE_DLE(bt_dev.le.features)) {
|
||||
err = hci_le_set_data_len(conn);
|
||||
if (!err) {
|
||||
atomic_set_bit(conn->flags, BT_CONN_AUTO_DATA_LEN);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
update_conn_param(conn);
|
||||
|
||||
done:
|
||||
@@ -845,7 +888,48 @@ static void le_remote_feat_complete(struct net_buf *buf)
|
||||
}
|
||||
}
|
||||
|
||||
if (BT_FEAT_LE_DLE(bt_dev.le.features) &&
|
||||
BT_FEAT_LE_DLE(conn->le.features)) {
|
||||
int err;
|
||||
|
||||
err = hci_le_set_data_len(conn);
|
||||
if (!err) {
|
||||
atomic_set_bit(conn->flags, BT_CONN_AUTO_DATA_LEN);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
update_conn_param(conn);
|
||||
|
||||
done:
|
||||
bt_conn_unref(conn);
|
||||
}
|
||||
|
||||
static void le_data_len_change(struct net_buf *buf)
|
||||
{
|
||||
struct bt_hci_evt_le_data_len_change *evt = (void *)buf->data;
|
||||
u16_t max_tx_octets = sys_le16_to_cpu(evt->max_tx_octets);
|
||||
u16_t max_rx_octets = sys_le16_to_cpu(evt->max_rx_octets);
|
||||
u16_t max_tx_time = sys_le16_to_cpu(evt->max_tx_time);
|
||||
u16_t max_rx_time = sys_le16_to_cpu(evt->max_rx_time);
|
||||
u16_t handle = sys_le16_to_cpu(evt->handle);
|
||||
struct bt_conn *conn;
|
||||
|
||||
conn = bt_conn_lookup_handle(handle);
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to lookup conn for handle %u", handle);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("max. tx: %u (%uus), max. rx: %u (%uus)", max_tx_octets,
|
||||
max_tx_time, max_rx_octets, max_rx_time);
|
||||
|
||||
if (!atomic_test_and_clear_bit(conn->flags, BT_CONN_AUTO_DATA_LEN)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
update_conn_param(conn);
|
||||
|
||||
done:
|
||||
bt_conn_unref(conn);
|
||||
}
|
||||
@@ -869,6 +953,17 @@ static void le_phy_update_complete(struct net_buf *buf)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (BT_FEAT_LE_DLE(bt_dev.le.features) &&
|
||||
BT_FEAT_LE_DLE(conn->le.features)) {
|
||||
int err;
|
||||
|
||||
err = hci_le_set_data_len(conn);
|
||||
if (!err) {
|
||||
atomic_set_bit(conn->flags, BT_CONN_AUTO_DATA_LEN);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
update_conn_param(conn);
|
||||
|
||||
done:
|
||||
@@ -2686,6 +2781,9 @@ static void hci_le_meta_event(struct net_buf *buf)
|
||||
case BT_HCI_EVT_LE_CONN_PARAM_REQ:
|
||||
le_conn_param_req(buf);
|
||||
break;
|
||||
case BT_HCI_EVT_LE_DATA_LEN_CHANGE:
|
||||
le_data_len_change(buf);
|
||||
break;
|
||||
case BT_HCI_EVT_LE_PHY_UPDATE_COMPLETE:
|
||||
le_phy_update_complete(buf);
|
||||
break;
|
||||
@@ -3149,6 +3247,9 @@ static int le_set_event_mask(void)
|
||||
if (BT_FEAT_LE_CONN_PARAM_REQ_PROC(bt_dev.le.features)) {
|
||||
mask |= BT_EVT_MASK_LE_CONN_PARAM_REQ;
|
||||
}
|
||||
if (BT_FEAT_LE_DLE(bt_dev.le.features)) {
|
||||
mask |= BT_EVT_MASK_LE_DATA_LEN_CHANGE;
|
||||
}
|
||||
if (BT_FEAT_LE_PHY_2M(bt_dev.le.features) ||
|
||||
BT_FEAT_LE_PHY_CODED(bt_dev.le.features)) {
|
||||
mask |= BT_EVT_MASK_LE_PHY_UPDATE_COMPLETE;
|
||||
@@ -3237,6 +3338,41 @@ static int le_init(void)
|
||||
net_buf_unref(rsp);
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLUETOOTH_CONN) &&
|
||||
BT_FEAT_LE_DLE(bt_dev.le.features)) {
|
||||
struct bt_hci_cp_le_write_default_data_len *cp;
|
||||
struct bt_hci_rp_le_read_max_data_len *rp;
|
||||
struct net_buf *buf, *rsp;
|
||||
u16_t tx_octets, tx_time;
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_MAX_DATA_LEN, NULL,
|
||||
&rsp);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
rp = (void *)rsp->data;
|
||||
tx_octets = sys_le16_to_cpu(rp->max_tx_octets);
|
||||
tx_time = sys_le16_to_cpu(rp->max_tx_time);
|
||||
net_buf_unref(rsp);
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_WRITE_DEFAULT_DATA_LEN,
|
||||
sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
cp->max_tx_octets = sys_cpu_to_le16(tx_octets);
|
||||
cp->max_tx_time = sys_cpu_to_le16(tx_time);
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_WRITE_DEFAULT_DATA_LEN,
|
||||
buf, NULL);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
return le_set_event_mask();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ static void uart_isr(struct device *dev)
|
||||
uart_irq_update(dev);
|
||||
|
||||
if (uart_irq_rx_ready(dev)) {
|
||||
char c;
|
||||
u8_t c;
|
||||
|
||||
while (1) {
|
||||
if (uart_fifo_read(dev, &c, 1) == 0) {
|
||||
@@ -89,7 +89,7 @@ int console_putchar(char c)
|
||||
return -1;
|
||||
}
|
||||
|
||||
tx_ringbuf[tx_put] = c;
|
||||
tx_ringbuf[tx_put] = (u8_t)c;
|
||||
tx_put = tx_next;
|
||||
|
||||
irq_unlock(key);
|
||||
|
||||
@@ -64,7 +64,7 @@ config NET_IPV6_FRAGMENT_MAX_COUNT
|
||||
config NET_IPV6_FRAGMENT_TIMEOUT
|
||||
int "How long to wait the fragments to receive"
|
||||
range 1 60
|
||||
default 60
|
||||
default 5
|
||||
depends on NET_IPV6_FRAGMENT
|
||||
help
|
||||
How long to wait for IPv6 fragment to arrive before the reassembly
|
||||
|
||||
@@ -499,67 +499,93 @@ struct in6_addr *net_ipv6_nbr_lookup_by_index(struct net_if *iface,
|
||||
}
|
||||
#endif /* CONFIG_NET_IPV6_NBR_CACHE */
|
||||
|
||||
int net_ipv6_find_last_ext_hdr(struct net_pkt *pkt)
|
||||
int net_ipv6_find_last_ext_hdr(struct net_pkt *pkt, u16_t *next_hdr_idx,
|
||||
u16_t *last_hdr_idx)
|
||||
{
|
||||
struct net_ipv6_hdr *hdr = NET_IPV6_HDR(pkt);
|
||||
struct net_buf *frag = pkt->frags;
|
||||
int pos = 6; /* Initial value if no extension fragments were found */
|
||||
u16_t offset;
|
||||
int pos = 0;
|
||||
u16_t offset, prev, tmp;
|
||||
u8_t next_hdr;
|
||||
u8_t length;
|
||||
u8_t next;
|
||||
|
||||
offset = sizeof(struct net_ipv6_hdr);
|
||||
next = hdr->nexthdr;
|
||||
|
||||
/* Initial value if no extension fragments are found */
|
||||
*next_hdr_idx = 6;
|
||||
|
||||
offset = *last_hdr_idx = sizeof(struct net_ipv6_hdr);
|
||||
|
||||
/* First check the simplest case where there is no extension headers
|
||||
* in the packet. There cannot be any extensions after the normal or
|
||||
* typical IP protocols
|
||||
*/
|
||||
if (next == IPPROTO_ICMPV6 || next == IPPROTO_UDP ||
|
||||
next == IPPROTO_TCP) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
prev = pos;
|
||||
|
||||
while (frag) {
|
||||
frag = net_frag_read_u8(frag, offset, &offset, &next_hdr);
|
||||
if (frag != pkt->frags) {
|
||||
break;
|
||||
if (!frag && offset == 0xffff) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
frag = net_frag_read_u8(frag, offset, &offset, &length);
|
||||
if (!frag && offset == 0xffff) {
|
||||
pos = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
length = length * 8 + 8;
|
||||
|
||||
/* TODO: Add here more IPv6 extension headers to check */
|
||||
switch (next) {
|
||||
case NET_IPV6_NEXTHDR_NONE:
|
||||
pos = offset;
|
||||
*next_hdr_idx = prev;
|
||||
*last_hdr_idx = offset - 2;
|
||||
goto out;
|
||||
|
||||
case NET_IPV6_NEXTHDR_HBHO:
|
||||
pos = offset;
|
||||
offset += length;
|
||||
break;
|
||||
|
||||
case NET_IPV6_NEXTHDR_FRAG:
|
||||
pos = offset;
|
||||
offset += sizeof(struct net_ipv6_frag_hdr);
|
||||
goto out;
|
||||
prev = pos;
|
||||
pos = offset - 2;
|
||||
offset += 2 + 4;
|
||||
break;
|
||||
|
||||
case NET_IPV6_NEXTHDR_HBHO:
|
||||
prev = pos;
|
||||
pos = offset - 2;
|
||||
offset += length - 2;
|
||||
break;
|
||||
|
||||
case IPPROTO_ICMPV6:
|
||||
case IPPROTO_UDP:
|
||||
case IPPROTO_TCP:
|
||||
pos = offset;
|
||||
prev = pos;
|
||||
pos = *next_hdr_idx = offset - 2;
|
||||
goto out;
|
||||
|
||||
default:
|
||||
pos = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Get the next header value */
|
||||
frag = net_frag_read_u8(frag, pos, &tmp, &next);
|
||||
if (!frag && pos == 0xffff) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
if (!frag || pos > frag->len) {
|
||||
pos = -EINVAL;
|
||||
}
|
||||
*next_hdr_idx = prev;
|
||||
*last_hdr_idx = offset - 2;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
return pos;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
const struct in6_addr *net_ipv6_unspecified_address(void)
|
||||
@@ -812,6 +838,7 @@ struct net_pkt *net_ipv6_prepare_for_send(struct net_pkt *pkt)
|
||||
ret = net_ipv6_send_fragmented_pkt(net_pkt_iface(pkt),
|
||||
pkt, pkt_len);
|
||||
if (ret < 0) {
|
||||
NET_DBG("Cannot fragment IPv6 pkt (%d)", ret);
|
||||
net_pkt_unref(pkt);
|
||||
}
|
||||
|
||||
@@ -1197,7 +1224,7 @@ static enum net_verdict handle_ns_input(struct net_pkt *pkt)
|
||||
net_pkt_ipv6_ext_opt_len(pkt) +
|
||||
(hdr->len << 3));
|
||||
|
||||
if (prev_opt_len == net_pkt_ipv6_ext_opt_len(pkt)) {
|
||||
if (prev_opt_len >= net_pkt_ipv6_ext_opt_len(pkt)) {
|
||||
NET_ERR("Corrupted NS message");
|
||||
goto drop;
|
||||
}
|
||||
@@ -2671,21 +2698,16 @@ static struct net_icmpv6_handler ra_input_handler = {
|
||||
#if defined(CONFIG_NET_IPV6_FRAGMENT_TIMEOUT)
|
||||
#define IPV6_REASSEMBLY_TIMEOUT K_SECONDS(CONFIG_NET_IPV6_FRAGMENT_TIMEOUT)
|
||||
#else
|
||||
#define IPV6_REASSEMBLY_TIMEOUT K_SECONDS(60)
|
||||
#define IPV6_REASSEMBLY_TIMEOUT K_SECONDS(5)
|
||||
#endif /* CONFIG_NET_IPV6_FRAGMENT_TIMEOUT */
|
||||
|
||||
#define FRAG_BUF_WAIT 10 /* how long to max wait for a buffer */
|
||||
|
||||
static void reassembly_timeout(struct k_work *work);
|
||||
static bool reassembly_init_done;
|
||||
|
||||
static struct net_ipv6_reassembly
|
||||
reassembly[CONFIG_NET_IPV6_FRAGMENT_MAX_COUNT] = {
|
||||
[0 ... (CONFIG_NET_IPV6_FRAGMENT_MAX_COUNT - 1)] = {
|
||||
.timer = {
|
||||
.work = K_WORK_INITIALIZER(reassembly_timeout),
|
||||
},
|
||||
},
|
||||
};
|
||||
reassembly[CONFIG_NET_IPV6_FRAGMENT_MAX_COUNT];
|
||||
|
||||
static struct net_ipv6_reassembly *reassembly_get(u32_t id,
|
||||
struct in6_addr *src,
|
||||
@@ -2695,14 +2717,14 @@ static struct net_ipv6_reassembly *reassembly_get(u32_t id,
|
||||
|
||||
for (i = 0; i < CONFIG_NET_IPV6_FRAGMENT_MAX_COUNT; i++) {
|
||||
|
||||
if (k_work_pending(&reassembly[i].timer.work) &&
|
||||
if (k_delayed_work_remaining_get(&reassembly[i].timer) &&
|
||||
reassembly[i].id == id &&
|
||||
net_ipv6_addr_cmp(src, &reassembly[i].src) &&
|
||||
net_ipv6_addr_cmp(dst, &reassembly[i].dst)) {
|
||||
return &reassembly[i];
|
||||
}
|
||||
|
||||
if (k_work_pending(&reassembly[i].timer.work)) {
|
||||
if (k_delayed_work_remaining_get(&reassembly[i].timer)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2732,11 +2754,12 @@ static bool reassembly_cancel(u32_t id,
|
||||
{
|
||||
int i, j;
|
||||
|
||||
NET_DBG("Cancel 0x%x", id);
|
||||
|
||||
for (i = 0; i < CONFIG_NET_IPV6_FRAGMENT_MAX_COUNT; i++) {
|
||||
s32_t remaining;
|
||||
|
||||
if (!k_work_pending(&reassembly[i].timer.work) ||
|
||||
reassembly[i].id != id ||
|
||||
if (reassembly[i].id != id ||
|
||||
!net_ipv6_addr_cmp(src, &reassembly[i].src) ||
|
||||
!net_ipv6_addr_cmp(dst, &reassembly[i].dst)) {
|
||||
continue;
|
||||
@@ -2757,8 +2780,8 @@ static bool reassembly_cancel(u32_t id,
|
||||
continue;
|
||||
}
|
||||
|
||||
NET_DBG("IPv6 reassembly pkt %p %zd bytes data",
|
||||
reassembly[i].pkt[j],
|
||||
NET_DBG("[%d] IPv6 reassembly pkt %p %zd bytes data",
|
||||
j, reassembly[i].pkt[j],
|
||||
net_pkt_get_len(reassembly[i].pkt[j]));
|
||||
|
||||
net_pkt_unref(reassembly[i].pkt[j]);
|
||||
@@ -2802,7 +2825,7 @@ static void reassemble_packet(struct net_ipv6_reassembly *reass)
|
||||
struct net_pkt *pkt;
|
||||
struct net_buf *last;
|
||||
u8_t next_hdr;
|
||||
int i, len;
|
||||
int i, len, ret;
|
||||
u16_t pos;
|
||||
|
||||
k_delayed_work_cancel(&reass->timer);
|
||||
@@ -2845,6 +2868,7 @@ static void reassemble_packet(struct net_ipv6_reassembly *reass)
|
||||
}
|
||||
|
||||
pkt = reass->pkt[0];
|
||||
reass->pkt[0] = NULL;
|
||||
|
||||
/* Next we need to strip away the fragment header from the first packet
|
||||
* and set the various pointers and values in packet.
|
||||
@@ -2870,7 +2894,7 @@ static void reassemble_packet(struct net_ipv6_reassembly *reass)
|
||||
|
||||
if (!net_pkt_compact(pkt)) {
|
||||
NET_ERR("Cannot compact reassembly packet %p", pkt);
|
||||
reassembly_cancel(reass->id, &reass->src, &reass->dst);
|
||||
net_pkt_unref(pkt);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2895,16 +2919,9 @@ static void reassemble_packet(struct net_ipv6_reassembly *reass)
|
||||
* MUST NOT pass it to L2 so there will be a special check for that
|
||||
* in process_data() when handling the packet.
|
||||
*/
|
||||
net_recv_data(net_pkt_iface(pkt), pkt);
|
||||
|
||||
/* Make room for new packet that can be reassembled */
|
||||
k_delayed_work_cancel(&reass->timer);
|
||||
|
||||
/* We do not need to unref the net_pkt as that will be handled
|
||||
* by the receiving code in upper part of the IP stack.
|
||||
*/
|
||||
for (i = 0; i < NET_IPV6_FRAGMENTS_MAX_PKT; i++) {
|
||||
reass->pkt[i] = NULL;
|
||||
ret = net_recv_data(net_pkt_iface(pkt), pkt);
|
||||
if (ret < 0) {
|
||||
net_pkt_unref(pkt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2912,8 +2929,9 @@ void net_ipv6_frag_foreach(net_ipv6_frag_cb_t cb, void *user_data)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CONFIG_NET_IPV6_FRAGMENT_MAX_COUNT; i++) {
|
||||
if (!k_work_pending(&reassembly[i].timer.work)) {
|
||||
for (i = 0; reassembly_init_done &&
|
||||
i < CONFIG_NET_IPV6_FRAGMENT_MAX_COUNT; i++) {
|
||||
if (!k_delayed_work_remaining_get(&reassembly[i].timer)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2954,12 +2972,41 @@ static bool fragment_verify(struct net_ipv6_reassembly *reass)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int shift_packets(struct net_ipv6_reassembly *reass, int pos)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = pos + 1; i < NET_IPV6_FRAGMENTS_MAX_PKT; i++) {
|
||||
if (!reass->pkt[i]) {
|
||||
NET_DBG("Moving [%d] %p (offset 0x%x) to [%d]",
|
||||
pos, reass->pkt[pos],
|
||||
net_pkt_ipv6_fragment_offset(reass->pkt[pos]),
|
||||
i);
|
||||
|
||||
/* Do we have enough space in packet array to make
|
||||
* the move?
|
||||
*/
|
||||
if (((i - pos) + 1) >
|
||||
(NET_IPV6_FRAGMENTS_MAX_PKT - i)) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memmove(&reass->pkt[i], &reass->pkt[pos],
|
||||
sizeof(void *) * (i - pos));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static enum net_verdict handle_fragment_hdr(struct net_pkt *pkt,
|
||||
struct net_buf *frag,
|
||||
int total_len,
|
||||
u16_t buf_offset)
|
||||
{
|
||||
struct net_ipv6_reassembly *reass;
|
||||
struct net_ipv6_reassembly *reass = NULL;
|
||||
u32_t id;
|
||||
u16_t loc;
|
||||
u16_t offset;
|
||||
@@ -2969,6 +3016,18 @@ static enum net_verdict handle_fragment_hdr(struct net_pkt *pkt,
|
||||
bool found;
|
||||
int i;
|
||||
|
||||
if (!reassembly_init_done) {
|
||||
/* Static initializing does not work here because of the array
|
||||
* so we must do it at runtime.
|
||||
*/
|
||||
for (i = 0; i < CONFIG_NET_IPV6_FRAGMENT_MAX_COUNT; i++) {
|
||||
k_delayed_work_init(&reassembly[i].timer,
|
||||
reassembly_timeout);
|
||||
}
|
||||
|
||||
reassembly_init_done = true;
|
||||
}
|
||||
|
||||
net_pkt_set_ipv6_fragment_start(pkt, frag->data + buf_offset);
|
||||
|
||||
/* Each fragment has a fragment header. */
|
||||
@@ -2993,7 +3052,8 @@ static enum net_verdict handle_fragment_hdr(struct net_pkt *pkt,
|
||||
net_pkt_set_ipv6_fragment_offset(pkt, offset);
|
||||
|
||||
if (!reass->pkt[0]) {
|
||||
NET_DBG("Storing pkt %p to slot %d", pkt, 0);
|
||||
NET_DBG("Storing pkt %p to slot %d offset 0x%x", pkt, 0,
|
||||
offset);
|
||||
reass->pkt[0] = pkt;
|
||||
|
||||
reassembly_info("Reassembly 1st pkt", reass);
|
||||
@@ -3006,37 +3066,26 @@ static enum net_verdict handle_fragment_hdr(struct net_pkt *pkt,
|
||||
* in reassembly chain in correct order.
|
||||
*/
|
||||
for (i = 0, found = false; i < NET_IPV6_FRAGMENTS_MAX_PKT; i++) {
|
||||
bool move_done = false;
|
||||
int j;
|
||||
|
||||
if (!reass->pkt[i]) {
|
||||
NET_DBG("Storing pkt %p to slot %d", pkt, i);
|
||||
NET_DBG("Storing pkt %p to slot %d offset 0x%x", pkt,
|
||||
i, offset);
|
||||
reass->pkt[i] = pkt;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (net_pkt_ipv6_fragment_offset(reass->pkt[i]) <
|
||||
offset) {
|
||||
if (net_pkt_ipv6_fragment_offset(reass->pkt[i]) < offset) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = i + 1; j < NET_IPV6_FRAGMENTS_MAX_PKT; j++) {
|
||||
if (!reass->pkt[j]) {
|
||||
memmove(reass->pkt[j], reass->pkt[i],
|
||||
sizeof(void *));
|
||||
move_done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we do not have any free space in the pkt array,
|
||||
* then the fragment needs to be discarded.
|
||||
/* Make room for this fragment, if there is no room, then
|
||||
* discard the whole reassembly.
|
||||
*/
|
||||
if (!move_done) {
|
||||
if (shift_packets(reass, i)) {
|
||||
break;
|
||||
}
|
||||
|
||||
NET_DBG("Storing %p (offset 0x%x) to [%d]", pkt, offset, i);
|
||||
reass->pkt[i] = pkt;
|
||||
found = true;
|
||||
break;
|
||||
@@ -3046,7 +3095,7 @@ static enum net_verdict handle_fragment_hdr(struct net_pkt *pkt,
|
||||
/* We could not add this fragment into our saved fragment
|
||||
* list. We must discard the whole packet at this point.
|
||||
*/
|
||||
reassembly_cancel(reass->id, &reass->src, &reass->dst);
|
||||
NET_DBG("No slots available for 0x%x", reass->id);
|
||||
goto drop;
|
||||
}
|
||||
|
||||
@@ -3071,7 +3120,12 @@ static enum net_verdict handle_fragment_hdr(struct net_pkt *pkt,
|
||||
if (!fragment_verify(reass)) {
|
||||
NET_DBG("Reassembled IPv6 verify failed, dropping id %u",
|
||||
reass->id);
|
||||
reassembly_cancel(reass->id, &reass->src, &reass->dst);
|
||||
|
||||
/* Let the caller release the already inserted pkt */
|
||||
if (i < NET_IPV6_FRAGMENTS_MAX_PKT) {
|
||||
reass->pkt[i] = NULL;
|
||||
}
|
||||
|
||||
goto drop;
|
||||
}
|
||||
|
||||
@@ -3082,9 +3136,56 @@ accept:
|
||||
return NET_OK;
|
||||
|
||||
drop:
|
||||
if (reass) {
|
||||
reassembly_cancel(reass->id, &reass->src, &reass->dst);
|
||||
}
|
||||
|
||||
return NET_DROP;
|
||||
}
|
||||
|
||||
static int get_next_hdr(struct net_pkt *pkt, u16_t *next_hdr_idx,
|
||||
u16_t *last_hdr_idx, u8_t *next_hdr)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
u16_t pos;
|
||||
int ret;
|
||||
|
||||
/* We need to fix the next header value so find out where
|
||||
* is the last IPv6 extension header. The next_hdr_idx value is
|
||||
* offset from the start of the 1st fragment, it is not the
|
||||
* actual next header value.
|
||||
*/
|
||||
ret = net_ipv6_find_last_ext_hdr(pkt, next_hdr_idx, last_hdr_idx);
|
||||
if (ret < 0) {
|
||||
NET_DBG("Cannot find the last IPv6 ext header");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* The IPv6 must fit into first fragment, otherwise the next read
|
||||
* will fail.
|
||||
*/
|
||||
if (*next_hdr_idx > pkt->frags->len) {
|
||||
NET_DBG("IPv6 header too short (%d vs %d)", *next_hdr_idx,
|
||||
pkt->frags->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (*last_hdr_idx > pkt->frags->len) {
|
||||
NET_DBG("IPv6 header too short (%d vs %d)", *last_hdr_idx,
|
||||
pkt->frags->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf = net_frag_read_u8(pkt->frags, *next_hdr_idx, &pos, next_hdr);
|
||||
if (!buf && pos == 0xffff) {
|
||||
NET_DBG("Next header too far (%d vs %d)", *next_hdr_idx,
|
||||
pkt->frags->len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int send_ipv6_fragment(struct net_if *iface,
|
||||
struct net_pkt *pkt,
|
||||
struct net_buf *orig,
|
||||
@@ -3093,13 +3194,16 @@ static int send_ipv6_fragment(struct net_if *iface,
|
||||
u16_t ipv6_len,
|
||||
u16_t offset,
|
||||
int len,
|
||||
bool final)
|
||||
u8_t next_hdr,
|
||||
u16_t next_hdr_idx,
|
||||
u16_t last_hdr_idx,
|
||||
bool final,
|
||||
int frag_count)
|
||||
{
|
||||
struct net_pkt *ipv6;
|
||||
struct net_buf *rest = NULL, *end = NULL, *orig_copy = NULL;
|
||||
struct net_ipv6_frag_hdr hdr;
|
||||
u16_t pos, ext_len;
|
||||
u8_t prev_hdr;
|
||||
struct net_pkt *ipv6;
|
||||
u16_t pos;
|
||||
int ret;
|
||||
|
||||
/* Prepare the pkt so that the IPv6 packet will be sent properly
|
||||
@@ -3114,6 +3218,7 @@ static int send_ipv6_fragment(struct net_if *iface,
|
||||
}
|
||||
|
||||
if (!ipv6) {
|
||||
NET_DBG("Cannot get packet (%d)", -ENOMEM);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@@ -3129,6 +3234,7 @@ static int send_ipv6_fragment(struct net_if *iface,
|
||||
ret = net_pkt_split(pkt, frag, len, &end, &rest,
|
||||
FRAG_BUF_WAIT);
|
||||
if (ret < 0) {
|
||||
NET_DBG("Cannot split fragment (%d)", ret);
|
||||
goto free_pkts;
|
||||
}
|
||||
}
|
||||
@@ -3154,53 +3260,60 @@ static int send_ipv6_fragment(struct net_if *iface,
|
||||
}
|
||||
|
||||
end->frags = NULL;
|
||||
|
||||
memcpy(ipv6, pkt, sizeof(struct net_pkt));
|
||||
|
||||
/* We must not take the fragments from the original packet (yet) */
|
||||
ipv6->frags = NULL;
|
||||
|
||||
/* Update the extension length metadata so that upper layer checksum
|
||||
* will be calculated properly by net_ipv6_finalize_raw().
|
||||
*/
|
||||
ext_len = net_pkt_ipv6_ext_len(ipv6) + sizeof(struct net_ipv6_frag_hdr);
|
||||
net_pkt_set_ipv6_ext_len(ipv6, ext_len);
|
||||
net_pkt_set_ipv6_ext_len(ipv6,
|
||||
net_pkt_ipv6_ext_len(pkt) +
|
||||
sizeof(struct net_ipv6_frag_hdr));
|
||||
|
||||
orig_copy = net_buf_clone(orig, FRAG_BUF_WAIT);
|
||||
if (!orig_copy) {
|
||||
ret = -ENOMEM;
|
||||
NET_DBG("Cannot clone IPv6 header (%d)", ret);
|
||||
goto free_pkts;
|
||||
}
|
||||
|
||||
/* Then add the IPv6 header into the packet. */
|
||||
net_pkt_frag_insert(ipv6, orig_copy);
|
||||
|
||||
/* We need to fix the next header value so find out where
|
||||
* is the last IPv6 extension header. The returned value is offset
|
||||
* from the start of the 1st fragment, it is not the actual next
|
||||
* header value.
|
||||
*/
|
||||
prev_hdr = net_ipv6_find_last_ext_hdr(ipv6);
|
||||
if (prev_hdr < 0) {
|
||||
ret = -EINVAL;
|
||||
goto free_pkts;
|
||||
}
|
||||
|
||||
/* We need to update the next header of the packet. */
|
||||
net_frag_read_u8(ipv6->frags, prev_hdr, &pos, &hdr.nexthdr);
|
||||
|
||||
hdr.reserved = 0;
|
||||
hdr.id = net_pkt_ipv6_fragment_id(pkt);
|
||||
hdr.offset = htons((offset & 0xfff8) | final);
|
||||
/* Avoid double free if there is an error later in this function. */
|
||||
orig_copy = NULL;
|
||||
|
||||
/* And we need to update the last header in the IPv6 packet to point to
|
||||
* fragment header.
|
||||
*/
|
||||
net_pkt_write_u8(ipv6, ipv6->frags, prev_hdr, &pos,
|
||||
net_pkt_write_u8(ipv6, ipv6->frags, next_hdr_idx, &pos,
|
||||
NET_IPV6_NEXTHDR_FRAG);
|
||||
|
||||
/* Then just add the fragmentation header. */
|
||||
ret = net_pkt_append_all(ipv6, sizeof(hdr), (u8_t *)&hdr,
|
||||
FRAG_BUF_WAIT);
|
||||
NET_ASSERT(pos != next_hdr_idx);
|
||||
|
||||
hdr.reserved = 0;
|
||||
hdr.id = net_pkt_ipv6_fragment_id(pkt);
|
||||
hdr.offset = htons(((offset / 8) << 3) | !final);
|
||||
hdr.nexthdr = next_hdr;
|
||||
|
||||
/* Then add the fragmentation header. */
|
||||
ret = net_pkt_insert(ipv6, ipv6->frags, last_hdr_idx,
|
||||
sizeof(hdr), (u8_t *)&hdr, FRAG_BUF_WAIT);
|
||||
if (!ret) {
|
||||
ret = -ENOMEM;
|
||||
goto free_pkts;
|
||||
/* If we could not insert because we are already at the
|
||||
* end of fragment, then just append data to the end of
|
||||
* the IPv6 header.
|
||||
*/
|
||||
ret = net_pkt_append_all(ipv6, sizeof(hdr), (u8_t *)&hdr,
|
||||
FRAG_BUF_WAIT);
|
||||
if (!ret) {
|
||||
ret = -ENOMEM;
|
||||
NET_DBG("Cannot add IPv6 frag header (%d)", ret);
|
||||
goto free_pkts;
|
||||
}
|
||||
}
|
||||
|
||||
/* Tie all the fragments together to form an IPv6 packet. Then
|
||||
@@ -3208,7 +3321,10 @@ static int send_ipv6_fragment(struct net_if *iface,
|
||||
*/
|
||||
net_pkt_frag_add(ipv6, pkt->frags);
|
||||
|
||||
ret = net_ipv6_finalize_raw(ipv6, hdr.nexthdr);
|
||||
/* Note that we must not calculate possible UDP/TCP/ICMPv6 checksum
|
||||
* as that is already calculated in the non-fragmented packet.
|
||||
*/
|
||||
ret = net_ipv6_finalize_raw(ipv6, NET_IPV6_NEXTHDR_FRAG);
|
||||
if (ret < 0) {
|
||||
NET_DBG("Cannot create IPv6 packet (%d)", ret);
|
||||
goto free_pkts;
|
||||
@@ -3224,12 +3340,18 @@ static int send_ipv6_fragment(struct net_if *iface,
|
||||
*/
|
||||
ret = net_send_data(ipv6);
|
||||
if (ret < 0) {
|
||||
NET_DBG("Cannot send fragment (%d)", ret);
|
||||
goto free_pkts;
|
||||
}
|
||||
|
||||
/* Then process the rest of the fragments */
|
||||
pkt->frags = rest;
|
||||
|
||||
/* Let this packet to be sent and hopefully it will release
|
||||
* the memory that can be utilized for next sent IPv6 fragment.
|
||||
*/
|
||||
k_yield();
|
||||
|
||||
return 0;
|
||||
|
||||
free_pkts:
|
||||
@@ -3251,13 +3373,22 @@ int net_ipv6_send_fragmented_pkt(struct net_if *iface, struct net_pkt *pkt,
|
||||
{
|
||||
struct net_buf *frag = pkt->frags;
|
||||
struct net_buf *prev = NULL;
|
||||
struct net_buf *orig_ipv6, *rest;
|
||||
struct net_buf *orig_ipv6 = NULL;
|
||||
struct net_buf *rest;
|
||||
int frag_count = 0;
|
||||
int curr_len = 0;
|
||||
int status = false;
|
||||
u16_t ipv6_len = 0, offset = 0;
|
||||
u32_t id = sys_rand32_get();
|
||||
u8_t next_hdr;
|
||||
u16_t next_hdr_idx, last_hdr_idx;
|
||||
int ret;
|
||||
|
||||
ret = get_next_hdr(pkt, &next_hdr_idx, &last_hdr_idx, &next_hdr);
|
||||
if (ret < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Split the first fragment that contains the IPv6 header into
|
||||
* two pieces. The "orig_ipv6" will only contain the original IPv6
|
||||
* header which is copied into each fragment together with
|
||||
@@ -3267,7 +3398,8 @@ int net_ipv6_send_fragmented_pkt(struct net_if *iface, struct net_pkt *pkt,
|
||||
net_pkt_ip_hdr_len(pkt) + net_pkt_ipv6_ext_len(pkt),
|
||||
&orig_ipv6, &rest, FRAG_BUF_WAIT);
|
||||
if (ret < 0) {
|
||||
return -ENOMEM;
|
||||
NET_DBG("Cannot split packet (%d)", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ipv6_len = net_buf_frags_len(orig_ipv6);
|
||||
@@ -3301,16 +3433,20 @@ int net_ipv6_send_fragmented_pkt(struct net_if *iface, struct net_pkt *pkt,
|
||||
|
||||
status = send_ipv6_fragment(iface, pkt, orig_ipv6,
|
||||
prev, frag, ipv6_len,
|
||||
offset, fit_len, false);
|
||||
offset, fit_len,
|
||||
next_hdr, next_hdr_idx,
|
||||
last_hdr_idx, false,
|
||||
frag_count);
|
||||
if (status < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
offset += curr_len;
|
||||
offset += curr_len - (frag->len - fit_len);
|
||||
prev = NULL;
|
||||
|
||||
frag = pkt->frags;
|
||||
curr_len = 0;
|
||||
frag_count++;
|
||||
}
|
||||
|
||||
prev = frag;
|
||||
@@ -3318,12 +3454,16 @@ int net_ipv6_send_fragmented_pkt(struct net_if *iface, struct net_pkt *pkt,
|
||||
}
|
||||
|
||||
status = send_ipv6_fragment(iface, pkt, orig_ipv6, prev, prev,
|
||||
ipv6_len, offset, 0, true);
|
||||
ipv6_len, offset, 0, next_hdr,
|
||||
next_hdr_idx, last_hdr_idx, true,
|
||||
frag_count);
|
||||
|
||||
net_pkt_unref(pkt);
|
||||
|
||||
out:
|
||||
net_pkt_frag_unref(orig_ipv6);
|
||||
if (orig_ipv6) {
|
||||
net_pkt_frag_unref(orig_ipv6);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -374,7 +374,9 @@ static inline void net_ipv6_nbr_set_reachable_timer(struct net_if *iface,
|
||||
* This means that we should receive everything within first two fragments.
|
||||
* The first one being 1280 bytes and the second one 220 bytes.
|
||||
*/
|
||||
#if !defined(NET_IPV6_FRAGMENTS_MAX_PKT)
|
||||
#define NET_IPV6_FRAGMENTS_MAX_PKT 2
|
||||
#endif
|
||||
|
||||
/** Store pending IPv6 fragment information that is needed for reassembly. */
|
||||
struct net_ipv6_reassembly {
|
||||
@@ -421,11 +423,15 @@ void net_ipv6_frag_foreach(net_ipv6_frag_cb_t cb, void *user_data);
|
||||
* @brief Find the last IPv6 extension header in the network packet.
|
||||
*
|
||||
* @param pkt Network head packet.
|
||||
* @param next_hdr_idx Where is the index to next header field that points
|
||||
* to last header. This is returned to caller.
|
||||
* @param last_hdr_idx Where is the last header field in the packet.
|
||||
* This is returned to caller.
|
||||
*
|
||||
* @return Offset to the extension header within the first fragment of net_pkt.
|
||||
* Return <0 if the packet is malformed.
|
||||
* @return Return 0 if ok or <0 if the packet is malformed.
|
||||
*/
|
||||
int net_ipv6_find_last_ext_hdr(struct net_pkt *pkt);
|
||||
int net_ipv6_find_last_ext_hdr(struct net_pkt *pkt, u16_t *next_hdr_idx,
|
||||
u16_t *last_hdr_idx);
|
||||
|
||||
#if defined(CONFIG_NET_IPV6)
|
||||
void net_ipv6_init(void);
|
||||
|
||||
@@ -122,7 +122,10 @@ static inline u32_t parse_channel_set(char *str_set)
|
||||
}
|
||||
|
||||
chan = atoi(p);
|
||||
channel_set |= BIT(chan - 1);
|
||||
if (chan > 0 && chan < 32) {
|
||||
channel_set |= BIT(chan - 1);
|
||||
}
|
||||
|
||||
p = n ? n + 1 : n;
|
||||
} while (n);
|
||||
|
||||
|
||||
@@ -1615,6 +1615,7 @@ int net_pkt_split(struct net_pkt *pkt, struct net_buf *orig_frag,
|
||||
*fragB = net_pkt_get_frag(pkt, timeout);
|
||||
if (!*fragB) {
|
||||
net_pkt_frag_unref(*fragA);
|
||||
*fragA = NULL;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,9 @@ static inline char *net_sprint_ip_addr(const struct net_addr *addr)
|
||||
static inline void net_hexdump(const char *str, const u8_t *packet,
|
||||
size_t length)
|
||||
{
|
||||
int n = 0;
|
||||
char output[sizeof("xxxxyyyy xxxxyyyy")];
|
||||
int n = 0, k = 0;
|
||||
u8_t byte;
|
||||
|
||||
if (!length) {
|
||||
SYS_LOG_DBG("%s zero-length packet", str);
|
||||
@@ -125,12 +127,22 @@ static inline void net_hexdump(const char *str, const u8_t *packet,
|
||||
printk("%s %08X ", str, n);
|
||||
}
|
||||
|
||||
printk("%02X ", *packet++);
|
||||
byte = *packet++;
|
||||
|
||||
printk("%02X ", byte);
|
||||
|
||||
if (byte < 0x20 || byte > 0x7f) {
|
||||
output[k++] = '.';
|
||||
} else {
|
||||
output[k++] = byte;
|
||||
}
|
||||
|
||||
n++;
|
||||
if (n % 8 == 0) {
|
||||
if (n % 16 == 0) {
|
||||
printk("\n");
|
||||
output[k] = '\0';
|
||||
printk(" [%s]\n", output);
|
||||
k = 0;
|
||||
} else {
|
||||
printk(" ");
|
||||
}
|
||||
@@ -138,7 +150,18 @@ static inline void net_hexdump(const char *str, const u8_t *packet,
|
||||
}
|
||||
|
||||
if (n % 16) {
|
||||
printk("\n");
|
||||
int i;
|
||||
|
||||
output[k] = '\0';
|
||||
|
||||
for (i = 0; i < (16 - (n % 16)); i++) {
|
||||
printk(" ");
|
||||
}
|
||||
if ((n % 16) < 8) {
|
||||
printk(" "); /* one extra delimiter after 8 chars */
|
||||
}
|
||||
|
||||
printk(" [%s]\n", output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -576,17 +576,37 @@ static void ipv6_frag_cb(struct net_ipv6_reassembly *reass,
|
||||
{
|
||||
int *count = user_data;
|
||||
char src[ADDR_LEN];
|
||||
int i;
|
||||
|
||||
if (!*count) {
|
||||
printk("\nIPv6 reassembly Id Remain Src\t\t\t\tDst\n");
|
||||
printk("\nIPv6 reassembly Id Remain Src \tDst\n");
|
||||
}
|
||||
|
||||
snprintk(src, ADDR_LEN, "%s", net_sprint_ipv6_addr(&reass->src));
|
||||
|
||||
printk("%p 0x%08x %5d %s\t%s\n",
|
||||
printk("%p 0x%08x %5d %16s\t%16s\n",
|
||||
reass, reass->id, k_delayed_work_remaining_get(&reass->timer),
|
||||
src, net_sprint_ipv6_addr(&reass->dst));
|
||||
|
||||
for (i = 0; i < NET_IPV6_FRAGMENTS_MAX_PKT; i++) {
|
||||
if (reass->pkt[i]) {
|
||||
struct net_buf *frag = reass->pkt[i]->frags;
|
||||
|
||||
printk("[%d] pkt %p->", i, reass->pkt[i]);
|
||||
|
||||
while (frag) {
|
||||
printk("%p", frag);
|
||||
|
||||
frag = frag->frags;
|
||||
if (frag) {
|
||||
printk("->");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
(*count)++;
|
||||
}
|
||||
#endif /* CONFIG_NET_IPV6_FRAGMENT */
|
||||
@@ -1669,50 +1689,35 @@ int net_shell_cmd_tcp(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
int net_shell_cmd_help(int argc, char *argv[])
|
||||
{
|
||||
ARG_UNUSED(argc);
|
||||
ARG_UNUSED(argv);
|
||||
|
||||
/* Keep the commands in alphabetical order */
|
||||
printk("net allocs\n\tPrint network memory allocations\n");
|
||||
printk("net conn\n\tPrint information about network connections\n");
|
||||
printk("net dns\n\tShow how DNS is configured\n");
|
||||
printk("net dns cancel\n\tCancel all pending requests\n");
|
||||
printk("net dns <hostname> [A or AAAA]\n\tQuery IPv4 address (default)"
|
||||
" or IPv6 address for a host name\n");
|
||||
printk("net iface\n\tPrint information about network interfaces\n");
|
||||
printk("net mem\n\tPrint network memory information\n");
|
||||
printk("net nbr\n\tPrint neighbor information\n");
|
||||
printk("net nbr rm <IPv6 address>\n\tRemove neighbor from cache\n");
|
||||
printk("net ping <host>\n\tPing a network host\n");
|
||||
printk("net route\n\tShow network routes\n");
|
||||
printk("net stacks\n\tShow network stacks information\n");
|
||||
printk("net stats\n\tShow network statistics\n");
|
||||
printk("net tcp connect <ip> port\n\tConnect to TCP peer\n");
|
||||
printk("net tcp send <data>\n\tSend data to peer using TCP\n");
|
||||
printk("net tcp close\n\tClose TCP connection\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct shell_cmd net_commands[] = {
|
||||
/* Keep the commands in alphabetical order */
|
||||
{ "allocs", net_shell_cmd_allocs, NULL },
|
||||
{ "conn", net_shell_cmd_conn, NULL },
|
||||
{ "dns", net_shell_cmd_dns, NULL },
|
||||
{ "help", net_shell_cmd_help, NULL },
|
||||
{ "iface", net_shell_cmd_iface, NULL },
|
||||
{ "mem", net_shell_cmd_mem, NULL },
|
||||
{ "nbr", net_shell_cmd_nbr, NULL },
|
||||
{ "ping", net_shell_cmd_ping, NULL },
|
||||
{ "route", net_shell_cmd_route, NULL },
|
||||
{ "stacks", net_shell_cmd_stacks, NULL },
|
||||
{ "stats", net_shell_cmd_stats, NULL },
|
||||
{ "tcp", net_shell_cmd_tcp, NULL },
|
||||
{ "allocs", net_shell_cmd_allocs,
|
||||
"\n\tPrint network memory allocations" },
|
||||
{ "conn", net_shell_cmd_conn,
|
||||
"\n\tPrint information about network connections" },
|
||||
{ "dns", net_shell_cmd_dns, "\n\tShow how DNS is configure\n"
|
||||
"dns cancel\n\tCancel all pending requests\n"
|
||||
"dns <hostname> [A or AAAA]\n\tQuery IPv4 address (default) or "
|
||||
"IPv6 address for a host name" },
|
||||
{ "iface", net_shell_cmd_iface,
|
||||
"\n\tPrint information about network interfaces" },
|
||||
{ "mem", net_shell_cmd_mem,
|
||||
"\n\tPrint information about network interfaces" },
|
||||
{ "nbr", net_shell_cmd_nbr, "\n\tPrint neighbor information\n"
|
||||
"nbr rm <IPv6 address>\n\tRemove neighbor from cache" },
|
||||
{ "ping", net_shell_cmd_ping, "<host>\n\tPing a network host" },
|
||||
{ "route", net_shell_cmd_route, "\n\tShow network route" },
|
||||
{ "stacks", net_shell_cmd_stacks,
|
||||
"\n\tShow network stacks information" },
|
||||
{ "stats", net_shell_cmd_stats, "\n\tShow network statistics" },
|
||||
{ "tcp", net_shell_cmd_tcp, "connect <ip> port\n\tConnect to TCP peer\n"
|
||||
"tcp send <data>\n\tSend data to peer using TCP\n"
|
||||
"tcp close\n\tClose TCP connection" },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
void net_shell_init(void)
|
||||
{
|
||||
SHELL_REGISTER(NET_SHELL_MODULE, net_commands);
|
||||
}
|
||||
|
||||
SHELL_REGISTER(NET_SHELL_MODULE, net_commands);
|
||||
|
||||
@@ -30,6 +30,5 @@ int net_shell_cmd_route(int argc, char *argv[]);
|
||||
int net_shell_cmd_stacks(int argc, char *argv[]);
|
||||
int net_shell_cmd_stats(int argc, char *argv[]);
|
||||
int net_shell_cmd_tcp(int argc, char *argv[]);
|
||||
int net_shell_cmd_help(int argc, char *argv[]);
|
||||
|
||||
#endif /* __NET_SHELL_H */
|
||||
|
||||
@@ -107,17 +107,57 @@ static int http_add_chunk(struct net_pkt *pkt, s32_t timeout, const char *str)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void req_timer_cancel(struct http_server_ctx *ctx)
|
||||
{
|
||||
ctx->req.timer_cancelled = true;
|
||||
k_delayed_work_cancel(&ctx->req.timer);
|
||||
|
||||
NET_DBG("Context %p request timer cancelled", ctx);
|
||||
}
|
||||
|
||||
static void req_timeout(struct k_work *work)
|
||||
{
|
||||
struct http_server_ctx *ctx = CONTAINER_OF(work,
|
||||
struct http_server_ctx,
|
||||
req.timer);
|
||||
|
||||
if (ctx->req.timer_cancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
NET_DBG("Context %p request timeout", ctx);
|
||||
|
||||
net_context_unref(ctx->req.net_ctx);
|
||||
}
|
||||
|
||||
static void pkt_sent(struct net_context *context,
|
||||
int status,
|
||||
void *token,
|
||||
void *user_data)
|
||||
{
|
||||
/* We can just close the context after the packet is sent. */
|
||||
net_context_unref(context);
|
||||
s32_t timeout = POINTER_TO_INT(token);
|
||||
struct http_server_ctx *ctx = user_data;
|
||||
|
||||
req_timer_cancel(ctx);
|
||||
|
||||
if (timeout == K_NO_WAIT) {
|
||||
/* We can just close the context after the packet is sent. */
|
||||
net_context_unref(context);
|
||||
} else if (timeout > 0) {
|
||||
NET_DBG("Context %p starting timer", ctx);
|
||||
|
||||
k_delayed_work_submit(&ctx->req.timer, timeout);
|
||||
|
||||
ctx->req.timer_cancelled = false;
|
||||
}
|
||||
|
||||
/* Note that if the timeout is K_FOREVER, we do not close
|
||||
* the connection.
|
||||
*/
|
||||
}
|
||||
|
||||
int http_response(struct http_server_ctx *ctx, const char *http_header,
|
||||
const char *html_payload)
|
||||
int http_response_wait(struct http_server_ctx *ctx, const char *http_header,
|
||||
const char *html_payload, s32_t timeout)
|
||||
{
|
||||
struct net_pkt *pkt;
|
||||
int ret = -EINVAL;
|
||||
@@ -147,7 +187,7 @@ int http_response(struct http_server_ctx *ctx, const char *http_header,
|
||||
|
||||
net_pkt_set_appdatalen(pkt, net_buf_frags_len(pkt->frags));
|
||||
|
||||
ret = ctx->send_data(pkt, pkt_sent, 0, NULL, ctx);
|
||||
ret = ctx->send_data(pkt, pkt_sent, 0, INT_TO_POINTER(timeout), ctx);
|
||||
if (ret != 0) {
|
||||
goto exit_routine;
|
||||
}
|
||||
@@ -162,6 +202,12 @@ exit_routine:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int http_response(struct http_server_ctx *ctx, const char *http_header,
|
||||
const char *html_payload)
|
||||
{
|
||||
return http_response_wait(ctx, http_header, html_payload, K_NO_WAIT);
|
||||
}
|
||||
|
||||
int http_response_400(struct http_server_ctx *ctx, const char *html_payload)
|
||||
{
|
||||
return http_response(ctx, HTTP_STATUS_400_BR, html_payload);
|
||||
@@ -624,6 +670,7 @@ fail:
|
||||
}
|
||||
|
||||
quit:
|
||||
http_parser_init(&http_ctx->req.parser, HTTP_REQUEST);
|
||||
http_ctx->req.data_len = 0;
|
||||
net_pkt_unref(pkt);
|
||||
}
|
||||
@@ -818,6 +865,8 @@ bool http_server_disable(struct http_server_ctx *http_ctx)
|
||||
|
||||
NET_ASSERT(http_ctx);
|
||||
|
||||
req_timer_cancel(http_ctx);
|
||||
|
||||
old = http_ctx->enabled;
|
||||
|
||||
http_ctx->enabled = false;
|
||||
@@ -865,6 +914,8 @@ int http_server_init(struct http_server_ctx *http_ctx,
|
||||
http_ctx->recv_cb = http_recv;
|
||||
http_ctx->send_data = net_context_send;
|
||||
|
||||
k_delayed_work_init(&http_ctx->req.timer, req_timeout);
|
||||
|
||||
parser_init(http_ctx);
|
||||
|
||||
return 0;
|
||||
@@ -956,11 +1007,7 @@ static void ssl_received(struct net_context *context,
|
||||
ARG_UNUSED(context);
|
||||
ARG_UNUSED(status);
|
||||
|
||||
if (!pkt) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!net_pkt_appdatalen(pkt)) {
|
||||
if (pkt && !net_pkt_appdatalen(pkt)) {
|
||||
net_pkt_unref(pkt);
|
||||
return;
|
||||
}
|
||||
@@ -997,6 +1044,11 @@ static int ssl_rx(void *context, unsigned char *buf, size_t size)
|
||||
if (!ctx->https.mbedtls.ssl_ctx.frag) {
|
||||
rx_data = k_fifo_get(&ctx->https.mbedtls.ssl_ctx.rx_fifo,
|
||||
K_FOREVER);
|
||||
if (!rx_data->pkt) {
|
||||
NET_DBG("Closing %p connection", ctx);
|
||||
k_mem_pool_free(&rx_data->block);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
ctx->https.mbedtls.ssl_ctx.rx_pkt = rx_data->pkt;
|
||||
|
||||
@@ -1197,6 +1249,10 @@ static int https_send(struct net_pkt *pkt,
|
||||
} while (ret <= 0);
|
||||
|
||||
out:
|
||||
if (cb) {
|
||||
cb(net_pkt_context(pkt), ret, token, user_data);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1319,8 +1375,6 @@ reset:
|
||||
if (ret != MBEDTLS_ERR_SSL_WANT_READ &&
|
||||
ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
|
||||
if (ret < 0) {
|
||||
print_error("mbedtls_ssl_handshake returned "
|
||||
"-0x%x", ret);
|
||||
goto reset;
|
||||
}
|
||||
}
|
||||
@@ -1374,7 +1428,10 @@ reset:
|
||||
}
|
||||
|
||||
close:
|
||||
http_parser_init(&ctx->req.parser, HTTP_REQUEST);
|
||||
|
||||
mbedtls_ssl_close_notify(&ctx->https.mbedtls.ssl);
|
||||
|
||||
goto reset;
|
||||
|
||||
exit:
|
||||
@@ -1509,6 +1566,8 @@ int https_server_init(struct http_server_ctx *ctx,
|
||||
ctx->send_data = https_send;
|
||||
ctx->recv_cb = ssl_received;
|
||||
|
||||
k_delayed_work_init(&ctx->req.timer, req_timeout);
|
||||
|
||||
parser_init(ctx);
|
||||
|
||||
/* Then mbedtls specific initialization */
|
||||
|
||||
@@ -13,6 +13,14 @@ config ZOAP
|
||||
help
|
||||
This option enables the Zoap implementation of CoAP.
|
||||
|
||||
# This setting is only used by unit test. Do not enable it in applications
|
||||
config ZOAP_TEST_API_ENABLE
|
||||
bool "Enable test API for ZoAP unit tests"
|
||||
default n
|
||||
depends on ZOAP
|
||||
help
|
||||
Do not enable this for normal use.
|
||||
|
||||
config ZOAP_WELL_KNOWN_BLOCK_WISE
|
||||
bool
|
||||
prompt "CoAP ./well-known/core services block wise support"
|
||||
|
||||
@@ -28,7 +28,7 @@ static bool match_path_uri(const char * const *path,
|
||||
const char *uri, u16_t len)
|
||||
{
|
||||
const char * const *p = NULL;
|
||||
int i, j, plen;
|
||||
int i, j, k, plen;
|
||||
|
||||
if (!path) {
|
||||
return false;
|
||||
@@ -46,31 +46,43 @@ static bool match_path_uri(const char * const *path,
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Go through uri and try to find a matching path */
|
||||
for (i = 1; i < len; i++) {
|
||||
if (!*p) {
|
||||
return false;
|
||||
}
|
||||
while (*p) {
|
||||
plen = strlen(*p);
|
||||
|
||||
if (!p) {
|
||||
k = i;
|
||||
|
||||
for (j = 0; j < plen; j++) {
|
||||
if (uri[k] == '*') {
|
||||
if ((k + 1) == len) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (uri[k] != (*p)[j]) {
|
||||
goto next;
|
||||
}
|
||||
|
||||
k++;
|
||||
}
|
||||
|
||||
if (i == (k - 1) && j == plen) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (k == len && j == plen) {
|
||||
return true;
|
||||
}
|
||||
|
||||
next:
|
||||
p++;
|
||||
plen = *p ? strlen(*p) : 0;
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (j == plen && uri[i] == '/') {
|
||||
p = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (uri[i] == '*' && i + 1 == len) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (uri[i] != (*p)[j]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
j++;
|
||||
/* Did we find the resource or not */
|
||||
if (i == len && !*p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -260,7 +272,7 @@ static int format_uri(const char * const *path, struct net_buf *buf,
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (p = path; p && *p; ) {
|
||||
for (p = path; *p; ) {
|
||||
u16_t path_len = strlen(*p);
|
||||
|
||||
add_to_net_buf(buf, *p, path_len,
|
||||
@@ -301,7 +313,7 @@ static int format_attributes(const char * const *attributes,
|
||||
goto terminator;
|
||||
}
|
||||
|
||||
for (attr = attributes; attr && *attr; ) {
|
||||
for (attr = attributes; *attr; ) {
|
||||
int attr_len = strlen(*attr);
|
||||
|
||||
add_to_net_buf(buf, *attr, attr_len,
|
||||
@@ -527,7 +539,7 @@ static int format_uri(const char * const *path, struct net_buf *buf)
|
||||
str = net_buf_add(buf, sizeof(prefix) - 1);
|
||||
strncpy(str, prefix, sizeof(prefix) - 1);
|
||||
|
||||
for (p = path; p && *p; ) {
|
||||
for (p = path; *p; ) {
|
||||
u16_t path_len = strlen(*p);
|
||||
|
||||
str = net_buf_add(buf, path_len);
|
||||
@@ -556,7 +568,7 @@ static int format_attributes(const char * const *attributes,
|
||||
goto terminator;
|
||||
}
|
||||
|
||||
for (attr = attributes; attr && *attr; ) {
|
||||
for (attr = attributes; *attr; ) {
|
||||
int attr_len = strlen(*attr);
|
||||
|
||||
str = net_buf_add(buf, attr_len);
|
||||
@@ -703,3 +715,12 @@ done:
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Exposing some of the APIs to ZoAP unit tests in tests/net/lib/zoap */
|
||||
#if defined(CONFIG_ZOAP_TEST_API_ENABLE)
|
||||
bool _zoap_match_path_uri(const char * const *path,
|
||||
const char *uri, u16_t len)
|
||||
{
|
||||
return match_path_uri(path, uri, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
/*
|
||||
* Function prototypes.
|
||||
*/
|
||||
int mailbox_get(struct k_mbox *mailbox,
|
||||
void mailbox_get(struct k_mbox *mailbox,
|
||||
int size,
|
||||
int count,
|
||||
unsigned int *time);
|
||||
@@ -70,10 +70,14 @@ void mailrecvtask(void)
|
||||
* @param count Number of data portions.
|
||||
* @param time Resulting time.
|
||||
*/
|
||||
int mailbox_get(struct k_mbox *mailbox, int size, int count, unsigned int *time)
|
||||
void mailbox_get(struct k_mbox *mailbox,
|
||||
int size,
|
||||
int count,
|
||||
unsigned int *time)
|
||||
{
|
||||
int i;
|
||||
unsigned int t;
|
||||
s32_t return_value = 0;
|
||||
struct k_mbox_msg Message;
|
||||
|
||||
Message.rx_source_thread = K_ANY;
|
||||
@@ -83,7 +87,10 @@ int mailbox_get(struct k_mbox *mailbox, int size, int count, unsigned int *time)
|
||||
k_sem_take(&SEM0, K_FOREVER);
|
||||
t = BENCH_START();
|
||||
for (i = 0; i < count; i++) {
|
||||
k_mbox_get(mailbox, &Message, &data_recv, K_FOREVER);
|
||||
return_value |= k_mbox_get(mailbox,
|
||||
&Message,
|
||||
&data_recv,
|
||||
K_FOREVER);
|
||||
}
|
||||
|
||||
t = TIME_STAMP_DELTA_GET(t);
|
||||
@@ -91,7 +98,9 @@ int mailbox_get(struct k_mbox *mailbox, int size, int count, unsigned int *time)
|
||||
if (bench_test_end() < 0) {
|
||||
PRINT_OVERFLOW_ERROR();
|
||||
}
|
||||
return 0;
|
||||
if (return_value != 0) {
|
||||
k_panic();
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MAILBOX_BENCH */
|
||||
|
||||
@@ -20,17 +20,24 @@ void mempool_test(void)
|
||||
{
|
||||
u32_t et; /* elapsed time */
|
||||
int i;
|
||||
s32_t return_value = 0;
|
||||
struct k_mem_block block;
|
||||
|
||||
PRINT_STRING(dashline, output_file);
|
||||
et = BENCH_START();
|
||||
for (i = 0; i < NR_OF_POOL_RUNS; i++) {
|
||||
k_mem_pool_alloc(&DEMOPOOL, &block, 16, K_FOREVER);
|
||||
return_value |= k_mem_pool_alloc(&DEMOPOOL,
|
||||
&block,
|
||||
16,
|
||||
K_FOREVER);
|
||||
k_mem_pool_free(&block);
|
||||
}
|
||||
et = TIME_STAMP_DELTA_GET(et);
|
||||
check_result();
|
||||
|
||||
if (return_value != 0) {
|
||||
k_panic();
|
||||
}
|
||||
PRINT_F(output_file, FORMAT,
|
||||
"average alloc and dealloc memory pool block",
|
||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_POOL_RUNS)));
|
||||
|
||||
@@ -54,7 +54,12 @@ u64_t dummy_time;
|
||||
u64_t start_time;
|
||||
u64_t test_end_time;
|
||||
|
||||
#if CONFIG_X86
|
||||
/* Disable the overhead calculations, this is needed to calculate
|
||||
* the overhead created by the benchmarking code itself.
|
||||
*/
|
||||
#define DISABLE_OVERHEAD_MEASUREMENT
|
||||
|
||||
#if defined(CONFIG_X86) && !defined(DISABLE_OVERHEAD_MEASUREMENT)
|
||||
u32_t benchmarking_overhead_swap(void)
|
||||
{
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
static void tclock_uptime(void)
|
||||
{
|
||||
u64_t t64, t32;
|
||||
s64_t d64;
|
||||
s64_t d64 = 0;
|
||||
|
||||
/**TESTPOINT: uptime elapse*/
|
||||
t64 = k_uptime_get();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <ztest.h>
|
||||
|
||||
extern void test_mpool_alloc_free_thread(void);
|
||||
extern void test_mpool_alloc_free_isr(void);
|
||||
extern void test_mpool_kdefine_extern(void);
|
||||
extern void test_mpool_alloc_size(void);
|
||||
extern void test_mpool_alloc_timeout(void);
|
||||
@@ -17,6 +18,7 @@ void test_main(void *p1, void *p2, void *p3)
|
||||
{
|
||||
ztest_test_suite(test_mpool_api,
|
||||
ztest_unit_test(test_mpool_alloc_free_thread),
|
||||
ztest_unit_test(test_mpool_alloc_free_isr),
|
||||
ztest_unit_test(test_mpool_kdefine_extern),
|
||||
ztest_unit_test(test_mpool_alloc_size),
|
||||
ztest_unit_test(test_mpool_alloc_timeout),
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <ztest.h>
|
||||
#include <irq_offload.h>
|
||||
#include "test_mpool.h"
|
||||
|
||||
/** TESTPOINT: Statically define and initialize a memory pool*/
|
||||
@@ -75,6 +76,11 @@ void test_mpool_alloc_free_thread(void)
|
||||
tmpool_alloc_free(NULL);
|
||||
}
|
||||
|
||||
void test_mpool_alloc_free_isr(void)
|
||||
{
|
||||
irq_offload(tmpool_alloc_free, NULL);
|
||||
}
|
||||
|
||||
void test_mpool_alloc_size(void)
|
||||
{
|
||||
struct k_mem_block block[BLK_NUM_MIN];
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
CONFIG_ZTEST=y
|
||||
CONFIG_IRQ_OFFLOAD=y
|
||||
CONFIG_TIMESLICING=y
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
include $(ZEPHYR_BASE)/tests/Makefile.test
|
||||
|
||||
obj-y = main.o test_sched_priority.o test_sched_timeslice_and_lock.o
|
||||
obj-y += test_sched_is_preempt_thread.o
|
||||
obj-y += test_sched_is_preempt_thread.o test_sched_timeslice_reset.o
|
||||
|
||||
@@ -28,7 +28,8 @@ void test_main(void *p1, void *p2, void *p3)
|
||||
ztest_unit_test(test_time_slicing_disable_preemptible),
|
||||
ztest_unit_test(test_lock_preemptible),
|
||||
ztest_unit_test(test_unlock_preemptible),
|
||||
ztest_unit_test(test_sched_is_preempt_thread)
|
||||
ztest_unit_test(test_sched_is_preempt_thread),
|
||||
ztest_unit_test(test_slice_reset)
|
||||
);
|
||||
ztest_run_test_suite(test_threads_scheduling);
|
||||
}
|
||||
|
||||
@@ -32,5 +32,6 @@ void test_time_slicing_disable_preemptible(void);
|
||||
void test_lock_preemptible(void);
|
||||
void test_unlock_preemptible(void);
|
||||
void test_sched_is_preempt_thread(void);
|
||||
void test_slice_reset(void);
|
||||
|
||||
#endif /* __TEST_SCHED_H__ */
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <ztest.h>
|
||||
|
||||
#define STACK_SIZE 512
|
||||
#define NUM_THREAD 3
|
||||
static char __noinit __stack tstack[NUM_THREAD][STACK_SIZE];
|
||||
/* slice size in millisecond*/
|
||||
#define SLICE_SIZE 200
|
||||
/* busy for more than one slice*/
|
||||
#define BUSY_MS (SLICE_SIZE+20)
|
||||
/* a half timeslice*/
|
||||
#define HALF_SLICE_SIZE (SLICE_SIZE >> 1)
|
||||
|
||||
K_SEM_DEFINE(sema, 0, NUM_THREAD);
|
||||
/*elapsed_slice taken by last thread*/
|
||||
static s64_t elapsed_slice;
|
||||
/*expected elapsed duration*/
|
||||
static s64_t expected_slice[NUM_THREAD] = {
|
||||
HALF_SLICE_SIZE,/* the ztest native thread taking a half timeslice*/
|
||||
SLICE_SIZE, /* the spawned thread taking a full timeslice, reset*/
|
||||
SLICE_SIZE /* the spawned thread taking a full timeslice, reset*/
|
||||
};
|
||||
static int thread_idx;
|
||||
|
||||
static void thread_tslice(void *p1, void *p2, void *p3)
|
||||
{
|
||||
s64_t t = k_uptime_delta(&elapsed_slice);
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
TC_PRINT("thread[%d] elapsed slice %lld, ", thread_idx, t);
|
||||
TC_PRINT("expected %lld\n", expected_slice[thread_idx]);
|
||||
#endif
|
||||
/** TESTPOINT: timeslice should be reset for each preemptive thread*/
|
||||
zassert_true(t <= expected_slice[thread_idx], NULL);
|
||||
thread_idx = (thread_idx + 1) % NUM_THREAD;
|
||||
|
||||
u32_t t32 = k_uptime_get_32();
|
||||
|
||||
/* Keep the current thread busy for more than one slice, even though,
|
||||
* when timeslice used up the next thread should be scheduled in.
|
||||
*/
|
||||
while (k_uptime_get_32() - t32 < BUSY_MS)
|
||||
;
|
||||
k_sem_give(&sema);
|
||||
}
|
||||
|
||||
/*test cases*/
|
||||
|
||||
void test_slice_reset(void)
|
||||
{
|
||||
u32_t t32;
|
||||
k_tid_t tid[NUM_THREAD];
|
||||
struct k_thread t[NUM_THREAD];
|
||||
int old_prio = k_thread_priority_get(k_current_get());
|
||||
|
||||
thread_idx = 0;
|
||||
/*disable timeslice*/
|
||||
k_sched_time_slice_set(0, K_PRIO_PREEMPT(0));
|
||||
|
||||
for (int j = 0; j < 2; j++) {
|
||||
k_sem_reset(&sema);
|
||||
/* update priority for current thread*/
|
||||
k_thread_priority_set(k_current_get(), K_PRIO_PREEMPT(j));
|
||||
/* create delayed threads with equal preemptive priority*/
|
||||
for (int i = 0; i < NUM_THREAD; i++) {
|
||||
tid[i] = k_thread_create(&t[i], tstack[i], STACK_SIZE,
|
||||
thread_tslice, NULL, NULL, NULL,
|
||||
K_PRIO_PREEMPT(j), 0, 0);
|
||||
}
|
||||
/* enable time slice*/
|
||||
k_sched_time_slice_set(SLICE_SIZE, K_PRIO_PREEMPT(0));
|
||||
k_uptime_delta(&elapsed_slice);
|
||||
|
||||
/* current thread (ztest native) consumed a half timeslice*/
|
||||
t32 = k_uptime_get_32();
|
||||
while (k_uptime_get_32() - t32 < HALF_SLICE_SIZE)
|
||||
;
|
||||
|
||||
/* relinquish CPU and wait for each thread to complete*/
|
||||
for (int i = 0; i < NUM_THREAD; i++) {
|
||||
k_sem_take(&sema, K_FOREVER);
|
||||
}
|
||||
|
||||
/* test case teardown*/
|
||||
for (int i = 0; i < NUM_THREAD; i++) {
|
||||
k_thread_abort(tid[i]);
|
||||
}
|
||||
/* disable time slice*/
|
||||
k_sched_time_slice_set(0, K_PRIO_PREEMPT(0));
|
||||
}
|
||||
k_thread_priority_set(k_current_get(), old_prio);
|
||||
}
|
||||
@@ -22,6 +22,11 @@ struct test_struct {
|
||||
struct test_nested some_nested_struct;
|
||||
int some_array[16];
|
||||
size_t some_array_len;
|
||||
bool another_bxxl; /* JSON field: "another_b!@l" */
|
||||
bool if_; /* JSON: "if" */
|
||||
int another_array[10]; /* JSON: "another-array" */
|
||||
size_t another_array_len;
|
||||
struct test_nested xnother_nexx; /* JSON: "4nother_ne$+" */
|
||||
};
|
||||
|
||||
static const struct json_obj_descr nested_descr[] = {
|
||||
@@ -39,6 +44,15 @@ static const struct json_obj_descr test_descr[] = {
|
||||
nested_descr),
|
||||
JSON_OBJ_DESCR_ARRAY(struct test_struct, some_array,
|
||||
16, some_array_len, JSON_TOK_NUMBER),
|
||||
JSON_OBJ_DESCR_PRIM_NAMED(struct test_struct, "another_b!@l",
|
||||
another_bxxl, JSON_TOK_TRUE),
|
||||
JSON_OBJ_DESCR_PRIM_NAMED(struct test_struct, "if",
|
||||
if_, JSON_TOK_TRUE),
|
||||
JSON_OBJ_DESCR_ARRAY_NAMED(struct test_struct, "another-array",
|
||||
another_array, 10, another_array_len,
|
||||
JSON_TOK_NUMBER),
|
||||
JSON_OBJ_DESCR_OBJECT_NAMED(struct test_struct, "4nother_ne$+",
|
||||
xnother_nexx, nested_descr),
|
||||
};
|
||||
|
||||
static void test_json_encoding(void)
|
||||
@@ -57,14 +71,33 @@ static void test_json_encoding(void)
|
||||
.some_array[2] = 8,
|
||||
.some_array[3] = 16,
|
||||
.some_array[4] = 32,
|
||||
.some_array_len = 5
|
||||
.some_array_len = 5,
|
||||
.another_bxxl = true,
|
||||
.if_ = false,
|
||||
.another_array[0] = 2,
|
||||
.another_array[1] = 3,
|
||||
.another_array[2] = 5,
|
||||
.another_array[3] = 7,
|
||||
.another_array_len = 4,
|
||||
.xnother_nexx = {
|
||||
.nested_int = 1234,
|
||||
.nested_bool = true,
|
||||
.nested_string = "no escape necessary",
|
||||
},
|
||||
};
|
||||
char encoded[] = "{\"some_string\":\"zephyr 123\","
|
||||
"\"some_int\":42,\"some_bool\":true,"
|
||||
"\"some_nested_struct\":{\"nested_int\":-1234,"
|
||||
"\"nested_bool\":false,\"nested_string\":"
|
||||
"\"this should be escaped: \\t\"},"
|
||||
"\"some_array\":[1,4,8,16,32]}";
|
||||
"\"some_array\":[1,4,8,16,32],"
|
||||
"\"another_b!@l\":true,"
|
||||
"\"if\":false,"
|
||||
"\"another-array\":[2,3,5,7],"
|
||||
"\"4nother_ne$+\":{\"nested_int\":1234,"
|
||||
"\"nested_bool\":true,"
|
||||
"\"nested_string\":\"no escape necessary\"}"
|
||||
"}";
|
||||
char buffer[sizeof(encoded)];
|
||||
int ret;
|
||||
|
||||
@@ -89,8 +122,15 @@ static void test_json_decoding(void)
|
||||
"\"nested_bool\":false,\t"
|
||||
"\"nested_string\":\"this should be escaped: \\t\"},"
|
||||
"\"some_array\":[11,22, 33,\t45,\n299]"
|
||||
"\"another_b!@l\":true,"
|
||||
"\"if\":false,"
|
||||
"\"another-array\":[2,3,5,7],"
|
||||
"\"4nother_ne$+\":{\"nested_int\":1234,"
|
||||
"\"nested_bool\":true,"
|
||||
"\"nested_string\":\"no escape necessary\"}"
|
||||
"}";
|
||||
const int expected_array[] = { 11, 22, 33, 45, 299 };
|
||||
const int expected_other_array[] = { 2, 3, 5, 7 };
|
||||
int ret;
|
||||
|
||||
ret = json_obj_parse(encoded, sizeof(encoded) - 1, test_descr,
|
||||
@@ -113,7 +153,23 @@ static void test_json_decoding(void)
|
||||
zassert_equal(ts.some_array_len, 5, "Array has correct number of items");
|
||||
zassert_true(!memcmp(ts.some_array, expected_array,
|
||||
sizeof(expected_array)),
|
||||
"Array decoded with unexpected values");
|
||||
"Array decoded with expected values");
|
||||
zassert_true(ts.another_bxxl,
|
||||
"Named boolean (special chars) decoded correctly");
|
||||
zassert_false(ts.if_,
|
||||
"Named boolean (reserved word) decoded correctly");
|
||||
zassert_equal(ts.another_array_len, 4,
|
||||
"Named array has correct number of items");
|
||||
zassert_true(!memcmp(ts.another_array, expected_other_array,
|
||||
sizeof(expected_other_array)),
|
||||
"Decoded named array with expected values");
|
||||
zassert_equal(ts.xnother_nexx.nested_int, 1234,
|
||||
"Named nested integer decoded correctly");
|
||||
zassert_equal(ts.xnother_nexx.nested_bool, true,
|
||||
"Named nested boolean decoded correctly");
|
||||
zassert_true(!strcmp(ts.xnother_nexx.nested_string,
|
||||
"no escape necessary"),
|
||||
"Named nested string decoded correctly");
|
||||
}
|
||||
|
||||
static void test_json_invalid_unicode(void)
|
||||
|
||||
@@ -194,13 +194,15 @@ static struct net_pkt *prepare_ra_message(void)
|
||||
|
||||
static int tester_send(struct net_if *iface, struct net_pkt *pkt)
|
||||
{
|
||||
struct net_icmp_hdr *icmp = NET_ICMP_HDR(pkt);
|
||||
struct net_icmp_hdr *icmp;
|
||||
|
||||
if (!pkt->frags) {
|
||||
TC_ERROR("No data to send!\n");
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
icmp = NET_ICMP_HDR(pkt);
|
||||
|
||||
/* Reply with RA messge */
|
||||
if (icmp->type == NET_ICMPV6_RS) {
|
||||
net_pkt_unref(pkt);
|
||||
|
||||
4
tests/net/ipv6_fragment/Makefile
Normal file
4
tests/net/ipv6_fragment/Makefile
Normal file
@@ -0,0 +1,4 @@
|
||||
BOARD ?= qemu_x86
|
||||
CONF_FILE = prj.conf
|
||||
|
||||
include $(ZEPHYR_BASE)/Makefile.test
|
||||
36
tests/net/ipv6_fragment/prj.conf
Normal file
36
tests/net/ipv6_fragment/prj.conf
Normal file
@@ -0,0 +1,36 @@
|
||||
CONFIG_NETWORKING=y
|
||||
CONFIG_NET_IPV6=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_TCP=n
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_MAX_CONTEXTS=4
|
||||
CONFIG_NET_L2_DUMMY=y
|
||||
CONFIG_NET_LOG=y
|
||||
CONFIG_SYS_LOG_SHOW_COLOR=y
|
||||
CONFIG_RANDOM_GENERATOR=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
CONFIG_NET_IPV6_DAD=n
|
||||
CONFIG_NET_IPV6_MLD=n
|
||||
CONFIG_NET_PKT_TX_COUNT=50
|
||||
CONFIG_NET_PKT_RX_COUNT=50
|
||||
CONFIG_NET_BUF_RX_COUNT=50
|
||||
CONFIG_NET_BUF_TX_COUNT=50
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=6
|
||||
CONFIG_NET_IPV6_ND=n
|
||||
CONFIG_NET_IPV6_FRAGMENT=y
|
||||
#CONFIG_NET_UDP_CHECKSUM=n
|
||||
#CONFIG_NET_TCP_CHECKSUM=n
|
||||
|
||||
CONFIG_ZTEST=y
|
||||
|
||||
CONFIG_SYS_LOG_NET_LEVEL=4
|
||||
CONFIG_SYS_LOG_SHOW_COLOR=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_NET_STATISTICS=n
|
||||
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_CONN=n
|
||||
CONFIG_NET_DEBUG_IPV6=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=n
|
||||
CONFIG_NET_DEBUG_CORE=n
|
||||
4
tests/net/ipv6_fragment/src/Makefile
Normal file
4
tests/net/ipv6_fragment/src/Makefile
Normal file
@@ -0,0 +1,4 @@
|
||||
obj-y = main.o
|
||||
ccflags-y += -I${ZEPHYR_BASE}/subsys/net/ip
|
||||
|
||||
include $(ZEPHYR_BASE)/tests/Makefile.test
|
||||
703
tests/net/ipv6_fragment/src/main.c
Normal file
703
tests/net/ipv6_fragment/src/main.c
Normal file
@@ -0,0 +1,703 @@
|
||||
/* main.c - Application main entry point */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/types.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <misc/printk.h>
|
||||
#include <sections.h>
|
||||
|
||||
#include <ztest.h>
|
||||
|
||||
#include <net/ethernet.h>
|
||||
#include <net/buf.h>
|
||||
#include <net/net_ip.h>
|
||||
#include <net/net_if.h>
|
||||
|
||||
#define NET_LOG_ENABLED 1
|
||||
#include "net_private.h"
|
||||
|
||||
#include "ipv6.h"
|
||||
#include "udp.h"
|
||||
|
||||
#if defined(CONFIG_NET_DEBUG_IPV6)
|
||||
#define DBG(fmt, ...) printk(fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define DBG(fmt, ...)
|
||||
#endif
|
||||
|
||||
/* Interface 1 addresses */
|
||||
static struct in6_addr my_addr1 = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0x1 } } };
|
||||
|
||||
/* Interface 2 addresses */
|
||||
static struct in6_addr my_addr2 = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0x2 } } };
|
||||
|
||||
/* Extra address is assigned to ll_addr */
|
||||
static struct in6_addr ll_addr = { { { 0xfe, 0x80, 0x43, 0xb8, 0, 0, 0, 0,
|
||||
0, 0, 0, 0xf2, 0xaa, 0x29, 0x02,
|
||||
0x04 } } };
|
||||
|
||||
static u8_t mac2_addr[] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x02 };
|
||||
static struct net_linkaddr ll_addr2 = {
|
||||
.addr = mac2_addr,
|
||||
.len = 6,
|
||||
};
|
||||
|
||||
/* No extension header */
|
||||
static const unsigned char ipv6_udp[] = {
|
||||
/* IPv6 header starts here */
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x36, 0x11, 0x3f, /* `....6.? */
|
||||
0x20, 0x01, 0x0D, 0xB8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x20, 0x01, 0x0D, 0xB8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
|
||||
/* UDP header starts here (checksum is "fixed" in this example) */
|
||||
0xaa, 0xdc, 0xbf, 0xd7, 0x00, 0x2e, 0xa2, 0x55, /* ......M. */
|
||||
/* User data starts here and is appended in corresponding function */
|
||||
};
|
||||
|
||||
/* IPv6 hop-by-hop option in the message */
|
||||
static const unsigned char ipv6_hbho[] = {
|
||||
/* IPv6 header starts here */
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x3f, /* `....6.? */
|
||||
0x20, 0x01, 0x0D, 0xB8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x20, 0x01, 0x0D, 0xB8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
|
||||
/* Hop-by-hop option starts here */
|
||||
0x11, 0x00,
|
||||
/* RPL sub-option starts here */
|
||||
0x63, 0x04, 0x80, 0x1e, 0x01, 0x00, /* ..c..... */
|
||||
/* UDP header starts here (checksum is "fixed" in this example) */
|
||||
0xaa, 0xdc, 0xbf, 0xd7, 0x00, 0x2e, 0xa2, 0x55, /* ......M. */
|
||||
/* User data starts here and is appended in corresponding function */
|
||||
};
|
||||
|
||||
/* IPv6 hop-by-hop option in the message */
|
||||
static const unsigned char ipv6_hbho_frag[] = {
|
||||
/* IPv6 header starts here */
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x3f, /* `....6.? */
|
||||
0x20, 0x01, 0x0D, 0xB8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x20, 0x01, 0x0D, 0xB8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
|
||||
/* Hop-by-hop option starts here */
|
||||
0x2c, 0x00,
|
||||
/* RPL sub-option starts here */
|
||||
0x63, 0x04, 0x80, 0x1e, 0x01, 0x00, /* ..c..... */
|
||||
/* IPv6 fragment header */
|
||||
0x11, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04,
|
||||
/* UDP header starts here (checksum is "fixed" in this example) */
|
||||
0xaa, 0xdc, 0xbf, 0xd7, 0x00, 0x2e, 0xa2, 0x55, /* ......M. */
|
||||
/* User data starts here and is appended in corresponding function */
|
||||
};
|
||||
|
||||
static unsigned char ipv6_first_frag[] = {
|
||||
/* IPv6 header starts here */
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x3f, /* `....6.? */
|
||||
0x20, 0x01, 0x0D, 0xB8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x20, 0x01, 0x0D, 0xB8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
|
||||
/* Hop-by-hop option starts here */
|
||||
0x2C, 0x00,
|
||||
/* RPL sub-option starts here */
|
||||
0x63, 0x04, 0x80, 0x1e, 0x01, 0x00, /* ..c..... */
|
||||
/* IPv6 fragment header */
|
||||
0x11, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04,
|
||||
/* UDP header starts here (checksum is "fixed" in this example) */
|
||||
0xaa, 0xdc, 0xbf, 0xd7, 0x00, 0x2e, 0xa2, 0x55, /* ......M. */
|
||||
/* User data starts here and is appended in corresponding function */
|
||||
};
|
||||
|
||||
static unsigned char ipv6_second_frag[] = {
|
||||
/* IPv6 header starts here */
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x3f, /* `....6.? */
|
||||
0x20, 0x01, 0x0D, 0xB8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x20, 0x01, 0x0D, 0xB8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
|
||||
/* Hop-by-hop option starts here */
|
||||
0x2C, 0x00,
|
||||
/* RPL sub-option starts here */
|
||||
0x63, 0x04, 0x80, 0x1e, 0x01, 0x00, /* ..c..... */
|
||||
/* IPv6 fragment header */
|
||||
0x11, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04,
|
||||
};
|
||||
|
||||
static int frag_count;
|
||||
|
||||
static struct net_if *iface1;
|
||||
static struct net_if *iface2;
|
||||
|
||||
static bool test_failed;
|
||||
static bool test_started;
|
||||
static struct k_sem wait_data;
|
||||
|
||||
static u16_t pkt_data_len;
|
||||
static u16_t pkt_recv_data_len;
|
||||
|
||||
#define WAIT_TIME K_SECONDS(1)
|
||||
|
||||
#define ALLOC_TIMEOUT 500
|
||||
|
||||
struct net_if_test {
|
||||
u8_t idx;
|
||||
u8_t mac_addr[sizeof(struct net_eth_addr)];
|
||||
struct net_linkaddr ll_addr;
|
||||
};
|
||||
|
||||
static int net_iface_dev_init(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u8_t *net_iface_get_mac(struct device *dev)
|
||||
{
|
||||
struct net_if_test *data = dev->driver_data;
|
||||
|
||||
if (data->mac_addr[2] == 0x00) {
|
||||
/* 00-00-5E-00-53-xx Documentation RFC 7042 */
|
||||
data->mac_addr[0] = 0x00;
|
||||
data->mac_addr[1] = 0x00;
|
||||
data->mac_addr[2] = 0x5E;
|
||||
data->mac_addr[3] = 0x00;
|
||||
data->mac_addr[4] = 0x53;
|
||||
data->mac_addr[5] = sys_rand32_get();
|
||||
}
|
||||
|
||||
data->ll_addr.addr = data->mac_addr;
|
||||
data->ll_addr.len = 6;
|
||||
|
||||
return data->mac_addr;
|
||||
}
|
||||
|
||||
static void net_iface_init(struct net_if *iface)
|
||||
{
|
||||
u8_t *mac = net_iface_get_mac(net_if_get_device(iface));
|
||||
|
||||
net_if_set_link_addr(iface, mac, sizeof(struct net_eth_addr),
|
||||
NET_LINK_ETHERNET);
|
||||
}
|
||||
|
||||
static int verify_fragment(struct net_pkt *pkt)
|
||||
{
|
||||
/* The fragment needs to have
|
||||
* 1) IPv6 header
|
||||
* 2) HBH option (if any)
|
||||
* 3) IPv6 fragment header
|
||||
* 4) UDP/ICMPv6/TCP header
|
||||
* 5) data
|
||||
*/
|
||||
u16_t offset;
|
||||
|
||||
frag_count++;
|
||||
|
||||
if (frag_count == 1) {
|
||||
/* First fragment received. Make sure that all the
|
||||
* things are correct before the fragment header.
|
||||
*/
|
||||
size_t total_len = net_pkt_get_len(pkt);
|
||||
|
||||
total_len -= sizeof(struct net_ipv6_hdr);
|
||||
|
||||
ipv6_first_frag[4] = total_len / 256;
|
||||
ipv6_first_frag[5] = total_len -
|
||||
ipv6_first_frag[4] * 256;
|
||||
|
||||
if ((total_len / 256) != pkt->frags->data[4]) {
|
||||
DBG("Invalid length, 1st byte\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((total_len - pkt->frags->data[4] * 256) !=
|
||||
pkt->frags->data[5]) {
|
||||
DBG("Invalid length, 2nd byte\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
offset = pkt->frags->data[6 * 8 + 2] * 256 +
|
||||
(pkt->frags->data[6 * 8 + 3] & 0xfe);
|
||||
if (offset != 0) {
|
||||
DBG("Invalid offset\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((ipv6_first_frag[6 * 8 + 3] & 0x01) != 1) {
|
||||
DBG("Invalid MORE flag for first fragment\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pkt_recv_data_len += total_len - 8 /* HBHO */ - 8 /* UDP */ -
|
||||
sizeof(struct net_ipv6_frag_hdr);
|
||||
|
||||
/* Rewrite the fragment id so that the memcmp() will not fail */
|
||||
ipv6_first_frag[6 * 8 + 4] = pkt->frags->data[6 * 8 + 4];
|
||||
ipv6_first_frag[6 * 8 + 5] = pkt->frags->data[6 * 8 + 5];
|
||||
ipv6_first_frag[6 * 8 + 6] = pkt->frags->data[6 * 8 + 6];
|
||||
ipv6_first_frag[6 * 8 + 7] = pkt->frags->data[6 * 8 + 7];
|
||||
|
||||
if (memcmp(pkt->frags->data, ipv6_first_frag, 7 * 8) != 0) {
|
||||
net_hexdump("received", pkt->frags->data, 7 * 8);
|
||||
DBG("\n");
|
||||
net_hexdump("expected", ipv6_first_frag, 7 * 8);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (frag_count == 2) {
|
||||
/* Second fragment received. */
|
||||
size_t total_len = net_pkt_get_len(pkt);
|
||||
|
||||
total_len -= sizeof(struct net_ipv6_hdr);
|
||||
|
||||
ipv6_second_frag[4] = total_len / 256;
|
||||
ipv6_second_frag[5] = total_len -
|
||||
ipv6_second_frag[4] * 256;
|
||||
|
||||
if ((total_len / 256) != pkt->frags->data[4]) {
|
||||
DBG("Invalid length, 1st byte\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((total_len - pkt->frags->data[4] * 256) !=
|
||||
pkt->frags->data[5]) {
|
||||
DBG("Invalid length, 2nd byte\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
offset = pkt->frags->data[6 * 8 + 2] * 256 +
|
||||
(pkt->frags->data[6 * 8 + 3] & 0xfe);
|
||||
|
||||
if (offset != pkt_recv_data_len) {
|
||||
DBG("Invalid offset %d received %d\n",
|
||||
offset, pkt_recv_data_len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Make sure the MORE flag is set correctly */
|
||||
if ((pkt->frags->data[6 * 8 + 3] & 0x01) != 0) {
|
||||
DBG("Invalid MORE flag for second fragment\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pkt_recv_data_len += total_len - 8 /* HBHO */ - 8 /* UDP */ -
|
||||
sizeof(struct net_ipv6_frag_hdr);
|
||||
|
||||
ipv6_second_frag[6 * 8 + 2] = pkt->frags->data[6 * 8 + 2];
|
||||
ipv6_second_frag[6 * 8 + 3] = pkt->frags->data[6 * 8 + 3];
|
||||
|
||||
/* Rewrite the fragment id so that the memcmp() will not fail */
|
||||
ipv6_second_frag[6 * 8 + 4] = pkt->frags->data[6 * 8 + 4];
|
||||
ipv6_second_frag[6 * 8 + 5] = pkt->frags->data[6 * 8 + 5];
|
||||
ipv6_second_frag[6 * 8 + 6] = pkt->frags->data[6 * 8 + 6];
|
||||
ipv6_second_frag[6 * 8 + 7] = pkt->frags->data[6 * 8 + 7];
|
||||
|
||||
if (memcmp(pkt->frags->data, ipv6_second_frag, 7 * 8) != 0) {
|
||||
net_hexdump("received 2", pkt->frags->data, 7 * 8);
|
||||
DBG("\n");
|
||||
net_hexdump("expected 2", ipv6_second_frag, 7 * 8);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (pkt_data_len != pkt_recv_data_len) {
|
||||
DBG("Invalid amount of data received (%d vs %d)\n",
|
||||
pkt_data_len, pkt_recv_data_len);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sender_iface(struct net_if *iface, struct net_pkt *pkt)
|
||||
{
|
||||
if (!pkt->frags) {
|
||||
DBG("No data to send!\n");
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
if (test_started) {
|
||||
struct net_if_test *data = iface->dev->driver_data;
|
||||
|
||||
DBG("Sending at iface %d %p\n", net_if_get_by_iface(iface),
|
||||
iface);
|
||||
|
||||
if (net_pkt_iface(pkt) != iface) {
|
||||
DBG("Invalid interface %p, expecting %p\n",
|
||||
net_pkt_iface(pkt), iface);
|
||||
test_failed = true;
|
||||
}
|
||||
|
||||
if (net_if_get_by_iface(iface) != data->idx) {
|
||||
DBG("Invalid interface %d index, expecting %d\n",
|
||||
data->idx, net_if_get_by_iface(iface));
|
||||
test_failed = true;
|
||||
}
|
||||
|
||||
/* Verify the fragments */
|
||||
if (verify_fragment(pkt) < 0) {
|
||||
DBG("Fragments cannot be verified\n");
|
||||
test_failed = true;
|
||||
} else {
|
||||
k_sem_give(&wait_data);
|
||||
}
|
||||
}
|
||||
|
||||
zassert_false(test_failed, "Fragment verify failed");
|
||||
|
||||
net_pkt_unref(pkt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct net_if_test net_iface1_data;
|
||||
struct net_if_test net_iface2_data;
|
||||
|
||||
static struct net_if_api net_iface_api = {
|
||||
.init = net_iface_init,
|
||||
.send = sender_iface,
|
||||
};
|
||||
|
||||
#define _ETH_L2_LAYER DUMMY_L2
|
||||
#define _ETH_L2_CTX_TYPE NET_L2_GET_CTX_TYPE(DUMMY_L2)
|
||||
|
||||
NET_DEVICE_INIT_INSTANCE(net_iface1_test,
|
||||
"iface1",
|
||||
iface1,
|
||||
net_iface_dev_init,
|
||||
&net_iface1_data,
|
||||
NULL,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
||||
&net_iface_api,
|
||||
_ETH_L2_LAYER,
|
||||
_ETH_L2_CTX_TYPE,
|
||||
127);
|
||||
|
||||
NET_DEVICE_INIT_INSTANCE(net_iface2_test,
|
||||
"iface2",
|
||||
iface2,
|
||||
net_iface_dev_init,
|
||||
&net_iface2_data,
|
||||
NULL,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
||||
&net_iface_api,
|
||||
_ETH_L2_LAYER,
|
||||
_ETH_L2_CTX_TYPE,
|
||||
127);
|
||||
|
||||
static void add_nbr(struct net_if *iface,
|
||||
struct in6_addr *addr,
|
||||
struct net_linkaddr *lladdr)
|
||||
{
|
||||
struct net_nbr *nbr;
|
||||
|
||||
nbr = net_ipv6_nbr_add(iface, addr, lladdr, false,
|
||||
NET_IPV6_NBR_STATE_REACHABLE);
|
||||
zassert_not_null(nbr, "Cannot add neighbor");
|
||||
}
|
||||
|
||||
static enum net_verdict udp_data_received(struct net_conn *conn,
|
||||
struct net_pkt *pkt,
|
||||
void *user_data)
|
||||
{
|
||||
DBG("Data %p received\n", pkt);
|
||||
|
||||
net_pkt_unref(pkt);
|
||||
|
||||
return NET_OK;
|
||||
}
|
||||
|
||||
static void setup_udp_handler(const struct in6_addr *raddr,
|
||||
const struct in6_addr *laddr,
|
||||
u16_t remote_port,
|
||||
u16_t local_port)
|
||||
{
|
||||
static struct net_conn_handle *handle;
|
||||
struct sockaddr remote_addr = { 0 };
|
||||
struct sockaddr local_addr = { 0 };
|
||||
int ret;
|
||||
|
||||
net_ipaddr_copy(&net_sin6(&local_addr)->sin6_addr, laddr);
|
||||
local_addr.family = AF_INET6;
|
||||
|
||||
net_ipaddr_copy(&net_sin6(&remote_addr)->sin6_addr, raddr);
|
||||
remote_addr.family = AF_INET6;
|
||||
|
||||
ret = net_udp_register(&remote_addr, &local_addr, remote_port,
|
||||
local_port, udp_data_received,
|
||||
NULL, &handle);
|
||||
zassert_equal(ret, 0, "Cannot register UDP handler");
|
||||
}
|
||||
|
||||
static void setup(void)
|
||||
{
|
||||
struct net_if_addr *ifaddr;
|
||||
int idx;
|
||||
|
||||
/* The semaphore is there to wait the data to be received. */
|
||||
k_sem_init(&wait_data, 0, UINT_MAX);
|
||||
|
||||
iface1 = net_if_get_by_index(0);
|
||||
iface2 = net_if_get_by_index(1);
|
||||
|
||||
((struct net_if_test *)iface1->dev->driver_data)->idx = 0;
|
||||
((struct net_if_test *)iface2->dev->driver_data)->idx = 1;
|
||||
|
||||
idx = net_if_get_by_iface(iface1);
|
||||
zassert_equal(idx, 0, "Invalid index iface1");
|
||||
|
||||
idx = net_if_get_by_iface(iface2);
|
||||
zassert_equal(idx, 1, "Invalid index iface2");
|
||||
|
||||
zassert_not_null(iface1, "Interface 1");
|
||||
zassert_not_null(iface2, "Interface 2");
|
||||
|
||||
ifaddr = net_if_ipv6_addr_add(iface1, &my_addr1,
|
||||
NET_ADDR_MANUAL, 0);
|
||||
if (!ifaddr) {
|
||||
DBG("Cannot add IPv6 address %s\n",
|
||||
net_sprint_ipv6_addr(&my_addr1));
|
||||
zassert_not_null(ifaddr, "addr1");
|
||||
}
|
||||
|
||||
/* For testing purposes we need to set the adddresses preferred */
|
||||
ifaddr->addr_state = NET_ADDR_PREFERRED;
|
||||
|
||||
ifaddr = net_if_ipv6_addr_add(iface1, &ll_addr,
|
||||
NET_ADDR_MANUAL, 0);
|
||||
if (!ifaddr) {
|
||||
DBG("Cannot add IPv6 address %s\n",
|
||||
net_sprint_ipv6_addr(&ll_addr));
|
||||
zassert_not_null(ifaddr, "ll_addr");
|
||||
}
|
||||
|
||||
ifaddr->addr_state = NET_ADDR_PREFERRED;
|
||||
|
||||
net_if_up(iface1);
|
||||
net_if_up(iface2);
|
||||
|
||||
add_nbr(iface1, &my_addr2, &ll_addr2);
|
||||
|
||||
/* Remote and local are swapped so that we can receive the sent
|
||||
* packet.
|
||||
*/
|
||||
setup_udp_handler(&my_addr1, &my_addr2, 4352, 25348);
|
||||
|
||||
/* The interface might receive data which might fail the checks
|
||||
* in the iface sending function, so we need to reset the failure
|
||||
* flag.
|
||||
*/
|
||||
test_failed = false;
|
||||
|
||||
test_started = true;
|
||||
}
|
||||
|
||||
static void find_last_ipv6_fragment_udp(void)
|
||||
{
|
||||
u16_t next_hdr_idx = 0;
|
||||
u16_t last_hdr_pos = 0;
|
||||
struct net_pkt *pkt;
|
||||
int ret;
|
||||
|
||||
pkt = net_pkt_get_reserve_tx(0, ALLOC_TIMEOUT);
|
||||
zassert_not_null(pkt, "packet");
|
||||
|
||||
net_pkt_set_iface(pkt, iface1);
|
||||
net_pkt_set_family(pkt, AF_INET6);
|
||||
net_pkt_set_ip_hdr_len(pkt, sizeof(struct net_ipv6_hdr));
|
||||
net_pkt_set_ipv6_ext_len(pkt, sizeof(ipv6_udp) -
|
||||
sizeof(struct net_ipv6_hdr));
|
||||
net_pkt_ll_clear(pkt);
|
||||
|
||||
/* Add IPv6 header + UDP */
|
||||
ret = net_pkt_append_all(pkt, sizeof(ipv6_udp), ipv6_udp,
|
||||
ALLOC_TIMEOUT);
|
||||
zassert_true(ret, "IPv6 header append failed");
|
||||
|
||||
ret = net_ipv6_find_last_ext_hdr(pkt, &next_hdr_idx, &last_hdr_pos);
|
||||
zassert_equal(ret, 0, "Cannot find last header");
|
||||
|
||||
zassert_equal(next_hdr_idx, 6, "Next header index wrong");
|
||||
zassert_equal(last_hdr_pos, sizeof(struct net_ipv6_hdr),
|
||||
"Last header position wrong");
|
||||
|
||||
zassert_equal(NET_IPV6_HDR(pkt)->nexthdr, 0x11, "Invalid next header");
|
||||
zassert_equal(pkt->frags->data[next_hdr_idx], 0x11, "Invalid next "
|
||||
"header");
|
||||
|
||||
net_pkt_unref(pkt);
|
||||
}
|
||||
|
||||
static void find_last_ipv6_fragment_hbho_udp(void)
|
||||
{
|
||||
u16_t next_hdr_idx = 0;
|
||||
u16_t last_hdr_pos = 0;
|
||||
struct net_pkt *pkt;
|
||||
int ret;
|
||||
|
||||
pkt = net_pkt_get_reserve_tx(0, ALLOC_TIMEOUT);
|
||||
zassert_not_null(pkt, "packet");
|
||||
|
||||
net_pkt_set_iface(pkt, iface1);
|
||||
net_pkt_set_family(pkt, AF_INET6);
|
||||
net_pkt_set_ip_hdr_len(pkt, sizeof(struct net_ipv6_hdr));
|
||||
net_pkt_set_ipv6_ext_len(pkt, sizeof(ipv6_hbho) -
|
||||
sizeof(struct net_ipv6_hdr));
|
||||
net_pkt_ll_clear(pkt);
|
||||
|
||||
/* Add IPv6 header + HBH option */
|
||||
ret = net_pkt_append_all(pkt, sizeof(ipv6_hbho), ipv6_hbho,
|
||||
ALLOC_TIMEOUT);
|
||||
zassert_true(ret, "IPv6 header append failed");
|
||||
|
||||
ret = net_ipv6_find_last_ext_hdr(pkt, &next_hdr_idx, &last_hdr_pos);
|
||||
zassert_equal(ret, 0, "Cannot find last header");
|
||||
|
||||
zassert_equal(next_hdr_idx, sizeof(struct net_ipv6_hdr),
|
||||
"Next header index wrong");
|
||||
zassert_equal(last_hdr_pos, sizeof(struct net_ipv6_hdr) + 8,
|
||||
"Last header position wrong");
|
||||
|
||||
zassert_equal(NET_IPV6_HDR(pkt)->nexthdr, 0, "Invalid next header");
|
||||
zassert_equal(pkt->frags->data[next_hdr_idx], 0x11, "Invalid next "
|
||||
"header");
|
||||
|
||||
net_pkt_unref(pkt);
|
||||
}
|
||||
|
||||
static void find_last_ipv6_fragment_hbho_frag(void)
|
||||
{
|
||||
u16_t next_hdr_idx = 0;
|
||||
u16_t last_hdr_pos = 0;
|
||||
struct net_pkt *pkt;
|
||||
int ret;
|
||||
|
||||
pkt = net_pkt_get_reserve_tx(0, ALLOC_TIMEOUT);
|
||||
zassert_not_null(pkt, "packet");
|
||||
|
||||
net_pkt_set_iface(pkt, iface1);
|
||||
net_pkt_set_family(pkt, AF_INET6);
|
||||
net_pkt_set_ip_hdr_len(pkt, sizeof(struct net_ipv6_hdr));
|
||||
net_pkt_set_ipv6_ext_len(pkt, sizeof(ipv6_hbho_frag) -
|
||||
sizeof(struct net_ipv6_hdr));
|
||||
net_pkt_ll_clear(pkt);
|
||||
|
||||
/* Add IPv6 header + HBH option + fragment header */
|
||||
ret = net_pkt_append_all(pkt, sizeof(ipv6_hbho_frag), ipv6_hbho_frag,
|
||||
ALLOC_TIMEOUT);
|
||||
zassert_true(ret, "IPv6 header append failed");
|
||||
|
||||
ret = net_ipv6_find_last_ext_hdr(pkt, &next_hdr_idx, &last_hdr_pos);
|
||||
zassert_equal(ret, 0, "Cannot find last header");
|
||||
|
||||
zassert_equal(next_hdr_idx, sizeof(struct net_ipv6_hdr) + 8,
|
||||
"Next header index wrong");
|
||||
zassert_equal(last_hdr_pos, sizeof(struct net_ipv6_hdr) + 8 + 8,
|
||||
"Last header position wrong");
|
||||
|
||||
zassert_equal(NET_IPV6_HDR(pkt)->nexthdr, 0, "Invalid next header");
|
||||
zassert_equal(pkt->frags->data[next_hdr_idx], 0x11, "Invalid next "
|
||||
"header");
|
||||
|
||||
net_pkt_unref(pkt);
|
||||
}
|
||||
|
||||
static void send_ipv6_fragment(void)
|
||||
{
|
||||
#define MAX_LEN 1600
|
||||
static char data[] = "123456789.";
|
||||
int data_len = sizeof(data) - 1;
|
||||
int count = MAX_LEN / data_len;
|
||||
struct net_pkt *pkt;
|
||||
size_t total_len;
|
||||
int i, ret;
|
||||
|
||||
pkt_data_len = 0;
|
||||
|
||||
pkt = net_pkt_get_reserve_tx(0, ALLOC_TIMEOUT);
|
||||
zassert_not_null(pkt, "packet");
|
||||
|
||||
net_pkt_set_iface(pkt, iface1);
|
||||
net_pkt_set_family(pkt, AF_INET6);
|
||||
net_pkt_set_ip_hdr_len(pkt, sizeof(struct net_ipv6_hdr));
|
||||
net_pkt_set_ipv6_ext_len(pkt, 8 + 8); /* hbho + udp */
|
||||
net_pkt_ll_clear(pkt);
|
||||
|
||||
/* Add IPv6 header + HBH option */
|
||||
ret = net_pkt_append_all(pkt, sizeof(ipv6_hbho), ipv6_hbho,
|
||||
ALLOC_TIMEOUT);
|
||||
zassert_true(ret, "IPv6 header append failed");
|
||||
|
||||
/* Then add some data that is over 1280 bytes long */
|
||||
for (i = 0; i < count; i++) {
|
||||
bool written = net_pkt_append_all(pkt, data_len, data,
|
||||
ALLOC_TIMEOUT);
|
||||
zassert_true(written, "Cannot append data");
|
||||
|
||||
pkt_data_len += data_len;
|
||||
}
|
||||
|
||||
zassert_equal(pkt_data_len, count * data_len, "Data size mismatch");
|
||||
|
||||
total_len = net_pkt_get_len(pkt);
|
||||
total_len -= sizeof(struct net_ipv6_hdr);
|
||||
|
||||
DBG("Sending %zd bytes of which ext %d and data %d bytes\n",
|
||||
total_len, net_pkt_ipv6_ext_len(pkt), pkt_data_len);
|
||||
|
||||
zassert_equal(total_len - net_pkt_ipv6_ext_len(pkt), pkt_data_len,
|
||||
"Packet size invalid");
|
||||
|
||||
NET_IPV6_HDR(pkt)->len[0] = total_len / 256;
|
||||
NET_IPV6_HDR(pkt)->len[1] = total_len -
|
||||
NET_IPV6_HDR(pkt)->len[0] * 256;
|
||||
|
||||
NET_UDP_HDR(pkt)->chksum = 0;
|
||||
NET_UDP_HDR(pkt)->chksum = ~net_calc_chksum_udp(pkt);
|
||||
|
||||
test_failed = false;
|
||||
|
||||
ret = net_send_data(pkt);
|
||||
if (ret < 0) {
|
||||
DBG("Cannot send test packet (%d)\n", ret);
|
||||
zassert_equal(ret, 0, "Cannot send");
|
||||
}
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
DBG("Timeout while waiting interface data\n");
|
||||
zassert_equal(ret, 0, "Timeout");
|
||||
}
|
||||
}
|
||||
|
||||
static void recv_ipv6_fragment(void)
|
||||
{
|
||||
/* TODO: Verify that we can receive individual fragments and
|
||||
* then reassemble them back.
|
||||
*/
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(net_ipv6_fragment_test,
|
||||
ztest_unit_test(setup),
|
||||
ztest_unit_test(find_last_ipv6_fragment_udp),
|
||||
ztest_unit_test(find_last_ipv6_fragment_hbho_udp),
|
||||
ztest_unit_test(find_last_ipv6_fragment_hbho_frag),
|
||||
ztest_unit_test(send_ipv6_fragment),
|
||||
ztest_unit_test(recv_ipv6_fragment)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(net_ipv6_fragment_test);
|
||||
}
|
||||
4
tests/net/ipv6_fragment/testcase.ini
Normal file
4
tests/net/ipv6_fragment/testcase.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
[test]
|
||||
tags = net
|
||||
arch_whitelist = x86
|
||||
platform_whitelist = qemu_x86
|
||||
@@ -5,3 +5,4 @@ CONFIG_NETWORKING_WITH_IPV6=y
|
||||
CONFIG_RANDOM_GENERATOR=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
CONFIG_ZOAP=y
|
||||
CONFIG_ZOAP_TEST_API_ENABLE=y
|
||||
|
||||
@@ -39,6 +39,10 @@ static struct zoap_pending pendings[NUM_PENDINGS];
|
||||
static struct zoap_observer observers[NUM_OBSERVERS];
|
||||
static struct zoap_reply replies[NUM_REPLIES];
|
||||
|
||||
/* This is exposed for this test in subsys/net/lib/zoap/zoap_link_format.c */
|
||||
bool _zoap_match_path_uri(const char * const *path,
|
||||
const char *uri, u16_t len);
|
||||
|
||||
/* Some forward declarations */
|
||||
static void server_notify_callback(struct zoap_resource *resource,
|
||||
struct zoap_observer *observer);
|
||||
@@ -1060,6 +1064,71 @@ done:
|
||||
return result;
|
||||
}
|
||||
|
||||
static int test_match_path_uri(void)
|
||||
{
|
||||
int result = TC_FAIL;
|
||||
const char * const resource_path[] = {
|
||||
"s",
|
||||
"1",
|
||||
"foobar",
|
||||
"foobar3a",
|
||||
"foobar3",
|
||||
"devnull",
|
||||
NULL
|
||||
};
|
||||
const char *uri;
|
||||
|
||||
uri = "/k";
|
||||
if (_zoap_match_path_uri(resource_path, uri, strlen(uri))) {
|
||||
TC_PRINT("Matching %s failed\n", uri);
|
||||
goto out;
|
||||
}
|
||||
|
||||
uri = "/s";
|
||||
if (!_zoap_match_path_uri(resource_path, uri, strlen(uri))) {
|
||||
TC_PRINT("Matching %s failed\n", uri);
|
||||
goto out;
|
||||
}
|
||||
|
||||
uri = "/foobar";
|
||||
if (!_zoap_match_path_uri(resource_path, uri, strlen(uri))) {
|
||||
TC_PRINT("Matching %s failed\n", uri);
|
||||
goto out;
|
||||
}
|
||||
|
||||
uri = "/foobar2";
|
||||
if (_zoap_match_path_uri(resource_path, uri, strlen(uri))) {
|
||||
TC_PRINT("Matching %s failed\n", uri);
|
||||
goto out;
|
||||
}
|
||||
|
||||
uri = "/foobar*";
|
||||
if (!_zoap_match_path_uri(resource_path, uri, strlen(uri))) {
|
||||
TC_PRINT("Matching %s failed\n", uri);
|
||||
goto out;
|
||||
}
|
||||
|
||||
uri = "/foobar3*";
|
||||
if (!_zoap_match_path_uri(resource_path, uri, strlen(uri))) {
|
||||
TC_PRINT("Matching %s failed\n", uri);
|
||||
goto out;
|
||||
}
|
||||
|
||||
uri = "/devnull*";
|
||||
if (_zoap_match_path_uri(resource_path, uri, strlen(uri))) {
|
||||
TC_PRINT("Matching %s failed\n", uri);
|
||||
goto out;
|
||||
}
|
||||
|
||||
result = TC_PASS;
|
||||
|
||||
out:
|
||||
TC_END_RESULT(result);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
static const struct {
|
||||
const char *name;
|
||||
int (*func)(void);
|
||||
@@ -1073,6 +1142,7 @@ static const struct {
|
||||
{ "Test observer server", test_observer_server, },
|
||||
{ "Test observer client", test_observer_client, },
|
||||
{ "Test block sized transfer", test_block_size, },
|
||||
{ "Test match path uri", test_match_path_uri, },
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
Reference in New Issue
Block a user