Skip to content

Commit

Permalink
added verify via CRC32 checksum
Browse files Browse the repository at this point in the history
- support re-synchronization after return from RAM routine
- add option verify via CRC32 checksum (see issue #20)
- add parameter to verify option for new CRC32 check
  • Loading branch information
gicking committed Dec 26, 2020
1 parent 75ddbc6 commit 7cd542c
Show file tree
Hide file tree
Showing 17 changed files with 1,068 additions and 85 deletions.
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Project: stm8gal

CC = gcc
CFLAGS = -c -Wall -I./STM8_Routines
CFLAGS = -c -Wall -I./RAM_Routines
#CFLAGS += -DDEBUG
LDFLAGS = -g3 -lm
SOURCES = bootloader.c hexfile.c main.c misc.c serial_comm.c spi_Arduino_comm.c
INCLUDES = misc.h bootloader.h hexfile.h serial_comm.h spi_spidev_comm.h spi_Arduino_comm.h main.h
STM8FLASH = STM8_Routines/E_W_ROUTINEs_128K_ver_2.1.s19 STM8_Routines/E_W_ROUTINEs_128K_ver_2.0.s19 STM8_Routines/E_W_ROUTINEs_256K_ver_1.0.s19 STM8_Routines/E_W_ROUTINEs_32K_ver_1.3.s19 STM8_Routines/E_W_ROUTINEs_32K_ver_1.4.s19 STM8_Routines/E_W_ROUTINEs_128K_ver_2.2.s19 STM8_Routines/E_W_ROUTINEs_32K_ver_1.0.s19 STM8_Routines/E_W_ROUTINEs_128K_ver_2.4.s19 STM8_Routines/E_W_ROUTINEs_32K_ver_1.2.s19 STM8_Routines/E_W_ROUTINEs_32K_verL_1.0.s19 STM8_Routines/E_W_ROUTINEs_8K_verL_1.0.s19
STM8INCLUDES = $(STM8FLASH:.s19=.h)
SOURCES = bootloader.c hexfile.c main.c misc.c serial_comm.c spi_Arduino_comm.c verify_CRC32.c
INCLUDES = misc.h bootloader.h hexfile.h serial_comm.h spi_spidev_comm.h spi_Arduino_comm.h verify_CRC32.h main.h
RAMROUTINES = RAM_Routines/E_W_ROUTINEs_128K_ver_2.1.s19 RAM_Routines/E_W_ROUTINEs_128K_ver_2.0.s19 RAM_Routines/E_W_ROUTINEs_256K_ver_1.0.s19 RAM_Routines/E_W_ROUTINEs_32K_ver_1.3.s19 RAM_Routines/E_W_ROUTINEs_32K_ver_1.4.s19 RAM_Routines/E_W_ROUTINEs_128K_ver_2.2.s19 RAM_Routines/E_W_ROUTINEs_32K_ver_1.0.s19 RAM_Routines/E_W_ROUTINEs_128K_ver_2.4.s19 RAM_Routines/E_W_ROUTINEs_32K_ver_1.2.s19 RAM_Routines/E_W_ROUTINEs_32K_verL_1.0.s19 RAM_Routines/E_W_ROUTINEs_8K_verL_1.0.s19
RAMINCLUDES = $(RAMROUTINES:.s19=.h)
OBJDIR = Objects
OBJECTS = $(patsubst %.c, $(OBJDIR)/%.o, $(SOURCES))
BIN = stm8gal
Expand All @@ -17,7 +17,7 @@ RM = rm -fr
#CFLAGS += -DUSE_SPIDEV
#SOURCES += spi_spidev_comm.c

# add optional GPIO reset via wiringPi library (Raspberry only)
# add optional GPIO reset via wiringPi library (Raspberry only)
#CFLAGS += -DUSE_WIRING
#LDFLAGS += -lwiringPi

Expand All @@ -28,21 +28,21 @@ RM = rm -fr

default: $(BIN) $(OBJDIR)

all: $(STM8INCLUDES) $(SOURCES) $(BIN)
all: $(RAMINCLUDES) $(SOURCES) $(BIN)

$(OBJDIR):
mkdir -p $(OBJDIR)

clean:
${RM} $(OBJECTS) $(OBJDIR) $(BIN) $(BIN).exe *~ .DS_Store
%.h: %.s19 $(STM8FLASH)
${RM} $(OBJECTS) $(OBJDIR) $(BIN) $(BIN).exe *~ .DS_Store

%.h: %.s19 $(RAMROUTINES)
xxd -i $< > $@

# link application
$(BIN): $(OBJECTS) $(OBJDIR)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@

# compile all *c files
$(OBJDIR)/%.o: %.c $(SOURCES) $(INCLUDES) $(STM8INCLUDES) $(OBJDIR)
$(OBJDIR)/%.o: %.c $(SOURCES) $(INCLUDES) $(RAMINCLUDES) $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@
57 changes: 57 additions & 0 deletions RAM_Routines/verify_CRC32_ihx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
unsigned char bin_verify_CRC32_ihx[] = {
0x3a, 0x32, 0x30, 0x30, 0x32, 0x30, 0x30, 0x30, 0x30, 0x38, 0x38, 0x43,
0x45, 0x30, 0x33, 0x35, 0x36, 0x43, 0x33, 0x30, 0x33, 0x35, 0x32, 0x43,
0x36, 0x30, 0x33, 0x35, 0x35, 0x43, 0x32, 0x30, 0x33, 0x35, 0x31, 0x43,
0x36, 0x30, 0x33, 0x35, 0x34, 0x43, 0x32, 0x30, 0x33, 0x35, 0x30, 0x32,
0x35, 0x31, 0x31, 0x41, 0x45, 0x37, 0x46, 0x46, 0x46, 0x43, 0x33, 0x30,
0x33, 0x35, 0x36, 0x41, 0x36, 0x30, 0x32, 0x43, 0x32, 0x30, 0x33, 0x35,
0x35, 0x37, 0x31, 0x0a, 0x3a, 0x32, 0x30, 0x30, 0x32, 0x32, 0x30, 0x30,
0x30, 0x34, 0x46, 0x43, 0x32, 0x30, 0x33, 0x35, 0x34, 0x32, 0x34, 0x30,
0x45, 0x35, 0x46, 0x43, 0x46, 0x30, 0x33, 0x35, 0x42, 0x43, 0x46, 0x30,
0x33, 0x35, 0x39, 0x33, 0x35, 0x30, 0x31, 0x30, 0x33, 0x35, 0x38, 0x43,
0x43, 0x30, 0x32, 0x43, 0x33, 0x43, 0x36, 0x35, 0x30, 0x43, 0x36, 0x36,
0x42, 0x30, 0x31, 0x33, 0x35, 0x30, 0x30, 0x35, 0x30, 0x43, 0x36, 0x41,
0x45, 0x46, 0x46, 0x46, 0x46, 0x30, 0x43, 0x0a, 0x3a, 0x32, 0x30, 0x30,
0x32, 0x34, 0x30, 0x30, 0x30, 0x43, 0x46, 0x30, 0x33, 0x35, 0x42, 0x41,
0x45, 0x46, 0x46, 0x46, 0x46, 0x43, 0x46, 0x30, 0x33, 0x35, 0x39, 0x43,
0x45, 0x30, 0x33, 0x35, 0x36, 0x43, 0x33, 0x30, 0x33, 0x35, 0x32, 0x43,
0x36, 0x30, 0x33, 0x35, 0x35, 0x43, 0x32, 0x30, 0x33, 0x35, 0x31, 0x43,
0x36, 0x30, 0x33, 0x35, 0x34, 0x43, 0x32, 0x30, 0x33, 0x35, 0x30, 0x32,
0x35, 0x33, 0x46, 0x38, 0x38, 0x39, 0x32, 0x42, 0x43, 0x42, 0x42, 0x0a,
0x3a, 0x32, 0x30, 0x30, 0x32, 0x36, 0x30, 0x30, 0x30, 0x30, 0x33, 0x35,
0x31, 0x43, 0x37, 0x30, 0x33, 0x35, 0x38, 0x38, 0x34, 0x33, 0x42, 0x30,
0x33, 0x35, 0x38, 0x43, 0x45, 0x30, 0x33, 0x35, 0x42, 0x38, 0x39, 0x43,
0x45, 0x30, 0x33, 0x35, 0x39, 0x38, 0x39, 0x43, 0x44, 0x30, 0x32, 0x45,
0x32, 0x35, 0x42, 0x30, 0x35, 0x43, 0x46, 0x30, 0x33, 0x35, 0x42, 0x39,
0x30, 0x43, 0x46, 0x30, 0x33, 0x35, 0x39, 0x43, 0x45, 0x30, 0x33, 0x35,
0x32, 0x36, 0x41, 0x0a, 0x3a, 0x32, 0x30, 0x30, 0x32, 0x38, 0x30, 0x30,
0x30, 0x31, 0x43, 0x30, 0x30, 0x30, 0x31, 0x39, 0x30, 0x43, 0x45, 0x30,
0x33, 0x35, 0x30, 0x32, 0x34, 0x30, 0x32, 0x39, 0x30, 0x35, 0x43, 0x43,
0x46, 0x30, 0x33, 0x35, 0x32, 0x39, 0x30, 0x43, 0x46, 0x30, 0x33, 0x35,
0x30, 0x33, 0x35, 0x41, 0x41, 0x35, 0x30, 0x45, 0x30, 0x33, 0x35, 0x37,
0x46, 0x35, 0x30, 0x44, 0x31, 0x32, 0x30, 0x41, 0x44, 0x43, 0x36, 0x30,
0x33, 0x35, 0x43, 0x34, 0x33, 0x38, 0x46, 0x0a, 0x3a, 0x32, 0x30, 0x30,
0x32, 0x41, 0x30, 0x30, 0x30, 0x39, 0x37, 0x43, 0x36, 0x30, 0x33, 0x35,
0x42, 0x34, 0x33, 0x39, 0x35, 0x43, 0x36, 0x30, 0x33, 0x35, 0x41, 0x34,
0x33, 0x39, 0x30, 0x39, 0x37, 0x43, 0x36, 0x30, 0x33, 0x35, 0x39, 0x34,
0x33, 0x39, 0x30, 0x39, 0x35, 0x43, 0x46, 0x30, 0x33, 0x35, 0x42, 0x39,
0x30, 0x43, 0x46, 0x30, 0x33, 0x35, 0x39, 0x37, 0x32, 0x35, 0x46, 0x30,
0x33, 0x35, 0x38, 0x41, 0x45, 0x35, 0x30, 0x43, 0x36, 0x42, 0x43, 0x0a,
0x3a, 0x32, 0x30, 0x30, 0x32, 0x43, 0x30, 0x30, 0x30, 0x37, 0x42, 0x30,
0x31, 0x46, 0x37, 0x33, 0x35, 0x30, 0x31, 0x35, 0x33, 0x30, 0x34, 0x43,
0x36, 0x35, 0x33, 0x30, 0x32, 0x33, 0x35, 0x30, 0x30, 0x35, 0x33, 0x30,
0x32, 0x33, 0x35, 0x30, 0x31, 0x35, 0x33, 0x32, 0x34, 0x43, 0x36, 0x35,
0x33, 0x32, 0x32, 0x33, 0x35, 0x30, 0x30, 0x35, 0x33, 0x32, 0x32, 0x37,
0x32, 0x35, 0x46, 0x30, 0x30, 0x39, 0x39, 0x43, 0x43, 0x36, 0x30, 0x32,
0x45, 0x32, 0x33, 0x0a, 0x3a, 0x32, 0x30, 0x30, 0x32, 0x45, 0x30, 0x30,
0x30, 0x38, 0x34, 0x38, 0x31, 0x37, 0x42, 0x30, 0x37, 0x31, 0x38, 0x30,
0x36, 0x36, 0x42, 0x30, 0x36, 0x31, 0x45, 0x30, 0x35, 0x31, 0x36, 0x30,
0x33, 0x41, 0x36, 0x30, 0x38, 0x39, 0x30, 0x35, 0x34, 0x35, 0x36, 0x32,
0x34, 0x31, 0x31, 0x30, 0x31, 0x41, 0x38, 0x32, 0x30, 0x30, 0x31, 0x41,
0x38, 0x38, 0x33, 0x30, 0x31, 0x39, 0x30, 0x30, 0x31, 0x41, 0x38, 0x42,
0x38, 0x39, 0x30, 0x30, 0x31, 0x31, 0x37, 0x0a, 0x3a, 0x30, 0x38, 0x30,
0x33, 0x30, 0x30, 0x30, 0x30, 0x41, 0x38, 0x45, 0x44, 0x39, 0x30, 0x30,
0x31, 0x34, 0x41, 0x32, 0x36, 0x45, 0x37, 0x38, 0x31, 0x46, 0x37, 0x0a,
0x3a, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x46, 0x46, 0x0a
};
unsigned int bin_verify_CRC32_ihx_len = 648;
Loading

0 comments on commit 7cd542c

Please sign in to comment.