Pebble v 0.8 - BETA: Simple bootsplash program

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

Pebble v 0.8 - BETA: Simple bootsplash program

#1 Post by Pizzasgood »

Note: version 0.9 BETA is now available:
http://www.murga-linux.com/puppy/viewto ... 553#156553
No major upgrades, but it should run a little smoother and supports logging of the hidden boot messages.

Pebble 0.8 - BETA!

Pebble is a very basic boot splash system. It can be disabled with the boot option pfix=nosplash, but there isn't a hot-key to disable it while it's actually booting. It does not have internal support for progress bars, but they can be implemented by using staged animation (Make stage_1 an image of a 0% bar, stage_2 and image of a 20% bar, etc., then just incriment the stage at key points. Not ideal, but it works.) One more thing not supported is split screen.

All these non-supported things are on my long-term to-do list, but will not happen in the near future.

Installing Pebble:
Installing Pebble involves modifying your initrd.gz file. Because of this, I can't just provide a dotpup. What I can do is provide pre-set initrd.gz files for a couple versions of Puppy, and hopefully enough documentation and examples for you to modify things yourself for other versions (I did try to make it as simple as possible when writing Pebble, and version 0.8 is the simplest yet).

For this guide, I will assume you're running Puppy 3.01. I'll also provide a package for 3.00, and these instructions will work for that too (just change 3.01 to 3.00). For other versions of Puppy, read this anyways to get an idea, then read the section afterwards for technical details.

Okay, first things first. Download pebble_p301-0.8.tar.gz from the bottom of this post. Extract it somewhere (clicking it should bring up a gui, but I prefer just opening a terminal and running tar -xf pebble_p301-0.8.tar.gz). It should spit out two things: a new initrd.gz file, and a petget titled "pebble_postinit-0.8.pet". We'll start with the easy part: Click pebble_postinit-0.8.pet to install it. That will install several things you'll need, including slight tweaks to some system scripts.
WARNING: This will modify /etc/rc.d/rc.country, rc.country-PUP217, rc.local0, and rc.sysinit. If you have any custom changes to those files, back them up and manually apply those changes to the new versions (or the reverse, whichever you prefer). Tkdiff is very handy for this purpose ;)

Okay, next you need to install the new initrd.gz and alter your boot commands. This part is going to be different for each person, though I'll try to cover as many situations as I can. I'll devote a section for each situation, but first I need to explain something common to all: the frame buffer. Specifically, how to set it. It uses the boot option vga=### where ### is either a number or normal. normal is what it defaults to when you don't use this option. Otherwise, it will be the mode that corresponds with the number. Different modes have different color depths and resoultions. For this guide, I will use 785, which is 640x480x64k. You're free to use whatever you want, but keep in mind that Pebble does not scale images yet, so make sure you set it appropriately for the theme you use (using too big a resolution won't hurt, the boot image will just be centered in the middle, surrounded by black). The default theme included with Pebble uses 640x480. The monkey theme is 800x600 (vesa=788). Also something to note: whatever you set will also apply to Puppy's CLI. It won't affect Xwindows, but when you drop out to the commandline, you'll have whatever resolution you use here.

Code: Select all

no framebuffer:  vga = normal 
1024x768x64k:  vga=791
1024x768x32k:  vga=790
1024x768x256:  vga=773
800x600x64k:  vga=788
800x600x32k:  vga=787
800x600x256:  vga=771
640x480x64k:  vga=785
640x480x32k:  vga=784
640x480x256:  vga=769
If you need any other modes, a quick web search can probably turn them up.


Now that that's out of the way, on with the installation.

LiveCD
If you use Puppy as a LiveCD, you will need to edit the Puppy iso to add the new initrd.gz file. Isomaster is a program that can do this, which is included with Puppy. Just use it to delete the old one, then plop in the new on I provided.

You also need to modify the isolinux.cfg file that is within the iso. Probably, you'll have to do that by extracting it from the iso, editing it, then putting it back in. Find the line that looks like this:

Code: Select all

append initrd=initrd.gz pmedia=cd
Change it to look like this:

Code: Select all

append initrd=initrd.gz pmedia=cd vga=785
(Don't change it to look exactly like that, just add the vga=785 part)

Okay, that should do it. At this point you should have a new iso file. If all went well, you should be able to just burn that to a disk and boot. If not, let me know exactly what you did, and post a copy of your isolinux.cfg (please put it within the

Code: Select all

 [/code ] tags, it's easier to read that way).



[u]Multisession[/u]
My sincere apologies, but I don't know how to do it with this yet.  I think you might be able to follow the directions above for LiveCD to create a new disk with the boot splash (burnt open for multisession), then remove your normal disk from the drive, insert the new disk, and just let Puppy save to that like it was the original.  I suspect that will work, but I'm not certain.  One of these days I'll have to test it, unless somebody can confirm that this works.



[u]Frugal/Full HD[/u]
I'm going to assume you use Grub.  If you use Lilo, add the vga=785 option to the append line of lilo.conf, and make sure you run lilo after you finish everything.
Okay, first you need to add the new initrd.gz file.  Where you put it depends on how you're system is set up.  In my case, I have initrd.gz at /mnt/home/boot/puppy301/initrd.gz.  You should know where it is on your computer, otherwise use [b]find / -name initrd.gz[/b] to find all initrd.gz files on your system, and determine which one to replace.  Once you have it located, just delete or rename it, then drop in the new version.

Second step:  Dig up your menu.lst file, which for me is at /mnt/home/boot/grub/menu.lst.  Find the line that looks like this: [code]kernel /boot/puppy301/vmlinuz PMEDIA=satahd
Change it to look like this:

Code: Select all

kernel /boot/puppy301/vmlinuz PMEDIA=satahd vga=785
(Don't change it to look exactly like that, just add the vga=785 part)

Now it should be finished. If all goes well, a reboot will start you up with a nice refreshing splash instead of text. If not, let me know exactly what you did, and post a copy of your menu.lst (please put it within the

Code: Select all

 [/code ] tags, it's easier to read that way).



[u]USB[/u]
Okay, first you need to add the new initrd.gz file.  Mount your USB drive.  The old initrd.gz file should be right there.  Just back it up somewhere and drop in the new one.

Next, edit the syslinux.cfg file.  Find the line that looks like this: [code]default vmlinuz initrd=initrd.gz pmedia=usbflash
Change it to look like this:

Code: Select all

default vmlinuz initrd=initrd.gz pmedia=usbflash vga=785
(Don't change it to look exactly like that, just add the vga=785 part)

Now it should be finished. If all goes well, a reboot will start you up with a nice refreshing splash instead of text. If not, let me know exactly what you did, and post a copy of your menu.lst (please put it within the

Code: Select all

 [/code ] tags, it's easier to read that way).

Now it should be finished.  If all goes well, a reboot will start you up with a nice refreshing splash instead of text.  If not, let me know exactly what you did, and post a copy of your syslinux.cfg (please put it within the [code ] [/code ] tags, it's easier to read that way).



[b][u]Technical Details[/u][/b]
You can skip this if you don't care how it works.  If you're interested in themeing, you'll want to read this.  Also usefull if you want to add Pebble to a version of Puppy I haven't provided a package for.

Okay, here's the brief overview of how Pebble works.  There are two key programs:  /bin/pebble-daemon and /bin/pebble.  pebble-daemon is the program that does the actual work of displaying the images.  It is not controled directly though, as that would be tedious.  Instead, /bin/pebble is the main interface point, but since the name "pebble" isn't very descriptive, it is symlinked to /bin/bootsplash, which is how I call it in all the files I've provided.  So to start the daemon, you'd call [b]bootsplash start[/b], and to stop it, you'd do [b]bootsplash stop[/b].  I'll go ahead and list all the options you should be using at this point (there are more if you read the scripts and sources, but they're leftovers from various other schemes, which I've neglected to delete in case I need them again):
[quote][b]bootsplash start[/b]
This starts the daemon.  It should only be used at the very beginning, to start things up.
[b]bootsplash pause[/b]
This pauses the daemon and restores the normal screen output.  You need to use this command before places in the boot process where things need to be shown to the user, such as the keyboard wizard, choosing a save file, etc.
[b]bootsplash resume[/b]
This resumes the daemon where it left off, after a pause.  Do NOT use this after a switch_root!  (that uses revive)
[b]bootsplash switch_root[/b]
This is necissary before Puppy does the switch_root.  It hibernates the daemon (saves the current state and frame, then shuts down without adjusting the display), and moves any important files (like the pipe) into the new filesystem.  Note:  This needs to be run before /proc and co. are unmounted (several lines above the switch_root, no biggie)
[b]bootsplash revive[/b]
This is what you use in /etc/rc.d/rc.sysinit to start the daemon back up after the switch_root.  It will load the previously saved frame and stage and continue where it left off.
[b]bootsplash next[/b]
This one increments the stage.  (This is overflow safe, so if you have more next's than you have stages, it will just ignore the superfluous calls).
[b]bootsplash previous[/b]
This decrements the stage, and is underflow safe the same as next.
[b]bootsplash stop[/b]
This shuts down the daemon and restores the normal output.[/quote]
In case your wondering about the stages, it's basically support for multiple animations.  See the section on theme format for more info.

These commands will mostly be in the /init file of the initrc.gz file.  There are also some in /etc/rc.d/rc.country, rc.country-PUP217, rc.local0, and rc.sysinit, at least in Puppy 3.01.  In other versions you'll need them in other spots.  Usually you'll want the [b]stop[/b] in rc.local0 though.

Just adding all these commands isn't enough though.  Puppy needs to have the frame-buffer enabled for this to work.  That's easy enough, just boot with the vga=785 option.  However, you'd find that doing that alone would render all CLI text invisible.  This is because you need to load the fbcon module for the console to output to the framebuffer.  Puppy doesn't have that module by default, so I compiled it myself, and added a line in /init to modprobe it (which was nice compared to in older Puppies that didn't have modprobe in initrd.gz, so you had to use zcat piped to insmod on fbcon and all it's dependant modules, which was kind of ugly).

And that sums up most all the changes I had to make.  I had to include the kernel modules, my binaries, and some dependancies for pebble within the initrd.gz file.  (Future versions will be statically compiled, and with smaller libraries like uclib).  The extra files you install with the PETget are just the modified rc.* files and the binaries.  The theme itself gets copied (if it doesn't exist already) by [b]bootsplash switch_root[/b].

If you want still more info, you can compare the packages I provided with the standards.  Also, I uploaded an extra package that contains diffs of all the modified files, along with the source and all the extra modules and libraries.  I apologize in advance about the source being kind of messy and undocumented.  I worked off of the nifty FBV image viewer app to avoid having to immediately write my own image processing rutines (I do plan to do that eventually).  Unfortunately, the author of FBV didn't seem to be fond of commenting his code.  Also, I haven't gotten around to cleaning up the src directory, so you'll find that the ./configure script is broken.  It isn't needed anyways, just use make.  Any documentation or license info in there is also the original stuff.  Mostly the only things I've altered are main.c and the make file.  The original source should be availible online, just check his old documentation for a link.  If not, I should have it on my drive somewhere.  (I fully intend to clean everything up soon, but I didn't want to delay uploading this beta just for superficial stuff like that.  I'm already over a month late and feel guilty for making poorani wait this long...)


[b][u]Theme Format[/u][/b]
First off, the supported image formats:  .bmp, .jpg, and .png.
Okay, now to explain how this works.  So far, it isn't very complex.  When Pebble starts, it reads /etc/pebble/theme to get the name of the theme to use.  Then it reads /etc/pebble/<theme_name>/theme.conf to get the configuration.  So if you have [b]theme[/b] set to [b]paw_fade[/b] it will load /etc/pebble/paw_fade/theme.conf.

The theme.conf files look like this:
[code]ram_glutton	false

stage
	fps			20
	images		stage_1
	loop		true
	loop_start	13
end_stage

stage
	fps			30
	images		stage_2
	loop		false
end_stage
This is a very simple example (though they don't get much more complicated). It has a single stage, looped, at 40 "frames per second". I quote that, because it isn't exact and will actually run a little slower than that (improving that is on the to-do list).

Before I continue, I should explain what a stage is. They are basically a method to have multiple animations, so that you can update things throughout the boot process. Each stage is one animation, and they're stored in the order defined. When you run bootsplash next it will move on to the next animation in the sequence, and bootsplash previous goes to the previous animation. In this way, you could implement a loading bar. You'd set the first stage's image to be an empty bar, the second stage's as a 10% bar, the third's as a 20%, etc. Then incriment it every so often within the boot scripts.

It's not as robust as I'd like yet, as it can only be incremented and decremented. You can't just tell it to use stage 4. I'll improve it some day, but it's not high on my priority list.

Okay, so now that that's clear (hopefully), I'll explain the file on a line-by-line basis:

Code: Select all

ram_glutton	false
This can be set to either true or false. It's essentially an option to make a tradeoff, of ram for speed. If you leave it set to false, Pebble will load only one image at a time. When it goes to the next frame, it unloads the old image and loads the next. This can be a little slow. Enabling ram_glutton will cause it to load every single frame (in every single stage!) right at the beginning, and keep them loaded until it's shut down. That means it might take a little longer to start up, but then it will run more quickly and without eating as much CPU time. However, this uses a LOT of ram, as the images are stored completely decompressed within ram. If you have, say, a 40 frame animation using 800x600 jpg images, it can easily use 50+ mb of ram. Thus why it's optional. You should enable it for small animations, especially if it's just a single frame (no such thing as static, just animations with a single frame), otherwise that same image will keep getting loaded and unloaded, which is pretty stupid.

Code: Select all

stage
This initiates a stage section.

Code: Select all

	fps			20
This sets the framerate for the stage, in "frames per second" (yes, each stage can have its own framerate). The actual framerate will be a little lower than this though. Probably shouldn't go higher than 60 either, due to monitor refresh rates...

Code: Select all

	images		stage_1
This one is important. It sets the location to look for the stage's images. How it works is like this: "/etc/pebble/<theme>/<stage_image_option>/*", so if you're using the theme paw_fade, the images this refers to would be at /etc/pebble/paw_fade/stage_1/. Now I need to explain how animation works. Basically, it just goes through all the files in that directory in alphabetical order. So it's best to name them as 0000.jpg, 0001.jpg, 0002.jpg, etc. so that you ensure they get played in the correct sequence. (Starting with 0 and working up will help when you get to the loop_start option...)

Code: Select all

	loop		true
This sets whether it loops or not. If you set it to false, it will just play through the sequence once, then stop on the last frame.

Code: Select all

	loop_start	13
This one only applies if looping is true. It sets which frame (numerically) starts the looping sequence. So in this case, it will play through the entire sequence of frames once, then after finishing the final frame it will warp back to frame 13, then continue through the sequence, always looping back to 13 after it finishes. This is a good way to have an "intro" effect, like the fade-in that the paw_fade uses. In that case though, it has looping set to false, since it doesn't change after the fade. But with this option, you could have it fade in, then have an animation afterward. Then using loop_start would be handy, so you wouldn't have to keep re-playing the intro.
And please take note: This goes by number, NOT filename. It doesn't care if an image is named 13.jpg, m.jpg, or Zeratul.jpg, so long as it comes 14'th when they're put in alphabetical order. No, that isn't a typo. I'm indexing from 0, so the first frame is 0, the second is 1, etc. This is why I suggested naming your images starting with 0000.jpg. If you don't like it, hey, this is open source. Just go add a +1 in the appropriate place, recompile, and add the new binary to /bin in initrd.gz and the normal filesystem.

Code: Select all

end_stage
This ends the stage section.

Then it just goes into another stage section. As you can see, you don't do anything special like numbering the stages. Just define them in order. Also, you can have multiple stages pointing at the same location for images. That might come in handy if you want the first and last sections the same, but need something different in the middle. Or if you want to alter the looping or framerate mid-way through.

And, that's a theme file.


Adding a new theme
If you want to add a new theme, you'll need to edit the initrd.gz file and add it to the relevant place (etc/pebble/). Don't forget to set etc/pebble/theme to contain the name of the theme. During the boot process, any new themes will automatically be copied from initrd.gz into the save_file, as long as they don't already exist (currently, it will not overwrite any existing file other than /etc/pebble/theme, though I plan to improve it so it can tell which files are newer).

To edit initrd.gz, open a terminal in the same location as it (make sure it's a linux partition), and run this:

Code: Select all

mkdir initrd-tree
cd initrd-tree
zcat ../initrd.gz | cpio -i -d
That will make a directory initrd-tree that contains the contents of the initrd.gz file. Go inside and edit away. When you're finished, from inside the initrd-tree directory, run these commands:

Code: Select all

find . | cpio -o -H newc | gzip -9 > ../initrd.gz
That will replace the old initrd.gz file with the new one. Now just copy that into the correct place, and you're good to go!
Note: There may be an error/difference with Puppy's cpio program, resulting in an absurdly large initrd.gz due to dereferencing symlinks. There are a couple solutions. The simplist is to use the dev package I provided below. It includes a script you can just click to build the new initrd.gz file. Make any changes in the new-initrd-stuff directory, and click the makecpioinitrd script. Or, you could just overwrite Puppy's cpio with the one included in the dev package, then follow the first set of instructions I posted. If you happen to have the unleashed-core installed for Puppy 3.xx, you could also steal the cpio program from the boot/ directory of it, as that's the same one I used.



Packages

These are the pre-packaged packages mentioned in the installing section:
http://www.browserloadofcoolness.com/so ... 0.8.tar.gz
http://www.browserloadofcoolness.com/so ... 0.8.tar.gz

This is the extra package, which includes everything in both of the above packages, along with diffs and the source.
http://www.browserloadofcoolness.com/so ... 0.8.tar.gz
In the 300/ and 301/ directories, you'll find these directories:
initrd-tree_ORIG
new-init-stuff
along with this script:
makecpioinitrd
Clicking that script will create a directory "initrd-tree" and populate it with the combined contents of initrd-tree_ORIG and new-init-stuff, then build a new initrd.gz file. You can use that as an easy way to modify things.
Last edited by Pizzasgood on Wed 28 Nov 2007, 04:30, edited 2 times in total.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

Great work

#2 Post by ecomoney »

Great work, everything seemed to go fine on my 3.01 install (ac97 sound and graphics, p800, 392mb Ram). The boot process seemed to take a long time but I noticed it did this under the new 3.01 setup anyway (something about having to load the pup_save.2fs file that wasnt there before?). Anyway, I could find no faults with the program apart from the improvements that you say need doing (great bootsplash btw!!!). The only rude interruption was the screen asking me which pup_save file to use, which looks even worse by comparison now!

At last puppy is looking like the fine distro that it is, many thanks for the long hours that this must have taken you. I look forward to seeing and testing your refinements. Im hoping this will be ready to be included in the next 3.03ce.
Puppy Linux's [url=http://www.murga-linux.com/puppy/viewtopic.php?p=296352#296352]Mission[/url]

Sorry, my server is down atm!

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#3 Post by Pizzasgood »

Should be. I'm taking tonight off, then will be spending tomorrow studying and working on that project I was hired for (been neglecting it to get this finished). Once I get caught up I'll finish up the output logger for Pebble, take care of any issues, and upload either a revision or version 0.9.

Oh, and working on Isolinux is also right up there on my to-do list, I haven't forgotten it.

One thing is that your initial boot will actually be a little longer, because it has to copy the theme data into the save file. For 3.03CE, the theme could be included within the pup_303.sfs file already, so that wouldn't be an issue. Also, the only reason it might have a noticible delay right now is that I included the monkey theme, which consists of 40 800x600 .jpg files. In 3.03CE we'd only need to include a single theme, probably comparable in size to the 13 frame 640x480 .jpg animation This package defaults to.

I also forgot to mention, any animation that's running will pause for a moment during the switch_root. That can't be helped. As far as I've been able to determine, it's impossible for anything to correctly survive the switch_root other than the init script itself (PID 1). Everything else either dies, or gets stranded in the old filesystem with no way to access the "real" filesystem. So the best I can do is have it store the current frame, shut down without disturbing the screen, switch_root, then start back up where it left off.

Not a big deal, and irrelevant when using a mostly static animation like the default one.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#4 Post by Pizzasgood »

I added a small section to the documentation about adding a new theme. I forgot to explicitly state that you need to add the new theme to the initrd.gz file. It should be obvious, but you could easily get confused when you notice that the theme also exists in the save_file...
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
ecomoney
Posts: 2178
Joined: Fri 25 Nov 2005, 07:00
Location: Lincolnshire, England
Contact:

Hi there

#5 Post by ecomoney »

Hi there pizzasgood

I take it that the theme files have to be in both the initrd.gz script and in the pup_3xx.sfs for after control switches from one to the other (after "pivot root"?). Roughly how much of a size increase in the pup_3xx.sfs file are we looking at? I know if jpg's are used then the less image there is in them (the more continuous single colour) the less space there is.

Im also thinking (and I down want to increase the spec of this project too far for the time being), could the "infrastructure" of pebble be used to provide a graphical shutdown screen as well (the classic "its now safe to turn off your computer").
Puppy Linux's [url=http://www.murga-linux.com/puppy/viewtopic.php?p=296352#296352]Mission[/url]

Sorry, my server is down atm!

User avatar
Juggz
Posts: 26
Joined: Wed 26 Sep 2007, 20:25
Location: Somewhere In The Northern Hemisphere...

STOKED!!!

#6 Post by Juggz »

@ Pizzasgood:

Know how that school stuff can go... I'm majoring in DM after I figured out how much crunch time ya have to put into CIS... :shock: :wink:

I bet you it's going to be sick, your idea is great!!! :D
In the words of the most wise Scrappy Doo, "PUPPY POWER!!!" :D

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#7 Post by Pizzasgood »

Yes, I could modify it to have a shutdown screen. In fact, I just jurry-rigged what I hope will provide that for someone. It can be done much more elegantly though, so I'll look into doing it in the "correct" way (really, just add a new parameter to the daemon telling it to read a different file than /etc/pebble/theme before starting, then do a little tweaking to the pebble script). The most painful part would be making sure it pauses for any time user input is needed, and that isn't hard.

As for duplicate theme data, it isn't needed in pup_xxx.sfs. Including it there would speed up the first boot, but if it doesn't exist, it will be copied out of the initrd.gz file before the switch_root. After that, it will already exist in the save-file, so future copies won't be needed.

Currently, it only copies things that don't already exist, regardless of new-ness. The exception is /etc/pebble/theme, which gets copied every time (it's only 5-12 bytes). I do plan to eventually have it overwrite any old files also, and I'll also probably limit it so that only files for the current theme get copied, rather than all themes.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

Post Reply