CNS11XX FreeBSD port completed

It has been a long time since I started this project, and even though I am making a good progress at the beginning, my progress was getting slower lately. Today I decided to take a day off from work to finish some remaining task: network driver, automatic memory detection, and flash device support.

Pyun YongHyeon have helped me a lot with the network driver. The speed is still not good, but he have helped to make the network driver to more correct (better, more reliable). I will still need to ask him to check for the final version, but I believe I have fixed most errors he pointed out.

My agestar, which also uses CNS11XX devices comes with 32Mb memory, while the Emprex NSD-100 have 64mb of memory. I have added a code to autodetect the memory size. So one binary file should work on both devices.

The flash device in Emprex NSD-100 complies with CFI, and it was very easy to use with the existing CFI driver. I just need to write several lines of code. The next step is to boot freebsd directly from the flash (with the root filesystem on USB). Unlike in Linux, the flash device can not be accessed as partitions (not yet).

First, we need to write the kernel.bin to cfi0, because the first 132 kb is used by boot loader, we need to skip to somewhere > 132kb. To make it easy, i just skip 1 megabyte from beginning of flash.

dd if=kernel.bin seek=1 bs=1m of=/dev/cfi0

be very very very careful with the dd command. Without correct seek and bs, you may overwrite the bootloader. The command will take quite a long time to finish (3 minutes).

Next step is to set the initial boot command. In the boot loader, setup bootcmd to copy the data in ram to 0x1000000 from 0x10100000, then boot the device:

setenv bootcmd cp.l 0x10100000 0x1000000 0x1a0000\;go 0x1000000
saveenv

Now when we boot the device, we should go directly to freebsd.

I won’t provide binaries, but the latest source code is in:

http://p4db.freebsd.org/depotTreeBrowser.cgi?FSPC=//depot/projects/str91xx/src/sys/arm/econa&HIDEDEL=NO

CNX11XX/STR91XX FreeBSD Progress

Last weekend I continued my work on FreeBSD port. I am concentrating on the network speed improvement, and I made a good progress with it. The network speed is now about 2.1 Mbps (FTP upload from device), this is still slower than the Linux version but i think it already reach a usable state (I think I should be able to stream some DivX files through HTTP from it). I will ask around in the freebsd-arm/freebsd-net mailing list so I can do more improvement on the driver.

I am still a bit worried playing around with the Flash, since I don’t have anything to restore it back in case I made a mistake. So I think I will leave this part for a while.

For everyone who have NSD-100 with Serial Port attached to it, you can try a precompiled binary thah I have prepared, or you can compile from source. To use the binary version, you will need a USB disk (at least 2GB in size), and a TFTP server. Actually you only need about 256 megabyte if you prepare your own disk instead of using my image.

Here are the steps for the binary version:

  1. Download the disk image from here
  2. Decompress (bunzip) the disk image, use dd to write to your USB disk
  3. Since there is no boot menu, entering single or multi user mode is done by booting different kernel. Download the multi user kernel or single user kernel and put it in your tftpserver
  4. Boot the kernel

To boot the kernel, you need to access your device using serial port. I think You need to hold the reset button to enter the boot prompt (mine always goes to the boot prompt because Bruce did something with the configuration area). You should see

STR9100>

prompt.

setenv serverip 192.168.1.1
(you can also 'saveenv' to save the TFTP server address permanently)
tftpboot 0x1000000 name-of-kernel.bin
go 0x1000000

To build your own disk image, make an empty disk.img with the size that you want. Goto /usr/src and then (modified from instruction to make i386 image by Warner Losh)

export TARGET_ARCH=arm
make buildworld
mdconfig -a -t vnode -f disk.img
fdisk -I md0
fdisk -B md0
bsdlabel -w md0s1 auto
bsdlabel -B md0s1
newfs /dev/md0s1a
mount /dev/md0s1a /mnt/
make installworld DESTDIR=/mnt
make distrib-dirs DESTDIR=/mnt
make distribution DESTDIR=/mnt
echo /dev/da0s1a / ufs rw 1 1 > /mnt/etc/fstab
echo ifconfig_DEFAULT=DHCP > /mnt/etc/rc.conf
echo hostname=demo >> /mnt/etc/rc.conf

