debug SHM
This commit is contained in:
parent
68b882acfb
commit
f9e1a7a151
@ -42,8 +42,8 @@
|
|||||||
#define USB_MAX_TRANS 0xff
|
#define USB_MAX_TRANS 0xff
|
||||||
#define USB_CRC_CHECK 0x01
|
#define USB_CRC_CHECK 0x01
|
||||||
|
|
||||||
#define TRANSFER_BUFFER_SIZE 0x200
|
#define TRANSFER_BUFFER_SIZE 0x000
|
||||||
#define FORMAT_BUFFER_LEN 0x0FF
|
#define FORMAT_BUFFER_LEN 0x100
|
||||||
#define HW_VERSION "2.6"
|
#define HW_VERSION "2.6"
|
||||||
#define SW_VERSION "1.0"
|
#define SW_VERSION "1.0"
|
||||||
|
|
||||||
|
|||||||
@ -137,7 +137,6 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
} else if (rq->bRequest == USB_BULK_UPLOAD_NEXT) {
|
} else if (rq->bRequest == USB_BULK_UPLOAD_NEXT) {
|
||||||
|
|
||||||
req_state = REQ_STATUS_BULK_UPLOAD;
|
req_state = REQ_STATUS_BULK_UPLOAD;
|
||||||
req_addr = rq->wValue.word;
|
req_addr = rq->wValue.word;
|
||||||
req_addr = req_addr << 16;
|
req_addr = req_addr << 16;
|
||||||
@ -146,8 +145,6 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
|
|
||||||
req_percent = (uint32_t)( 100 * req_addr ) / req_addr_end;
|
req_percent = (uint32_t)( 100 * req_addr ) / req_addr_end;
|
||||||
if (req_percent!=req_percent_last){
|
if (req_percent!=req_percent_last){
|
||||||
//debug_P(DEBUG_USB,
|
|
||||||
// PSTR("USB_BULK_UPLOAD_ADDR: precent=%i\n", req_percent);
|
|
||||||
shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_PROGESS, req_percent);
|
shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_PROGESS, req_percent);
|
||||||
sram_bulk_write_start(req_addr);
|
sram_bulk_write_start(req_addr);
|
||||||
}
|
}
|
||||||
@ -165,7 +162,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
sram_bulk_write_start(req_addr);
|
sram_bulk_write_start(req_addr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SHM_SCRATCHPAD
|
#if 1
|
||||||
if (!shared_memory_scratchpad_region_save_helper(req_addr)){
|
if (!shared_memory_scratchpad_region_save_helper(req_addr)){
|
||||||
debug_P(DEBUG_USB,
|
debug_P(DEBUG_USB,
|
||||||
PSTR("USB_BULK_UPLOAD_NEXT: scratchpad_region_save_helper was dirty\n"));
|
PSTR("USB_BULK_UPLOAD_NEXT: scratchpad_region_save_helper was dirty\n"));
|
||||||
@ -293,7 +290,7 @@ void usb_connect()
|
|||||||
|
|
||||||
void boot_startup_rom()
|
void boot_startup_rom()
|
||||||
{
|
{
|
||||||
info_P(PSTR("Boot startup rom\n"));
|
info_P(PSTR("Fetch loader rom\n"));
|
||||||
info_P(PSTR("Activate AVR bus\n"));
|
info_P(PSTR("Activate AVR bus\n"));
|
||||||
avr_bus_active();
|
avr_bus_active();
|
||||||
info_P(PSTR("IRQ off\n"));
|
info_P(PSTR("IRQ off\n"));
|
||||||
@ -302,7 +299,7 @@ void boot_startup_rom()
|
|||||||
snes_lorom();
|
snes_lorom();
|
||||||
rle_decode(&_rom, ROM_BUFFER_SIZE, 0x000000);
|
rle_decode(&_rom, ROM_BUFFER_SIZE, 0x000000);
|
||||||
info_P(PSTR("\n"));
|
info_P(PSTR("\n"));
|
||||||
#if 1
|
#if 0
|
||||||
dump_memory(0x10000 - 0x100, 0x10000);
|
dump_memory(0x10000 - 0x100, 0x10000);
|
||||||
#endif
|
#endif
|
||||||
snes_hirom();
|
snes_hirom();
|
||||||
@ -310,9 +307,7 @@ void boot_startup_rom()
|
|||||||
snes_bus_active();
|
snes_bus_active();
|
||||||
info_P(PSTR("Activate SNES bus\n"));
|
info_P(PSTR("Activate SNES bus\n"));
|
||||||
send_reset();
|
send_reset();
|
||||||
_delay_ms(50);
|
_delay_ms(100);
|
||||||
send_reset();
|
|
||||||
_delay_ms(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void banner(){
|
void banner(){
|
||||||
@ -348,6 +343,7 @@ int main(void)
|
|||||||
stdout = &uart_stdout;
|
stdout = &uart_stdout;
|
||||||
banner();
|
banner();
|
||||||
system_init();
|
system_init();
|
||||||
|
shared_memory_init();
|
||||||
snes_reset_hi();
|
snes_reset_hi();
|
||||||
snes_reset_off();
|
snes_reset_off();
|
||||||
irq_init();
|
irq_init();
|
||||||
@ -417,6 +413,8 @@ int main(void)
|
|||||||
info_P(PSTR("Read 0x3000=%c\n"), c);
|
info_P(PSTR("Read 0x3000=%c\n"), c);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
system_init();
|
||||||
|
shared_memory_init();
|
||||||
irq_init();
|
irq_init();
|
||||||
boot_startup_rom();
|
boot_startup_rom();
|
||||||
globals_init();
|
globals_init();
|
||||||
|
|||||||
@ -48,6 +48,13 @@ uint8_t scratchpad_locked_rx = 1;
|
|||||||
uint8_t scratchpad_locked_tx = 1;
|
uint8_t scratchpad_locked_tx = 1;
|
||||||
|
|
||||||
|
|
||||||
|
void shared_memory_init(void){
|
||||||
|
scratchpad_locked_rx = 1;
|
||||||
|
scratchpad_locked_tx = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t shared_memory_scratchpad_region_save_helper(uint32_t addr){
|
uint8_t shared_memory_scratchpad_region_save_helper(uint32_t addr){
|
||||||
|
|
||||||
if(addr > (SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE) && scratchpad_locked_tx){
|
if(addr > (SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE) && scratchpad_locked_tx){
|
||||||
@ -183,10 +190,11 @@ void shared_memory_irq_restore()
|
|||||||
|
|
||||||
void shared_memory_write(uint8_t cmd, uint8_t value)
|
void shared_memory_write(uint8_t cmd, uint8_t value)
|
||||||
{
|
{
|
||||||
|
return 0;
|
||||||
if (scratchpad_locked_tx)
|
if (scratchpad_locked_tx){
|
||||||
debug_P(DEBUG_SHM, PSTR("shared_memory_write: locked_tx\n"));
|
debug_P(DEBUG_SHM, PSTR("shared_memory_write: locked_tx\n"));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
debug_P(DEBUG_SHM, PSTR("shared_memory_write: 0x%04x=0x%02x 0x%04x=0x%02x \n"),
|
debug_P(DEBUG_SHM, PSTR("shared_memory_write: 0x%04x=0x%02x 0x%04x=0x%02x \n"),
|
||||||
SHARED_MEM_TX_LOC_CMD, cmd, SHARED_MEM_TX_LOC_PAYLOAD, value);
|
SHARED_MEM_TX_LOC_CMD, cmd, SHARED_MEM_TX_LOC_PAYLOAD, value);
|
||||||
|
|
||||||
@ -242,9 +250,10 @@ int shared_memory_read(uint8_t *cmd, uint8_t *len,uint8_t *buffer)
|
|||||||
{
|
{
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
|
|
||||||
if (scratchpad_locked_rx)
|
if (scratchpad_locked_rx){
|
||||||
debug_P(DEBUG_SHM, PSTR("shared_memory_write: locked_tx\n"));
|
debug_P(DEBUG_SHM, PSTR("shared_memory_write: locked_tx\n"));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
state = sram_read(SHARED_MEM_RX_LOC_STATE);
|
state = sram_read(SHARED_MEM_RX_LOC_STATE);
|
||||||
if (state != SHARED_MEM_RX_AVR_ACK){
|
if (state != SHARED_MEM_RX_AVR_ACK){
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
#define SHARED_MEM_TX_CMD_TERMINATE 0x06
|
#define SHARED_MEM_TX_CMD_TERMINATE 0x06
|
||||||
|
|
||||||
#define SHARED_MEM_TX_LOC_STATE 0x000000
|
#define SHARED_MEM_TX_LOC_STATE 0x000000
|
||||||
#define SHARED_MEM_TX_LOC_SIZE 0x000040
|
#define SHARED_MEM_TX_LOC_SIZE 0x000100
|
||||||
#define SHARED_MEM_TX_LOC_CMD 0x000001
|
#define SHARED_MEM_TX_LOC_CMD 0x000001
|
||||||
#define SHARED_MEM_TX_LOC_PAYLOAD 0x000002
|
#define SHARED_MEM_TX_LOC_PAYLOAD 0x000002
|
||||||
|
|
||||||
@ -48,7 +48,7 @@
|
|||||||
#define SHARED_MEM_RX_CMD_FILESEL 0x01
|
#define SHARED_MEM_RX_CMD_FILESEL 0x01
|
||||||
|
|
||||||
#define SHARED_MEM_RX_LOC_STATE 0x001000
|
#define SHARED_MEM_RX_LOC_STATE 0x001000
|
||||||
#define SHARED_MEM_RX_LOC_SIZE 0x000040
|
#define SHARED_MEM_RX_LOC_SIZE 0x000100
|
||||||
#define SHARED_MEM_RX_LOC_CMD 0x001001
|
#define SHARED_MEM_RX_LOC_CMD 0x001001
|
||||||
#define SHARED_MEM_RX_LOC_LEN 0x001002
|
#define SHARED_MEM_RX_LOC_LEN 0x001002
|
||||||
#define SHARED_MEM_RX_LOC_PAYLOAD 0x001003
|
#define SHARED_MEM_RX_LOC_PAYLOAD 0x001003
|
||||||
|
|||||||
@ -156,6 +156,9 @@ quickdev16_write_rom (const char *filename)
|
|||||||
USB_ENDPOINT_OUT, USB_MODE_AVR, 0, 0, NULL,
|
USB_ENDPOINT_OUT, USB_MODE_AVR, 0, 0, NULL,
|
||||||
0, 5000);
|
0, 5000);
|
||||||
|
|
||||||
|
/* wait for the loader to depack */
|
||||||
|
usleep(500000);
|
||||||
|
|
||||||
|
|
||||||
cnt = usb_control_msg(handle,
|
cnt = usb_control_msg(handle,
|
||||||
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT,
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user