Saturday, August 23, 2014

I recently got a 3D printer. A TAZ 3, to be precise. I've had a lot of fun!

Even when I've glued things the wrong way.

Wife recently found this pretty miniature sewing machine. Of course it needed a table. So off I went looking for reference pictures on the web and I came up with this.


It is on GitHub. At some point I guess I will cleanup and upload everything to Thingiverse. License GPL V3 have fun!




Sunday, February 12, 2012

Recreating LSPRO fw_env.config

In the process of upgrading my LSPRO to Debian Squeeze I found that I had no fw_env.config. That is, when I attempted to get the boot parameters I only got an error and bogus values:
# fw_printenv
Cannot parse config file: No such file or directory
Bummer...

As it happens, that file only contains the device, offset and length of the parameters in the flash memory. Also, there is a nice example already present in
/usr/share/doc/uboot-envtools/examples/
but I found that one after I made my own fw_env.config by hand.

So, the easy way to fix it:
# cp /usr/share/doc/uboot-envtools/examples/linkstation_pro_live.config /etc/fw_env.config
Here is the hard-ish way I actually used. Find the flash device info according to the kernel:
# cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00001000 "phys_mapped_flash"
With that, we know the device is "/etc/mtd0" and the erase size is 0x1000.

Then we can examine the flash device to figure out where is the actual data. It is probably aligned to the erase size and it is all text (except for a small header) so it should be easy to spot by simple visual inspection:
# hexdump -C /dev/mtd0 | less
Lo and behold, it is there near the end.
00038f70 90 6a f4 00 00 00 00 00 00 00 00 00 ff ff ff ff |.j..............|
00038f80 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
0003f000 48 aa b0 1a 62 6f 6f 74 61 72 67 73 3d 24 28 62 |H...bootargs=$(b|
0003f010 6f 6f 74 61 72 67 73 5f 62 61 73 65 29 20 24 28 |ootargs_base) $(|
0003f020 62 6f 6f 74 61 72 67 73 5f 72 6f 6f 74 29 00 62 |bootargs_root).b|
0003f030 61 75 64 72 61 74 65 3d 31 31 35 32 30 30 00 6c |audrate=115200.l|
... sipped for brevity ... 0003f3e0 6f 64 65 3d 68 6f 73 74 00 00 75 73 62 31 4d 6f |ode=host..usb1Mo|
0003f3f0 64 65 3d 68 6f 73 74 00 00 00 00 00 00 00 00 00 |de=host.........|
0003f400 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00040000
It begins at 0x3f000. Given that the erase size is 0x1000, it ends at 0x3ffff. And with that we can reconstruct the file:
/etc/fw_env.conf
#device   start   size   flash block size
/dev/mtd0 0x3f000 0x1000 0x1000

Saturday, February 13, 2010

Little Birds on our Backyard

It seems we got a couple of Tweeties nesting in our backyard. I hope they do not peck on peaople's heads!

Tuesday, June 30, 2009

My first ext4 dataloss!

I guess it was to be expected. Let's see:

1. Ubuntu Jaunty, kernel 2.6.29. Check.

2. An ext4 single partition (or at least a /home in a ext4 partition). Check.

3. Intel driver, using UXA. Check.

Bonus:

4. In a laptop after several sleep/power-up cycles. Check

5. Trying to save power by powering wireless up/down as needed. Check!!

Result: the laptop froze just as I had checked my last 5 minutes of work into Mercurial and was pushing it to my home server. Hard lockup. No emergency SysReq + Sync possible!! Upon reboot it was as if I had never saved the last 5 minutes of work.

Very interesting. Not much was lost and I could not detect any corruption. So I am kind of optimistic. I'll keep using ext4 for the time being.

I am considering making a fsync button, though!! ^_^

Thursday, January 1, 2009

Asterisk and a WGR614v9

I have a nice asterisk setup in a Buffalo Linkstation to get cheap international calls. It's worked nicely for several months.

On the other hand, the wireless router I used to have (a hand me down) had issues. A LAN port burned out, it provides 800.11b and the new laptop I have communicates poorly with it.

So with the new year I decided to get a new shiny WGR614 wireless router. Setting it up from my Linux network went fine. You are instructed to use http://www.routerconfig.net/ to get to the web setup provided by the router. So far so good.

But then Asterisk stopped working... strange. My VoIP provider (Sipphone) started giving 401 and 404 errors. As if my user and/or password were wrong. After many tries and false attempts to 'fix' asterisk and the router setup I stumbled on the answer.

Upgrade the firmware. That gives a nice new setting:

