0
\$\begingroup\$

I was working on an embedded system project and wanted to develop a peripheral driver for Ethernet connection supported by stm32 bluepill board.

I wanted to use FreeRTOS. I understand that there are two types of device driver, one is low level device driver which is OS independent and another is high level device driver which is OS dependent.

I wanted to know how to proceed with device driver development. Should I write low level device driver first and then proceed with high level device driver? Is high level device driver dependent on low level device driver and vice versa.

\$\endgroup\$
1
  • \$\begingroup\$ Drivers in the context of microcontroller programming is simply the part of the program closest to the hardware. It has nothing to do with some OS and nothing to do with PC programming "device drivers". \$\endgroup\$
    – Lundin
    Commented Sep 27, 2023 at 6:34

2 Answers 2

1
\$\begingroup\$

I think you are confusing the microcontrollers with microProcessors.

microProcessors running operating systems like linux usually have low level drivers implemented at kernel level and high level user code (aka application code) implemented at user space.

In microControllers, the terminologies commonly used are baremetal (lowest level), middleware (abstraction usually provided by OEM) and then user application.

If I'm to interpret your question, you want to develop an ethernet driver for STM32 BluePill. Firstly as @Justme mentioned, there's no onboard ethernet support on bluepill however you can get an external ethernet module and communicate with it via SPI. This means what you really want is SPI driver which can handle data packets sent by Ethernet Controller IC.

If you are a complete beginner, I suggest you start with hooking up a simple SPI sensor with your bluepill and understand the SPI comms first. You can rely on ST tools like STM32CubeMX and IDE to speed up your learning. Once you've familiarised yourself with the basics, only then start working on ethernet side. Implementing ethernet stack on microcontrollers is a very involved process and required a level of experties. I suggest building your foundational knowledge first.

\$\endgroup\$
7
  • \$\begingroup\$ I have done projects based on SPI, I2C and UART communication on bare metal programming concept. I wanted to get acquainted with Freertos hence wanted to interface MCU with ethernet module. Freertos provides drivers for ethernet connection. Hence wanted to know if these drivers are high level drivers or has any dependencies to be supported by freertos kernel. Thanks. \$\endgroup\$ Commented Sep 27, 2023 at 11:11
  • \$\begingroup\$ freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/… for reference \$\endgroup\$ Commented Sep 27, 2023 at 11:14
  • \$\begingroup\$ Are you planning to use stm32cube envoirnment (HAL abstraction) for your project ? \$\endgroup\$
    – Prashant
    Commented Sep 27, 2023 at 11:20
  • 1
    \$\begingroup\$ Have a look at the stack digram in this link freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/… . There are layers beneath freeRTOS which will be the "baremetal" code which you can either write yourself or use ST manuals for reference. The question however is what're you using for ethernet controller. If you wish to stick with bluepill then as i said before You'll have to get a ethernet module and communicate with it via SPI. \$\endgroup\$
    – Prashant
    Commented Sep 27, 2023 at 14:04
  • 1
    \$\begingroup\$ @DeepakKumar Yes and No. Microcontroller applications built using RTOS have layers of abstraction similar to that you'll find in an operating system running on microProcessor. But before you dwell into software complexities, first familiarise yourself with the functioning of ethernet hardware, how it communicated with controllers, then choose the right controller for your application (uC or uP) and then dive deep into the awsome world of embedded software development. \$\endgroup\$
    – Prashant
    Commented Sep 28, 2023 at 8:57
0
\$\begingroup\$

The understanding is flawed. There are no high or low level drivers unless you define yourself what is the meaning of those.

And anyway the Blue Pill MCU has no Ethernet so anyway you would need to communicate with another chip or module that can provide Ethernet connectivity through an interface the both chips support, such as SPI.

And you are given an SPI driver, so you need to build your Ethernet chip driver which communicates via the SPI driver to the Ethernet chip to do what it allows you to do, and the Ethernet chip could offer very high level API for managing TCP/UDP connections at IP level or just sending raw Ethernet frames, so then you need the IP stack on top of your Ethernet driver.

It really boils down to what thing/device/chip you want to add to provide Ethernet connectivity, and that chip alone could be more powerful and complex than the STM32 on the Blue Pill so it might not make sense to add Ethernet to Blue Pill but to use something which already is powerful enough to provide Ethernet.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.