Booting Linux from Flash Memory
 
1. NOR Flash (2Mbyte)
 
• Being located at 0x0, it is used to store boot code
 
• Memory map
 
 0x001F0000 - 0x0001FFFF  used by u-boot to save environment variables
 0x00040000 - 0x001EFFFF  blank
 0x00010000 - 0x0003FFFF  u-boot code (upto 184k)
 0x00000000 - 0x0000FFFF  CyberLab bootloader
  • 1.6M bytes of space (0x40000 ~ 0x1EFFFF) is available for compressed Linux kernel
   
  2. NAND Flash (32Mbyte)
    • I/O mapped device controlled by registers at 0x4e000000 ~ 0x4e000014
    • can be configured as boot device by R9 and R10 on the board
    • All 32Mbyte space is available for Linux file system
    • See http://www.linux-mtd.infradead.org/archive/tech/nand.html for details about NAND vs. NOR flash
   
 
3. Store File System to NAND Flash
 
• Create CRAMFS image from LN2410disk.gz
   
  $ unzip LN2410disk.gz
 
   
  $ mount -o loop LN2410disk tmp_mnt
 
   
  $ mkcramfs tmp_mnt LN2410disk_cramfs
 
 
    • Download LN2410disk_cramfs to onboard DRAM
   
  LN2410SBC # tftp 0x31000000 LN2410disk_cramfs
 
   
  TFTP from server 172.16.1.35; our IP address is 172.16.1.37
 
      Filename 'LN2410disk_cramfs'.  
 
  Load address: 0x31000000  
      Loading:  
   
  ###########################################################
 
      done  
   
  Bytes transferred = 1691648 (19d000 hex)
 
   
   
• Program NAND flash
   
   Default MTD partition in drivers/mtd/nand/smdk2410.c
   
  0x01000000 - 0x01FFFFFF   /dev/mtdblock4, 16Mbyte, default boot
  0x00800000 - 0x00FFFFFF   /dev/mtdblock3, 8Mbyte
  0x00400000 - 0x007FFFFF   /dev/mtdblock2, 4Mbyte
  0x00200000 - 0x003FFFFF   /dev/mtdblock1, 2Mbyte
  0x00000000 - 0x001FFFFF   /dev/mtdblock0, 2Mbyte
   
• Erase /dev/mtdblock4
   
  LN2410SBC # nand erase 0x1000000 0x1000000
 
    Copy cramfs image in DRAM to NAND flash
   
  LN2410SBC # nand write 0x31000000 0x1000000 0x19d000 /* source, destination, size */
 
     
 
4. Store Kernel to NOR Flash
   
• Create kernel image using mkimage tools in u-boot/tools
   
 $ mkimage -A arm -O linux -T kernel -C none -a 0x30f00000 -e 0x30f00000 -n "Linux 2.4.18" -d
 
   
  zImage zImage.bin
 
   
  This command creates zImage.bin from zImage by appending small piece of code that copies
   
  zImage from NOR flash to 0x30f00000 in RAM and jumps into 0x30f00000.
     
    • Download zImage.bin onboard DRAM
      LN2410SBC # tftp 0x31000000 zImage.bin  
      TFTP from server 172.16.1.35; our IP address is 172.16.1.37  
      Filename 'zImage.bin'.  
      Load address: 0x31000000  
   
  Loading:
 
   
  ###########################################################
 
   
  done
 
      Bytes transferred = 673192 (a45a8 hex)  
 
   
• Erase NOR flash
      LN2410SBC # flinfo /* get flash information */  
       
      Bank # 1: AMD: 1x Amd29LV160DB (16Mbit)  
      Size: 2 MB in 35 Sectors  
      Sector Start Addresses:  
      00000000 (RO) 00004000 (RO) 00006000 (RO) 00008000 (RO) 00010000 (RO)  
      00020000 00030000 00040000 00050000 00060000  
     ...  
      001B0000 001C0000 001D0000 001E0000 001F0000 (RO)  
       
      LN2410SBC # erase 1:7-33 /* from 0x40000 to 0x1effff */  
      Erase Flash Sectors 7-33 in Bank # 1 Erasing sector 7 ... ok.  
      Erasing sector 8 ... ok.  
     ....  
      Erasing sector 33 ... ok.  
     
    • Copy zImage from DRAM to Flash
      LN2410SBC # cp.b 0x31000000 0x40000 0xa45a8 /* source, destination, size */  
      Copy to Flash... done  
      It takes 2 ~ 3 minutes to finish
     
    • Boot kernel
      LN2410SBC # bootm 0x40000  
     

 

© 2004-2008 LittleChips.com. All Rights reserved.