add first batch of commands to shell
This commit is contained in:
parent
105575bc37
commit
ec68a9a1a1
@ -39,7 +39,7 @@ else
|
|||||||
CFLAGS =-Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG -DNO_INFO
|
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 \
|
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 \
|
uart.o fifo.o sram.o crc.o debug.o dump.o timer.o watchdog.o rle.c loader.o \
|
||||||
pwm.o uril.o shell.o info.o shared_memory.o command.o irq.o
|
pwm.o util.o shell.o info.o shared_memory.o command.o irq.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
|
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
|
||||||
|
|||||||
@ -29,8 +29,11 @@
|
|||||||
#include "info.h"
|
#include "info.h"
|
||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
#include "usbdrv.h"
|
#include "usbdrv.h"
|
||||||
|
#include "rle.h"
|
||||||
|
#include "loader.h"
|
||||||
|
|
||||||
extern uint32_t req_bank_size;
|
extern uint32_t req_bank_size;
|
||||||
|
extern const char _rom[] PROGMEM;
|
||||||
|
|
||||||
void usb_connect()
|
void usb_connect()
|
||||||
{
|
{
|
||||||
@ -81,3 +84,54 @@ void set_rom_mode()
|
|||||||
info_P(PSTR("Set SNES hirom \n"));
|
info_P(PSTR("Set SNES hirom \n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void boot_startup_rom(uint16_t init_delay)
|
||||||
|
{
|
||||||
|
info_P(PSTR("Fetch loader rom\n"));
|
||||||
|
info_P(PSTR("Activate AVR bus\n"));
|
||||||
|
avr_bus_active();
|
||||||
|
info_P(PSTR("IRQ off\n"));
|
||||||
|
snes_irq_lo();
|
||||||
|
snes_irq_off();
|
||||||
|
snes_lorom();
|
||||||
|
rle_decode(&_rom, ROM_BUFFER_SIZE, 0x000000);
|
||||||
|
info_P(PSTR("\n"));
|
||||||
|
|
||||||
|
#if DO_CRC_CHECK_LOADER
|
||||||
|
dump_memory(0x010000 - 0x100, 0x010000);
|
||||||
|
uint16_t crc;
|
||||||
|
crc = crc_check_bulk_memory((uint32_t)0x000000,0x010000, 0x010000);
|
||||||
|
info(PSTR("crc=%x\n"),crc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
snes_irq_lo();
|
||||||
|
snes_irq_off();
|
||||||
|
snes_hirom();
|
||||||
|
snes_wr_disable();
|
||||||
|
|
||||||
|
snes_bus_active();
|
||||||
|
info_P(PSTR("Activate SNES bus\n"));
|
||||||
|
send_reset();
|
||||||
|
_delay_ms(init_delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void banner(){
|
||||||
|
uint8_t i;
|
||||||
|
for (i=0;i<40;i++)
|
||||||
|
info_P(PSTR("\n"));
|
||||||
|
info_P(PSTR(" ________ .__ __ ________ ____ ________\n"));
|
||||||
|
info_P(PSTR(" \\_____ \\ __ __|__| ____ | | __\\______ \\ _______ _/_ |/ _____/\n"));
|
||||||
|
info_P(PSTR(" / / \\ \\| | \\ |/ ___\\| |/ / | | \\_/ __ \\ \\/ /| / __ \\ \n"));
|
||||||
|
info_P(PSTR(" / \\_/. \\ | / \\ \\___| < | ` \\ ___/\\ / | \\ |__\\ \\ \n"));
|
||||||
|
info_P(PSTR(" \\_____\\ \\_/____/|__|\\___ >__|_ \\/_______ /\\___ >\\_/ |___|\\_____ / \n"));
|
||||||
|
info_P(PSTR(" \\__> \\/ \\/ \\/ \\/ \\/ \n"));
|
||||||
|
info_P(PSTR("\n"));
|
||||||
|
info_P(PSTR(" www.optixx.org\n"));
|
||||||
|
info_P(PSTR("\n"));
|
||||||
|
info_P(PSTR("System Hw: %s Sw: %s\n"),HW_VERSION,SW_VERSION);
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -26,5 +26,6 @@ void send_reset();
|
|||||||
void send_irq();
|
void send_irq();
|
||||||
void set_rom_mode();
|
void set_rom_mode();
|
||||||
void usb_connect();
|
void usb_connect();
|
||||||
|
void boot_startup_rom(uint16_t init_delay);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -49,7 +49,8 @@
|
|||||||
|
|
||||||
#define DO_CRC_CHECK_LOADER 0
|
#define DO_CRC_CHECK_LOADER 0
|
||||||
#define DO_CRC_CHECK 0
|
#define DO_CRC_CHECK 0
|
||||||
#define DO_SHM_SCRATCHPAD 1
|
#define DO_SHM_SCRATCHPAD 0
|
||||||
#define DO_SHM 1
|
#define DO_SHM 0
|
||||||
|
#define DO_TIMER 0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -51,7 +51,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern const char _rom[] PROGMEM;
|
|
||||||
extern FILE uart_stdout;
|
extern FILE uart_stdout;
|
||||||
|
|
||||||
uint8_t debug_level = (DEBUG | DEBUG_USB | DEBUG_CRC | DEBUG_SHM );
|
uint8_t debug_level = (DEBUG | DEBUG_USB | DEBUG_CRC | DEBUG_SHM );
|
||||||
@ -101,9 +100,11 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
|
|
||||||
shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_START, 0);
|
shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_START, 0);
|
||||||
shared_memory_write(SHARED_MEM_TX_CMD_BANK_COUNT, req_bank_cnt);
|
shared_memory_write(SHARED_MEM_TX_CMD_BANK_COUNT, req_bank_cnt);
|
||||||
|
#if DO_TIMER
|
||||||
if (req_addr == 0x000000) {
|
if (req_addr == 0x000000) {
|
||||||
timer_start();
|
timer_start();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -118,6 +119,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
|
|
||||||
|
|
||||||
if (req_addr && req_addr % req_bank_size == 0) {
|
if (req_addr && req_addr % req_bank_size == 0) {
|
||||||
|
#if DO_TIMER
|
||||||
|
|
||||||
#ifdef FLT_DEBUG
|
#ifdef FLT_DEBUG
|
||||||
debug_P(DEBUG_USB,
|
debug_P(DEBUG_USB,
|
||||||
PSTR("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
|
PSTR("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
|
||||||
@ -127,8 +130,9 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
PSTR("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%i\n"),
|
PSTR("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%i\n"),
|
||||||
req_bank, req_addr, timer_stop_int());
|
req_bank, req_addr, timer_stop_int());
|
||||||
#endif
|
#endif
|
||||||
req_bank++;
|
|
||||||
timer_start();
|
timer_start();
|
||||||
|
#endif
|
||||||
|
req_bank++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sram_bulk_write_start(req_addr);
|
sram_bulk_write_start(req_addr);
|
||||||
@ -154,6 +158,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
shared_memory_scratchpad_region_save_helper(req_addr);
|
shared_memory_scratchpad_region_save_helper(req_addr);
|
||||||
|
|
||||||
if (req_addr && (req_addr % req_bank_size) == 0) {
|
if (req_addr && (req_addr % req_bank_size) == 0) {
|
||||||
|
#if DO_TIMER
|
||||||
|
|
||||||
#ifdef FLT_DEBUG
|
#ifdef FLT_DEBUG
|
||||||
debug_P(DEBUG_USB,
|
debug_P(DEBUG_USB,
|
||||||
PSTR("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
|
PSTR("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
|
||||||
@ -163,8 +169,9 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
PSTR("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%i\n"),
|
PSTR("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%i\n"),
|
||||||
req_bank, req_addr, timer_stop_int());
|
req_bank, req_addr, timer_stop_int());
|
||||||
#endif
|
#endif
|
||||||
req_bank++;
|
|
||||||
timer_start();
|
timer_start();
|
||||||
|
#endif
|
||||||
|
req_bank++;
|
||||||
shared_memory_write(SHARED_MEM_TX_CMD_BANK_CURRENT, req_bank);
|
shared_memory_write(SHARED_MEM_TX_CMD_BANK_CURRENT, req_bank);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -251,53 +258,6 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
void boot_startup_rom(uint16_t init_delay)
|
|
||||||
{
|
|
||||||
info_P(PSTR("Fetch loader rom\n"));
|
|
||||||
info_P(PSTR("Activate AVR bus\n"));
|
|
||||||
avr_bus_active();
|
|
||||||
info_P(PSTR("IRQ off\n"));
|
|
||||||
snes_irq_lo();
|
|
||||||
snes_irq_off();
|
|
||||||
snes_lorom();
|
|
||||||
rle_decode(&_rom, ROM_BUFFER_SIZE, 0x000000);
|
|
||||||
info_P(PSTR("\n"));
|
|
||||||
|
|
||||||
#if DO_CRC_CHECK_LOADER
|
|
||||||
dump_memory(0x010000 - 0x100, 0x010000);
|
|
||||||
uint16_t crc;
|
|
||||||
crc = crc_check_bulk_memory((uint32_t)0x000000,0x010000, 0x010000);
|
|
||||||
info(PSTR("crc=%x\n"),crc);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
snes_irq_lo();
|
|
||||||
snes_irq_off();
|
|
||||||
snes_hirom();
|
|
||||||
snes_wr_disable();
|
|
||||||
|
|
||||||
snes_bus_active();
|
|
||||||
info_P(PSTR("Activate SNES bus\n"));
|
|
||||||
send_reset();
|
|
||||||
_delay_ms(init_delay);
|
|
||||||
}
|
|
||||||
|
|
||||||
void banner(){
|
|
||||||
uint8_t i;
|
|
||||||
for (i=0;i<40;i++)
|
|
||||||
info_P(PSTR("\n"));
|
|
||||||
info_P(PSTR(" ________ .__ __ ________ ____ ________\n"));
|
|
||||||
info_P(PSTR(" \\_____ \\ __ __|__| ____ | | __\\______ \\ _______ _/_ |/ _____/\n"));
|
|
||||||
info_P(PSTR(" / / \\ \\| | \\ |/ ___\\| |/ / | | \\_/ __ \\ \\/ /| / __ \\ \n"));
|
|
||||||
info_P(PSTR(" / \\_/. \\ | / \\ \\___| < | ` \\ ___/\\ / | \\ |__\\ \\ \n"));
|
|
||||||
info_P(PSTR(" \\_____\\ \\_/____/|__|\\___ >__|_ \\/_______ /\\___ >\\_/ |___|\\_____ / \n"));
|
|
||||||
info_P(PSTR(" \\__> \\/ \\/ \\/ \\/ \\/ \n"));
|
|
||||||
info_P(PSTR("\n"));
|
|
||||||
info_P(PSTR(" www.optixx.org\n"));
|
|
||||||
info_P(PSTR("\n"));
|
|
||||||
info_P(PSTR("System Hw: %s Sw: %s\n"),HW_VERSION,SW_VERSION);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void globals_init(){
|
void globals_init(){
|
||||||
req_addr = 0;
|
req_addr = 0;
|
||||||
req_addr_end = 0;
|
req_addr_end = 0;
|
||||||
|
|||||||
@ -35,6 +35,8 @@
|
|||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include "dump.h"
|
#include "dump.h"
|
||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
|
#include "crc.h"
|
||||||
|
#include "command.h"
|
||||||
|
|
||||||
#define RECEIVE_BUF_LEN 40
|
#define RECEIVE_BUF_LEN 40
|
||||||
|
|
||||||
@ -54,11 +56,11 @@ uint8_t *get_token(void)
|
|||||||
token_ptr = p;
|
token_ptr = p;
|
||||||
do {
|
do {
|
||||||
token_ptr++;
|
token_ptr++;
|
||||||
if (*token_ptr == ' ') {
|
if (*token_ptr == ' ' || *token_ptr == '\n' || *token_ptr == '\r') {
|
||||||
*token_ptr++ = '\0';
|
*token_ptr++ = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (*token_ptr != '\0');
|
} while (*token_ptr != ' ' && *token_ptr != '\n' && *token_ptr != '\r');
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,8 +81,6 @@ uint8_t get_dec(uint32_t *decval)
|
|||||||
uint8_t parse_hex(const uint8_t *s, uint32_t *hexval)
|
uint8_t parse_hex(const uint8_t *s, uint32_t *hexval)
|
||||||
{
|
{
|
||||||
uint32_t x = util_sscanhex(s);
|
uint32_t x = util_sscanhex(s);
|
||||||
if (x > 0xffffff)
|
|
||||||
return 0;
|
|
||||||
*hexval = (uint32_t) x;
|
*hexval = (uint32_t) x;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -142,7 +142,6 @@ static uint8_t get_int32(uint32_t *val)
|
|||||||
|
|
||||||
uart_putc('\r');
|
uart_putc('\r');
|
||||||
uart_putc('\n');
|
uart_putc('\n');
|
||||||
uart_putc(':');
|
|
||||||
uart_putc('>');
|
uart_putc('>');
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -185,6 +184,7 @@ void shell_run(void)
|
|||||||
uint32_t arg1;
|
uint32_t arg1;
|
||||||
uint32_t arg2;
|
uint32_t arg2;
|
||||||
uint32_t arg3;
|
uint32_t arg3;
|
||||||
|
uint16_t crc;
|
||||||
|
|
||||||
if (!cr)
|
if (!cr)
|
||||||
return;
|
return;
|
||||||
@ -203,25 +203,58 @@ void shell_run(void)
|
|||||||
if (get_hex_arg2(&arg1,&arg2))
|
if (get_hex_arg2(&arg1,&arg2))
|
||||||
dump_memory(arg1,arg2);
|
dump_memory(arg1,arg2);
|
||||||
else
|
else
|
||||||
printf("DUMP <start addr> <end addr> %i %i\n",arg1,arg2);
|
printf("DUMP <start addr> <end addr>\n");
|
||||||
}
|
|
||||||
else if (strcmp((char*)t, "RESET") == 0) {
|
}else if (strcmp((char*)t, "CRC") == 0) {
|
||||||
|
if (get_hex_arg2(&arg1,&arg2)){
|
||||||
|
crc = crc_check_bulk_memory(arg1,arg2,0x8000);
|
||||||
|
printf("0x%06lx - 0x%06lx crc=0x%04x\n",arg1,arg2,crc);
|
||||||
|
} else
|
||||||
|
printf("CRC <start addr> <end addr>\n");
|
||||||
|
}else if (strcmp((char*)t, "EXIT") == 0) {
|
||||||
leave_application();
|
leave_application();
|
||||||
|
}else if (strcmp((char*)t, "RESET") == 0) {
|
||||||
|
send_reset();
|
||||||
|
}else if (strcmp((char*)t, "IRQ") == 0) {
|
||||||
|
printf("Send IRQ\n");
|
||||||
|
snes_irq_on();
|
||||||
|
snes_irq_lo();
|
||||||
|
_delay_us(20);
|
||||||
|
snes_irq_hi();
|
||||||
|
snes_irq_off();
|
||||||
|
}else if (strcmp((char*)t, "AVR") == 0) {
|
||||||
|
printf("Activate AVR bus\n");
|
||||||
|
avr_bus_active();
|
||||||
|
snes_irq_lo();
|
||||||
|
snes_irq_off();
|
||||||
|
}else if (strcmp((char*)t, "SNES") == 0) {
|
||||||
|
printf("Activate SNES bus\n");
|
||||||
|
snes_irq_lo();
|
||||||
|
snes_irq_off();
|
||||||
|
snes_wr_disable();
|
||||||
|
snes_bus_active();
|
||||||
|
}else if (strcmp((char*)t, "LOROM") == 0) {
|
||||||
|
printf("Set LOROM\n");
|
||||||
|
snes_lorom();
|
||||||
|
snes_wr_disable();
|
||||||
|
}else if (strcmp((char*)t, "HIROM") == 0) {
|
||||||
|
printf("Set HIROM\n");
|
||||||
|
snes_hirom();
|
||||||
|
snes_wr_disable();
|
||||||
|
}else if (strcmp((char*)t, "LOADER") == 0) {
|
||||||
|
boot_startup_rom(500);
|
||||||
|
}else if (strcmp((char*)t, "RECONNECT") == 0) {
|
||||||
|
usb_connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt();
|
prompt();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
reset
|
|
||||||
reset snes
|
|
||||||
dias
|
dias
|
||||||
switch to avr mode
|
|
||||||
swicth to snes mode
|
|
||||||
send irq
|
|
||||||
crc
|
|
||||||
set irq vector
|
set irq vector
|
||||||
set reset vector
|
set reset vector
|
||||||
set rom mode
|
dump cart header
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -127,7 +127,7 @@ section at the end of this file).
|
|||||||
* (e.g. HID), but never want to send any data. This option saves a couple
|
* (e.g. HID), but never want to send any data. This option saves a couple
|
||||||
* of bytes in flash memory and the transmit buffers in RAM.
|
* of bytes in flash memory and the transmit buffers in RAM.
|
||||||
*/
|
*/
|
||||||
#define USB_CFG_INTR_POLL_INTERVAL 200
|
#define USB_CFG_INTR_POLL_INTERVAL 20
|
||||||
/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
|
/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
|
||||||
* interval. The value is in milliseconds and must not be less than 10 ms for
|
* interval. The value is in milliseconds and must not be less than 10 ms for
|
||||||
* low speed devices.
|
* low speed devices.
|
||||||
|
|||||||
@ -101,7 +101,7 @@ uint32_t util_sscandec(const uint8_t *s)
|
|||||||
|
|
||||||
uint32_t util_sscanhex(const uint8_t *s)
|
uint32_t util_sscanhex(const uint8_t *s)
|
||||||
{
|
{
|
||||||
uint32_t result;
|
int32_t result;
|
||||||
if (*s == '\0')
|
if (*s == '\0')
|
||||||
return -1;
|
return -1;
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user