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

hardware support float point (FPU) in this project (STM32F769I-disco_Buildroot) in linux user application #7

Open
salara1960 opened this issue Apr 24, 2023 · 0 comments

Comments

@salara1960
Copy link

Good day to all.
This project does not support the FPU hardware module on the ARM.
But I'm trying to use FPU in a user level application written in c under uclinux, for this,
as in HAL stm32f769 : SCB->CPACR |= ((3UL << 102) | (3UL << 112) ); (set CP10 Full Access and set CP11 Full Access),
I wrote a function that I activate in the self-written Linux kernel driver.
This function looks like this:
static void vfp_enable(void *unused)
{
uint32_t ret = 0;

asm volatile("ldr   r1, =0xE000ED88 \n\t"    // CPACR is located at address 0xE000ED88
               "ldr   r0, [r1] \n\t"                             // Read CPACR
               "orr   r0, r0, #0xf << 20 \n\t"          // Set bits 20-23 to enable CP10 and CP11 coprocessors
               "str   r0, [r1] \n\t"                            // Write back the modified value to the CPACR
               "isb \n\t"
               : "=r" (ret) : : "cc");
if (ret == 0xF00000)
printk("[%s] FPU activate OK !\n", __func__);
else
printk("[%s] FPU activate Error !\n", __func__);

}
This function is needed to activate the hardware module of the FPU, since after a processor reset it is in an inactive state.
After kernel loaded i see next message from this function : [vfp_enable] FPU activate OK !
I compile a user-level test application (fpu) with the following options: CFLAGS += -Os -Wall -mtune=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard.
uсlibс is built with support for hardware FPU module and toolchain also supports hardware FPU (arm-buildroot-uclinux-uclibcgnueabihf packet).
But after starting application I get exception with kernel panic :
Unhandled exception: IPSR = 00000004 LR = fffffffd
CPU: 0 PID: 55 Comm: fpu Not tainted 4.15.10 #3421
Hardware name: Generic DT based system
PC is at 0x0
LR is at 0xc03e044b
pc : [<00000000>] lr : [] psr: 00000000
sp : c03f3d48 ip : 2f5a5f49 fp : c03edfa4
r10: c03edfa8 r9 : 00000001 r8 : 00000000
r7 : 00000001 r6 : 00000000 r5 : c03f3efc r4 : 00000000
r3 : 0000004e r2 : c03f3f08 r1 : 00000000 r0 : 00000000
xPSR: 00000000
CPU: 0 PID: 55 Comm: fpu Not tainted 4.15.10 #3421
Hardware name: Generic DT based system
[] (unwind_backtrace) from [] (show_stack+0xb/0xc)
[] (show_stack) from [] (__invalid_entry+0x4b/0x4c)

Maybe someone already dealt with this problem and can share their experience?
Thank you in advance.
With my best regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant