0) Reset a CC9U module to factory settings/programming
=============================================================================
If there is no serial U-Boot output, try different baud rates.
If you cannot get any U-Boot prompt on the serial line,
recover the module via JTAG (see recoverU-Boot-CC9UNC90.pdf).

If you are getting any U-Boot prompt try to program the
Digi factory U-Boot you can get from:
http://ftp1.digi.com/support/patches/CC9U_UBOOT114_BIN_82002254_A.zip

Your-Prompt> tftp 20100000 u-boot-unc90dev.bin   <- asumed to be from .zip above
Your-Prompt> protect off 1:0-3
Your-Prompt> erase 10000000 1003ffff
Your-Prompt> cp.b 20100000 10000000 $(filesize)
Your-Prompt> reset

U-Boot 1.1.4-CC9U-RevA
..
CC9U> imm 50 500.2
00000500: 20 ? ff    <- enter ff
00000501: 73 ? .     <- enter "." to abort i2c mem modify mode
CC9U> reset
U-Boot 1.1.4-CC9U-RevA 
..
*** Warning - bad CRC, using default environment
..
CC9U> setenv ethaddr 00:04:F3:xx:yy:zz    <= where xx:yy:zz is the MAC printed on module
  add you network settings here, e.g. setenv ipaddr ...; setenv serverip ..
CC9U> saveenv
CC9U> reset

Additionally you might want to clear the reminder of the flash memory,
to have well defined flash contents to start your custom programming:

CC9U> erase 10040000 10ffffff



A) Tests with U-Boot
=============================================================================
1) program Digi U-Boot 1.1.4 RevA into flash, boot module with this U-Boot
2) NetWork test:

   CC9U> setenv ipaddr   ... <- to match your local network
   CC9U> setenv serverip ... <- to match remote PC in same subnet
   CC9U> ping $(serverip)

   upload an image via TFTP into RAM:

   CC9U> setenv loadaddr 20100000
   CC9U> tftp $(loadaddr) myfilename

3) RAM test
   RAM in U-Boot can by accessed from address 20.00.00.00 to 22.00.00.00
   However the region from 20.ED.00.00 to 20.F8.80.00 is used by U-Boot
   You can run a RAM test of the lower 14,8MByte with:
   
   CC9U> mtest 20000000 20ED0000

   This test runs endlessly and can be interrupted with Ctrl-C.
   You can run a RAM test of the upper 16,46875MByte with:

   CC9U> mtest 20F88000 21FFFFFF

4) FLASH test
   16MB Flash is located at address 0x10.00.00.00 to 0x11.00.00.00
   The first 256KByte 0x10.00.00.00 to 0x10.03.FF.FF are occupied by U-Boot
   You can erase flash blocks (64/128KByte aligned), e.g. erase everything but U-Boot:

   CC9U> erase 10040000 10ffffff

   You can write from RAM to flash with the "cp.b" command (64/128KByte sector has to erased before):
   CC9U> cp.b 20f88000 10040000 FC0000
   This examples write FC0000=16MB - 256KByte (maximum flashsize) from RAM at 20f88000 into flash

   15MByte flash test:
   a) create random file 15MB.bin with 15MByte size on TFTP server
   b) clear last 16MByte in RAM:
      CC9U> mw.l 21000000 0 400000   <- this size is only 4MB because mw."l" is accessing 4Bytes at once
   c) verify by checksum RAM is cleared:
      CC9U> crc32 21000000 1000000
      CRC32 for 21000000 ... 21ffffff ==> a47ca14a
   d) transfer 15MB file via tftp into RAM:
      CC9U> tftp 21000000 15MB.bin
      #### ... ####
      Bytes transferred = 15728640 (f00000 hex)
   e) Check CRC of file in RAM (outcome is dependent on your file contents and size, remember it):
      CC9U> crc32 21000000   1000000
      CRC32 for 21000000 ... 21ffffff ==> 5abbafdf    <= remember your crc32 from here, its different
   f) erase backmost 15MB space in flash before writing:
      CC9U> erase 10100000 10ffffff
   g) program 15MB file in byte-mode from RAM into flash:
      CC9U> cp.b 21000000 10100000 F00000
   h) power cycle module to be sure flash is holding information non volatile
   i) clear last 16MByte in RAM:
      CC9U> mw.l 21000000 0 400000
   j) verify by checksum RAM is cleared:
      CC9U> crc32 21000000 1000000
      CRC32 for 21000000 ... 21ffffff ==> a47ca14a
   k) Read 15MB file from flash in word mode into RAM
      CC9U> cp.w 10100000 21000000 780000  <- this size is only half of the partition size, since cp.w read 2Bytes at once
   l) Check CRC in RAM is matching your remembered file from above
      CC9U> crc32 21000000   1000000
      CRC32 for 21000000 ... 21ffffff ==> 5abbafdf    <= this should match your file


