Saturday, October 9, 2010

GuruPlug Plus Gets a New OS - Redux, part 2 (uboot/kernel)

Flashing a new uboot & kernel
(this continues from the previous post)
Hit any key to stop the autoboot.  Since they factory uboot and kernel images have incorrect arcNumbers, flashing one and not the other will cause the kernel to not boot.  Because of this we're going to go ahead and flash both.

In order to do this, you'll need:
  • a working tftp server (in Fedora 'yum install tftp-server' and make sure xinetd is reloaded and running).  I'm using a tftp server because the GuruPlug is picky about USB keys.
  • either no firewall or configuration settings for tftp (you can drop the firewall settings temporarily with 'sudo server iptables stop' and when you're finished 'sudo service iptables start'
  • A new uboot image.  I choose this one mostly for convenience.  In Fedora, this should be copied to /var/lib/tftpboot.
  • A new kernel image.  I choose this one mostly for convenience.  The only thing that I have found that I don't care for in this image is the kernel timestamps, but I can live with that for now.  In Fedora, this should be copied to /var/lib/tftpboot.
First thing we will do is set the serverip and ipaddr variables.  Serverip is the IP address of the tftp server, and ipaddr is the GuruPlug address.  They need to be on the same subnet.
Marvell>> setenv serverip 192.168.1.10                                        
Marvell>> setenv ipaddr 192.168.1.11                                           
Marvell>>
Now we're ready to load the uboot image and flash it to nand memory.
Marvell>> tftp 0x6400000 uboot.guruplug.bin                                    
Using egiga0 device                                                            
TFTP from server 192.168.1.10; our IP address is 192.168.1.11                  
Filename 'uboot.guruplug.bin'.                                                 
Load address: 0x6400000                                                        
Loading: #############                                                         
done                                                                           
Bytes transferred = 180220 (2bffc hex)                                         
Marvell>> nand erase 0x0 0x100000                                              
                                                                               
NAND erase: device 0 offset 0x0, size 0x100000                                 
Erasing at 0xe0000 -- 100% complete.                                           
OK                                                                             
Marvell>> nand write.e 0x6400000 0x0 0x100000                                  
                                                                               
NAND write: device 0 offset 0x0, size 0x100000                                 
 1048576 bytes written: OK                                                     
Marvell>>
Ok, now we're ready to load the new kernel image and flash it to nand memory.

Marvell>> tftp 0x6400000 sheeva-2.6.35.7-uImage                                
Using egiga0 device                                                            
TFTP from server 192.168.1.20; our IP address is 192.168.1.30                  
Filename 'sheeva-2.6.35.7-uImage'.                                             
Load address: 0x6400000                                                        
Loading: #################################################################     
         #################################################################     
         #############################################################         
done                                                                           
Bytes transferred = 2798652 (2ab43c hex)                                        Marvell>> nand erase 0x100000 0x400000                                         
                                                                               
NAND erase: device 0 offset 0x100000, size 0x400000                            
Erasing at 0x4e0000 -- 100% complete.                                          
OK                                                                             
Marvell>> nand write.e 0x6400000 0x100000 0x400000                             
                                                                               
NAND write: device 0 offset 0x100000, size 0x400000                            
 4194304 bytes written: OK                                                     
Marvell>>
At this point you'll want to reboot by using the reset command.  There are a couple things to be aware of at this point.  These are completely normal:  You'll get a CRC error for your environment and your MAC addresses are likely lost for your ethernet interfaces and you'll have to fix that.  We'll do that on this first boot.
Marvell>> reset                                                                
resetting ...                                                                  
                                                                               
                                                                               
U-Boot 2010.03-01161-gd91b0a9 (Apr 22 2010 - 03:24:41)                         
Marvell-GuruPlug                                                               
                                                                               
SoC:   Kirkwood 88F6281_A0                                                     
DRAM:  512 MB                                                                  
NAND:  512 MiB                                                                 
*** Warning - bad CRC or NAND, using default environment                       
                                                                               
In:    serial                                                                  
Out:   serial                                                                  
Err:   serial                                                                  
Net:   egiga0, egiga1                                                          
88E1121 Initialized on egiga0                                                  
88E1121 Initialized on egiga1                                                  
Hit any key to stop autoboot:  0                                               
Marvell>> setenv                                                               
setenv - set environment variables                                             
                                                                               
Marvell>> printenv                                                             
bootcmd=${x_bootcmd_usb}; ${x_bootcmd_kernel}; setenv bootargs ${x_bootargs} ${;
bootdelay=3                                                                    
baudrate=115200                                                                
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                    
stdin=serial                                                                   
stdout=serial                                                                  
stderr=serial                                                                  
ethaddr=03:41:7d:ab:b4:7c                                                      
ethact=egiga0                                                                  
eth1addr=04:41:7d:ab:b4:7d                                                     
                                                                               
Environment size: 423/131068 bytes                                             
Marvell>>

 Yep, just as predicted.  Let's fix those up and reboot:

Marvell>> editenv ethaddr                                                      
edit: 11:43:1c:77:a3:bb                                                        
Marvell>> editenv eth1addr                                                     
edit: 11:43:1c:77:a3:bc                                                        
Marvell>> saveenv                                                              
Saving Environment to NAND...                                                  
Erasing Nand...                                                                
Erasing at 0x40000 -- 100% complete.                                           
Writing to Nand... done                                                        
Marvell>> reset                                                                
resetting ...                                                                  
                                                                               
U-Boot 2010.03-01161-gd91b0a9 (Apr 22 2010 - 03:24:41)                        
Marvell-GuruPlug                                                               
                                                                               
SoC:   Kirkwood 88F6281_A0                                                     
DRAM:  512 MB                                                                  
NAND:  512 MiB                                                                 
In:    serial                                                                  
Out:   serial                                                                  
Err:   serial                                                                  
Net:   egiga0, egiga1                                                          
88E1121 Initialized on egiga0                                                  
88E1121 Initialized on egiga1                                                  
Hit any key to stop autoboot:  0                                               
(Re)start USB...                                                               
USB:   Register 10011 NbrPorts 1                                               
USB EHCI 1.00                                                                  
scanning bus for devices... 3 USB Device(s) found                              
       scanning bus for storage devices... Device NOT ready                    
   Request Sense returned 02 3A 00                                             
1 Storage Device(s) found                                                      
                                                                               
NAND read: device 0 offset 0x100000, size 0x400000                             
 4194304 bytes read: OK                                                        
## Booting kernel from Legacy Image at 06400000 ...                            
   Image Name:   Linux-2.6.35.7                                                
   Image Type:   ARM Linux Kernel Image (uncompressed)                         
   Data Size:    2798588 Bytes =  2.7 MB                                       
   Load Address: 00008000                                                      
   Entry Point:  00008000                                                      
   Verifying Checksum ... OK                                                   
   Loading Kernel Image ... OK                                                 
OK                                                                             
                                                                               
Starting kernel ...                                                            
                                                                               
Uncompressing Linux... done, booting the kernel.                               
[    0.000000] Linux version 2.6.35.7 (kelly@speedy) (gcc version 4.4.3 (Source0
[    0.000000] CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=0005397
[    0.000000] CPU: VIVT data cache, VIVT instruction cache                    
[    0.000000] Machine: Marvell GuruPlug Reference Board                       
[    0.000000] Memory policy: ECC disabled, Data cache writeback               
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pa8
[    0.000000] Kernel command line: console=ttyS0,115200 ubi.mtd=2 root=ubi0:ros
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)             
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) 
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)  
[    0.000000] Memory: 256MB 256MB = 512MB total                               
[    0.000000] Memory: 513680k/513680k available, 10608k reserved, 0K highmem  
[    0.000000] Virtual kernel memory layout:                                   
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)               
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)               
[    0.000000]     DMA     : 0xffc00000 - 0xffe00000   (   2 MB)               
[    0.000000]     vmalloc : 0xe0800000 - 0xfe800000   ( 480 MB)               
[    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)               
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)               
[    0.000000]       .init : 0xc0008000 - 0xc002b000   ( 140 kB)               
[    0.000000]       .text : 0xc002b000 - 0xc04fd000   (4936 kB)               
[    0.000000]       .data : 0xc051e000 - 0xc054e7e0   ( 194 kB)               
[    0.000000] SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, 1
[    0.000000] Hierarchical RCU implementation.                                
[    0.000000]  RCU-based detection of stalled CPUs is disabled.               
[    0.000000]  Verbose stalled-CPUs detection is disabled.                    
[    0.000000] NR_IRQS:114                                                     
[    0.000000] Console: colour dummy device 80x30                              
[   21.474963] Calibrating delay loop... 1192.75 BogoMIPS (lpj=5963776)        
[   21.714888] pid_max: default: 32768 minimum: 301                            
[   21.714954] Mount-cache hash table entries: 512                             
[   21.715203] CPU: Testing write buffer coherency: ok                         
[   21.717038] NET: Registered protocol family 16                              
[   21.718247] Kirkwood: MV88F6281-A0, TCLK=200000000.                         
[   21.718261] Feroceon L2: Cache support initialised.                         
[   21.732685] bio: create slab at 0                                   
[   21.733189] vgaarb: loaded                                                  
[   21.733691] SCSI subsystem initialized                                      
[   21.734415] usbcore: registered new interface driver usbfs                  
[   21.734671] usbcore: registered new interface driver hub                    
[   21.734847] usbcore: registered new device driver usb                       
[   21.737378] cfg80211: Calling CRDA to update world regulatory domain        
[   21.737567] Switching to clocksource orion_clocksource                      
[   21.751467] NET: Registered protocol family 2                               
[   21.751664] IP route cache hash table entries: 4096 (order: 2, 16384 bytes) 
[   21.752354] TCP established hash table entries: 16384 (order: 5, 131072 byte)
[   21.752708] TCP bind hash table entries: 16384 (order: 4, 65536 bytes)      
[   21.752912] TCP: Hash tables configured (established 16384 bind 16384)      
[   21.752922] TCP reno registered                                             
[   21.752933] UDP hash table entries: 256 (order: 0, 4096 bytes)              
[   21.752956] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)         
[   21.753095] NET: Registered protocol family 1                               
[   21.753340] RPC: Registered udp transport module.                           
[   21.753351] RPC: Registered tcp transport module.                           
[   21.753360] RPC: Registered tcp NFSv4.1 backchannel transport module.       
[   21.836710] JFFS2 version 2.2. (NAND) �© 2001-2006 Red Hat, Inc.            
[   21.837960] JFS: nTxBlock = 4013, nTxLock = 32105                           
[   21.839308] msgmni has been set to 1003                                     
[   21.841654] alg: No test for stdrng (krng)                                  
[   21.841700] io scheduler noop registered                                    
[   21.841710] io scheduler deadline registered                                
[   21.841811] io scheduler cfq registered (default)                           
[   21.849009] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled        
[   21.849872] serial8250.0: ttyS0 at MMIO 0xf1012000 (irq = 33) is a 16550A   
[   22.203935] console [ttyS0] enabled                                         
[   22.215396] brd: module loaded                                              
[   22.222241] loop: module loaded                                             
[   22.226963] NAND device: Manufacturer ID: 0xec, Chip ID: 0xdc (Samsung NAND )
[   22.235759] Scanning device for bad blocks                                  
[   22.308974] Bad eraseblock 1843 at 0x00000e660000                           
[   22.352006] Bad eraseblock 2867 at 0x000016660000                           
[   22.398578] Bad eraseblock 3986 at 0x00001f240000                           
[   22.407376] Creating 3 MTD partitions on "orion_nand":                      
[   22.412553] 0x000000000000-0x000000100000 : "u-boot"                        
[   22.418708] 0x000000100000-0x000000500000 : "uImage"                        
[   22.424758] 0x000000500000-0x000020000000 : "root"                          
[   22.431735] UBI: attaching mtd2 to ubi0                                     
[   22.435595] UBI: physical eraseblock size:   131072 bytes (128 KiB)         
[   22.441926] UBI: logical eraseblock size:    129024 bytes                   
[   22.447354] UBI: smallest flash I/O unit:    2048                           
[   22.452095] UBI: sub-page size:              512                            
[   22.456737] UBI: VID header offset:          512 (aligned 512)              
[   22.462609] UBI: data offset:                2048                           
[   23.267491] UBI: attached mtd2 to ubi0                                      
[   23.271299] UBI: MTD device name:            "root"                         
[   23.276199] UBI: MTD device size:            507 MiB                        
[   23.281201] UBI: number of good PEBs:        4053                           
[   23.285931] UBI: number of bad PEBs:         3                              
[   23.290407] UBI: max. allowed volumes:       128                            
[   23.295043] UBI: wear-leveling threshold:    4096                           
[   23.299780] UBI: number of internal volumes: 1                              
[   23.304243] UBI: number of user volumes:     1                              
[   23.308718] UBI: available PEBs:             0                              
[   23.313181] UBI: total number of reserved PEBs: 4053                        
[   23.318181] UBI: number of PEBs reserved for bad PEB handling: 40           
[   23.324299] UBI: max/mean erase counter: 2/0                                
[   23.328601] UBI: image sequence number: -1                                  
[   23.332760] UBI: background thread "ubi_bgt0d" started, PID 465             
[   23.339820] MV-643xx 10/100/1000 ethernet driver version 1.4                
[   23.345692] mv643xx_eth smi: probed                                         
[   23.351963] net eth0: port 0 with MAC address f0:ad:4e:00:17:93             
[   23.360584] net eth1: port 0 with MAC address f0:ad:4e:00:17:94             
[   23.366691] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver      
[   23.373333] orion-ehci orion-ehci.0: Marvell Orion EHCI                     
[   23.378646] orion-ehci orion-ehci.0: new USB bus registered, assigned bus nu1
[   23.407617] orion-ehci orion-ehci.0: irq 19, io mem 0xf1050000              
[   23.427615] orion-ehci orion-ehci.0: USB 2.0 started, EHCI 1.00             
[   23.434187] hub 1-0:1.0: USB hub found                                      
[   23.437992] hub 1-0:1.0: 1 port detected                                    
[   23.442558] Initializing USB Mass Storage driver...                         
[   23.447668] usbcore: registered new interface driver usb-storage            
[   23.453703] USB Mass Storage support registered.                            
[   23.458519] usbcore: registered new interface driver ums-datafab            
[   23.464660] usbcore: registered new interface driver ums-freecom            
[   23.470864] usbcore: registered new interface driver ums-jumpshot           
[   23.477098] usbcore: registered new interface driver ums-sddr09             
[   23.483228] usbcore: registered new interface driver ums-sddr55             
[   23.489558] mice: PS/2 mouse device common for all mice                     
[   23.495335] rtc-mv rtc-mv: rtc core: registered rtc-mv as rtc0              
[   23.501453] i2c /dev entries driver                                         
[   23.505576] cpuidle: using governor ladder                                  
[   23.510182] cpuidle: using governor menu                                    
[   23.514376] sdhci: Secure Digital Host Controller Interface driver          
[   23.520638] sdhci: Copyright(c) Pierre Ossman                               
[   23.525390] mmc0: mvsdio driver initialized, lacking card detect (fall back )
[   23.534529] mv_xor_shared mv_xor_shared.0: Marvell shared XOR driver        
[   23.540973] mv_xor_shared mv_xor_shared.1: Marvell shared XOR driver        
[   23.587646] mv_xor mv_xor.0: Marvell XOR: ( xor cpy )                       
[   23.595288] mmc0: new high speed SDIO card at address 0001                  
[   23.627645] mv_xor mv_xor.1: Marvell XOR: ( xor fill cpy )                  
[   23.667643] mv_xor mv_xor.2: Marvell XOR: ( xor cpy )                       
[   23.707646] mv_xor mv_xor.3: Marvell XOR: ( xor fill cpy )                  
[   23.717283] usbcore: registered new interface driver hiddev                 
[   23.723063] usbcore: registered new interface driver usbhid                 
[   23.728769] usbhid: USB HID core driver                                     
[   23.732622] oprofile: hardware counters not available                       
[   23.737754] oprofile: using timer interrupt.                                
[   23.743491] TCP cubic registered                                            
[   23.746741] NET: Registered protocol family 17                              
[   23.751414] lib80211: common routines for IEEE802.11 drivers                
[   23.757700] usb 1-1: new high speed USB device using orion-ehci and address 2
[   23.765796] rtc-mv rtc-mv: setting system clock to 2010-09-30 17:15:40 UTC ()
[   23.872392] UBIFS: mounted UBI device 0, volume 0, name "rootfs"            
[   23.878461] UBIFS: file system size:   515837952 bytes (503748 KiB, 491 MiB,)
[   23.886505] UBIFS: journal size:       9033728 bytes (8822 KiB, 8 MiB, 71 LE)
[   23.893864] UBIFS: media format:       w4/r0 (latest is w4/r0)              
[   23.899735] UBIFS: default compressor: zlib                                 
[   23.903934] UBIFS: reserved for root:  0 bytes (0 KiB)                      
[   23.909880] VFS: Mounted root (ubifs filesystem) on device 0:13.            
[   23.915947] Freeing init memory: 140K                                       
[   23.967703] hub 1-1:1.0: USB hub found                                      
[   23.971764] hub 1-1:1.0: 4 ports detected                                   
modprobe: FATAL: Could not load /lib/modules/2.6.35.7/modules.dep: No such filey
                                                                               
