sunxi-tools/fit_image.h
Andre Przywara 14b3492e41 fel: Add FIT image parsing and loading
So far sunxi-fel expects a legacy U-Boot image after the SPL, when
called with the "uboot" command.
This only works for (current) 32-bit builds, which only need one image
to load (U-Boot proper).

64-bit builds also include at least a Trusted Firmware binary, and also
might contain a firmware image for the ARISC management processor. So
we use the more capable FIT image, which can contain multiple images
to load.

Introduce support for that, by adding code to parse a FIT image, find
the image files included, and load them to their respective load
addresses. On the way we keep track of the entry point, that only one of
those images provides, and also note the architecture of this image
(ARMv7 or AArch64).
On top of that we detect which of the images is the actual U-Boot proper
image, and append the chosen DTB to the end of it.

This all mimics the code U-Boot's SPL uses to achieve the same goal when
running from MMC or SPI flash, compare the implementation of
spl_load_simple_fit() in U-Boot's common/spl/spl_fit.c:
https://gitlab.denx.de/u-boot/u-boot/-/blob/master/common/spl/spl_fit.c

This requires the libfdt library for parsing the FIT image (which is in
fact a devicetree blob).

Signed-off-by: Andre Przywara <osp@andrep.de>
2021-01-12 12:30:55 +00:00

33 lines
1.1 KiB
C

/*
* Copyright (C) 2018-2020 Andre Przywara <osp@andrep.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; under version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __FIT_IMAGE_H__
#define __FIT_IMAGE_H__
#include <stdint.h>
#include "fel_lib.h"
/*
* Load all images referenced in the given U-Boot FIT image. @dt_name will
* be used to select one of the configurations. @use_aarch64 contains the
* target architecture of the entry point.
* Returns the entry point address of the image to be started.
*/
uint32_t load_fit_images(feldev_handle *dev, const void *fit,
const char *dt_name, bool *use_aarch64);
#endif