aboutsummaryrefslogtreecommitdiffstats
path: root/tools/firmware-utils/src/mkdhpimg.c
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2021-07-05 11:54:26 +0200
committerRafał Miłecki <rafal@milecki.pl>2021-10-05 16:20:10 +0200
commit8cc9a74a3f6bf363645efda6db417f8dadd3d844 (patch)
tree68f1648a077df8e49328f087eccaf94c2e47d1e8 /tools/firmware-utils/src/mkdhpimg.c
parentf82c93b93c0a021921ac7a30ba6e7a090c7ddd1c (diff)
downloadupstream-8cc9a74a3f6bf363645efda6db417f8dadd3d844.tar.gz
upstream-8cc9a74a3f6bf363645efda6db417f8dadd3d844.tar.bz2
upstream-8cc9a74a3f6bf363645efda6db417f8dadd3d844.zip
firmware-utils: update to version 2021-10-05
Includes following changes: db65821f006c cmake: fix missing install target 3a0cfc856991 Add initial GitLab CI support 8f47adea6f87 Add missing includes for byte swap operations fbafae9f8037 Convert to CMake based project Additionaly moves source code into separate Git project repository and converts the package build to utilize CMake. Signed-off-by: Petr Štetiar <ynezz@true.cz> [rmilecki: rebase, update to the latest repo git & rm -r src] Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'tools/firmware-utils/src/mkdhpimg.c')
-rw-r--r--tools/firmware-utils/src/mkdhpimg.c81
1 files changed, 0 insertions, 81 deletions
diff --git a/tools/firmware-utils/src/mkdhpimg.c b/tools/firmware-utils/src/mkdhpimg.c
deleted file mode 100644
index 9b77b44e05..0000000000
--- a/tools/firmware-utils/src/mkdhpimg.c
+++ /dev/null
@@ -1,81 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (c) 2016 FUKAUMI Naoki <naobsd@gmail.com>
- */
-
-#include <sys/stat.h>
-#include <err.h>
-#include <fcntl.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "buffalo-lib.h"
-
-#define DHP_HEADER_SIZE 20
-
-static char *progname;
-
-static void
-usage(void)
-{
-
- fprintf(stderr, "usage: %s <in> <out>\n", progname);
- exit(EXIT_FAILURE);
-}
-
-int
-main(int argc, char *argv[])
-{
- struct stat in_st;
- size_t size;
- uint32_t crc;
- int in, out;
- uint8_t *buf;
-
- progname = argv[0];
-
- if (argc != 3)
- usage();
-
- if ((in = open(argv[1], O_RDONLY)) == -1)
- err(EXIT_FAILURE, "%s", argv[1]);
-
- if (fstat(in, &in_st) == -1)
- err(EXIT_FAILURE, "%s", argv[1]);
-
- size = DHP_HEADER_SIZE + in_st.st_size;
-
- if ((buf = malloc(size)) == NULL)
- err(EXIT_FAILURE, "malloc");
-
- memset(buf, 0, DHP_HEADER_SIZE);
- buf[0x0] = 0x62;
- buf[0x1] = 0x67;
- buf[0x2] = 0x6e;
- buf[0xb] = 0xb1;
- buf[0xc] = (size >> 24) & 0xff;
- buf[0xd] = (size >> 16) & 0xff;
- buf[0xe] = (size >> 8) & 0xff;
- buf[0xf] = size & 0xff;
-
- read(in, &buf[DHP_HEADER_SIZE], in_st.st_size);
- close(in);
-
- crc = buffalo_crc(buf, size);
- buf[0x10] = (crc >> 24) & 0xff;
- buf[0x11] = (crc >> 16) & 0xff;
- buf[0x12] = (crc >> 8) & 0xff;
- buf[0x13] = crc & 0xff;
-
- if ((out = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1)
- err(EXIT_FAILURE, "%s", argv[2]);
- write(out, buf, size);
- close(out);
-
- free(buf);
-
- return EXIT_SUCCESS;
-}