Skip to content
Open
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
10 changes: 8 additions & 2 deletions multi/imxrt-multi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ NAME := imxrt-multi

LOCAL_PATH := $(call my-dir)

LOCAL_SRCS = imxrt-multi.c common.c uart.c gpio.c spi.c i2c.c fs.c posixsrv.c pct2075.c rtt.c
LOCAL_SRCS = imxrt-multi.c common.c uart.c gpio.c spi.c i2c.c fs.c posixsrv.c pct2075.c rtt.c coredumpsrv.c
ifneq ($(TARGET_SUBFAMILY), imxrt117x)
LOCAL_SRCS += trng.c
else
Expand All @@ -18,7 +18,13 @@ DEP_LIBS := libtty libklog libpseudodev i2c-common librtt
LIBS := libdummyfs libklog libpseudodev libposixsrv
LOCAL_HEADERS := imxrt-multi.h

# FIXME: adapt code to array-bounds checker
# FIXME: adapt code to array-bounds checker
LOCAL_CFLAGS := -Wno-array-bounds

ifeq ($(COREDUMP_DISABLE),1)
LOCAL_CFLAGS += -DBUILTIN_COREDUMPSRV=0
else
LIBS += libcoredumpsrv
endif

include $(binary.mk)
5 changes: 5 additions & 0 deletions multi/imxrt-multi/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,11 @@
#error "BUILTIN_POSIXSRV must have a value of 0, 1, or be undefined"
#endif

/* libcoredumpsrv */
#ifndef BUILTIN_COREDUMPSRV
#define BUILTIN_COREDUMPSRV 1
#endif


/* Pseudodev */

Expand Down
90 changes: 90 additions & 0 deletions multi/imxrt-multi/coredumpsrv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Phoenix-RTOS
*
* i.MX RT builtin coredump server (libcoredumpsrv)
*
* Copyright 2025 Phoenix Systems
* Author: Jakub Klimek
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#include "config.h"

#if BUILTIN_COREDUMPSRV

#include <coredump.h>
#include <sys/threads.h>

#ifndef COREDUMPSRV_PRIO
#define COREDUMPSRV_PRIO 4
#endif

#ifndef COREDUMP_MAX_THREADS
#define COREDUMP_MAX_THREADS 4
#endif

#ifndef COREDUMP_MAX_STACK_SIZE
#define COREDUMP_MAX_STACK_SIZE 0
#endif

#ifndef COREDUMP_MEM_SCOPE
#define COREDUMP_MEM_SCOPE COREDUMP_MEM_ALL_STACKS
#endif

#ifndef COREDUMP_FP_CONTEXT
#define COREDUMP_FP_CONTEXT 0
#endif

#ifndef COREDUMP_MAX_MEM_CHUNK
#define COREDUMP_MAX_MEM_CHUNK 0
#endif

#ifndef COREDUMP_PRINT
#define COREDUMP_PRINT 1
#endif

#ifndef COREDUMP_PRINT_SLEEP
#define COREDUMP_PRINT_SLEEP 10 * 1000 /* 10ms */
#endif

#ifndef COREDUMP_SAVEPATH
#define COREDUMP_SAVEPATH "/coredumps"
#endif

#ifndef COREDUMP_MAX_FILES
#define COREDUMP_MAX_FILES 0
#endif


static struct {
char stack[_PAGE_SIZE];
coredump_opts_t opts;
} coredumpsrv_common;


static void coredumpsrv_thr(void *arg)
{
coredumpsrv_common.opts = (coredump_opts_t) {
.maxThreads = COREDUMP_MAX_THREADS,
.maxStackSize = COREDUMP_MAX_STACK_SIZE,
.memScope = COREDUMP_MEM_SCOPE,
.fpContext = COREDUMP_FP_CONTEXT,
.maxMemChunk = COREDUMP_MAX_MEM_CHUNK,
.print = COREDUMP_PRINT,
.printSleep = COREDUMP_PRINT_SLEEP,
.savepath = COREDUMP_SAVEPATH,
.maxFiles = COREDUMP_MAX_FILES,
};
coredump_serverthr(&coredumpsrv_common.opts);
}


int coredumpsrv_start(void)
{
return beginthread(coredumpsrv_thr, COREDUMPSRV_PRIO, coredumpsrv_common.stack, sizeof(coredumpsrv_common.stack), NULL);
}

#endif
9 changes: 9 additions & 0 deletions multi/imxrt-multi/imxrt-multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,11 @@ extern int posixsrv_start(void);
#endif


#if BUILTIN_COREDUMPSRV
extern int coredumpsrv_start(void);
#endif


