View file | ||
---|---|---|
|
Introduction
Welcome to the firmware team! We’re glad to have you.
...
With that out of the way, let’s get started!
What’s firmware?
Software vs. Firmware
Software is a set of instructions that you run on a computer. For example, your favourite video game or code editor is software. It’s normally stored on your hard drive, then when you want to execute it, your operating system (Windows or Mac OS or Linux) will grab those instructions, put them into working memory (RAM), and execute those instructions.
Firmware is also a set of instructions, but instead of being stored on your hard drive, they’re stored forever in memory. As soon as the computer is powered on, it’ll start executing the instructions it has in firmwarethese base instructions.
In our firmware team, we work mainly on writing code for microcontrollers (think Arduino) that control electrical signals or monitor the solar car. Microcontrollers are essentially just computers but much smaller, and directly connected to hardware components.
Why does it matter?
Firmware generally has a lot more restrictions than software. Firstly, the The processor we use isn’t (comparatively) very fast and there isn’t much memory available, so our code needs to be simple and not too demanding. We partially can get around this restriction by breaking the firmware into small projects and running it on different boards, each responsible for controlling a different part of the car. Breaking it down also helps us work on different parts at the same time.
Systems overview
Here’s a diagram of the car’s electrical system:
...
If this scares you, don’t worry! It scares us too. Thankfully, implementing what’s in this diagram is the hardware team’s job, not ours!
Firmware system overview
...
See, we don’t even need to worry about wires. Much cleaner and easier to understand.
...
Battery: Ensures the battery doesn’t explode.
Driver controls: Takes input from the driver and passes it on to the rest of the system.
Power distribution: Turns other boards on and off (controls which boards are powered).
Drivetrain: Converts the angle that the pedal is at to the current levels for the motors (so if you floor it the car will go faster).
Charging: Manages charging of the battery from an off-the-shelf wall electric car wall charger or from the solar array.
Your PC vs a Microcontroller
We write all the code on our personal computers, but we need it to build it differently so that we can flash it over to run on our microcontrollers in a way that they understand. There are a few differences between the two that we need to consider.
...
First, let’s talk about compiling code.
Compiling code
As you may or may not know, to run C code, first you have to compile it. This means turning the higher level instructions you write as code into simpler instructions for the computer to understand.
...
An important caveat here is that not all computers understand the same instructions. For example, the processor in your laptop understands instructions called x86 (instruction set for Intel processors), while the computer chips we run our firmware on understands instructions called ARM.
Compiling our code
To do things like turn headlights on or off and read voltages from our hardware components on the BMS (battery management system) through code, we use pieces of code that are called libraries. Our firmware projects implement the logic parts we need, like determining when and how often we want an LED to blink and then we use the library to actually talk to the LED to turn it on or off. What this allows us to do is have different versions of the libraries for different types of computers:
...
Also, the hardware is still around, we’re just not close to it anymore. Good thing zoom, discord, and slack all exist! If we want to run our code on real hardware, we just have to call up the hardware member with the board and ask them to run it for us. Yes, this is more inconvenient, but it’s better than showing up a month later without having tested anything at all on hardware.
Our Process
Writing Code
Our firmware runs in safety critical situations, and as such it can be dangerous if it goes wrong. To help prevent this we have a structure for creating and testing our firmware.
...
Notice how much testing we go through! This is really important. In firmware, writing the code is often only half the battle, and there can be many unforeseen delays when you actually start interacting with hardware.
Tools
GitHub:
Git is a version control system that lets us have a master version of our firmware code as well as “branches”. GitHub allows you to use git to Each branch can have modifications made to it in an isolated environment, then once the changes are checked and verified, they can be “merged” back into master. We use this as a way to give each member an isolated environment to work on their changes.
...
We put “tickets” on the board, which include the task, the assignee, and some other information about the task.
Conclusion
Thanks for sticking through! In conclusion, here’s what you should come away from reading this with an understanding of:
...
Next in firmware 102, we’ll go into more depth on our firmware system, controller boards, our project structure, testing and validation, and our collaboration platforms. We hope to see you there!
FW 101 Tasks
Each of these modules comes with some tasks or projects that should be completed before moving onto the next part. There will usually be a deliverable so that we can check off that you’ve completed the homework.
*One important thing: as you are working through your tasks, you will encounter errors. The leads are happy to answer questions about any of these issues, but most of the time it can be solved by a quick google. 90% of the errors you will encounter can usually be solved with answers from Stack Overflow, and a little bit of thinking.
FW 101 Tasks
There are several tasks that need to be completed as part of this module:
Learn about Git and the Command Line by watching/reading the following tutorials
Git Tutorial Videos (part 1 and 2) and branching lesson
Command Line Tutorials (Part 1 and 2)
Get your environment set up by following the instructions listed at Setup
Write your very own Hello World program!
1. Intro Videos
These videos give an introduction to two of the main tools we use on our team, Git and the shell command line. We suggest watching them if you aren’t very experienced in one or the other, since the rest of the onboarding content will rely heavily on these concepts. However, we also do explain it as we go, so feel free to continue on even if you still haven’t fully grasped the concepts, and use these resources when you get stuck.
2. Setup
Assuming you have followed the steps listed in the setup page, we can now try out your new repository.
...
Don’t worry about what anything means, this is just to make sure you’ve got things up and running. We will talk more about scons and building software later.
3. Hello World
This section will cover writing a basic hello world program (using the C language), and running it in the environment we have just set up.
...
As you can see, we have a simple program which increments an integer and stores its value in a buffer array. Using this template, we are now going to write our very own hello world program!
The Program
The goal of this next part is to write a program which increments an integer using a function, and prints it to the console every second along with “Hello world”.
...