1 /* 2 * Copyright (c) 2012-2014 Wind River Systems, Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/kernel.h> 8 #include <zephyr/sys/printk.h> 9 #include <zephyr/debug/coredump.h> 10 func_3(uint32_t * addr)11void func_3(uint32_t *addr) 12 { 13 #if defined(CONFIG_BOARD_M2GL025_MIV) || \ 14 defined(CONFIG_BOARD_HIFIVE1) || \ 15 defined(CONFIG_BOARD_LONGAN_NANO) || \ 16 defined(CONFIG_BOARD_LONGAN_NANO_LITE) || \ 17 defined(CONFIG_SOC_FAMILY_INTEL_ADSP) 18 ARG_UNUSED(addr); 19 /* Call k_panic() directly so Renode doesn't pause execution. 20 * Needed on ADSP as well, since null pointer derefence doesn't 21 * fault as the lowest memory region is writable. SOF uses k_panic 22 * a lot, so it's good to check that it causes a coredump. 23 */ 24 k_panic(); 25 #elif !defined(CONFIG_CPU_CORTEX_M) 26 /* For null pointer reference */ 27 *addr = 0; 28 #else 29 ARG_UNUSED(addr); 30 /* Dereferencing null-pointer in TrustZone-enabled 31 * builds may crash the system, so use, instead an 32 * undefined instruction to trigger a CPU fault. 33 */ 34 __asm__ volatile("udf #0" : : : ); 35 #endif 36 } 37 func_2(uint32_t * addr)38void func_2(uint32_t *addr) 39 { 40 func_3(addr); 41 } 42 func_1(uint32_t * addr)43void func_1(uint32_t *addr) 44 { 45 func_2(addr); 46 } 47 main(void)48int main(void) 49 { 50 printk("Coredump: %s\n", CONFIG_BOARD); 51 52 func_1(0); 53 return 0; 54 } 55