mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 13:12:37 -05:00
atjboottool: split fwu code into its own file
Slightly cleanup the code by removing the old and dangerous --force option. Change-Id: I776633a9924797fcd509b8b80623bcd64b391672
This commit is contained in:
parent
13364c5525
commit
95c32a505a
7 changed files with 1145 additions and 1074 deletions
|
|
@ -10,7 +10,7 @@ all: $(BINS)
|
|||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
atjboottool: atjboottool.o misc.o atj_tables.o
|
||||
atjboottool: atjboottool.o fwu.o misc.o atj_tables.o
|
||||
$(LD) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
29
utils/atj2137/atjboottool/afi.h
Normal file
29
utils/atj2137/atjboottool/afi.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2017 Amaury Pouly
|
||||
*
|
||||
* 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; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __AFI_H__
|
||||
#define __AFI_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Check if a file looks like a FWU file */
|
||||
bool afi_check(uint8_t *buf, size_t size);
|
||||
|
||||
#endif /* __AFI_H__ */
|
||||
File diff suppressed because it is too large
Load diff
1034
utils/atj2137/atjboottool/fwu.c
Normal file
1034
utils/atj2137/atjboottool/fwu.c
Normal file
File diff suppressed because it is too large
Load diff
40
utils/atj2137/atjboottool/fwu.h
Normal file
40
utils/atj2137/atjboottool/fwu.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2017 Amaury Pouly
|
||||
*
|
||||
* 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; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __FWU_H__
|
||||
#define __FWU_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum fwu_mode_t
|
||||
{
|
||||
FWU_AUTO, /* Will try to guess which mode to use */
|
||||
FWU_ATJ213X, /* Will use ATJ213x style mode */
|
||||
FWU_ATJ2127, /* Will use ATJ2127 variation */
|
||||
};
|
||||
|
||||
/* Decrypt a FWU file inplace, the size variable is updated to reflect the size of the decrypted
|
||||
* firmware. Return 0 on success. The mode parameter selects how the function guesses between
|
||||
* various variants of FWU. */
|
||||
int fwu_decrypt(uint8_t *buf, size_t *size, enum fwu_mode_t mode);
|
||||
/* Check if a file looks like a FWU file */
|
||||
bool fwu_check(uint8_t *buf, size_t size);
|
||||
|
||||
#endif /* __FWU_H__ */
|
||||
|
|
@ -37,7 +37,12 @@ static bool g_color_enable = true;
|
|||
void *xmalloc(size_t s)
|
||||
{
|
||||
void * r = malloc(s);
|
||||
if(!r) bugp("malloc");
|
||||
if(!r)
|
||||
{
|
||||
color(GREY);
|
||||
printf("Allocation failed.\n");
|
||||
abort();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,14 +22,15 @@
|
|||
#define __MISC_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define _STR(a) #a
|
||||
#define STR(a) _STR(a)
|
||||
#define cprintf(col, ...) do {color(col); printf(__VA_ARGS__); }while(0)
|
||||
|
||||
#define bug(...) do { fprintf(stderr,"["__FILE__":"STR(__LINE__)"]ERROR: "__VA_ARGS__); exit(1); } while(0)
|
||||
#define bugp(...) do { fprintf(stderr, __VA_ARGS__); perror(" "); exit(1); } while(0)
|
||||
#define cprintf_field(str1, ...) do{ cprintf(GREEN, str1); cprintf(YELLOW, __VA_ARGS__); }while(0)
|
||||
|
||||
#define ROUND_UP(val, round) ((((val) + (round) - 1) / (round)) * (round))
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
typedef char color_t[];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue