Topics

#nrf52480 Calling a function not compiled as part of Zephyr from within Zephyr #nrf52480


Marti Bolivar <marti@...>
 

Hi Jamie,

You might want to take a look at how MCUboot invokes the reset vector
in an NVIC table after having found the image:

https://github.com/runtimeco/mcuboot/blob/master/boot/zephyr/main.c#L53

As you can see, you can cast the address to a function of the
appropriate type and it does work on nRF52840.

If it's an MPU issue in your environment, the kernel developers who
work on userspace would probably benefit from seeing any relevant
Kconfig options in your build/zephyr/.config file.

HTH,
Marti

On Mon, Nov 12, 2018 at 6:24 AM <jamie.mccrae@...> wrote:

Hi,

I am attempting to run an external function on an nRF52840 which is present on the module's flash at a known address but is not part of the Zephyr environment (consider it external). The function doesn't do much except update some pointers which are provided to it, however when attempting to run the function from Zephyr, it generates a usage fault error, "Illegal use of the EPSR". I assume this is caused by a kernel security feature, so how would one go about calling an external function generated in a different build environment from Zephyr without it causing a fault?


lairdjm
 

Hi,
I sent a reply using the reply function on the message board site but it seems to have been a private message not a general reply. I fixed this off-by-one issue as I was calling at the function minus one by mistake, I've changed it and can confirm it works fine.
Thanks,
Jamie


From: Marti Bolivar <marti@...>
Sent: Wednesday, November 14, 2018 4:56:57 PM
To: Jamie Mccrae
Cc: devel@...
Subject: Re: [Zephyr-devel] #nrf52480 Calling a function not compiled as part of Zephyr from within Zephyr
 
Hi Jamie,

You might want to take a look at how MCUboot invokes the reset vector
in an NVIC table after having found the image:

https://github.com/runtimeco/mcuboot/blob/master/boot/zephyr/main.c#L53

As you can see, you can cast the address to a function of the
appropriate type and it does work on nRF52840.

If it's an MPU issue in your environment, the kernel developers who
work on userspace would probably benefit from seeing any relevant
Kconfig options in your build/zephyr/.config file.

HTH,
Marti
On Mon, Nov 12, 2018 at 6:24 AM <jamie.mccrae@...> wrote:
>
> Hi,
>
> I am attempting to run an external function on an nRF52840 which is present on the module's flash at a known address but is not part of the Zephyr environment (consider it external). The function doesn't do much except update some pointers which are provided to it, however when attempting to run the function from Zephyr, it generates a usage fault error, "Illegal use of the EPSR". I assume this is caused by a kernel security feature, so how would one go about calling an external function generated in a different build environment from Zephyr without it causing a fault?
>