This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BUS FAULT when calling SYS_INIT and using secure services

Hi!

I'm running into quite a strange problem which is that when trying to use SPM secure services in my program, I get a BUS FAULT error.

What's also really strange is that the error doesn't occur on the function call but a few ms after. The function exits correctly and returns the expected value and then, the program crashes.

When I try to remove the secure function call, the BUS FAULT error stops occurring as well as when I remove all SYS_INIT. No matter which one I keep, I get the BUS FAULT error.

K_SEM_DEFINE(sem_end, 0, 1)

void main(void)
{
	printk("Calling secure function\n");

	uint32_t result;

	int ret = spm_request_read(&result, (uint32_t)&NRF_FICR_S->INFO.PART,
		sizeof(uint32_t));

	if (ret != 0) {
		printk("Could not read FICR (err: %d)\n", ret);
	}
	printk("FICR.INFO.PART = 0x%08X\n\n", result);

	printk("Calling secure function success!\n");

	k_sem_take(&sem_end, K_FOREVER);
}

LOG output:

Calling secure function
FICR.INFO.PART = 0x00009120

Calling secure function success!
[00:00:01.583,923] <inf> protobuf: Initializing protobuf
[00:00:02.583,953] <err> os: ***** MPU FAULT *****
[00:00:02.583,984] <err> os:   Instruction Access Violation
[00:00:02.583,984] <err> os: r0/a1:  0x00000000  r1/a2:  0xe000ed00  r2/a3:  0x200156c0
[00:00:02.583,984] <err> os: r3/a4:  0x20014a00 r12/ip:  0x871dfabe r14/lr:  0x0001c80d
[00:00:02.584,014] <err> os:  xpsr:  0x61000000
[00:00:02.584,014] <err> os: Faulting instruction address (r15/pc): 0xab55d3c4
[00:00:02.584,014] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:02.584,014] <err> os: Current thread: 0x20014a00 (unknown)
[00:00:02.646,697] <err> os: Halting system

There is nothing special happening in that protobuf function except the LOG output (I disabled everything else):

static int protobuf_init(const struct device *dev)
{
	ARG_UNUSED(dev);

	LOG_INF("Initializing protobuf");

	return 0;
}

SYS_INIT(protobuf_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);

Thanks by advance to anyone that can help me with this issue !

Parents
  • Hi,

     

    The fault happens 1 second after protobuf init.

    You can use arm-none-eabi-addr2line to resolve a address to source code:

    arm-none-eabi-addr2line -e ../build-folder/zephyr/zephyr.elf 0xFAULTING_ADDRESSES

    The content of LR (0x1c80d in this case) can be interesting to look at.

     

    In addition, you can also map the failing thread by looking at build/zephyr/zephyr.map, and look for this address:

    [00:00:02.584,014] <err> os: Current thread: 0x20014a00 (unknown)

     

    Could you try this and see where those addresses point to?

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    The fault happens 1 second after protobuf init.

    You can use arm-none-eabi-addr2line to resolve a address to source code:

    arm-none-eabi-addr2line -e ../build-folder/zephyr/zephyr.elf 0xFAULTING_ADDRESSES

    The content of LR (0x1c80d in this case) can be interesting to look at.

     

    In addition, you can also map the failing thread by looking at build/zephyr/zephyr.map, and look for this address:

    [00:00:02.584,014] <err> os: Current thread: 0x20014a00 (unknown)

     

    Could you try this and see where those addresses point to?

     

    Kind regards,

    Håkon

Children
No Data
Related