Work Work Work!
September 19th, 2009 by TheKidd
May 23rd, 2009 by TheKidd
For this exercise, I will be basing my walk through off of AVR Freak’s Wiki documentation. For other updating options, please refer to the Firmware Upgrade page on AVR Freak’s Wiki.
Using NGW100’s Root FS & WGET to Load /usr FS
May 23rd, 2009 by TheKidd
Next I am going to look at using TFTP to restore or upgrade the /root filesystem on the NGW100. The /root file system will require more intereaction with U-Boot so let us get started!
For this exercise, I will be basing my walk through off of AVR Freak’s Wiki documentation. For other updating options, please refer to the Firmware Upgrade page on AVR Freak’s Wiki.
Quick TFTP Setup
Using U-Boot and TFTP To Restore The Root Filesystem
This section assumes that your Linux desktop is not your DHCP server. I don’t know too many people who would have this setup normally so why even bother screwing with that when its quite easy to type a few extra lines and get the same results.
You may get an error saying that ethaddr is not set. So we will set a bogus mac address for the the NGW100 as follows:
Uboot> set ethaddr 00:11:95:00:00:00
Uboot> set ipaddr 192.168.100.105
Set to an IP that is available on your network
Uboot> set tftpip 192.168.100.103
Change to your TFTP Server IP
Uboot> set serverip 192.168.100.103
Change to your TFTP Server IP
Uboot> tftp
This command will fail because you did not specify a file but it should show that it connected to the TFTP server and tried to download a file. If it did try to load one, you are ready to actually erase the existing root image. I personally find the above test methods much better then erasing the flash first before knowing you can get to the file.
Uboot> protect off 0×20000 0×7EFFFF
This turns off /dev/mtd1 flash protection.
Uboot> erase 0×20000 0×7EFFFF
This erases the entire /dev/mtd1 flash chip.
Uboot> tftp 0×90000000 rootfs.avr32.jffs2-root
This connects to your TFTP server, downloads the root image file and places it into SDRAM for temporary storage.
Uboot> cp.b $(fileaddr) 0×20000 $(filesize)
This copies the file (fileaddr) located in SDRAM to the start of the /dev/mtd1 flash chip and it also specifies its size. These two variables are added to the environment when you ran tftp above.
Uboot> protect on all
Turns read only protection back on for /dev/mtd1.
Note: The first time I tried to boot the root filesystem, I got some unexpected errors. For more information check here.
That wasn’t too difficult. Next we will use WGET to load the /usr filesystem.
May 23rd, 2009 by TheKidd
I did run into a bit of a problem after restoring u-boot and the root filesystem with the JTAG ICE. It appears that the version the board shipped with was setup to boot the linux kernel off of /dev/mtdblock1 at /uImage but the latest build, 2.3.0, had the kernel located at /boot/uImage. I was constantly getting the following error from u-boot:
Wrong Image Format for bootm command
ERROR: can’t get kernel image!
UBoot>
After a bit of Googling, I found a blog on the subject which suggested the following:
Booting By Internal Flash
To boot the kernel and root file system off of the internal flash (/dev/mtd1), get into u-boot and enter this:
Uboot> askenv bootcmd
Please enter ‘bootcmd’: fsload /boot/uImage; bootm
Uboot> askenv bootargs
Please enter ‘bootargs’: console=ttyS0 root=/dev/mtdblock1 rootfstype=jffs2
Uboot> saveenv
Uboot> bootm
Booting By SD Card
To boot the kernel and root file system off of SD card (/dev/mmcblk0p1), get into u-boot and enter this:
Uboot> askenv bootcmd
Please enter ‘bootcmd’: mmcinit; ext2load mmc 0:1 0×103000000 /boot/uImage; bootm 0×103000000
Uboot> askenv bootargs
Please enter ‘bootargs’: console=ttyS0 root=/dev/mmcblk0p1 rootwait
Uboot> saveenv
Uboot> bootm
You can test to see if u-boot can read the card by issueing the command ext2ls mmc 0:1. It should list all of the files on the card.
I did notice while I was looking around that if you have problems on the NGW100 board with the above SD u-boot settings, that it is recommended to try setting rootwait to rootwait=1. Hope that will help someone else.
May 23rd, 2009 by TheKidd
So as I mentioned, I attempted the flash method to update u-boot to the latest version. I got to the erase flash part of the instructions and I ended up getting a support call and had to run. Storm rolled through while I was gone and killed the power and, because it was down for more than an hour, the battery backup too. So I returned home to find a ‘dead’ NGW100 board.
Just to mention, there are three ways to perform a NGW100 U-Boot/Root FS update. They are as follows:
For this exercise, I will be basing my walk through off of AVR Freak’s Wiki documentation. For other updating options, please refer to the Firmware Upgrade page on AVR Freak’s Wiki.
Notes
After purchasing the JTAG ICE MKII and after setting up Ubuntu with a AVR32 development environment, I did the following to replace u-boot.
Prepare NGW100 For JTAG ICE Restore
Use JTAG ICE To Flash U-Boot and Root On The NGW100
Note: The first time I tried to boot the root filesystem, I got some unexpected errors. For more information check here.
That is how you use a JTAG ICE MKII to restore/upgrade/install a fresh u-boot and root image onto your Atmel NGW100 board. You can also use TFTP to load a root image or you can move on to loading the usr filesystem.
May 22nd, 2009 by TheKidd
Over the past few days I attempted to upgrade the u-boot, root, and usr images on my NGW100 but ended up loosing power after erasing the u-boot partition (doh, major fail!). I ended up realizing that Mouser Electronics was pretty close to me in Ft Worth so I ran over there earlier this week and plunked down the $300 (another doh!) for a JTAG ICE MKII Programmer. I really didn’t want to spend that much money, but I figure it will come in handy during future development.
So this post starts out with a wiped NGW100 board, a JTAG ICE MKII, and a spare computer I had laying around. I decided to use the spare computer to setup a proper development platform as I really needed to get away from Windows. I did try to run the Atmel Ubuntu VMWare image, but it ran very slow and VMware Player somehow killed the drivers for my wireless card on my laptop. So for this post, I will go over the steps I took to setup Ubuntu and install all of the necessary files needed to setup an AVR development environment.
Installing Ubuntu
Installing The AVR Development Environment
The following information was found off of the AVR Freaks Wiki::Documentation:AVR32 General/Installing tools on Ubuntu Linux. I have sort of repeated it due to a few differences I noticed on my machine.
To get this file, go to the Ubuntu Packages site and download libxerces27 here.
I will be coming back to this in a bit to build my first NGW100 image, so this info may change.
May 15th, 2009 by TheKidd
For my first few posts on the NGW100, I am going to start with a walk through on compiling a new kernel and root image for the device. This will give me a better understanding of the differences between the AP7000 vs the x86 platform when it comes to Linux and compiling its software. My main goal is to understand more about how programs are compiled and prepared to run on the Atmel platform so that when I get to my end goal, installing Asterisk/AstLinux, I have a better grasp of this platform.
Useful Notes
Here are some useful notes I’ve realized throughout the process. Might as well get these out of the way before continuing.
Backing Up The Original Atmel Linux Image
Okay the following section is all hear-say. I played around for a long time in Uboot looking for a way to dump the data flash and flash chips to an image on my TFTP server and was unsuccessful. So I did the next best thing…I dd and cp -paR -ed the hell out of the system. Here is what I did, there may be an easier way:
All this was done as I managed to hit 1.3 GB on the BSP package. If anyone has some incite on an easier/quicker way to backup the original image, please let me know. I will mention right now that I do not have a JTAG lying around. Planning on going to Mouser Electronics in Ft Worth to build/buy one tomorrow if time permits.
Next up, I will attempt to upgrade Uboot I believe.
May 14th, 2009 by TheKidd
After a long hiatus, I’m back! Work has been crazy, but I may have a bit more time on my hands now. To get things off to a good start, I purchased an Atmel NGW 100 Embedded Linux demo board the other day. I have been drooling over the idea of integrating circuit design with the Linux operating system for some time and at a cost of $70-$80, its a steal.
Picture of the product.
The Atmel NGW100 board which measures in at 120mm by 100mm comes with the AT32AP7000 processor which runs at 130 MHz (150MHz overclocked). It also has 16MB of flash memory, 32MB of SDRAM, SD Card reader for storage, 2 10/100 ethernet controllers, a serial and a USB connection. It appears to come pre-installed with a nice copy of the BusyBox Linux distro on it which includes command line tools, SSH, a web server, NFS and Samba.
I found a very interesting project for this board on Sawdust’s Blog called ‘Network Accessible A/C Outlet Control‘. You can also find a lot of useful information on this board at AVRfreaks and on their NGW 100 Documentation Wiki.
I think I am going to recreate Sawdust’s device first just to play around and get use to it. After that, I am really interested in trying to get Asterisk loaded onto the board. I am figuring that with the overclocked processor, I should be able to squeeze 2-4 VoIP lines out of it. From what I’ve found out so far though, it is going to be a real pain to get Asterisk’s voice codecs compiled to run on the Atmel processor. Oh well, if it isn’t challenging, it isn’t fun!
Besides playing with the NGW100, I will also get back to work on XBee, home automation, and a lot more VoIP/Asterisk stuff. I’ll keep everyone updated.
March 3rd, 2009 by TheKidd
I was looking around on the web the other day for an easy way to backup data on a Linux server to Amazon S3. I ended up running into SoftwareBloat’s script and liked what they had done with it. One thing I needed, however, was to be able to clean up the backup bucket on S3. So here is the script i came up with from SoftwareBloats original. Hope it will help someone looking for the same!
Oh one note, after you issue the apt-get install s3cmd command to grab the program, you will also want to run s3cmd –configure which will ask for your S3 information. Important step before the below will work.
#!/bin/bash
## SoftwareBloat’s Script
## TheKidd had to play with it.
## Which means I screwed it up.
## Hehe, thx bloat! Awesome tutorial! Hope this might help.
# Dates to variables for the backup script
DATE_TAG=$(date +"%Y.%m.%d")
# to clean backups off s3 older than 28 days
# as i only want to keep 4 sets of backups
S3_DATE_TAG=$(date -d "-28 days" +"%Y.%m.%d")
# Admin email notification
EMAIL_ADMN="admin@domain.com"
EMAIL_SUBJ="S3 Backup Results"
EMAIL_FROM="s3backup@domain.com"
# Directories to backup to and from
SHELL_DIR="/shell"
WWW_DIR="/www"
HOME_DIR="/home"
ROOT_DIR="/root"
BACKUP_DIR="/backup/soho"
SQL_BK_NAME="athena.mysql.bk"
BUCKET_NAME="sohobackup"
# Intro for Admin Email
echo "This message is to inform you that your backup on $DATE_TAG just started running. Lets get started." > $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
# Clean up any files older than 7 days
# this allows me to catch the 7 daily mysql backups but delete anything created 8+ days ago.
echo "Cleaning folders before start…" >> $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
/usr/bin/find $BACKUP_DIR -maxdepth 0 -type f -mtime +7 -print | xargs rm -f
# backup key directories
echo "Backing up key directories…" >> $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
tar pczvf $BACKUP_DIR/shell-$DATE_TAG.tgz $SHELL_DIR
tar pczvf $BACKUP_DIR/www-$DATE_TAG.tgz $WWW_DIR
tar pczvf $BACKUP_DIR/home-$DATE_TAG.tgz $HOME_DIR
tar pczvf $BACKUP_DIR/root-$DATE_TAG.tgz $ROOT_DIR
# backup databases
# echo "Backing up Database…" >> $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
# mysqldump -u root –password=your_pw_here –all-databases | gzip -c > $BACKUP_DIR/$SQL_BK_NAME$DATE_TAG.gz
# **Don’t need the above as webmin provides daily MySql backups dumped into BACKUP_DIR**
# But everyone prefers their own way!
# Just to prevent errors, we attempt to create the bucket
/usr/bin/s3cmd -c /root/.s3cfg mb s3://$BUCKET_NAME
# Backup all the tgz’s with correct date stamp
echo "Uploading backup files…" >> $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
for f in $BACKUP_DIR/*$DATE_TAG.tgz
do
/usr/bin/s3cmd -c /root/.s3cfg put $f s3://$BUCKET_NAME/$(basename $f) >> $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
done
# now we kill the mysql daily backups made 28+ days ago
echo "Deleting old DB files on S3…" >> $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
for (( i=40; i>=28; i– ))
do
/usr/bin/s3cmd -c /root/.s3cfg del s3://$BUCKET_NAME/$SQL_BK_NAME`date -d "-$i days" +"%Y.%m.%d"`.tgz >> $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
done
# now we kill the key directory backups made 28+ days ago
echo "Deleting old key directories on S3…" >> $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
for f in shell www home root
do
/usr/bin/s3cmd -c /root/.s3cfg del s3://$BUCKET_NAME/$(basename $f)-$S3_DATE_TAG.tgz >> $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
done
# just to let the admin in on the backup
echo "All done! Below is a list of what was backed up."
echo "Additional info: $BACKUP_DIR/logs/backup-$DATE_TAG.log" $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
/usr/bin/s3cmd -c /root/.s3cfg ls s3://$BUCKET_NAME/ >> $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
echo "Sending Email! Have a good day!" >> $BACKUP_DIR/logs/backup-$DATE_TAG.log 2>&1
(echo "Subject: $EMAIL_SUBJ"; echo "From: $EMAIL_FROM"; echo "To: $EMAIL_ADMN";
echo "Reply-To: $EMAIL_FROM"; cat $BACKUP_DIR/logs/backup-$DATE_TAG.log;) | /usr/lib/sendmail -t
October 31st, 2008 by TheKidd
I’ve been so bad in the past few months about updating this blog. I’ve made some headway so far on my latest project, but it has not been what I’ve would have liked. Been side tracked due to a great idea I had for a program in C# for insurance agencies.
Thanks to everyone who have sent me feedback from the Arudino/Make forums. I definitely need to update some previous posts with your suggestions along with some new ideas and accomplishments I’ve been able to pull off. I’ll get on this as soon as possible. Its just so difficult between the IT company and the software program I’ve been developing.
I’ll do my best to post soon. Definitely let me know if you find any problems so far with my posts. I appreciate the feedback.