add multipart rom array's
This commit is contained in:
parent
f027b93a1a
commit
13c71760c8
@ -16,19 +16,19 @@
|
||||
# Author: Christian Starkjohann
|
||||
# =====================================================================================
|
||||
|
||||
DEBUG = 1
|
||||
DEBUG = 0
|
||||
TTY = /dev/tty.PL2303-00002126
|
||||
DEVICE = atmega644
|
||||
F_CPU = 20000000 # in Hz
|
||||
F_CPU = 20000000
|
||||
TARGET = main
|
||||
AVRDUDE = avrdude -c usbasp -p $(DEVICE)
|
||||
SIZE = avr-size
|
||||
LOADER = ../../roms/qd16boot02.smc
|
||||
LOADER = ../../roms/qd16boot01.smc
|
||||
ROM_CONVERT = ../../scripts/conv_rle.py
|
||||
|
||||
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
ifeq ($(DEBUG),0)
|
||||
LDFLAGS =-Wl,-u,vfprintf -lprintf_flt
|
||||
CFLAGS =-Iusbdrv -I. -DDEBUG_LEVEL=0
|
||||
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o \
|
||||
@ -39,8 +39,8 @@ else
|
||||
LDFLAGS =-Wl,-u
|
||||
CFLAGS =-Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG -DNO_INFO
|
||||
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 rle.c loader.o \
|
||||
system.o pwm.o util.o shell.o info.o shared_memory.o command.o irq.o
|
||||
sram.o crc.o debug.o dump.o watchdog.o rle.c loader.o \
|
||||
system.o util.o info.o shared_memory.o command.o irq.o
|
||||
endif
|
||||
|
||||
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
|
||||
|
||||
@ -34,7 +34,9 @@
|
||||
|
||||
extern usb_transaction_t usb_trans;
|
||||
|
||||
extern const char _rom[] PROGMEM;
|
||||
extern const char *_rom[];
|
||||
extern const char _rom01[];
|
||||
extern const int _rom_size[];
|
||||
|
||||
void usb_connect()
|
||||
{
|
||||
@ -89,6 +91,8 @@ void set_rom_mode()
|
||||
|
||||
void boot_startup_rom(uint16_t init_delay)
|
||||
{
|
||||
uint8_t i;
|
||||
uint32_t addr = 0x000000;
|
||||
info_P(PSTR("Fetch loader rom\n"));
|
||||
info_P(PSTR("Activate AVR bus\n"));
|
||||
avr_bus_active();
|
||||
@ -96,7 +100,9 @@ void boot_startup_rom(uint16_t init_delay)
|
||||
snes_irq_lo();
|
||||
snes_irq_off();
|
||||
snes_lorom();
|
||||
rle_decode(&_rom, ROM_BUFFER_SIZE, 0x000000);
|
||||
for (i=0; i<ROM_BUFFER_CNT; i++){
|
||||
addr += rle_decode(_rom[i], _rom_size[i], addr);
|
||||
}
|
||||
info_P(PSTR("\n"));
|
||||
|
||||
#if DO_CRC_CHECK_LOADER
|
||||
|
||||
5518
avr/usbload/loader.c
5518
avr/usbload/loader.c
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,14 @@
|
||||
/*
|
||||
File: qd16boot02.smc
|
||||
Time: Fri, 16 Oct 2009 07:51:04
|
||||
File: qd16boot01.smc
|
||||
Time: Sat, 17 Oct 2009 16:28:09
|
||||
*/
|
||||
#ifndef __FIFO_H__
|
||||
#define __FIFO_H__
|
||||
|
||||
#define ROM_BUFFER_SIZE 58046
|
||||
#define ROM_HUFFMAN_SIZE 0
|
||||
#define ROM_RLE_SIZE 58046
|
||||
#define ROM_RLE_SIZE 31091
|
||||
#define ROM_BUFFER_CNT 1
|
||||
|
||||
#define ROM_BUFFER_SIZE01 31091
|
||||
|
||||
#endif
|
||||
|
||||
@ -52,8 +52,10 @@
|
||||
#include "system.h"
|
||||
|
||||
|
||||
|
||||
#ifndef NO_DEBUG
|
||||
extern FILE uart_stdout;
|
||||
#endif
|
||||
|
||||
extern system_t system;
|
||||
|
||||
uint8_t debug_level = (DEBUG | DEBUG_USB | DEBUG_CRC | DEBUG_SHM );
|
||||
@ -87,7 +89,9 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
shared_memory_write(SHARED_MEM_TX_CMD_BANK_COUNT, usb_trans.req_bank_cnt);
|
||||
#if DO_TIMER
|
||||
if (usb_trans.req_addr == 0x000000) {
|
||||
#ifndef NO_DEBUG
|
||||
timer_start();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
@ -105,7 +109,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
|
||||
if (usb_trans.req_addr && usb_trans.req_addr % usb_trans.req_bank_size == 0) {
|
||||
#if DO_TIMER
|
||||
|
||||
#ifndef NO_DEBUG
|
||||
#ifdef FLT_DEBUG
|
||||
debug_P(DEBUG_USB,
|
||||
PSTR("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
|
||||
@ -116,6 +120,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
usb_trans.req_bank, usb_trans.req_addr, timer_stop_int());
|
||||
#endif
|
||||
timer_start();
|
||||
#endif
|
||||
#endif
|
||||
usb_trans.req_bank++;
|
||||
|
||||
@ -144,7 +149,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
#endif
|
||||
if (usb_trans.req_addr && (usb_trans.req_addr % usb_trans.req_bank_size) == 0) {
|
||||
#if DO_TIMER
|
||||
|
||||
#ifndef NO_DEBUG
|
||||
#ifdef FLT_DEBUG
|
||||
debug_P(DEBUG_USB,
|
||||
PSTR("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
|
||||
@ -155,6 +160,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
usb_trans.req_bank, usb_trans.req_addr, timer_stop_int());
|
||||
#endif
|
||||
timer_start();
|
||||
#endif
|
||||
#endif
|
||||
usb_trans.req_bank++;
|
||||
#if DO_SHM
|
||||
@ -242,19 +248,27 @@ void globals_init(){
|
||||
int main(void)
|
||||
{
|
||||
|
||||
#ifndef NO_DEBUG
|
||||
uart_init();
|
||||
stdout = &uart_stdout;
|
||||
#endif
|
||||
banner();
|
||||
shared_memory_init();
|
||||
system_init();
|
||||
sram_init();
|
||||
|
||||
#ifndef NO_DEBUG
|
||||
pwm_init();
|
||||
#endif
|
||||
irq_init();
|
||||
|
||||
boot_startup_rom(50);
|
||||
|
||||
globals_init();
|
||||
|
||||
#ifndef NO_DEBUG
|
||||
pwm_stop();
|
||||
#endif
|
||||
|
||||
usbInit();
|
||||
usb_connect();
|
||||
@ -269,7 +283,9 @@ int main(void)
|
||||
info_P(PSTR("USB poll\n"));
|
||||
while (usb_trans.req_state != REQ_STATUS_SNES) {
|
||||
usbPoll();
|
||||
#ifndef NO_DEBUG
|
||||
shell_run();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DO_SHM
|
||||
@ -297,15 +313,16 @@ int main(void)
|
||||
info_P(PSTR("Poll USB\n"));
|
||||
while ((usb_trans.req_state != REQ_STATUS_AVR)) {
|
||||
usbPoll();
|
||||
#ifndef NO_DEBUG
|
||||
shell_run();
|
||||
#endif
|
||||
}
|
||||
info_P(PSTR("-->Switch TO AVR\n"));
|
||||
shared_memory_init();
|
||||
irq_init();
|
||||
if(usb_trans.loader_enabled)
|
||||
if(usb_trans.loader_enabled) {
|
||||
boot_startup_rom(500);
|
||||
else
|
||||
{
|
||||
} else {
|
||||
avr_bus_active();
|
||||
send_reset();
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#define RUNCHAR 0x90
|
||||
|
||||
uint8_t rle_decode(PGM_VOID_P in_addr, int32_t in_len, uint32_t out_addr)
|
||||
uint32_t rle_decode(PGM_VOID_P in_addr, int32_t in_len, uint32_t out_addr)
|
||||
{
|
||||
uint8_t in_byte, in_repeat, last_byte;
|
||||
info_P(PSTR("RLE decode len=%li addr=0x%08lx\n"), in_len, out_addr);
|
||||
@ -98,5 +98,5 @@ uint8_t rle_decode(PGM_VOID_P in_addr, int32_t in_len, uint32_t out_addr)
|
||||
}
|
||||
sram_bulk_write_end();
|
||||
info_P(PSTR("\nDone addr=0x%08lx\n"), out_addr);
|
||||
return 0;
|
||||
return out_addr;
|
||||
}
|
||||
|
||||
@ -23,6 +23,6 @@
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
uint8_t rle_decode(PGM_VOID_P in_addr, uint32_t in_len, uint32_t out_addr);
|
||||
uint32_t rle_decode(PGM_VOID_P in_addr, uint32_t in_len, uint32_t out_addr);
|
||||
|
||||
#endif
|
||||
|
||||
@ -9,7 +9,7 @@ huffman = False
|
||||
TARGET=os.getcwd()
|
||||
SOURCE=sys.argv[1]
|
||||
|
||||
HUFFMAN_ENCODER="/Users/david/Devel/arch/avr/code/quickdev16/tools/huffman/huffman-encode"
|
||||
HUFFMAN_ENCODER="/Users/david/Devel/arch/avr/code/quickdev16/packages/huffman/huffman-encode"
|
||||
|
||||
data = open(SOURCE,"r").read()
|
||||
print "Load %s, %i bytes" % (SOURCE,len(data))
|
||||
@ -27,6 +27,7 @@ if huffman == True:
|
||||
binfile.close()
|
||||
|
||||
cmd = "%s /tmp/loader.rle" % HUFFMAN_ENCODER
|
||||
print cmd
|
||||
os.system(cmd)
|
||||
data = open("/tmp/loader.rle.hfm","r").read()
|
||||
print "HUFFMAN crunch (%i) bytes" % (len(data))
|
||||
@ -37,6 +38,13 @@ if huffman == True:
|
||||
cfile = open("/tmp/loader.c","w")
|
||||
hfile = open("/tmp/loader.h","w")
|
||||
|
||||
parts = []
|
||||
cnt = len(data) / ((2**15) -1 )
|
||||
r = len(data) - (cnt * ((2**15) -1))
|
||||
for i in range(0, cnt):
|
||||
parts.append(((2**15) -1 ))
|
||||
parts.append(r)
|
||||
|
||||
hfile.write('''/*
|
||||
File: %s
|
||||
Time: %s
|
||||
@ -44,26 +52,39 @@ Time: %s
|
||||
#ifndef __FIFO_H__
|
||||
#define __FIFO_H__
|
||||
|
||||
#define ROM_BUFFER_SIZE %i
|
||||
#define ROM_HUFFMAN_SIZE %i
|
||||
#define ROM_RLE_SIZE %i
|
||||
#define ROM_BUFFER_CNT %i
|
||||
|
||||
#endif
|
||||
''' % (os.path.basename(SOURCE),time.strftime("%a, %d %b %Y %H:%M:%S",
|
||||
time.localtime()),len(data), huffman_size, rle_size))
|
||||
hfile.close()
|
||||
time.localtime()), huffman_size, rle_size,len(parts)))
|
||||
|
||||
|
||||
for idx,val in enumerate(parts):
|
||||
hfile.write('#define ROM_BUFFER_SIZE%02i %i\n' % (idx+1,val))
|
||||
|
||||
|
||||
hfile.write('\n#endif\n')
|
||||
hfile.close()
|
||||
cfile.write('''/*
|
||||
File: %s
|
||||
Time: %s
|
||||
*/
|
||||
#include <avr/pgmspace.h>
|
||||
#include <loader.h>
|
||||
''')
|
||||
|
||||
const char _rom[ROM_BUFFER_SIZE] PROGMEM = {
|
||||
''' % (os.path.basename(SOURCE),time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())))
|
||||
|
||||
for idx,c in enumerate(data):
|
||||
addr = 0
|
||||
for idx,val in enumerate(parts):
|
||||
cfile.write('''
|
||||
const char _rom%02i[ROM_BUFFER_SIZE%02i] PROGMEM = {
|
||||
''' % (idx+1,idx+1))
|
||||
l = addr
|
||||
h = addr + parts[idx]
|
||||
addr+= parts[idx]
|
||||
print l,h
|
||||
for idx,c in enumerate(data[l:h]):
|
||||
c = ord(c)
|
||||
if idx<len(data)-1:
|
||||
cfile.write("0x%02x," % c)
|
||||
@ -71,9 +92,28 @@ for idx,c in enumerate(data):
|
||||
cfile.write("0x%02x" % c)
|
||||
if idx and idx%16==0:
|
||||
cfile.write("\n")
|
||||
cfile.write('''
|
||||
};
|
||||
cfile.write('''
|
||||
};
|
||||
''')
|
||||
|
||||
cfile.write('PGM_VOID_P _rom[ROM_BUFFER_CNT]= {')
|
||||
for idx,val in enumerate(parts):
|
||||
if idx<len(parts)-1:
|
||||
cfile.write('''&_rom%02i,''' % (idx+1))
|
||||
else:
|
||||
cfile.write('''&_rom%02i''' % (idx+1))
|
||||
cfile.write('''};
|
||||
''')
|
||||
|
||||
cfile.write('const int _rom_size[ROM_BUFFER_CNT] = {')
|
||||
for idx,val in enumerate(parts):
|
||||
if idx<len(parts)-1:
|
||||
cfile.write('''%i,''' % (val))
|
||||
else:
|
||||
cfile.write('''%i''' % (val))
|
||||
cfile.write('''};
|
||||
''')
|
||||
|
||||
cfile.close()
|
||||
|
||||
shutil.copy("/tmp/loader.c", os.path.join(TARGET,"loader.c"))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user