blob: 6bf0415e9c9b4d8b7e3ef847463d8e63d02d27f3 [file] [log] [blame]
Amaury Pouly303c4862011-11-06 19:44:03 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 by Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
Dominik Riebeling346f1e02011-12-04 13:54:18 +000022#ifndef MKIMXBOOT_H
23#define MKIMXBOOT_H
24
Amaury Pouly303c4862011-11-06 19:44:03 +000025#include <stdbool.h>
26#include <stdint.h>
27#include <sys/types.h>
Amaury Pouly303c4862011-11-06 19:44:03 +000028
Dominik Riebeling346f1e02011-12-04 13:54:18 +000029#ifdef __cplusplus
30extern "C" {
31#endif
Amaury Poulyff946f12017-01-01 21:31:47 +010032
Amaury Pouly303c4862011-11-06 19:44:03 +000033enum imx_error_t
34{
35 IMX_SUCCESS = 0,
36 IMX_ERROR = -1,
37 IMX_OPEN_ERROR = -2,
38 IMX_READ_ERROR = -3,
39 IMX_NO_MATCH = -4,
40 IMX_BOOT_INVALID = -5,
41 IMX_BOOT_MISMATCH = -6,
42 IMX_BOOT_CHECKSUM_ERROR = -7,
43 IMX_DONT_KNOW_HOW_TO_PATCH = -8,
Amaury Poulye09c1e32012-05-19 13:55:33 +020044 IMX_VARIANT_MISMATCH = -9,
Amaury Pouly58e27b92013-06-15 22:13:08 +020045 IMX_WRITE_ERROR = -10,
46 IMX_FIRST_SB_ERROR = -11,
Amaury Poulyff946f12017-01-01 21:31:47 +010047 IMX_MODEL_MISMATCH = -12,
Amaury Pouly303c4862011-11-06 19:44:03 +000048};
49
50enum imx_output_type_t
51{
52 IMX_DUALBOOT = 0,
Amaury Poulyff946f12017-01-01 21:31:47 +010053 IMX_RECOVERY,
54 IMX_SINGLEBOOT,
55 IMX_CHARGE,
56 IMX_ORIG_FW,
Amaury Pouly303c4862011-11-06 19:44:03 +000057};
58
Amaury Poulye09c1e32012-05-19 13:55:33 +020059/* Supported models */
60enum imx_model_t
61{
Amaury Poulyff946f12017-01-01 21:31:47 +010062 MODEL_UNKNOWN = 0,
63 MODEL_FUZEPLUS,
Amaury Pouly6ac481e2013-09-25 14:30:35 +020064 MODEL_ZENXFI2,
65 MODEL_ZENXFI3,
66 MODEL_ZENXFISTYLE,
67 MODEL_ZENSTYLE, /* Style 100 and Style 300 */
68 MODEL_NWZE370,
69 MODEL_NWZE360,
Amaury Poulyff946f12017-01-01 21:31:47 +010070 /* Last */
71 MODEL_COUNT
Amaury Poulye09c1e32012-05-19 13:55:33 +020072};
73
74/* Supported firmware variants */
75enum imx_firmware_variant_t
76{
77 VARIANT_DEFAULT = 0,
78 /* For the Creative ZEN X-Fi2 */
79 VARIANT_ZENXFI2_NAND,
80 VARIANT_ZENXFI2_SD,
81 VARIANT_ZENXFI2_RECOVERY,
Amaury Poulyf2dfc842013-01-26 18:37:12 +000082 /* For the Creative X-Fi Style */
83 VARIANT_ZENXFISTYLE_RECOVERY,
Amaury Pouly55babd52013-06-18 15:02:01 +020084 /* For the Creative Zen Style 100/300 */
85 VARIANT_ZENSTYLE_RECOVERY,
Amaury Poulye09c1e32012-05-19 13:55:33 +020086 /* Last */
87 VARIANT_COUNT
88};
89
Amaury Pouly303c4862011-11-06 19:44:03 +000090struct imx_option_t
91{
92 bool debug;
Amaury Poulyff946f12017-01-01 21:31:47 +010093 enum imx_model_t model;
Amaury Pouly303c4862011-11-06 19:44:03 +000094 enum imx_output_type_t output;
Amaury Poulye09c1e32012-05-19 13:55:33 +020095 enum imx_firmware_variant_t fw_variant;
Amaury Pouly42a725f2013-01-29 11:50:46 +000096 const char *force_version; // set to NULL to ignore
Amaury Pouly303c4862011-11-06 19:44:03 +000097};
98
Amaury Poulyff946f12017-01-01 21:31:47 +010099/* Print internal information to stdout about device database */
Amaury Poulye09c1e32012-05-19 13:55:33 +0200100void dump_imx_dev_info(const char *prefix);
Amaury Poulyff946f12017-01-01 21:31:47 +0100101/* Build a SB image from an input firmware and a bootloader, input firmware
102 * can either be a firmware update or another SB file produced by this tool */
Amaury Pouly303c4862011-11-06 19:44:03 +0000103enum imx_error_t mkimxboot(const char *infile, const char *bootfile,
104 const char *outfile, struct imx_option_t opt);
Amaury Poulyff946f12017-01-01 21:31:47 +0100105/* Compute MD5 sum of an entire file */
Amaury Pouly782d9c02014-05-29 21:45:51 +0200106enum imx_error_t compute_md5sum(const char *file, uint8_t file_md5sum[16]);
Amaury Poulyff946f12017-01-01 21:31:47 +0100107/* Compute "soft" MD5 sum of a SB file */
108enum imx_error_t compute_soft_md5sum(const char *file, uint8_t soft_md5sum[16]);
Amaury Poulyee2eb132017-11-05 18:27:18 +0100109/* Translate error */
110const char *imx_error_to_string(enum imx_error_t err);
Dominik Riebeling346f1e02011-12-04 13:54:18 +0000111
112#ifdef __cplusplus
113}
114#endif
115#endif
116