If you like BoxMatrix then please contribute Supportdata, Supportdata2, Firmware and/or Hardware (get in touch).
My metamonk@yahoo.com is not reachable by me since years. Please use hippie2000@webnmail.de instead.
Property:SDK-Firmware
BoxMatrix >> Lexicon >> FRITZ-Terms >> SDK-Firmware | @ BoxMatrix - IRC-Chat - Translate: de es fr it nl pl |
News | Selectors | Models | Accessories | Components | Environment | Config | Commands | System | Webif | Software | Develop | Lexicon | Community | Project | Media |
Computer | FRITZ | I18N | Telephony | Smarthome | Internet | Protocols | Multimedia | Formats | Hardware | Software | Research |
Term
Term: | SDK-Firmware | Wiki | Freetz | IPPF | whmf | AVM | Web |
Short for: | Software Development Kit Firmware | ||||||
Location: | Lexicon >> FRITZ-Terms | ||||||
Weblinks: | |||||||
Description: | USB-Stick containing Firmware to be booted from RAM. |
Goto: Preparation - Tips - Gallery - FRITZ!OS - SMW-Browser
Details
See also the explanation in german language I wrote in the passed Wehavemorefun Wiki.
SDK-Firmware is a specially prepared USB-Stick containing Firmware to be booted from RAM.
It is only supported in fw 5.01 - 5.54 for the 7270v2 and 7270v3 which have CONFIG_SDK = 'y'
.
The Kernel of these Firmwares has builtin Kernel-Modules which are normally external modules:
- USB modules: usbcore.ko, usbmon.ko, usb-storage.ko
- SCSI modules: scsi_mod.ko, sd_mod.ko
- Filesystems: msdos.ko, fat.ko, vfat.ko, ext2.ko, ext3.ko
- NLS modules: nls_ascii.ko, nls_cp437.ko, nls_cp850.ko, nls_iso8859-15.ko, nls_iso8859-1.ko
In userland these Firmwares have an udev-mount-sd hotplug script which calls boot_sdk.sh for each detected disk device.
Besides this there is an extended flash_update.ko which supports a ram_boot_file
parameter.
A SDK-Stick
requires 4 partitions, 3 of which must be labeled correctly:
rootfs
- ext3boot
- vfat - must contain thefirmware.image
to be booteddata
- ext3unlabeled
- swap
boot_sdk.sh uses blkid to check the presence of these 4 partitions on the specified disk, and terminates otherwise.
Next it checks for the presence of the string tffs=/tffs/[1-2]
in cmdline, which is present in running SDK-Firmware.
If the string was found the script terminates, if not the 3 labeled partitions are mounted to:
After resetting the watchdog the swap partition is activated with swapon -a
.
If not already present the TFFS partitions are copied using cat:
Next the md5sum of firmware.image
is compared to the stored checksum in /var/sdk/rootfs/firmware.md5
.
If both differ then firmware.image
is unpacked to /var/sdk/boot
using tar and /var/sdk/boot/var/tmp/kernel.image
is splitted into /var/sdk/boot/kernel.image
and /var/sdk/boot/filesystem.image
using split_image.
Now the TFFS dumps in /var/sdk/rootfs/tffs
are backed up to /var/sdk/boot
for the following steps.
Then the /var/sdk/boot/filesystem.image
is mounted to /var/sdk/squashfs
using the loop device.
The content of /var/sdk/rootfs
is deleted and the content of /var/sdk/squashfs
is copied there.
After a sync /var/sdk/squashfs
can be umounted again. Then the TFFS backups in
/var/sdk/boot
are restored to/var/sdk/rootfs/tffs
and firmware.md5
is updated with the previously calculated md5sum./var/sdk/boot/var
containing the unpacked tar image and /var/sdk/boot/filesystem.image
are deleted again.
Next /var/sdk/boot/boot.config
is created containing the kernel_args for the SDK-Firmware:
root=/dev/sdaX rw rootfstype=ext3 swap=/dev/sdaX tffs=1,0x40000 rootdelay=15
After a sync and a swapoff -a
the real magic starts:
insmod flash_update.ko ram_boot_file=/var/sdk/boot/kernel.image,boot.config,crc=0
Finally all SDK partitions are umounted and a reboot is performed.
The ram_boot_file
parameter of flash_update.ko and split_image are present from fw 5.01 to the latest fw 6.06.
But the boot_sdk.sh script is only present until fw 5.54.
Preparation
Here a Howto to create a SDK-Stick.
1) Check the prerequisites
- boot_sdk.sh only works if loop.ko is loaded, which is used for the Internal-Storage RAM disk. Make sure it's running.
- If you are using Freetz make sure you disable
freetzmount
and keep blkid ande2fsprogs
. - Do not use
Replae Kernel
in Freetz unless you preserve the additional builtin modules explained above - An SDK reboot has to umount the stick. Make sure no program locks ressources on the stick.
2) Partition the USB-Stick
Example: 4 primary partitions on a 4 GB stick (3859 MB in gparted) - see the Gallery:
- 2500 MB ext3 labeled
data
- 1000 MB ext3 labeled
rootfs
- 233 MB fat32 labeled
boot
- 128 MB linux-swap
Size, order and partition type (primary/logical) may vary, filesystem and labels must not.
3) Install the firmware
The firmware version may differ from the flashed firmware, but some combinations may not work.
- Rename the firmware to
firmware.image
- Mount the
boot
partition - Copy
firmware.image
there - Unmount the
boot
partition
4) Plug the stick into the box
- Plug the stick into the running box
- If your stick has an LED you notice activity
- After a few seconds all 5 box LEDs flash once in red
- The box boots into the SDK-Firmware
Tips
Detect being inside a SDK-Firmware
$ cat /proc/cmdline root=/dev/sda2 rw rootfstype=ext3 swap=/dev/sda4 tffs=/tffs/1,0x40000 rootdelay=15 $ cat /firmware.md5 4f82c62ea7bf86f2cfb430c8408be4c0 - $ df -h Filesystem Size Used Available Use% Mounted on /dev/root 980.5M 70.2M 860.5M 8% / /dev/mtdblock5 2.0M 436.0K 1.6M 21% /data /dev/loop0 3.9M 261.0K 3.4M 7% /var/media/ftp
As expected /
is approx. 1 GB and is writable!
Mount the data partition
Partitions on a SDK-Stick are not mounted automatically (besides rootfs
and swap but they are nomally accessible.
The Webinterface just shows 1 Speicher (entfernt)
(german for "1 storage (removed)").
$ blkid /dev/mtdblock0: TYPE="squashfs" /dev/loop0: UUID="3b85c627-9dc1-4ed5-aa08-1fa5b17d92cb" TYPE="ext2" /dev/ramzswap0: TYPE="swap" /dev/sda1: LABEL="data" UUID="a034cd7a-0cf6-4a2c-a698-793f275d68c8" SEC_TYPE="ext2" TYPE="ext3" /dev/sda2: LABEL="rootfs" UUID="9d69b61e-32b7-4c9e-89dc-dc8085dc98af" TYPE="ext3" /dev/sda3: LABEL="boot" UUID="1847-F72C" TYPE="vfat" /dev/sda4: TYPE="swap" UUID="21c1cd29-8250-40b9-8cad-15d280ed63e3"
Of course fstab could be adapted but changes are lost with a firmware update and it does not create mount points.
In Freetz a persistent rc.local script is more reliable, since the cloned TFFS is preserved on SDK-Firmware updates.
Make sure you do not mount the boot
partition into /var/media/ftp
since it contains the TFFS partitions and the config.
The data
partition is completely free for whatever one desires and by default empty.
Here my rc.local, which already fixes a lot:
mkdir -p /var/media/ftp/uStor01 mount -t ext3 /dev/sda1 /var/media/ftp/uStor01 mkdir -p /mnt/boot mount -t vfat /dev/sda3 /mnt/boot mkdir -p /mnt/oldroot mount -t squashfs /dev/mtdblock0 /mnt/oldroot msgsend multid update_usb_infos
This is by far not perfect, the Webinterface still shows nonsense here and there.
But NAS, FTP, WebDAV, etc work. See the Gallery.
Don't be surprised about double reboots
If you call reboot from within the SDK-Firmware it will reboot twice.
The first boot boots into the flashed firmware, the second boot boots into the SDK-Firmware.
Gallery
If you want to extend the gallery with own work then please get in touch. See also the Photography-Inspiration article.