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

Discussions and support about ChibiOS/RT, the free embedded RTOS.
方悠然
Posts: 4
Joined: Mon Nov 14, 2022 2:43 am
Has thanked: 2 times

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

Postby 方悠然 » Fri Nov 25, 2022 11:13 am

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.

User avatar
Giovanni
Site Admin
Posts: 14219
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1031 times
Been thanked: 881 times
Contact:

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

Postby Giovanni » Fri Nov 25, 2022 11:51 am

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

方悠然
Posts: 4
Joined: Mon Nov 14, 2022 2:43 am
Has thanked: 2 times

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

Postby 方悠然 » Tue Nov 29, 2022 3:58 am

#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.

User avatar
Giovanni
Site Admin
Posts: 14219
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1031 times
Been thanked: 881 times
Contact:

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

Postby Giovanni » Tue Nov 29, 2022 6:22 am

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


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: Google [Bot] and 5 guests