jeudi 20 septembre 2012

Raspberry pi underclock, from 200 to 50MHz

Underclocking the raspberry pi, running a fresh archlinuxarm install, is funny.

At 50MHz text mode runs fine. But the usb chip seems to have issues (unresponsive keyboard). The provided firmware for the rpi isn't really an all purpose driver pack, IIUC they made decisions based on the original use-case for the SoC (video/dsp applications) like having naive hi-freq polling of the usb chip (again IIUC) which might overwhelm the throttled cpu.

At 100MHz almost no glitches, except on full terminal/screen redraw (htop, less, etc). Anything fancier will becoming a zen exercise.

I ran xorg + dwm + emacs (gtk) at 200MHz, it's harsh, but mostly because of graphic render; since I've used the lo-perf vesa driver I can't be too surprised, maybe with some X tweakings it can get smoother.

I'll try to run it around 20MHz, with ssh instead of usb keyboard. All this reminded me that my first computer was a Pentium 60 (fanless of course ;).

ps: clock settings are located in /boot/config.txt, a simple arm_freq=200 and a reboot will do. You can have min/max values to be used by cpufreq dynamic throttling. Follow here : http://www.raspberrypi.org/phpBB3/viewtopic.php?f=2&t=3042

lundi 16 juillet 2012

Bedroom museum, part 1 : IDE HDD

Who said hard drive fails. Plugged a Seagate ST32122A 2GB 4500RPM IDE. Didn't like its first boot but runs fine now, crunchy though. Debian 3.0 on it (300MB used), as soft NAT router.

For fun, reading tests:

luser@x60s_GPT ~ (master*) % sudo hdparm -tT /dev/sdb

/dev/sdb:
 Timing cached reads:   1586 MB in  2.00 seconds = 793.22 MB/sec
 Timing buffered disk reads:  20 MB in  3.02 seconds =   6.62 MB/sec


luser@x60s_GPT ~ (master*) % sudo hdparm -tT /dev/sdb

/dev/sdb:
 Timing cached reads:   1582 MB in  2.00 seconds = 791.04 MB/sec
 Timing buffered disk reads:  20 MB in  3.04 seconds =   6.58 MB/sec


take that MicroSD.

samedi 14 avril 2012

Notes about Chrome Tabs. Ctrl, Shift and multiple tabs selection.

Messing with too many opened tabs in Chrome, I'm missing Firefox Tab Groups / Panorama. Just to bitch about Chrome I start shift-clicking tabs .. when they actually start to move together.  


It actually does what you'd expect:
  • Maintain SHIFT, click on two tabs, they're now a selected tab interval.
  • Maintain CTRL, click on many tabs, they're now a selected tab set.
The selection can be moved around in the tab bar, onto another window, or out to a new one. If you fiddle with a sparse tab set, the tabs will group together. It lacks a bit of user feedback, but beside that it does what you'd expect.

note: I run Chrome '20.0.1100.0 canary' on Windows XP.

Can't find any documentation about it, don't know if it's new or not.. but it's sure cute.


Edit: Tab Selection is really thought through. Operations allowed also include : 

  • pinning
  • closing* selection
  • closing* all but selection

(*) close a group isn't directly undo-able, Ctrl-Shift-T will re-open one at a time. nothing too bad.


And it's actually one year old. 'multiple tabs selection' or 'multiselect tabs'. cf these :
http://exde601e.blogspot.fr/2011/03/multiple-tab-selection-in-google-chrome.html
http://lifehacker.com/5791787/select-multiple-chrome-tabs-by-domain-or-history
http://www.thechromesource.com/tag/multiselect-chrome-tabs/
http://src.chromium.org/viewvc/chrome?view=rev&revision=78884


There's more: you can also select by domain or by opener.

vendredi 13 avril 2012

LFS : hard drive partition as virtual vmdk drive in Virtual Box 4.1.12

I built LFS on a usb key, Kubuntu as a host. To run it I have to `halt` and then boot the usb key. I wanted to see how it runs on bare metal sort of. But now I want to tinker the system so I tried to see what virtualbox can offert. Turns out they support that (virtualbox do a lot of things, dhcp, port forward, you name it).

version used: 
Virtual Box, `VBoxManager --version` => 4.1.12r77245
Kubuntu 12.04b2 ~ 13/04/2012

1) create the vmdk file that represent your real partition:
VBoxManage internalcommands createrawvmdk -filename $path/$name.vmdk -rawdisk /dev/$disk -partitions $partition-number


