summaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* rename file_operations -> cdev_operationsSascha Hauer2018-04-062-2/+2
| | | | | | | | Linux also has struct file_operations which are something different. Rename our file_operations to cdev_operations which better matches what we have. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Revert "startup: Load default environment earlier"Sascha Hauer2018-03-191-3/+3
| | | | | | | | | | | | | | | | Several boards use defaultenv_append_directory() to append a board specific envfs snippet during runtime. This only works when defaultenv_append_directory() is called before defaultenv_load() is exectuted. Since that was executed at the end of the start process every initcall level could be used to append a env directory. With this patch only initcall levels earlier than fsdevice_initcall work and most boards do not cope with this. Revert this patch until a better solution is found. Reported-by: Alexander Kurz <akurz@blala.de> This reverts commit 5b92cfceff38f3a6462a21cf6b69159ad0ae9744.
* Merge branch 'for-next/ratp'Sascha Hauer2018-03-0511-98/+617
|\
| * ratp: new reset commandAleksander Morgado2018-03-012-0/+56
| | | | | | | | | | | | | | | | E.g.: $ ./bbremote -v --port /dev/ttyUSB2 reset Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: new md and mw commandsAleksander Morgado2018-03-013-0/+377
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces support for running the md and mw commands using the binary interface provided by RATP. This allows clients to read and write memory files without needing to do custom string parsing on the data returned by the console 'md' and 'mw' operations. The request and response messages used for these new operations are structured in the same way: * An initial fixed-sized section includes the fixed-sized variables (e.g. integers), as well as the size and offset of the variable-length variables. * After the initial fixed-sized section, the buffer is given, which contains the variable-length variables in the offsets previously defined and with the size previously defined. The message also defines separately the offset of the buffer w.r.t. the start of the message. The endpoint reading the message will use this information to decide where the buffer starts. This allows to extend the message format in the future without needing to break the message API, as new fields can be appended to the fixed-sized section as long as the buffer offset is also updated to report the new position of the buffer. E.g.: $ ./bbremote --port /dev/ttyUSB2 md /dev/pic_eeprom_rdu 0x107 5 0000000000 $ ./bbremote --port /dev/ttyUSB2 mw /dev/pic_eeprom_rdu 0x107 0102030405 5 bytes written $ ./bbremote --port /dev/ttyUSB2 md /dev/pic_eeprom_rdu 0x107 5 0102030405 $ ./bbremote --port /dev/ttyUSB2 mw /dev/pic_eeprom_rdu 0x107 0000000000 5 bytes written $ ./bbremote --port /dev/ttyUSB2 md /dev/pic_eeprom_rdu 0x107 5 0000000000 Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: use xstrndup() instead of a custom xmemdup_add_zero()Aleksander Morgado2018-03-011-12/+1
| | | | | | | | | | | | | | | | The console operations done via RATP expect strings, so just use xstrndup() instead of defining a custom method. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: implement getenv as a standard ratp commandAleksander Morgado2018-03-013-30/+52
| | | | | | | | | | | | | | | | Also, use xstrndup() instead of the custom xmemdup_add_zero() as we're working with strings anyway. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: implement ping as a standard ratp commandAleksander Morgado2018-03-013-24/+41
| | | | | | | | | | Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: allow building without full console supportAleksander Morgado2018-03-012-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Make CONFIG_RATP a selectable config option, so that the user can enable RATP support without explicitly needing to enable the full console support over RATP (e.g. only for RATP FS or built-in command support). The full console can still be explicitly enabled with CONFIG_CONSOLE_RATP. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: moved logic to its own subdirectoryAleksander Morgado2018-03-015-14/+18
| | | | | | | | | | | | | | | | We are going to add new RATP command implementations in separate files within this subdirectory. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: implement generic command supportAleksander Morgado2018-03-012-16/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The RATP implementation now allows executing generic commands with a binary interface: binary requests are received and binary responses are returned. Each command can define its own RATP request contents (e.g. to specify command-specific options) as well as its own RATP response contents (if any data is to be returned). Each command is associated with a pair of numeric unique request and response IDs, and for easy reference these IDs are maintained in the common ratp_bb header. Modules may override generic implemented commands or include their own new ones (as long as the numeric IDs introduced are unique). Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2018-03-053-20/+63
|\ \
| * | Use globalvar_add_simple_string for model and hostnameSascha Hauer2018-02-261-18/+8
| | | | | | | | | | | | | | | | | | | | | Simplify the code by using globalvar_add_simple_string(), no functional change intended. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | console: added colored print out of log levelsEugen Wiens2018-02-221-0/+25
| | | | | | | | | | | | | | | | | | | | | When the system is booting the warnings and errors are not be quickly discovered. With this improvement the errors are colored red, the warnings yellow and the notices blue. Signed-off-by: Eugen Wiens <eugen.wiens@jumo.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | console: move global.allow_color handling to C codeSascha Hauer2018-02-222-2/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | We have global.allow_color, but this is limited to the environment only. Move creation and handling of this variable to C code so that we can add support for colored output to commands/console controlled by the same variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | bootm: fit: add option to add DT snipped that contains fit public keyMarc Kleine-Budde2018-02-201-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it easier for build systems to include a configurable dts snippet which holds the public keys for FIT images. Usage: Add to your dts: #ifdef CONFIG_BOOTM_FITIMAGE_PUBKEY #include CONFIG_BOOTM_FITIMAGE_PUBKEY #endif Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/fastboot'Sascha Hauer2018-03-051-19/+36
|\ \ \ | |_|/ |/| |
| * | ubiformat: Allow to ubiformat with a buffer givenSascha Hauer2018-02-091-19/+36
| |/ | | | | | | | | | | | | So far ubiformat can only handle files. Make it possible to pass a buffer into ubiformat. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | state: find backend node with its reproducible nameSascha Hauer2018-02-222-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | When fixing up the kernels state nodes we depended on the full node path of the input device tree. This does not work when the kernel device tree has different names. This has happened lately when the i.MX6 device trees got their leading zeroes removed from the node names. Use of_find_node_by_reproducible_name() to find the node corresponding to the storage backend node in the kernel device tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | state: remove unused arguments from state_new_from_node()Sascha Hauer2018-02-222-29/+17
|/ | | | | | | | state_new_from_node() has arguments describing the backend path. These are never used in barebox, the backend path is always derived from the device nodes backend description. Remove these arguments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* FIT: Use const dtb unflatten variantSascha Hauer2018-02-081-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/tftp-workaround'Sascha Hauer2018-02-082-25/+25
|\
| * uimage: Use is_tftp_fs() and cache_file() to ease TFTP workaroundSascha Hauer2018-01-251-25/+22
| | | | | | | | | | | | | | We have helper functions now to ease file caching when a file is on TFTP. Use them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * uimage: fix memory leak in error pathSascha Hauer2018-01-251-0/+2
| | | | | | | | | | | | | | handle->name is dynamically allocated, so free it in the error path. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Stefan Lengfeld <contact@stefanchrist.eu>
| * startup: create /tmpSascha Hauer2018-01-231-0/+1
| | | | | | | | | | | | | | Some commands create temporary files in /. Create /tmp to offer these commands an appropriate place for storing temporary files. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/ratp'Sascha Hauer2018-02-081-16/+10
|\ \
| * | ratp: remove unused context fieldsAleksander Morgado2018-01-301-6/+0
| | | | | | | | | | | | | | | Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | ratp: move barebox-specific command to ratp_bb.hAleksander Morgado2018-01-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The ratp_run_command() is really an implementation detail of the barebox ratp 'command' operation support. Move it to the barebox specific header and rename it with the correct prefix. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | ratp: rename global context variableAleksander Morgado2018-01-301-9/+9
| |/ | | | | | | | | | | | | | | | | | | The 'ratp_command_ctx' seems to specify that this variable is only used to process command operations, but it really is used in every async operation (e.g. also in FS), so just rename it to a more generic name for clarity. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2018-02-088-11/+32
|\ \
| * | env: Add more context to error messageSascha Hauer2018-02-081-1/+1
| | | | | | | | | | | | | | | | | | | | | When setenv complains that it can't set a device parameter, then print which parameter it tried to set. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | bootchooser: Drop SHELL_NONE conflictSascha Hauer2018-02-061-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | Earlier versions of the bootchooser code executed scripts, thus had to depend on shell support. We do not need this anymore, so the dependency can be dropped. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | boot: Make independent of command supportSascha Hauer2018-02-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The boot code works with command support disabled if we skip support for boot scripts. Bail out before parsing boot scripts and allow to build with command support disabled. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | startup: Load default environment earlierSascha Hauer2018-02-061-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some files compiled into the default environment may be needed earlier in the boot process, so move loading of the default environment to fs_initcall. Only the default environment is loaded earlier, but not the overwriting with the persistent environment files, so when the files are used that early, only the compiled in version is available; it's not overwritable at that time. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | state: Add 'init_from_defaults' parameterSascha Hauer2018-02-062-0/+9
| | | | | | | | | | | | | | | | | | | | | The init_from_defaults parameter allows to detect if a state has been initialized from default values, i.e. state_load failed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | state: refuse to set dirty parameter via setenvSascha Hauer2018-02-061-1/+6
| | | | | | | | | | | | | | | | | | The dirty parameter is readonly, so refuse to set it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | filetype: Add type detection at an offsetPhilipp Zabel2018-02-051-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | Add file_name_detect_type_offset to allow file system detection for loop mounts at an offset. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | bootargs: Fix memory leak in linux_bootargs_get()Sascha Hauer2018-01-261-2/+4
| |/ | | | | | | | | | | | | globalvar_get_match() returns an allocated string which may be empty. We have to free() the empty string aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/constify'Sascha Hauer2018-02-082-15/+16
|\ \
| * | imd: Make all pointers into image constSascha Hauer2018-01-302-15/+16
| |/ | | | | | | | | | | | | The IMD code should be readonly and never modify any pointers. Make all pointers const so that const pointers can be passed in to IMD. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | FIT: Allow to open buffer as FIT imageSascha Hauer2018-02-081-32/+81
| | | | | | | | | | | | This adds fit_open_buf() which can open a buffer as FIT image. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | FIT: Implement opening images with no configurationSascha Hauer2018-02-081-7/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | different images can be grouped together to build a FIT configuration. So far we only supported opening images as parts of configurations. This patch adds support for opening images that are not part of a configuration. This mode is used when the configuration parameter of fit_open_image is NULL. The main difference is in the way the RSA signature is checked. When being part of a configuration all involved nodes (including the hash nodes of the images, but not the image itself) are covered by the signature, thus during opening an image only the validity of the image data hash has to be checked. When not being part of a configuration, the image data itself is signed and must be checked. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | FIT: factor out some helper functionsSascha Hauer2018-02-081-47/+74
| | | | | | | | | | | | | | Create and use fit_alloc_digest() and fit_read_rsa_public_key() which we can use a second time in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | FIT: move handle->verify check to fit_verify_hash()Sascha Hauer2018-02-081-20/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Preparation for the next step which will allow to open images which are not part of a configuration. This has one change inside: We used to iterate over all subnodes of a image expecting all of them containing a hash, so it could happen that we check multiple hashes if more exist or that we falsely interpret some unrelated subnode as hash node. With this patch we expect the hash in a subnode named "hash@1" as required by the FIT image format description. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | FIT: store device_nodes in fit_handleSascha Hauer2018-02-081-8/+12
| | | | | | | | | | | | | | | | We need the /images and /configurations nodes more than once, so store them in the fit_handle rather than searching for them each time again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | FIT: Let user specify the configuration to useSascha Hauer2018-02-082-24/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The images in FIT images can be opened in two different ways. They can be either opened directly based on their names in the images/ node or as part of a configuration based on their names in the corresponding /configuration/ node. So far we only supported the latter. To prepare supporting the former we return a cookie belonging to the configuration from fit_open_configuration() which we use in fit_open_image() to refer to the desired configuration. While at it document fit_open_configuration(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | FIT: Do not pre-open imagesSascha Hauer2018-02-081-21/+0
| | | | | | | | | | | | | | Only do what fit_open_configuration() suggests: open the configuration, but not the images in it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootm: FIT: do not depend on FIT pre-opened imagesSascha Hauer2018-02-081-14/+32
|/ | | | | | | | | | When calling fit_open_configuration the FIT code already opens the images "kernel", "ramdisk" and "dtb". This does not fit well into the FIT code, so make the bootm code independent of these pre-opened images so that we can drop the opening from the FIT code in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2018-01-226-52/+138
|\
| * partitions: dos: Treat all extended partition types equallyAndrey Smirnov2018-01-221-7/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Creating logical DOS partitions with fdisk (Fedora 27, fdisk from util-linux 2.30.2) results in extended partition of type 0x05 being created on the device. Partitioned like this, device is succesfully recognized by Linux, but, due to algorithm in dos_partition(), not Barebox. Looking closer at the actual contents of MBR shows that while marked as "Extended partition with CHS addressing" that partition still have all of the LBA adressed fields filled correctly. Given the above and the fact that similar code in Linux kernel (block/partitions/msdos.c) does not make a distinction between types 0x0f and 0x05, port Linux's is_extended_partition() and convert the code to treat types 0x05, 0x0f and 0x85 the same way. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>