Embedded Linux Development Kits
From Crashcourse Wiki
What's all this?
It's just a general dumping ground for working notes as I rewrite a lot of Embedded Linux (and related) courseware. This main page will contain random thoughts and tutorials that would be useful for embedded Linux people and might show up in exercises in the final courseware, while the links to particular development kits will cover topics specific to those dev kits.
All of this comes with no guarantees whatever, but I try very hard to make sure what's here is correct. To that end, if you're reading something here and it doesn't appear to work, by all means, e-mail me at firstname.lastname@example.org and let me know. I realize it's probably unrealistic, but my goal is that everything documented here should just work.
Finally, I have no plans to reproduce everything out there. If there's a page somewhere that's a perfectly good explanation as to how something works, I'll just link to it. No intention of re-inventing wheels.
Useful (Ubuntu) packages for various reasons
A list of Ubuntu packages that are likely to come in handy when playing with embedded Linux. Explanations of what they're for and what you can do with them come later, this is just the package list.
The Ubuntu packages related to 7-zip compression/uncompression (only the first of which you might actually need depending on the files you're working with):
One option for getting real-time progress when dding those sizable SD card images.
A standard filter you can use for getting real-time progress in a Linux pipeline; another way to see progress when copying those SD card images.
Partitioning utility for working with SD card images.
For JTAG debugging of ARM and MIPS systems.
General, random topic list
Compression, unzip and 7-zip
In a recent dust-up on the BeagleBoard mailing list, it turns out that .zip files created with 7-Zip couldn't properly be processed with Ubuntu's unzip, so there was a consensus that using 7-Zip officially from now on would probably be a good idea.
In Ubuntu, there are three 7-Zip-related packages:
- p7zip: provides p7r, a standalone minimal version of 7-Zip that handles only 7z archives,
- p7zip-full: provides utilities to pack and unpack 7z archives within a shell or using a gui (such as File Roller or nautilus), and
- p7zip-rar: provides a module for p7zip-full to make 7z able to extract RAR files.
As a working example, if you download the BeagleBoard-xM zip file here, using Ubuntu's unzip command will extract a corrupt image file. Also, the basic 7zr won't work (because of the .zip suffix?) so, for now, you can use the 7z utility from the p7zip-full package:
$ 7z l xMc_4_25.zip 7-Zip  9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,8 CPUs) Listing archive: xMc_4_25.zip -- Path = xMc_4_25.zip Type = zip Physical Size = 228082726 Date Time Attr Size Compressed Name ------------------- ----- ------------ ------------ ------------------------ 2011-04-25 20:24:12 ....A 3948134400 228082584 xMc_4_25.img ------------------- ----- ------------ ------------ ------------------------ 3948134400 228082584 1 files, 0 folders $ 7z x xMc_4_25.zip 7-Zip  9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,8 CPUs) Processing archive: xMc_4_25.zip Extracting xMc_4_25.img Everything is Ok Size: 3948134400 Compressed: 228082726 $
Once the image files are compressed with 7-Zip, all of these issues should disappear.
Writing SD cards, dd and progress markers
Given how long it takes to write an SD card image using dd, it's nice to be able to generate progress markers of some kind. Here's a useful article showing a number of ways to do that. Make sure you read the comments to see other alternatives. This is where the ddrescue and pv Ubuntu packages come in.
NOTE: Many SD cards have slightly less capacity than their official size (4G, 8G, etc.). If you want to know the exact usable size of the card, insert it and run fdisk on it. Or you can check the appropriate line in /proc/partitions.
SD card image verification and manipulation with fdisk and kpartx
Before writing a bootable image to an SD card, you might want to examine the image file, its properties, its contents and so on. You can do this in a number of ways, given a sample xMc_4_25.img image file for a BeagleBoard-xM that you can get here, although any valid xM image file should work fine.
First, there's fdisk, which you can use to verify that this is a valid bootable image:
$ fdisk -l xMc_4_25.img Disk xMc_4_25.img: 3948 MB, 3948134400 bytes 255 heads, 63 sectors/track, 480 cylinders, total 7711200 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System xMc_4_25.img1 * 63 240974 120456 c W95 FAT32 (LBA) xMc_4_25.img2 240975 7132859 3445942+ 83 Linux $
In addition, you can use the mount command with "loop" and "offset" options to mount the internal filesystems to a temporary mount point, say m. You'll need to calculate that 63*512 = 32256, and 240975*512 = 123379200 for the offsets you're about to use.
First, mount and examine the FAT filesystem:
$ sudo mount -o loop,offset=32256 xMc_4_25.img m $ ls -l m total 3421 -rwxr-xr-x 1 root root 22232 2011-04-19 17:24 MLO -rwxr-xr-x 1 root root 284788 2011-04-19 17:24 U-BOOT.BIN -rwxr-xr-x 1 root root 134 2011-04-19 15:31 uEnv.txt -rwxr-xr-x 1 root root 3194256 2011-04-19 17:24 UIMAGE $ sudo umount m
Then do the same with the second (Linux) filesystem:
$ sudo mount -o loop,offset=123379200 xMc*img m $ ls -l m total 72 drwxr-xr-x 2 www-data www-data 4096 1969-12-31 20:02 bin drwxr-xr-x 2 www-data www-data 4096 2011-04-19 12:21 boot drwxr-xr-x 2 www-data www-data 4096 2011-04-19 12:20 dev drwxr-xr-x 54 root root 4096 2010-11-05 14:37 etc drwxr-xr-x 3 www-data www-data 4096 2011-04-19 12:15 home drwxr-xr-x 5 root root 4096 2010-11-05 12:01 lib drwx------ 2 root root 16384 2011-04-19 12:24 lost+found drwxr-xr-x 14 www-data www-data 4096 1969-12-31 19:01 media drwxr-xr-x 2 root root 4096 2011-04-19 11:21 mmc drwxr-xr-x 2 www-data www-data 4096 2011-04-19 12:15 mnt -rw-r--r-- 1 www-data www-data 0 2011-04-19 12:25 narcissus-was-here drwxr-xr-x 2 www-data www-data 4096 2011-02-20 14:13 proc drwxr-xr-x 2 www-data www-data 4096 1969-12-31 20:02 sbin drwxr-xr-x 2 www-data www-data 4096 2011-02-20 14:13 sys lrwxrwxrwx 1 root root 8 1969-12-31 22:24 tmp -> /var/tmp drwxr-xr-x 12 root root 4096 2010-11-05 14:37 usr drwxr-xr-x 9 www-data www-data 4096 2011-04-05 05:25 var $
Finally, if you install the kpartx package, you can use the kpartx command to do effectively the same thing. Figuring out how to use kpartx is left as an exercise for the reader.
Some simple U-Boot stuff
While U-Boot for different boards will be built with different options, there are a few basic commands you can run just for the fun of it to see if U-Boot looks sane. The following is for the same BeagleBoard-xM image described above. This is all pretty basic; more sophisticated U-Boot operation comes later.
OMAP3 beagleboard.org # version U-Boot 2011.03-rc1-00000-g9a3cc57-dirty (Apr 01 2011 - 17:41:42) arm-angstrom-linux-gnueabi-gcc (GCC) 4.3.3 GNU ld (Linux/GNU Binutils) 22.214.171.124.7.20080502 OMAP3 beagleboard.org #
OMAP3 beagleboard.org # bdinfo arch_number = 0x0000060A boot_params = 0x80000100 DRAM bank = 0x00000000 -> start = 0x80000000 -> size = 0x10000000 DRAM bank = 0x00000001 -> start = 0x90000000 -> size = 0x10000000 baudrate = 115200 bps TLB addr = 0x9FFF0000 relocaddr = 0x9FF7E000 reloc off = 0x1FF76000 irq_sp = 0x9FF1DF68 sp start = 0x9FF1DF60 FB base = 0x00000000 OMAP3 beagleboard.org #
OMAP3 beagleboard.org # coninfo List of available devices: serial 80000003 SIO stdin stdout stderr usbtty 00000003 .IO
OMAP3 beagleboard.org # mmcinfo Device: OMAP SD/MMC Manufacturer ID: 27 OEM: 5048 Name: SD08G Tran Speed: 25000000 Rd Block Len: 512 SD version 2.0 High Capacity: Yes Capacity: 7969177600 Bus Width: 4-bit OMAP3 beagleboard.org # mmc list OMAP SD/MMC: 0 OMAP3 beagleboard.org # mmc part 0 Partition Map for MMC device 0 -- Partition Type: DOS Partition Start Sector Num Sectors Type 1 63 240912 c 2 240975 6891885 83 OMAP3 beagleboard.org #
OMAP3 beagleboard.org # fatinfo mmc 0:1 Interface: MMC Device 0: Vendor: Man 275048 Snr dab0a548 Rev: 3.0 Prod: SD08G Type: Removable Hard Disk Capacity: 7600.0 MB = 7.4 GB (15564800 x 512) Partition 1: Filesystem: FAT32 "boot " OMAP3 beagleboard.org # fatls mmc 0:1 22232 mlo 284788 u-boot.bin 3194256 uimage 134 uenv.txt 4 file(s), 0 dir(s) OMAP3 beagleboard.org #
OMAP3 beagleboard.org # ext2ls mmc 0:2 <DIR> 4096 . <DIR> 4096 .. <DIR> 16384 lost+found <DIR> 4096 etc <DIR> 4096 usr <DIR> 4096 var <DIR> 4096 sbin <DIR> 4096 proc <DIR> 4096 sys <DIR> 4096 boot <DIR> 4096 dev <DIR> 4096 media <SYM> 8 tmp <DIR> 4096 lib <DIR> 4096 bin <DIR> 4096 mnt <DIR> 4096 home 0 narcissus-was-here <DIR> 4096 mmc OMAP3 beagleboard.org #
Just the simple ones:
OMAP3 beagleboard.org # i2c dev Current bus is 0 OMAP3 beagleboard.org # i2c probe Valid chip addresses: 48 49 4A 4B Excluded chip addresses: 00 OMAP3 beagleboard.org #
Too much to list here ...