summaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* | | startup: remove unused editcmd variableSascha Hauer2019-07-031-3/+0
| | | | | | | | | | | | | | | | | | Nobody uses global.editcmd, so remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | add CONFIG_PBL_BREAK optionOleksij Rempel2019-06-271-0/+8
| |/ |/| | | | | | | | | | | | | With this option barebox will be build with breakpoint instruction in early pbl stage. Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | startup: execute /env/bin/init as part of the initial shellIan Abbott2019-06-131-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 90df2a955e3c ("defaultenv: Convert init script to C") unintentionally changed the way the legacy "/env/bin/init" script is run, so that it runs in a sub-shell context, effectively changing `run_command("source /env/bin/init");` to `run_command("/env/bin/init");`. Therefore, any changes to shell environment variables made by the script are undone when the script exits. This patch reverts back to the old behavior. Fixes: 90df2a955e3c ("defaultenv: Convert init script to C") Cc: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | startup: Do not overwrite global.linux.bootargs.consoleSascha Hauer2019-06-131-3/+0
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/ubootenv'Sascha Hauer2019-06-111-0/+8
|\ \
| * | filetype: Allow specifying cdev's filetype explicitlyAndrey Smirnov2019-06-071-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Allow specifying cdev's filetype explicitly to support the cases where the type of a cdev is known apriori, yet cannot be determined by reading the cdev's content. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | filetype: Add "U-Boot environmemnt variable data" filetypeAndrey Smirnov2019-06-071-0/+2
| |/ | | | | | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2019-06-114-9/+13
|\ \
| * | remove CONFIG_DEBUG_INFOOleksij Rempel2019-06-071-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | The ELF file should have debug symbols, the binary should have no symbols any way. Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | filetype: fix typoAntony Pavlov2019-06-071-1/+1
| | | | | | | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | libbb: Drop simple_itoa()Andrey Smirnov2019-05-281-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Hush is the only one user of simple_itoa() and the code there can be re-implemented using snprintf(). Change the code to get rid of simple_itoa(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: state: check lengthJan Remmet2019-05-231-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | if written_length is read from a partial written bucket it may be to big and xmalloc will panic barebox. Check if the value is sane. Make read_len unsigned to avoid negative values. Signed-off-by: Jan Remmet <j.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>