Skip to content

Instantly share code, notes, and snippets.

@ryu10
Last active May 24, 2023 15:51
Show Gist options
  • Save ryu10/4cf6b3015607730a15e2a74e0a69bb05 to your computer and use it in GitHub Desktop.
Save ryu10/4cf6b3015607730a15e2a74e0a69bb05 to your computer and use it in GitHub Desktop.
hex2bin patch on libcrc.h Makefile common.h
--- hex2bin/libcrc.h 2023-05-21 01:35:20.711215991 +0100
+++ hex2bin.new/libcrc.h 2023-05-21 01:21:23.359661817 +0100
@@ -24,7 +24,7 @@
#ifndef _LIBCRC_H_
#define _LIBCRC_H_
-void *crc_table;
+extern void *crc_table;
void init_crc8_normal_tab(uint8_t polynom);
void init_crc8_reflected_tab(uint8_t polynom);
--- hex2bin/common.h 2023-05-21 01:35:20.707216070 +0100
+++ hex2bin.new/common.h 2023-05-21 01:20:57.640163966 +0100
@@ -11,11 +11,11 @@
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
-
+
//#if defined(_WIN32) || defined(_WIN64)
//#include <windows.h>
//#endif /* _WIN32 */
-
+
/* option character */
#if defined(MSDOS) || defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS)
#define _IS_OPTION_(x) (((x) == '-') || ((x) == '/'))
@@ -74,10 +74,10 @@
void GetExtension(const char *str,char *ext);
void PutExtension(char *Flnm, char *Extension);
-filetype Filename; /* string for opening files */
-char Extension[MAX_EXTENSION_SIZE]; /* filename extension for output files */
+extern filetype Filename; /* string for opening files */
+extern char Extension[MAX_EXTENSION_SIZE]; /* filename extension for output files */
-FILE *Filin, /* input files */
+extern FILE *Filin, /* input files */
*Filout; /* output files */
#ifdef USE_FILE_BUFFERS
@@ -85,44 +85,44 @@
*FiloutBuf; /* text buffer for file output */
#endif
-int Pad_Byte;
-bool Enable_Checksum_Error;
-bool Status_Checksum_Error;
-byte Checksum;
-unsigned int Record_Nb;
-unsigned int Nb_Bytes;
+extern int Pad_Byte;
+extern bool Enable_Checksum_Error;
+extern bool Status_Checksum_Error;
+extern byte Checksum;
+extern unsigned int Record_Nb;
+extern unsigned int Nb_Bytes;
/* This will hold binary codes translated from hex file. */
-byte *Memory_Block;
-unsigned int Lowest_Address, Highest_Address;
-unsigned int Starting_Address, Phys_Addr;
-unsigned int Records_Start; // Lowest address of the records
-unsigned int Max_Length;
-unsigned int Minimum_Block_Size;
-unsigned int Ceiling_Address;
-unsigned int Floor_Address;
-int Module;
-bool Minimum_Block_Size_Setted;
-bool Starting_Address_Setted;
-bool Floor_Address_Setted;
-bool Ceiling_Address_Setted;
-bool Max_Length_Setted;
-bool Swap_Wordwise;
-bool Address_Alignment_Word;
-bool Batch_Mode;
-bool Verbose_Flag;
-
-int Endian;
-
-t_CRC Cks_Type;
-unsigned int Cks_Start, Cks_End, Cks_Addr, Cks_Value;
-bool Cks_range_set;
-bool Cks_Addr_set;
-bool Force_Value;
-
-unsigned int Crc_Poly, Crc_Init, Crc_XorOut;
-bool Crc_RefIn;
-bool Crc_RefOut;
+extern byte *Memory_Block;
+extern unsigned int Lowest_Address, Highest_Address;
+extern unsigned int Starting_Address, Phys_Addr;
+extern unsigned int Records_Start; // Lowest address of the records
+extern unsigned int Max_Length;
+extern unsigned int Minimum_Block_Size;
+extern unsigned int Ceiling_Address;
+extern unsigned int Floor_Address;
+extern int Module;
+extern bool Minimum_Block_Size_Setted;
+extern bool Starting_Address_Setted;
+extern bool Floor_Address_Setted;
+extern bool Ceiling_Address_Setted;
+extern bool Max_Length_Setted;
+extern bool Swap_Wordwise;
+extern bool Address_Alignment_Word;
+extern bool Batch_Mode;
+extern bool Verbose_Flag;
+
+extern int Endian;
+
+extern t_CRC Cks_Type;
+extern unsigned int Cks_Start, Cks_End, Cks_Addr, Cks_Value;
+extern bool Cks_range_set;
+extern bool Cks_Addr_set;
+extern bool Force_Value;
+
+extern unsigned int Crc_Poly, Crc_Init, Crc_XorOut;
+extern bool Crc_RefIn;
+extern bool Crc_RefOut;
void VerifyChecksumValue(void);
void VerifyRangeFloorCeil(void);
@@ -130,7 +130,7 @@
void WriteMemBlock16(uint16_t Value);
void WriteMemBlock32(uint32_t Value);
void WriteMemory(void);
-void Allocate_Memory_And_Rewind(void);
-char *ReadDataBytes(char *p);
-void ParseOptions(int argc, char *argv[]);
+void Allocate_Memory_And_Rewind(void);
+char *ReadDataBytes(char *p);
+void ParseOptions(int argc, char *argv[]);
--- hex2bin/Makefile 2023-05-21 01:35:20.703216149 +0100
+++ hex2bin.new/Makefile 2023-05-21 01:24:17.624252702 +0100
@@ -32,7 +32,7 @@
# Linux uses:
#MAN_DIR = $(INSTALL_DIR)/man/man1
# Cygwin uses:
-MAN_DIR = /usr/man/man1
+MAN_DIR = /usr/share/man/man1
all: hex2bin mot2bin hex2bin.1
@ryu10
Copy link
Author

ryu10 commented May 21, 2023

A patch to build hex2bin on Raspberry Pi OS.
Root cause: as discussed on this forum.

How to apply:

Save this gist as h2b.patch. Then:

git clone https://github.com/E3V3A/hex2bin.git
cd hex2bin
git checkout 03cbdd67fcd0
patch -p1 < ../h2b.patch
make
sudo make install

Verified on: Linux raspberry pi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment