summaryrefslogtreecommitdiffstats
path: root/common/imd.c
Commit message (Collapse)AuthorAgeFilesLines
* imd: Make all pointers into image constSascha Hauer2018-01-301-13/+14
| | | | | | | 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>
* imd: make it work on big-endian machinesAntony Pavlov2016-05-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit commit 5e335773e0814173b40873a891964a7858d64688 Author: Sascha Hauer <s.hauer@pengutronix.de> Date: Tue Mar 29 10:06:46 2016 +0200 imd: use struct imd_header * as argument introduces additional imd type checks like this if (!imd_is_string(imd->type)) return NULL; These checks work incorrectly on any big-endian machine because the imd->type field needs addition conversion to little-endian byteorder before use. Here is the imd command output on big-endian qemu-malta: barebox:/ imd /dev/nor0.barebox release: <NULL> build: <NULL> This patch fixes the problem by adding necessary conversion via imd_read_type(). Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* stdio: replace fprintf(stderr,...) with eprintfSascha Hauer2016-04-151-2/+2
| | | | | | | We have a shortcut for fprintf(stderr, so use it. This is done to be able to remove fprintf in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imd: Add function to read parametersSascha Hauer2016-04-011-0/+31
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imd: export functionsSascha Hauer2016-04-011-3/+27
| | | | | | | To make the image metadata API usable for external users export some functions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imd: rename imd_search_validate to imd_getSascha Hauer2016-04-011-13/+11
| | | | | | | The name is more suitable for what the function does. Also let the function return a pointer to the imd data found in the buffer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imd: string returned from imd_string_data should be constSascha Hauer2016-04-011-6/+10
| | | | | | | imd_string_data() returns the original data, so the string should be const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imd: use struct imd_header * as argumentSascha Hauer2016-03-291-15/+16
| | | | | | | | imd_concat_strings() and imd_string_data() are easier to handle when they take a struct imd_header * instead of a struct imd_entry_string *. Change this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imd: provide dummy imd_command_setenvLucas Stach2015-02-121-0/+7
| | | | | | | | | | | | | | If CONFIG_CMD_IMD is not set there is no imd_command_setenv in the barebox binary that can be linked to. Although the whole imd infrastructure will be removed by the linker later in the build process as soon as it figures out that nothing inside barebox is using it, we still have to provide a dummy function to keep the build going. Fixes: In function `imd_command': undefined reference to `imd_command_setenv' Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add support for metadata in barebox imagesSascha Hauer2014-08-071-0/+322
It's often useful to get some information about a barebox image before starting or flashing it. This patch introduces barebox Image MetaData (IMD). When enabled a barebox image will contain a list of tags containing the desired information. We have tags for: - the barebox release (2014.07.0-00160-g035de50-dirty) - the build timestamp (#741 Mon Jul 28 15:08:54 CEST 2014) - the board model the image is intended for - the device tree toplevel compatible property Also there is an additional generic key-value store which stores parameters for which no dedicated tag exists. In this patch it is used for the memory size an image supports. Since there is no fixed offset in a barebox image which can be used for storing the information, the metadata is stored somewhere in the image and found by iterating over the image. This works for most image types, but obviously not for SoC images which are encoded or encrypted in some way. There is a 'imd' tool compiled from the same sources for barebox, for the compile host and for the target, so the metadata information is available whereever needed. For device tree boards the model and of_compatible tags are automatically generated. Example output of the imd tool for a Phytec phyFLEX image: build: #889 Wed Jul 30 16:08:54 CEST 2014 release: 2014.07.0-00167-g6b2070d-dirty parameter: memsize=1024 of_compatible: phytec,imx6x-pbab01 phytec,imx6dl-pfla02 fsl,imx6dl model: Phytec phyFLEX-i.MX6 Duallite Carrier-Board Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>