gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/pkg/mount/mtd/doc.go (about) 1 // Copyright 2019 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Chips are made by vendors, and an individual vendor is 6 // defined by a 1 to 8 byte vendor id stored in the chip. 7 // An instance of a type of chip, with, e.g., a particular size, 8 // is defined by a 1 to 3 or so byte device id stored in the chip. 9 // The vendor, device id pair can be used to find both unique 10 // properties of a chip (e.g. size) and the common properties of a chip 11 // (e.g. erase value, voltages, erase blocks. etc.) 12 // It is not at all unusual to know a vendor but not a device id. 13 // Hence we need to be able to get a vendor given a vendor id, 14 // and then a chip given a chip id. It's ok, however, to know 15 // the vendor and fail to know the chip. 16 // 17 // Sadly, device ids are not unique; they are reused per vendor. 18 // And, as mentioned, both vendor and device id are variable length. 19 // In a not uncommon failure of vision, they started out as 1 byte 20 // each, grew to 2, then 3 in some cases, 7 in other. Good times. 21 // Life would be easier if everybody just made these things strings 22 // in the beginning. 23 // 24 // An ID identifies a vendor, but not the same vendor over time. 25 // Vendor names for a given ID change over time, due to buyouts, 26 // bankruptcies, and the occasional near depression. 27 // For example, what was AMD is now Spansion. 28 // This name changing complicates the picture a bit, 29 // so we maintain a list of vendor names for a given part, with 30 // the first name in the list being the current name. This will allow 31 // us to accomodate scripts that might have the wrong vendor name. 32 // As time goes by, and bankruptcies accumulate, this first name 33 // can change. 34 // 35 // Hence, it is useful to have 3 bits of knowledge 36 // o list of vendor names given a vendor id 37 // o list of chips and their unique properties given a device id 38 // o list of common properties which can be referenced from a chip 39 // 40 // We wish to embed this code in FLASH so if needed we can burn 41 // a chip from FLASH-embedded u-root. 42 // 43 // This code uses strings, not integers, 44 // since device and vendor IDs are now variable length, depending 45 // on year of manufacture. Further, it is just nicer to work with 46 // strings. 47 // 48 // In most cases, we will walk these tables once, so we design for 49 // exhaustive search. The tables are short and are traversed in 50 // microseconds, you only do it once, and it's important to keep data 51 // as compact as possible. 52 // 53 // A note on flashing. Writing is not zero cost: each erase/write 54 // cycle reduces chip lifetime. Data in the chip need not be erased to 55 // be written: 0xee can be changed to 0xcc without an erase cycle in 56 // many parts. Code can make a guess a guess at an optimal 57 // erase/write pattern based on the size of the regions to be written, 58 // the content of regions, and the size of the blocks available. 59 // Getting this calculation right has proven to be tricky, as it has 60 // to balance time costs of writing, expected costs of too many erase 61 // cycles, and several other factors I can not recall just now. Watch 62 // this space. 63 // 64 // TODO: figure out some minimum set of config options for Linux, with 65 // the proviso that this will be very kernel version dependent. 66 package mtd