BYOF - Simplified firmware builder
BYOF is a PC tool to created your own firmware.
Version: 2.0
Status: Stable
Description
In order to simplify the development of custom firmwares that can be upgraded quickly and simply to reflect MediaGate releases, you can use the BYO firmware package and scripts. Included are a skin patcher, a user/developer target builder, and an upgrade packager. These tools are currently targeted for Linux, but a Windows port is planned.
Directories
The standard BYO package contains 3 sub-directories to store files used for patching the stock firmware:
- skin.Fixups contains all the files needed to change the skin of the firmware: a copy of the stock palette (in stock_v1.act), the royalblue new palette and the new skin images.
- cram.FixupsUser contains the changes from the stock firmware to create end-user firmware. By default, this is empty. If you choose to apply a skin to your firmware, mkskin will add the custom dvdplayer.bin and img subdirectory here .
- cram.FixupsDevel contains the changes from the stock firmware to create developer firmware. Like for cram.FixupsUser, if you choose to apply a skin mkskin will add custom dvdplayer.bin and img subdirectory .
During the build process, the following directories will/might be created, depending on your settings:
- cram.Stock will be created by 00-startup. The stock firmware cramfs image will be mounted here as a base for your custom firmware.
- cram.User will be created by mktarget if you set MODAUDIENCE=User in the settings file. This is where your custom user firmware image will reside during the build process.
- cram.Devel will be created by mktarget if you set MODAUDIENCE=Devel in the settings file. This is where your custom developer firmware image will reside during the build process.
Scripts
The BYO firmware builder contains 5 scripts to reduce the manual modifications necessary for building a custom firmware:
- 00-startup
- mkskin
- mktarget
- mkupgrade
- 99-finished
For best results, the scripts should be executed in that order. After the scripts have successfully executed, you should be left with a new .upgrade file. Its name depends on the stock firmware version you used as a base, and various settings.
00-startup
This startup script ensures you have a stock .upgrade file (downloading one if necessary), extracting the contained cramfs, and mounting it. To run it, simply use ./00-startup. This script can be run multiple times, but you should really only need to run it once. NOTE: Downloading requires the 'wget' utility.
mkskin
The mkskin script handles the modification of the stock dvdplayer.bin for applying a new theme, and puts the result in your cramfs target folder. It also copies any files located in skin.Fixups/ to the cramfs target folder. If you run mkskin more than once, be sure to re-run mktarget and mkupgrade to regenerate your .upgrade file.
mktarget
The mktarget scripts creates a new target cramfs folder, and populates it with a copy of the stock firmware image, as well as the contents of the cramfs fixup directory. It then performs a number of transformations based on your settings.
mkupgrade
The mkupgrade script extracts the linux.gz kernel image from the stock upgrade, creates a cramfs image from your target directory, and glues them together into your final .upgrade file.
99-finished
This cleanup script unmounts and deletes the stock firmware image, and removes the cramfs target and stock folders. This should always be run after you finish working on your target .upgrade.
Utilities
Along with the above scripts, there are a few extra utilities included that are required by the scripts:
- palfixup.py
- mg35tool
- mkcramfs
palfixup.py
The palfixup utility directly handles the patching of dvdplayer.bin with a new palette.
Usage:
palfixup [<arguments>]
Arguments:
{-s <stockdvd.bin> | --stockdvd=<stockdvd.bin>}
Identify the location of the stock dvd player to fix up with a new palette.
{-p <stockpal.act> | --stockpal=<stockpal.act>}
Identify the location of the stock palette to replace with a new palette.
{-o <customdvd.bin> | --output=<customdvd.bin>}
Identify the location to save the updated dvdplayer binary to.
{-c <custompal.act> | --output=<custompal.act>}
Identify the location of the updated palette to replace the old palette.
Example/Defaults:
palfixup -s cram.Stock/dvdplayer.bin -p skin.Fixups/stock_v1.act -c skin.Fixups/royalblue.act -o cram.Fixups/dvdplayer.bin
mg35tool
The mg35tool handles the splitting and joining of upgrade files.
mkcramfs
The mkcramfs utility creates a cramfs image from a directory. The basic command line is as follows:
mkcramfs <sourcedir> <destcramfs.img>
Settings
The settings are located in the settings file in the root of the BYO distribution. Each of the above scripts references these settings for determining how and what to do.
|
Name
|
Description
|
Default
|
|
LANG
|
Language identifier.
|
Eng
|
|
STOCKVERSION
|
Which stock .upgrade version to use.
|
1.5.1
|
|
STOCK_ROOT
|
The directory to create and mount the stock cramfs.img on.
|
cram.Stock
|
|
MODAUDIENCE
|
The target audience of the .upgrade to build. Can be User or Devel.
|
User
|
|
MODVERSION
|
The trailing version number to append to STOCKVERSION in naming the upgrade.
|
4
|
|
MODRELEASE
|
The release identifier for your upgrade.
|
alpha4_sf24
|
|
MODDER
|
The modifier tag for your upgrade.
|
JD
|
|
TARGET_ROOT
|
The base directory name for building your target cramfs. MODAUDIENCE will be appended after a '.'
|
cram
|
|
SKIN_ROOT
|
The source of the skin fixups. Your skin files should be in a subdirectory, with the palette in this directory.
|
skin.Fixups
|
|
SKIN
|
The name of the skin to apply.
|
royalblue
|
|
USE_SOFT
|
Create soft links (1) or hard links (0) for various executables.
|
1
|
|
USE_RBIN
|
Relocate executables (1) to /sbin/rbin in the target cramfs.
|
0
|
|
USE_BBREL
|
Create relative (1) or absolute (0) links to busybox.
|
1
|
|
USE_INTMK
|
Use the internal (1) or system-wide (0) mkcramfs to build the target image.
|
1
|
|
USE_NEWNBT
|
Use the original (0) or new (1) nbtscan.
|
0
|
|
USE_PARTRWRO
|
Keep (1) the ro1/ro2/rw1/rw2 partition-specific remounters.
|
0
|
|
USE_BIGBOX
|
Use the BIGbox (1) or standard busybox (0) for applets.
|
0
|
|
USE_ORGBAK
|
Create backups of bin,etc. in org (1) or not (0)
|
0
|
Download
You can obtain the latest version of the BYO firmware package here.
Thanks
Special thanks to gadgetmind, pbarette, icabrindus, teddystacker, and everyone else whose hard work make working around MediaGate much more palatable.
Comments
(VasileB) idea: place all the binaries from / and /bin to /org/rbin (for "root bin") and /org/bin respectively, and place symlinks in their original place pointing to the new locations. Now if you want to override one of the programs in /bin using unionfs, you can do that and still have access to the original application. (e.g. replacing /bin/nbtscan with a wrapper, which can still later call the original /org/bin/nbtscan). You can also replace the built-in players, but losing access to the original ones.
(VasileB) one more convoluted step, only for the root programs: place all the binaries from in the root directory to /org/rbin, as before. Now create a new directory /rbin and place in it symlinks to the programs in /org/rbin. Now create symlinks in / to the previously created symlinks from /rbin. What you have now is a symlink chain as in this example: /fileplayer.bin --> /rbin/fileplayer/bin --> /org/rbin/fileplayer.bin. The result is that you can override any of the / programs using unionfs over /rbin, while keeping access to the original programs in /org/rbin. A possible application is to create a new wrapper /rbin/fileplayer, which to parse the beginning of the .m3u files. If it's a "normal" m3u, call the original /org/rbin/fileplayer.bin. If it's a m3u file having an url as target, call the radio player. This way we can extend any of the built-in players, including /dvdplayer.
(John) How about just link root binaries into /bin, and if you want to keep them, move them (eg. to /bin/real) before you delete them?
(John) Alternatively, if no moving is desired, we could add a mirror of /etc, /bin, /sbin, etc. under /org in the cramfs, but leave the originals untouched (no symlinking). They would always be at a known location, take up very little space in RAM/cramfs, and require no modifications to target application locations.
(VasileB) Can you mirror the files in the cramfs, so they don't waste space? Something like a hardlink? That solves first ppart of the problem, the access to original files. But in order to override them, you need to have symlinks in / which point to another place you can unionfs upon (e.g. /bin, as you suggested), since you cannot unionfs the root directory. The only thing to test is if /dvdplayer works with symlinks in /, instead of real files.
(John) dvdplayer.bin (and the rest) work fine as symlinks.
Comments (0)
You don't have permission to comment on this page.