Search ARMWorks Answers

Sunday, September 16, 2012

Note: Wingston, mentioned in earlier postings, has become so successful that he has pulled his blog.

Developing for Linux on FriendlyARM boards.

A typical development setup has a Mini/Micro/Tiny of your choice with power supply and cables from the SDK accessory kit. Your Mini is connected to a Linux PC by the serial cable (often to a USB to serial converter) and an Ethernet cable. If you have an Ethernet hub, use a regular Cat5 cable from Mini to hub. If not, use the crossover cable from the kit and connect to your PC. The hub is more convenient so that you can use the Internet at the same time without jumping through hoops. The USB cable is used in a few special situations.
A great way to do fast development with the least hassle, is with NFS. NFS, or Network File System, allows part of your PC hard drive to be mounded by the Mini over Ethernet. When you change a script or configuration file or compile something on a shared directory, it is seen by the Mini as being on its own hard drive. There is no burning of NAND or transferring SD cards.
Your PC will need your favorite Linux - FriendlyARM uses Fedora in some of the user manuals, a lot of people use Ubuntu, and some prefer the more Spartan Debian. Debian has the advantage that anything in the repository is available for both x86 and ARM. The pending release of a Debian customized for Mini210 makes this appealing. You will need the "tools", the GNU compilers and linker, GDB for debugging, and and perhaps an IDE like Eclipse. Old school Linux users might scorn the IDE, but most of us relative noobs can make good use of it. Single stepping through lines of code or by machine instructions is simple with a proper setup of Eclipse. If you are new to this and wonder what all thjose special directories are for in Linux, here is a very handy reference.
Your first step if you don't have Linux, is choosing the "Distro" or distribution you want to use. Will you put it on a PC or laptop of it's own? Or set up dual boot with Windows? Or maybe use VirtualBox or VMWare to install a virtual machine? Check the forum at www.friendlyarm.net to see what people are doing and what systems are working best. A favorite around here is a bare bones quad core AMD at 3GHz+ with 4 or 8 GBytes of RAM. We watch for really good sale prices on bare bones and 20" displays at places like Tiger Direct or NewEgg. If you luck out, you can get dual monitors (with stand) and a great box for less than $500. You hardly need this if you have time to wait for long compiles. After all the Mini210S itself is more powerfull than a great PC of 10 years ago.
Can you develop for the Mini210/S directly on the Mini210/S? Yes you can. The Mini210S can run Debian Squeeze, the current Debian for desktops, and that means anything else in the Debian repository. A new release with drivers for I/O on the Mini/Tiny210 systems will be ready soon. There is plenty of RAM on the Mini210S and we like to run Debian from a uSD card so we have up to 32 GBytes of flash. 36 if you count the 4 GBytes on board. If you choose this method, spend the extra for a Class 10 SD. They write much faster. A very simple and powerful way to develop directly on your card is with Python. Once Debian is loaded, add USB mouse and keyboard, connected to the Internet, and just
 
You can even use the HDMI on one of the 210's with a large display or use a 7" 5" or 4.3" LCD. See if IDLE or Eric will load for a Python IDE.

Monday, January 2, 2012

Wingston at WorkshopIndia has been writing a great blog and tutorial on Pengutronix and the Mini2440 and more. Following his tutorial looked like a quick way to get started, and it was. When I began the first steps of the process of getting the ptxdist (Pengutronix Dist) started, I had to apt-get piles of stuff that was not in the Ubuntu install.

Unlike Fedora and some others, Ubuntu does not have an option to install a full development version with tools. The trick is to run

apt-get install build-essentials

and maybe some other things. Wingston has added a line to the tutorial that will install all the needed tools on Ubuntu. Aside from some of the usual frustrations of downloading with a browser and moving files with the terminal command line, everything went quite smoothly. Note: I used all the latest versions of tools and source despite the latest version of gcc not being in the compatibility matrix for Pengutronix Mini2440. I used a "force" option at one point when the ptxdist setup offered it as a way to use a non-specified version of gcc. When cross compiler tool build ran, it chunked away echoing great masses of stuff to the terminal for 80 minutes, and finished with no errors! It would have been faster with a better Internet connection. At least half that time is spent downloading files. I now had the Pengutronic BSP and tool chains for cross compiling to the Mini2440 all built.

I would have continued, but ran into a problem with permissions and left it till Sunday afternoon. In the tutorial, you create a directory for the BSP in /home/BSP and I either missed something or made a mistake during installation. Firefox would not download to the directory and ptxdist gave an error when trying to create directories. If you try to run ptxdist as root, it will give an error. It refuses to run as root, which is a good thing.

I had forgotten that the permissions for my user account did not include /home, only /home/myUser. On the advice of an experience Ubuntu user (thanks Seppoz), I did a quick

~$sudo chown -R myUser /home/BSP

and all was well with the world. After a simple configuration for LCD type and IP addresses and boot method, I was able to command 

~$ptxdist go

and off it went! Biding Wingston's advice in his tutorial, I stayed within range to see if things stopped, and they did, about 4 times. Each stop was because a file to be downloaded could not be found - error 404. It was easy to copy the file name and Google for it. I found most in Fedora repositories, and now that Firefox would download to /BSP, it was easy to drop them directly to the /src directory shown in the stoppages. Another ptxdist go and it starts where it quit. A little over 90 minutes and it was done. Again error free! And in an images directory sat barebox and the kernel and file system. Woohoo! It would have taken maybe half the time with faster Internet and me noticing things had stopped instead of reading tables of ballistic coefficients for another project.

Note that the commands are given from inside /home/BSP/long-name-of-bsp-directory .

So far this is the best Linux experience I have ever had :-) I think I configured correctly to load the bootloader over tftp and everything else will be NSF. Hmm. Now I haver to check on that. Anyway, assuming it runs on the Mini, everything is sweetness and light. If it doesn't, I'll revise my opinion about best -- experience -- ever.

Would I do anything differently? Yes, I would put the BSP in my user directory so there were no confusions over permissions. However, if you change the ownership as above in the beginning, it will be painless as is. It is definitively awesome that you can assemble a new computer, install Ubuntu, build cross development tools and BSP, and generate a new Linux for the Mini2440 in a day. More details as testing continues!