To compare your boot experience here is is the bootlog for the multi user mode, and the single user mode.

For the latest kernel source, you can see the perforce depot at:

http://p4db.freebsd.org/depotTreeBrowser.cgi?FSPC=//depot/projects/str91xx&HIDEDEL=NO

Agestar/CNS11XX Freebsd progress

I’m still working on the Freebsd port, and haven’t tried to fix the network driver problem in Linux (it only happens on samba 3 which I don’t use daily). The reason to focus my work on the FreeBSD port is because I want to understand more about the network driver. The current Linux network driver was not written from scratch but from modifying existing source. The source was full of things that I don’t understand, which proves to be unnecessary after I gain understanding when writing the Freebsd network driver.

Here is the current FreeBSD port status:

  1. Timer is now working, previously the timer tick works, but the time counter was too fast.
  2. EHCI and OHCI is working, but there is still some caching problem, so i need to modify usb_busdma.c, this modification is not clean. I can access USB disks, and USB network adapter.
  3. Network driver works, but it is still very slow . I am still trying to understand better the DMA handling in FreeBSD. There is still one bug: you can not stop the interface and start it again. The stopping part works, ifconfig ece0 down, but the starting again part doesn’t.
  4. Multi user works. I can also activate network services, such as sshd.

I am still waiting for my perforce account. But anyone willing to test it can contact me. I still don’t know the best method to release a patch against CURRENT for people to try, because changes happens very quickly.

Here is the latest boot log: bsd-24-may-2009.txt

STR9104/CNS1104 FreeBSD Port Progress

Returning from Indonesia, I continued my Freebsd porting attempt to the Emprex NSD-100. So far it’s going quite well. I took the FA526 CPU support from NetBSD, I use the 8250 driver for the UART, and default EHCI driver. I got stuck for a while on the EHCI part until Hans Petter Selasky pointed me that there might a problem in the busdma/cache handling. With the EHCI part fixed, I can get to the userland, booting from USB stick.

The remaining drivers that needs to be written are the OHCI and network. The OHCI shouldn’t take too much time, but I think the network will take quite a long time.

I was planning to clean up, and release the code today, but I was busy with something else, so may be I will release the code in the next few days. For those of you who are curious about the boot log, here it is:
Continue reading “STR9104/CNS1104 FreeBSD Port Progress”

Too many things to do

There are so many things to do lately, but so little time. Plus i have so many dental problems lately, three of my molar teeth has been pulled out in the last 2 months, and going to have the fourth taken next month. Going to dentist and waiting for the recovery always takes away my free time.

My wife just bought Nokia 5800, a Nokia series 60 5th edition phone. It means that i need to finish my SymbianBible port for 5th edition (mostly done, beta version is on symbianbible google groups). My wife also asked me to port MultiCounter to her new phone (done, not yet uploaded).

I have cleaned up the 2.6.29 port of STR9104 Soc, but i will need to clean up again, because of the new documentation from www.cnusers.org. I have also started the freebsd port, but the progress is not much yet.
Continue reading “Too many things to do”

STAR9104: Linux Kernel 2.6.29 and Starting FreeBSD port

I’ve finally updated my patch to 2.6.29, the patch can be downloaded from:
http://tinyhack.com/agestar/patch-2.6.29-star.gz

and the config file:

http://tinyhack.com/agestar/config-2.6.29-star

or if you want the image that i already compiled and test (image is compiled with 32 MB memory). This is NOT a FIRMWARE

http://tinyhack.com/agestar/zImage-2.6.29

when i have the time, i will work on creating a new firmware image.

Some changes:

  • The machine ID is now registered in http://www.arm.linux.org.uk/developer/machines/
  • The network problem instability has now been fixed
  • Added new configuration option to select memory size based on your board memory (16, 32, or 64 mb). Note: selecting values larger than the supported size will cause crash.

The other news is that Bruce M Simpson has donated me an Emprex NSD 100 for porting FreeBSD to it. I have started my work, but the progress will be slower from the Linux at the beginning, because:

  1. I am more familiar with Linux kernel compared to FreeBSD kernel
  2. Currently FreeBSD kernel itself doesn’t support many ARM devices yet, so to find an exmple of something I need to look at NetBSD, (and it helps, for example the Faraday 526 processor support is already in NetBSD).
  3. I am rather busy this and coming month (planning to go to Indonesia for about 10 days)

