I'm trying to build something like a documentation here for the DM7020 boot process.
Overview:
On the DM7020, there is a loader called "first-stage" in the bootrom.
- First, it will look for a answer for the serial "dreamup" protocol
- Then, it will look in the nand flash for a valid 2nd stage loader. When found, the loader will be decompressed (gzip) and executed.
- If no second stage loader was found, the loader will try to boot from a recovery compact flash image. I'll describe this later, but usually you don't need this.
- If even this doesn't work, the loader will give up.
This means: even if you destroyed your secondstage loader, the only thing you need is a serial cable. NO MORE JTAG. 🙂 Look below how to restore a broken 2nd stage loader.
power modes
- Switched on. This is the mode when you watch tv.
- Standby. When you press the power button on the remote control once, the box will enter standby mode. The lcd will go dark, LNB power will be switched off, but the box is still alive.
- Deep-standby. You can enter the deep-standby mode when you press the power-button more than a few seconds (and possibly select "shutdown"). Linux will be shut down, but the frontpanel processor is still alive, and will wake the box when you press the power key again, or a recordings is about to start.
- Off. When you use the power-suplly switch (or remove power at all), the box is completely switched off.
Booting…
The Second stage loader is more complex, and will be available as source soon. It can boot from JFFS2, Compact flash and tftp. It resides in the first 128k of the NAND flash rom. Normally, the loader boots linux from the jffs2 boot partition, but you can configure it to boot from anything else. It can be configured to look at different sources depending on if you press a frontpanel button. It has a fallback mechanism to boot from flash when no other source (like tftp) is available.
Flash Images
… aren't that easy anymore. Because NAND flash can contain bad sectors, everything is getting a bit more complex. We introduced a special format called "nfi", which contains a header (and possibly a crc) and 3 different partitions (2nd stage, boot, root). You can flash this either with the bootloader directly (using a special HTTP client or using a browser), or using a special version of Dreamup. The good news are that you can flash even without a serial cable, you just have to interrupt the boot process by pressing a frontpanel key.
If you don't have network (what?!?), or trashed your second stage loader, you can flash using only a serial cable.
Flashing a new image
To flash a new image, you can use the second stage loader. It must be present, look below on how to restore it if it's broken.
The following steps assume you have a DHCP server. If you don't have one, you have to setup an IP address in the bootloader's serial setup. Oh, and it assumes you have a second-stage loader newer than Version 20. The Second-stage version is displayed when you poweron the box, in the LCD. look for "BOOT #22" (which is version 22). If it says "CF FOUND" instead, remove the compact flash card to see the version message. If it doesn't say anything, it's probably an even older version.
- Power down the Dreambox, either using "shutdown" (to enter the deep-standby mode) or by using the power-switch. Standby is not enough!
- Press and hold the lower frontpanel button.
- Switch on the dreambox, either by using the powerswitch or, in deep-standby mode, press the power button. Still, hold the lower button.
- A text "*** STOP ***" should appear. If something like "/flash".. appears, you didn't hold the right button.
- Now you can release the button. The bootloader entered the "waiting" mode.
- Above the "*** STOP ***" text, there should appear an IP-address (four decimal values with a dot in between). If there appears the string "dhcp" instead, the box still searches for a DHCP server. Wait a bit. If it doesn't change, something doesn't work with the DHCP server. Check wether network cable is plugged in etc. If it just doesn't work, set an IP using the serial terminal)
- Now, open a browser on your PC. enter in the address line "http://ip/" (where ip must be replaced with the value in the LCD).
- on the bottom of the page, there's a link called "firmware upgrade". Click it.
- On the next page, you can select the flash image you want to flash. be sure that it has the ".nfi" extension. You can't flash other images (like .img)!
- Click on "FLASH!" and wait. It might take some time to upload and flash the image.
- Switch the box off again, and on again. The new image should be flashed and working.
Different Boot sources
The Secondstage loader has the following boot sources:
source | argument | prefix for autoexec.bat |
flash | path into the first boot partition, usually starting with a /. example: "/autoexec.bat" for "/boot/autoexec.bat" | . /flash/ |
cf | path into the first FAT[12|16|32] partition on the compact flash card | /cf/ |
none | not used. used to temporary disable boot sources | – |
stop | not used. Used to enter the bootloader, for example for using the bootloader's web interface | – |
tftp | [server:][bootfile] – server and bootfile will be taken from dhcp when not available (but can be overridden) | /tftp/ |
Prerun
Prerun means that "/cf/autorun.bat" (sic!) will be executed before anything else. This can be useful if you, for example, want to put a flash upgrade app onto a CF card for upgrading a firmware without any other interaction.
Try Default Boot Sources
..just means that, when everything else failed, "/flash/zImage.elf" will be tried again. This is useful when you messed with your autoexec.bat…
Primary/secondary/Alternate boot sources
The "Primary bootsource" is the tried first (exception is "prerun", which comes even before). If this fails, the "secondary boot source" will be tried. (This can be useful to mimic the dbox2's boot behaviour: first try tftp, then flash. The reason for not defaulting to this is that the network init, including auto negotiation and DHCP timeouting takes several seconds.). The alternate boot sources can be enabled by pressing a key on bootup, either the "up" or the "down" key. "up" is alternative boot source 1, "down" the alternative source 2.
"Powerstate after AC loss"
Here you can setup what happens when you powered on the box with the hard-switch (or inserting AC power again). "as before", the most useful function, doesn't work yet. You can choose between "always on" and "always off".