SqueezeOS Internals
From SqueezeboxWiki
Contents |
Firmware Layout & Upgrade
Flash partitions
Begin End Partition 0x00000000 0x00028000 uboot 0x00028000 0x0002c000 uboot env 1 0x0002c000 0x00030000 uboot env 2 0x00030000 0x00200000 zimage A 0x00200000 0x01600000 cramfs A 0x01600000 0x017d0000 zimage B 0x017d0000 0x02bd0000 cramfs B 0x02bd0000 0x03fd0000 yaffs
Uboot
This is the bootloader binary. It is installed in the factory and won't be upgraded in the field. This partition is not visible from Linux.
Uboot env 1 & 2
This is the bootloader environment variables. Dual partitions are used to provide redundancy for this data. This data is accessible in linux using the fw_printenv and fw_setenv commands.
zimage A / cramfs A
The bootable kernel and filesystem in the lower area of the flash. These images are always used together.
zimage B / cramfs B
The bootable kernel and filesystem in the upper area of the flash. These images are always used together.
yaffs
A read/write flash filesystem. This is mounted using an overlay filesystem over the current cramfs root filesystem allowing any files to modified. A factory reset will clear the yaffs filesystem restoring the Controller to an unmodified state.
Boot Process
The uboot environment variables control which image gets booted. The ‘kernelblock’ variable points to the flash block containing the kernel (c or 850) and the ‘mtdset’ variable is passed to the kernel to control the flash partitions. The running kernel and filesystem are mounted in the flash as read-only partitions. The spare kernel and filesystem are mounted as read-write partitions.
Upgrade process
- Parse /proc/mtd and /proc/cmdline to find the correct partitions for upgrading and to see which mtdset has been booted.
- Download the firmware using a url, either over the net or from sd card. The jive.bin file is really a zip file, this is decompressed and the files stored in /tmp.
- Using md5 checksum the downloaded images.
- Disabled the VOL+ function in the bootloader.
- Write the zImage and root.cramfs files to flash.
- Update ‘kernelblock’ and ‘mtdset’ to switch to the other partition map.
- Enable the VOL+ function to boot to the current running kernel and filesystem.
- Reboot
- On reboot detect that the jive version has changed and clean up the yaffs filesystem (this is still a TODO).
The u-boot bootloader looks for keys presses on boot. If any keys are pressed it trys to run the command “run swX” where X is the key number. By defining “swX” in the bootloader environment different commands can be run.
By default pressing ADD on boot will perform a factory reset.
Pressing VOL+ is enabled by the upgrader.
MAC Address & Serial Number
The device’s MAC address and serial number can be stored in the uboot environment variables. U-boot and the fw-setenv programs only allow these values to be written once. The MAC address is passed to the kernel on boot, and the /etc/init.d/wifi-init script parses this address from /proc/cmdline and reconfigures the wlan card.
To set a MAC address in u-boot use:
setenv ethaddr 00:12:34:xx:xx:xxsaveenv
To set a MAC address in linux use:
fw-setenv ethaddr 00:12:34:xx:xx:xx
To clear all addresses to allow the board to be reprogrammed then in u-boot do:
nande a 4096