Update – Debian on Agestar Firmware

Warning/Note: This is not an update to the existing firmware. This is for installing Debian. If you don’t know anything about Linux, this is not for you. This firmware DOES NOT contain web interface.

I haven’t looked again on Debian installer for Agestar, but I have built a new firmware for Debian on Agestar using the latest kernel patch (faster network). If you have installed Debian using the instruction in here, you can download zImage-20092008 to Agestar, and then do:

dd if=zImage-20092008 of=/dev/mtdblock1

If you haven’t installed Debian, then when following the instruction, but instead of using star.bin use star-20092008.bin. To make it clear, use zImage-20092008 to update existing installation, and star-20092008.bin for new installation (starting from the original Agestar firmware). If you made a mistake, then you need a serial port to unbrick your Agestar. NOTE: the web update method only works on agestar, other models can work by using serial port and latest patch for kernel source (2.6.29 or later).

If you are interested to make your own firmware, this is what you should do:

  1. Download armboot.bin and put it to a directory
  2. Download mergefile.c to the same directory as armboot.bin
  3. Compile mergefile.c (just do cc mergefile.c -o mergefile)
  4. Compile your kernel according to the instruction at http://tinyhack.com/2008/09/08/how-to-compile-kernel-for-agestar/ to create zImage, copy/move it to the same directory as armboot.bin
  5. Type ./mergefile to merge armboot.bin and zImage to star.bin.

You can use star.bin to flash (replace) original firmware. If you already installed Debian, and you want to update your kernel, you only need to build zImage and do dd if=newzImage of=/dev/mtdblock1.

How to compile kernel for Agestar

Here is a guide how to compile a kernel for your Agestar. In this latest patch from me, I have included the network driver with scatter/gather support. For FTP transfer, HTTP, or other transfers that uses sendfile syscall, the speed is about 50% faster than before, for ordinary transfer, it almost doesn’t change.

  1. Download vanilla kernel from kernel.org (use version linux-2.6.25.4)
  2. Extract kernel , and apply this patch file (patchfile-20080907.gz)
  3. Download initramfs.cpio.gz put it in the kernel directory and extract it
  4. Download my configuration file config-20080907 put it into kernel directory, rename it as .config
  5. Install an arm compiler, your distribution may have them (for instance in Debian you can use aptitude with emdebian.org repository), or download from codesourcery.com.
  6. Edit Makefile, find CROSS_COMPILE and change the value to the location and prefix of your compiler. For example, of your compiler is /opt/arm/920t_le/bin/arm_920t_le-gcc, fill in /opt/arm/920t_le/bin/arm_920t_le- (without the gcc part)
  7. To configure the kernel, type “make menuconfig”
  8. Type make to build zImage

NOTE: the zImage is NOT a FIRMWARE. You can write zImage to /dev/mtdblock1 on the agestar to update your kernel but not through the web interface. I will write another tutorial on how to make zImage into a firmware that can be flashed using the web interface.

If you want a newer kernel, start from the current kernel, and keep on patching with the next incremental patch until you reach the kernel number that you want. This is not always easy, because sometimes a patch will conflict with the changes that i have made.

Tips For Debian on Agestar

Chris (Whites11) and several others have pointed that the source code for a device similar to Agestar have been released by a German company (http://www.multicase.de/en/products/76/ns348s.html). I have not looked carefully at the source code of this one, but none of the people on the mailing list have got it working with networking enabled.

Kari Ahtiala who owned several NAS devices (SLUG, NCB3AST, NCH3AHT), said that you can just move your disk from NSLU (SLUG) to Agestar just fine:

Continue reading “Tips For Debian on Agestar”

Installing Debian on Agestar without serial port

I have prepared a firmware and tutorial to Install Debian here, this time without the need for serial port. I have tested this, and it seems that everything works. But of course I will not be responsible if anything happens. If you think there are some missing, unclear or inaccurate steps, or if you doubt about something, then don’t install it. If you have anything to ask just email to yohanes [at] gmail.com, or just post your questions as comments.

NOTE: the web update method only works on agestar ncb3ast, other models can work by using serial port and latest patch for kernel source (2.6.29 or later).