Skip to content

Conversation

@LarkspurRaven
Copy link
Contributor

What changed?

This code adds an Operating System Abstraction Layer (OSAL) and a Hardware Abstraction Layer (HAL).

Reference docs/bm_osal_hal.md.

How does it make Bristlemouth better?

The OSAL and HAL provide a uniform interface between Bristlemouth core libraries and the underlying operating system and hardware platform. This decouples application logic from specific platform implementations (e.g., FreeRTOS, STM32), allowing for greater portability, testability, decoupling, and maintainability.

Reference docs/bm_osal_hal.md.

Where should reviewers focus?

This is not intended to be a complete or usable implementation.

Checklist

  • [ ~ ] Add or update unit tests for changed code
  • [ x ] Ensure all submodules up to date. If this PR relies on changes in submodules, merge those PRs first, then point this PR at/after the merge commit
  • [ x ] Ensure code is formatted correctly with clang-format. If there are large formatting changes, they should happen in a separate whitespace-only commit on this PR after all approvals.

@matt001k
Copy link
Contributor

matt001k commented Jun 2, 2025

Hello!
Thank you for the contribution!

Currently there is a lot of OS abstraction that has been implemented in bm_core. I would take a look at the file bm_os.h which implements a lot of FreeRTOS abstractions.
To avoid having multiple sources of truth, I would recommend replacing the use all of the API related to FreeRTOS (bm_osal_freertos) with the bm_os API.

bm_os.h includes things such as:

  • Queues
  • Semaphores
  • Stream Buffers
  • Timers
  • Systick time

Please let me know if you have any questions.
Other than that I enjoy the direction of this PR and what it is bringing to the table!

@LarkspurRaven
Copy link
Contributor Author

LarkspurRaven commented Jun 2, 2025

Hi Matt, thanks for the feedback. I inadvertently sent this PR to this repo instead of my forked repo. I wasn't quite ready to post here yet, but here it is!

I missed the abstractions in bm_core, thanks for sharing. Had you done any similar work for a HAL that I may have missed?

To be clear, this is just a preliminary PR intended for discussion, not (yet) intended for submission to mainline. I have some other ideas for similar approaches within the drivers.

@matt001k
Copy link
Contributor

matt001k commented Jun 2, 2025

@LarkspurRaven, we have not done anything in regards to a HAL.

The things that have been things abstracted away from the core Bristlemouth stack are LWIP and FreeRTOS.
These follow a very similar structure to your abstractions if you are interested in seeing what has been currently done.

Interested to see some of your other ideas around the HAL layer!

Out of curiosity, are you trying to place Bristlemouth onto another platform other than the STM32U5?
If so, I can also help guide you in the best way to approach that!

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

Successfully merging this pull request may close these issues.

2 participants