WAN Setup >> Disable SIP ALG


Voila!

Now I wonder. What was the router doing to mangle SIP packets such that other programs (Ekiga, for example) would work but not Asterisk?

But now it works, so I am happy.

Thursday, November 13, 2008

Backing up a new laptop

So I got a laptop, a Lenovo T500. But what to do with its funky Vista OS?

Well, wipe it out, of course! With Ubuntu perhaps. But nevertheless I'd like to keep a backup of what came in the hard drive. So, here is what I did.

1. Boot with Ubuntu Ibex. For that I had to get to the BIOS and force the Laptop to prefer to use the Intel card. Otherwise Ubuntu gets real confused about having two cards.

Once it booted I opened a terminal and got root.This assumess that networking works fine, the HDD works reliably, etc.

sudo -s


2. Mount a CIFS share to my desktop.

mount -t cifs -o user=my_username_there //mycomputer/my_username_there /mnt

cd /mnt


3. Backup the partition table

sfdisk -d /dev/sda > the-windows-partititon.dump


4. Backup the MBR

dd if=/dev/sda bs=512 count=1 of=the-windows-mbr


5. Now it is time to get to the main issue:

ntfsclone -s -o - /dev/sda1 | gzip | split -b 1000m - the-windows-sda1.img.gz_
ntfsclone -s -o - /dev/sda2 | gzip | split -b 1000m - the-windows-sda2.img.gz_
ntfsclone -s -o - /dev/sda3 | gzip | split -b 1000m - the-windows-sda3.img.gz_


To restore:

1. Boot with Ubuntu, open a terminal, get root

sudo -s


2. Mount a CIFS share to my desktop.

mount -t cifs -o user=my_username_there //mycomputer/my_username_there /mnt

cd /mnt


3. Restore the partition table

sfdisk /dev/sda < the-windows-partititon.dump


4. Restore the MBR

dd of=the-windows-mbr of=/dev/sda bs=512 count=1


5. Now Restore the partitions:

cat the-windows-sda1.img.gz_* | gunzip -c | ntfsclone --restore-image --overwrite /dev/sda1 -
cat the-windows-sda2.img.gz_* | gunzip -c | ntfsclone --restore-image --overwrite /dev/sda2 -
cat the-windows-sda3.img.gz_* | gunzip -c | ntfsclone --restore-image --overwrite /dev/sda3 -

Sunday, October 19, 2008

Towards easier suspend for my PC

I have several PCs at home (Debin Sid). It uses a lot of power. I fear the elctric bill, but I like my PCs to boot fast...

Suspend (suspend to ram) to the rescue!!! ^_^

That is, when it works. But fixing things is already discussed elsewhere. In my case it meant not using the forcedeth Ethernet card on the mother board, but a an oldish PCI 3com instead (although I'd still like to be able to WoL so I might change the 3com for another one).

But I digress. What I've done so far has been to:


  1. Convince pm-tools that yes, it is OK to force s2ram.


  2. Coax GDM to use s2ram -f


  3. Get into every account I have at home and set power management preferences to suspend after 1 hour of inactivity and to suspend on the power button.


  4. Modify the ACPI power button script to suspend instead of powering down. ACPI calls this script to make KDE and/or GNOME aware of the power button action or to shutdown by default otherwise



In short, I wanted to make it really easy to suspend instead of powering down.

For 1) I edited some file in /etc... Unfortunately I had to try so many things I do not remember what I did to successfully make suspend to work, even tough s2ram complains the machines are unknown.

For 2) one I edited /etc/gdm/gdm.conf and added under [daemon]


SuspendCommand=/usr/sbin/s2ram -f


For 3) I just logged into every account (I am root afer all) and changed the power settings for KDE and gnome. I am sure there is a way to change the default. I just got lazy. After fixing everything else.

For 4) I edited /etc/acpi/powerbtn.sh to to s2ram -f instead of the usual shutdown:


# If all else failed, just initiate a plain shutdown.
#/sbin/shutdown -h now "Power button pressed"

# regelatwork: canged to sleep instead of shutdown
/usr/sbin/s2ram -f


This is still not good enough, though. It is still too easy to shutdown from inside a session. It'd be nice to have a simple way to do a logout+suspend instead. Better still for that to be the default logout option and for shutdown to ask something like "are you sure you do not want to logout and suspend instead?"

Also, it is too easy to Shutdown from GDM (it is the default Action). I'd like a similar warning message along with suspend as the default.

Pehaps I'll have to bite the bullet, get my hands dirty and code some scripts and modify some Gnome/KDM code to have things my way.