mirror of https://github.com/FOME-Tech/fome-fw.git
dead bin2header
This commit is contained in:
parent
57691ce0f9
commit
34061103ff
|
@ -1,28 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCRIPT_NAME="compile_bootloader.sh"
|
||||
echo "Entering $SCRIPT_NAME"
|
||||
|
||||
# Needed for board overrides
|
||||
[ $BOOTLOADER_CODE_DESTINATION_PATH ] || { BOOTLOADER_CODE_DESTINATION_PATH=".."; }
|
||||
|
||||
BOOTLOADER_CODE_DESTINATION_FILE=$BOOTLOADER_CODE_DESTINATION_PATH/bootloader_generated.hxx
|
||||
|
||||
echo "$SCRIPT_NAME: Starting bootloader compilation..."
|
||||
make -j6 $1 $2 $3
|
||||
|
||||
# downstream scripts detect error condition by checking if the output file exists so we need to make sure we remove it
|
||||
[ $? -eq 0 ] || { echo "ERROR: bootloader compilation failed"; rm -f blbuild/$BOOTLOADER_CODE_DESTINATION_FILE ; exit 1; }
|
||||
|
||||
echo "$SCRIPT_NAME: Bootloader build success."
|
||||
|
||||
cd blbuild
|
||||
# Generate a header file with binary bootloader code
|
||||
java -jar ../../../java_tools/bin2header.jar bootloader.bin "$BOOTLOADER_CODE_DESTINATION_FILE" "$BOOTLOADER_COMMENT static const volatile uint8_t bootloader_code[] BOOTLOADER_SECTION"
|
||||
[ $? -eq 0 ] || { echo "$SCRIPT_NAME: error generating header file"; exit 1; }
|
||||
cd ..
|
||||
|
||||
# Touch 'bootloader_storage.c' to update its modification date (needed for make)
|
||||
touch bootloader_storage.c
|
||||
|
||||
pwd
|
|
@ -1,14 +0,0 @@
|
|||
plugins {
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
defaultTasks 'jar'
|
||||
|
||||
jar {
|
||||
destinationDirectory = file( '$rootDir/../..' )
|
||||
manifest {
|
||||
attributes(
|
||||
'Main-Class': 'rusefi.Bin2Header'
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package rusefi;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.Date;
|
||||
|
||||
public class Bin2Header {
|
||||
private static final String NL = "\n";//System.getProperty("line.separator");
|
||||
private final static char[] hexChars = "0123456789abcdef".toCharArray();
|
||||
|
||||
private Bin2Header() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length < 3) {
|
||||
System.out.println("This tool converts a binary file to C/C++ header file");
|
||||
System.out.println("usage:");
|
||||
System.out.println("Bin2Header in_file.bin out_file.h arrayVariableDecl");
|
||||
return;
|
||||
}
|
||||
|
||||
String binFile = args[0];
|
||||
String hFile = args[1];
|
||||
String arrayVariableDecl = args[2];
|
||||
|
||||
System.out.println("Converting " + binFile + " into " + hFile);
|
||||
|
||||
// This will reference one line at a time
|
||||
String line = null;
|
||||
|
||||
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(hFile));
|
||||
Path path = Paths.get(binFile);
|
||||
byte[] data = Files.readAllBytes(path);
|
||||
|
||||
String headerTag = hFile;
|
||||
int pos = headerTag.lastIndexOf("/");
|
||||
if (pos >= 0)
|
||||
headerTag = headerTag.substring(pos + 1);
|
||||
headerTag = headerTag.toUpperCase().replace(".", "_") + "_";
|
||||
|
||||
bw.write("// This file was generated by Bin2Header" + NL);
|
||||
bw.write("// " + new Date() + NL);
|
||||
bw.write("#ifndef " + headerTag + NL);
|
||||
bw.write("#define " + headerTag + NL + NL);
|
||||
|
||||
bw.write(arrayVariableDecl + " = {");
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
if ((i & 0xf) == 0)
|
||||
bw.write(NL + "\t");
|
||||
int b = data[i] & 0xFF;
|
||||
bw.write("0x");
|
||||
bw.write(hexChars[b >>> 4]);
|
||||
bw.write(hexChars[b & 0xf]);
|
||||
bw.write(", ");
|
||||
}
|
||||
|
||||
bw.write(NL + "};" + NL + NL);
|
||||
bw.write("#endif /* " + headerTag + " */" + NL + NL);
|
||||
bw.close();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue