Make bootloader 1 work

This commit is contained in:
optixx 2016-08-20 18:13:08 +02:00
parent f8bd7384b5
commit a1e3ef36b4
14 changed files with 1997 additions and 3066 deletions

View File

@ -16,15 +16,15 @@
# Author: Christian Starkjohann
# =====================================================================================
DEBUG = 0
DEBUG = 1
TTY = /dev/tty.PL2303-00002126
DEVICE = atmega644
F_CPU = 20000000
TARGET = main
AVRDUDE = avrdude -c usbasp -p $(DEVICE)
SIZE = avr-size
BOOT_LOADER = 2
BOOT_COMPRESS = fastlz
BOOT_LOADER = 1
BOOT_COMPRESS = rle
BOOT_ROM01 = ../../roms/qd16boot_ver01.smc
BOOT_ROM02 = ../../roms/qd16boot_ver02.smc
@ -34,9 +34,9 @@ ifeq ($(DEBUG),1)
LDFLAGS =-Wl,-u,vfprintf
CFLAGS =-Iusbdrv -I. -DDEBUG_LEVEL=0
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o \
main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o \
dump.o timer.o watchdog.o loader.o info.o shared_memory.o \
system.o pwm.o util.o shell.o irq.o command.o testing.o
main.o usb_bulk.o uart.o fifo.o sram.o debug.o \
dump.o timer.o watchdog.o loader.o info.o shared_memory.o crc.o \
system.o pwm.o util.o shell.o irq.o command.o
else
BOOT_DEBUG = nodebug
LDFLAGS =

View File

@ -46,13 +46,13 @@
#define FORMAT_BUFFER_LEN 0x080
#define RECEIVE_BUF_LEN 0x030
#define HW_VERSION "2.6"
#define SW_VERSION "1.1"
#define SW_VERSION "1.2"
#define DO_CRC_CHECK_LOADER 0
#define DO_CRC_CHECK 0
#define DO_CRC_CHECK 1
#define DO_SHM_SCRATCHPAD 0
#define DO_SHM 0
#define DO_TIMER 0
#define DO_TIMER 1
#define DO_SHELL 1
#endif

View File