for my needs it turned out like this:
VBoxManage internalcommands createrawvmdk -filename /home/foobar/VM/lfs.vmdk -rawdisk /dev/sdc -partitions 1


1.5) There's a permission issue, it seems that /dev/sda is only accessible for root, and forbids virtualbox to load the vmdk that points to /dev/sda2. For now run virtualbox as root. Maybe `chown` and `chmod` can correct the problem. I may try that later.


2) create a virtual machine, choose 'use an existing disk' and points to the vmdk. There might be another vmdk beside (name contains '-pt', partition tables ?? maybe), ignore it.


3) adjust the drives

When I boot the usb key on my laptop, remember:
- the lfs system is stored on partition 2 (counting from 1)
- For grub, the internal sata drives is hd0, the usb key is hd1 => grub run `linux (hd1,2)/boot/vmlinuz root=...`
- For linux kernel, the internal sata drives gets 'sda', the usb key gets 'sdb'. => we have to be sure to pass /dev/sdb2 as root for the kernel.

But in virtualbox, at first there's only one drive, the vmdk. So you need to create sata drives to match the configuration in the lfs partition. I added an old vdi virtual image drive, anyone will do, it's just a dummy placeholder that won't be used. Now I got 2 disks, vmdk and vdi. The vmdk being inserted first is plugged on sata port 0, the vdi on port 1. To swap this order, put the vmdk on 2, then the vdi on 0, then vmdk on 1. Now you're virtual boot time config is isomorphic to the real laptop system.


Now it should boot the kernel and reach init without issues. Right now my main problem is that the network interface isn't working. I suck at using `ip` but I got to fix this in order to build blfs.

mardi 10 avril 2012

LFS Success. Retrospective.

You have successfully registered!
ID: 23340
Name: agumonkey
First LFS Version: 20120409
© 1998-2012 Gerard Beekmans. Website design by Jeremy Huntwork & Matthew Burgess.
Finally I boot a LFS system.

I don't remember, it might be my 5th attempt ? development branch no less.
Never could go further than new system gcc/glibc.
Couldn't put my mind into solving.. too much noise. Weak mental.

Wasn't a walk in the park this time, what went wrong. Or what I should call
'The Overlook List' :

- choose a host
  last attempt was on a usb key 1Go for debian live, 6Go for the new lfs
  Failed early, stayed that way.
  last attempt started bad, I didn't pay attention and used lfslivecd which was obsolete.
  => realize that no special os needed, just a right set of tools
  now I thought to reuse the usb key and debian .. but I didn't want to boot another system.
  => realize that no special os needed, I run Kubuntu .. it's actually enough even for the latest SVN branch.

- headfirst style
  Created a local lfs user. Used $HOME/lfs as target for $LFS.
  I went through the book simply. This time not writing commands, I now understand sed enough
  so I can just copy/paste, and avoid time-wasting typos.
  By the time I reach the chapter 7 I wonder how I'm gonna boot this local folder.
  So I skip the beat, erase the usb key 2nd partition. cp -R $HOME/lfs /media/usb
  and try to finish there.

- lfs-bootscript, wrong sudo : host corrupted
  In a hurry I try to trick make to install bootscripts using DESTDIR variable.
  Except, I think, that sudo doesn't inherit the environment, thus letting make
  do its job using the host /.
  Luckily, Kubuntu init.d wasn't too corrupted, network setup takes 2 minutes
  now but it still boots. At first I thought I was good for a full setup.

- can't compile kernel (predefs.h not found)
  Not caring much about Kubuntu, I reach the kernel compilation step.
  To my surprise I made something wrong. Someone in the toolchain complains about
  about 'predefs.h' and 'bits.h' not being found. Seems related to kernel headers.
  Problem : too complex, Brain : too weak.

- redo & build an env
  Frustrated by the bare naked, information overload, and fragility. I try to improve a bit
  the process. I recreate the lfs user, add a .bash.d with :
  - extract function
  - lfs specific variable setup
  - a little login message to remind me of what variables are set or not.
  Nothing fancy at all, but it's already easier.
  I also time and log everything:
  `time make $cmd 2>&1 | tee $logs/$chapter/$(basename $(pwd))-$cmd.log` ; echo ">>> $?"

  I can leverage history key bindings almost blindly. Almost.

- grub road bump
  Things are smooth, no more `sudo` havoc, kernel compiles. I'm anxious about the
  grub process but anyway.
  Grub stops, saying he can't do shit, but even grub1 is nice enough to let you poke
  around live. The usb key is hd0, so I prepend the vmlinuz path with (hd0,2).
  F10 to run. 'Decompressing Kernel...' followed by kernel panic.

- IRC saves the day again
  Can't count how much knowledge I got on IRC channels.
  @Ratrophy tell me to add rootdelay=n[seconds] to avoid mounting before the usb key is
  fully setup.
  Works fine, now the kernel only panics, but for a totally different reason.

- FS drivers !
  It's been a long time since I've compiled a kernel, the menu organisation changed a bit.
  I didn't see EXT4 because it's written Extended Fileblahblahblah-long-wording Version 4.
  Okay, since I kept linux source in their compiled state, I can rebuild it quick with ext4 module.
  ...
  Seems that it needs to be builtin. Oh yeah there's no initrd .. I don't understand it all but
  someone has to have ext4 builtin.
  Now it .. panics. Saying /dev/sda can't be mounted. My kernel parameters mention /dev/sdb
  so Y U NO bOOT ?!?

- fstab ...
  Ah I copied the fstab from the book taking a bet on the device name, thinking the usb key would
  get sda since I boot on it. Wrong. Let's go vimcorrect that.
  Now I reach init ! and then I see a horrifying error message talking about forced halt.

- Stubbornness => single mode peeping.
  So :
  - the bootloader is fine
  - the kernel is fine
  - the filesystem is fine
  - the userspace is fine ( as in, program runs when chrooted in the host )

  This can't be serious. I poke in grub, making the FS rw.. No progress.
  Some setups drop the kernel into a shell. I wish I could.. I can only try single user mode.
  Rewrite grub.cfg `linux (hd0,2)/boot/vmlinuz-xxx root=/dev/sdb2 ro single init=/bin/bash`
  Boot, and here it is, the glorious shell. First time I type in that state.
  Can't do shit since the FS is ro, but I understand that only 10 minutes later.

- devtmpfs investigation
  I try running the bootscripts by hand, line by line.
  `mount -t -o procfs none /proc`
  Now ps works ... nice but not what I want.
  I mount everything until I realize /dev is quite empty. What is udev waiting for ??
  `mount -t devtmpfs .. /dev` => error, unknown fs type devtmpfs. WAT
  What is devtmpfs anyway ? isn't it devfs ?
  Then my eyes catch the huge NOTE saying not to forget to activate 'devtmpfs' ...
  Okay, reboot Kubuntu, recompile (the whole) kernel.

- Register
  Yep it boots, grub >= kernel >= init >= login.
  60MB used, 38 for cache. Not bad Linus.

- BLFS ? Not so fast
  - the network is not setup right
  - I got a static IP
  - no route to my internet gateway
  - there's no ssh, no wget. only ftp is on the system

- Ending notes
   Even though I've had a lot of criticizing in my head about LFS, it's a wonderful tutorial.
   Thanks a lot to their team.

lundi 9 avril 2012

LFS random discovery : time bash builtin and /usr/bin/time

I'm trying to instrument a bit LFS commands. I often wrap `make` into time + tee.
Exit status is often 0 even if make reports errors. Does time report it's exit status ? or the parameter command's one ? .. well it seems that make or the Makefile was design to return 0 even on 'unexpected FAIL' so time says everything is OK. Meanwhile I googled a bit to investigate and stumbled upon that : http://stackoverflow.com/questions/9715570/gnu-time-and-formatting-output

Ahh noobery strikes again.

samedi 7 avril 2012

bash_it color generator cost me 8 seconds at login



  • trying bash_it
  • sluggish login time
  • need : bash debug using -x, set PS4
  • trace -> inspect under vim
  • discover fancy color name generator
  • perlishly lispy thing
  • large set of nested, args eating, function aggregating bits of term code on the output
  • very DSL
  • followed by a cute 30-something calls to generate a set of {,bold,underline,blah}color variables.

I may be wrong, it seems this stacking of functions is not very cheap, at least not on my VM on a core duo. When I trace the login, thousands of calls, 90% are color related, mostly identical. I feel like looking at the naive recursive Fibonacci function.

Anyway disabling colors made bash-it invisible (sic) again.

cheat url summary :

- PS4 string to see stack >>> http://wiki.bash-hackers.org/scripting/debuggingtips
- Trace, tee log a script >>> http://www.commandlinefu.com/commands/view/3310/run-a-bash-script-in-debug-mode-show-output-and-save-it-on-a-file
- Mass comment in vim >>> http://vim.wikia.com/wiki/Commenting_out_a_range_of_lines

and the original project :

- bash-it >>> https://github.com/revans/bash-it