summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* barebox-state: get devicetree from filev2017.03.0/topic/efi-stateSteffen Trumtrar2017-07-033-10/+24
| | | | Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
* libdt: support finding devices by partuuidSteffen Trumtrar2017-07-031-0/+12
| | | | Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
* barebox-state: Fail for unhandled argumentsEnrico Jorns2017-06-301-0/+5
| | | | | | | | | | | | | When passing unhandled arguments as in % barebox-state foo these will be silently ignored. This may lead to misunderstandings and unintended behavior, thus the user should be informed and the programm should exit with an error in these cases. Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
* barebox-state: fix termination of long_options[]Enrico Jorns2017-06-301-0/+1
| | | | | | | | | | | | | | | From the getopt_long() documentation: | The argument longopts must be an array of these structures, one for each | long option. Terminate the array with an element containing all zeros. Otherwise barebox-state will segfault for unknown options: % ./barebox-state --foo [1] 17946 segmentation fault (core dumped) ./barebox-state --foo Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
* common: Include sys/types.h headerMarcin Niestroj2017-06-271-0/+1
| | | | | | | | | | | | | | | Build with musl library fails with following error: In file included from src/crypto/sha1.c:21:0: ./src/digest.h:95:10: error: unknown type name ‘ulong’ ulong start, ulong size); ... Fix that by including sys/types.h header in common.h, so ulong type is defined with musl library. Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: Rename strlcpy to DT_strlcpyMarcin Niestroj2017-06-272-3/+3
| | | | | | | | | | | strlcpy function is defined in uClibc library, causing "static declaration of ‘strlcpy’ follows non-static declaration" build errors. Rename internal strlcpy function to DT_strlcpy to avoid conflicts. Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* barebox-state: backend_raw: init digest earlierSascha Hauer2017-04-241-4/+6
| | | | | | | | | In backend_format_raw_pack() digest_length is used before it's initialized in backend_raw_digest_init() which results in a too small memory allocation for the raw backend. Fix this and prevent a memory corruption. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Release v2017.03.0v2017.03.0Sascha Hauer2017-03-313-2/+9
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* libdt: support "partitions" subnode on mtd devicesBastian Stender2017-03-311-1/+7
| | | | | | | | | | | | | In case there is an additional "partitions" subnode between the device itself and its partitions like /soc/spi@?/mram@?/partitions/partition@? also try the parent of the parent before giving up finding the device node. See kernel docs for reference: Documentation/devicetree/bindings/mtd/partition.txt Signed-off-by: Bastian Stender <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Remove -EUCLEAN check from userspace toolSascha Hauer2017-03-311-21/+1
| | | | | | | | | | | | | | | | | | | | | | | | The state code is used for the userspace tool aswell, kept in sync manually. This patch only introduces a change for the userspace tool, not for barebox. In Linux userspace there is no direct possibility to check for -EUCLEAN. To indirectly check for -EUCLEAN the state tool reads the number of corrected bits before and after reading a block. Unfortunately it does not take the number of acceptable bitflips into account, but instead returns -EUCLEAN even when only a single bitflip occurred on a whole page. To be correct the algorithm must be more complicated: We would have to read the bitflip_threshold from sysfs. This value is per ECC step (often 512 byte), not per page. We would have to read the page in ECC step size chunks, testing for bitflips lower than the threshold for each chunk. Even if we would do that, there's still another issue. The eccstats ioctl delivers the eccstats for the whole device, so a concurrent reader would falsify the result. Let's decide that this is not worth the hassle and assume that no device has enough uptime that a cleanup in barebox is not sufficient. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* barebox-state: implement skipping authentification (again)Sascha Hauer2017-03-313-5/+13
| | | | | | | Implement authentification again, this time wihtout the need of passing a "force" argument through half of the function call stack. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Do not load state during state_new_from_nodeSascha Hauer2017-03-312-5/+4
| | | | | | | | The caller of state_new_from_node() may have it's own ideas what to do when loading the state fails, so do not load it in the initialization function, but instead let the caller do it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* barebox-state: make state_get() definition consistent to its prototypeSascha Hauer2017-03-313-3/+4
| | | | | | | | | | In 2839d4f6f4 state_get() got an additional argument, but its prototype in barebox-state.h was never adjusted. Include the file containing the prototype from the file containing the function definition so that this bug can be detected by the compiler. Also add the missing argument to the callers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Allow to load without authentificationSascha Hauer2017-03-316-11/+29
| | | | | | | Sometimes it's useful to be able to load a state even when it can't be authentificated. Add an option for this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend bucket circular: Explain metadataSascha Hauer2017-03-311-0/+5
| | | | | | Explain why we have metadata and where it is used. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_circular: Set minumum writesize to 8Sascha Hauer2017-03-311-0/+3
| | | | | | | | NOR flashes have a write size of 1. With this the metadata may end up on non-4-byte-aligned offsets. Force the minimum writesize to 8 so that the metadata is always at aligned offsets. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_raw: alloc digest only when neededSascha Hauer2017-03-311-53/+59
| | | | | | | | Instead of deferring probe just allocate the digest when it's needed. This way the credentials can be added later, possibly on the commandline. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_storage: rename more variablesSascha Hauer2017-03-311-6/+6
| | | | | | Use "buckets" rather than "copies" in variable names. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_storage: make locally used variable staticSascha Hauer2017-03-311-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_storage: rewrite function docSascha Hauer2017-03-311-2/+2
| | | | | | | The function documentation for state_storage_file_buckets_init() is not very accurate. Rewrite it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_storage: Rename variable desired_copies to desired_bucketsSascha Hauer2017-03-311-9/+9
| | | | | | | | | We defined what a bucket is, so rename the variable that holds the number of desired buckets from desired_copies to desired_buckets. While at it, make locally used variable static. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_storage: Rename variable nr_copies to n_bucketsSascha Hauer2017-03-311-12/+12
| | | | | | | We defined what a bucket is, so use n_buckets when counting buckets, and not nr_copies. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_circular: rewrite function docSascha Hauer2017-03-311-5/+3
| | | | | | | The commment talks about copies where buckets are meant and also claims we start at offset 0, which may not be true. Rewrite comment. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_circular: default to circular storageSascha Hauer2017-03-311-6/+8
| | | | | | | | Default to the new circular storage format which saves erase cycles. The old format can still be selected with backend-storage-type = "noncircular". Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend: Add some documentationSascha Hauer2017-03-312-1/+37
| | | | | | Write some sentences to make the concepts clearer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: storage: direct: do not close file that is not openedSascha Hauer2017-03-311-1/+0
| | | | | | When open failed to not try to close the invalid fd afterwards. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_circular: remove unnecessary warningSascha Hauer2017-03-311-4/+1
| | | | | | | It's expected that NAND flashes contain bad blocks, do not warn about them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend: Add more fields to struct state_backend_storageSascha Hauer2017-03-312-28/+26
| | | | | | To save a few function arguments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_bucket_direct: max_size is always givenSascha Hauer2017-03-311-1/+1
| | | | | | max_size is always != 0, so if(direct->max_size) can be skipped. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: bucket: Make output more informativeSascha Hauer2017-03-312-10/+18
| | | | | | | | | | | Print offset and number of the bucket along with the bucket specific messages to give a hint which bucket a message is for. Also it's pretty much expected that buckets sometimes have no data or need cleanup, so instead of complaining loudly, only write which bucket is used and which buckets are cleaned up. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend-direct: Fix max_sizeSascha Hauer2017-03-311-1/+1
| | | | | | | The max_size in the direct backend includes the meta data, so substract its size when determing the max data size we can store. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Drop cache bucketSascha Hauer2017-03-314-190/+71
| | | | | | | | | | | | | | The cache bucket sits between the storage functions and the backend storage. We only read from the storage once, so there is no need to cache anything. The real purpose of the cache bucket is to keep the -EUCLEAN information when a NAND block needs to be rewritten and to keep the read buffers as long as the backend iterates over all buckets trying to find the one we want to use. This can be coded easier and more obvious in the backend code, so drop the cache bucket. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Convert all bufs to void *Sascha Hauer2017-03-318-35/+35
| | | | | | | | A void * is a much better type for a buffer than a u8 * as it can be casted to any other type implicitly. Convert all buffers used by the state framework to void *. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: replace len_hint logicSascha Hauer2017-03-316-17/+21
| | | | | | | | The len_hint mechanism is rather hard to understand as it's not clear from where to where the hint is passed and also it's not clear what happens if the hint is empty or wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: simplify direct backendSascha Hauer2017-03-311-131/+14
| | | | | | | | | - drop support for regular files. This, if at all, is only useful for debugging. For the debugging case still a file of sufficient size can be created manually. - make stridesize mandatory. Makes the code simpler. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: drop lazy_initSascha Hauer2017-03-314-60/+6
| | | | | | | | | lazy_init is an optimization that makes it possible to read only up to the first valid bucket when starting. However, when restoring consistency, immediately afterwards we have we have to initialize all buckets anyway, so being lazy doesn't give us any gain. Remove it to simplify the code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend_circular: Read whole PEBSascha Hauer2017-03-311-10/+8
| | | | | | | | | | | When the circular backend searches for the last page written in the eraseblock, it iterates backwards pagewise from the end of the block. This is ok for NAND flash, but on NOR flash, which does not have pages, the code ends up iterating bytewise backwards, calling into mtd each time. This is very time consuming, so optimize this by reading the whole eraseblock once and just iterate over the buffer in memory. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: storage: initialize variable once outside loopSascha Hauer2017-03-311-4/+6
| | | | | | | writesize is initialized with the same value in each loop iteration, Instead, initialize it once outside the loop. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: pass struct state * to storage functionsSascha Hauer2017-03-313-7/+5
| | | | | | | We can get a state_backend_storage * and the device * from struct state, so pass this to the storage functions rather than the two pointers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: remove unnecessary argument from state_format_initSascha Hauer2017-03-311-7/+6
| | | | | | | The device pointer is already in struct state, no need to pass it around when a struct state * is already passed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: open code state_backend_init in callerSascha Hauer2017-03-311-57/+13
| | | | | | | Safes a lot of argument passing to a function that is used only once. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: merge backend.c into state.cSascha Hauer2017-03-314-190/+161
| | | | | | | The code in backend.c is too small to justify an extra file. Merge it into state.c. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Drop backend as extra struct typeSascha Hauer2017-03-313-59/+46
| | | | | | | struct state_backend is embedded into struct state. This additional indirection does not have any real gain. Drop it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend: remove len_hint argument from state_storage_readSascha Hauer2017-03-313-7/+4
| | | | | | The argument is 0 in the only caller, so remove the argument. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: backend: remove .get_packed_lenSascha Hauer2017-03-312-5/+0
| | | | | | | .get_packed_len isn't implemented by any backend, so remove the hook and its potential caller. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: Use positive logicSascha Hauer2017-03-311-7/+7
| | | | | | | bools with "non" in the names are rather confusing. Switch to positive logic. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: pass error code instead of inventing new oneSascha Hauer2017-03-311-3/+4
| | | | | | | | Both of_find_path() and of_find_path_by_node() return a meaningful error code, so forward it instead of inventing a new one. Do this especially for the -EPROBE_DEFER case which currently does not work. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: fix finding the correct parent nodeMichael Olbrich2017-03-311-2/+2
| | | | | | | | | | Looking for the parent node during fixup is broken. The path of the parent node is not correctly terminated ('0' vs '\0'). Also, the new state node should be added to the supplied device tree not the barebox device tree used by of_find_node_by_path(). Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* barebox-state: Sync pieces with bareboxSascha Hauer2017-03-313-12/+7
| | | | | | | dev_add_param_bool are no-ops, save_on_shutdown is irrelevant for the userspace part. Sync with barebox as of v2017.03.0 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: don't keep pointers to device tree nodesMichael Olbrich2017-03-312-8/+13
| | | | | | | | | | Caching pointers to device tree nodes or is not save. The barebox internal device tree may be changed by loading a new device tree or through fixup handlers. As a result, the node may be deleted and replaced with a new one. Keep a copy of the full path instead and resolve the node as needed. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>