summaryrefslogtreecommitdiffstats
path: root/common/filetype.c
Commit message (Collapse)AuthorAgeFilesLines
* filetype: add new file types for EFI-enabled Linux imagesAhmad Fatoum2024-03-051-3/+10
| | | | | | | | | | | | | We currently detect EFI-stubbed Linux images for ARM64 and RISC-V as normal kernel images and would boot them that way. As these images additionally start with MZ like normal PE executables, lets have new filetypes for them. No functional change yet, but we can use a different bootm handler for them in the future when boot is configured to be EFI-enabled. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-82-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: have cdev_detect_type take a cdevAhmad Fatoum2024-03-051-10/+2
| | | | | | | | | | | cdev_detect_type reads as if it would take a cdev argument, but instead it takes the adev's path. Fix it, so it takes a cdev and change the only user. A new user will be added later that will pass in an already open cdev. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-51-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: add zstd supportMarco Felsch2024-02-061-0/+4
| | | | | | | | Add support to detect ZSTD compressed files. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20240124134738.133782-2-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: Layerscape: LS1028a: extend layerscape image filetype detection for LS1028aSascha Hauer2024-01-101-0/+2
| | | | | | | | The LS1028a images differ slightly from LS1046a images, extend its filetype detection accordingly. Link: https://lore.barebox.org/20240109161527.3237581-20-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: return error and pass filetype as pointer argumentSascha Hauer2023-08-181-14/+15
| | | | | | | | | | | | | | | | | file_name_detect_type(), file_name_detect_type_offset() and cdev_detect_type() return the filetype. With this all errors from these functions remain undetected and are just returned as filetype_unknown. Explicitly return an error code and pass the filetype as pointer argument so that callers can detect and handle errors. This fixes a bug in the bootm code where the returned filetype was erroneously tested for being smaller than 0. This was never true and so the corresponding error message was never printed. Now with this patch a non existing initrd or device tree file is responded with a meaningful error message. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: add NXP FlexSPI filetypeMarco Felsch2023-04-041-0/+5
| | | | | | | | | This adds the NXP FlexSPI FCFB header check to the file_detect_type() so update handlers can verify the correct type. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20230228-v2023-02-0-topic-flexspi-v2-16-3d33126d2434@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: Move mach header files to include/mach/imxSascha Hauer2023-03-061-1/+1
| | | | | | | | | | | Currently arch specific headers can be included with #include <mach/xxx.h>. With upcoming multi-arch support this is no longer possible as there won't be a single mach anymore. Move all i.MX specific header files to include/mach/imx/ to prepare for multi-arch support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fastboot: support TF-A FSBL and FIP images for barebox updateAhmad Fatoum2022-06-031-0/+2
| | | | | | | | | | | | Newly added stm32mp_bbu_mmc_fip_register() accepts two kinds of barebox images: A FIP image containing barebox as well as a FIP image preceded by TF-A as a STM32 FSBL image. Inform filetype_is_barebox_image of these file types, so the handler can be invoked via fastboot when global.fastboot.bbu=1. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: differentiate between STM32MP FSBL and SSBL imagesAhmad Fatoum2022-06-031-3/+10
| | | | | | | | | | | | | | We have some special handling for legacy (non-FIP) STM32 images: We have a bootm handler for chainloading and an update handler for use with GPT ssbl partitions. Both aren't applicable to the TF-A image used as FSBL. As barebox always has 0x00000000 at offset 0xfc and TF-A alrways has 0x10000000, we can use that to differentiate between the two images to make sure we refuse TF-A images when barebox images are expected. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: detect TF-A Firmware Image Packages (FIP)Ahmad Fatoum2022-02-231-0/+4
| | | | | | | | | | | | | FIP is the new format for firmware loaded by ARM Trusted Firmware. It can contain non-secure firmware, hardware config (device tree), firmware config (configuration DT) and optionally OP-TEE. In future, we may want to mount FIP to chain boot barebox out of it, but for now, just let barebox filetype detect it correctly. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220220124736.3052502-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/qoi'Sascha Hauer2022-02-181-0/+3
|\
| * filetype: Add QOI format image typeJules Maselbas2022-01-201-0/+3
| | | | | | | | | | | | | | | | | | QOI image format is a "Quite OK" image format, it's simplicity is it's strengh and could be a good replacement of bmp, maybe even for png. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Link: https://lore.barebox.org/20220117230235.13549-2-jmaselbas@kalray.eu Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | rename cdev_open() -> cdev_open_by_name()Sascha Hauer2022-02-081-1/+1
|/ | | | | | | | | | | | The cdev_* functions normally take a struct cdev * argument, with the exception of cdev_open(). Rename cdev_open() to cdev_open_by_name() to be able to implement cdev_open() with the expected semantics in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220207094953.949868-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: fat: pbl: support >32M alignment for first partitionAhmad Fatoum2021-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | The LBA of the first absolute sector in a partition is a 32-bit field at offset 0x8 of a partition entry. The first such partition entry is at offset 446 of the MBR. The DOS partition parser adheres to this scheme, but the FAT code contains a very basic partition parser as well that kicks in when a disk couldn't be mounted as FAT: It will seek to the first FAT partition in a MBR and mount that. This only happens with FAT PBL, because in barebox proper, we use the actual partition parser. The partition parser in FAT assumed starting LBA to be a 16-bit value and thus failed to load a first FAT partition located more than 0x10000 sectors into the image. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210922065000.20970-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: Add Rockchip boot image typeSascha Hauer2021-06-211-0/+3
| | | | | | | | | | | Newer Rockchip SoCs boot images starting with the magic "RKNS". There are older image formats currently not supported, this one is at least supported on the RK3568. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210615141641.31577-4-s.hauer@pengutronix.de Link: https://lore.barebox.org/20210621092802.27275-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: detect RISC-V imagesAhmad Fatoum2021-03-231-0/+6
| | | | | | | | | | We still have no boot support for RISC-V, take the first step by enabling barebox to detect both a RISC-V Linux kernel and barebox image. The header format is aligned with that of arm64, but they differ in the signature magic. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: replace license statements with SPDX-License-IdentifiersAhmad Fatoum2020-11-271-9/+1
| | | | | | | | | | | | | For all files in common/ that already have a license text: - Replace with appropriate SPDX-License-Identifier - Remove empty comment lines around replacement - remove comment completely if only thing remaining is name of file without description Reviewed-by: Roland Hieber <rhi@pengutronix.de> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mxs'Sascha Hauer2020-05-141-0/+4
|\
| * filetype: Add filetype for i.MX23/28 SD card imagesSascha Hauer2020-05-061-0/+4
| | | | | | | | | | | | | | Add a filetype for i.MX23/28 SD card images so that they can be detected. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: remove references to CREDITSUwe Kleine-König2020-04-271-3/+0
|/ | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: add Zynq image typeLucas Stach2019-12-111-0/+4
| | | | | | | | Use the 2 invariant words (width detection and image identification) from the Zynq image header to detect the filetype. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: mvebu: Fix kwbimage v1 detectionSascha Hauer2019-11-151-10/+12
| | | | | | | | | | | The kwbimage detection calculates a checksum over the first 31 bytes of the image. This is correct for the v0 image format, but for the v1 image format the checksum in the image also covers the extenstion headers. These might not be completely present in the initial buffer provided to file_detect_type(), so just drop the checksum calculation for v1 images. Fixes: bf8b6d46db ("kwbimage_v0: add support to detect and boot a mvebu v0 image") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* 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>
* 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/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>
* | 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>
* filetype: Detect Layerscape PBL imagesSascha Hauer2019-05-091-0/+7
| | | | | | | The Layerscape SoCs have their own boot image format. Add filetype detection for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: Always return enum filetype in file_name_detect_type_offset()Andrey Smirnov2019-03-111-2/+2
| | | | | | | | | None of the callers of file_name_detect_type_offset() are prepared to deal with negative error code. Change the code to return filetype_unknown if open_and_lseek() fails. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: Add code to detect i.MX image v2Andrey Smirnov2018-08-311-0/+4
| | | | | | | | Modify file_detect_type() and add code needed to be able to detect i.MX boot images with v2 header. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: Add code to detect i.MX image v1Andrey Smirnov2018-08-311-0/+7
| | | | | | | | Modify file_detect_type() and add code needed to be able to detect i.MX boot images with v1 header. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/bootm'Sascha Hauer2018-07-091-0/+5
|\
| * filetype: add ELF typeAntony Pavlov2018-06-151-0/+5
| | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | kwbimage_v0: add support to detect and boot a mvebu v0 imageUwe Kleine-König2018-06-041-5/+17
|/ | | | | | | | | The differences between v0 and v1 of the mvebu kwbimage are small enough that the function to boot such an image can be shared between both variants. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: Detect ARM aarch64 Linux imagesSascha Hauer2018-04-041-0/+3
| | | | | | ARM aarch64 Linux image have a special type. Allow to detect them. 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>
* filetype: Add fastboot sparse format detectionSascha Hauer2018-01-171-0/+5
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: Add image type for boot images used on Armada 370 and XPUwe Kleine-König2017-03-021-0/+8
|
* Add filetype and detection for squashfs imagesEnrico Jorns2016-10-241-0/+4
| | | | | | | | | | | | | | | | | | | This adds `filetype_squashfs` to the list of known filetypes and adds a detection for squashfs files to file_detect_type(). This currently matches on the `hsqs` start sequence of an image file. Additionally, the newly introduced filetype is registered as the type of the squashfs_driver which allows, for example, to mount squashfs without the need to specify a type parameter. This changes enable booting a squashfs with the simple `boot` command pointing to the location (device) that holds the squashfs. Note that booting with blspec is limited as the current squashfs driver is not capable of handling symbolic links. Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: add new filetype for SoCFPGA xload imageSteffen Trumtrar2016-08-181-0/+4
| | | | | Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: Fix booting ARM Linux Kernels with CONFIG_EFI enabledSascha Hauer2016-04-191-2/+3
| | | | | | | | When an ARM kernel is built with CONFIG_EFI enabled, then the kernel image also looks like a EXE file. Move ARM zImage detection before EXE detection so that the kernel is still detected as zImage. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fastboot: Add a ARM Barebox filetype handlerMarkus Pargmann2016-03-111-0/+13
| | | | | | | | | This will automatically call barebox_update for the transfered file if it is an ARM Barebox image and the destination file is defined by some update handler. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: filetype: do not redetect MBR-type devices as a FAT-typePeter Mamonov2015-11-231-31/+0
| | | | | | | | | | | | | Deleted pieces of code detect MBR-containig device as a FAT-type device, if it's first partition contains a FAT filesystem. This behaviour enabled one to mount the FAT FS which is either directly on the device (disk0) or on the first partition (disk0.0) using the same command: mount /dev/disk0 /fat However, the desired behaviour can be reached with a: mount /dev/disk0 /fat || mount /dev/disk0.0 /fat || echo "Mounting failed" Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: Use cdev_openSascha Hauer2015-10-151-1/+3
| | | | | | | a cdev has to be opened before usage. Use cdev_open instead of cdev_by_name. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* detect_fs: use device instead of fileVicente Bergas2015-10-021-0/+37
| | | | | | | | detect_fs would usually mount a device on a directory, so, use a device-specific type detection. Signed-off-by: Vicente Bergas <vicencb@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: Add filetype for MXS bootstreamSascha Hauer2015-06-121-0/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/xz'Sascha Hauer2014-11-051-0/+4
|\
| * filetype: Add XZ filetype supportSascha Hauer2014-10-241-0/+4
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: fix mbr filetype detectionZahari Doychev2014-11-051-0/+48
|/ | | | | | | | | | | | | | Sometimes mbr is erroneously recocognised as FAT partion. Due to this the mbr partition parser is not being called and the partitions on the media are not detected. This patch should fix the problem. The checking is done as in the linux kernel. I have seen the problem using usb sticks. Although partitioning and formatting them under linux. The file system type field in the mbr remains there which causes the wrong detections as FAT32 type and not as mbr. Signed-off-by: Zahari Doychev <zahari.doychev@linux.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>