This is our entry to the TI India Analog Design contest 2011.
I have written a port of the ELM-FatFs Generic FAT File System Module for the TI Stellaris EK-LM3S811 Evaluation board which runs on an ARM Cortex-M3 processor. The library is extensively used when connecting SD Cards to embedded systems. It is freely available under the GNU License.
It consists of a File I/O layer and Disk I/O Layer in which the former is constant across all platforms while the latter is specific to a micro-controller.
Disk I/O layer specifies the board pins, clocks and timers which are to be used. The board pins I have used are:
Steps to use the files in your project.
The feature to remap pins of an ARM processor sounds cool. Ain’t it? But it can be bothersome at times, if you configure pins the wrong way.
The same happened with me which almost bricked my TI Stellaris LM3S811 Evaluation Board. I accidentally configured the JTAG pin, PC0, which was the TCK pin for the JTAG peripheral, to be a GPIO pin. I uploaded the code onto the board and it ran like a charm for my application. But unknowingly, I had done changes which would prevent me from uploading new code on the board. I had bricked it.
The LM3S811 Evaluation board uses a PC<->USB<->FT2232<->JTAG<->MCU interface. Which basically means, all upload and download of code onto the MCU is done through the JTAG interface. The code reconfigured the JTAG pin to be a GPIO, disabled the JTAG peripheral of the MCU and would not let me upload any code. Even after reset, the pin would lose its JTAG functionality whenever the command to remap would be executed. And this happened way too early in program execution(within microseconds) as the command was the fourth statement in my code. So yes, the computer interface was no longer valid.
What I Tried :-
The Solution :-
In my code, the first statement selected the clock I wanted to use, the second initialized my display adapter, the third configured the pin PC5 and the fourth, and the one which should always be avoided, configured the pin PC0. The main motive was to halt program execution just before the reconfigure takes place. As instructed on the forum, if I could somehow stop the display initialization and come up with an error at that point, program execution would stop. But how to do it? The guy on the forum told me to pull out the display from the board
I didn’t do that. Learning how the display was connected to the the MCU, I figured out how it could be done. The display on the Stellaris Eval Board uses the I2C interface to communicate with the processor. I decided to pull the SCL or the clock pin of the I2C low and connected it to GND using a jumper. As there was no clock to the display, it wouldn’t initialize, and program execution would halt.
Job Well Done :-
I connected the modified board to my computer. Pressed reset, and Eureka! The program execution did stop before the pin could be reconfigured and I successfully uploaded the new code on the board.
Things I Learnt :-
I was introduced to the open source integrated development environment Eclipse by my friend Shan. Since then, I have shifted all my development routines for Arduino, Python and now ARM onto Eclipse. It is the best IDE I have used so far which supports almost everything, all programming languages, hardwares and toolchains.
The post is a simple walkthrough to making your first ARM project on Eclipse Helios on a Mac running OS X 10.7(the walkthrough is also applicable to previous generation OS X).
I am using Helios. Yes, it is old. A new version is already out. But some of the plugins we need to use, which I shall be explaining later in this post, still run on Helios.
Eclipse CDT is a C/C++ development IDE based on Eclipse (which defaults to Java development).
CodeSourcery Lite is GCC-based ARM toolchain which provides all the basic ingredients (compiler, assembler, archiver, linker, libraries, newlib, binutils, etc.) in console based executables. The best thing about CodeSourcery is that they also offer commercial solutions which result in quarterly updates to the Lite tool-chain also. This way you always stay inline with the latest GCC developments.
First let’s have a look at the pre-requisites. You will need the latest version of Apple Developer Tools which include Xcode, Interface Designer, Instruments etc. and can be download from the Mac App Store. It is needed for the initial building of the toolchain which requires gcc, binutils and make. If you do not want to install the Developer Tools package, you will have to download and install these components individually. Google will help you.
Let’s start now.
Step 1 – Install Eclipse
Download and install the Eclipse IDE from http://www.eclipse.org. Eclipse Helios. The download page would provide you with a variety of flavors for the IDE. All of them are useful sometime or the other and can be ported to different versions using plugins. So go for the “Eclipse IDE for C/C++ Developers”. It would have all the functionality needed to set up the toolchain.
Step 2 – Install Eclipse Plugins – Fueling up Eclipse
This step involves adding the necessary plugins to Eclipse which are needed to successfully compile an ARM application.
Step 3 – Install CodeSourcery
This step can be put as the most time consuming and mind boggling of the entire process. It took me more than 10 hours to get it working correctly. Thanks to James Snyder I was able to get it up and running in less than 30 minutes.
arm-none-eabi-gcc (GCC) 4.5.1 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
If you are not getting this message, you have missed out some steps above. Delete the folder arm-cs-tools in your HOME folder and repeat Step 3 again.
Step 4 – Firing up Eclipse
Now that the plugins have been installed and the toolchain set up, it is time to write our first ARM code. But before that, one thing to note is that Eclipse doesn’t pick up its PATH variables from the bash directly or rather there is a flaw in Eclipse for Mac. It took me a while to figure this out. So the way out is to edit the proprietary $HOME/.MacOSX/environment.plist file. But an easer way out, is to start Eclipse from the Terminal directly. This way, the PATH we created in our .bash_profile script will be automatically added to Eclipse’s PATH variables. To do that,
And you will be presented by the ever beautiful, Eclipse IDE. Yes, it is beautiful.
Step 5 – Writing your first ARM Application