2014/09/24

Flash in Linux

NAND & Driver

struct nand_chip {
 int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
   uint32_t offset, int data_len, const uint8_t *buf,
   int oob_required, int page, int cached, int raw);
       
           
}
nand_write
  nand_do_write_ops
    chip->write_page ( nand_write_page )
      ecc->write_page ( nand_write_page_hwecc )
        chip->write_buf ( s3c2410_nand_write_buf )
      chip->cmdfunc( nand_command )
        chip->cmd_ctrl( s3c2410_nand_hwcontrol )

nand_read
  nand_do_read_ops
    chip->cmdfunc ( nand_command )
      chip->cmd_ctrl( s3c2410_nand_hwcontrol )
    ecc->read_page_raw ( nand_read_page_raw )
      chip->read_buf ( s3c2410_nand_read_buf )


MTD Layer

mtd_read
  mtd->_read ( nand_read )
mtd_write    
  mtd->_write ( nand_write )


UBI Layer

ubi_io_write
  mtd_write
ubi_io_read
  mtd_read

ubi_attach
  scan_fast
    scan_peb
  scan_all
    scan_peb
      ubi_io_read_ec_hdr ( check if the header is ok or not )
      ubi_add_to_av
        add_volume
        p = &av->root.rb_node;
     
        rb_link_node(&aeb->u.rb, parent, p);
        rb_insert_color(&aeb->u.rb, &av->root);


ubi_attach_mtd_dev
  io_init
    ubi->peb_size   = ubi->mtd->erasesize;

ubi_vid_hdr's lnum holds the logical block number
ubi_ainf_peb, attach information about a physical eraseblock, lnum

ubi_eba_init
  vol->eba_tbl = kmalloc
  av = ubi_find_av(ai, idx2vol_id(ubi, i));
  vol->eba_tbl[aeb->lnum] = aeb->pnum;
Wear-Leveling is in the drivers\mtd\ubi\wl.c


UBI FS

UBIFS to UBI
  ubifs_leb_read
    ubi_read
      ubi_leb_read
  ubifs_leb_write
    ubi_leb_write


UBIFS's VFS mount point
  fs\ubifs\file.c
  fs\ubifs\dir.c
  fs\ubifs\super.c

No comments:

Post a Comment

Post Code on Blogger

Simplest way to post code to blogger for me: <pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black;overflow-x:...