Creating 3 MTD partitions on "orion_nand": 0x000000000000-0x000000100000 : "u-boot" 0x000000100000-0x000000500000 : "uImage" 0x000000500000-0x000020000000 : "root"
Friday, 06 January 2012
mtd-utils
(Comments)
Quick node about this useful project I packaged two days ago. It has a long FAQ - I was interested in how can one access the builtin nand storage on an arm board using it.
First, check your dmesg, you should see something like:
Creating 3 MTD partitions on "orion_nand": 0x000000000000-0x000000100000 : "u-boot" 0x000000100000-0x000000500000 : "uImage" 0x000000500000-0x000020000000 : "root"
As the names say, the three items here are the bootloader, the kernel and the root filesystem. To access and mount the last one, you need:
ubiattach /dev/ubi_ctrl -m 2 mount /dev/ubi0_0 root ... hack hack hack ... umount root ubidetach /dev/ubi_ctrl -m 2
Wednesday, 04 January 2012
Frugalware arm port install HOWTO
(Comments)
I recently got a GuruPlug. It has Debian by default, and it’s apt config is set to stable, while in fact at the moment what’s the factory default is considered as oldstable by upstream. So if you blindly do a few apt-get install foo, soon you’ll have newer userspace than kernel, and your device will no longer boot (based on true story - and yes, this is not Debian’s fault). Moreover, I was interested in how to install Frugalware on this device, so here is a quick howto.
First you need to bootstrap Frugalware from Debian. It’s a good idea to install Frugalware on a USB stick, so you can switch back to Debian in case you messed up something and start from scratch again.
Partitioning is up to you, you’re recommended to have a small FAT (type: 0x0b) partition (32MB for example) at the beginning, we’ll use that later. The second can be the rest, ext4 or so.
Format and mount it (your device name may differ!):
mkfs.ext4 /dev/sda2 mkdir -p /mnt/sda2 mount /dev/sda2 /mnt/sda2
Then install our pacman-g2 binary to the Debian system, so you can bootstrap:
wget http://ftp.frugalware.org/pub/frugalware/frugalware-stable/frugalware-arm/pacman-g2-3.8.3-2mores2-arm.fpm unxz pacman-g2-3.8.3-2mores2-arm.tar.xz cd / tar xf /path/to/pacman-g2-3.8.3-2mores2-arm.tar rm .CHANGELOG .FILELIST .PKGINFO
Installing the required packages is a single command, as described here:
pacman-g2.static --noconfirm -Sy core base -r /mnt/sda2/
Once the rootfs is ready, you need a new bootloader that will be able to boot our vanilla kernel.
You need a JTAG Board, so you can access the serial console. If you connect the USB cable to you PC, you can use for example
screen /dev/ttyUSB0 115200
to access the device.
Given that we want to boot a vanilla kernel, we need a vanilla bootloader as well. Before you mess with the bootloader, it’s a good idea to make a backup of its config (there is a 3 second timeout during boot - if you press any key there, you get the Marvell prompt). Here is my config:
Marvell>> printenv
bootcmd=${x_bootcmd_ethernet}; ${x_bootcmd_usb}; ${x_bootcmd_kernel}; setenv bootargs ${x_bootargs} ${x_bootargs_root}; bootm 0x6400000;
bootdelay=3
baudrate=115200
x_bootcmd_ethernet=ping 192.168.2.1
x_bootcmd_usb=usb start
x_bootcmd_kernel=nand read.e 0x6400000 0x100000 0x400000
x_bootargs=console=ttyS0,115200
x_bootargs_root=ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs
ethact=egiga0
bootargs=console=ttyS0,115200 ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs
ipaddr=10.10.10.10
serverip=10.10.10.179
ethaddr=F0:AD:4E:00:CE:C3
stdin=serial
stdout=serial
stderr=serial
The only semi-unique part is the MAC address of the network interface(s).
If you want to update the bootloader, a possible way is to put the new binary to a pendrive. Given that the default bootloader does not support ext*, we need a fat filesystem. So format the first small partition we created already (the device name may be different in your case!):
mkdosfs /dev/sda1
Till Frugalware 1.6 is released, support for GuruPlug is available in Frugalware -current only, so download the binary package from there, extract the u-boot.kwb file from the guruplug directory, put it to the new partition. (A few other models are explained here).
Before you reboot, copy also /boot/uImage to the fat partition, you may have problems problems with reading the kernel from the ext4 partition with u-boot.
Once copying the kernel is done, reboot and in the u-boot shell do:
usb start fatload usb 0:1 0x0800000 u-boot.kwb nand erase 0x0 0x60000 nand write 0x0800000 0x0 0x60000 reset
You can verify the updated bootloader with the version command:
Marvell>> version U-Boot 2011.12 (Jan 03 2012 - 16:55:38) Marvell-GuruPlug gcc (Frugalware Linux) 4.6.2 GNU ld (GNU Binutils) 2.22
If Frugalware is mentioned, that’s a good sign. :)
Now you can boot your new rootfs:
usb start fatload usb 0:1 0x00800000 /uImage setenv bootargs console=ttyS0,115200 root=/dev/sda2 rootdelay=5 bootm 0x00800000
If it booted fine, you may want to make this the default:
setenv bootargs 'console=ttyS0,115200 root=/dev/sda2 rootdelay=5' setenv bootcmd_usb 'usb start; fatload usb 0:1 0x00800000 /uImage' setenv bootcmd 'run bootcmd_usb; bootm 0x00800000' saveenv
The rest is up to you:
setting up a root password
setting up network by default using netconfig
and so on… you know this already, nothing arm-specific.
For the reference, here is the tested CPU and Frugalware version:
$ cat /proc/cpuinfo Processor : Feroceon 88FR131 rev 1 (v5l) BogoMIPS : 1191.11 Features : swp half thumb fastmult edsp CPU implementer : 0x56 CPU architecture: 5TE CPU variant : 0x2 CPU part : 0x131 CPU revision : 1 Hardware : Marvell GuruPlug Reference Board Revision : 0000 Serial : 0000000000000000 $ cat /etc/frugalware-release Frugalware 1.5 (Mores)
Saturday, 24 September 2011
Userspace boot speed: less than a second
(Comments)
I did not care about boot speed for a long time, since servers usually restarted only for kernel upgrades, laptops suspend to ram all the time, and I have no desktop machine at home for years now. Though one use case started to motivate me recently: I use virtual machines a lot, and waiting for them to boot up is boring.
So I looked at the systemd-analyze blame output, and it turned out that for a base-only install the only service that takes a lot of time is netconfig. It’s because it was a oneshot service, so the whole boot process waited for dhcpcd to get an IP. A much better solution is to just start netconfig in the background and move on — and that’s exactly frugalwareutils in git does now.
Before:
$ systemd-analyze Startup finished in 2030ms (kernel) + 1166ms (initrd) + 6755ms (userspace) = 9953ms
After:
$ systemd-analyze Startup finished in 2039ms (kernel) + 1146ms (initrd) + 892ms (userspace) = 4079ms
|
Note
|
Again, this is for a virtual machine (where the host has some IO cache) and for a base-only install. |
Tuesday, 18 January 2011
systemd vs. LVM
(Comments)
Yesterday I enabled udev support in our LVM package, and that means LVM volumes under systemd not work as expected. Thanks to Lennart for the quick answer. :)
Friday, 14 January 2011
Nationality of currently active Frugalware developers
(Comments)
Just a FYI:
$ ./chkacc --verbose Accepting active developer 'vmiklos' [hu] Accepting active developer 'iron' [hu] Accepting active developer 'voroskoi' [hu] Accepting active developer 'boobaa' [hu] Accepting active developer 'crazy' [ro] Accepting active developer 'priyank' [in] Accepting active developer 'hermier' [fr] Accepting active developer 'devil505' [fr] Accepting active developer 'bouleetbil' [fr] Accepting active developer 'ryuo' [us] Accepting active developer 'gholafox' [fr] Accepting active developer 'phayz' [au] Accepting active developer 'elentir' [fr] Accepting active developer 'cedynamix' [fr] Accepting active developer 'jercel' [fr] Accepting active developer 'exceed' [fr] Accepting active developer 'dex' [de] Accepting active developer 'kooda' [fr] Accepting active developer 'centuri0' [fr] Accepting active developer 'kikadf' [hu] Accepting active developer 'pingax' [fr]
Monday, 27 December 2010
Systemd: kernel, bluetooth, bitlbee
(Comments)
Finally I can run systemd on my desktop, and not in a virtual machine only, since there is a patch for the sched/cgroup issue I had. It was not a systemd bug, but systemd triggered a kernel issue, which was hidden so far.
I just updated our bluez package, and bus activation works fine. This means bluetoothd is not started till somebody connects to it. Given that I sometimes do not log in to KDE to use kbluetooth, but just want to do something on the console, where having bluetoothd running is totally unnecessary, I consider this really nice.
It came up on #bitlbee that there is a Fedora bug where they ask for systemd unit files for BitlBee. So I created a patch, and the nice thing is that the second iteration now seems to be fine for Frugalware/Fedora/Debian, so we managed to build something cross-distro here. (I think I mentioned that’s the #1 feature I like in systemd.)
Monday, 20 December 2010
Systemd Podcast
(Comments)
I just found this podcast, it’s a bit dated since it happened in August and things have been improved a bit since then, but still I was happy to listen it. (The interesting part starts at 1:10:50; 17 minutes.)
I already had a short post about systemd, and I mentioned the killer feature for me is the compact distro-independent service file (initscript for sysvinit) format it uses, since even if the initscript format we use in Frugalware right now is mostly bullshit-free, it’s still more bloated than the systemd service files.
Now back to why I began writing this post. :) So there is the post about systemd, but it’s rather long, and it’s easy to miss the point. Since the previous post, I think there are a few more killer features in systemd:
Every service is started in a separate control group (cgroup). Do you remember the situation when you wanted to know who the hell started a given particular process? This is typically a problem if the process is running as root. Now this is no longer a problem, systemd-cgls will show you if it was started by a user or a given service, etc. (Yes, I consider this a security feature.)
Upstart already had this "restart if it crashed" feature, but systemd does it better: if the daemon supports socket activation, then messages sent to the socket are buffered by the kernel, and no message will be lost during the restart.
systemd provides this on-demand feature, which is pretty much like inetd, so hopefully we can get rid of inetd, which was a constant problem previously. (We inherited a fork of the OpenBSD inetd from Slackware, and being a fork it did not improve since years, causing a constant problem.)
Why writing this post today? Because this morning systemd appeared in -current, so you can even try it out without installing any unofficial package.
Wednesday, 15 December 2010
Splashy vs. systemd
(Comments)
So we have this systemd wip repo and one of the remaining todo items was to fix up splashy to work with systemd.
First, why doesn’t it out of the box of systemd is a drop-in replacement? Because splashy is not a simple init script, it hooks itself to rc.sysvinit, so it was specific to sysvinit.
Now given that plymouth was already ported to systemd, it served as a good example. You may also ask: why don’t we just switch to plymouth? Because:
we don’t want to introduce multiple changes at the same time
it requires kms, while Splashy did not require it - so as long as it’s not true that most video cards support kms (think of via or anything else which supports vesafb, but not kms), such a switch would be a regression
Okay, enough anti-Plymouth rant. As you can see, right now the task is to fix Splashy.
The steps I did were:
updated the Splashy theme to remove the progressbar: given that now we start services parallel and on-demand, it does not really make too much sense
introduced unit files: to start on boot, to stop before getty/xorg, to start before kexec/reboot/halt/poweroff
added the usual compatibility symlinks to avoid starting the old rc.splash (which would happen anyway)
added a simple wrapper that fires up splashy and once it’s ready it sends the Booting…/Rebooting…/etc text to it
The last problem is a bit more complex: now that xorg startup wants to stop splashy, a dependency has to be declared. xorg startup is handled by prefdm.service, but in case it depends on splashy-quit.service, what will happen if you don’t have or don’t want a splash?
The solution for now is to declare an After= relation: that means xorg startup will happen after the quit of splashy, if it happens at all.
This way:
you can disable the splash, it won’t cause any dependency errors
if you don’t have prefdm.service enabled, you can even have splashy uninstalled
(this one is a bit ugly) you can disable the splash, but if you uninstall it and have prefdm.service enabled, you’ll get a dependency error, as systemd will have no idea what splashy-quit.service is.
To test the above:
you need to enable the systemd wip repo (see the link above)
run pacman-g2 -Sy systemd
boot with init=/bin/systemd
Stay tuned, we still have a few blocker issues before merging the (disabled by default, as you need that kernel parameter) systemd support to current.
Saturday, 11 December 2010
amtterm
(Comments)
So we have two machines next to each other: genesis and helicon. The original idea years ago was to put a serial cable between the two so that it’s possible to manage the machines even in case ssh dies for some reason. Of course we never did that, because we were lazy - but in the meantime both machines were replaced by a newer mainboard, supporting Intel AMT.
In short, this is a poor man’s IP console, it supports serial-over-lan, so with a bit of configuration and a special client tool you can control grub, watch the bootup process (will you miss the risky few minutes after a reboot till it turned out if a remote machine boots up after a kernel upgrade or not?) and finally can even log in when ssh is not running.
First you need to set up grub to listen on the serial port as well. To do this, you need to know the device name and I/O port of your serial-over-lan port. The boxes mentioned above have one physical and one virtual serial port, so we need the later - that will be /dev/ttyS1. Now let’s grep in dmesg to get the port:
$ dmesg|grep 'ttyS1 at' 0000:00:03.3: ttyS1 at I/O 0xf1c0 (irq = 17) is a 16550A
Now we know everything to set up grub. Just prepend the following lines to your /boot/grub/menu.lst:
serial --port=0xf1c0 --speed=115200 terminal --timeout=30 console serial
The speed is AFAIK the same for each SoL port, so you can just copy&paste it.
It’s also recommended to change the timeout line to 30 as well, this way you will have half minute to press any key to tell grub you want to control is on the serial port and you’ll again have half minute to hit any key to edit the kernel parameters, etc. (The whole grub part is useful because this way in case you upgraded the machine and it fails to boot up, you can still boot using init=/bin/sh and fix the system.)
Second, you want to see the boot process, this way you can fix the system remotely, even if fsck fails and asks for root password, etc.
For this, you need to change your kernel parameters, so that messages sent to /dev/console will end up on the serial port.
I changed
root=/dev/md0 ro quiet vga=791
to
root=/dev/md0 ro vga=normal nomodeset console=ttyS1,115200
and that achieved this.
Third, you want to start a getty on ttyS1 once the machine booted up, in case ssh fails to start up. If you don’t use systemd yet, add the following line to /etc/inittab:
s1:12345:respawn:/sbin/agetty ttyS1 115200 vt100-nav
(Don’t forget to run init q to reload the config!)
Finally, you need amtterm on the client side - I plan to package it for Frugalware once 1.4pre2 is out. Till then you can just download, unpack and build the source tarball using make - no installation is necessary, you can run amtterm in-place. In my case I can’t connect directly to the machine as (for obvious reasons) the AMT is reachable from the local subnet only. So I build an ssh tunnel to the other machine and use socksify to pretend I run amtterm on the local subnet. The commandline I use is:
$ socksify ./amtterm -p <pass> <ip>
And that’s it - enjoy editing your kernel parameters, watching your boot process and login to the box even if ssh is not running and you don’t have IP console. :)
If you can’t try it out right now but you want to see it in action: grub in amtterm and boot in amtterm - without any virtualization! ;)
Thursday, 04 November 2010
tgt is now available as a package
(Comments)
Today I packaged tgt an iSCSI target (server). The upstream package provides a large number of examples, though I thought it’s a good idea to note what I used for testing:
# egrep -v '#|^$' /etc/tgt/targets.conf
default-driver iscsi
<target iqn.2010-11.local.test:storage>
backing-store /dev/sdb
</target>
Something offtopic: a rejourn patch accepted and a LibreOffice bug fixed today.