Hi guys,
After 5 years of enjoying playing with embedded system, I wanna demonstrate what I learned/experienced about microcontroller in this bring-up series.
The purpose of this series is not only the summary of myself but also help the other guys, especially students, can bring up the a mircocontroller from scratch, what I mean is nearly from scratch.
I will use Discovery kit from ST which consists of a Cortex M4 MCU and is quite common on the market.
Prerequisite:
- A Discovery Kit from ST, of course, I use it as an example, the concept should be similar to the other MCU.
-A PC, of course, I use an Linux environment for my convenience, you can use Window for your convenience, but you should prepare some equivalent tool which I list below
-A cross compiler for ARM Cortex M4, I used GCC which is quite popular in community, I believe that window variant is available.
-A loader software that helps you to load the code to microC.
-Last but not least, an eagerness to reinvent the wheel.
The method I use is try to approach the thing from theory, then analyze it, try it, apply it, fail, correct it and then loop the whole process.
Let get started
When purchasing an STM32F4DISCOVERY board, you often think of writing some led blinking program and then load to the board, there is some available toolsuites from the vendor that help you do the job. But this series is about building from scratch, isn't it? Let us review something from the university.
We 've already known that a computer work because it Fetch the instruction from the memory, then Decode the instruction into ALU operation, the eXcecute it (FDX cycle). All the cycle is done by CPU itself, what we have to do is just prepare the program which is the arrangement of instructions.
Basically, each type of computer have its own Instruction Set Architecture and yes, our development kit use ARM architecure, specifically, the Cortex M4 architecute, it has their own ISR which contains some instruction like "moving data to register", "adding content of 2 register",...
The computer just understands the instruction in the form of manchine code (binary code), but our programe is often (or always nowaday) written in higher level language such as C or Assembly code, so we should preprare a toolsuite which covert what we write in to machine code, I use gcc as I said before.
Regarding the toolsuite in embedded world, it often consists of a C compiler, an Assember, linker and a loader and might be a debugger.
For the compiler, assember, linker, I use arm-non-eabi-gcc toolchain, it is free. You can download it via the official page of ARM ( https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads )
A loader is a software that help you to load the machine code from your PC to memory of Microcontroller, it is often included in the software called debugger which have a feature "programming". I used openocd for this part. Please refer to http://openocd.org/
Once reading to this line, you should prepare enough tools for next parts of this series. If you have any trouble in installing above tools, please feel free to ask.
I believe you would also have a big picture of what I am going to do in this series.
In the next part, I will put the first step into MCU, it is about memory segmentation. It is very important but they are often omitted in university. Just relax yourself and waiting for the next part.
See you soon.
After 5 years of enjoying playing with embedded system, I wanna demonstrate what I learned/experienced about microcontroller in this bring-up series.
The purpose of this series is not only the summary of myself but also help the other guys, especially students, can bring up the a mircocontroller from scratch, what I mean is nearly from scratch.
I will use Discovery kit from ST which consists of a Cortex M4 MCU and is quite common on the market.
Prerequisite:
- A Discovery Kit from ST, of course, I use it as an example, the concept should be similar to the other MCU.
-A PC, of course, I use an Linux environment for my convenience, you can use Window for your convenience, but you should prepare some equivalent tool which I list below
-A cross compiler for ARM Cortex M4, I used GCC which is quite popular in community, I believe that window variant is available.
-A loader software that helps you to load the code to microC.
-Last but not least, an eagerness to reinvent the wheel.
The method I use is try to approach the thing from theory, then analyze it, try it, apply it, fail, correct it and then loop the whole process.
Let get started
When purchasing an STM32F4DISCOVERY board, you often think of writing some led blinking program and then load to the board, there is some available toolsuites from the vendor that help you do the job. But this series is about building from scratch, isn't it? Let us review something from the university.
We 've already known that a computer work because it Fetch the instruction from the memory, then Decode the instruction into ALU operation, the eXcecute it (FDX cycle). All the cycle is done by CPU itself, what we have to do is just prepare the program which is the arrangement of instructions.
Basically, each type of computer have its own Instruction Set Architecture and yes, our development kit use ARM architecure, specifically, the Cortex M4 architecute, it has their own ISR which contains some instruction like "moving data to register", "adding content of 2 register",...
The computer just understands the instruction in the form of manchine code (binary code), but our programe is often (or always nowaday) written in higher level language such as C or Assembly code, so we should preprare a toolsuite which covert what we write in to machine code, I use gcc as I said before.
Regarding the toolsuite in embedded world, it often consists of a C compiler, an Assember, linker and a loader and might be a debugger.
For the compiler, assember, linker, I use arm-non-eabi-gcc toolchain, it is free. You can download it via the official page of ARM ( https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads )
A loader is a software that help you to load the machine code from your PC to memory of Microcontroller, it is often included in the software called debugger which have a feature "programming". I used openocd for this part. Please refer to http://openocd.org/
Once reading to this line, you should prepare enough tools for next parts of this series. If you have any trouble in installing above tools, please feel free to ask.
I believe you would also have a big picture of what I am going to do in this series.
In the next part, I will put the first step into MCU, it is about memory segmentation. It is very important but they are often omitted in university. Just relax yourself and waiting for the next part.
See you soon.