get read/write and bulks working
This commit is contained in:
parent
b6956c8fbd
commit
a9640af2bf
@ -3,9 +3,10 @@
|
|||||||
#define __config_h__
|
#define __config_h__
|
||||||
|
|
||||||
#define DEBUG_USB 1
|
#define DEBUG_USB 1
|
||||||
#define DEBUG_USB_RAW 1
|
#undef DEBUG_USB_RAW 1
|
||||||
#define DEBUG_SRAM 1
|
#undef DEBUG_SRAM 1
|
||||||
#define DEBUG_SREG 1
|
#undef DEBUG_SRAM_RAW
|
||||||
|
#undef DEBUG_SREG
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,6 @@ uint16_t crc_check_memory_range(uint32_t start_addr, uint32_t size,uint8_t *buff
|
|||||||
{
|
{
|
||||||
uint16_t crc = 0;
|
uint16_t crc = 0;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
uint8_t req_bank = 0;
|
|
||||||
for (addr = start_addr; addr < start_addr + size; addr += TRANSFER_BUFFER_SIZE) {
|
for (addr = start_addr; addr < start_addr + size; addr += TRANSFER_BUFFER_SIZE) {
|
||||||
sram_read_buffer(addr, buffer, TRANSFER_BUFFER_SIZE);
|
sram_read_buffer(addr, buffer, TRANSFER_BUFFER_SIZE);
|
||||||
crc = do_crc_update(crc, buffer, TRANSFER_BUFFER_SIZE);
|
crc = do_crc_update(crc, buffer, TRANSFER_BUFFER_SIZE);
|
||||||
|
|||||||
@ -41,3 +41,4 @@ void dump_packet(uint32_t addr, uint32_t len, uint8_t * packet)
|
|||||||
printf("|\n");
|
printf("|\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/wdt.h>
|
|
||||||
#include <avr/interrupt.h> /* for sei() */
|
#include <avr/interrupt.h> /* for sei() */
|
||||||
#include <util/delay.h> /* for _delay_ms() */
|
#include <util/delay.h> /* for _delay_ms() */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -60,12 +59,6 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
} else if (rq->bRequest == USB_UPLOAD_ADDR) {
|
} else if (rq->bRequest == USB_UPLOAD_ADDR) {
|
||||||
if (req_state != REQ_STATUS_IDLE){
|
|
||||||
#if DEBUG_USB
|
|
||||||
printf("USB_UPLOAD_ADDR: ERROR state is not REQ_STATUS_IDLE\n");
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
req_state = REQ_STATUS_UPLOAD;
|
req_state = REQ_STATUS_UPLOAD;
|
||||||
req_addr = rq->wValue.word;
|
req_addr = rq->wValue.word;
|
||||||
@ -244,6 +237,48 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void test_read_write(){
|
||||||
|
|
||||||
|
uint8_t i;
|
||||||
|
uint32_t addr;
|
||||||
|
avr_bus_active();
|
||||||
|
addr = 0x000000;
|
||||||
|
i = 1;
|
||||||
|
while (addr++ <= 0x0000ff){
|
||||||
|
sram_write(addr,i++);
|
||||||
|
}
|
||||||
|
|
||||||
|
addr = 0x000000;
|
||||||
|
while (addr++ <= 0x0000ff){
|
||||||
|
printf("read addr=0x%08lx %x\n",addr,sram_read(addr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void test_bulk_read_write(){
|
||||||
|
|
||||||
|
uint8_t i;
|
||||||
|
uint32_t addr;
|
||||||
|
avr_bus_active();
|
||||||
|
addr = 0x000000;
|
||||||
|
i = 0;
|
||||||
|
sram_bulk_write_start(addr);
|
||||||
|
while (addr++ <= 0x3fffff){
|
||||||
|
sram_bulk_write(i++);
|
||||||
|
sram_bulk_write_next();
|
||||||
|
}
|
||||||
|
sram_bulk_write_end();
|
||||||
|
|
||||||
|
addr = 0x000000;
|
||||||
|
sram_bulk_read_start(addr);
|
||||||
|
while (addr <= 0x3fffff){
|
||||||
|
printf("addr=0x%08lx %x\n",addr,sram_bulk_read());
|
||||||
|
sram_bulk_read_next();
|
||||||
|
addr ++;
|
||||||
|
}
|
||||||
|
sram_bulk_read_end();
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
@ -255,19 +290,9 @@ int main(void)
|
|||||||
system_init();
|
system_init();
|
||||||
printf("Sytem Init\n");
|
printf("Sytem Init\n");
|
||||||
|
|
||||||
|
//while(1);
|
||||||
|
|
||||||
avr_bus_active();
|
avr_bus_active();
|
||||||
|
|
||||||
addr = 0x000000;
|
|
||||||
i = 0;
|
|
||||||
while (addr++ <= 0x00ffff){
|
|
||||||
sram_write(addr,i++);
|
|
||||||
}
|
|
||||||
|
|
||||||
addr = 0x000000;
|
|
||||||
while (addr++ <= 0x00ffff){
|
|
||||||
printf("read addr=0x%08lx %x\n",addr,sram_read(addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
usbInit();
|
usbInit();
|
||||||
printf("USB Init\n");
|
printf("USB Init\n");
|
||||||
usbDeviceDisconnect(); /* enforce re-enumeration, do this while
|
usbDeviceDisconnect(); /* enforce re-enumeration, do this while
|
||||||
@ -276,7 +301,6 @@ int main(void)
|
|||||||
printf("USB disconnect\n");
|
printf("USB disconnect\n");
|
||||||
i = 10;
|
i = 10;
|
||||||
while (--i) { /* fake USB disconnect for > 250 ms */
|
while (--i) { /* fake USB disconnect for > 250 ms */
|
||||||
wdt_reset();
|
|
||||||
led_on();
|
led_on();
|
||||||
_delay_ms(35);
|
_delay_ms(35);
|
||||||
led_off();
|
led_off();
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/wdt.h>
|
|
||||||
#include <util/delay.h> /* for _delay_ms() */
|
#include <util/delay.h> /* for _delay_ms() */
|
||||||
|
|
||||||
|
|
||||||
@ -97,6 +96,7 @@ void sreg_set(uint32_t addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void sram_bulk_read_start(uint32_t addr)
|
void sram_bulk_read_start(uint32_t addr)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_SRAM
|
#ifdef DEBUG_SRAM
|
||||||
@ -105,7 +105,6 @@ void sram_bulk_read_start(uint32_t addr)
|
|||||||
avr_data_in();
|
avr_data_in();
|
||||||
|
|
||||||
AVR_CS_PORT &= ~(1 << AVR_CS_PIN);
|
AVR_CS_PORT &= ~(1 << AVR_CS_PIN);
|
||||||
|
|
||||||
AVR_WR_PORT |= (1 << AVR_WR_PIN);
|
AVR_WR_PORT |= (1 << AVR_WR_PIN);
|
||||||
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
||||||
|
|
||||||
@ -113,14 +112,6 @@ void sram_bulk_read_start(uint32_t addr)
|
|||||||
|
|
||||||
AVR_RD_PORT &= ~(1 << AVR_RD_PIN);
|
AVR_RD_PORT &= ~(1 << AVR_RD_PIN);
|
||||||
asm volatile ("nop");
|
asm volatile ("nop");
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sram_bulk_read_next(void)
|
inline void sram_bulk_read_next(void)
|
||||||
@ -130,24 +121,12 @@ inline void sram_bulk_read_next(void)
|
|||||||
AVR_RD_PORT &= ~(1 << AVR_RD_PIN);
|
AVR_RD_PORT &= ~(1 << AVR_RD_PIN);
|
||||||
|
|
||||||
asm volatile ("nop");
|
asm volatile ("nop");
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline uint8_t sram_bulk_read(void)
|
inline uint8_t sram_bulk_read(void)
|
||||||
{
|
{
|
||||||
uint8_t byte;
|
return AVR_DATA_PIN;
|
||||||
|
|
||||||
byte = AVR_DATA_PIN;
|
|
||||||
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
|
||||||
return byte;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sram_bulk_read_end(void)
|
void sram_bulk_read_end(void)
|
||||||
@ -155,6 +134,7 @@ void sram_bulk_read_end(void)
|
|||||||
#ifdef DEBUG_SRAM
|
#ifdef DEBUG_SRAM
|
||||||
printf("sram_bulk_read_end:");
|
printf("sram_bulk_read_end:");
|
||||||
#endif
|
#endif
|
||||||
|
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
||||||
AVR_CS_PORT |= (1 << AVR_CS_PIN);
|
AVR_CS_PORT |= (1 << AVR_CS_PIN);
|
||||||
avr_data_in();
|
avr_data_in();
|
||||||
}
|
}
|
||||||
@ -162,7 +142,7 @@ void sram_bulk_read_end(void)
|
|||||||
uint8_t sram_read(uint32_t addr)
|
uint8_t sram_read(uint32_t addr)
|
||||||
{
|
{
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
#ifdef DEBUG_SRAM
|
#ifdef DEBUG_SRAM_RAW
|
||||||
printf("sram_read: addr=0x%08lx\n\r", addr);
|
printf("sram_read: addr=0x%08lx\n\r", addr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -177,13 +157,6 @@ uint8_t sram_read(uint32_t addr)
|
|||||||
|
|
||||||
AVR_RD_PORT &= ~(1 << AVR_RD_PIN);
|
AVR_RD_PORT &= ~(1 << AVR_RD_PIN);
|
||||||
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
|
||||||
asm volatile ("nop");
|
asm volatile ("nop");
|
||||||
|
|
||||||
byte = AVR_DATA_PIN;
|
byte = AVR_DATA_PIN;
|
||||||
@ -216,17 +189,13 @@ void sram_bulk_write_start(uint32_t addr)
|
|||||||
inline void sram_bulk_write_next(void)
|
inline void sram_bulk_write_next(void)
|
||||||
{
|
{
|
||||||
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
||||||
|
|
||||||
counter_up();
|
counter_up();
|
||||||
|
|
||||||
AVR_WR_PORT &= ~(1 << AVR_WR_PIN);
|
AVR_WR_PORT &= ~(1 << AVR_WR_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sram_bulk_write( uint8_t data)
|
inline void sram_bulk_write( uint8_t data)
|
||||||
{
|
{
|
||||||
AVR_DATA_PORT = data;
|
AVR_DATA_PORT = data;
|
||||||
|
|
||||||
AVR_WR_PORT |= (1 << AVR_WR_PIN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sram_bulk_write_end(void)
|
void sram_bulk_write_end(void)
|
||||||
@ -234,8 +203,8 @@ void sram_bulk_write_end(void)
|
|||||||
#ifdef DEBUG_SRAM
|
#ifdef DEBUG_SRAM
|
||||||
printf("sram_bulk_write_end:");
|
printf("sram_bulk_write_end:");
|
||||||
#endif
|
#endif
|
||||||
|
AVR_WR_PORT |= (1 << AVR_WR_PIN);
|
||||||
AVR_CS_PORT |= (1 << AVR_CS_PIN);
|
AVR_CS_PORT |= (1 << AVR_CS_PIN);
|
||||||
|
|
||||||
avr_data_in();
|
avr_data_in();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +212,7 @@ void sram_bulk_write_end(void)
|
|||||||
void sram_write(uint32_t addr, uint8_t data)
|
void sram_write(uint32_t addr, uint8_t data)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef DEBUG_SRAM
|
#ifdef DEBUG_SRAM_RAW
|
||||||
printf("sram_write: addr=0x%08lx data=%x\n\r", addr, data);
|
printf("sram_write: addr=0x%08lx data=%x\n\r", addr, data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -155,7 +155,7 @@ inline void sram_bulk_read_end(void);
|
|||||||
uint8_t sram_bulk_read(void);
|
uint8_t sram_bulk_read(void);
|
||||||
|
|
||||||
void sram_bulk_write_start(uint32_t addr);
|
void sram_bulk_write_start(uint32_t addr);
|
||||||
inline void sram_bulk_read_next(void);
|
inline void sram_bulk_write_next(void);
|
||||||
inline void sram_bulk_write_end(void);
|
inline void sram_bulk_write_end(void);
|
||||||
void sram_bulk_write(uint8_t data);
|
void sram_bulk_write(uint8_t data);
|
||||||
|
|
||||||
|
|||||||
@ -43,9 +43,9 @@ uint8_t usbFunctionWrite(uint8_t * data, uint8_t len)
|
|||||||
printf("usbFunctionWrite REQ_STATUS_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n",
|
printf("usbFunctionWrite REQ_STATUS_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n",
|
||||||
req_addr, len, rx_remaining);
|
req_addr, len, rx_remaining);
|
||||||
#endif
|
#endif
|
||||||
cli();
|
//cli();
|
||||||
sram_copy(req_addr, data, len);
|
sram_copy(req_addr, data, len);
|
||||||
sei();
|
//sei();
|
||||||
req_addr += len;
|
req_addr += len;
|
||||||
} else if (req_state == REQ_STATUS_BULK_UPLOAD) {
|
} else if (req_state == REQ_STATUS_BULK_UPLOAD) {
|
||||||
|
|
||||||
|
|||||||
@ -9,15 +9,20 @@ import popen2
|
|||||||
import glob
|
import glob
|
||||||
import sys
|
import sys
|
||||||
import pprint
|
import pprint
|
||||||
|
from subprocess import Popen
|
||||||
|
|
||||||
|
|
||||||
|
path = "/Users/david/Devel/arch/avr/code/snesram/roms/"
|
||||||
|
|
||||||
|
|
||||||
|
def shellquote(s):
|
||||||
|
return "'" + s.replace("'", "'\\''") + "'"
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
conn = sqlite3.connect('roms.sqlite3')
|
conn = sqlite3.connect('roms.sqlite3')
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
for i in [(4,),(8,),(16,),(32,)]:
|
for i in [(4,),(8,),(16,),(32,)]:
|
||||||
dirname = "%02i" % i
|
dirname = os.path.join(path,"%02i" % i)
|
||||||
if not os.path.isdir(dirname):
|
if not os.path.isdir(dirname):
|
||||||
os.mkdir(dirname)
|
os.mkdir(dirname)
|
||||||
print "#" * 60
|
print "#" * 60
|
||||||
@ -42,8 +47,13 @@ def main():
|
|||||||
for row in c:
|
for row in c:
|
||||||
name,size,filename = row
|
name,size,filename = row
|
||||||
if '[' not in filename:
|
if '[' not in filename:
|
||||||
cmd = 'scp burst:"%s" %s/' % ( filename,dirname)
|
src = "david@burst:%s" % filename
|
||||||
print cmd
|
command = ["scp",shellquote(src), dirname]
|
||||||
|
proc = Popen(command)
|
||||||
|
print dir(proc)
|
||||||
|
proc.communicate()
|
||||||
|
|
||||||
|
raise
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user