Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crashdump change to choice, add coredump to mtd support based on mtdout stream. #14997

Merged
merged 5 commits into from
Nov 29, 2024
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
8 changes: 4 additions & 4 deletions arch/renesas/src/rx65n/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ config RX65N_CMT0
config RX65N_CMT1
bool "CMT1"
default n
depends on BOARD_CRASHDUMP && RX65N_SBRAM && RX65N_SAVE_CRASHDUMP
depends on BOARD_CRASHDUMP_CUSTOM && RX65N_SBRAM && RX65N_SAVE_CRASHDUMP

config RX65N_CMT2
bool "CMT2"
Expand All @@ -170,7 +170,7 @@ config RX65N_IRQ_GROUP
config RX65N_SBRAM
bool "SBRAM"
default n
depends on BOARD_CRASHDUMP
depends on BOARD_CRASHDUMP_CUSTOM

config RX65N_SAVE_CRASHDUMP
bool "SBRAM Save Crashdump"
Expand Down Expand Up @@ -541,7 +541,7 @@ config RX65N_CMT0
config RX65N_CMT1
bool "CMT1"
default n
depends on BOARD_CRASHDUMP && RX65N_SBRAM && RX65N_SAVE_CRASHDUMP
depends on BOARD_CRASHDUMP_CUSTOM && RX65N_SBRAM && RX65N_SAVE_CRASHDUMP

config RX65N_CMT2
bool "CMT2"
Expand All @@ -562,7 +562,7 @@ config RX65N_IRQ_GROUP
config RX65N_SBRAM
bool "SBRAM"
default n
depends on BOARD_CRASHDUMP
depends on BOARD_CRASHDUMP_CUSTOM

config RX65N_SAVE_CRASHDUMP
bool "SBRAM Save Crashdump"
Expand Down
39 changes: 27 additions & 12 deletions boards/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4693,9 +4693,9 @@ source "boards/arm/nrf91/common/Kconfig"
endif
endif

config BOARD_CRASHDUMP
bool "Enable Board level logging of crash dumps"
default n
choice
prompt "BOARD crashdump method"
default BOARD_CRASHDUMP_NONE
---help---
If selected up_assert will call out to board_crashdump, in the case
of an assertion failure, prior to calling exit. Or in the
Expand All @@ -4712,36 +4712,51 @@ config BOARD_CRASHDUMP

config BOARD_COREDUMP_SYSLOG
bool "Enable Core dump to syslog"
default n
depends on COREDUMP
---help---
Enable put coredump to syslog when crash.

config BOARD_COREDUMP_BLKDEV
bool "Enable Core Dump to block device"
default n
depends on COREDUMP
---help---
Enable save coredump at block device when crash.
Enable save coredump to block device when crash.

config BOARD_COREDUMP_MTDDEV
bool "Enable Core Dump to mtd device"
depends on COREDUMP
---help---
Enable save coredump to mtd device when crash.

config BOARD_CRASHDUMP_CUSTOM
bool "Enable Core Dump with custom method"
---help---
Enable save coredump with custom method. only work with
board_crashdump api.

config BOARD_CRASHDUMP_NONE
bool "No Board level crash dump"

endchoice # BOARD crashdump method

config BOARD_COREDUMP_BLKDEV_PATH
string "Save Core Dump block device PATH"
depends on BOARD_COREDUMP_BLKDEV
config BOARD_COREDUMP_DEVPATH
string "Save Core Dump data with device PATH"
depends on BOARD_COREDUMP_BLKDEV || BOARD_COREDUMP_MTDDEV
---help---
Save coredump file block device path.
Save coredump file into block/mtd device path.

config BOARD_COREDUMP_FULL
bool "Core Dump all thread registers and stacks"
default y
depends on BOARD_COREDUMP_SYSLOG || BOARD_COREDUMP_BLKDEV
depends on !BOARD_CRASHDUMP_NONE
---help---
Enable to support for the dump all task registers and stacks.

config BOARD_COREDUMP_COMPRESSION
bool "Enable Core Dump compression"
default y
select LIBC_LZF
depends on BOARD_COREDUMP_SYSLOG || BOARD_COREDUMP_BLKDEV
depends on !BOARD_CRASHDUMP_NONE
---help---
Enable LZF compression algorithm for core dump content

