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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ config ARM
select ARCH_IS_SET
select ARCH_SUPPORTS_COREDUMP if CPU_CORTEX_M
select ARCH_SUPPORTS_COREDUMP_THREADS if CPU_CORTEX_M
select ARCH_SUPPORTS_COREDUMP_STACK_PTR if CPU_CORTEX_M
# FIXME: current state of the code for all ARM requires this, but
# is really only necessary for Cortex-M with ARM MPU!
select GEN_PRIV_STACKS
Expand Down Expand Up @@ -695,6 +696,9 @@ config ARCH_SUPPORTS_COREDUMP_THREADS
config ARCH_SUPPORTS_COREDUMP_PRIV_STACKS
bool

config ARCH_SUPPORTS_COREDUMP_STACK_PTR
bool

config ARCH_SUPPORTS_ARCH_HW_INIT
bool

Expand Down
6 changes: 6 additions & 0 deletions arch/arm/core/cortex_m/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <string.h>
#include <zephyr/debug/coredump.h>
#include <zephyr/kernel/thread.h>

#define ARCH_HDR_VER 2

Expand Down Expand Up @@ -96,3 +97,8 @@ uint16_t arch_coredump_tgt_code_get(void)
{
return COREDUMP_TGT_ARM_CORTEX_M;
}

uintptr_t arch_coredump_stack_ptr_get(const struct k_thread *thread)
{
return (thread == _current) ? z_arm_coredump_fault_sp : thread->callee_saved.psp;
}
10 changes: 10 additions & 0 deletions doc/releases/release-notes-4.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ New APIs and options

* :kconfig:option:`CONFIG_NVME_PRP_PAGE_SIZE`

* Debug

* Core Dump

* :kconfig:option:`CONFIG_DEBUG_COREDUMP_THREAD_STACK_TOP`, enabled by default for ARM Cortex M when :kconfig:option:`CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_MIN` is selected.

* Other

* :kconfig:option:`CONFIG_LV_Z_COLOR_MONO_HW_INVERSION`

New Boards
**********

Expand Down
5 changes: 5 additions & 0 deletions kernel/include/kernel_arch_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,11 @@ void arch_coredump_info_dump(const struct arch_esf *esf);
*/
uint16_t arch_coredump_tgt_code_get(void);

/**
* @brief Get the stack pointer of the thread.
*/
uintptr_t arch_coredump_stack_ptr_get(const struct k_thread *thread);

#if defined(CONFIG_USERSPACE) || defined(__DOXYGEN__)

/**
Expand Down
19 changes: 14 additions & 5 deletions lib/hash/hash_func32_murmur3.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <stddef.h>
#include <stdint.h>
#include <zephyr/toolchain.h>
#include <zephyr/sys/util.h>

static inline uint32_t murmur_32_scramble(uint32_t k)
{
Expand All @@ -16,18 +18,25 @@
return k;
}

#define _LOOP(_GET) \
for (; n >= sizeof(uint32_t); n -= sizeof(uint32_t), str += sizeof(uint32_t)) { \
k = _GET; \
h ^= murmur_32_scramble(k); \
h = (h << 13) | (h >> 19); \
h = h * 5 + 0xe6546b64; \
}

Check notice on line 27 in lib/hash/hash_func32_murmur3.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

lib/hash/hash_func32_murmur3.c:27 -#define _LOOP(_GET) \ - for (; n >= sizeof(uint32_t); n -= sizeof(uint32_t), str += sizeof(uint32_t)) { \ - k = _GET; \ - h ^= murmur_32_scramble(k); \ - h = (h << 13) | (h >> 19); \ - h = h * 5 + 0xe6546b64; \ +#define _LOOP(_GET) \ + for (; n >= sizeof(uint32_t); n -= sizeof(uint32_t), str += sizeof(uint32_t)) { \ + k = _GET; \ + h ^= murmur_32_scramble(k); \ + h = (h << 13) | (h >> 19); \ + h = h * 5 + 0xe6546b64; \

Check notice on line 27 in lib/hash/hash_func32_murmur3.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

lib/hash/hash_func32_murmur3.c:27 -#define _LOOP(_GET) \ - for (; n >= sizeof(uint32_t); n -= sizeof(uint32_t), str += sizeof(uint32_t)) { \ - k = _GET; \ - h ^= murmur_32_scramble(k); \ - h = (h << 13) | (h >> 19); \ - h = h * 5 + 0xe6546b64; \ +#define _LOOP(_GET) \ + for (; n >= sizeof(uint32_t); n -= sizeof(uint32_t), str += sizeof(uint32_t)) { \ + k = _GET; \ + h ^= murmur_32_scramble(k); \ + h = (h << 13) | (h >> 19); \ + h = h * 5 + 0xe6546b64; \

uint32_t sys_hash32_murmur3(const char *str, size_t n)
{
uint32_t k;
/* seed of 0 */
uint32_t h = 0;
const size_t len = n;

