Editing Linuxstamp II 9260

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 3: Line 3:
  
 
== Description ==
 
== Description ==
The Linuxstamp is designed to be a general purpose processor module. It is designed to work as a stand alone module (micro-SD card, Ethernet and USB/Serial converter are all on the module). This allows all initial development to be done without a motherboard, but for integration into a specific project a motherboard with specific features could be designed.
+
The Linuxstamp is designed to be a general purpose processor module. It is designed to work as a stand alone module (micro-SD card, Ethernet and USB/Serial converter are all on the module). This allows all initial development to be done without a motherboard, but for integration into a specific project a motherboard with specific features could be designed. Check out the start of the first mother board for the Linuxstamp, [http://opencircuits.com/Linuxstamp_Mboard_1 Mboard 1].
  
 
== Status ==
 
== Status ==
Line 12: Line 12:
 
* 32MB SDRAM
 
* 32MB SDRAM
 
* 256MB NAND Flash
 
* 256MB NAND Flash
 +
* 8MB SPI Dataflash
 
* 1x 10/100 Ethernet
 
* 1x 10/100 Ethernet
 
* 1x USB host port (allows wifi adapters, flash drives and other USB devices to be used)
 
* 1x USB host port (allows wifi adapters, flash drives and other USB devices to be used)
Line 17: Line 18:
 
* Serial debug port 5-pin header
 
* Serial debug port 5-pin header
 
* JTAG port
 
* JTAG port
 
== Motherboards ==
 
It is very easy to make a motherboard for the Linuxstamp II such as the [http://opencircuits.com/Linuxstamp_II_8-channel_RC_Control_board 8-channel RC Control board].
 
 
== Emdebian ==
 
The current Linux distribution is [http://www.emdebian.org/ Emdebian]. It is located in the NAND flash and uses UBI & UBIFS. The Emdebian folks have done a stellar job on Emdebian, and the best part is if the package you're after hasn't been "gripped" yet you can get the normal debian version.
 
 
The following instructions show how to build an emdebian system. The host system is debian squeeze on a x86_64, multistrap version 2.1.7. Here's the configuration file:
 
[General]
 
arch=armel
 
directory=/opt/multistrap/grip_squeeze
 
# same as --tidy-up option if set to true
 
cleanup=true
 
# same as --no-auth option if set to true
 
# keyring packages listed in each debootstrap will
 
# still be installed.
 
noauth=false
 
# whether to add the /suite to be explicit about where apt
 
# needs to look for packages. Default is false.
 
explicitsuite=false
 
# extract all downloaded archives (default is true)
 
unpack=true
 
# the order of sections is not important.
 
# the debootstrap option determines which repository
 
# is used to calculate the list of Priority: required packages.
 
debootstrap=Emdebian
 
aptsources=Emdebian
 
 
[Emdebian]
 
#packages=
 
packages=gcc subversion openssh-server net-tools wireless-tools wpasupplicant ifupdown inetutils-ping isc-dhcp-client udev nano
 
source=http://www.emdebian.org/grip
 
keyring=emdebian-archive-keyring
 
suite=squeeze
 
components=main dev
 
 
Save this config to a file (example is grip_squeeze_ls2.conf but any name can be used).
 
Run this command to generate the root filesystem:
 
# multistrap -f grip_squeeze_ls2.conf
 
 
To use a different directory, use the -d option to multistrap.
 
 
Before we to the actual chroot lets make sure a few files are setup. Most of the following section could be put into a simple script, but I'll go through it for reference. First lets add an /etc/fstab. It should look something like this:
 
proc                /proc      proc      defaults              0 0
 
devpts              /dev/pts  devpts    mode=0620,gid=5      0 0
 
sysfs                /sys      sysfs      defaults              0 0
 
none                /tmp      tmpfs      defaults,size=2M      0 0
 
 
And etc/profile should be something like:
 
export LANGUAGE=C
 
export LC_ALL=C
 
export LANG=C
 
 
Next we'll need a working etc/resolv.conf file. You can copy this from any working linux box on the same network. Now we should have a working network.
 
 
Now we can chroot into this new root fs from a running unit. I use a rootnfs setup that the ls2 is already booted into for this step. This does of course present a chicken & egg problem of how do you get a working emdebian root fs to bootup in order to run the chroot command. The simple answer is to use an existing emdebian root fs. Another option is to massage the root fs just created. The main requirements for this are adding the device nodes (same ones we add from chroot environment) & /etc/inittab (this is created from dpkg --configure -a within the chroot environment so it would need to be created or copied in). And finally there has been some talk of using qemu from an x86_64 side for this in system configuration.
 
 
Now we can go ahead and chroot in:
 
# LANG=C chroot /grip_squeeze/ /bin/bash
 
Now we can mount some of those partitions even from chroot, so do: (the directory /dev/pts is needed before the mount)
 
# mkdir /dev/pts
 
# mount -a
 
 
Now that we're in the chroot environment we can do some more configuration. First well need some device nodes before udev comes up. This could also be done with [http://wiki.debian.org/DeviceTableScripting multistrap].
 
# mknod /dev/ttyS0 c 4 64
 
# mknod /dev/console c 5 1
 
Now to configure all the packages. The multistrap step installed the correct packages, but because it's not running on the native environment it doesn't want to configure the packages. You'll be prompted a couple of times for information like timezone:
 
# dpkg --configure -a
 
There might have been some errors, we'll catch those in the next pass. Before booting into our new environment, a few more steps. Edit the newly created inittab. Add a line like:
 
T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100
 
And comment all the ttyX lines.
 
 
Create a host name:
 
# echo ls2 > /etc/hostname
 
Set a root password:
 
# passwd
 
 
Now we can boot into this new root fs. If the network was started with a command line argument like ip=, then you might need to add a default gateway like this:
 
# route add default gw 192.168.0.1
 
Now add a line like
 
deb http://http.us.debian.org/debian squeeze main
 
to /etc/apt/sources.list.d/multistrap-emdebian.list. The deb-src line can also be commented. Now an 'apt-get update' should work. Now we can set the date manually until rdate is working:
 
# date 032822382011
 
Now back to dpkg --configure. dash needs a little extra work to configure. To get dash to configure first /var/lib/dpkg/info/dash.preinst will need to run correctly, to do this some man dir/files need to be created/touched.
 
# mkdir /usr/share/man; mkdir /usr/share/man/man1
 
And next run:
 
# sh /var/lib/dpkg/info/dash.preinst
 
And now the 'dpkg --configure -a' should work, and you can even remove the man stuff now:
 
# rm -rf /usr/share/man
 
The last think to do is make sure the keyrings are correct. I had to remove the *pgp* files in /etc/apt, and then run:
 
# apt-key add /usr/share/keyrings/emdebian-archive-keyring.gpg
 
# apt-key add /usr/share/keyrings/debian-archive-keyring.gpg
 
'apt-get update' is now very happy, and you can 'apt-get install' until your hearts content.
 
 
== Cross Compiler ==
 
you can use [http://ymorin.is-a-geek.org/projects/crosstool crosstool-ng] to generate a cross compiler. The documentation on the website is very good.
 
 
Emdebian also has pre-built cross-compilers that you can [http://www.emdebian.org/tools/crosstools.html install], as well as the [http://www.emdebian.org/tools/crossdev.html tools] to build your own.
 
 
== U-boot ==
 
First we need [ftp://ftp.denx.de/pub/u-boot/u-boot-2010.03.tar.bz2 u-boot]. If you have not yet built a cross compilier now would be a good time to do so (See the cross compilier section above). Now you can do a test for the Atmel at91sam9g20 EL board using NAND.
 
$make at91sam9g20ek_nandflash_config
 
$make CROSS_COMPILE=your_cross_compiler
 
This should give you a "u-boot.bin" file. We will have to write a board specific configuration file for the Linuxstamp. We should be able to base it off the the Atmel DK board. If you look at "/u-boot-1.1.6/include/configs/at91rm9200dk.h" you can see the configuration for the DK board.
 
<br>
 
Other u-boot commands:
 
> '''printenv''', prints the enviroment variables
 
> '''saveenv''', saves the enviroment variables
 
> '''setenv bootcmd 'tftpboot 20800000 uImage; bootm 20800000'''' Sets the boot command to load a image over tftp and boot it
 
> '''setenv bootargs mem=32M nfsroot=192.168.0.3:/nfs_root ip=192.168.0.51 console=ttyS0,115200n8 rootdelay=1'''
 
This sets the command line to be passed to the kernel. As you can see it sets the nfsrot, ip address and console
 
 
Warning!!! you can brick a board with the wrong u-boot NAND commands.
 
You can read and write the NAND flash with u-boot. To get started the u-boot NAND help is useful:
 
> '''nand help'''
 
So if to update the kernel, you must first be able to load the uImage into ram. This is normally done from tftpboot, with something like:
 
> '''tftpboot 0x20800000 uImage.9g20r5'''
 
Where 0x20800000 is the ram address, and uImage.9g20r5 is the file name on the tftp server. Now you need to erase the kernel block. This is necessary because a NAND write by itself can only switch bits to 0's:
 
> '''nand erase 0xa0000 0x200000'''
 
Where 0xa0000 is the offset and 0x200000 is the length. Now the new kernel can be written:
 
> '''nand write 0x20800000 0xa0000 0x200000'''
 
Where 0xa0000 is the offset and 0x200000 is the length
 
  
 
== License ==
 
== License ==
Line 144: Line 23:
  
 
== Hardware design files ==
 
== Hardware design files ==
Warning!!! Use this design at your own risk. Errata: a 10k pull-up resistor is needed on the CMD line to use the uSD card.
+
Warning!!! Use this design at your own risk.
Here are the design [http://linuxstamp.budgetdedicated.com/index.php?dir=lnst2/design/ files]
 
You can view the pdf of the schematic [http://linuxstamp.budgetdedicated.com/index.php?dir=lnst2/design/&file=ls2_101_sch.pdf here]
 
  
 
== Power ==
 
== Power ==
Line 152: Line 29:
  
 
== Minicom & the debug port ==
 
== Minicom & the debug port ==
[[Image:Ftdi_cable.jpeg]]
+
[[Image:ftdi_cable.jpg]]
 
+
The mini-USB device port on the Linuxstamp does not connect directly to the AT91RM9200 it connects to the FT232R chip. The FT232R is a USB/serial converter. The FT232R chip has drivers for both Windows and Linux, but the Linux drivers are included in later kernels. Drivers for Mac OS X are available [http://www.ftdichip.com/FTDrivers.htm here].
Above shows the proper connection of the ftdi cable to the Linuxstamp II. This provides both the debug console as well as power to the board. Pin 6 (green wire) on the cable overhangs the 5-pin connector on the board.
 
  
 
When you plug the Linuxstamp into your host (Linux) machine a device should appear '''/dev/ttyUSB0''' (the suffix number will increment as you add more devices). '''/dev/ttyUSB0''' will behave as any other serial port now. '''Minicom''' is the standard program to access the serial port in Linux. The first time you run minicom you will have to be root in order to do the setup, after that you can change the permissions on /dev/ttyUSB0 so any user can run minicom. To enter configuration mode in minicom type '''CTRL-A o''', now scroll down to '''Serial port setup'''. Use the letters to navigate. You will want the device to be '''/dev/ttyUSB0''' and '''Bps/Par/Bits''' to read '''115200 8N1'''. Both hardware and software flow control should be OFF. Connection to the board is important for loading Atmel's tiny program and u-boot, but once the board is working it might not be as important.
 
When you plug the Linuxstamp into your host (Linux) machine a device should appear '''/dev/ttyUSB0''' (the suffix number will increment as you add more devices). '''/dev/ttyUSB0''' will behave as any other serial port now. '''Minicom''' is the standard program to access the serial port in Linux. The first time you run minicom you will have to be root in order to do the setup, after that you can change the permissions on /dev/ttyUSB0 so any user can run minicom. To enter configuration mode in minicom type '''CTRL-A o''', now scroll down to '''Serial port setup'''. Use the letters to navigate. You will want the device to be '''/dev/ttyUSB0''' and '''Bps/Par/Bits''' to read '''115200 8N1'''. Both hardware and software flow control should be OFF. Connection to the board is important for loading Atmel's tiny program and u-boot, but once the board is working it might not be as important.
  
Another alternative is to use HyperTerm on Windows, which works fine with the Hardware boot loader. If you are updating the Darrel Bootloader, note that the loader only has a short delay after you initiate the "receive" (on the loader) after which it send out the "ready to receive" signal. As a result, you'll need to be rather quick to initiate the Xmodem "send" (on HyperTerm). If you are seeing time outs on HyperTerm when you try and send the loader.bin file, you are probably hitting this problem ... you need to have initiated the send before you see the "C" on the screen from the bootloader.
+
Another alternative is to use HyperTerm on Windows, which works fine with the Hardware boot loader. If you are updating the Darren Bootloader, note that the loader only has a short delay after you initiate the "receive" (on the loader) after which it send out the "ready to receive" signal. As a result, you'll need to be rather quick to initiate the Xmodem "send" (on HyperTerm). If you are seeing time outs on HyperTerm when you try and send the loader.bin file, you are probably hitting this problem ... you need to have initiated the send before you see the "C" on the screen from the bootloader.
  
 
== nfs & tftp ==
 
== nfs & tftp ==
Nfs (network file system) and tftp (trivial file transfer protocol) are two servers you will want running on your host machine. Nfs is useful for hosting the root file system of the Linuxstamp. Tftp is useful for u-boot to retrieve the kernel from. There are many other websites on nfs and tftp, but I will try and go over a simple setup. I would suggest being behind a firewall before trying either of these setups as neither is secure. I wrote this using a Fedora 7 system. You may have to modify the iptables on the server to allow a client to connect to the server.
+
Nfs (network file system) and tftp (trivial file transfer protocol) are two servers you will want running on your host machine. Nfs is useful for hosting the root file system of the Linuxstamp. Tftp is useful for u-boot to retrieve the kernel from. There are many other websites on nfs and tftp, but I will try and go over a simple setup. I would suggest being behind a firewall before trying either of these setups as neither is secure. I wrote this using a Fedora 7 system. First make sure you have nfs installed.
 
 
 
 
''<path_to_nfs_root>'' = This is the path to the root file system on the NFS machine.
 
 
 
''<server_name>'' = This is either the server host name, or an ip address to the NFS server.
 
 
 
''<path_to_test_mount>'' = This is the directory on the host that will be mounted to.
 
 
 
 
 
 
 
First make sure you have nfs installed.
 
  
 
  $ '''yum install nfs-utils nfs-utils-lib portmap system-config-nfs'''
 
  $ '''yum install nfs-utils nfs-utils-lib portmap system-config-nfs'''
Line 182: Line 47:
 
Now to make sure the service is enabled run (this won't work on Ubuntu):
 
Now to make sure the service is enabled run (this won't work on Ubuntu):
 
  $ '''serviceconf''' and make sure '''nfs''' and '''nfs lock''' are checked
 
  $ '''serviceconf''' and make sure '''nfs''' and '''nfs lock''' are checked
Now edit '''/etc/exports''' you should add a line like this '''/''<path_to_nfs_root>''/ *(rw,no_root_squash,insecure)'''. Now restart nfs.
+
Now edit '''/etc/exports''' you should add a line like this '''/path_to_nfs_root/ *(rw,no_root_squash,insecure)'''. Now restart nfs.
 
  $ '''sudo /etc/init.d/nfs restart'''
 
  $ '''sudo /etc/init.d/nfs restart'''
 
You can test that it is set up correctly by typing the following on the local system (i.e. right on the NFS server)
 
You can test that it is set up correctly by typing the following on the local system (i.e. right on the NFS server)
Line 188: Line 53:
  
 
You can test this from a remote system with
 
You can test this from a remote system with
  $ '''mount -t nfs ''<server_name>'':/''<path_to_nfs_root>'' /''<path_to_test_mount>'''''
+
  $ '''mount -t nfs server_name:/path_to_nfs_root /path_to_test_mount'''
 
Now on to tftp. Make sure it is installed.
 
Now on to tftp. Make sure it is installed.
 
  $ '''yum install tftp-server'''
 
  $ '''yum install tftp-server'''
Line 201: Line 66:
 
And boot them
 
And boot them
 
  > '''bootm 20800000'''
 
  > '''bootm 20800000'''
 
== Update Root FS on NAND ==
 
To update the root file system on the nand, you will need to have a running NFS server as described in the above section.
 
 
You can get the latest root_fs from here [http://linuxstamp.budgetdedicated.com/index.php?dir=lnst2_9g20/rootfs/&file=grip_squeeze_20110512.tar.bz2 grip_squeeze_20110512.tar.bz2] and un-tar it on your NFS server.
 
 
If you would like to create your own UBIFS, go to this [http://www.linux-mtd.infradead.org/doc/ubifs.html link].
 
 
Now we need to have u-boot boot up to connect to your NFS server for the root file system. Just as the board is booting up, you will see ''Hit any key to stop autoboot:'' You will have three seconds to hit any key. When you hit any key, you will be placed into the u-boot command.
 
 
To see the current environmental variables type:
 
> printenv
 
We will now be changing the variable ''bootargs'':
 
> setenv bootargs ip=dhcp nfsroot=<server_name>:<path_to_nfs_root>
 
Now save the new environment variables.
 
> saveenv
 
You can now reboot your board and see if it connects to your NFS root file system.
 
 
Note: On your NFS server, make sure you edit '''/etc/network/interfaces''' and comment out all the lines so that the kernal will not reset your network while booting up as the U-Boot has already setup the network for you.
 
 
 
 
Now lets install the new root file system. Take your new .bz2 file that you either created or download and put it in the root of the NFS root path.
 
 
The first command you will be doing, is going to format the root file system partition on the NAND drive. Note: We will be using mtd5 as this is the partition where the root file system resides and this will not erase the boot partition that contains U-Boot.
 
$ ubiformat /dev/mtd5 && ubiattach /dev/ubi_ctrl -m 5
 
Now we will be creating a new volume.
 
$ ubimkvol /dev/ubi0 -N rootfs -s 230MiB
 
Now lets mount the new partition.
 
$ mount -t ubifs ubi0_0 /mnt/tmp/
 
Now let un-tar the new root file system into the new partition.
 
$ tar -jxf /grip_squeeze_20110512.tar.bz2 -C /mnt/tmp/
 
Now we will move the un-tared root file system into the root of the partition.
 
$ mv /mnt/tmp/grip_squeeze/* /mnt/tmp/
 
Lets do some clean-up to gain some room as flash memory is limited.
 
$ rmdir /mnt/tmp/grip_squeeze/
 
Now unmount the partition.
 
$ umount /mnt/tmp/
 
 
Reboot the board and use the above commands to restore bootargs in U-Boot to boot from the new root file system on the board.
 
> setenv bootargs mem=32M console=ttyS0,115200 rootdelay=0 ip=192.168.0.51 ubi.mtd=5 root=ubi0_0 rootfstype=ubifs
 
Remember to save your environments before rebooting again.
 
> saveenv
 
You are now ready to use your fresh installed root file system.
 
  
 
== NAND Flash ==
 
== NAND Flash ==
One good solution for the NAND flash is to use the new [http://www.linux-mtd.infradead.org/faq/ubi.html ubi] and [http://www.linux-mtd.infradead.org/faq/ubifs.html ubifs] components. These both need to be enabled in the kernel, and then they can be used from the emdebian system. You can always check what mtd devices are avaliable in /proc/mtd. First we can format the mtd device (Note: This mtd1 will remove everything including u-boot):
+
One good solution for the NAND flash is to use the new [http://www.linux-mtd.infradead.org/faq/ubi.html ubi] and [http://www.linux-mtd.infradead.org/faq/ubifs.html ubifs] components. These both need to be enabled in the kernel, and then they can be used from the emdebian system. You can always check what mtd devices are avaliable in /proc/mtd. First we can format the mtd device:
 
  $ ubiformat /dev/mtd1
 
  $ ubiformat /dev/mtd1
 
Now we can "attach" it. This is telling the kernel to use the ubi subsystem for that partition. The -m 1 says use /dev/mtd1.
 
Now we can "attach" it. This is telling the kernel to use the ubi subsystem for that partition. The -m 1 says use /dev/mtd1.
Line 256: Line 77:
 
  $ mount -t ubifs ubi0_0 /mnt/tmp/
 
  $ mount -t ubifs ubi0_0 /mnt/tmp/
  
== Flashing with Atmel SAM-BA ==
 
Ateml SAM-BA can be used to to flash the linuxstampII board. Some special considerations must be taken to properly communicate with the board.
 
 
1) SAM-BA must be running in a windows environment to flash over the debug port. If running on a Windows 7 machine, you must install in XP compatibility mode. This will allow you to run SAM-BA and not SAM-BA_cdc
 
 
2) There cannot be any executable code in flash. It must be erased or you can very carefully pull the CS pin (pin 9) high to temporarily disable the NAND flash upon powering up the board.
 
 
3) You must change one line in the 
 
 
4) change sam9g20ek configuration file in:
 
Program Files/ATMEL Corporation/SAM-BA v2.10/tcl_lib/at91sam9g20-ek/at91sam9g20.tcl
 
 
#set bus width (16 or 32)
 
bus width = 16
 
 
5) should connect now when choosing sam9g20ek connection
 
 
6) In scripts, select "Enable Nand" and execute
 
 
7) In scripts, select "Erase All and execute
 
 
8) You can now write fresh versions of the at91bootstrap and u-boot!
 
  
 
== Links ==
 
== Links ==
Line 283: Line 82:
 
*[http://cadsoft.de/ Cadsoft.de]: Free (as in beer) tools for schematic and PCB design
 
*[http://cadsoft.de/ Cadsoft.de]: Free (as in beer) tools for schematic and PCB design
 
*[http://openhardware.wordpress.com/ openhardware.wordpress.com]: Here is my openhardware blog
 
*[http://openhardware.wordpress.com/ openhardware.wordpress.com]: Here is my openhardware blog
*[[Linuxstamp]] for the original AT91RM9200 Linuxstamp
+
*[http://www.atmel.com/dyn/products/app_notes.asp?family_id=605 App notes]: for Atmel arm processors
 +
*[[Linuxstamp Mboard 1| Mborad 1]] for the Linuxstamp
 
*[http://wiki.emqbit.com/free-ecb-at91 ECB AT91] This is another open source project similar to the Linuxstamp. They have some [http://wiki.emqbit.com/wiki very good documentation].
 
*[http://wiki.emqbit.com/free-ecb-at91 ECB AT91] This is another open source project similar to the Linuxstamp. They have some [http://wiki.emqbit.com/wiki very good documentation].
*[http://www.budgetdedicated.com/ Budgetdedicated] Graciously hosts our ftp [http://linuxstamp.budgetdedicated.com/index.php?dir=lnst2/ site]
+
*[http://www.budgetdedicated.com/ Budgetdedicated] Graciously hosts our ftp [http://linuxstamp.budgetdedicated.com/ site]
  
 
== Discussion ==
 
== Discussion ==

Please note that all contributions to OpenCircuits may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenCircuits:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)