@ -52,7 +52,6 @@ int fastlz_decompress(const void* input, int length, void* output);
#define OUTPUT_INC_FROM_REFINC() do { \
__dist = (output_index-ref_index); \
__c = buffer_get(ref_buffer_ptr, __dist); \
info_P(PSTR("output_index=%i ref_index=%i(%x) dist=%i(%x) buf->end=%i buf->size=%i position=%i\n"), output_index, ref_index, __c, __dist, __c, ref_buffer_ptr->end, ref_buffer_ptr->size, __mod(ref_buffer_ptr->end - __dist, ref_buffer_ptr->size)); \
sram_bulk_write(__c);\
sram_bulk_write_next();\
output_index++;\
@ -121,7 +120,7 @@ int fastlz_decompress2(unsigned char* input1, unsigned char* input2, int length)
ref_index = output_index;
flzuint32 len = ctrl >> 5;
flzuint32 ofs = (ctrl & 31) << 6;
log2(1)
//log2(1)
if(ctrl >= 32)
{
len--;
@ -135,7 +134,7 @@ int fastlz_decompress2(unsigned char* input1, unsigned char* input2, int length)
ref_index -= tmp;
//ref_index -= input[input_index++];
log2(1)
//log2(1)
if(FASTLZ_EXPECT_CONDITIONAL( input_index < ip_limit))
INPUT_INC(ctrl);
@ -143,11 +142,11 @@ int fastlz_decompress2(unsigned char* input1, unsigned char* input2, int length)
else
loop = 0;
log2(1)
//log2(1)
if(ref_index == output_index)
{
log2(2)
//log2(2)
//flzuint8 b = output[ref_index-1];
flzuint8 b;
FROM_REF(b);
@ -161,7 +160,7 @@ int fastlz_decompress2(unsigned char* input1, unsigned char* input2, int length)
}
else
{
log2(3)
//log2(3)
ref_index--;
OUTPUT_INC_FROM_REFINC();
OUTPUT_INC_FROM_REFINC();
@ -173,12 +172,12 @@ int fastlz_decompress2(unsigned char* input1, unsigned char* input2, int length)
else
{
ctrl++;
log2(4)
//log2(4)
INPUT_INC(tmp);
OUTPUT_INC(tmp);
//OUTPUT_INC(input[input_index++]);
for(--ctrl; ctrl; ctrl--){
log2(5)
//log2(5)
INPUT_INC(tmp);
OUTPUT_INC(tmp);
//OUTPUT_INC(input[input_index++]);
@ -189,7 +188,7 @@ int fastlz_decompress2(unsigned char* input1, unsigned char* input2, int length)
INPUT_INC(ctrl);
//ctrl = input[input_index++];
}
log2(6)
//log2(6)
}
}
while(FASTLZ_EXPECT_CONDITIONAL(loop));

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,15 @@
/*
File: qd16boot_ver02.smc
Time: Sun, 07 Aug 2016 20:21:45
File: qd16boot_ver01.smc
Time: Sat, 20 Aug 2016 18:12:14
*/
#ifndef __FIFO_H__
#define __FIFO_H__
#define LOADER_NAME "qd16boot_ver02.smc"
#define LOADER_COMPRESS "FASTLZ"
#define ROM_FASTLZ_SIZE 48271
#define ROM_BUFFER_CNT 2
#define LOADER_NAME "qd16boot_ver01.smc"
#define LOADER_COMPRESS "RLE"
#define ROM_RLE_SIZE 31091
#define ROM_BUFFER_CNT 1
#define ROM_BUFFER_SIZE01 32767
#define ROM_BUFFER_SIZE02 15504
#define ROM_BUFFER_SIZE01 31091
#endif

View File

@ -19,7 +19,6 @@
*/
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdlib.h>
@ -198,8 +197,10 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
usb_trans.req_addr = usb_trans.req_addr | rq->wIndex.word;
debug_P(DEBUG_USB, PSTR("USB_CRC: addr=0x%08lx \n"),
usb_trans.req_addr);
#if DO_CRC_CHECK
crc_check_bulk_memory(0x000000, usb_trans.req_addr,
usb_trans.req_bank_size);
#endif
ret_len = 0;
/*
* -------------------------------------------------------------------------

View File

@ -199,7 +199,9 @@ enum cmds {
CMD_DUMP,
CMD_DUMPVEC,
CMD_DUMPHEADER,
#if DO_CRC_CHECK
CMD_CRC,
#endif
CMD_EXIT,
CMD_RESET,
CMD_RESETSNIFF,
@ -223,7 +225,9 @@ const uint8_t cmdlist[][CMD_HELP] PROGMEM = {
{"DUMP"},
{"DUMPVEC"},
{"DUMPHEADER"},
#if DO_CRC_CHECK
{"CRC"},
#endif
{"EXIT"},
{"RESET"},
{"RESETSNIFF"},
@ -284,12 +288,14 @@ void shell_run(void)
else
info_P(PSTR("DUMP <start addr> <end addr>\n"));
#if DO_CRC_CHECK
} else if (strcmp_P((char *) t, (PGM_P) cmdlist[CMD_CRC]) == 0) {
if (get_hex_arg2(&arg1, &arg2)) {
crc = crc_check_bulk_memory(arg1, arg2, 0x8000);
info_P(PSTR("0x%06lx - 0x%06lx crc=0x%04x\n"), arg1, arg2, crc);
} else
info_P(PSTR("CRC <start addr> <end addr>\n"));
#endif
} else if (strcmp_P((char *) t, (PGM_P) cmdlist[CMD_EXIT]) == 0) {
leave_application();
} else if (strcmp_P((char *) t, (PGM_P) cmdlist[CMD_RESET]) == 0) {
@ -344,17 +350,17 @@ void shell_run(void)
else
offset = 0x0000;
info_P(PSTR("ABORT 0x%04x 0x%04x\n"), (0xFFE8 - offset),
info_P(PSTR("ABORT 0x%04x 0x%04x\n"), (0xFFE8 - offset),
sram_read16_be(0xFFE8 - offset));
info_P(PSTR("BRK 0x%04x 0x%04x\n"), (0xFFE6 - offset),
info_P(PSTR("BRK 0x%04x 0x%04x\n"), (0xFFE6 - offset),
sram_read16_be(0xFFE6 - offset));
info_P(PSTR("COP 0x%04x 0x%04x\n"), (0xFFE4 - offset),
info_P(PSTR("COP 0x%04x 0x%04x\n"), (0xFFE4 - offset),
sram_read16_be(0xFFE4 - offset));
info_P(PSTR("IRQ 0x%04x 0x%04x\n"), (0xFFEE - offset),
info_P(PSTR("IRQ 0x%04x 0x%04x\n"), (0xFFEE - offset),
sram_read16_be(0xFFEE - offset));
info_P(PSTR("NMI 0x%04x 0x%04x\n"), (0xFFEA - offset),
info_P(PSTR("NMI 0x%04x 0x%04x\n"), (0xFFEA - offset),
sram_read16_be(0xFFEA - offset));
info_P(PSTR("RES 0x%04x 0x%04x\n"), (0xFFFC - offset),
info_P(PSTR("RES 0x%04x 0x%04x\n"), (0xFFFC - offset),
sram_read16_be(0xFFFC - offset));
} else if (strcmp_P((char *) t, (PGM_P) cmdlist[CMD_DUMPHEADER]) == 0) {
@ -372,7 +378,7 @@ void shell_run(void)
* $00. # $ffdc..$ffdd => Checksum complement, which is the bitwise-xor of the checksum and $ffff. # $ffde..$ffdf => SNES checksum,
* an unsigned 16-bit checksum of bytes. # $ffe0..$ffe3 => Unknown.
*/
info_P(PSTR("NAME 0x%04x "), (0xffc0 - offset));
info_P(PSTR("NAME 0x%04x "), (0xffc0 - offset));
for (arg1 = (0xffc0 - offset); arg1 < (0xffc0 - offset + 21); arg1++) {
c = sram_read(arg1);
if (c > 0x1f && c < 0x7f)
@ -380,7 +386,7 @@ void shell_run(void)
}
printf("\n");
c = sram_read(0xffd5 - offset);
info_P(PSTR("LAYOUT 0x%04x "), (0xffd5 - offset));
info_P(PSTR("LAYOUT 0x%04x "), (0xffd5 - offset));
switch (c) {
case 0x20:
@ -401,7 +407,7 @@ void shell_run(void)
}
c = sram_read(0xffd6 - offset);
info_P(PSTR("TYPE 0x%04xc"), (0xffd6 - offset), c);
info_P(PSTR("TYPE 0x%04xc"), (0xffd6 - offset), c);
switch (c) {
case 0x00:
info_P(PSTR("Rom\n"));
@ -435,12 +441,12 @@ void shell_run(void)
break;
}
arg1 = (2 << (sram_read(0xffd7 - offset) - 1));
info_P(PSTR("ROM 0x%04x %li MBit ( %li KiB)\n"),
info_P(PSTR("ROM 0x%04x %li MBit ( %li KiB)\n"),
(0xffd7 - offset), (arg1 / 128), arg1);
arg1 = (2 << (sram_read(0xffd8 - offset) - 1));
info_P(PSTR("RAM 0x%04x %li KiB\n"), (0xffd8 - offset), arg1);
info_P(PSTR("RAM 0x%04x %li KiB\n"), (0xffd8 - offset), arg1);
info_P(PSTR("CCODE 0x%04x "), (0xffd9 - offset));
info_P(PSTR("CCODE 0x%04x "), (0xffd9 - offset));
c = sram_read(0xffd9 - offset);
if (c == 0x00 || c == 0x01 || 0x0d)
info_P(PSTR("NTSC\n"));
@ -449,13 +455,13 @@ void shell_run(void)
else
info_P(PSTR("Unkown 0x%02x\n"), c);
info_P(PSTR("LIC 0x%04x 0x%02x\n"), (0xffda - offset),
info_P(PSTR("LIC 0x%04x 0x%02x\n"), (0xffda - offset),
sram_read(0xffda - offset));
info_P(PSTR("VER 0x%04x 0x%02x\n"), (0xffdb - offset),
info_P(PSTR("VER 0x%04x 0x%02x\n"), (0xffdb - offset),
sram_read(0xffdb - offset));
info_P(PSTR("SUM1 0x%04x 0x%04x\n"), (0xffdc - offset),
info_P(PSTR("SUM1 0x%04x 0x%04x\n"), (0xffdc - offset),
sram_read16_be(0xffdc - offset));
info_P(PSTR("SUM2 0x%04x 0x%04x\n"), (0xffde - offset),
info_P(PSTR("SUM2 0x%04x 0x%04x\n"), (0xffde - offset),
sram_read16_be(0xffde - offset));

View File

@ -104,7 +104,7 @@
/* #undef USE_PPDEV */
/* build with (lib)usb support (default: no) */
/* #undef USE_USB */
#define USE_USB 1
/* build with gzip and zip support (default: yes) */
#define USE_ZLIB 1

View File

@ -1,7 +1,7 @@
DLOPEN=1
USE_ZLIB=1
USE_DISCMAGE=1
USE_USB=1
CC=gcc

View File

@ -300,7 +300,7 @@ Report bugs to <bug-autoconf@gnu.org>."
ac_cs_version="\
uCON64 config.status 2.0.2
configured by ./configure, generated by GNU Autoconf 2.59,
with options \"'--with-libusb'\"
with options \"'--with-libusb' 'CFLAGS=-I/usr/local/Cellar/libusb-compat/0.1.5/include' 'LDFLAGS=-L/usr/local/Cellar/libusb-compat/0.1.5/lib -lusb'\"
Copyright (C) 2003 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
@ -379,8 +379,8 @@ if $ac_cs_silent; then
fi
if $ac_cs_recheck; then
echo "running /bin/sh ./configure " '--with-libusb' $ac_configure_extra_args " --no-create --no-recursion" >&6
exec /bin/sh ./configure '--with-libusb' $ac_configure_extra_args --no-create --no-recursion
echo "running /bin/sh ./configure " '--with-libusb' 'CFLAGS=-I/usr/local/Cellar/libusb-compat/0.1.5/include' 'LDFLAGS=-L/usr/local/Cellar/libusb-compat/0.1.5/lib -lusb' $ac_configure_extra_args " --no-create --no-recursion" >&6
exec /bin/sh ./configure '--with-libusb' 'CFLAGS=-I/usr/local/Cellar/libusb-compat/0.1.5/include' 'LDFLAGS=-L/usr/local/Cellar/libusb-compat/0.1.5/lib -lusb' $ac_configure_extra_args --no-create --no-recursion
fi
for ac_config_target in $ac_config_targets
@ -473,8 +473,8 @@ s,@ECHO_N@,,;t t
s,@ECHO_T@,,;t t
s,@LIBS@,,;t t
s,@CC@,gcc,;t t
s,@CFLAGS@,-g -O2,;t t
s,@LDFLAGS@,,;t t
s,@CFLAGS@,-I/usr/local/Cellar/libusb-compat/0.1.5/include,;t t
s,@LDFLAGS@,-L/usr/local/Cellar/libusb-compat/0.1.5/lib -lusb,;t t
s,@CPPFLAGS@,,;t t
s,@ac_ct_CC@,gcc,;t t
s,@EXEEXT@,,;t t
@ -486,7 +486,7 @@ s,@DEFINE_DISCMAGE_MAKE@,USE_DISCMAGE=1,;t t
s,@DEFINE_LIBCD64_MAKE@,,;t t
s,@LIBI386_MAKE@,-li386,;t t
s,@DEFINE_ZLIB_MAKE@,USE_ZLIB=1,;t t
s,@DEFINE_USB_MAKE@,,;t t
s,@DEFINE_USB_MAKE@,USE_USB=1,;t t
s,@LIBOBJS@,,;t t
s,@RANLIB@,ranlib,;t t
s,@ac_ct_RANLIB@,ranlib,;t t
@ -813,6 +813,7 @@ ${ac_dA}USE_ANSI_COLOR${ac_dB}USE_ANSI_COLOR${ac_dC}1${ac_dD}
${ac_dA}DLOPEN${ac_dB}DLOPEN${ac_dC}1${ac_dD}
${ac_dA}USE_DISCMAGE${ac_dB}USE_DISCMAGE${ac_dC}1${ac_dD}
${ac_dA}USE_ZLIB${ac_dB}USE_ZLIB${ac_dC}1${ac_dD}
${ac_dA}USE_USB${ac_dB}USE_USB${ac_dC}1${ac_dD}
${ac_dA}HAVE_DIRENT_H${ac_dB}HAVE_DIRENT_H${ac_dC}1${ac_dD}
${ac_dA}STDC_HEADERS${ac_dB}STDC_HEADERS${ac_dC}1${ac_dD}
${ac_dA}HAVE_SYS_TYPES_H${ac_dB}HAVE_SYS_TYPES_H${ac_dC}1${ac_dD}
@ -852,6 +853,7 @@ ${ac_uA}USE_ANSI_COLOR${ac_uB}USE_ANSI_COLOR${ac_uC}1${ac_uD}
${ac_uA}DLOPEN${ac_uB}DLOPEN${ac_uC}1${ac_uD}
${ac_uA}USE_DISCMAGE${ac_uB}USE_DISCMAGE${ac_uC}1${ac_uD}
${ac_uA}USE_ZLIB${ac_uB}USE_ZLIB${ac_uC}1${ac_uD}
${ac_uA}USE_USB${ac_uB}USE_USB${ac_uC}1${ac_uD}
${ac_uA}HAVE_DIRENT_H${ac_uB}HAVE_DIRENT_H${ac_uC}1${ac_uD}
${ac_uA}STDC_HEADERS${ac_uB}STDC_HEADERS${ac_uC}1${ac_uD}
${ac_uA}HAVE_SYS_TYPES_H${ac_uB}HAVE_SYS_TYPES_H${ac_uC}1${ac_uD}

Binary file not shown.