VoIP Laboratory B How to re flash an IP04 (cc) Creative Commons Share Alike Non Commercial Attribution 3 This lab guides you through the process of re flashing an IP04. To re flash a unit is useful when you have been using a unit for training or development purpose, and wants to reset it to default values. Hardware requirements: 1 IP04, a serial cable, a PC (with serial port) 1, screwdriver Step 1: Hardware setup 1. Open the IP04 casing and put the four screws in a safe place. 2. Remove the jumper 2 and make sure you do not loose it! 3. Connect a RS232 cable to your IP04 (via the daughter board). Connect the other end of the cable to your computer. 4. Now we need to know where the RS232 modem has been attached. Run the following command and look for a message similar to the one below: #tail /var/log/message usb 2 1: FTDI USB Serial Device converter now attached to ttyusb0 In our case, the RS232 is attached to ttyusb0. This information will be required when we set up the serial communication. Step 2: Serial communication with Minicom We will communicate with the IP04 using serial communication. The software we are using is called minicom. 1. Install mincom in your PC by entering the following command: #apt get install minicom 2. Run the minicom application from your PC 1 If you do not have access to a PC with a serial port, use a serial to USB converter. 2 The latest version of IP04 [Nov 08] do not have (or need) a jumper. 1 (7)
#minicom Welcome to minicom 2.2 OPTIONS: I18n Compiled on Apr 27 2007, 15:50:20. Port /dev/ttyusb0 Press CTRL A Z for help on special keys 3. Press Ctrl A Z to enter the configuration menu. Press O (configuration) and select Serial port setup Edit Serial Device to reflect your setup (/dev/ttyusb0 in this example) Set Bps/Par/Bits to: 115200 8N1 Make sure that Hardware/Software Flow Control are set to No Save and exit configuration menu. Step 3: Boot IP04 Power on the IP04 and monitor the boot process through the minicom interface. Stop the boot process at the u boot prompt by hitting any key when you see the following message: U Boot 1.1.5 (May 5 2007 05:46:05) CPU: ADSP BF532 Rev.: 0.5 Board: IP04 IP PBX http://www.rowetel.com/ucasterisk/ip04.html Clock: VCO: 400 MHz, Core: 400 MHz, System: 133 MHz SDRAM: 64 MB In: serial Out: serial Err: serial 256 MiB DM9000#0 starting from spi flash Hit any key to stop autoboot: 0 ip04> Step 4: Write flash image to ip04 Now we are going to write the new uimage to the flash memory of the IP04. Before we do that, it is important that you write down the MAC address of your IP04 (as it will be overwritten in the re flash process). You will find your MAC address under bootargs if you run the command: 2 (7)
#print bootargs=ethaddr=0a:1a:2a:3a:4a:5a root=/dev/mtdblock2 rw Now we will install the new uimage into NAND flash using u boot. We will use tftp (trivial FTP) to transfer the image from the server to your IP04. Hence, your IP04 needs to be connected to the LAN. Run the commands below (form the u boot prompt): set autostart disables the automatic booting of u boot when an image is loaded (e.g. via tftp). The command has the meaning "set autostart null". ip04>set autostart Replace <ip addr of tftp server> to the IP address of the tftp server you are using ip04>set serverip <ip addr of tftp server> Replace <ip addr> to the IP address of your IP04 ip04>set ipaddr 192.168.46.12 Start the file transfer. ip04>tftp 0x1000000 uimage_r2.ip08 If everything goes OK, the prompt should return the following data: dm9000 i/o: 0x20100000, id: 0x90000a46 MAC: 0a:1a:2a:3a:4a:5a operating at 100M full duplex mode Using DM9000#0 device TFTP from server 192.168.46.99; our IP address is 192.168.46.12 Filename 'uimage_r2.ip08'. Load address: 0x1000000 Loading: ############################################## done Bytes transferred = 2228224 (220000 hex) 3 (7)
Step 5: Prepare the NAND 1. Clean the NAND memory by running the following command: ip04>nand erase clean NAND erase: device 0 whole chip Skipping bad block at 0x08000000 Skipping bad block at 0x0a560000 Erasing at 0xffe0000 100% complete. Cleanmarker written at 0xffe0000. OK 2. The, run the following command (this time without the clean) ip04>nand erase NAND erase: device 0 whole chip Skipping bad block at 0x08000000 Skipping bad block at 0x0a560000 Erasing at 0xffe0000 100% complete. Step 6: Copy the Image Now we are going to write the image from SDRAM to Flash NAND RAM (volatile > Flash). Execute the following commands. Replace the MAC address to your own (the one you wrote down). ip04>nand write 0x1000000 0x0 0x300000 NAND write: device 0 offset 0, size 3145728... 3145728 bytes written: OK ip04>set bootargs ethaddr=0a:1a:2a:3a:4a:5a root=/dev/mtdblock0 rw ip04>save Saving Environment to EEPROM... 0x0003FFFF 4 (7)
Step 7: Booting with new image ip04>bootm 0x1000000 (uclinux will boot...) BusyBox v1.4.1 (2008 03 10 09:54:22 CST) Built in shell (msh) Enter 'help' for a list of built in commands. root:~> Step 8: Copy Image to YAFFS Now we have uclinux running, but using an ext2 file system for your root files system. YAFFS file system works better in a flash memory, so we are going to copy all the data from the ext2 file system mtdblock0 to the YAFFS mtdblock2. In the IP04, run the script copy_rootfs.sh root:~> /bin/copy_rootfs.sh yaffs: dev is 32505858 name is "mtdblock2" yaffs: Attempting MTD mount on 31.2, "mtdblock2" yaffs: auto selecting yaffs2 block 961 is bad block 1260 is bad root:~> root:~> reboot NAND flash chips usually have a few bad blocks out of the factory. The files system accounts for this and it is expected and normal. In this example, two bad blocks were found. Step 9: Boot with YAFFS root file system Now set up u boot to mount root from YAFFS (some of these environment variables may be set already, use print to check): ip04>set autostart yes ip04>set bootargs ethaddr=0a:1a:2a:3a:4a:5a root=/dev/mtdblock2 rw ip04>set nandboot 'nboot 0x2000000 0x0' ip04>set bootcmd run nandboot ip04>save ip04>reset Automatic boot of image at addr 0x02000000... ## Booting image at 02000000... Image Name: uclinux Kernel and ext2 5 (7)
Image Type: Blackfin Linux Kernel Image (gzip compressed) Data Size: 2126307 Bytes = 2 MB Load Address: 00001000 Entry Point: 00001000 Verifying Checksum... OK Uncompressing Kernel Image... Check your IP address root:~> ifconfig eth0 Link encap:ethernet HWaddr 0a:1a:2a:3a:4a:5a inet addr:192.168.46.12 Bcast:192.168.46.255 Mask:255.255.255.0 UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1 RX packets:12 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 Interrupt:48 Step 10: Installing the asterisk packages Boot IP04 to a uclinux root prompt. Checkpoint 1: Make sure that root is mounted on mtdblock2 (YAFFS file system). If not, you need to review the parameters you have set (run print). #root:> df Filesystem 1k blocks Used Available Use% Mounted on /dev/mtdblock2 253952 5124 248828 2% / Now we will install some additional packages using ipkg. ipkg is using the repository configured in the file /etc/ipkg.conf 1. Let's update our repository of packages from the sources. $root:~> ipkg update 2. Install a few packages. $root:~> ipkg install zaptel sport asterisk native sounds dropbear Installing zaptel sport (1.4.3 1) to root... Downloading http://192.168.46.101/ucasterisk/ipkg/./zaptel sport_1.4.3 1_bfin.ik Installing oslec (1.0 1) to root... Downloading http://192.168.46.99/ucasterisk/ipkg/./oslec_1.0 1_bfin.ipk Installing asterisk (1.4.4 1) to root... 6 (7)
Downloading http://192.168.46.99/ucasterisk/ipkg/./asterisk_1.4.4 1_bfin.ipk Installing native sounds (1.0 1) to root... Downloading http://192.168.46.99/ucasterisk/ipkg/./native sounds_1.0 1_bfin.ipk 3. Make sure that the following packages are installed: 1. zaptel sport 2. asterisk 3. native sounds 4. oslec 5. dropbear Some useful ipkg command to know: A. List all possible packages $root: > ipkg list B. List all packages installed $root: > ipkg list_installed Step 11: Testing Zaptel Checkpoint 2: Test that the modules are working properly (that Zaptel has discovered all your FXO/FXS cards). In this example, 2 FXO and 1 FXS were discovered. root:~> ztcfg vvv Zaptel Version: 1.4.3 Echo Canceller: OSLEC Configuration ====================== Channel map: Channel 01: FXS Kewlstart (Default) (Slaves: 01) Channel 02: FXO Kewlstart (Default) (Slaves: 02) Channel 03: FXO Kewlstart (Default) (Slaves: 03) Registered tone zone 0 (United States / North America) 3 channels configured. Checkpoint 3: As a final test that your IP04 is working properly, connect two phones to the IP04, check that there is a dial tone in all FXS ports, and place phone calls between the handsets. 7 (7)