summaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
...
| * | imd: fix memory leakUlrich Ölmann2019-10-141-6/+14
| | | | | | | | | | | | | | | | | | | | | Each invocation of 'imd' ate up to 1MB of RAM. Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | state: drop unused code and declarations for non-existing functionsUwe Kleine-König2019-10-141-7/+0
| |/ | | | | | | | | | | | | | | | | state_get_name() is not used and so can be removed. state_backend_dtb_file() and state_backend_raw_file() were dropped in c999b507da98 ("state: Refactor state framework"). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/machine-id'Sascha Hauer2019-10-174-0/+107
|\ \
| * | bootm: allow providing machine id to KernelBastian Krause2019-09-301-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By default systemd generates a machine id on first boot and tries to persist it (see `man machine-id`). When the root file system is read-only systemd cannot persist the machine id. In case multiple redundant slots are used the machine id will vary. When not handled explicitly the machine id will also change during system updates. It is possible to pass a machine id to the kernel which will be used by systemd (systemd.machine_id=). If global.bootm.provide_machine_id (or nv.bootm.provide_machine_id) is true then provide the machine id from global.machine_id as systemd.machine_id= parameter to the Kernel. Note that global.machine_id must be set, either by the machine_id_set_bootarg late init call or by setting it manually with nv.machine_id if necessary. Signed-off-by: Bastian Krause <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: machine_id: introduce machine id generationBastian Krause2019-09-303-0/+88
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds functionality to pass device-specific information that will be hashed to generate a persistent unique machine id. It is then available as global.machine_id. It can be overwritten with nv.machine_id if necessary. Passing the machine id to the kernel is done in a separate patch. Note: if multiple sources provide hashable device-specific information (via machine_id_set_hashable()) the information provided by the last call prior to the late initcall set_machine_id() is used to generate the machine id from. Thus when updating barebox the machine id might change. Signed-off-by: Bastian Krause <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/layerscape'Sascha Hauer2019-10-171-0/+2
|\ \
| * | filetype: support fastboot barebox_update with layerscape imageAhmad Fatoum2019-09-181-0/+2
| |/ | | | | | | | | | | | | | | | | | | We do not yet support USB on the Layerscape platforms, but when we do, it's imaginable that we would want to export barebox_update targets over Fastboot. Prepare for this by adding the layerscape images to those that filetype_is_barebox_image returns true for. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/imx'Sascha Hauer2019-10-171-1/+8
|\ \
| * | imx-bbu-nand-fcb: Mark block as bad when erasing it failsSascha Hauer2019-09-251-1/+8
| |/ | | | | | | | | | | | | | | When a block cannot be erased it must be marked as bad. Previously we accidently ignored the erase failure and the the code just wrote the firmware into that block which resulted in boot failure. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: at91: add basic sama5d2 supportAhmad Fatoum2019-10-141-0/+1
| | | | | | | | | | | | | | | | Add hardware description, chip identification and clock changes to support the sama5d2 SoC. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: at91: build for all SoCs when AT91_MULTI_BOARDS is selectedAhmad Fatoum2019-10-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the addition of 15afd9d25 ("ARM: at91: Add initial support for the EVB-KSZ9477 eval board"), we now have two multi-image capable boards supported, but users still have to choose a specific SoC, so they can't be selected at the same time. Fix this, by restricting the menu to the non-multi-image configurations, i.e. CONFIG_ARCH_* symbols become specific to non-multi-image. The multi-image configurations on the other hand directly select the CONFIG_SOC_* symbol they require. Existing CONFIG_ARCH_* usage is adjusted to align with the new usage. Eventually, we would want to have a at91_multi_defconfig along with this, but for now leave existing configs as is. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fix compile error when set CONFIG_CONSOLE_SIMPLE=yDU HUANPENG2019-10-141-0/+12
|/ | | | | Signed-off-by: DU HUANPENG <u74147@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: release tee_resSascha Hauer2019-09-121-0/+2
| | | | | | | | When a tee_res has been acquired it must be released when bootm returns (for dryrun) Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
* Merge branch 'for-next/reset-source'Sascha Hauer2019-09-122-13/+44
|\
| * oftree: expose reset_source device in device treeUwe Kleine-König2019-09-091-0/+14
| | | | | | | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * reset_source: implement helper to set a device as reset sourceUwe Kleine-König2019-08-281-2/+25
| | | | | | | | | | | | | | This allows to remove some boilerplate from drivers. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * reset_source: drop reset_source_set_instance()Uwe Kleine-König2019-08-281-11/+4
| | | | | | | | | | | | | | | | | | | | | | | | The semantic of reset_source_set_instance() required a separate call to reset_source_set() (or reset_source_set_priority()) and checked right usage only using the type. Make the set of functions a bit easier to use by dropping reset_source_set_instance() and instead introduce a function that can set all relevant parameters (source, priority and instance) in one go. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * reset_source: fix ordering of exported functionsUwe Kleine-König2019-08-281-6/+6
| | | | | | | | | | | | | | | | Declare and implement getters first, then setters. This syncs the order of functions in reset_source.c and reset_source.h. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * reset_source: use instance = -1 as defaultUwe Kleine-König2019-08-282-3/+4
| | | | | | | | | | | | | | | | | | | | | | As with platform device id (does someone still remember?) 0 might be a valid id. So use -1 for "unknown" or "doesn't apply" instead of 0. Also don't pass the instance to the device tree if negative. (This ends up as 0xffffffff otherwise.) Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/qemu'Sascha Hauer2019-09-121-1/+4
|\ \
| * | common: return "none" when board unsetSascha Hauer2019-08-191-1/+4
| | | | | | | | | | | | | | | | | | Instead of returning NULL when board is not set return "none". Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/misc'Sascha Hauer2019-09-126-45/+44
|\ \ \
| * | | console: set default console_device devnameDavid Dgien2019-09-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some commands (loadb/x/y) rely on console_get_by_name, which searches the list of console devices based on console_device->devname. However, some serial drivers do not set devname, meaning that their respective console_devices can never be found. During console_register, ensure that a default devname is set if one is not already explicitly set. Signed-off-by: David Dgien <dgienda125@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | elf: add 64 bits elf loading supportClement Leger2019-09-061-22/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch add elf64 loading support to the elf loader. Since elf32 and elf64 uses completely different types, to avoid copying all the code and simply replace elf32 with elf64, use a macro which will return the appropriate field for each type of header. This macro generates getter for elf structures according to the class of the loaded elf. All direct elf struct dereference are then replaced by call to generated functions. This allows to keep a common loader code even if types are different. Tested-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Clement Leger <cleger@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | console: fix out-of-bounds read in dputc(/dev/*, ...)Ahmad Fatoum2019-09-022-17/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Trying to output a single character via echo -a /dev/serial0-1 currently results in garbage output after the newline, because console.c's fops_write discards the buffer length and passes the buffer to (struct cdev)::puts which only handles NUL-terminated strings. Fix this by amending (struct cdev)::puts with a new nbytes parameter, which is correctly propagated. All this functions now return at most the nbytes parameter they were passed in. This fixes __console_puts, which used to count new lines twice in its return value. Fixes: b4f55fcf35 ("console: expose consoles in devfs") Cc: Bastian Krause <bst@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | startup: allow ctrl+c abort during boot sequenceAhmad Fatoum2019-08-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment e.g. a wait for an ARP response during net boot can only aborted if the auto boot countdown was aborted. Otherwise ctrl+c is without effect. For better user experience allow code querying for ctrl+c to see it even if barebox had not dropped into a shell. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | complete: remove unused variableAhmad Fatoum2019-08-301-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | instr_param serves no purpose in the function. Thus remove it. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | ratp: fix use of %hu for printing intAhmad Fatoum2019-08-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While each of path_size and data_size is 16 bit in size, their sum may exceed this. Also the type of the resulting expression is an int, thus change the format specifier accordingly. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | startup: Fix typo in commentLadislav Michl2019-08-231-1/+1
| | |/ | |/| | | | | | | | | | | | | Fixes: 35266d7e583f ("startup: Factor out the autoboot counter...") Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | common: add generic CONFIG_KASAN optionAhmad Fatoum2019-09-091-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -fsanitize=[kernel-]address-sanitizer allows compile-time instrumentation of memory accesses to detect some classes of runtime undefined behavior. In preparation for allowing arches to provide infrastructure in support of this feature, add the generic KASAN options. These are only shown in the debug menu when the arch selects the appropriate symbol. The option is named equally to their Linux counterparts. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | common: add generic CONFIG_UBSAN plumbingAhmad Fatoum2019-09-091-0/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | -fsanitize=undefined allows compile-time instrumentation of code to detect some classes of runtime undefined behavior. In preparation for allowing arches to provide infrastructure in support of this feature, add some generic UBSAN options and associated plumbing. These are only shown in the debug menu when the arch selects the appropriate symbol. The option is named equally to their Linux counterparts. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / startup: Register autoboot variables earlierLadislav Michl2019-08-231-7/+11
|/ | | | | | | | | | | Autoboot is controlled by autoboot_timeout and autoboot_abort_key variables which might be altered by init scripts, so we need to register them before those scripts are run. Otherwise they are set back to defaultenv values upon registration. Fixes: 35266d7e583f ("startup: Factor out the autoboot counter...") Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/stm32'Sascha Hauer2019-08-151-0/+9
|\
| * filetype: add STM32 image typeAhmad Fatoum2019-07-151-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Both STM32MP BootROM and TF-A first stage expect subsequent bootloader stages to feature a specific 256-byte long STM32 file header. Add detection of the header to file_detect_type(). While there's only one version of the header so far, identify the new header as v1 anyway, so new versions can be unambiguously added. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/mtd-gpmi-nand'Sascha Hauer2019-08-151-4/+11
|\ \
| * | mtd: nand-mxs: change API between NAND driver and fcb codeSascha Hauer2019-08-061-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The imx-bbu-nand-fcb update handler code calls into the NAND driver to get the ecc strength and bad block marker position. Change the API so that only a single function is necessary and not three functions. Also in future the ecc strength will be configurable via device tree. This means static parameters like page size / oob size are no longer enough to calculate the ecc strength and so we store a pointer to our mtd_info struct in a static global variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/mtd'Sascha Hauer2019-08-153-22/+47
|\ \ \
| * | | ubiformat: Fix wrong error testsSascha Hauer2019-07-161-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several tests in ubiformat test for a positive error code where a negative error code is returned from the called functions. This is because the original code used tested against errno which is a positive value. One place still tests against errno, but the test should be against the return value from the last function call. Fix that aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | ubiformat: handle write errors correctlySascha Hauer2019-07-161-9/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a barebox adoption of mtd-utils commit d9cbf6a ("ubiformat: handle write errors correctly"): | ubiformat: handle write errors correctly | | This issue was reported and analyzed by | Anton Olofsson <anol.martinsson@gmail.com>: | | when ubiformat encounters a write error while flashing the UBI image (which may | come from a file of from stdout), it correctly marks the faulty eraseblock as | bad and skips it. However, it also incorrectly drops the data buffer which was | supposed to be written, and reads next block of data. | | This patch fixes this issue - in case of a write error, we preserve the current | data and write it to the next eraseblock, instead of dropping it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | mtd: peb: Do not mark as bad in mtd_peb_torture()Sascha Hauer2019-07-163-6/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both the Kernel and mtd-utils have peb torture functions and both do not mark the block as bad automatically. Instead, the caller must mark the block as bad when -EIO is returned from the torture function. Do the same in barebox. This is necessary as the UBI code otherwise may mark a block as bad twice: Once indirectly in mtd_peb_torture() and then directly afterwards. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | ubiformat: improve generation of UBI image sequenceSascha Hauer2019-07-151-2/+4
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The UBI ec_hdr has an image_seq field. During attaching UBI expects that its value is the same for all eraseblocks. The value should be changed with every ubiformat and is used to detect half written images. In barebox we use a pseudo random number generated with rand() for this value. The ubiformat command calls srand(get_time_ns()) to initialize the pseudo random numbber generator. This is done in the option parser, so when ubiformat() is called directly (from fastboot for example) the pseudo random number generator is not initialized and we get the same values after every barebox restart. This patch moves the pseudo random number generator initialization to the place where the numbers are generated. Also use random32() rather than rand() to generate 32bit values rather than 15bit values (0 - RAND_MAX). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / | console: return number of characters written in fops_writeSascha Hauer2019-08-051-1/+1
|/ / | | | | | | | | | | | | | | struct cdev_operations write() callback is supposed to return the number of characters written. Do this instead of returning 0 for the console device files. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/stm32'Sascha Hauer2019-07-121-0/+1
|\ \
| * | reset_source: add new Brownout reset (BOR) sourceAhmad Fatoum2019-06-131-0/+1
| |/ | | | | | | | | | | | | | | | | The STM32MP1 can report brown out as reason for a reset, which doesn't fit into existing reasons. Thus add a new one to the enumeration. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/pstore'Sascha Hauer2019-07-121-0/+4
|\ \
| * | pstore: Only capture log messagesSascha Hauer2019-07-091-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this pstore only captures barebox log messages printed with pr_* and dev_*, but no longer anything printed with printf and friends. When capturing the barebox output with pstore only the log messages are of interest, but not the ones printed with printf and certainly not the things typed interactively on the command line. These are logged currently because we register pstore as a barebox console. Instead, hook into pr_puts which only outputs the barebox log messages. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | blspec: invalidate only necessary bootm variablesRouven Czerwinski2019-07-041-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of removing all global bootm variables, remove only the ones which will be set by the blspec entries. This allows setting the bootm.tee variable to load OP-TEE for blspec entries or setting the image load address. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | startup: Factor out the autoboot counter to separate functionSascha Hauer2019-07-031-46/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | The autoboot countdown is part of the init function. This patch factors out this code to a separate function to allow boards to call it at a different time. Also boards can set the autoboot state manually in case they have its own idea how to interrupt the autoboot process. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | startup: Create boot related variables where they are usedSascha Hauer2019-07-032-14/+14
| | | | | | | | | | | | | | | | | | | | | global.boot.default, global.linux.bootargs.base and global.user are used in the boot code, so create them there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | startup: Create global.linux.bootargs.dyn.* variables where they are neededSascha Hauer2019-07-032-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | global.linux.bootargs.dyn.* variables are exclusively used in boot scripts, so create them right before executing a script. This moves the corresponding code from the unrelated startup code to the place where the variables are used. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>