Project

General

Profile

Howto flash » History » Version 7

Eric Krausser, 01/04/2012 03:23 AM
remove gap

1 2 Eric Krausser
h1. How to flash
2 1 Eric Krausser
3 1 Eric Krausser
If you are aware of OpenWRT or DD-WRT: initial flashing of a ZRouter firmware will be done the same way.
4 1 Eric Krausser
5 1 Eric Krausser
A lot of our work / knowledge is based on the information on their websites. So it's always a good idea to visit https://openwrt.org/ and http://www.dd-wrt.com if our pages suffer information about board details, bootloader tips, flashing tutorials and so on. We thank OpenWRT and DD-WRT for sharing this information and we hope they will benefit from our work as we do.
6 1 Eric Krausser
7 1 Eric Krausser
8 1 Eric Krausser
Flashing depends on board type and it's bootloader. In most cases you have to read board specific instructions which you will hopefully find in zrouter board definitions, in this wiki or on OpenWRT / DD-WRT.
9 1 Eric Krausser
10 1 Eric Krausser
h2. Preparations
11 1 Eric Krausser
12 5 Eric Krausser
* find out how you can "unbrick" (reflash if something fails) your device - if it's not possible it's on you to keep on
13 1 Eric Krausser
* before you open your device be sure you can successfully build a ZRouter firmware for it
14 1 Eric Krausser
* create a serial connection between your workstation and your device (mostly you have to open it and you need a special converter in hardware)
15 6 Eric Krausser
* start a TFTP service in your LAN or on your workstation, the operating system doesn't matter
16 1 Eric Krausser
* connect the ethernet port of your device (if it's a router it's mostly the WAN port) with your switch or workstation, so it can link to the TFTP server
17 1 Eric Krausser
18 1 Eric Krausser
h2. Instructions
19 1 Eric Krausser
20 2 Eric Krausser
h3. Serial connection
21 2 Eric Krausser
22 2 Eric Krausser
Establish the serial connection with a terminal program. You need board specific parameters like speed, stop bit and negation.
23 2 Eric Krausser
24 7 Eric Krausser
On FreeBSD, in most cases <pre>
25 2 Eric Krausser
# /usr/bin/cu -s <speed> -l <serial-port>
26 1 Eric Krausser
e.g.
27 2 Eric Krausser
# /usr/bin/cu -s 115200 -l /dev/cuaU0
28 7 Eric Krausser
</pre> will do.
29 2 Eric Krausser
30 2 Eric Krausser
If you don't know the &lt;speed> (you'll see nothing or garbage when speed is wrong), try 115200, 57600, 38400, 19200 and 9600 until you see something useful after powering up the device. The &lt;serial-port> depends on your converter hardware: use _/dev/cuaU0_ if it's connected via USB and _/dev/cuad0_ for old serial "COM" port. Of course, for every available port on your system the trailing number grows. To exit _cu_ type "~." (tilde, dot) or "~ ." (tilde, blank, dot). It's a bit confusing, but _cu_ is always with you in FreeBSD base system. Never forget the man pages of tools you are using before giving up.
31 2 Eric Krausser
32 2 Eric Krausser
33 2 Eric Krausser
h3. Enter and configure bootloader
34 2 Eric Krausser
35 3 Eric Krausser
What you see in the terminal when powering up the device is the bootloader how it's booting the kernel of the currently installed firmware. The bootloader is a small program in the flash memory of your device, able to start other programs and to boot firmware images.
36 3 Eric Krausser
Before the kernel boots, the bootloader usually gives the possibility to enter it's command-line by hitting a key or key sequence. As you can guess it depends on the bootloader what keys to hit.
37 2 Eric Krausser
38 3 Eric Krausser
If you can see a command-line prompt and the kernel doesn't load, you did it. Within this command-line you can configure some options, e.g. the IP and the TFTP server IP if you flash by this service. Always try "help" or "?" when you get access to such command-line interfaces and "help <command>" to get further usage instructions for a command listed by "help".
39 2 Eric Krausser
40 2 Eric Krausser
h4. u-boot loader
41 2 Eric Krausser
42 2 Eric Krausser
Show configuration
43 2 Eric Krausser
<pre>
44 4 Eric Krausser
> printenv
45 2 Eric Krausser
</pre>
46 2 Eric Krausser
47 2 Eric Krausser
Set IP and TFTP Server IP
48 2 Eric Krausser
<pre>
49 4 Eric Krausser
> setenv ipaddr 192.168.3.10
50 4 Eric Krausser
> setenv serverip 192.168.3.1
51 2 Eric Krausser
</pre>
52 1 Eric Krausser
 
53 2 Eric Krausser
h3. Flashing firmware from TFTP
54 2 Eric Krausser
55 2 Eric Krausser
Put the ZRouter firmware to the directory served by the TFTP service.
56 2 Eric Krausser
57 2 Eric Krausser
You can test the download on a workstation:
58 2 Eric Krausser
<pre>
59 2 Eric Krausser
# /usr/bin/tftp
60 2 Eric Krausser
tftp> get servername:firmware.bin
61 2 Eric Krausser
Received 8126415 bytes during 1.8 seconds in 15918 blocks
62 2 Eric Krausser
tftp> quit
63 2 Eric Krausser
</pre>
64 2 Eric Krausser
65 2 Eric Krausser
Now you do the same on the device with bootloaders capabilities.
66 2 Eric Krausser
67 2 Eric Krausser
h4. u-boot loader
68 2 Eric Krausser
69 2 Eric Krausser
1. Erase area in flash
70 2 Eric Krausser
<pre>
71 2 Eric Krausser
> erase <address> +<size>
72 2 Eric Krausser
</pre>
73 2 Eric Krausser
74 2 Eric Krausser
2. Fetch firmware (will use server defined with "setenv serverip &lt;address>")
75 2 Eric Krausser
<pre>
76 2 Eric Krausser
> tftpboot <target-address-RAM> firmware.bin
77 2 Eric Krausser
</pre>
78 2 Eric Krausser
79 2 Eric Krausser
3. Copy firmware from memory to flash
80 2 Eric Krausser
<pre>
81 2 Eric Krausser
> cp.b <target-address-RAM> <target-address-flash> <size>
82 2 Eric Krausser
</pre>
83 2 Eric Krausser
84 2 Eric Krausser
4. Boot flashed firmware
85 2 Eric Krausser
<pre>
86 2 Eric Krausser
> bootm <target-address-flash>
87 2 Eric Krausser
</pre>