INIT: version 2.86 booting                                                     
[   24.267939] usb 1-1.1: new high speed USB device using orion-ehci and addres3
[   24.417916] scsi0 : usb-storage 1-1.1:1.0                                   
Starting the hotplug events dispatcher: udevd.                                 
Synthesizing the initial hotplug events...[   25.448862] scsi 0:0:0:0: Direct-A0
[   25.487658] sd 0:0:0:0: [sda] Attached SCSI removable disk                  
[   25.534923] sd 0:0:0:0: Attached scsi generic sg0 type 0                    
done.                                                                          
Waiting for /dev to be fully populated...[   25.643065] scsi 0:0:0:1: Direct-Ac0
[   25.856648] sd 0:0:0:1: Attached scsi generic sg1 type 0                    
[   25.862808] sd 0:0:0:1: [sdb] 15572992 512-byte logical blocks: (7.97 GB/7.4)
[   25.927690] sd 0:0:0:1: [sdb] Write Protect is off                          
[   25.932528] sd 0:0:0:1: [sdb] Assuming drive cache: write through           
[   26.101923] sd 0:0:0:1: [sdb] Assuming drive cache: write through           
[   26.108161]  sdb: sdb1 sdb2                                                 
[   26.256963] sd 0:0:0:1: [sdb] Assuming drive cache: write through           
[   26.310164] sd 0:0:0:1: [sdb] Attached SCSI removable disk                  
[   62.691332] EXT3-fs: barriers not enabled                                   
[   62.697559] kjournald starting.  Commit interval 5 seconds                  
[   62.757697] EXT3-fs (sdb1): using internal journal                          
[   62.762537] EXT3-fs (sdb1): mounted filesystem with writeback data mode     
done.                                                                          
Setting the system clock.                                                      
Activating swap...done.                                                        
Setting the system clock.                                                      
Cleaning up ifupdown....                                                       
Loading kernel modules...FATAL: Could not load /lib/modules/2.6.35.7/modules.dey
Checking file systems...fsck 1.41.3 (12-Oct-2008)                              
done.                                                                          
Setting kernel variables (/etc/sysctl.conf)...done.                            
Mounting local filesystems...done.                                             
Activating swapfile swap...done.                                               
Setting up networking....                                                      
Configuring network interfaces...done.                                         
Starting portmap daemon....                                                    
Setting up ALSA...done (none loaded).                                          
INIT: Entering runlevel: 2                                                     
Starting enhanced syslogd: rsyslogd.                                           
Starting system message bus: dbus.                                             
Starting OpenBSD Secure Shell server: sshd.                                    
Starting MySQL database server: mysqld.                                        
Checking for corrupt, not cleanly closed and upgrade needing tables..          
Starting MTA: exim4.                                                           
ALERT: exim paniclog /var/log/exim4/paniclog has non-zero size, mail system pos!
Starting Network Interface Plugging Daemon: eth0 eth1.                         
Starting web server: lighttpd.                                                 
Starting Samba daemons: nmbd smbd.                                             
Starting file alteration monitor: FAM.                                         
Starting NTP server: ntpd.                                                     
[   75.207567] warning: `ntpd' uses 32-bit capabilities (legacy support in use)
Starting periodic command scheduler: crond.                                    
uap0: error fetching interface information: Device not found                   
FATAL: Could not load /lib/modules/2.6.35.7/modules.dep: No such file or directy
SIOCSIFADDR: No such device                                                    
uap0: ERROR while getting interface flags: No such device                      
uap0: ERROR while getting interface flags: No such device                      
No such device                                                                 
ERR:UAPHOSTCMD is not supported by uap0                                        
ERR:Command sending failed!                                                    
No such device                                                                 
ERR:UAPHOSTCMD is not supported by uap0                                        
ERR:Command sending failed!                                                    
FATAL: Could not load /lib/modules/2.6.35.7/modules.dep: No such file or directy
iptables v1.4.2: can't initialize iptables table `nat': iptables who? (do you n)
Perhaps iptables or your kernel needs to be upgraded.                          
FATAL: Could not load /lib/modules/2.6.35.7/modules.dep: No such file or directy
iptables v1.4.2: can't initialize iptables table `nat': iptables who? (do you n)
Perhaps iptables or your kernel needs to be upgraded.                          
Starting very small DHCP server: udhcpd (v0.9.9-pre) started                   
Unable to open /var/lib/udhcpd.leases for reading                              
SIOCGIFADDR failed, is the interface up and configured?: No such device        
Starting DNS forwarder and DHCP server: dnsmasq.                               
FATAL: Could not load /lib/modules/2.6.35.7/modules.dep: No such file or directy
iptables v1.4.2: can't initialize iptables table `filter': iptables who? (do yo)
Perhaps iptables or your kernel needs to be upgraded.                          
ERROR: Module btmrvl_sdio does not exist in /proc/modules                      
ERROR: Module btmrvl does not exist in /proc/modules                           
Starting bluetooth: bluetoothd.                                                
FATAL: Could not load /lib/modules/2.6.35.7/modules.dep: No such file or directy
[   76.187926] eth0: link up, 1000 Mb/s, full duplex, flow control disabled    
Can't open HCI socket.: Address family not supported by protocol               
Can't open HCI socket.: Address family not supported by protocol               
                                                                               
Debian GNU/Linux 5.0 guruplug-debian ttyS0                                     
                                                                               
guruplug-debian login:                                                                              

If your intent was only to upgrade uboot and the kernel, I have good new for you - you're mostly done.  If you want to keep Debian, just login with root/nosoup4u and install the kernel modules that were in the same directory as the kernel (untar them to /).