Month: August 2014

[solved] usb wireless mouse freeze periodically in ubuntu 12.04 lts

usb wireless mouse freeze periodically in ubuntu 12.04 lts, edit /boot/grub/grub.cfg, add a boot option irqpoll will fix it

menuentry 'Ubuntu, with Linux 3.8.0-41-generic' --class ubuntu --class gnu-linux --class gnu --class os {
	recordfail
	gfxmode $linux_gfx_mode
	insmod gzio
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos1)'
	search --no-floppy --fs-uuid --set=root 4abd314f-d625-417d-b9f1-52ae7df8d1fd
	linux	/boot/vmlinuz-3.8.0-41-generic root=UUID=4abd314f-d625-417d-b9f1-52ae7df8d1fd ro   quiet splash nomodeset $vt_handoff irqpoll
	initrd	/boot/initrd.img-3.8.0-41-generic
}

read count : 929

libelf.h has bug, it includes a missing header file

I cross compile the libel 0.8.13 on my ubuntu 12.04lts. I used the below command to configure it. The compile process is success and installed it correct. But inside the include/libelf/sys_elf.h, it includes a missing header file (elf.h). Just comment it out, and it will works.

libelf.h has bug, it includes a missing header file

libelf has bug

read count : 314

Mac has no mkfs.vfat

I have to package my kernel into a fat partition and load it up using grub, but mac doesn’t has a mkfs.vfat and “mount loopback” command. So I am creating a small programing using https://github.com/waldheinz/fat32-lib/ to manipulate the fat image by myself. So far these two small program can read & write a fat image:

Read Fat32:

package peter;

import java.io.File;
import java.nio.ByteBuffer;
import java.util.Iterator;

import de.waldheinz.fs.FsDirectory;
import de.waldheinz.fs.FsDirectoryEntry;
import de.waldheinz.fs.FsFile;
import de.waldheinz.fs.fat.BootSector;
import de.waldheinz.fs.fat.FatFileSystem;
import de.waldheinz.fs.util.FileDisk;

public class Fat32Lib_ReadTest {

	public static void main(String[] args) {
		try {
			File file = new File("peter.img");
			if (!file.exists()) {
				System.out.println(file.getName() + " not exist");
			}
			FileDisk rd = new FileDisk(file, false);
			FatFileSystem fatFs = FatFileSystem.read(rd, true);
			BootSector bs = fatFs.getBootSector();
			System.out.println(bs.getOemName());

			FsDirectory fatRootDir = fatFs.getRoot();

			Iterator<FsDirectoryEntry> i = fatRootDir.iterator();
			while (i.hasNext()) {
				final FsDirectoryEntry e = i.next();
				System.out.println("     - " + e);

				FsDirectory dir = e.getDirectory();
				Iterator<FsDirectoryEntry> i2 = dir.iterator();
				while (i2.hasNext()) {
					final FsDirectoryEntry e2 = i2.next();
					System.out.println("     - " + e2);
					if (e2.isFile()) {
						FsFile f = e2.getFile();
						System.out.println("         File = " + e2.getName() + ", " + f.getLength());
						ByteBuffer buff = ByteBuffer.allocate((int) f.getLength());
						f.read(0, buff);
						System.out.println(new String(buff.array(), "utf8"));
					}
				}
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		System.out.println("done");
	}
}

Write to Fat32

package peter;

import java.io.File;
import java.nio.ByteBuffer;

import de.waldheinz.fs.FsDirectoryEntry;
import de.waldheinz.fs.FsFile;
import de.waldheinz.fs.fat.FatFileSystem;
import de.waldheinz.fs.fat.FatLfnDirectory;
import de.waldheinz.fs.fat.FatLfnDirectoryEntry;
import de.waldheinz.fs.fat.FatType;
import de.waldheinz.fs.fat.SuperFloppyFormatter;
import de.waldheinz.fs.util.FileDisk;

public class Fat32Lib_WriteTest {

	public static void main(String[] args) {
		try {
			File file = new File("peter.img");
			if (!file.delete()) {
				System.out.println("unable to delete " + file.getName());
			}
			FileDisk dev = FileDisk.create(file, 40 * 1024 * 1024);
			SuperFloppyFormatter sf = SuperFloppyFormatter.get(dev);
			sf.setOemName("Peter32");
			sf.setVolumeLabel("Peter Fat32");
			sf.setFatType(FatType.FAT32);
			sf.format();

			FatFileSystem fs = new FatFileSystem(dev, false);
			final FatLfnDirectory rootDir = (FatLfnDirectory) fs.getRoot();
			FatLfnDirectoryEntry entry = rootDir.addDirectory("Directory");
			for (int i = 0; i < 10; i++) {
				final FsDirectoryEntry e = entry.getDirectory().addFile("file_" + i);
				final FsFile fsFile = e.getFile();

				byte[] nullBytes = "Peter 你好 UTF8\n".getBytes();
				ByteBuffer buff = ByteBuffer.wrap(nullBytes);
				buff.rewind();
				fsFile.write(0, buff);
			}
			fs.flush();
			fs.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		System.out.println("done");
	}

}

 

read count : 706