• Carl-Daniel Hailfinger's avatar
    Store block sizes and corresponding erase functions in struct flashchip · f38431a5
    Carl-Daniel Hailfinger authored
    I decided to fill in the info for a
    few chips to illustrate how this works both for uniform and non-uniform
    sector sizes.
    
    struct eraseblock{
    int size; /* Eraseblock size */
    int count; /* Number of contiguous blocks with that size */
    };
    
    struct eraseblock doesn't correspond with a single erase block, but with
    a group of contiguous erase blocks having the same size.
    Given a (top boot block) flash chip with the following weird, but
    real-life structure:
    
    top
    16384
    8192
    8192
    32768
    65536
    65536
    65536
    65536
    65536
    65536
    65536
    bottom
    
    we get the following encoding:
    {65536,7},{32768,1},{8192,2},{16384,1}
    
    Although the number of blocks is bigger than 4, the number of block
    groups is only 4. If you ever add some flash chips with more than 4
    contiguous block groups, the definition will not fit into the 4-member
    array anymore and gcc will recognize that and error out. No undetected
    overflow possible. In that case, you simply increase array size a b...
    f38431a5
it87spi.c 7.99 KB