Expand Down
2 changes: 1 addition & 1 deletion include/nuttx/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg);
*
****************************************************************************/

#ifdef CONFIG_BOARD_CRASHDUMP
#ifdef CONFIG_BOARD_CRASHDUMP_CUSTOM
struct tcb_s;
void board_crashdump(uintptr_t sp, FAR struct tcb_s *tcb,
FAR const char *filename, int lineno,
Expand Down
4 changes: 2 additions & 2 deletions include/nuttx/streams.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ struct lib_lzfoutstream_s
#ifndef CONFIG_DISABLE_MOUNTPOINT
struct lib_blkoutstream_s
{
struct lib_outstream_s common;
struct lib_sostream_s common;
FAR struct inode *inode;
struct geometry geo;
FAR unsigned char *cache;
Expand All @@ -303,7 +303,7 @@ struct lib_blkoutstream_s
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_MTD)
struct lib_mtdoutstream_s
{
struct lib_outstream_s common;
struct lib_sostream_s common;
FAR struct inode *inode;
struct mtd_geometry_s geo;
FAR unsigned char *cache;
Expand Down
77 changes: 74 additions & 3 deletions libs/libc/stream/lib_blkoutstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
* Name: blkoutstream_flush
****************************************************************************/

static int blkoutstream_flush(FAR struct lib_outstream_s *self)
static int blkoutstream_flush(FAR struct lib_sostream_s *self)
{
FAR struct lib_blkoutstream_s *stream =
(FAR struct lib_blkoutstream_s *)self;
Expand All @@ -61,11 +61,81 @@ static int blkoutstream_flush(FAR struct lib_outstream_s *self)
return ret;
}

/****************************************************************************
* Name: blkoutstream_seek
****************************************************************************/

static off_t blkoutstream_seek(FAR struct lib_sostream_s *self,
off_t offset, int whence)
{
FAR struct lib_blkoutstream_s *stream =
(FAR struct lib_blkoutstream_s *)self;
size_t sectorsize = stream->geo.geo_sectorsize;
off_t streamsize = sectorsize * stream->geo.geo_nsectors;
FAR struct inode *inode = stream->inode;
off_t sector;
off_t ret;

switch (whence)
{
case SEEK_SET:
break;
case SEEK_END:
offset += streamsize;
break;
case SEEK_CUR:
offset += self->nput;
break;
default:
return -ENOTSUP;
}

/* Seek to negative value or value larger than maximum size shall fail. */

if (offset < 0 || offset > streamsize)
{
return -EINVAL;
}

if (self->nput % sectorsize)
{
sector = self->nput / sectorsize;
if (offset >= sector * sectorsize &&
offset < (sector + 1) * sectorsize)
{
/* Inside same sector */

goto out;
}

ret = inode->u.i_bops->write(stream->inode, stream->cache,
sector, 1);
if (ret < 0)
{
return ret;
}
}

if (offset % sectorsize)
{
ret = inode->u.i_bops->read(inode, stream->cache,
offset / sectorsize, 1);
if (ret < 0)
{
return ret;
}
}

out:
self->nput = offset;
return offset;
}

/****************************************************************************
* Name: blkoutstream_puts
****************************************************************************/

static ssize_t blkoutstream_puts(FAR struct lib_outstream_s *self,
static ssize_t blkoutstream_puts(FAR struct lib_sostream_s *self,
FAR const void *buf, size_t len)
{
FAR struct lib_blkoutstream_s *stream =
Expand Down Expand Up @@ -140,7 +210,7 @@ static ssize_t blkoutstream_puts(FAR struct lib_outstream_s *self,
* Name: blkoutstream_putc
****************************************************************************/

static void blkoutstream_putc(FAR struct lib_outstream_s *self, int ch)
static void blkoutstream_putc(FAR struct lib_sostream_s *self, int ch)
{
char tmp = ch;
blkoutstream_puts(self, &tmp, 1);
Expand Down Expand Up @@ -240,6 +310,7 @@ int lib_blkoutstream_open(FAR struct lib_blkoutstream_s *stream,
stream->common.putc = blkoutstream_putc;
stream->common.puts = blkoutstream_puts;
stream->common.flush = blkoutstream_flush;
stream->common.seek = blkoutstream_seek;

return OK;
}
Expand Down
Loading
Loading