Hi everyone, in the previous blog we have discussed the basics of the Embedded System using the Rust programming language. That was like the “Hello World” in the Embedded Development. We also discussed that how we can start working with the bare metal environment and we can build and run the application in such an environment. If you want to read more about it then you can go through this blog here.
Okay, what do we have for today?
Today we are going to discuss various topics on the Embedded System and some are related to the stm32-Discovery Board. In today’s blog, we will learn various new topics related to our bare metal environment and we are also going to discuss why Rust is becoming so popular among scientists and also in embedded development.
As we are working with the Embedded Systems they make our task fast and reliable. Also, they are much smaller in size compared to traditional computers, which makes them compact and portable, and useful for mass production. Management of Embedded Systems is pretty easy, as elements used in their creation are cheap & long-lasting. Embedded Systems are also cost-effective.
Most Microcontrollers have more than just a CPU, RAM, or Flash Memory – they contain sections of silicon that are used for interacting with systems outside of the microcontroller, as well as directly and indirectly interacting with their surroundings in the world via sensors, motor controllers, or human interfaces such as a display or keyboard. These components are collectively known as Peripherals.
You can understand peripherals as the source which connects you or which makes you able to interact with the other sources present in the hardware in this case.
If you look at the main circuit board in an old-fashioned home computer from the 1970s or 1980s (and actually, the desktop PCs of yesterday are not so far removed from the embedded systems of today) you would expect to see:
- A processor
- A RAM chip
- A ROM chip
- An I/O controller
Memory Mapped Peripherals
Interaction with these peripherals is simple at a first glance – write the right data to the correct address. For example, sending a 32-bit word over a serial port could be as direct as writing that 32-bit word to a certain memory address. The Serial Port Peripheral would then take over and send out the data automatically. These peripherals work on the Registers address to provide the right data to the right point of address.
Now we are going to discuss the “portability” in the embedded environment.
In embedded environments portability is a very important topic: Every vendor and even each family from a single manufacturer offers different peripherals and capabilities and similarly the ways to interact with the peripherals will vary.
The way which helps us to interact with the other peripherals is HAL.
A hardware abstraction layer (HAL) is a logical division of code that serves as an abstraction layer between a computer’s physical hardware and its software. It provides a device driver interface allowing a program to communicate with the hardware.
The main purpose of a HAL is to conceal different hardware architectures from the OS by providing a uniform interface to the system peripherals.
Scientist and Rust programming language
Till now we have read about two of the topic of Embedded Development portability and peripherals. Next, we will discuss that why scientists are moving towards or talking about the RUST programming language.
There are various points behind this:
Rust Memory rules
Rust’s model uses rules to assign each piece of memory to a single owner and enforce who can access it. Code that violates those rules never gets the chance to crash — it won’t compile. The compiler uses the Memory Management System which works on the concept of “lifetimes” and tracks whenever memory is allocated.
Focus on usability
In Rust the compiler produces particularly informative error messages, even highlighting offending code and suggesting how to fix it. The way Rust compiler works lets the developers of Rust focus on the usability of this programming language better.
This is the end of the Blog. In the next blog, we will surely discuss some of the important topics related to the bare metal environment. Thanks for the readings.
If you want to read more content like this? Subscribe to Rust Times Newsletter and receive insights and latest updates, bi-weekly, straight into your inbox. Subscribe to Rust Times Newsletter: https://bit.ly/2Vdlld7.