int main(void)
{
int i;
Expand Down Expand Up @@ -620,6 +625,10 @@ int main(void)
posixsrv_start();
#endif

#if BUILTIN_COREDUMPSRV
coredumpsrv_start();
#endif

#if PSEUDODEV
pseudo_init();
#endif
Expand Down
8 changes: 7 additions & 1 deletion multi/stm32l4-multi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LOCAL_PATH := $(call my-dir)

NAME := stm32l4-multi

LOCAL_SRCS = fs.c gpio.c i2c.c posixsrv.c rng.c rtc.c spi.c stm32l4-multi.c tty.c uart.c
LOCAL_SRCS = fs.c gpio.c i2c.c posixsrv.c rng.c rtc.c spi.c stm32l4-multi.c tty.c uart.c coredumpsrv.c
ifeq ($(TARGET_SUBFAMILY),stm32l4x6)
LOCAL_CFLAGS += -DMULTIDRV_STACKSZ=640
LOCAL_SRCS += adc_l4.c exti_l4.c flash.c rcc_l4.c
Expand All @@ -21,4 +21,10 @@ LOCAL_HEADERS := stm32l4-multi.h
DEP_LIBS := libstm32l4-multi libtty libklog
LIBS := libdummyfs libklog libposixsrv

ifeq ($(COREDUMP_DISABLE),1)
LOCAL_CFLAGS += -DBUILTIN_COREDUMPSRV=0
else
LIBS += libcoredumpsrv
endif

include $(binary.mk)
5 changes: 5 additions & 0 deletions multi/stm32l4-multi/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,5 +488,10 @@
#define BUILTIN_POSIXSRV 0
#endif

/* libcoredumpsrv */
#ifndef BUILTIN_COREDUMPSRV
#define BUILTIN_COREDUMPSRV 1
#endif


#endif
90 changes: 90 additions & 0 deletions multi/stm32l4-multi/coredumpsrv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Phoenix-RTOS
*
* STM32L4 builtin coredump server (libcoredumpsrv)
*
* Copyright 2025 Phoenix Systems
* Author: Jakub Klimek
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#include "config.h"

#if BUILTIN_COREDUMPSRV

#include <coredump.h>
#include <sys/threads.h>

#ifndef COREDUMPSRV_PRIO
#define COREDUMPSRV_PRIO 4
#endif

#ifndef COREDUMP_MAX_THREADS
#define COREDUMP_MAX_THREADS 4
#endif

#ifndef COREDUMP_MAX_STACK_SIZE
#define COREDUMP_MAX_STACK_SIZE 0
#endif

#ifndef COREDUMP_MEM_SCOPE
#define COREDUMP_MEM_SCOPE COREDUMP_MEM_ALL_STACKS
#endif

#ifndef COREDUMP_FP_CONTEXT
#define COREDUMP_FP_CONTEXT 0
#endif

#ifndef COREDUMP_MAX_MEM_CHUNK
#define COREDUMP_MAX_MEM_CHUNK 0
#endif

#ifndef COREDUMP_PRINT
#define COREDUMP_PRINT 1
#endif

#ifndef COREDUMP_PRINT_SLEEP
#define COREDUMP_PRINT_SLEEP 10 * 1000 /* 10ms */
#endif

#ifndef COREDUMP_SAVEPATH
#define COREDUMP_SAVEPATH "/coredumps"
#endif

#ifndef COREDUMP_MAX_FILES
#define COREDUMP_MAX_FILES 0
#endif


static struct {
char stack[_PAGE_SIZE];
coredump_opts_t opts;
} coredumpsrv_common;


static void coredumpsrv_thr(void *arg)
{
coredumpsrv_common.opts = (coredump_opts_t) {
.maxThreads = COREDUMP_MAX_THREADS,
.maxStackSize = COREDUMP_MAX_STACK_SIZE,
.memScope = COREDUMP_MEM_SCOPE,
.fpContext = COREDUMP_FP_CONTEXT,
.maxMemChunk = COREDUMP_MAX_MEM_CHUNK,
.print = COREDUMP_PRINT,
.printSleep = COREDUMP_PRINT_SLEEP,
.savepath = COREDUMP_SAVEPATH,
.maxFiles = COREDUMP_MAX_FILES,
};
coredump_serverthr(&coredumpsrv_common.opts);
}


int coredumpsrv_start(void)
{
return beginthread(coredumpsrv_thr, COREDUMPSRV_PRIO, coredumpsrv_common.stack, sizeof(coredumpsrv_common.stack), NULL);
}

#endif
9 changes: 9 additions & 0 deletions multi/stm32l4-multi/stm32l4-multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ extern int posixsrv_start(void);
#endif


#if BUILTIN_COREDUMPSRV
extern int coredumpsrv_start(void);
#endif


int main(void)
{
int i;
Expand Down Expand Up @@ -394,6 +399,10 @@ int main(void)
pwm_init();
#endif

#if BUILTIN_COREDUMPSRV
coredumpsrv_start();
#endif

/* Do this after klog init to keep shell from overtaking klog */

#if CONSOLE_IS_TTY
Expand Down
Loading