One of the most important concept in every computing system, the Memory.
Today in Personal Computers there is plenty of memory space whereas the embedded systems still lack enough memory space. Power consumption, memory and disk space, size are the limitations of the embedded systems. For that reason, programming accordingly is crucial for the system.
We are not in the era when 64KB memory was a great success. The size of memory goes up to GigaBytes but still there are important issues in memory design and use.types of memory? Which one is the best fit for your system?? To be able to answer this question, you need to know the types, the volatility, addressing, write-ability issues in a memory chip. Today I will discuss about the memory types existing in embedded systems.
RAM and ROM are the basic types however there are hybrid types as well. RAM memories are volatile chips, which means if the power is off, you lose all the data in that location. If you are using a SRAM, which is a static RAM and mostly used as CPU cache, you can keep the data there as log you supply with the power. But if you are using a DRAM, the data is refreshed periodically and you cant keep the data forever. A DRAM is nothing if you do not have a DRAM controller for it. That is why a memory controller is important in the proper functioning of a DRAM. Unlike RAMs, ROMs are stable memory devices. Even if the power is off, the data still remains in the memory chip. But once the data is written there, you cant easily erase or re-write the data. To overcome the difficulties of ROM and RAM type memories, the hardware engineers developed hybrid types of memory, which are re-writable but non-volatile. The most common ones are NVRAM and Flash memories. I have never used a NVRAM but I am currently programming a data flash to store some temperature data I read in my room. As I make progress in this project, I will keep you updated with this blog as well :-) This is just a very basic information about memories currently used.
Have a GREAT Sunday!
And yes, I didnt forget to write about Makefiles...
Sunday, June 13, 2010
hello world, merhaba dünya!!
For those who want to have some fun(!) in these boring days, I would recommend you start reviewing your first days of embedded programming..Saying hello to our cruel world as every new-born programmer does :) I wont talk about how to write a Hello World program in C but rather about how this runs on your system..Yes the build process..When you write a program, as you understand it, the machine has to be able to understand and interpret the code. So how does it work? What does the OS do so that you see the execution results on the screen? It uses some compiler tools ---->Compile - Link- Relocate and Load. I am sure many of you are familiar with this process. Especially if you are using GNU tools like gcc, as, ld!!! If you did not use it before I recommend that you start soon since it is open source, easy to use.
Well, when you develop software, the very first thing you need to do is compile each source file..If the compilation process is successful, then you will have object files (.o extensions). All the source files must be assembled to an object file. The second step is to produce one object file. This file will be the combination of all the object files in one single file. Every object file has text, data, and bss segments. The machine code resides in the text segment, the initialized variables go to the data segment and unitialized variables go to the bss segment. In the final object file these segments include these segments of all the object files. After this step, the relative addresses must be assigned in the code, which is relocation..Relocation is important since when the code is loaded into the physical memory, the relative offsets play an important role. Because the code will not be loaded to the 0th memory location but to any empty location with the relative offsets. This final file with the relocation information is ready to run in the memory. As I mentioned above, these steps can be fulfilled with GNU tools. GNU gcc is a compilation tool. You can compile your code with a command such as: "gcc -g -c -Wall -I../include source_files.c". -g flag is for debug information, -c tells the compiler not to link files, and -Wall flag means turn the warnings on, and -I../include tells the compiler to look in the include directory for the header files..I also want to say that, for an embedded systems, you will be using a cross-compiler and there must be a toolchain that converts the code into your embedded target board machine code. I am using ARM board and in my case, I use arm-elf-gcc instead of native gcc. Why am I doing this? Because it doesnt make sense to compile the code on the embedded target since it is already resource restricted. For that reason we use host platforms and develop the code using a cross compiler. After compilation, we need to link and locate. GNU has the ld tool. A sample command can be such as: "arm-elf-ld -Map source.map -T arm.ld -o source.exe source_files.o". -Map flag is used to generate a map file. arm.ld is a linker script which gives information about the ram, rom start adress, memory sizes as well as text, data, and bss start address. -o flag tells to link the object files and make an executable file, which is sources.exe in this case. Now the code is ready to run on your embedded system as it is transfered to the board.
Rather than doing these steps manually, we can also use the make utility. It simplifes the compilation process and used in every project. But I will talk about it in my next post..
For now have a good night.
Well, when you develop software, the very first thing you need to do is compile each source file..If the compilation process is successful, then you will have object files (.o extensions). All the source files must be assembled to an object file. The second step is to produce one object file. This file will be the combination of all the object files in one single file. Every object file has text, data, and bss segments. The machine code resides in the text segment, the initialized variables go to the data segment and unitialized variables go to the bss segment. In the final object file these segments include these segments of all the object files. After this step, the relative addresses must be assigned in the code, which is relocation..Relocation is important since when the code is loaded into the physical memory, the relative offsets play an important role. Because the code will not be loaded to the 0th memory location but to any empty location with the relative offsets. This final file with the relocation information is ready to run in the memory. As I mentioned above, these steps can be fulfilled with GNU tools. GNU gcc is a compilation tool. You can compile your code with a command such as: "gcc -g -c -Wall -I../include source_files.c". -g flag is for debug information, -c tells the compiler not to link files, and -Wall flag means turn the warnings on, and -I../include tells the compiler to look in the include directory for the header files..I also want to say that, for an embedded systems, you will be using a cross-compiler and there must be a toolchain that converts the code into your embedded target board machine code. I am using ARM board and in my case, I use arm-elf-gcc instead of native gcc. Why am I doing this? Because it doesnt make sense to compile the code on the embedded target since it is already resource restricted. For that reason we use host platforms and develop the code using a cross compiler. After compilation, we need to link and locate. GNU has the ld tool. A sample command can be such as: "arm-elf-ld -Map source.map -T arm.ld -o source.exe source_files.o". -Map flag is used to generate a map file. arm.ld is a linker script which gives information about the ram, rom start adress, memory sizes as well as text, data, and bss start address. -o flag tells to link the object files and make an executable file, which is sources.exe in this case. Now the code is ready to run on your embedded system as it is transfered to the board.
Rather than doing these steps manually, we can also use the make utility. It simplifes the compilation process and used in every project. But I will talk about it in my next post..
For now have a good night.
Subscribe to:
Posts (Atom)