for (; n >= sizeof(uint32_t); n -= sizeof(uint32_t), str += sizeof(uint32_t)) {
k = *(const uint32_t *)str;
h ^= murmur_32_scramble(k);
h = (h << 13) | (h >> 19);
h = h * 5 + 0xe6546b64;
if (IS_ALIGNED(str, sizeof(uint32_t))) {
_LOOP(*(const uint32_t *)str);
} else {
_LOOP(UNALIGNED_GET((const uint32_t *)str));
}

for (k = 0; n != 0; --n, ++str) {
Expand Down
4 changes: 4 additions & 0 deletions modules/lvgl/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ config LV_COLOR_16_SWAP
bool "Swap the 2 bytes of RGB565 color."
depends on LV_COLOR_DEPTH_16

config LV_Z_COLOR_MONO_HW_INVERSION
bool "Hardware pixel inversion (disables software pixel inversion)."
depends on LV_COLOR_DEPTH_1

config LV_Z_FLUSH_THREAD
bool "Flush LVGL frames in a separate thread"
help
Expand Down
8 changes: 8 additions & 0 deletions modules/lvgl/lvgl_display_mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,25 @@ static ALWAYS_INLINE void set_px_at_pos(uint8_t *dst_buf, uint32_t x, uint32_t y
}
}

#ifdef CONFIG_LV_Z_COLOR_MONO_HW_INVERSION
*buf |= BIT(bit);
#else
if (caps->current_pixel_format == PIXEL_FORMAT_MONO10) {
*buf |= BIT(bit);
} else {
*buf &= ~BIT(bit);
}
#endif
}

static void lvgl_transform_buffer(uint8_t **px_map, uint32_t width, uint32_t height,
const struct display_capabilities *caps)
{
#ifdef CONFIG_LV_Z_COLOR_MONO_HW_INVERSION
uint8_t clear_color = 0x00;
#else
uint8_t clear_color = caps->current_pixel_format == PIXEL_FORMAT_MONO10 ? 0x00 : 0xFF;
#endif

memset(mono_conv_buf, clear_color, mono_conv_buf_size);

Expand Down
23 changes: 23 additions & 0 deletions subsys/debug/coredump/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,27 @@ module = DEBUG_COREDUMP
module-str = coredump
source "subsys/logging/Kconfig.template.log_config"

config DEBUG_COREDUMP_THREAD_STACK_TOP
bool "Dump top of stack only"
default y if DEBUG_COREDUMP_MEMORY_DUMP_MIN
depends on DEBUG_COREDUMP_MEMORY_DUMP_MIN || \
DEBUG_COREDUMP_MEMORY_DUMP_THREADS
depends on ARCH_SUPPORTS_COREDUMP_STACK_PTR
help
This option enables dumping only the top portion of each thread's
stack, rather than the entire stack region. The top of the stack is
defined as the area from the stack pointer to the stack end, but the
size of this region can additionally be constrained using the
DEBUG_COREDUMP_THREAD_STACK_TOP_LIMIT option.

config DEBUG_COREDUMP_THREAD_STACK_TOP_LIMIT
int "Stack top size limit"
default -1
depends on DEBUG_COREDUMP_THREAD_STACK_TOP
help
See the description of the DEBUG_COREDUMP_THREAD_STACK_TOP option.
The value -1 indicates that there is no limit, meaning that the stack
is dumped till the end of its region.


endif # DEBUG_COREDUMP
45 changes: 38 additions & 7 deletions subsys/debug/coredump/coredump_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ static struct coredump_backend_api
#define DT_DRV_COMPAT zephyr_coredump
#endif

#if defined(CONFIG_DEBUG_COREDUMP_THREAD_STACK_TOP_LIMIT) && \
CONFIG_DEBUG_COREDUMP_THREAD_STACK_TOP_LIMIT > 0
#define STACK_TOP_LIMIT ((size_t)CONFIG_DEBUG_COREDUMP_THREAD_STACK_TOP_LIMIT)
#else
#define STACK_TOP_LIMIT SIZE_MAX
#endif

#if defined(CONFIG_DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK)
__weak void arch_coredump_priv_stack_dump(struct k_thread *thread)
{
Expand Down Expand Up @@ -70,10 +77,35 @@ static void dump_header(unsigned int reason)
backend_api->buffer_output((uint8_t *)&hdr, sizeof(hdr));
}

#if defined(CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_MIN) || \
#if defined(CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_MIN) || \
defined(CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_THREADS)

static inline void select_stack_region(const struct k_thread *thread, uintptr_t *start,
uintptr_t *end)
{
uintptr_t sp;

*start = thread->stack_info.start;
*end = thread->stack_info.start + thread->stack_info.size;

if (!IS_ENABLED(CONFIG_DEBUG_COREDUMP_THREAD_STACK_TOP)) {
return;
}

sp = arch_coredump_stack_ptr_get(thread);

if (IN_RANGE(sp, *start, *end)) {
/* Skip ahead to the stack pointer. */
*start = sp;
}

/* Make sure no more than STACK_TOP_LIMIT bytes of the stack are dumped. */
*end = *start + MIN((size_t)(*end - *start), STACK_TOP_LIMIT);
}

static void dump_thread(struct k_thread *thread)
{
uintptr_t start_addr;
uintptr_t end_addr;

/*
Expand All @@ -86,13 +118,12 @@ static void dump_thread(struct k_thread *thread)
return;
}

end_addr = POINTER_TO_UINT(thread) + sizeof(*thread);

coredump_memory_dump(POINTER_TO_UINT(thread), end_addr);

end_addr = thread->stack_info.start + thread->stack_info.size;
start_addr = POINTER_TO_UINT(thread);
end_addr = start_addr + sizeof(*thread);
coredump_memory_dump(start_addr, end_addr);

coredump_memory_dump(thread->stack_info.start, end_addr);
select_stack_region(thread, &start_addr, &end_addr);
coredump_memory_dump(start_addr, end_addr);

#if defined(CONFIG_DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK)
if ((thread->base.user_options & K_USER) == K_USER) {
Expand Down
Loading