B) Tests with Linux
=============================================================================
0) Get the Digi default kernel/rootfs from:
   http://ftp1.digi.com/support/patches/CC9U_LX32_IMAGES.zip

1) program Digi kernel into flash

   CC9U> run update_kernel_tftp
   if this macro is not found, do it manually like this:
   CC9U> setenv loadaddr 20100000; saveenv
   CC9U> tftp ${loadaddr} uImage-unc90dev
   CC9U> erase 10040000 1033ffff
   CC9U> cp.b ${loadaddr} 10040000 ${filesize}

2) program Digi rootfs into flash

   CC9U> run update_rootfs_tftp
   if this macro is not found or you have module with new NUMONIX flash, do it manually:
   CC9U> tftp ${loadaddr} rootfs-unc90dev-64.jffs2   <- use rootfs-unc90dev-128.jffs2 for Numonix flash
   CC9U> erase 10340000 1063ffff
   CC9U> cp.b ${loadaddr} 10340000 ${filesize}

3) boot Digi kernel from flash

   CC9U> run boot_flash
     or
   CC9U> dboot linux flash
   if this macro is not found, boot it manually with:
   CC9U> cp.w 10040000 ${loadaddr} 180000
   CC9U> setenv bootargs ip=${ipaddr}:${serverip}::${netmask}::eth0:off root=/dev/mtdblock3 rootfs=jffs2
   CC9U> bootm

   after booting Linux, you can telnet and ping the module

4) Transfer File(s) via TFTP into RAM, or Flash, compare them

   When Linux is booted you get a prompt " # ".
   a) check how much RAM is left:
   # grep Mem /proc/meminfo
   MemTotal: 30184 kB
   MemFree:  26172 kB

   b) create a file occupying most available RAM. On your development host, e.g. a 24MByte
   PC> cd /tftpboot    <- root directory of your TFTPserver
   PC> dd if=/dev/urandom of=24MB.bin count=1 bs=24M
   PC> md5sum 24MB.bin
   88c0f1....96  24MB.bin   <- remember md5 checksum for this file

   c) upload the file into RAM (from the CC9U Linux prompt enter):
   # tftp -g -l /tmp/24MB.bin -r 24MB.bin 192.168.42.1   <- IP from your server
   # md5sum /tmp/24MB.bin
   88c0f1....96 /tmp/24MB.bin   <- check md5sum is matching checksum above
   Note: /tmp is RAM filesystem on CC9U/LxNETES-3.2

   d) check how much space in flash is left
   # df -h
   Filesystem Size Used Available Use Mounted on
   /dev/root  3.0M 1.9M      1.1M 63% /
   This Linux has only a 3MB rootfs partiton set in /dev/mtdblock3
   
   e) create a file occupying most available JFFS2/Flash space in your rootfs parition.
      In your development host, e.g. a 800KByte
   PC> cd /tftpboot    <- root directory of your TFTPserver
   PC> dd if=/dev/urandom of=800K.bin count=1 bs=800K
   PC> md5sum 800K.bin
   b9....67  800K.bin   <- remember md5 checksum for this file

   f) upload the file into flash (from the CC9U Linux prompt enter):
   # tftp -g -l /etc/800K.bin -r 800K.bin 192.168.42.1   <- IP from your server
   # md5sum /etc/800K.bin
   b9....67 /etc/800K.bin   <- check md5sum is matching checksum above
   Note: /etc is Flash filesystem on CC9U/LxNETES-3.2
   Note: JFFS2 need some spare blocks to operate, don't fill it up more than 90%