Page 1 of 1

Can chibios' RT and ST's HAL be used together?

Posted: Fri Nov 25, 2022 11:13 am
by 方悠然
I want to generate code using STM32CubeMX and then perform tasks using Chibios' RT.

Put ST's HAL library into "ChibiOS-stable_21.11.x/ext", and then replace Chibios' hal with ST's HAL via Makefile in the Chibios demos example;

Or put "ChibiOS-stable_21.11.x/os/rt" in the project folder generated by STM32CubeMX.

Which one is a viable solution?

I'm trying it now and look forward to your reply.

Re: Can chibios' RT and ST's HAL be used together?

Posted: Fri Nov 25, 2022 11:51 am
by Giovanni
Hi,

RT can be used without our HAL no problems. I have never used the ST HAL but people have already used it with RT so it should be OK.

I recommend to use ChibiOS startup files and makefiles so I would include ST source code on top of a ChibiOS-like project, not all of it, just the parts you need adding drivers one at time.

It would also be possible to integrate RT into a CubeMX project but it is likely that ST startup files and makefiles don't do all things that are required so you would need to be extra careful.

Another note: you need to take care that all ISRs are written following the ChibiOS style (with prologue/epilogue macros)

BTW it is also possible to mix our HAL with specific drivers taken from ST HAL.

The best approach largely depends on what you are trying to achieve.

Giovanni

Re: Can chibios' RT and ST's HAL be used together?

Posted: Tue Nov 29, 2022 3:58 am
by 方悠然
#HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/hal/ports/STM32/STM32F4xx/platform.mk
include $(CHIBIOS)/os/hal/boards/ST_STM32F4_DISCOVERY/board.mk
include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk

When I comment out the above, why do I get an error?

Can you tell me how chibios distributes clocks? I wonder if it is possible to configure the clock with ST's HAL library?

For some reason, I wanted a pure CHIBIOS/RT+ST HAL, not CHIBIOS/HAL. Just use RT's threads, peripherals and interrupt configuration using ST's HAL, sorry for asking so many questions, I'm getting familiar with CHIBIOS.

Re: Can chibios' RT and ST's HAL be used together?

Posted: Tue Nov 29, 2022 6:22 am
by Giovanni
Hi,

If you remove HAL then the OS does nothing about initializing clocks, it is entirely up to you.

See the demo in /demos/various/RT-ARMCM4-GENERIC for an example of project without HAL, you may use it as a starting point.

Giovanni