Compare commits
145 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38de9b0156 | ||
|
|
3a21dff459 | ||
|
|
b98ec9e0db | ||
|
|
8f2d164674 | ||
|
|
6b61b219ea | ||
|
|
8822f85ef9 | ||
|
|
0bc81c82ab | ||
|
|
32c49d04b0 | ||
|
|
02c32316fc | ||
|
|
9bf571808d | ||
|
|
4eec9d95ef | ||
|
|
32a593396d | ||
|
|
066dcd6119 | ||
|
|
ffcc1d3c92 | ||
|
|
2d49a4c8b9 | ||
|
|
9d229e0bb5 | ||
|
|
74c00d0b4e | ||
|
|
2a09d5e53f | ||
|
|
ad4e9934de | ||
|
|
f133449cf5 | ||
|
|
33318bfb45 | ||
|
|
3497031e3e | ||
|
|
57a1be33ff | ||
|
|
652eb37b4d | ||
|
|
9e4edaec21 | ||
|
|
9b18f4a730 | ||
|
|
3f958347c2 | ||
|
|
041653662b | ||
|
|
6da71d7c2f | ||
|
|
52a68bec73 | ||
|
|
6324e997e1 | ||
|
|
e9eed0015f | ||
|
|
a3e7047ad5 | ||
|
|
50a24d6782 | ||
|
|
9c3be1212f | ||
|
|
e2c96814ce | ||
|
|
3c64ed4e77 | ||
|
|
e78a6ab2cd | ||
|
|
6bbf1e7e7a | ||
|
|
063dbecb23 | ||
|
|
a807fff085 | ||
|
|
b4b474cb4b | ||
|
|
175ae83c78 | ||
|
|
22ab715ad8 | ||
|
|
dff6cf2694 | ||
|
|
d4a1231cd4 | ||
|
|
88249c470e | ||
|
|
265cd286f2 | ||
|
|
4bc2808291 | ||
|
|
feb1630492 | ||
|
|
59a491efd6 | ||
|
|
51e7ee4711 | ||
|
|
5883e897ba | ||
|
|
20899f9f7e | ||
|
|
3e41a7810d | ||
|
|
de5fc723eb | ||
|
|
6fa562e805 | ||
|
|
df7a1f3cf6 | ||
|
|
798cca3d61 | ||
|
|
58b8290163 | ||
|
|
9c6ed8ff95 | ||
|
|
fcf027ef93 | ||
|
|
d8ad569d33 | ||
|
|
a04de78971 | ||
|
|
9b1dfd6568 | ||
|
|
c2898af367 | ||
|
|
5933705d0c | ||
|
|
f77cb92075 | ||
|
|
d340ff111f | ||
|
|
c9b24cf07d | ||
|
|
1c71036236 | ||
|
|
fe53adec8e | ||
|
|
9b3a68b7d5 | ||
|
|
8546159275 | ||
|
|
49f35f3a00 | ||
|
|
13571c4155 | ||
|
|
14d87fcb63 | ||
|
|
f7f21cbc5f | ||
|
|
98e79516bd | ||
|
|
ad2d8fea73 | ||
|
|
24b30abc65 | ||
|
|
c9f11ff697 | ||
|
|
d52b43826e | ||
|
|
7cdc791b51 | ||
|
|
6a8023a18c | ||
|
|
229f0e259f | ||
|
|
6f6a77a492 | ||
|
|
bdbab499b5 | ||
|
|
532806e063 | ||
|
|
aecbdb7285 | ||
|
|
8369a0a3eb | ||
|
|
73d79674d7 | ||
|
|
7654997990 | ||
|
|
cf58352c22 | ||
|
|
a618d6ff81 | ||
|
|
02275d8013 | ||
|
|
3d61857d2f | ||
|
|
0d70ee6017 | ||
|
|
43e116e496 | ||
|
|
d4d569b334 | ||
|
|
c4bb210f4a | ||
|
|
8f24184e1b | ||
|
|
728ed5e4a6 | ||
|
|
203ec2a124 | ||
|
|
e34b8d5b58 | ||
|
|
f7358ea85a | ||
|
|
1d61b94eb2 | ||
|
|
8bc6f2cf34 | ||
|
|
1a7fc79c75 | ||
|
|
b805164907 | ||
|
|
54dc715b8d | ||
|
|
96cfb7ac9f | ||
|
|
8a1d3a0a40 | ||
|
|
533d284bd3 | ||
|
|
5b690c698e | ||
|
|
139f200992 | ||
|
|
753b1d7f23 | ||
|
|
f51223b449 | ||
|
|
2cf6ae69fc | ||
|
|
13dfae7410 | ||
|
|
262497f3a8 | ||
|
|
4bde9471c9 | ||
|
|
17c54a0072 | ||
|
|
3ebd567041 | ||
|
|
822b82faf0 | ||
|
|
750b212ac8 | ||
|
|
1903793c89 | ||
|
|
8f539523b6 | ||
|
|
22fc985376 | ||
|
|
3cb83d1bbe | ||
|
|
e23cd666c3 | ||
|
|
1630dac971 | ||
|
|
f21e74cb07 | ||
|
|
dfb5ef29ef | ||
|
|
419583697e | ||
|
|
dddb9f14d5 | ||
|
|
d10cb9b25b | ||
|
|
f9dee5613a | ||
|
|
8af83eac4f | ||
|
|
956bb90b08 | ||
|
|
2f24663c38 | ||
|
|
af35240cdd | ||
|
|
e00e2b8754 | ||
|
|
9e2bb08928 | ||
|
|
357d9d3220 |
29
.github/workflows/bluetooth-tests-publish.yaml
vendored
Normal file
29
.github/workflows/bluetooth-tests-publish.yaml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: Publish Bluetooth Tests Results
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Bluetooth Tests"]
|
||||
types:
|
||||
- completed
|
||||
jobs:
|
||||
bluetooth-test-results:
|
||||
name: "Publish Bluetooth Test Results"
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.workflow_run.conclusion != 'skipped'
|
||||
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
with:
|
||||
workflow: bluetooth-tests.yaml
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
|
||||
- name: Publish Bluetooth Test Results
|
||||
uses: EnricoMi/publish-unit-test-result-action@v1
|
||||
with:
|
||||
check_name: Bluetooth Test Results
|
||||
comment_mode: off
|
||||
commit: ${{ github.event.workflow_run.head_sha }}
|
||||
event_file: event/event.json
|
||||
event_name: ${{ github.event.workflow_run.event }}
|
||||
files: "bluetooth-test-results/**/bsim_results.xml"
|
||||
@@ -1,7 +1,7 @@
|
||||
name: Bluetooth Tests
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
paths:
|
||||
- "west.yml"
|
||||
- "subsys/bluetooth/**"
|
||||
@@ -39,9 +39,6 @@ jobs:
|
||||
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: west setup
|
||||
run: |
|
||||
@@ -60,26 +57,15 @@ jobs:
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Bluetooth Test Results
|
||||
path: ./bsim_bt_out/bsim_results.xml
|
||||
name: bluetooth-test-results
|
||||
path: |
|
||||
./bsim_bt_out/bsim_results.xml
|
||||
${{ github.event_path }}
|
||||
|
||||
bluetooth-test-results:
|
||||
name: "Publish Bluetooth Test Results"
|
||||
needs: bluetooth-test-build
|
||||
runs-on: ubuntu-20.04
|
||||
# the build-and-test job might be skipped, we don't need to run this job then
|
||||
if: success() || failure()
|
||||
|
||||
steps:
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
- name: Upload Event Details
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Publish Bluetooth Test Results
|
||||
uses: EnricoMi/publish-unit-test-result-action@v1
|
||||
with:
|
||||
check_name: Bluetooth Test Results
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: "**/bsim_results.xml"
|
||||
comment_mode: off
|
||||
name: event
|
||||
path: |
|
||||
${{ github.event_path }}
|
||||
1
.github/workflows/clang.yaml
vendored
1
.github/workflows/clang.yaml
vendored
@@ -39,6 +39,7 @@ jobs:
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Environment Setup
|
||||
run: |
|
||||
|
||||
1
.github/workflows/manifest.yml
vendored
1
.github/workflows/manifest.yml
vendored
@@ -15,6 +15,7 @@ jobs:
|
||||
path: zephyrproject/zephyr
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Manifest
|
||||
uses: zephyrproject-rtos/action-manifest@2f1ad2908599d4fe747f886f9d733dd7eebae4ef
|
||||
|
||||
2
.github/workflows/twister.yaml
vendored
2
.github/workflows/twister.yaml
vendored
@@ -49,6 +49,7 @@ jobs:
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Environment Setup
|
||||
if: github.event_name == 'pull_request_target'
|
||||
@@ -137,6 +138,7 @@ jobs:
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Environment Setup
|
||||
run: |
|
||||
|
||||
@@ -1385,6 +1385,17 @@ if(CONFIG_OUTPUT_PRINT_MEMORY_USAGE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT CONFIG_EXCEPTIONS)
|
||||
set(eh_frame_section ".eh_frame")
|
||||
else()
|
||||
set(eh_frame_section "")
|
||||
endif()
|
||||
set(remove_sections_argument_list "")
|
||||
foreach(section .comment COMMON ${eh_frame_section})
|
||||
list(APPEND remove_sections_argument_list
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>${section})
|
||||
endforeach()
|
||||
|
||||
if(CONFIG_BUILD_OUTPUT_HEX OR BOARD_FLASH_RUNNER STREQUAL openocd)
|
||||
get_property(elfconvert_formats TARGET bintools PROPERTY elfconvert_formats)
|
||||
if(ihex IN_LIST elfconvert_formats)
|
||||
@@ -1394,9 +1405,7 @@ if(CONFIG_BUILD_OUTPUT_HEX OR BOARD_FLASH_RUNNER STREQUAL openocd)
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag>
|
||||
${GAP_FILL}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>ihex
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>.comment
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>COMMON
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>.eh_frame
|
||||
${remove_sections_argument_list}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${KERNEL_HEX_NAME}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_final>
|
||||
@@ -1418,9 +1427,7 @@ if(CONFIG_BUILD_OUTPUT_BIN)
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag>
|
||||
${GAP_FILL}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>binary
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>.comment
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>COMMON
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>.eh_frame
|
||||
${remove_sections_argument_list}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${KERNEL_BIN_NAME}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_final>
|
||||
|
||||
2
VERSION
2
VERSION
@@ -1,5 +1,5 @@
|
||||
VERSION_MAJOR = 2
|
||||
VERSION_MINOR = 7
|
||||
PATCHLEVEL = 1
|
||||
PATCHLEVEL = 2
|
||||
VERSION_TWEAK = 0
|
||||
EXTRAVERSION =
|
||||
|
||||
@@ -849,7 +849,7 @@ static inline z_arch_esf_t *get_esf(uint32_t msp, uint32_t psp, uint32_t exc_ret
|
||||
bool *nested_exc)
|
||||
{
|
||||
bool alternative_state_exc = false;
|
||||
z_arch_esf_t *ptr_esf;
|
||||
z_arch_esf_t *ptr_esf = NULL;
|
||||
|
||||
*nested_exc = false;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ static inline uint64_t z_arm_dwt_freq_get(void)
|
||||
/* SysTick and DWT both run at CPU frequency,
|
||||
* reflected in the system timer HW cycles/sec.
|
||||
*/
|
||||
return CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
|
||||
return sys_clock_hw_cycles_per_sec();
|
||||
#else
|
||||
static uint64_t dwt_frequency;
|
||||
uint32_t cyc_start, cyc_end;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern K_KERNEL_STACK_ARRAY_DEFINE(z_interrupt_stacks, CONFIG_MP_NUM_CPUS,
|
||||
K_KERNEL_STACK_ARRAY_EXTERN(z_interrupt_stacks, CONFIG_MP_NUM_CPUS,
|
||||
CONFIG_ISR_STACK_SIZE);
|
||||
|
||||
/**
|
||||
|
||||
@@ -101,9 +101,28 @@ spurious_continue:
|
||||
* x0: 1st thread in the ready queue
|
||||
* x1: _current thread
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/*
|
||||
* 2 possibilities here:
|
||||
* - x0 != NULL (implies x0 != x1): we need to context switch and set
|
||||
* the switch_handle in the context switch code
|
||||
* - x0 == NULL: no context switch
|
||||
*/
|
||||
cmp x0, #0x0
|
||||
bne switch
|
||||
|
||||
/*
|
||||
* No context switch. Restore x0 from x1 (they are the same thread).
|
||||
* See also comments to z_arch_get_next_switch_handle()
|
||||
*/
|
||||
mov x0, x1
|
||||
b exit
|
||||
switch:
|
||||
#else
|
||||
cmp x0, x1
|
||||
beq exit
|
||||
|
||||
#endif
|
||||
/* Switch thread */
|
||||
bl z_arm64_context_switch
|
||||
|
||||
|
||||
@@ -129,7 +129,11 @@ void z_arm64_el2_init(void)
|
||||
|
||||
zero_cntvoff_el2(); /* Set 64-bit virtual timer offset to 0 */
|
||||
zero_cnthctl_el2();
|
||||
#ifdef CONFIG_CPU_AARCH64_CORTEX_R
|
||||
zero_cnthps_ctl_el2();
|
||||
#else
|
||||
zero_cnthp_ctl_el2();
|
||||
#endif
|
||||
/*
|
||||
* Enable this if/when we use the hypervisor timer.
|
||||
* write_cnthp_cval_el2(~(uint64_t)0);
|
||||
|
||||
@@ -124,9 +124,28 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
|
||||
|
||||
void *z_arch_get_next_switch_handle(struct k_thread **old_thread)
|
||||
{
|
||||
/*
|
||||
* When returning from this function we will have the current thread
|
||||
* onto the stack to be popped in x1 and the next thread in x0 returned
|
||||
* from z_get_next_switch_handle() (see isr_wrapper.S)
|
||||
*/
|
||||
*old_thread = _current;
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/*
|
||||
* XXX: see thread in #41840 and #40795
|
||||
*
|
||||
* The scheduler API requires a complete switch handle here, but arm64
|
||||
* optimizes things such that the callee-save registers are still
|
||||
* unsaved here (they get written out in z_arm64_context_switch()
|
||||
* below). So pass a NULL instead, which the scheduler will store into
|
||||
* the thread switch_handle field. The resulting thread won't be
|
||||
* switched into until we write that ourselves.
|
||||
*/
|
||||
return z_get_next_switch_handle(NULL);
|
||||
#else
|
||||
return z_get_next_switch_handle(*old_thread);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
|
||||
@@ -6,6 +6,7 @@ zephyr_library()
|
||||
zephyr_library_sources(cpuhalt.c)
|
||||
zephyr_library_sources(prep_c.c)
|
||||
zephyr_library_sources(fatal.c)
|
||||
zephyr_library_sources(cpuid.c)
|
||||
zephyr_library_sources(spec_ctrl.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_X86_MEMMAP memmap.c)
|
||||
|
||||
51
arch/x86/core/cpuid.c
Normal file
51
arch/x86/core/cpuid.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <cpuid.h> /* Header provided by the toolchain. */
|
||||
|
||||
#include <kernel_structs.h>
|
||||
#include <arch/x86/cpuid.h>
|
||||
#include <kernel.h>
|
||||
|
||||
uint32_t z_x86_cpuid_extended_features(void)
|
||||
{
|
||||
uint32_t eax, ebx, ecx = 0U, edx;
|
||||
|
||||
if (__get_cpuid(CPUID_EXTENDED_FEATURES_LVL,
|
||||
&eax, &ebx, &ecx, &edx) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return edx;
|
||||
}
|
||||
|
||||
#define INITIAL_APIC_ID_SHIFT (24)
|
||||
#define INITIAL_APIC_ID_MASK (0xFF)
|
||||
|
||||
uint8_t z_x86_cpuid_get_current_physical_apic_id(void)
|
||||
{
|
||||
uint32_t eax, ebx, ecx, edx;
|
||||
|
||||
if (IS_ENABLED(CONFIG_X2APIC)) {
|
||||
/* leaf 0x1F should be used first prior to using 0x0B */
|
||||
if (__get_cpuid(CPUID_EXTENDED_TOPOLOGY_ENUMERATION_V2,
|
||||
&eax, &ebx, &ecx, &edx) == 0) {
|
||||
if (__get_cpuid(CPUID_EXTENDED_TOPOLOGY_ENUMERATION,
|
||||
&eax, &ebx, &ecx, &edx) == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (__get_cpuid(CPUID_BASIC_INFO_1,
|
||||
&eax, &ebx, &ecx, &edx) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
edx = (ebx >> INITIAL_APIC_ID_SHIFT);
|
||||
}
|
||||
|
||||
return (uint8_t)(edx & INITIAL_APIC_ID_MASK);
|
||||
}
|
||||
@@ -114,4 +114,18 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
|
||||
thread->arch.excNestCount = 0;
|
||||
#endif /* CONFIG_LAZY_FPU_SHARING */
|
||||
thread->arch.flags = 0;
|
||||
|
||||
/*
|
||||
* When "eager FPU sharing" mode is enabled, FPU registers must be
|
||||
* initialised at the time of thread creation because the floating-point
|
||||
* context is always active and no further FPU initialisation is performed
|
||||
* later.
|
||||
*/
|
||||
#if defined(CONFIG_EAGER_FPU_SHARING)
|
||||
thread->arch.preempFloatReg.floatRegsUnion.fpRegs.fcw = 0x037f;
|
||||
thread->arch.preempFloatReg.floatRegsUnion.fpRegs.ftw = 0xffff;
|
||||
#if defined(CONFIG_X86_SSE)
|
||||
thread->arch.preempFloatReg.floatRegsUnion.fpRegsEx.mxcsr = 0x1f80;
|
||||
#endif /* CONFIG_X86_SSE */
|
||||
#endif /* CONFIG_EAGER_FPU_SHARING */
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <kernel_arch_func.h>
|
||||
#include <device.h>
|
||||
#include <drivers/pcie/msi.h>
|
||||
#include <drivers/interrupt_controller/sysapic.h>
|
||||
#include <arch/x86/cpuid.h>
|
||||
#endif
|
||||
|
||||
/* PCI Express Extended Configuration Mechanism (MMIO) */
|
||||
@@ -179,12 +181,15 @@ static bool get_vtd(void)
|
||||
|
||||
/* these functions are explained in include/drivers/pcie/msi.h */
|
||||
|
||||
#define MSI_MAP_DESTINATION_ID_SHIFT 12
|
||||
#define MSI_RH BIT(3)
|
||||
|
||||
uint32_t pcie_msi_map(unsigned int irq,
|
||||
msi_vector_t *vector)
|
||||
{
|
||||
uint32_t map;
|
||||
|
||||
ARG_UNUSED(irq);
|
||||
|
||||
#if defined(CONFIG_INTEL_VTD_ICTL)
|
||||
#if !defined(CONFIG_PCIE_MSI_X)
|
||||
if (vector != NULL) {
|
||||
@@ -197,7 +202,15 @@ uint32_t pcie_msi_map(unsigned int irq,
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
map = 0xFEE00000U; /* standard delivery to BSP local APIC */
|
||||
uint32_t dest_id;
|
||||
|
||||
dest_id = z_x86_cpuid_get_current_physical_apic_id() <<
|
||||
MSI_MAP_DESTINATION_ID_SHIFT;
|
||||
|
||||
/* Directing to current physical CPU (may not be BSP)
|
||||
* Destination ID - RH 1 - DM 0
|
||||
*/
|
||||
map = 0xFEE00000U | dest_id | MSI_RH;
|
||||
}
|
||||
|
||||
return map;
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <cpuid.h> /* Header provided by the toolchain. */
|
||||
|
||||
#include <init.h>
|
||||
#include <kernel_structs.h>
|
||||
#include <kernel_arch_data.h>
|
||||
#include <kernel_arch_func.h>
|
||||
#include <arch/x86/msr.h>
|
||||
#include <arch/x86/cpuid.h>
|
||||
#include <kernel.h>
|
||||
|
||||
/*
|
||||
@@ -18,31 +17,13 @@
|
||||
* https://software.intel.com/security-software-guidance/api-app/sites/default/files/336996-Speculative-Execution-Side-Channel-Mitigations.pdf
|
||||
*/
|
||||
|
||||
#define CPUID_EXTENDED_FEATURES_LVL 7
|
||||
|
||||
/* Bits to check in CPUID extended features */
|
||||
#define CPUID_SPEC_CTRL_SSBD BIT(31)
|
||||
#define CPUID_SPEC_CTRL_IBRS BIT(26)
|
||||
|
||||
#if defined(CONFIG_DISABLE_SSBD) || defined(CONFIG_ENABLE_EXTENDED_IBRS)
|
||||
static uint32_t cpuid_extended_features(void)
|
||||
{
|
||||
uint32_t eax, ebx, ecx = 0U, edx;
|
||||
|
||||
if (__get_cpuid(CPUID_EXTENDED_FEATURES_LVL,
|
||||
&eax, &ebx, &ecx, &edx) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return edx;
|
||||
}
|
||||
|
||||
static int spec_ctrl_init(const struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
uint32_t enable_bits = 0U;
|
||||
uint32_t cpuid7 = cpuid_extended_features();
|
||||
uint32_t cpuid7 = z_x86_cpuid_extended_features();
|
||||
|
||||
#ifdef CONFIG_DISABLE_SSBD
|
||||
if ((cpuid7 & CPUID_SPEC_CTRL_SSBD) != 0U) {
|
||||
|
||||
@@ -12,6 +12,7 @@ endif()
|
||||
string(REPLACE "nsim" "mdb" MDB_ARGS "${BOARD}.args")
|
||||
if((CONFIG_SOC_NSIM_HS_SMP OR CONFIG_SOC_NSIM_HS6X_SMP))
|
||||
board_runner_args(mdb-nsim "--cores=${CONFIG_MP_NUM_CPUS}" "--nsim_args=${MDB_ARGS}")
|
||||
board_runner_args(mdb-hw "--cores=${CONFIG_MP_NUM_CPUS}")
|
||||
else()
|
||||
board_runner_args(mdb-nsim "--nsim_args=${MDB_ARGS}")
|
||||
endif()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# BL654 USB adapter board configuration
|
||||
|
||||
# Copyright (c) 2021 Laird Connectivity
|
||||
# Copyright (c) 2021-2022 Laird Connectivity
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if BOARD_BL654_USB
|
||||
@@ -13,16 +13,21 @@ config BOARD
|
||||
|
||||
# Nordic nRF5 bootloader exists outside of the partitions specified in the
|
||||
# DTS file, so we manually override FLASH_LOAD_OFFSET to link the application
|
||||
# correctly, after Nordic MBR.
|
||||
# correctly, after Nordic MBR, and limit the maximum size to not protude into
|
||||
# the bootloader at the end of flash.
|
||||
|
||||
# When building MCUBoot, MCUBoot itself will select USE_DT_CODE_PARTITION
|
||||
# which will make it link into the correct partition specified in DTS file,
|
||||
# so no override is necessary.
|
||||
# so no override or limit is necessary.
|
||||
|
||||
config FLASH_LOAD_OFFSET
|
||||
default 0x1000
|
||||
depends on !USE_DT_CODE_PARTITION
|
||||
|
||||
config FLASH_LOAD_SIZE
|
||||
default 0xdf000
|
||||
depends on !USE_DT_CODE_PARTITION
|
||||
|
||||
if USB_DEVICE_STACK
|
||||
|
||||
config USB_UART_CONSOLE
|
||||
|
||||
@@ -216,7 +216,7 @@ Run a serial host program to connect with your NUCLEO-H745ZI-Q board.
|
||||
|
||||
$ minicom -b 115200 -D /dev/ttyACM0
|
||||
|
||||
or use scrreen:
|
||||
or use screen:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
@@ -235,15 +235,20 @@ You should see the following message on the console:
|
||||
|
||||
$ Hello World! nucleo_h745zi_q_m7
|
||||
|
||||
Blinky example can also be used:
|
||||
.. note::
|
||||
Sometimes, flashing is not working. It is necessary to erase the flash
|
||||
(with STM32CubeProgrammer for example) to make it work again.
|
||||
|
||||
Similarly, you can build and flash samples on the M4 target. For this, please
|
||||
take care of the resource sharing (UART port used for console for instance).
|
||||
|
||||
Here is an example for the :ref:`blinky-sample` application on M4 core.
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/basic/blinky
|
||||
:board: nucleo_h745zi_q_m7
|
||||
:board: nucleo_h745zi_q_m4
|
||||
:goals: build flash
|
||||
|
||||
Same way M4 core can be flashed.
|
||||
|
||||
.. note::
|
||||
|
||||
Flashing both M4 and M7 and pushing RESTART button on the board leads
|
||||
@@ -261,6 +266,10 @@ You can debug an application in the usual way. Here is an example for the
|
||||
:maybe-skip-config:
|
||||
:goals: debug
|
||||
|
||||
Debugging with west is currently not available on Cortex M4 side.
|
||||
In order to debug a Zephyr application on Cortex M4 side, you can use
|
||||
`STM32CubeIDE`_.
|
||||
|
||||
.. _Nucleo H745ZI-Q website:
|
||||
https://www.st.com/en/evaluation-tools/nucleo-h745zi-q.html
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ CONFIG_SOC_STM32H745XX=y
|
||||
# Board config should be specified since there are 2 possible targets
|
||||
CONFIG_BOARD_NUCLEO_H745ZI_Q_M7=y
|
||||
|
||||
# Enable the internal SMPS regulator
|
||||
CONFIG_POWER_SUPPLY_DIRECT_SMPS=y
|
||||
|
||||
# Enable MPU
|
||||
CONFIG_ARM_MPU=y
|
||||
|
||||
|
||||
@@ -255,19 +255,17 @@ flashed in the usual way (see :ref:`build_an_application` and
|
||||
Flashing
|
||||
========
|
||||
|
||||
Nucleo L552ZE Q board includes an ST-LINK/V3E embedded debug tool
|
||||
interface. This interface is not yet supported by the openocd version.
|
||||
Instead, support can be enabled on pyocd by adding "pack" support with
|
||||
the following pyocd command:
|
||||
Nucleo L552ZE Q board includes an ST-LINK/V2-1 embedded debug tool
|
||||
interface. Support can be enabled on pyocd by adding "pack" support with the
|
||||
following pyocd command:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ pyocd pack --update
|
||||
$ pyocd pack --install stm32l552ze
|
||||
|
||||
Nucleo L552ZE Q board includes an ST-LINK/V2-1 embedded debug tool
|
||||
interface. This interface is supported by the openocd version
|
||||
included in the Zephyr SDK since v0.9.2.
|
||||
Alternatively, this interface is supported by the openocd version
|
||||
included in the Zephyr SDK since v0.13.1.
|
||||
|
||||
Flashing an application to Nucleo L552ZE Q
|
||||
------------------------------------------
|
||||
|
||||
19
boards/arm/nucleo_l552ze_q/support/openocd.cfg
Normal file
19
boards/arm/nucleo_l552ze_q/support/openocd.cfg
Normal file
@@ -0,0 +1,19 @@
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
source [find target/stm32l5x.cfg]
|
||||
|
||||
# use hardware reset
|
||||
reset_config srst_only srst_nogate
|
||||
|
||||
$_TARGETNAME configure -event gdb-attach {
|
||||
echo "Debugger attaching: halting execution"
|
||||
reset halt
|
||||
gdb_breakpoint_override hard
|
||||
}
|
||||
|
||||
$_TARGETNAME configure -event gdb-detach {
|
||||
echo "Debugger detaching: resuming execution"
|
||||
resume
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
board_runner_args(pyocd "--target=stm32wb55rgvx")
|
||||
board_runner_args(stm32cubeprogrammer "--port=swd" "--reset=hw")
|
||||
|
||||
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
|
||||
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
|
||||
include(${ZEPHYR_BASE}/boards/common/stm32cubeprogrammer.board.cmake)
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
CONFIG_SOC_SERIES_STM32H7X=y
|
||||
CONFIG_SOC_STM32H735XX=y
|
||||
|
||||
# Enable the internal SMPS regulator
|
||||
CONFIG_POWER_SUPPLY_DIRECT_SMPS=y
|
||||
|
||||
# Enable MPU
|
||||
CONFIG_ARM_MPU=y
|
||||
|
||||
|
||||
@@ -220,24 +220,6 @@ the USB port to prepare it for flashing. Then build and flash your application.
|
||||
|
||||
Here is an example for the :ref:`hello_world` application.
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/hello_world
|
||||
:board: stm32h747i_disco_m7
|
||||
:goals: build
|
||||
|
||||
Use the following commands to flash either m7 or m4 target:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ ./STM32_Programmer_CLI -c port=SWD mode=UR -w <path_to_m7_binary> 0x8000000
|
||||
$ ./STM32_Programmer_CLI -c port=SWD mode=UR -w <path_to_m4_binary> 0x8100000
|
||||
|
||||
Alternatively it is possible to flash with OpenOcd but with some restrictions:
|
||||
Sometimes, flashing is not working. It is necessary to erase the flash
|
||||
(with STM32CubeProgrammer for example) to make it work again.
|
||||
Debugging with OpenOCD is currently working for this board only with Cortex M7,
|
||||
not Cortex M4.
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/hello_world
|
||||
:board: stm32h747i_disco_m7
|
||||
@@ -255,6 +237,20 @@ You should see the following message on the console:
|
||||
|
||||
Hello World! stm32h747i_disco_m7
|
||||
|
||||
.. note::
|
||||
Sometimes, flashing is not working. It is necessary to erase the flash
|
||||
(with STM32CubeProgrammer for example) to make it work again.
|
||||
|
||||
Similarly, you can build and flash samples on the M4 target. For this, please
|
||||
take care of the resource sharing (UART port used for console for instance).
|
||||
|
||||
Here is an example for the :ref:`blinky-sample` application on M4 core.
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/basic/blinky
|
||||
:board: stm32h747i_disco_m4
|
||||
:goals: build flash
|
||||
|
||||
Debugging
|
||||
=========
|
||||
|
||||
@@ -266,6 +262,9 @@ You can debug an application in the usual way. Here is an example for the
|
||||
:board: stm32h747i_disco_m7
|
||||
:goals: debug
|
||||
|
||||
Debugging with west is currently not available on Cortex M4 side.
|
||||
In order to debug a Zephyr application on Cortex M4 side, you can use
|
||||
`STM32CubeIDE`_.
|
||||
|
||||
.. _STM32H747I-DISCO website:
|
||||
http://www.st.com/en/evaluation-tools/stm32h747i-disco.html
|
||||
@@ -284,3 +283,6 @@ You can debug an application in the usual way. Here is an example for the
|
||||
|
||||
.. _DISCO_H747I modifications for Ethernet:
|
||||
https://os.mbed.com/teams/ST/wiki/DISCO_H747I-modifications-for-Ethernet
|
||||
|
||||
.. _STM32CubeIDE:
|
||||
https://www.st.com/en/development-tools/stm32cubeide.html
|
||||
|
||||
@@ -9,6 +9,9 @@ CONFIG_BOARD_STM32H747I_DISCO_M7=y
|
||||
# enable pinmux
|
||||
CONFIG_PINMUX=y
|
||||
|
||||
# Enable the internal SMPS regulator
|
||||
CONFIG_POWER_SUPPLY_DIRECT_SMPS=y
|
||||
|
||||
# enable GPIO
|
||||
CONFIG_GPIO=y
|
||||
|
||||
|
||||
@@ -252,18 +252,16 @@ Flashing
|
||||
========
|
||||
|
||||
STM32L562E-DK Discovery board includes an ST-LINK/V3E embedded debug tool
|
||||
interface. This interface is not yet supported by the openocd version.
|
||||
Instead, support can be enabled on pyocd by adding "pack" support with
|
||||
the following pyocd command:
|
||||
interface. Support can be enabled on pyocd by adding "pack" support with the
|
||||
following pyocd command:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ pyocd pack --update
|
||||
$ pyocd pack --install stm32l562qe
|
||||
|
||||
STM32L562E-DK Discovery board includes an ST-LINK/V2-1 embedded debug tool
|
||||
interface. This interface is supported by the openocd version
|
||||
included in the Zephyr SDK since v0.9.2.
|
||||
Alternatively, this interface is supported by the openocd version
|
||||
included in the Zephyr SDK since v0.13.1.
|
||||
|
||||
Flashing an application to STM32L562E-DK Discovery
|
||||
--------------------------------------------------
|
||||
|
||||
19
boards/arm/stm32l562e_dk/support/openocd.cfg
Normal file
19
boards/arm/stm32l562e_dk/support/openocd.cfg
Normal file
@@ -0,0 +1,19 @@
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
transport select hla_swd
|
||||
|
||||
source [find target/stm32l5x.cfg]
|
||||
|
||||
# use hardware reset
|
||||
reset_config srst_only srst_nogate
|
||||
|
||||
$_TARGETNAME configure -event gdb-attach {
|
||||
echo "Debugger attaching: halting execution"
|
||||
reset halt
|
||||
gdb_breakpoint_override hard
|
||||
}
|
||||
|
||||
$_TARGETNAME configure -event gdb-detach {
|
||||
echo "Debugger detaching: resuming execution"
|
||||
resume
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
set(EMU_PLATFORM armfvp)
|
||||
set(ARMFVP_BIN_NAME FVP_BaseR_AEMv8R)
|
||||
set(ARMFVP_MIN_VERSION 11.16.16)
|
||||
|
||||
set(ARMFVP_FLAGS
|
||||
-C cluster0.has_aarch64=1
|
||||
|
||||
@@ -27,6 +27,8 @@ To Run the Fixed Virtual Platform simulation tool you must download "Armv8-R AEM
|
||||
FVP" from Arm developer [1]_ (This might require the user to register) and
|
||||
install it on your host PC.
|
||||
|
||||
The current minimum required version of "Armv8-R AEM FVP" is 11.16.16.
|
||||
|
||||
Hardware
|
||||
********
|
||||
|
||||
|
||||
@@ -33,3 +33,5 @@ CONFIG_PM_CPU_OPS_PSCI=n
|
||||
CONFIG_SOC_FVP_AEMV8R_EL2_INIT=y
|
||||
|
||||
CONFIG_MP_NUM_CPUS=4
|
||||
|
||||
CONFIG_MAX_THREAD_BYTES=3
|
||||
|
||||
@@ -24,6 +24,7 @@ if(CONFIG_BOOTLOADER_ESP_IDF)
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
|
||||
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
||||
-DPYTHON=${PYTHON_EXECUTABLE}
|
||||
BUILD_COMMAND
|
||||
${CMAKE_COMMAND} --build .
|
||||
INSTALL_COMMAND "" # This particular build system has no install command
|
||||
@@ -35,14 +36,14 @@ if(CONFIG_BOOTLOADER_ESP_IDF)
|
||||
BINARY_DIR ${espidf_build_dir}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND
|
||||
python ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
|
||||
${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
|
||||
--offset 0x1000 --flash-size 4MB ${ESP_IDF_PATH}/components/partition_table/partitions_singleapp.csv ${espidf_build_dir}/partitions_singleapp.bin
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
if(CONFIG_BUILD_OUTPUT_BIN)
|
||||
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
|
||||
COMMAND python ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
|
||||
ARGS --chip esp32c3 elf2image --flash_mode dio --flash_freq 40m
|
||||
-o ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
|
||||
${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.elf)
|
||||
|
||||
@@ -23,6 +23,7 @@ if(CONFIG_BOOTLOADER_ESP_IDF)
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
|
||||
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
||||
-DPYTHON=${PYTHON_EXECUTABLE}
|
||||
BUILD_COMMAND
|
||||
${CMAKE_COMMAND} --build .
|
||||
INSTALL_COMMAND "" # This particular build system has no install command
|
||||
@@ -34,14 +35,14 @@ if(CONFIG_BOOTLOADER_ESP_IDF)
|
||||
BINARY_DIR ${espidf_build_dir}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND
|
||||
python ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
|
||||
${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
|
||||
--offset 0x1000 --flash-size 4MB ${ESP_IDF_PATH}/components/partition_table/partitions_singleapp.csv ${espidf_build_dir}/partitions_singleapp.bin
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
if(CONFIG_BUILD_OUTPUT_BIN)
|
||||
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
|
||||
COMMAND python ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
|
||||
ARGS --chip esp32 elf2image --flash_mode dio --flash_freq 40m
|
||||
-o ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
|
||||
${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.elf)
|
||||
|
||||
@@ -23,6 +23,7 @@ if(CONFIG_BOOTLOADER_ESP_IDF)
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
|
||||
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
||||
-DPYTHON=${PYTHON_EXECUTABLE}
|
||||
BUILD_COMMAND
|
||||
${CMAKE_COMMAND} --build .
|
||||
INSTALL_COMMAND "" # This particular build system has no install command
|
||||
@@ -34,14 +35,14 @@ if(CONFIG_BOOTLOADER_ESP_IDF)
|
||||
BINARY_DIR ${espidf_build_dir}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND
|
||||
python ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
|
||||
${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
|
||||
--offset 0x1000 --flash-size 4MB ${ESP_IDF_PATH}/components/partition_table/partitions_singleapp.csv ${espidf_build_dir}/partitions_singleapp.bin
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
if(CONFIG_BUILD_OUTPUT_BIN)
|
||||
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
|
||||
COMMAND python ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
|
||||
ARGS --chip esp32s2 elf2image --flash_mode dio --flash_freq 40m
|
||||
-o ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
|
||||
${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.elf)
|
||||
|
||||
@@ -10,6 +10,20 @@ find_program(
|
||||
NAMES ${ARMFVP_BIN_NAME}
|
||||
)
|
||||
|
||||
if ((NOT "${ARMFVP}" STREQUAL "ARMFVP-NOTFOUND") AND (DEFINED ARMFVP_MIN_VERSION))
|
||||
execute_process(
|
||||
COMMAND ${ARMFVP} --version
|
||||
OUTPUT_VARIABLE out
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
string(REPLACE "\n" "" out ${out})
|
||||
string(REGEX MATCH "[0-9]+\.[0-9]+\.[0-9]+" armfvp_version ${out})
|
||||
if(${armfvp_version} VERSION_LESS ${ARMFVP_MIN_VERSION})
|
||||
message(WARNING "Found FVP version is \"${armfvp_version}\", "
|
||||
"the minimum required by the current board is \"${ARMFVP_MIN_VERSION}\".")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_ARMV8_A_NS)
|
||||
foreach(filetype BL1 FIP)
|
||||
if ((NOT DEFINED ARMFVP_${filetype}_FILE) AND (EXISTS "$ENV{ARMFVP_${filetype}_FILE}"))
|
||||
|
||||
@@ -90,6 +90,8 @@ endforeach()
|
||||
# A list of common environment settings used when invoking Kconfig during CMake
|
||||
# configure time or menuconfig and related build target.
|
||||
string(REPLACE ";" "\\\;" SHIELD_AS_LIST_ESCAPED "${SHIELD_AS_LIST}")
|
||||
# cmake commands are escaped differently
|
||||
string(REPLACE ";" "\\;" SHIELD_AS_LIST_ESCAPED_COMMAND "${SHIELD_AS_LIST}")
|
||||
|
||||
set(COMMON_KCONFIG_ENV_SETTINGS
|
||||
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
|
||||
@@ -250,7 +252,7 @@ endif()
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
${COMMON_KCONFIG_ENV_SETTINGS}
|
||||
SHIELD_AS_LIST=${SHIELD_AS_LIST_ESCAPED}
|
||||
SHIELD_AS_LIST=${SHIELD_AS_LIST_ESCAPED_COMMAND}
|
||||
${PYTHON_EXECUTABLE}
|
||||
${ZEPHYR_BASE}/scripts/kconfig/kconfig.py
|
||||
--zephyr-base=${ZEPHYR_BASE}
|
||||
|
||||
@@ -31,6 +31,9 @@ Configuration options
|
||||
- ``doxyrunner_doxyfile``: Path to Doxyfile.
|
||||
- ``doxyrunner_outdir``: Doxygen build output directory (inserted to
|
||||
``OUTPUT_DIRECTORY``)
|
||||
- ``doxyrunner_outdir_var``: Variable representing the Doxygen build output
|
||||
directory, as used by ``OUTPUT_DIRECTORY``. This can be useful if other
|
||||
Doxygen variables reference to the output directory.
|
||||
- ``doxyrunner_fmt``: Flag to indicate if Doxyfile should be formatted.
|
||||
- ``doxyrunner_fmt_vars``: Format variables dictionary (name: value).
|
||||
- ``doxyrunner_fmt_pattern``: Format pattern.
|
||||
@@ -132,6 +135,7 @@ def process_doxyfile(
|
||||
fmt: bool = False,
|
||||
fmt_pattern: Optional[str] = None,
|
||||
fmt_vars: Optional[Dict[str, str]] = None,
|
||||
outdir_var: Optional[str] = None,
|
||||
) -> str:
|
||||
"""Process Doxyfile.
|
||||
|
||||
@@ -146,6 +150,7 @@ def process_doxyfile(
|
||||
fmt: If Doxyfile should be formatted.
|
||||
fmt_pattern: Format pattern.
|
||||
fmt_vars: Format variables.
|
||||
outdir_var: Variable representing output directory.
|
||||
|
||||
Returns:
|
||||
Processed Doxyfile content.
|
||||
@@ -179,6 +184,10 @@ def process_doxyfile(
|
||||
if not fmt_pattern or not fmt_vars:
|
||||
raise ValueError("Invalid formatting pattern or variables")
|
||||
|
||||
if outdir_var:
|
||||
fmt_vars = fmt_vars.copy()
|
||||
fmt_vars[outdir_var] = outdir.as_posix()
|
||||
|
||||
for var, value in fmt_vars.items():
|
||||
content = content.replace(fmt_pattern.format(var), value)
|
||||
|
||||
@@ -349,6 +358,7 @@ def doxygen_build(app: Sphinx) -> None:
|
||||
app.config.doxyrunner_fmt,
|
||||
app.config.doxyrunner_fmt_pattern,
|
||||
app.config.doxyrunner_fmt_vars,
|
||||
app.config.doxyrunner_outdir_var,
|
||||
)
|
||||
|
||||
logger.info("Checking if Doxygen needs to be run...")
|
||||
@@ -374,6 +384,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
|
||||
app.add_config_value("doxyrunner_doxygen", "doxygen", "env")
|
||||
app.add_config_value("doxyrunner_doxyfile", None, "env")
|
||||
app.add_config_value("doxyrunner_outdir", None, "env")
|
||||
app.add_config_value("doxyrunner_outdir_var", None, "env")
|
||||
app.add_config_value("doxyrunner_fmt", False, "env")
|
||||
app.add_config_value("doxyrunner_fmt_vars", {}, "env")
|
||||
app.add_config_value("doxyrunner_fmt_pattern", "@{}@", "env")
|
||||
|
||||
95
doc/_static/css/custom.css
vendored
95
doc/_static/css/custom.css
vendored
@@ -124,64 +124,27 @@ hr,
|
||||
border-color: var(--admonition-attention-title-background-color) !important;
|
||||
color: var(--admonition-attention-color) !important;
|
||||
}
|
||||
.rst-content dl:not(.docutils).class dt,
|
||||
.rst-content dl:not(.docutils).function dt,
|
||||
.rst-content dl:not(.docutils).method dt,
|
||||
.rst-content dl:not(.docutils).attribute dt {
|
||||
width: 100% !important;
|
||||
}
|
||||
.rst-content dl:not(.docutils).class > dt,
|
||||
.rst-content dl:not(.docutils).function > dt,
|
||||
.rst-content dl:not(.docutils).method > dt,
|
||||
.rst-content dl:not(.docutils).attribute > dt {
|
||||
font-size: 100% !important;
|
||||
font-weight: normal !important;
|
||||
margin-bottom: 16px !important;
|
||||
padding: 6px 8px !important;
|
||||
}
|
||||
.rst-content dl:not(.docutils) tt.descclassname,
|
||||
.rst-content dl:not(.docutils) code.descclassname {
|
||||
color: var(--highlight-type2-color) !important;
|
||||
font-weight: normal !important;
|
||||
}
|
||||
.rst-content dl:not(.docutils) tt.descname,
|
||||
.rst-content dl:not(.docutils) code.descname {
|
||||
color: var(--highlight-function-color) !important;
|
||||
font-weight: normal !important;
|
||||
}
|
||||
.rst-content dl:not(.docutils) .sig-paren,
|
||||
.rst-content dl:not(.docutils) .optional {
|
||||
color: var(--highlight-operator-color) !important;
|
||||
font-weight: normal !important;
|
||||
padding: 0 2px !important;
|
||||
}
|
||||
.rst-content dl:not(.docutils) .optional {
|
||||
font-style: italic !important;
|
||||
}
|
||||
.rst-content dl:not(.docutils) .sig-param,
|
||||
.rst-content dl:not(.docutils).class dt > em,
|
||||
.rst-content dl:not(.docutils).function dt > em,
|
||||
.rst-content dl:not(.docutils).method dt > em {
|
||||
color: var(--code-literal-color) !important;
|
||||
|
||||
.rst-content dt.sig .k {
|
||||
color: var(--highlight-keyword2-color) !important;
|
||||
font-style: normal !important;
|
||||
padding: 0 4px !important;
|
||||
}
|
||||
.rst-content dl:not(.docutils) .sig-param,
|
||||
.rst-content dl:not(.docutils).class dt > code,
|
||||
.rst-content dl:not(.docutils).function dt > code,
|
||||
.rst-content dl:not(.docutils).method dt > code {
|
||||
padding: 0 4px !important;
|
||||
}
|
||||
.rst-content dl:not(.docutils) .sig-param,
|
||||
.rst-content dl:not(.docutils).class dt > .optional ~ em,
|
||||
.rst-content dl:not(.docutils).function dt > .optional ~ em,
|
||||
.rst-content dl:not(.docutils).method dt > .optional ~ em {
|
||||
color: var(--highlight-number-color) !important;
|
||||
font-style: italic !important;
|
||||
}
|
||||
.rst-content dl:not(.docutils).class dt > em.property {
|
||||
|
||||
.rst-content dt.sig .kt {
|
||||
color: var(--highlight-keyword-color) !important;
|
||||
font-style: normal !important;
|
||||
}
|
||||
|
||||
.rst-content dt.sig .sig-name .n {
|
||||
color: var(--highlight-function-color) !important;
|
||||
}
|
||||
|
||||
.rst-content dt.sig .k,
|
||||
.rst-content dt.sig .kt,
|
||||
.rst-content dt.sig .n {
|
||||
font-weight: normal !important;
|
||||
}
|
||||
|
||||
.rst-content dl:not(.docutils) dt a.headerlink {
|
||||
color: var(--link-color) !important;
|
||||
}
|
||||
@@ -878,16 +841,8 @@ kbd, .kbd {
|
||||
|
||||
/* Breathe tweaks */
|
||||
|
||||
.rst-content dl.group>dt, .rst-content dl.group>dd>p {
|
||||
display:none !important;
|
||||
}
|
||||
|
||||
.rst-content dl.group {
|
||||
margin: 0 0 1rem 0;
|
||||
}
|
||||
|
||||
.rst-content dl.group>dd {
|
||||
margin-left: 0 !important;
|
||||
.rst-content .section > dl > dd {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.rst-content p.breathe-sectiondef-title {
|
||||
@@ -895,24 +850,12 @@ kbd, .kbd {
|
||||
color: var(--link-color);
|
||||
}
|
||||
|
||||
.rst-content div.breathe-sectiondef {
|
||||
padding-left: 0 !important;
|
||||
}
|
||||
|
||||
.rst-content dl:not(.docutils) dl:not(.rst-other-versions) dt {
|
||||
background: var(--admonition-note-background-color) !important;
|
||||
border-top: none !important;
|
||||
border-left: none !important;
|
||||
}
|
||||
|
||||
.rst-content dl:not(.docutils).c.var .pre {
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.rst-content dl:not(.docutils).c.struct .property {
|
||||
padding-right: 4px !important;
|
||||
}
|
||||
|
||||
/* Misc tweaks */
|
||||
|
||||
.rst-columns {
|
||||
|
||||
@@ -180,6 +180,7 @@ doxyrunner_doxyfile = ZEPHYR_BASE / "doc" / "zephyr.doxyfile.in"
|
||||
doxyrunner_outdir = ZEPHYR_BUILD / "doxygen"
|
||||
doxyrunner_fmt = True
|
||||
doxyrunner_fmt_vars = {"ZEPHYR_BASE": str(ZEPHYR_BASE)}
|
||||
doxyrunner_outdir_var = "DOXY_OUT"
|
||||
|
||||
# -- Options for Breathe plugin -------------------------------------------
|
||||
|
||||
@@ -203,6 +204,7 @@ cpp_id_attributes = [
|
||||
"__DEPRECATED_MACRO",
|
||||
"FUNC_NORETURN",
|
||||
"__subsystem",
|
||||
"ALWAYS_INLINE",
|
||||
]
|
||||
c_id_attributes = cpp_id_attributes
|
||||
|
||||
|
||||
@@ -209,6 +209,20 @@ on Zephyr. The ones that are supported are described in the following table:
|
||||
:kconfig:`CONFIG_THREAD_STACK_INFO` and :kconfig:`CONFIG_INIT_STACKS` options
|
||||
must be set.
|
||||
|
||||
.. _mcumgr_jlink_ob_virtual_msd:
|
||||
|
||||
J-Link Virtual MSD Interaction Note
|
||||
***********************************
|
||||
|
||||
On boards where a J-Link OB is present which has both CDC and MSC (virtual Mass
|
||||
Storage Device, also known as drag-and-drop) support, the MSD functionality can
|
||||
prevent mcumgr commands over the CDC UART port from working due to how USB
|
||||
endpoints are configured in the J-Link firmware (for example on the Nordic
|
||||
``nrf52840dk``) because of limiting the maximum packet size (most likely to occur
|
||||
when using image management commands for updating firmware). This issue can be
|
||||
resolved by disabling MSD functionality on the J-Link device, follow the
|
||||
instructions on :ref:`nordic_segger_msd` to disable MSD support.
|
||||
|
||||
.. _image_mgmt:
|
||||
|
||||
Image Management
|
||||
|
||||
@@ -261,7 +261,21 @@ or invoke make with the following target::
|
||||
# To generate HTML output without detailed Kconfig
|
||||
make html-fast
|
||||
|
||||
Linking external Doxygen projects against Zephyr
|
||||
************************************************
|
||||
|
||||
External projects that build upon Zephyr functionality and wish to refer to
|
||||
Zephyr documentation in Doxygen (through the use of @ref), can utilize the
|
||||
tag file exported at `zephyr.tag </doxygen/html/zephyr.tag>`_
|
||||
|
||||
Once downloaded, the tag file can be used in a custom ``doxyfile.in`` as follows::
|
||||
|
||||
TAGFILES = "/path/to/zephyr.tag=https://docs.zephyrproject.org/latest/doxygen/html/"
|
||||
|
||||
For additional information refer to `Doxygen External Documentation`_.
|
||||
|
||||
|
||||
.. _reStructuredText: http://sphinx-doc.org/rest.html
|
||||
.. _Sphinx: http://sphinx-doc.org/
|
||||
.. _Windows Python Path: https://docs.python.org/3/using/windows.html#finding-the-python-executable
|
||||
.. _Doxygen External Documentation: https://www.doxygen.nl/manual/external.html
|
||||
|
||||
@@ -297,3 +297,8 @@ Note that while SMP requires :kconfig:`CONFIG_USE_SWITCH`, the reverse is not
|
||||
true. A uniprocessor architecture built with :kconfig:`CONFIG_SMP` set to No might
|
||||
still decide to implement its context switching using
|
||||
:c:func:`arch_switch`.
|
||||
|
||||
API Reference
|
||||
**************
|
||||
|
||||
.. doxygengroup:: spinlock_apis
|
||||
|
||||
@@ -177,12 +177,12 @@ occurred. It does not block until the message is sent like the example above.
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
void tx_irq_callback(uint32_t error_flags, void *arg)
|
||||
void tx_irq_callback(int error, void *arg)
|
||||
{
|
||||
char *sender = (char *)arg;
|
||||
|
||||
if (error_flags) {
|
||||
LOG_ERR("Sendig failed [%d]\nSender: %s\n", error_flags, sender);
|
||||
if (error != 0) {
|
||||
LOG_ERR("Sendig failed [%d]\nSender: %s\n", error, sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,19 @@ release:
|
||||
* :github:`40844` - gen_app_partitions scans object files unrelated to current image
|
||||
* :github:`41237` - drivers: ieee802154_dw1000: use dedicated workqueue
|
||||
|
||||
Security Vulnerability Related
|
||||
******************************
|
||||
|
||||
The following security vulnerabilities (CVEs) were addressed in this
|
||||
release:
|
||||
|
||||
* CVE-2021-3966: `Zephyr project bug tracker GHSA-hfxq-3w6x-fv2m
|
||||
<https://github.com/zephyrproject-rtos/zephyr/security/advisories/GHSA-hfxq-3w6x-fv2m>`_
|
||||
|
||||
More detailed information can be found in:
|
||||
https://docs.zephyrproject.org/latest/security/vulnerabilities.html
|
||||
|
||||
|
||||
.. _zephyr_2.7.0:
|
||||
|
||||
Zephyr 2.7.0
|
||||
|
||||
@@ -2064,7 +2064,7 @@ TAGFILES =
|
||||
# tag file that is based on the input files it reads. See section "Linking to
|
||||
# external documentation" for more information about the usage of tag files.
|
||||
|
||||
GENERATE_TAGFILE =
|
||||
GENERATE_TAGFILE = @DOXY_OUT@/html/zephyr.tag
|
||||
|
||||
# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
|
||||
# the class index. If set to NO, only the inherited external classes will be
|
||||
|
||||
@@ -319,6 +319,49 @@ static void adc_stm32_calib(const struct device *dev)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enable ADC peripheral, and wait until ready if required by SOC.
|
||||
*/
|
||||
static int adc_stm32_enable(ADC_TypeDef *adc)
|
||||
{
|
||||
#if defined(CONFIG_SOC_SERIES_STM32L4X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32L5X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32WBX) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32G0X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32G4X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32WLX)
|
||||
|
||||
if (LL_ADC_IsEnabled(adc) == 1UL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
LL_ADC_ClearFlag_ADRDY(adc);
|
||||
LL_ADC_Enable(adc);
|
||||
|
||||
/*
|
||||
* Enabling ADC modules in L4, WB, G0 and G4 series may fail if they are
|
||||
* still not stabilized, this will wait for a short time to ensure ADC
|
||||
* modules are properly enabled.
|
||||
*/
|
||||
uint32_t count_timeout = 0;
|
||||
|
||||
while (LL_ADC_IsActiveFlag_ADRDY(adc) == 0) {
|
||||
if (LL_ADC_IsEnabled(adc) == 0UL) {
|
||||
LL_ADC_Enable(adc);
|
||||
count_timeout++;
|
||||
if (count_timeout == 10) {
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
LL_ADC_Enable(adc);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int start_read(const struct device *dev,
|
||||
const struct adc_sequence *sequence)
|
||||
{
|
||||
@@ -409,9 +452,10 @@ static int start_read(const struct device *dev,
|
||||
return err;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_STM32G0X)
|
||||
#if defined(CONFIG_SOC_SERIES_STM32G0X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32WLX)
|
||||
/*
|
||||
* Errata: Writing ADC_CFGR1 register while ADEN bit is set
|
||||
* Writing ADC_CFGR1 register while ADEN bit is set
|
||||
* resets RES[1:0] bitfield. We need to disable and enable adc.
|
||||
*/
|
||||
if (LL_ADC_IsEnabled(adc) == 1UL) {
|
||||
@@ -420,15 +464,14 @@ static int start_read(const struct device *dev,
|
||||
while (LL_ADC_IsEnabled(adc) == 1UL) {
|
||||
}
|
||||
LL_ADC_SetResolution(adc, resolution);
|
||||
LL_ADC_Enable(adc);
|
||||
while (LL_ADC_IsActiveFlag_ADRDY(adc) != 1UL) {
|
||||
}
|
||||
adc_stm32_enable(adc);
|
||||
#elif !defined(CONFIG_SOC_SERIES_STM32F1X) && \
|
||||
!defined(STM32F3X_ADC_V2_5)
|
||||
LL_ADC_SetResolution(adc, resolution);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SOC_SERIES_STM32L0X
|
||||
#if defined(CONFIG_SOC_SERIES_STM32L0X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32WLX)
|
||||
/*
|
||||
* setting OVS bits is conditioned to ADC state: ADC must be disabled
|
||||
* or enabled without conversion on going : disable it, it will stop
|
||||
@@ -524,11 +567,11 @@ static int start_read(const struct device *dev,
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("Invalid oversampling");
|
||||
LL_ADC_Enable(adc);
|
||||
adc_stm32_enable(adc);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* re-enable ADC after changing the OVS */
|
||||
LL_ADC_Enable(adc);
|
||||
adc_stm32_enable(adc);
|
||||
#else
|
||||
if (sequence->oversampling) {
|
||||
LOG_ERR("Oversampling not supported");
|
||||
@@ -543,7 +586,14 @@ static int start_read(const struct device *dev,
|
||||
!defined(CONFIG_SOC_SERIES_STM32F1X) && \
|
||||
!defined(STM32F3X_ADC_V2_5) && \
|
||||
!defined(CONFIG_SOC_SERIES_STM32L1X)
|
||||
|
||||
/* we cannot calibrate the ADC while the ADC is enabled */
|
||||
LL_ADC_Disable(adc);
|
||||
while (LL_ADC_IsEnabled(adc) == 1UL) {
|
||||
}
|
||||
adc_stm32_calib(dev);
|
||||
/* re-enable ADC after calibration */
|
||||
adc_stm32_enable(adc);
|
||||
#else
|
||||
LOG_ERR("Calibration not supported");
|
||||
return -ENOTSUP;
|
||||
@@ -564,7 +614,7 @@ static int start_read(const struct device *dev,
|
||||
#elif defined(CONFIG_SOC_SERIES_STM32F1X)
|
||||
LL_ADC_EnableIT_EOS(adc);
|
||||
#elif defined(STM32F3X_ADC_V2_5)
|
||||
LL_ADC_Enable(adc);
|
||||
adc_stm32_enable(adc);
|
||||
LL_ADC_EnableIT_EOS(adc);
|
||||
#else
|
||||
LL_ADC_EnableIT_EOCS(adc);
|
||||
@@ -904,32 +954,10 @@ static int adc_stm32_init(const struct device *dev)
|
||||
}
|
||||
#endif
|
||||
|
||||
LL_ADC_Enable(adc);
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_STM32L4X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32L5X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32WBX) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32G0X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32G4X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32H7X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32WLX)
|
||||
/*
|
||||
* Enabling ADC modules in L4, WB, G0 and G4 series may fail if they are
|
||||
* still not stabilized, this will wait for a short time to ensure ADC
|
||||
* modules are properly enabled.
|
||||
*/
|
||||
uint32_t countTimeout = 0;
|
||||
|
||||
while (LL_ADC_IsActiveFlag_ADRDY(adc) == 0) {
|
||||
if (LL_ADC_IsEnabled(adc) == 0UL) {
|
||||
LL_ADC_Enable(adc);
|
||||
countTimeout++;
|
||||
if (countTimeout == 10) {
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
}
|
||||
err = adc_stm32_enable(adc);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
config->irq_cfg_func();
|
||||
|
||||
|
||||
@@ -149,6 +149,9 @@ int can_mcan_set_timing(const struct can_mcan_config *cfg,
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* Configuration Change Enable */
|
||||
can->cccr |= CAN_MCAN_CCCR_CCE;
|
||||
|
||||
can_mcan_configure_timing(can, timing, timing_data);
|
||||
|
||||
ret = can_leave_init_mode(can, K_MSEC(CAN_INIT_TIMEOUT));
|
||||
|
||||
@@ -56,7 +56,7 @@ static const uint8_t reg_demand[] = {2, 1, 4, 2};
|
||||
static void can_stm32_signal_tx_complete(struct can_mailbox *mb)
|
||||
{
|
||||
if (mb->tx_callback) {
|
||||
mb->tx_callback(mb->error_flags, mb->callback_arg);
|
||||
mb->tx_callback(mb->error, mb->callback_arg);
|
||||
} else {
|
||||
k_sem_give(&mb->tx_int_sem);
|
||||
}
|
||||
@@ -151,7 +151,7 @@ void can_stm32_tx_isr_handler(CAN_TypeDef *can, struct can_stm32_data *data)
|
||||
bus_off = can->ESR & CAN_ESR_BOFF;
|
||||
|
||||
if ((can->TSR & CAN_TSR_RQCP0) | bus_off) {
|
||||
data->mb0.error_flags =
|
||||
data->mb0.error =
|
||||
can->TSR & CAN_TSR_TXOK0 ? CAN_TX_OK :
|
||||
can->TSR & CAN_TSR_TERR0 ? CAN_TX_ERR :
|
||||
can->TSR & CAN_TSR_ALST0 ? CAN_TX_ARB_LOST :
|
||||
@@ -163,7 +163,7 @@ void can_stm32_tx_isr_handler(CAN_TypeDef *can, struct can_stm32_data *data)
|
||||
}
|
||||
|
||||
if ((can->TSR & CAN_TSR_RQCP1) | bus_off) {
|
||||
data->mb1.error_flags =
|
||||
data->mb1.error =
|
||||
can->TSR & CAN_TSR_TXOK1 ? CAN_TX_OK :
|
||||
can->TSR & CAN_TSR_TERR1 ? CAN_TX_ERR :
|
||||
can->TSR & CAN_TSR_ALST1 ? CAN_TX_ARB_LOST :
|
||||
@@ -175,7 +175,7 @@ void can_stm32_tx_isr_handler(CAN_TypeDef *can, struct can_stm32_data *data)
|
||||
}
|
||||
|
||||
if ((can->TSR & CAN_TSR_RQCP2) | bus_off) {
|
||||
data->mb2.error_flags =
|
||||
data->mb2.error =
|
||||
can->TSR & CAN_TSR_TXOK2 ? CAN_TX_OK :
|
||||
can->TSR & CAN_TSR_TERR2 ? CAN_TX_ERR :
|
||||
can->TSR & CAN_TSR_ALST2 ? CAN_TX_ARB_LOST :
|
||||
@@ -688,7 +688,7 @@ int can_stm32_send(const struct device *dev, const struct zcan_frame *msg,
|
||||
|
||||
if (callback == NULL) {
|
||||
k_sem_take(&mb->tx_int_sem, K_FOREVER);
|
||||
return mb->error_flags;
|
||||
return mb->error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -43,7 +43,7 @@ struct can_mailbox {
|
||||
can_tx_callback_t tx_callback;
|
||||
void *callback_arg;
|
||||
struct k_sem tx_int_sem;
|
||||
uint32_t error_flags;
|
||||
int error;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -45,12 +45,12 @@ static inline void socket_can_iface_init(struct net_if *iface)
|
||||
LOG_DBG("Init CAN interface %p dev %p", iface, dev);
|
||||
}
|
||||
|
||||
static inline void tx_irq_callback(uint32_t error_flags, void *arg)
|
||||
static inline void tx_irq_callback(int error, void *arg)
|
||||
{
|
||||
char *caller_str = (char *)arg;
|
||||
if (error_flags) {
|
||||
if (error != 0) {
|
||||
LOG_DBG("TX error from %s! error-code: %d",
|
||||
caller_str, error_flags);
|
||||
caller_str, error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -259,8 +259,28 @@ static uint32_t get_hclk_frequency(void)
|
||||
|
||||
static int32_t prepare_regulator_voltage_scale(void)
|
||||
{
|
||||
/* Make sure to put the CPU in highest Voltage scale during clock configuration */
|
||||
/* Apply system power supply configuration */
|
||||
#if defined(SMPS) && defined(CONFIG_POWER_SUPPLY_DIRECT_SMPS)
|
||||
LL_PWR_ConfigSupply(LL_PWR_DIRECT_SMPS_SUPPLY);
|
||||
#elif defined(SMPS) && defined(CONFIG_POWER_SUPPLY_SMPS_1V8_SUPPLIES_LDO)
|
||||
LL_PWR_ConfigSupply(LL_PWR_SMPS_1V8_SUPPLIES_LDO);
|
||||
#elif defined(SMPS) && defined(CONFIG_POWER_SUPPLY_SMPS_2V5_SUPPLIES_LDO)
|
||||
LL_PWR_ConfigSupply(LL_PWR_SMPS_2V5_SUPPLIES_LDO);
|
||||
#elif defined(SMPS) && defined(CONFIG_POWER_SUPPLY_SMPS_1V8_SUPPLIES_EXT_AND_LDO)
|
||||
LL_PWR_ConfigSupply(LL_PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO);
|
||||
#elif defined(SMPS) && defined(CONFIG_POWER_SUPPLY_SMPS_2V5_SUPPLIES_EXT_AND_LDO)
|
||||
LL_PWR_ConfigSupply(LL_PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO);
|
||||
#elif defined(SMPS) && defined(CONFIG_POWER_SUPPLY_SMPS_1V8_SUPPLIES_EXT)
|
||||
LL_PWR_ConfigSupply(LL_PWR_SMPS_1V8_SUPPLIES_EXT);
|
||||
#elif defined(SMPS) && defined(CONFIG_POWER_SUPPLY_SMPS_2V5_SUPPLIES_EXT)
|
||||
LL_PWR_ConfigSupply(LL_PWR_SMPS_2V5_SUPPLIES_EXT);
|
||||
#elif defined(CONFIG_POWER_SUPPLY_EXTERNAL_SOURCE)
|
||||
LL_PWR_ConfigSupply(LL_PWR_EXTERNAL_SOURCE_SUPPLY);
|
||||
#else
|
||||
LL_PWR_ConfigSupply(LL_PWR_LDO_SUPPLY);
|
||||
#endif
|
||||
|
||||
/* Make sure to put the CPU in highest Voltage scale during clock configuration */
|
||||
/* Highest voltage is SCALE0 */
|
||||
LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE0);
|
||||
return 0;
|
||||
@@ -276,7 +296,25 @@ static int32_t optimize_regulator_voltage_scale(uint32_t sysclk_freq)
|
||||
/* LL_PWR_REGULATOR_SCALE3 is lowest power consumption */
|
||||
/* Must be done in accordance to the Maximum allowed frequency vs VOS*/
|
||||
/* See RM0433 page 352 for more details */
|
||||
#if defined(SMPS) && defined(CONFIG_POWER_SUPPLY_DIRECT_SMPS)
|
||||
LL_PWR_ConfigSupply(LL_PWR_DIRECT_SMPS_SUPPLY);
|
||||
#elif defined(SMPS) && defined(CONFIG_POWER_SUPPLY_SMPS_1V8_SUPPLIES_LDO)
|
||||
LL_PWR_ConfigSupply(LL_PWR_SMPS_1V8_SUPPLIES_LDO);
|
||||
#elif defined(SMPS) && defined(CONFIG_POWER_SUPPLY_SMPS_2V5_SUPPLIES_LDO)
|
||||
LL_PWR_ConfigSupply(LL_PWR_SMPS_2V5_SUPPLIES_LDO);
|
||||
#elif defined(SMPS) && defined(CONFIG_POWER_SUPPLY_SMPS_1V8_SUPPLIES_EXT_AND_LDO)
|
||||
LL_PWR_ConfigSupply(LL_PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO);
|
||||
#elif defined(SMPS) && defined(CONFIG_POWER_SUPPLY_SMPS_2V5_SUPPLIES_EXT_AND_LDO)
|
||||
LL_PWR_ConfigSupply(LL_PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO);
|
||||
#elif defined(SMPS) && defined(CONFIG_POWER_SUPPLY_SMPS_1V8_SUPPLIES_EXT)
|
||||
LL_PWR_ConfigSupply(LL_PWR_SMPS_1V8_SUPPLIES_EXT);
|
||||
#elif defined(SMPS) && defined(CONFIG_POWER_SUPPLY_SMPS_2V5_SUPPLIES_EXT)
|
||||
LL_PWR_ConfigSupply(LL_PWR_SMPS_2V5_SUPPLIES_EXT);
|
||||
#elif defined(CONFIG_POWER_SUPPLY_EXTERNAL_SOURCE)
|
||||
LL_PWR_ConfigSupply(LL_PWR_EXTERNAL_SOURCE_SUPPLY);
|
||||
#else
|
||||
LL_PWR_ConfigSupply(LL_PWR_LDO_SUPPLY);
|
||||
#endif
|
||||
LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -387,8 +387,8 @@ static int gsm_mux_send_data_msg(struct gsm_mux *mux, bool cmd,
|
||||
hdr[3] = (size << 1) | EA;
|
||||
pos = 4;
|
||||
} else {
|
||||
hdr[3] = (size >> 7);
|
||||
hdr[4] = (size & 127) << 1;
|
||||
hdr[3] = (size & 127) << 1;
|
||||
hdr[4] = (size >> 7);
|
||||
pos = 5;
|
||||
}
|
||||
|
||||
@@ -610,7 +610,8 @@ static void ctrl_msg_cleanup(struct gsm_control_msg *entry, bool pending)
|
||||
/* T2 timeout is for control message retransmits */
|
||||
static void gsm_mux_t2_timeout(struct k_work *work)
|
||||
{
|
||||
struct gsm_mux *mux = CONTAINER_OF(work, struct gsm_mux, t2_timer);
|
||||
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
|
||||
struct gsm_mux *mux = CONTAINER_OF(dwork, struct gsm_mux, t2_timer);
|
||||
uint32_t current_time = k_uptime_get_32();
|
||||
struct gsm_control_msg *entry, *next;
|
||||
|
||||
|
||||
@@ -636,8 +636,8 @@ static int ssd16xx_controller_init(const struct device *dev)
|
||||
|
||||
static int ssd16xx_init(const struct device *dev)
|
||||
{
|
||||
const struct ssd16xx_config *config = dev->config;
|
||||
struct ssd16xx_data *driver = dev->data;
|
||||
const struct ssd16xx_config *config = driver->config;
|
||||
|
||||
LOG_DBG("");
|
||||
|
||||
|
||||
@@ -217,8 +217,9 @@ static void invoke_link_cb(const struct device *dev)
|
||||
|
||||
static void monitor_work_handler(struct k_work *work)
|
||||
{
|
||||
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
|
||||
struct phy_mii_dev_data *const data =
|
||||
CONTAINER_OF(work, struct phy_mii_dev_data, monitor_work);
|
||||
CONTAINER_OF(dwork, struct phy_mii_dev_data, monitor_work);
|
||||
const struct device *dev = data->dev;
|
||||
int rc;
|
||||
|
||||
|
||||
@@ -30,17 +30,6 @@ LOG_MODULE_REGISTER(flash_stm32, CONFIG_FLASH_LOG_LEVEL);
|
||||
#define STM32_FLASH_TIMEOUT \
|
||||
(2 * DT_PROP(DT_INST(0, st_stm32_nv_flash), max_erase_time))
|
||||
|
||||
#if defined(FLASH_NSSR_NSBSY) /* For STM32L5x in non-secure mode */
|
||||
#define FLASH_SECURITY_NS
|
||||
#elif defined(FLASH_SECSR_SECBSY) /* For STM32L5x in secured mode */
|
||||
#error Flash is not supported in secure mode
|
||||
#define FLASH_SECURITY_SEC
|
||||
#else
|
||||
#define FLASH_SECURITY_NA /* For series which does not have
|
||||
* secured or non-secured mode
|
||||
*/
|
||||
#endif
|
||||
|
||||
static const struct flash_parameters flash_stm32_parameters = {
|
||||
.write_block_size = FLASH_STM32_WRITE_BLOCK_SIZE,
|
||||
/* Some SoCs (L0/L1) use an EEPROM under the hood. Distinguish
|
||||
@@ -89,37 +78,11 @@ static inline void _flash_stm32_sem_give(const struct device *dev)
|
||||
#if !defined(CONFIG_SOC_SERIES_STM32WBX)
|
||||
static int flash_stm32_check_status(const struct device *dev)
|
||||
{
|
||||
uint32_t const error =
|
||||
#if defined(FLASH_FLAG_PGAERR)
|
||||
FLASH_FLAG_PGAERR |
|
||||
#endif
|
||||
#if defined(FLASH_FLAG_RDERR)
|
||||
FLASH_FLAG_RDERR |
|
||||
#endif
|
||||
#if defined(FLASH_FLAG_PGPERR)
|
||||
FLASH_FLAG_PGPERR |
|
||||
#endif
|
||||
#if defined(FLASH_FLAG_PGSERR)
|
||||
FLASH_FLAG_PGSERR |
|
||||
#endif
|
||||
#if defined(FLASH_FLAG_OPERR)
|
||||
FLASH_FLAG_OPERR |
|
||||
#endif
|
||||
#if defined(FLASH_FLAG_PROGERR)
|
||||
FLASH_FLAG_PROGERR |
|
||||
#endif
|
||||
#if defined(FLASH_FLAG_PGERR)
|
||||
FLASH_FLAG_PGERR |
|
||||
#endif
|
||||
FLASH_FLAG_WRPERR;
|
||||
|
||||
#if defined(FLASH_SECURITY_NS)
|
||||
if (FLASH_STM32_REGS(dev)->NSSR & error) {
|
||||
LOG_DBG("Status: 0x%08x", FLASH_STM32_REGS(dev)->NSSR & error);
|
||||
#else /* FLASH_SECURITY_SEC | FLASH_SECURITY_NA */
|
||||
if (FLASH_STM32_REGS(dev)->SR & error) {
|
||||
LOG_DBG("Status: 0x%08x", FLASH_STM32_REGS(dev)->SR & error);
|
||||
#endif /* FLASH_SECURITY_NS */
|
||||
if (FLASH_STM32_REGS(dev)->FLASH_STM32_SR & FLASH_STM32_SR_ERRORS) {
|
||||
LOG_DBG("Status: 0x%08lx",
|
||||
FLASH_STM32_REGS(dev)->FLASH_STM32_SR &
|
||||
FLASH_STM32_SR_ERRORS);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
@@ -131,21 +94,21 @@ int flash_stm32_wait_flash_idle(const struct device *dev)
|
||||
{
|
||||
int64_t timeout_time = k_uptime_get() + STM32_FLASH_TIMEOUT;
|
||||
int rc;
|
||||
uint32_t busy_flags;
|
||||
|
||||
rc = flash_stm32_check_status(dev);
|
||||
if (rc < 0) {
|
||||
return -EIO;
|
||||
}
|
||||
#if defined(FLASH_SECURITY_NS)
|
||||
while ((FLASH_STM32_REGS(dev)->NSSR & FLASH_FLAG_BSY)) {
|
||||
#else /* FLASH_SECURITY_SEC | FLASH_SECURITY_NA */
|
||||
#if defined(FLASH_SR_BSY1)
|
||||
/* Applicable for STM32G0 series */
|
||||
while ((FLASH_STM32_REGS(dev)->SR & FLASH_SR_BSY1)) {
|
||||
#else
|
||||
while ((FLASH_STM32_REGS(dev)->SR & FLASH_SR_BSY)) {
|
||||
|
||||
busy_flags = FLASH_STM32_SR_BUSY;
|
||||
|
||||
/* Some Series can't modify FLASH_CR reg while CFGBSY is set. Wait as well */
|
||||
#if defined(FLASH_STM32_SR_CFGBSY)
|
||||
busy_flags |= FLASH_STM32_SR_CFGBSY;
|
||||
#endif
|
||||
#endif /* FLASH_SECURITY_NS */
|
||||
|
||||
while ((FLASH_STM32_REGS(dev)->FLASH_STM32_SR & busy_flags)) {
|
||||
if (k_uptime_get() > timeout_time) {
|
||||
LOG_ERR("Timeout! val: %d", STM32_FLASH_TIMEOUT);
|
||||
return -EIO;
|
||||
|
||||
@@ -33,9 +33,142 @@ struct flash_stm32_priv {
|
||||
/* as flash node property 'write-block-size' */
|
||||
#endif
|
||||
|
||||
/* Differentiate between arm trust-zone non-secure/secure, and others. */
|
||||
#if defined(FLASH_NSSR_NSBSY) /* For mcu w. TZ in non-secure mode */
|
||||
#define FLASH_SECURITY_NS
|
||||
#define FLASH_STM32_SR NSSR
|
||||
#elif defined(FLASH_SECSR_SECBSY) /* For mcu w. TZ in secured mode */
|
||||
#error Flash is not supported in secure mode
|
||||
#define FLASH_SECURITY_SEC
|
||||
#else
|
||||
#define FLASH_SECURITY_NA /* For series which does not have
|
||||
* secured or non-secured mode
|
||||
*/
|
||||
#define FLASH_STM32_SR SR
|
||||
#endif
|
||||
|
||||
|
||||
#define FLASH_STM32_PRIV(dev) ((struct flash_stm32_priv *)((dev)->data))
|
||||
#define FLASH_STM32_REGS(dev) (FLASH_STM32_PRIV(dev)->regs)
|
||||
|
||||
|
||||
/* Redefintions of flags and masks to harmonize stm32 series: */
|
||||
#if defined(CONFIG_SOC_SERIES_STM32G0X)
|
||||
#if defined(FLASH_FLAG_BSY2)
|
||||
#define FLASH_STM32_SR_BUSY (FLASH_FLAG_BSY1 | FLASH_FLAG_BSY2);
|
||||
#else
|
||||
#define FLASH_STM32_SR_BUSY (FLASH_SR_BSY1)
|
||||
#endif /* defined(FLASH_FLAG_BSY2) */
|
||||
#else
|
||||
#define FLASH_STM32_SR_BUSY (FLASH_FLAG_BSY)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_STM32G0X)
|
||||
#define FLASH_STM32_SR_CFGBSY (FLASH_SR_CFGBSY)
|
||||
#elif defined(FLASH_FLAG_CFGBSY)
|
||||
#define FLASH_STM32_SR_CFGBSY (FLASH_FLAG_CFGBSY)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_STM32G0X)
|
||||
/* STM32G0 HAL FLASH_FLAG_x don't represent bit-masks, need FLASH_SR_x instead */
|
||||
#define FLASH_STM32_SR_OPERR FLASH_SR_OPERR
|
||||
#define FLASH_STM32_SR_PGERR 0
|
||||
#define FLASH_STM32_SR_PROGERR FLASH_SR_PROGERR
|
||||
#define FLASH_STM32_SR_WRPERR FLASH_SR_WRPERR
|
||||
#define FLASH_STM32_SR_PGAERR FLASH_SR_PGAERR
|
||||
#define FLASH_STM32_SR_SIZERR FLASH_SR_SIZERR
|
||||
#define FLASH_STM32_SR_PGSERR FLASH_SR_PGSERR
|
||||
#define FLASH_STM32_SR_MISERR FLASH_SR_MISERR
|
||||
#define FLASH_STM32_SR_FASTERR FLASH_SR_FASTERR
|
||||
#if defined(FLASH_SR_RDERR)
|
||||
#define FLASH_STM32_SR_RDERR FLASH_SR_RDERR
|
||||
#else
|
||||
#define FLASH_STM32_SR_RDERR 0
|
||||
#endif
|
||||
#define FLASH_STM32_SR_PGPERR 0
|
||||
|
||||
#else /* !defined(CONFIG_SOC_SERIES_STM32G0X) */
|
||||
#if defined(FLASH_FLAG_OPERR)
|
||||
#define FLASH_STM32_SR_OPERR FLASH_FLAG_OPERR
|
||||
#else
|
||||
#define FLASH_STM32_SR_OPERR 0
|
||||
#endif
|
||||
|
||||
#if defined(FLASH_FLAG_PGERR)
|
||||
#define FLASH_STM32_SR_PGERR FLASH_FLAG_PGERR
|
||||
#else
|
||||
#define FLASH_STM32_SR_PGERR 0
|
||||
#endif
|
||||
|
||||
#if defined(FLASH_FLAG_PROGERR)
|
||||
#define FLASH_STM32_SR_PROGERR FLASH_FLAG_PROGERR
|
||||
#else
|
||||
#define FLASH_STM32_SR_PROGERR 0
|
||||
#endif
|
||||
|
||||
#if defined(FLASH_FLAG_WRPERR)
|
||||
#define FLASH_STM32_SR_WRPERR FLASH_FLAG_WRPERR
|
||||
#else
|
||||
#define FLASH_STM32_SR_WRPERR 0
|
||||
#endif
|
||||
|
||||
#if defined(FLASH_FLAG_PGAERR)
|
||||
#define FLASH_STM32_SR_PGAERR FLASH_FLAG_PGAERR
|
||||
#else
|
||||
#define FLASH_STM32_SR_PGAERR 0
|
||||
#endif
|
||||
|
||||
#if defined(FLASH_FLAG_SIZERR)
|
||||
#define FLASH_STM32_SR_SIZERR FLASH_FLAG_SIZERR
|
||||
#else
|
||||
#define FLASH_STM32_SR_SIZERR 0
|
||||
#endif
|
||||
|
||||
#if defined(FLASH_FLAG_PGSERR)
|
||||
#define FLASH_STM32_SR_PGSERR FLASH_FLAG_PGSERR
|
||||
#else
|
||||
#define FLASH_STM32_SR_PGSERR 0
|
||||
#endif
|
||||
|
||||
#if defined(FLASH_FLAG_MISERR)
|
||||
#define FLASH_STM32_SR_MISERR FLASH_FLAG_MISERR
|
||||
#else
|
||||
#define FLASH_STM32_SR_MISERR 0
|
||||
#endif
|
||||
|
||||
#if defined(FLASH_FLAG_FASTERR)
|
||||
#define FLASH_STM32_SR_FASTERR FLASH_FLAG_FASTERR
|
||||
#else
|
||||
#define FLASH_STM32_SR_FASTERR 0
|
||||
#endif
|
||||
|
||||
#if defined(FLASH_FLAG_RDERR)
|
||||
#define FLASH_STM32_SR_RDERR FLASH_FLAG_RDERR
|
||||
#else
|
||||
#define FLASH_STM32_SR_RDERR 0
|
||||
#endif
|
||||
|
||||
#if defined(FLASH_FLAG_PGPERR)
|
||||
#define FLASH_STM32_SR_PGPERR FLASH_FLAG_PGPERR
|
||||
#else
|
||||
#define FLASH_STM32_SR_PGPERR 0
|
||||
#endif
|
||||
|
||||
#endif /* !defined(CONFIG_SOC_SERIES_STM32G0X) */
|
||||
|
||||
#define FLASH_STM32_SR_ERRORS (FLASH_STM32_SR_OPERR | \
|
||||
FLASH_STM32_SR_PGERR | \
|
||||
FLASH_STM32_SR_PROGERR | \
|
||||
FLASH_STM32_SR_WRPERR | \
|
||||
FLASH_STM32_SR_PGAERR | \
|
||||
FLASH_STM32_SR_SIZERR | \
|
||||
FLASH_STM32_SR_PGSERR | \
|
||||
FLASH_STM32_SR_MISERR | \
|
||||
FLASH_STM32_SR_FASTERR | \
|
||||
FLASH_STM32_SR_RDERR | \
|
||||
FLASH_STM32_SR_PGPERR)
|
||||
|
||||
|
||||
#ifdef CONFIG_FLASH_PAGE_LAYOUT
|
||||
static inline bool flash_stm32_range_exists(const struct device *dev,
|
||||
off_t offset,
|
||||
|
||||
@@ -21,12 +21,30 @@ LOG_MODULE_REGISTER(LOG_DOMAIN);
|
||||
#include "flash_stm32.h"
|
||||
|
||||
|
||||
#define STM32G0X_PAGE_SHIFT 11
|
||||
/* FLASH_DBANK_SUPPORT is defined in the HAL for all G0Bx and G0C1 SoCs,
|
||||
* while only those with 256KiB and 512KiB Flash have two banks.
|
||||
*/
|
||||
#if defined(FLASH_DBANK_SUPPORT) && (CONFIG_FLASH_SIZE > (128))
|
||||
#define STM32G0_DBANK_SUPPORT
|
||||
#endif
|
||||
|
||||
#if defined(STM32G0_DBANK_SUPPORT)
|
||||
#define STM32G0_BANK_COUNT 2
|
||||
#define STM32G0_BANK2_START_PAGE_NR 256
|
||||
#else
|
||||
#define STM32G0_BANK_COUNT 1
|
||||
#endif
|
||||
|
||||
#define STM32G0_FLASH_SIZE (FLASH_SIZE)
|
||||
#define STM32G0_FLASH_PAGE_SIZE (FLASH_PAGE_SIZE)
|
||||
#define STM32G0_PAGES_PER_BANK \
|
||||
((STM32G0_FLASH_SIZE / STM32G0_FLASH_PAGE_SIZE) / STM32G0_BANK_COUNT)
|
||||
|
||||
/*
|
||||
* offset and len must be aligned on 8 for write,
|
||||
* positive and not beyond end of flash
|
||||
* On dual-bank SoCs memory accesses starting on the first bank and continuing
|
||||
* beyond the first bank into the second bank are allowed.
|
||||
*/
|
||||
bool flash_stm32_valid_range(const struct device *dev, off_t offset,
|
||||
uint32_t len,
|
||||
@@ -36,14 +54,6 @@ bool flash_stm32_valid_range(const struct device *dev, off_t offset,
|
||||
flash_stm32_range_exists(dev, offset, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* STM32G0xx devices can have up to 64 2K pages
|
||||
*/
|
||||
static unsigned int get_page(off_t offset)
|
||||
{
|
||||
return offset >> STM32G0X_PAGE_SHIFT;
|
||||
}
|
||||
|
||||
static inline void flush_cache(FLASH_TypeDef *regs)
|
||||
{
|
||||
if (regs->ACR & FLASH_ACR_ICEN) {
|
||||
@@ -101,11 +111,12 @@ static int write_dword(const struct device *dev, off_t offset, uint64_t val)
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int erase_page(const struct device *dev, unsigned int page)
|
||||
static int erase_page(const struct device *dev, unsigned int offset)
|
||||
{
|
||||
FLASH_TypeDef *regs = FLASH_STM32_REGS(dev);
|
||||
uint32_t tmp;
|
||||
int rc;
|
||||
int page;
|
||||
|
||||
/* if the control register is locked, do not fail silently */
|
||||
if (regs->CR & FLASH_CR_LOCK) {
|
||||
@@ -125,16 +136,32 @@ static int erase_page(const struct device *dev, unsigned int page)
|
||||
*/
|
||||
flush_cache(regs);
|
||||
|
||||
/* Set the PER bit and select the page you wish to erase */
|
||||
regs->CR |= FLASH_CR_PER;
|
||||
regs->CR &= ~FLASH_CR_PNB_Msk;
|
||||
regs->CR |= ((page % 256) << 3);
|
||||
|
||||
/* Set the STRT bit */
|
||||
regs->CR |= FLASH_CR_STRT;
|
||||
|
||||
/* flush the register write */
|
||||
tmp = regs->CR;
|
||||
page = offset / STM32G0_FLASH_PAGE_SIZE;
|
||||
|
||||
#if defined(STM32G0_DBANK_SUPPORT)
|
||||
bool swap_enabled = (regs->OPTR & FLASH_OPTR_nSWAP_BANK) == 0;
|
||||
|
||||
/* big page-nr w/o swap or small page-nr w/ swap indicate bank2 */
|
||||
if ((page >= STM32G0_PAGES_PER_BANK) != swap_enabled) {
|
||||
page = (page % STM32G0_PAGES_PER_BANK) + STM32G0_BANK2_START_PAGE_NR;
|
||||
tmp |= FLASH_CR_BKER;
|
||||
LOG_DBG("Erase page %d on bank 2", page);
|
||||
} else {
|
||||
page = page % STM32G0_PAGES_PER_BANK;
|
||||
tmp &= ~FLASH_CR_BKER;
|
||||
LOG_DBG("Erase page %d on bank 1", page);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set the PER bit and select the page you wish to erase */
|
||||
tmp |= FLASH_CR_PER;
|
||||
tmp &= ~FLASH_CR_PNB_Msk;
|
||||
tmp |= ((page << FLASH_CR_PNB_Pos) & FLASH_CR_PNB_Msk);
|
||||
|
||||
/* Set the STRT bit and write the reg */
|
||||
tmp |= FLASH_CR_STRT;
|
||||
regs->CR = tmp;
|
||||
|
||||
/* Wait for the BSY bit */
|
||||
rc = flash_stm32_wait_flash_idle(dev);
|
||||
@@ -148,11 +175,11 @@ int flash_stm32_block_erase_loop(const struct device *dev,
|
||||
unsigned int offset,
|
||||
unsigned int len)
|
||||
{
|
||||
int i, rc = 0;
|
||||
unsigned int addr = offset;
|
||||
int rc = 0;
|
||||
|
||||
i = get_page(offset);
|
||||
for (; i <= get_page(offset + len - 1) ; ++i) {
|
||||
rc = erase_page(dev, i);
|
||||
for (; addr <= offset + len - 1 ; addr += STM32G0_FLASH_PAGE_SIZE) {
|
||||
rc = erase_page(dev, addr);
|
||||
if (rc < 0) {
|
||||
break;
|
||||
}
|
||||
@@ -176,6 +203,16 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset,
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* The address space is always continuous, even though a subset of G0 SoCs has
|
||||
* two flash banks.
|
||||
* Only the "physical" flash page-NRs are not continuous on those SoCs.
|
||||
* As a result the page numbers used in the zephyr flash api differs
|
||||
* from the "physical" flash page number.
|
||||
* The first is equal to the address offset divided by the page size, while
|
||||
* "physical" pages are numbered starting with 0 on bank1 and 256 on bank2.
|
||||
* As a result only a single homogeneous flash page layout needs to be defined.
|
||||
*/
|
||||
void flash_stm32_page_layout(const struct device *dev,
|
||||
const struct flash_pages_layout **layout,
|
||||
size_t *layout_size)
|
||||
@@ -188,10 +225,24 @@ void flash_stm32_page_layout(const struct device *dev,
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
if (stm32g0_flash_layout.pages_count == 0) {
|
||||
stm32g0_flash_layout.pages_count = FLASH_SIZE / FLASH_PAGE_SIZE;
|
||||
stm32g0_flash_layout.pages_size = FLASH_PAGE_SIZE;
|
||||
stm32g0_flash_layout.pages_count =
|
||||
STM32G0_FLASH_SIZE / STM32G0_FLASH_PAGE_SIZE;
|
||||
stm32g0_flash_layout.pages_size = STM32G0_FLASH_PAGE_SIZE;
|
||||
}
|
||||
|
||||
*layout = &stm32g0_flash_layout;
|
||||
*layout_size = 1;
|
||||
}
|
||||
|
||||
/* Override weak function */
|
||||
int flash_stm32_check_configuration(void)
|
||||
{
|
||||
#if defined(STM32G0_DBANK_SUPPORT) && (CONFIG_FLASH_SIZE == 256)
|
||||
/* Single bank mode not supported on dual bank SoCs with 256kiB flash */
|
||||
if ((regs->OPTR & FLASH_OPTR_DUAL_BANK) == 0) {
|
||||
LOG_ERR("Single bank configuration not supported by the driver");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -410,7 +410,10 @@ static void sx126x_dio1_irq_work_handler(struct k_work *work)
|
||||
Radio.IrqProcess();
|
||||
}
|
||||
|
||||
sx126x_dio1_irq_enable(&dev_data);
|
||||
/* Re-enable the interrupt if we are not in sleep mode */
|
||||
if (dev_data.mode != MODE_SLEEP) {
|
||||
sx126x_dio1_irq_enable(&dev_data);
|
||||
}
|
||||
}
|
||||
|
||||
static int sx126x_lora_init(const struct device *dev)
|
||||
|
||||
@@ -241,8 +241,8 @@ static const struct mdm_control_pinconfig pinconfig[] = {
|
||||
#define MDM_SEND_OK_ENABLED 0
|
||||
#define MDM_SEND_OK_DISABLED 1
|
||||
|
||||
#define MDM_CMD_SEND_TIMEOUT K_SECONDS(5)
|
||||
#define MDM_IP_SEND_RX_TIMEOUT K_SECONDS(60)
|
||||
#define MDM_CMD_SEND_TIMEOUT K_SECONDS(6)
|
||||
#define MDM_IP_SEND_RX_TIMEOUT K_SECONDS(62)
|
||||
#define MDM_SOCK_NOTIF_DELAY K_MSEC(150)
|
||||
#define MDM_CMD_CONN_TIMEOUT K_SECONDS(31)
|
||||
|
||||
@@ -1317,7 +1317,7 @@ static int send_data(struct hl7800_socket *sock, struct net_pkt *pkt)
|
||||
/* Send EOF pattern to terminate data */
|
||||
k_sem_reset(&sock->sock_send_sem);
|
||||
mdm_receiver_send(&ictx.mdm_ctx, EOF_PATTERN, strlen(EOF_PATTERN));
|
||||
ret = k_sem_take(&sock->sock_send_sem, MDM_CMD_SEND_TIMEOUT);
|
||||
ret = k_sem_take(&sock->sock_send_sem, MDM_IP_SEND_RX_TIMEOUT);
|
||||
if (ret == 0) {
|
||||
ret = ictx.last_error;
|
||||
} else if (ret == -EAGAIN) {
|
||||
|
||||
@@ -130,8 +130,8 @@ static bool mux_is_active(struct modem_iface *iface)
|
||||
bool active = false;
|
||||
|
||||
#if defined(CONFIG_UART_MUX_DEVICE_NAME)
|
||||
const char *mux_name = CONFIG_UART_MUX_DEVICE_NAME;
|
||||
active = (mux_name == iface->dev->name);
|
||||
active = strncmp(CONFIG_UART_MUX_DEVICE_NAME, iface->dev->name,
|
||||
sizeof(CONFIG_UART_MUX_DEVICE_NAME) - 1) == 0;
|
||||
#endif /* CONFIG_UART_MUX_DEVICE_NAME */
|
||||
|
||||
return active;
|
||||
|
||||
@@ -186,7 +186,8 @@ static int uart_sam0_tx_halt(struct uart_sam0_dev_data *dev_data)
|
||||
|
||||
static void uart_sam0_tx_timeout(struct k_work *work)
|
||||
{
|
||||
struct uart_sam0_dev_data *dev_data = CONTAINER_OF(work,
|
||||
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
|
||||
struct uart_sam0_dev_data *dev_data = CONTAINER_OF(dwork,
|
||||
struct uart_sam0_dev_data, tx_timeout_work);
|
||||
|
||||
uart_sam0_tx_halt(dev_data);
|
||||
|
||||
@@ -51,6 +51,34 @@ LOG_MODULE_REGISTER(uart_stm32);
|
||||
#define UART_STRUCT(dev) \
|
||||
((USART_TypeDef *)(DEV_CFG(dev))->uconf.base)
|
||||
|
||||
#if HAS_LPUART_1
|
||||
#ifdef USART_PRESC_PRESCALER
|
||||
uint32_t lpuartdiv_calc(const uint64_t clock_rate, const uint16_t presc_idx,
|
||||
const uint32_t baud_rate)
|
||||
{
|
||||
uint64_t lpuartdiv;
|
||||
|
||||
lpuartdiv = clock_rate / LPUART_PRESCALER_TAB[presc_idx];
|
||||
lpuartdiv *= LPUART_LPUARTDIV_FREQ_MUL;
|
||||
lpuartdiv += baud_rate / 2;
|
||||
lpuartdiv /= baud_rate;
|
||||
|
||||
return (uint32_t)lpuartdiv;
|
||||
}
|
||||
#else
|
||||
uint32_t lpuartdiv_calc(const uint64_t clock_rate, const uint32_t baud_rate)
|
||||
{
|
||||
uint64_t lpuartdiv;
|
||||
|
||||
lpuartdiv = clock_rate * LPUART_LPUARTDIV_FREQ_MUL;
|
||||
lpuartdiv += baud_rate / 2;
|
||||
lpuartdiv /= baud_rate;
|
||||
|
||||
return (uint32_t)lpuartdiv;
|
||||
}
|
||||
#endif /* USART_PRESC_PRESCALER */
|
||||
#endif /* HAS_LPUART_1 */
|
||||
|
||||
#define TIMEOUT 1000
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
@@ -92,13 +120,39 @@ static inline void uart_stm32_set_baudrate(const struct device *dev,
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#if HAS_LPUART_1
|
||||
if (IS_LPUART_INSTANCE(UartInstance)) {
|
||||
uint32_t lpuartdiv;
|
||||
#ifdef USART_PRESC_PRESCALER
|
||||
uint8_t presc_idx;
|
||||
uint32_t presc_val;
|
||||
|
||||
for (presc_idx = 0; presc_idx < ARRAY_SIZE(LPUART_PRESCALER_TAB); presc_idx++) {
|
||||
lpuartdiv = lpuartdiv_calc(clock_rate, presc_idx, baud_rate);
|
||||
if (lpuartdiv >= LPUART_BRR_MIN_VALUE && lpuartdiv <= LPUART_BRR_MASK) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (presc_idx == ARRAY_SIZE(LPUART_PRESCALER_TAB)) {
|
||||
LOG_ERR("Unable to set %s to %d", dev->name, baud_rate);
|
||||
return;
|
||||
}
|
||||
|
||||
presc_val = presc_idx << USART_PRESC_PRESCALER_Pos;
|
||||
|
||||
LL_LPUART_SetPrescaler(UartInstance, presc_val);
|
||||
#else
|
||||
lpuartdiv = lpuartdiv_calc(clock_rate, baud_rate);
|
||||
if (lpuartdiv < LPUART_BRR_MIN_VALUE || lpuartdiv > LPUART_BRR_MASK) {
|
||||
LOG_ERR("Unable to set %s to %d", dev->name, baud_rate);
|
||||
return;
|
||||
}
|
||||
#endif /* USART_PRESC_PRESCALER */
|
||||
LL_LPUART_SetBaudRate(UartInstance,
|
||||
clock_rate,
|
||||
#ifdef USART_PRESC_PRESCALER
|
||||
LL_USART_PRESCALER_DIV1,
|
||||
presc_val,
|
||||
#endif
|
||||
baud_rate);
|
||||
} else {
|
||||
@@ -473,15 +527,32 @@ static void uart_stm32_poll_out(const struct device *dev,
|
||||
unsigned char c)
|
||||
{
|
||||
USART_TypeDef *UartInstance = UART_STRUCT(dev);
|
||||
#ifdef CONFIG_PM
|
||||
struct uart_stm32_data *data = DEV_DATA(dev);
|
||||
#endif
|
||||
int key;
|
||||
|
||||
/* Wait for TXE flag to be raised */
|
||||
while (!LL_USART_IsActiveFlag_TXE(UartInstance)) {
|
||||
/* Wait for TXE flag to be raised
|
||||
* When TXE flag is raised, we lock interrupts to prevent interrupts (notably that of usart)
|
||||
* or thread switch. Then, we can safely send our character. The character sent will be
|
||||
* interlaced with the characters potentially send with interrupt transmission API
|
||||
*/
|
||||
while (1) {
|
||||
if (LL_USART_IsActiveFlag_TXE(UartInstance)) {
|
||||
key = irq_lock();
|
||||
if (LL_USART_IsActiveFlag_TXE(UartInstance)) {
|
||||
break;
|
||||
}
|
||||
irq_unlock(key);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
struct uart_stm32_data *data = DEV_DATA(dev);
|
||||
|
||||
if (!data->tx_poll_stream_on) {
|
||||
/* If an interrupt transmission is in progress, the pm constraint is already managed by the
|
||||
* call of uart_stm32_irq_tx_[en|dis]able
|
||||
*/
|
||||
if (!data->tx_poll_stream_on && !data->tx_int_stream_on) {
|
||||
data->tx_poll_stream_on = true;
|
||||
|
||||
/* Don't allow system to suspend until stream
|
||||
@@ -497,6 +568,7 @@ static void uart_stm32_poll_out(const struct device *dev,
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
LL_USART_TransmitData8(UartInstance, (uint8_t)c);
|
||||
irq_unlock(key);
|
||||
}
|
||||
|
||||
static int uart_stm32_err_check(const struct device *dev)
|
||||
@@ -520,6 +592,16 @@ static int uart_stm32_err_check(const struct device *dev)
|
||||
err |= UART_ERROR_FRAMING;
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_SOC_SERIES_STM32F0X) || defined(USART_LIN_SUPPORT)
|
||||
if (LL_USART_IsActiveFlag_LBD(UartInstance)) {
|
||||
err |= UART_BREAK;
|
||||
}
|
||||
|
||||
if (err & UART_BREAK) {
|
||||
LL_USART_ClearFlag_LBD(UartInstance);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (err & UART_ERROR_OVERRUN) {
|
||||
LL_USART_ClearFlag_ORE(UartInstance);
|
||||
}
|
||||
@@ -531,7 +613,6 @@ static int uart_stm32_err_check(const struct device *dev)
|
||||
if (err & UART_ERROR_FRAMING) {
|
||||
LL_USART_ClearFlag_FE(UartInstance);
|
||||
}
|
||||
|
||||
/* Clear noise error as well,
|
||||
* it is not represented by the errors enum
|
||||
*/
|
||||
@@ -556,6 +637,14 @@ static int uart_stm32_fifo_fill(const struct device *dev,
|
||||
{
|
||||
USART_TypeDef *UartInstance = UART_STRUCT(dev);
|
||||
uint8_t num_tx = 0U;
|
||||
int key;
|
||||
|
||||
if (!LL_USART_IsActiveFlag_TXE(UartInstance)) {
|
||||
return num_tx;
|
||||
}
|
||||
|
||||
/* Lock interrupts to prevent nested interrupts or thread switch */
|
||||
key = irq_lock();
|
||||
|
||||
while ((size - num_tx > 0) &&
|
||||
LL_USART_IsActiveFlag_TXE(UartInstance)) {
|
||||
@@ -565,6 +654,8 @@ static int uart_stm32_fifo_fill(const struct device *dev,
|
||||
LL_USART_TransmitData8(UartInstance, tx_data[num_tx++]);
|
||||
}
|
||||
|
||||
irq_unlock(key);
|
||||
|
||||
return num_tx;
|
||||
}
|
||||
|
||||
@@ -593,25 +684,44 @@ static int uart_stm32_fifo_read(const struct device *dev, uint8_t *rx_data,
|
||||
static void uart_stm32_irq_tx_enable(const struct device *dev)
|
||||
{
|
||||
USART_TypeDef *UartInstance = UART_STRUCT(dev);
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
struct uart_stm32_data *data = DEV_DATA(dev);
|
||||
int key;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
key = irq_lock();
|
||||
data->tx_poll_stream_on = false;
|
||||
data->tx_int_stream_on = true;
|
||||
uart_stm32_pm_constraint_set(dev);
|
||||
#endif
|
||||
LL_USART_EnableIT_TC(UartInstance);
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
irq_unlock(key);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void uart_stm32_irq_tx_disable(const struct device *dev)
|
||||
{
|
||||
USART_TypeDef *UartInstance = UART_STRUCT(dev);
|
||||
#ifdef CONFIG_PM
|
||||
struct uart_stm32_data *data = DEV_DATA(dev);
|
||||
int key;
|
||||
|
||||
key = irq_lock();
|
||||
#endif
|
||||
|
||||
LL_USART_DisableIT_TC(UartInstance);
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
data->tx_int_stream_on = false;
|
||||
uart_stm32_pm_constraint_release(dev);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
irq_unlock(key);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int uart_stm32_irq_tx_ready(const struct device *dev)
|
||||
@@ -1234,7 +1344,8 @@ static int uart_stm32_async_tx_abort(const struct device *dev)
|
||||
|
||||
static void uart_stm32_async_rx_timeout(struct k_work *work)
|
||||
{
|
||||
struct uart_dma_stream *rx_stream = CONTAINER_OF(work,
|
||||
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
|
||||
struct uart_dma_stream *rx_stream = CONTAINER_OF(dwork,
|
||||
struct uart_dma_stream, timeout_work);
|
||||
struct uart_stm32_data *data = CONTAINER_OF(rx_stream,
|
||||
struct uart_stm32_data, dma_rx);
|
||||
@@ -1251,7 +1362,8 @@ static void uart_stm32_async_rx_timeout(struct k_work *work)
|
||||
|
||||
static void uart_stm32_async_tx_timeout(struct k_work *work)
|
||||
{
|
||||
struct uart_dma_stream *tx_stream = CONTAINER_OF(work,
|
||||
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
|
||||
struct uart_dma_stream *tx_stream = CONTAINER_OF(dwork,
|
||||
struct uart_dma_stream, timeout_work);
|
||||
struct uart_stm32_data *data = CONTAINER_OF(tx_stream,
|
||||
struct uart_stm32_data, dma_tx);
|
||||
|
||||
@@ -74,6 +74,7 @@ struct uart_stm32_data {
|
||||
#endif
|
||||
#ifdef CONFIG_PM
|
||||
bool tx_poll_stream_on;
|
||||
bool tx_int_stream_on;
|
||||
bool pm_constraint_on;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -288,8 +288,10 @@ static int spi_nrfx_pm_control(const struct device *dev,
|
||||
break;
|
||||
|
||||
case PM_DEVICE_ACTION_SUSPEND:
|
||||
nrfx_spi_uninit(&config->spi);
|
||||
data->initialized = false;
|
||||
if (data->initialized) {
|
||||
nrfx_spi_uninit(&config->spi);
|
||||
data->initialized = false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -345,8 +345,10 @@ static int spim_nrfx_pm_control(const struct device *dev,
|
||||
break;
|
||||
|
||||
case PM_DEVICE_ACTION_SUSPEND:
|
||||
nrfx_spim_uninit(&config->spim);
|
||||
data->initialized = false;
|
||||
if (data->initialized) {
|
||||
nrfx_spim_uninit(&config->spim);
|
||||
data->initialized = false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT qemu_ivshmem
|
||||
|
||||
#define LOG_LEVEL CONFIG_IVSHMEM_LOG_LEVEL
|
||||
#include <logging/log.h>
|
||||
LOG_MODULE_REGISTER(ivshmem);
|
||||
@@ -223,25 +225,42 @@ static const struct ivshmem_driver_api ivshmem_api = {
|
||||
static int ivshmem_init(const struct device *dev)
|
||||
{
|
||||
struct ivshmem *data = dev->data;
|
||||
static bool bdf_lookup_done;
|
||||
|
||||
data->bdf = pcie_bdf_lookup(PCIE_ID(IVSHMEM_VENDOR_ID,
|
||||
IVSHMEM_DEVICE_ID));
|
||||
if (data->bdf == PCIE_BDF_NONE) {
|
||||
LOG_WRN("ivshmem device not found");
|
||||
if ((data->bdf == PCIE_BDF_NONE) && bdf_lookup_done) {
|
||||
LOG_ERR("One instance of ivshmem with pcie_bdf_lookup() already initialized.\n"
|
||||
"Using more than one with PCIE_BDF_NONE parameter might conflict\n"
|
||||
"with already initialized instances.");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if ((data->bdf == PCIE_BDF_NONE) && !bdf_lookup_done) {
|
||||
if (data->dev_ven_id) {
|
||||
data->bdf = pcie_bdf_lookup(data->dev_ven_id);
|
||||
} else {
|
||||
data->bdf = pcie_bdf_lookup(PCIE_ID(IVSHMEM_VENDOR_ID, IVSHMEM_DEVICE_ID));
|
||||
}
|
||||
if (data->bdf == PCIE_BDF_NONE) {
|
||||
LOG_WRN("ivshmem device not found");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
}
|
||||
LOG_DBG("ivshmem found at bdf 0x%x", data->bdf);
|
||||
bdf_lookup_done = true;
|
||||
|
||||
if (!ivshmem_configure(dev)) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct ivshmem ivshmem_data;
|
||||
#define IVSHMEM_DEVICE_INIT(n) \
|
||||
static struct ivshmem ivshmem_data_##n = { \
|
||||
.bdf = DT_INST_REG_ADDR_BY_IDX(n, 0), \
|
||||
.dev_ven_id = DT_INST_REG_SIZE_BY_IDX(n, 0) \
|
||||
}; \
|
||||
DEVICE_DT_INST_DEFINE(n, &ivshmem_init, NULL, \
|
||||
&ivshmem_data_##n, NULL, \
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
&ivshmem_api);
|
||||
|
||||
DEVICE_DEFINE(ivshmem, CONFIG_IVSHMEM_DEV_NAME,
|
||||
ivshmem_init, NULL, &ivshmem_data, NULL,
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &ivshmem_api);
|
||||
DT_INST_FOREACH_STATUS_OKAY(IVSHMEM_DEVICE_INIT)
|
||||
|
||||
@@ -25,6 +25,7 @@ struct ivshmem_param {
|
||||
struct ivshmem {
|
||||
DEVICE_MMIO_RAM;
|
||||
pcie_bdf_t bdf;
|
||||
uint32_t dev_ven_id;
|
||||
uintptr_t shmem;
|
||||
size_t size;
|
||||
#ifdef CONFIG_IVSHMEM_DOORBELL
|
||||
|
||||
@@ -83,6 +83,8 @@ static int iwdg_stm32_setup(const struct device *dev, uint8_t options)
|
||||
if (options & WDT_OPT_PAUSE_HALTED_BY_DBG) {
|
||||
#if defined(CONFIG_SOC_SERIES_STM32F0X)
|
||||
LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_DBGMCU);
|
||||
#elif defined(CONFIG_SOC_SERIES_STM32G0X)
|
||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_DBGMCU);
|
||||
#elif defined(CONFIG_SOC_SERIES_STM32L0X)
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_DBGMCU);
|
||||
#endif
|
||||
|
||||
@@ -418,7 +418,8 @@ MODEM_CMD_DEFINE(on_cmd_cipsta)
|
||||
|
||||
static void esp_ip_addr_work(struct k_work *work)
|
||||
{
|
||||
struct esp_data *dev = CONTAINER_OF(work, struct esp_data,
|
||||
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
|
||||
struct esp_data *dev = CONTAINER_OF(dwork, struct esp_data,
|
||||
ip_addr_work);
|
||||
int ret;
|
||||
|
||||
|
||||
@@ -169,6 +169,15 @@ void esp_socket_rx(struct esp_socket *sock, struct net_buf *buf,
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NET_SOCKETS
|
||||
/* We need to claim the net_context mutex here so that the ordering of
|
||||
* net_context and socket mutex claims matches the TX code path. Failure
|
||||
* to do so can lead to deadlocks.
|
||||
*/
|
||||
if (sock->context->cond.lock) {
|
||||
k_mutex_lock(sock->context->cond.lock, K_FOREVER);
|
||||
}
|
||||
#endif /* CONFIG_NET_SOCKETS */
|
||||
k_mutex_lock(&sock->lock, K_FOREVER);
|
||||
if (sock->recv_cb) {
|
||||
sock->recv_cb(sock->context, pkt, NULL, NULL,
|
||||
@@ -179,6 +188,11 @@ void esp_socket_rx(struct esp_socket *sock, struct net_buf *buf,
|
||||
net_pkt_unref(pkt);
|
||||
}
|
||||
k_mutex_unlock(&sock->lock);
|
||||
#ifdef CONFIG_NET_SOCKETS
|
||||
if (sock->context->cond.lock) {
|
||||
k_mutex_unlock(sock->context->cond.lock);
|
||||
}
|
||||
#endif /* CONFIG_NET_SOCKETS */
|
||||
}
|
||||
|
||||
void esp_socket_close(struct esp_socket *sock)
|
||||
|
||||
@@ -91,10 +91,11 @@ static void eswifi_off_read_work(struct k_work *work)
|
||||
int next_timeout_ms = 100;
|
||||
int err, len;
|
||||
char *data;
|
||||
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
|
||||
|
||||
LOG_DBG("");
|
||||
|
||||
socket = CONTAINER_OF(work, struct eswifi_off_socket, read_work);
|
||||
socket = CONTAINER_OF(dwork, struct eswifi_off_socket, read_work);
|
||||
eswifi = eswifi_socket_to_dev(socket);
|
||||
|
||||
eswifi_lock(eswifi);
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
clk_lsi: clk-lsi {
|
||||
#clock-cells = <0>;
|
||||
compatible = "fixed-clock";
|
||||
clock-frequency = <DT_FREQ_K(32)>;
|
||||
clock-frequency = <DT_FREQ_K(37)>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
||||
8
dts/bindings/virtualization/qemu,ivshmem.yaml
Normal file
8
dts/bindings/virtualization/qemu,ivshmem.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
# Copyright (c) 2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
description: ivShMem device properties
|
||||
|
||||
compatible: "qemu,ivshmem"
|
||||
|
||||
include: base.yaml
|
||||
@@ -56,6 +56,7 @@
|
||||
MAKE_REG_HELPER(cntfrq_el0);
|
||||
MAKE_REG_HELPER(cnthctl_el2);
|
||||
MAKE_REG_HELPER(cnthp_ctl_el2);
|
||||
MAKE_REG_HELPER(cnthps_ctl_el2);
|
||||
MAKE_REG_HELPER(cntv_ctl_el0)
|
||||
MAKE_REG_HELPER(cntv_cval_el0)
|
||||
MAKE_REG_HELPER(cntvct_el0);
|
||||
|
||||
@@ -304,7 +304,7 @@ GROUP_START(ITCM)
|
||||
} GROUP_LINK_IN(ITCM AT> ROMABLE_REGION)
|
||||
|
||||
__itcm_size = __itcm_end - __itcm_start;
|
||||
__itcm_rom_start = LOADADDR(_ITCM_SECTION_NAME);
|
||||
__itcm_load_start = LOADADDR(_ITCM_SECTION_NAME);
|
||||
|
||||
GROUP_END(ITCM)
|
||||
#endif
|
||||
@@ -339,7 +339,7 @@ GROUP_START(DTCM)
|
||||
|
||||
__dtcm_end = .;
|
||||
|
||||
__dtcm_data_rom_start = LOADADDR(_DTCM_DATA_SECTION_NAME);
|
||||
__dtcm_data_load_start = LOADADDR(_DTCM_DATA_SECTION_NAME);
|
||||
|
||||
GROUP_END(DTCM)
|
||||
#endif
|
||||
|
||||
32
include/arch/x86/cpuid.h
Normal file
32
include/arch/x86/cpuid.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Intel Corp.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_ARCH_X86_CPUID_H_
|
||||
#define ZEPHYR_INCLUDE_ARCH_X86_CPUID_H_
|
||||
|
||||
#ifndef _ASMLANGUAGE
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CPUID_BASIC_INFO_1 0x01
|
||||
#define CPUID_EXTENDED_FEATURES_LVL 0x07
|
||||
#define CPUID_EXTENDED_TOPOLOGY_ENUMERATION 0x0B
|
||||
#define CPUID_EXTENDED_TOPOLOGY_ENUMERATION_V2 0x1F
|
||||
|
||||
/* Bits to check in CPUID extended features */
|
||||
#define CPUID_SPEC_CTRL_SSBD BIT(31)
|
||||
#define CPUID_SPEC_CTRL_IBRS BIT(26)
|
||||
|
||||
uint32_t z_x86_cpuid_extended_features(void);
|
||||
|
||||
uint8_t z_x86_cpuid_get_current_physical_apic_id(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _ASMLANGUAGE */
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_ARCH_X86_CPUID_H_ */
|
||||
@@ -1599,6 +1599,13 @@ struct bt_gatt_subscribe_params {
|
||||
#endif /* CONFIG_BT_GATT_AUTO_DISCOVER_CCC */
|
||||
/** Subscribe value */
|
||||
uint16_t value;
|
||||
#if defined(CONFIG_BT_SMP)
|
||||
/** Minimum required security for received notification. Notifications
|
||||
* and indications received over a connection with a lower security
|
||||
* level are silently discarded.
|
||||
*/
|
||||
bt_security_t min_security;
|
||||
#endif
|
||||
/** Subscription flags */
|
||||
ATOMIC_DEFINE(flags, BT_GATT_SUBSCRIBE_NUM_FLAGS);
|
||||
|
||||
|
||||
@@ -302,10 +302,10 @@ struct can_timing {
|
||||
* @typedef can_tx_callback_t
|
||||
* @brief Define the application callback handler function signature
|
||||
*
|
||||
* @param error_flags status of the performed send operation
|
||||
* @param error status of the performed send operation
|
||||
* @param arg argument that was passed when the message was sent
|
||||
*/
|
||||
typedef void (*can_tx_callback_t)(uint32_t error_flags, void *arg);
|
||||
typedef void (*can_tx_callback_t)(int error, void *arg);
|
||||
|
||||
/**
|
||||
* @typedef can_rx_callback_t
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
#endif
|
||||
|
||||
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32f1_pll_clock, okay)
|
||||
#define STM32_PLL_XTPRE DT_PROP(DT_NODELABEL(pll), xtre)
|
||||
#define STM32_PLL_XTPRE DT_PROP(DT_NODELABEL(pll), xtpre)
|
||||
#define STM32_PLL_MULTIPLIER DT_PROP(DT_NODELABEL(pll), mul)
|
||||
#elif DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32f0_pll_clock, okay) || \
|
||||
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32f100_pll_clock, okay) || \
|
||||
@@ -269,6 +269,7 @@
|
||||
#define STM32_PLL_SRC_MSI DT_SAME_NODE(DT_PLL_CLOCKS_CTRL, DT_NODELABEL(clk_msi))
|
||||
#define STM32_PLL_SRC_MSIS DT_SAME_NODE(DT_PLL_CLOCKS_CTRL, DT_NODELABEL(clk_msis))
|
||||
#define STM32_PLL_SRC_HSI DT_SAME_NODE(DT_PLL_CLOCKS_CTRL, DT_NODELABEL(clk_hsi))
|
||||
#define STM32_PLL_SRC_CSI DT_SAME_NODE(DT_PLL_CLOCKS_CTRL, DT_NODELABEL(clk_csi))
|
||||
#define STM32_PLL_SRC_HSE DT_SAME_NODE(DT_PLL_CLOCKS_CTRL, DT_NODELABEL(clk_hse))
|
||||
#define STM32_PLL_SRC_PLL2 DT_SAME_NODE(DT_PLL_CLOCKS_CTRL, DT_NODELABEL(pll2))
|
||||
#else
|
||||
|
||||
@@ -256,18 +256,16 @@ extern "C" {
|
||||
* @brief Writes an formatted string to the log.
|
||||
*
|
||||
* @details Conditionally compiled (see CONFIG_LOG_PRINTK). Function provides
|
||||
* printk functionality. It is inefficient compared to standard logging
|
||||
* because string formatting is performed in the call context and not deferred
|
||||
* to the log processing context (@ref log_process).
|
||||
* printk functionality.
|
||||
*
|
||||
* It is less efficient compared to standard logging because static packaging
|
||||
* cannot be used in v2. When v1 is used string formatting is performed in the
|
||||
* call context and not deferred to the log processing context (@ref log_process).
|
||||
*
|
||||
* @param fmt Formatted string to output.
|
||||
* @param ap Variable parameters.
|
||||
*/
|
||||
void z_log_printk(const char *fmt, va_list ap);
|
||||
static inline void log_printk(const char *fmt, va_list ap)
|
||||
{
|
||||
z_log_printk(fmt, ap);
|
||||
}
|
||||
void z_log_vprintk(const char *fmt, va_list ap);
|
||||
|
||||
/** @brief Copy transient string to a buffer from internal, logger pool.
|
||||
*
|
||||
|
||||
@@ -737,8 +737,12 @@ uint32_t log_get_strdup_pool_utilization(void);
|
||||
uint32_t log_get_strdup_longest_string(void);
|
||||
|
||||
/** @brief Indicate to the log core that one log message has been dropped.
|
||||
*
|
||||
* @param buffered True if dropped message was already buffered and it is being
|
||||
* dropped to free space for another message. False if message is being dropped
|
||||
* because allocation failed.
|
||||
*/
|
||||
void z_log_dropped(void);
|
||||
void z_log_dropped(bool buffered);
|
||||
|
||||
/** @brief Read and clear current drop indications counter.
|
||||
*
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
* | -------------- | ------------------------------------------------------- |
|
||||
* | 0x06 0x09 | Byte pair indicating the start of a packet. |
|
||||
* | 0x04 0x14 | Byte pair indicating the start of a continuation frame. |
|
||||
* | Packet length | The combined total length of the *unencoded* body. |
|
||||
* | Packet length | The combined total length of the *unencoded* body plus |
|
||||
* | | the final CRC (2 bytes). Length is in Big-Endian format.|
|
||||
* | Body | The actual SMP data (i.e., 8-byte header and CBOR |
|
||||
* | | key-value map). |
|
||||
* | CRC16 | A CRC16 of the *unencoded* body of the entire packet. |
|
||||
|
||||
@@ -109,7 +109,6 @@ void ZSOCK_FD_SET(int fd, zsock_fd_set *set);
|
||||
#ifdef CONFIG_NET_SOCKETS_POSIX_NAMES
|
||||
|
||||
#define fd_set zsock_fd_set
|
||||
#define timeval zsock_timeval
|
||||
#define FD_SETSIZE ZSOCK_FD_SETSIZE
|
||||
|
||||
static inline int select(int nfds, zsock_fd_set *readfds,
|
||||
|
||||
@@ -16,36 +16,37 @@
|
||||
|
||||
#include <zephyr/types.h>
|
||||
|
||||
#ifdef CONFIG_POSIX_API
|
||||
|
||||
#ifdef CONFIG_NEWLIB_LIBC
|
||||
|
||||
#include <newlib.h>
|
||||
|
||||
#ifdef __NEWLIB__
|
||||
#include <sys/_timeval.h>
|
||||
#else
|
||||
#else /* __NEWLIB__ */
|
||||
#include <sys/types.h>
|
||||
/* workaround for older Newlib 2.x, as it lacks sys/_timeval.h */
|
||||
struct timeval {
|
||||
time_t tv_sec;
|
||||
suseconds_t tv_usec;
|
||||
};
|
||||
#endif /* __NEWLIB__ */
|
||||
#endif /* CONFIG_POSIX_API */
|
||||
|
||||
#else /* CONFIG_NEWLIB_LIBC */
|
||||
|
||||
#ifdef CONFIG_ARCH_POSIX
|
||||
#include <bits/types/struct_timeval.h>
|
||||
#else
|
||||
#include <sys/_timeval.h>
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NEWLIB_LIBC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_POSIX_API
|
||||
/* Rely on the underlying libc definition */
|
||||
#ifdef __NEWLIB__
|
||||
#define zsock_timeval timeval
|
||||
#else
|
||||
/* workaround for older Newlib 2.x, as it lacks sys/_timeval.h */
|
||||
struct zsock_timeval {
|
||||
time_t tv_sec;
|
||||
suseconds_t tv_usec;
|
||||
};
|
||||
#endif /* __NEWLIB__ */
|
||||
#else
|
||||
struct zsock_timeval {
|
||||
/* Using longs, as many (?) implementations seem to use it. */
|
||||
long tv_sec;
|
||||
long tv_usec;
|
||||
};
|
||||
#endif /* CONFIG_POSIX_API */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ enum pm_device_action {
|
||||
* @brief Device PM info
|
||||
*/
|
||||
struct pm_device {
|
||||
#ifdef CONFIG_PM_DEVICE_RUNTIME
|
||||
/** Pointer to the device */
|
||||
const struct device *dev;
|
||||
/** Lock to synchronize the get/put operations */
|
||||
@@ -93,18 +94,28 @@ struct pm_device {
|
||||
/* Following are packed fields protected by #lock. */
|
||||
/** Device pm enable flag */
|
||||
bool enable : 1;
|
||||
/* Device PM status flags. */
|
||||
atomic_t flags;
|
||||
/** Device usage count */
|
||||
uint32_t usage;
|
||||
/** Device power state */
|
||||
enum pm_device_state state;
|
||||
/** Work object for asynchronous calls */
|
||||
struct k_work_delayable work;
|
||||
/** Event conditional var to listen to the sync request events */
|
||||
struct k_condvar condvar;
|
||||
#endif /* CONFIG_PM_DEVICE_RUNTIME */
|
||||
/* Device PM status flags. */
|
||||
atomic_t flags;
|
||||
/** Device power state */
|
||||
enum pm_device_state state;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PM_DEVICE_RUNTIME
|
||||
#define INIT_PM_DEVICE_RUNTIME(obj) \
|
||||
.usage = 0U, \
|
||||
.lock = Z_MUTEX_INITIALIZER(obj.lock), \
|
||||
.condvar = Z_CONDVAR_INITIALIZER(obj.condvar),
|
||||
#else
|
||||
#define INIT_PM_DEVICE_RUNTIME(obj)
|
||||
#endif /* CONFIG_PM_DEVICE_RUNTIME */
|
||||
|
||||
/**
|
||||
* @brief Utility macro to initialize #pm_device.
|
||||
*
|
||||
@@ -116,9 +127,7 @@ struct pm_device {
|
||||
*/
|
||||
#define Z_PM_DEVICE_INIT(obj, node_id) \
|
||||
{ \
|
||||
.usage = 0U, \
|
||||
.lock = Z_MUTEX_INITIALIZER(obj.lock), \
|
||||
.condvar = Z_CONDVAR_INITIALIZER(obj.condvar), \
|
||||
INIT_PM_DEVICE_RUNTIME(obj) \
|
||||
.state = PM_DEVICE_STATE_ACTIVE, \
|
||||
.flags = ATOMIC_INIT(COND_CODE_1( \
|
||||
DT_NODE_EXISTS(node_id), \
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Public interface for spinlocks
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_SPINLOCK_H_
|
||||
#define ZEPHYR_INCLUDE_SPINLOCK_H_
|
||||
|
||||
@@ -15,6 +21,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Spinlock APIs
|
||||
* @defgroup spinlock_apis Spinlock APIs
|
||||
* @ingroup kernel_apis
|
||||
* @{
|
||||
*/
|
||||
|
||||
struct z_spinlock_key {
|
||||
int key;
|
||||
};
|
||||
@@ -199,6 +212,8 @@ static ALWAYS_INLINE void k_spin_release(struct k_spinlock *l)
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -226,7 +226,7 @@ const union mpsc_pbuf_generic *mpsc_pbuf_claim(struct mpsc_pbuf_buffer *buffer);
|
||||
* @param packet Packet.
|
||||
*/
|
||||
void mpsc_pbuf_free(struct mpsc_pbuf_buffer *buffer,
|
||||
union mpsc_pbuf_generic *packet);
|
||||
const union mpsc_pbuf_generic *packet);
|
||||
|
||||
/** @brief Check if there are any message pending.
|
||||
*
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <inttypes.h>
|
||||
#if defined(CONFIG_LOG_PRINTK) && defined(CONFIG_LOG2)
|
||||
#include <logging/log.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -49,18 +46,8 @@ extern "C" {
|
||||
*/
|
||||
#ifdef CONFIG_PRINTK
|
||||
|
||||
#if defined(CONFIG_LOG_PRINTK) && defined(CONFIG_LOG2)
|
||||
#define printk(...) Z_LOG_PRINTK(__VA_ARGS__)
|
||||
static inline __printf_like(1, 0) void vprintk(const char *fmt, va_list ap)
|
||||
{
|
||||
z_log_msg2_runtime_vcreate(CONFIG_LOG_DOMAIN_ID, NULL,
|
||||
LOG_LEVEL_INTERNAL_RAW_STRING, NULL, 0,
|
||||
fmt, ap);
|
||||
}
|
||||
#else
|
||||
extern __printf_like(1, 2) void printk(const char *fmt, ...);
|
||||
extern __printf_like(1, 0) void vprintk(const char *fmt, va_list ap);
|
||||
#endif /* defined(CONFIG_LOG_PRINTK) && defined(CONFIG_LOG) */
|
||||
|
||||
#else
|
||||
static inline __printf_like(1, 2) void printk(const char *fmt, ...)
|
||||
|
||||
@@ -68,7 +68,7 @@ extern "C" {
|
||||
* inside usb data section in the RAM.
|
||||
*/
|
||||
#define USBD_CFG_DATA_DEFINE(p, name) \
|
||||
static __in_section(usb, data_##p, name) __used
|
||||
static __in_section(usb, data_##p, name) __used __aligned(4)
|
||||
|
||||
/*************************************************************************
|
||||
* USB configuration
|
||||
|
||||
@@ -348,7 +348,7 @@ static inline int z_vrfy_k_poll(struct k_poll_event *events,
|
||||
/* Validate the events buffer and make a copy of it in an
|
||||
* allocated kernel-side buffer.
|
||||
*/
|
||||
if (Z_SYSCALL_VERIFY(num_events >= 0U)) {
|
||||
if (Z_SYSCALL_VERIFY(num_events >= 0)) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -552,5 +552,12 @@ void *_sbrk_r(struct _reent *r, int count)
|
||||
|
||||
int _gettimeofday(struct timeval *__tp, void *__tzp)
|
||||
{
|
||||
#ifdef CONFIG_POSIX_API
|
||||
return gettimeofday(__tp, __tzp);
|
||||
#else
|
||||
/* Non-posix systems should not call gettimeofday() here as it will
|
||||
* result in a recursive call loop and result in a stack overflow.
|
||||
*/
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -224,21 +224,37 @@ int z_alloc_fd(void *obj, const struct fd_op_vtable *vtable)
|
||||
|
||||
ssize_t read(int fd, void *buf, size_t sz)
|
||||
{
|
||||
ssize_t res;
|
||||
|
||||
if (_check_fd(fd) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fdtable[fd].vtable->read(fdtable[fd].obj, buf, sz);
|
||||
(void)k_mutex_lock(&fdtable[fd].lock, K_FOREVER);
|
||||
|
||||
res = fdtable[fd].vtable->read(fdtable[fd].obj, buf, sz);
|
||||
|
||||
k_mutex_unlock(&fdtable[fd].lock);
|
||||
|
||||
return res;
|
||||
}
|
||||
FUNC_ALIAS(read, _read, ssize_t);
|
||||
|
||||
ssize_t write(int fd, const void *buf, size_t sz)
|
||||
{
|
||||
ssize_t res;
|
||||
|
||||
if (_check_fd(fd) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fdtable[fd].vtable->write(fdtable[fd].obj, buf, sz);
|
||||
(void)k_mutex_lock(&fdtable[fd].lock, K_FOREVER);
|
||||
|
||||
res = fdtable[fd].vtable->write(fdtable[fd].obj, buf, sz);
|
||||
|
||||
k_mutex_unlock(&fdtable[fd].lock);
|
||||
|
||||
return res;
|
||||
}
|
||||
FUNC_ALIAS(write, _write, ssize_t);
|
||||
|
||||
@@ -250,8 +266,12 @@ int close(int fd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
(void)k_mutex_lock(&fdtable[fd].lock, K_FOREVER);
|
||||
|
||||
res = fdtable[fd].vtable->close(fdtable[fd].obj);
|
||||
|
||||
k_mutex_unlock(&fdtable[fd].lock);
|
||||
|
||||
z_free_fd(fd);
|
||||
|
||||
return res;
|
||||
|
||||
@@ -444,18 +444,19 @@ const union mpsc_pbuf_generic *mpsc_pbuf_claim(struct mpsc_pbuf_buffer *buffer)
|
||||
}
|
||||
|
||||
void mpsc_pbuf_free(struct mpsc_pbuf_buffer *buffer,
|
||||
union mpsc_pbuf_generic *item)
|
||||
const union mpsc_pbuf_generic *item)
|
||||
{
|
||||
uint32_t wlen = buffer->get_wlen(item);
|
||||
k_spinlock_key_t key = k_spin_lock(&buffer->lock);
|
||||
union mpsc_pbuf_generic *witem = (union mpsc_pbuf_generic *)item;
|
||||
|
||||
item->hdr.valid = 0;
|
||||
witem->hdr.valid = 0;
|
||||
if (!(buffer->flags & MPSC_PBUF_MODE_OVERWRITE) ||
|
||||
((uint32_t *)item == &buffer->buf[buffer->rd_idx])) {
|
||||
item->hdr.busy = 0;
|
||||
witem->hdr.busy = 0;
|
||||
buffer->rd_idx = idx_inc(buffer, buffer->rd_idx, wlen);
|
||||
} else {
|
||||
item->skip.len = wlen;
|
||||
witem->skip.len = wlen;
|
||||
}
|
||||
MPSC_PBUF_DBG(buffer, "freed: %p ", item);
|
||||
|
||||
|
||||
@@ -22,8 +22,12 @@
|
||||
#include <sys/cbprintf.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(CONFIG_PRINTK_SYNC) && \
|
||||
!(defined(CONFIG_LOG_PRINTK) && defined(CONFIG_LOG2))
|
||||
/* Option present only when CONFIG_USERSPACE enabled. */
|
||||
#ifndef CONFIG_PRINTK_BUFFER_SIZE
|
||||
#define CONFIG_PRINTK_BUFFER_SIZE 0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PRINTK_SYNC)
|
||||
static struct k_spinlock lock;
|
||||
#endif
|
||||
|
||||
@@ -75,11 +79,7 @@ void *__printk_get_hook(void)
|
||||
{
|
||||
return _char_out;
|
||||
}
|
||||
#endif /* CONFIG_PRINTK */
|
||||
|
||||
#if defined(CONFIG_PRINTK) && \
|
||||
!(defined(CONFIG_LOG_PRINTK) && defined(CONFIG_LOG2))
|
||||
#ifdef CONFIG_USERSPACE
|
||||
struct buf_out_context {
|
||||
int count;
|
||||
unsigned int buf_count;
|
||||
@@ -104,7 +104,6 @@ static int buf_char_out(int c, void *ctx_p)
|
||||
|
||||
return c;
|
||||
}
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
struct out_context {
|
||||
int count;
|
||||
@@ -118,9 +117,13 @@ static int char_out(int c, void *ctx_p)
|
||||
return _char_out(c);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
void vprintk(const char *fmt, va_list ap)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_LOG_PRINTK)) {
|
||||
z_log_vprintk(fmt, ap);
|
||||
return;
|
||||
}
|
||||
|
||||
if (k_is_user_context()) {
|
||||
struct buf_out_context ctx = { 0 };
|
||||
|
||||
@@ -142,21 +145,6 @@ void vprintk(const char *fmt, va_list ap)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#else
|
||||
void vprintk(const char *fmt, va_list ap)
|
||||
{
|
||||
struct out_context ctx = { 0 };
|
||||
#ifdef CONFIG_PRINTK_SYNC
|
||||
k_spinlock_key_t key = k_spin_lock(&lock);
|
||||
#endif
|
||||
|
||||
cbvprintf(char_out, &ctx, fmt, ap);
|
||||
|
||||
#ifdef CONFIG_PRINTK_SYNC
|
||||
k_spin_unlock(&lock, key);
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
void z_impl_k_str_out(char *c, size_t n)
|
||||
{
|
||||
@@ -212,16 +200,11 @@ void printk(const char *fmt, ...)
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
if (IS_ENABLED(CONFIG_LOG_PRINTK)) {
|
||||
log_printk(fmt, ap);
|
||||
} else {
|
||||
vprintk(fmt, ap);
|
||||
}
|
||||
vprintk(fmt, ap);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
#endif /* defined(CONFIG_PRINTK) && \
|
||||
* !(defined(CONFIG_LOG_PRINTK) && defined(CONFIG_LOG2))
|
||||
*/
|
||||
#endif /* defined(CONFIG_PRINTK) */
|
||||
|
||||
struct str_context {
|
||||
char *str;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <posix/time.h>
|
||||
#include <posix/sys/time.h>
|
||||
#include <syscall_handler.h>
|
||||
#include <spinlock.h>
|
||||
|
||||
/*
|
||||
* `k_uptime_get` returns a timestamp based on an always increasing
|
||||
@@ -17,6 +18,7 @@
|
||||
* set from a real time clock, if such hardware is present.
|
||||
*/
|
||||
static struct timespec rt_clock_base;
|
||||
static struct k_spinlock rt_clock_base_lock;
|
||||
|
||||
/**
|
||||
* @brief Get clock time specified by clock_id.
|
||||
@@ -27,6 +29,7 @@ int z_impl_clock_gettime(clockid_t clock_id, struct timespec *ts)
|
||||
{
|
||||
uint64_t elapsed_nsecs;
|
||||
struct timespec base;
|
||||
k_spinlock_key_t key;
|
||||
|
||||
switch (clock_id) {
|
||||
case CLOCK_MONOTONIC:
|
||||
@@ -35,7 +38,9 @@ int z_impl_clock_gettime(clockid_t clock_id, struct timespec *ts)
|
||||
break;
|
||||
|
||||
case CLOCK_REALTIME:
|
||||
key = k_spin_lock(&rt_clock_base_lock);
|
||||
base = rt_clock_base;
|
||||
k_spin_unlock(&rt_clock_base_lock, key);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -77,6 +82,7 @@ int z_vrfy_clock_gettime(clockid_t clock_id, struct timespec *ts)
|
||||
int clock_settime(clockid_t clock_id, const struct timespec *tp)
|
||||
{
|
||||
struct timespec base;
|
||||
k_spinlock_key_t key;
|
||||
|
||||
if (clock_id != CLOCK_REALTIME) {
|
||||
errno = EINVAL;
|
||||
@@ -90,7 +96,9 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp)
|
||||
base.tv_sec = delta / NSEC_PER_SEC;
|
||||
base.tv_nsec = delta % NSEC_PER_SEC;
|
||||
|
||||
key = k_spin_lock(&rt_clock_base_lock);
|
||||
rt_clock_base = base;
|
||||
k_spin_unlock(&rt_clock_base_lock, key);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ static int cond_wait(pthread_cond_t *cv, pthread_mutex_t *mut,
|
||||
mut->lock_count = 0U;
|
||||
mut->owner = NULL;
|
||||
_ready_one_thread(&mut->wait_q);
|
||||
ret = z_pend_curr(&z_pthread_spinlock, key, &cv->wait_q, timeout);
|
||||
ret = z_sched_wait(&z_pthread_spinlock, key, &cv->wait_q, timeout, NULL);
|
||||
|
||||
/* FIXME: this extra lock (and the potential context switch it
|
||||
* can cause) could be optimized out. At the point of the
|
||||
@@ -39,37 +39,15 @@ static int cond_wait(pthread_cond_t *cv, pthread_mutex_t *mut,
|
||||
return ret == -EAGAIN ? ETIMEDOUT : ret;
|
||||
}
|
||||
|
||||
/* This implements a "fair" scheduling policy: at the end of a POSIX
|
||||
* thread call that might result in a change of the current maximum
|
||||
* priority thread, we always check and context switch if needed.
|
||||
* Note that there is significant dispute in the community over the
|
||||
* "right" way to do this and different systems do it differently by
|
||||
* default. Zephyr is an RTOS, so we choose latency over
|
||||
* throughput. See here for a good discussion of the broad issue:
|
||||
*
|
||||
* https://blog.mozilla.org/nfroyd/2017/03/29/on-mutex-performance-part-1/
|
||||
*/
|
||||
|
||||
int pthread_cond_signal(pthread_cond_t *cv)
|
||||
{
|
||||
k_spinlock_key_t key = k_spin_lock(&z_pthread_spinlock);
|
||||
|
||||
_ready_one_thread(&cv->wait_q);
|
||||
z_reschedule(&z_pthread_spinlock, key);
|
||||
|
||||
z_sched_wake(&cv->wait_q, 0, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_cond_broadcast(pthread_cond_t *cv)
|
||||
{
|
||||
k_spinlock_key_t key = k_spin_lock(&z_pthread_spinlock);
|
||||
|
||||
while (z_waitq_head(&cv->wait_q)) {
|
||||
_ready_one_thread(&cv->wait_q);
|
||||
}
|
||||
|
||||
z_reschedule(&z_pthread_spinlock, key);
|
||||
|
||||
z_sched_wake_all(&cv->wait_q, 0, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ static void canopen_rx_isr_callback(struct zcan_frame *msg, void *arg)
|
||||
buffer->pFunct(buffer->object, &rxMsg);
|
||||
}
|
||||
|
||||
static void canopen_tx_isr_callback(uint32_t error_flags, void *arg)
|
||||
static void canopen_tx_isr_callback(int error, void *arg)
|
||||
{
|
||||
CO_CANmodule_t *CANmodule = arg;
|
||||
|
||||
@@ -103,7 +103,7 @@ static void canopen_tx_isr_callback(uint32_t error_flags, void *arg)
|
||||
return;
|
||||
}
|
||||
|
||||
if (error_flags == CAN_TX_OK) {
|
||||
if (error == CAN_TX_OK) {
|
||||
CANmodule->first_tx_msg = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,13 +37,13 @@ struct can_bus_err_cnt current_err_cnt;
|
||||
|
||||
CAN_DEFINE_MSGQ(counter_msgq, 2);
|
||||
|
||||
void tx_irq_callback(uint32_t error_flags, void *arg)
|
||||
void tx_irq_callback(int error, void *arg)
|
||||
{
|
||||
char *sender = (char *)arg;
|
||||
|
||||
if (error_flags) {
|
||||
if (error != 0) {
|
||||
printk("Callback! error-code: %d\nSender: %s\n",
|
||||
error_flags, sender);
|
||||
error, sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user