OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/or_debug_proxy/src
    from Rev 497 to Rev 529
    Reverse comparison

Rev 497 → Rev 529

/linux_usb_driver_calls.c
176,11 → 176,11
int init_usb_jtag()
{
FTC_STATUS Status = FTC_SUCCESS;
DWORD dwNumDevices = 0;
//char szDeviceName[100];
//char szDeviceName[] = "Dual RS232 A"; // Original, unmodified FT2232 device name
// We now open the device by its name
char szDeviceName[] = "ORSoC OpenRISC debug cable A\0"; // ORSoC debug cable UART A name
//char szDeviceName[] = "ORSoC OpenRISC debug cable A\0"; // ORSoC debug cable UART A name
char* szDeviceName;
DWORD dwLocationID = 0;
DWORD dwClockFrequencyHz = 0;
FTC_INPUT_OUTPUT_PINS LowInputOutputPinsData;
191,70 → 191,51
//char szDllVersion[10];
 
// Has been changed to hardcode load device named "ORSoC OpenRISC debug cable A"; - jb 090301
/*
//Status = JTAG_GetNumDevices(&dwNumDevices);
Status = pFT2232cMpsseJtag->JTAG_GetNumDevices(&dwNumDevices);
if (DEBUG_USB_DRVR_FUNCS)
{
if (Status == FTC_SUCCESS)
printf("JTAG_GetNumDevices detected %ld available FT2232x device(s) connected to the system.\n", dwNumDevices);
else
{
printf("GetNumDevices failed with status code 0x%lx\n", Status);
exit(-1);
}
}
#define MAX_DEVICES 5
char * pcBufRead = NULL;
char * pcBufLD[MAX_DEVICES + 1];
char cBufLD[MAX_DEVICES][64];
FT_STATUS ftStatus;
int iNumDevs = 0;
int i;
for(i = 0; i < MAX_DEVICES; i++) {
pcBufLD[i] = cBufLD[i];
}
pcBufLD[MAX_DEVICES] = NULL;
ftStatus = FT_ListDevices(pcBufLD, &iNumDevs, FT_LIST_ALL | FT_OPEN_BY_DESCRIPTION);
 
if (dwNumDevices == 0)
{
printf("Error: USB Debugger device not detected\n");
exit(-1);
}
Status = pFT2232cMpsseJtag->JTAG_GetDllVersion(szDllVersion, 10);
if (DEBUG_USB_DRVR_FUNCS)
printf("JTAG_GetDLLVersion returned Status: 0x%lx and version %s\n", Status, szDllVersion);
if(ftStatus != FT_OK) {
printf("Error: FT_ListDevices(%d)\n", (int) ftStatus);
return 1;
}
#if DEBUG_USB_DRVR_FUNCS==1
for(i = 0; ( (i <MAX_DEVICES) && (i < iNumDevs) ); i++) {
printf("Device %d Description - %s\n", i, cBufLD[i]);
}
#endif
 
*/
dwNumDevices = 1;
szDeviceName = cBufLD[0]; // Should be first device
 
if (Status == FTC_SUCCESS)
{
if (dwNumDevices == 1)
{
/*
Status = pFT2232cMpsseJtag->JTAG_GetDeviceNameLocationID(0,szDeviceName,50, &dwLocationID);
if (DEBUG_USB_DRVR_FUNCS)
// In the Windows version it shows Dual RS323 A at: 0x321
printf("JTAG_GetDeviceNameLocID: %s at: 0x%lx\n", szDeviceName, dwLocationID);
*/
dwLocationID = 0;
if (Status == FTC_SUCCESS)
dwLocationID = 0;
if (Status == FTC_SUCCESS)
{
Status = pFT2232cMpsseJtag->JTAG_OpenSpecifiedDevice(szDeviceName,dwLocationID, &ftHandle);
#if DEBUG_USB_DRVR_FUNCS==1
printf("JTAG_OpenSpecifiedDevice %s\n", szDeviceName);
#endif
Status = pFT2232cMpsseJtag->JTAG_OpenSpecifiedDevice(szDeviceName,dwLocationID, &ftHandle);
#if DEBUG_USB_DRVR_FUNCS==1
printf("JTAG_OpenSpecifiedDevice status: %d (%s)\n",(int)Status, EN_Common_Errors[Status]);
#endif
}
}
else
// When there's more than 1 device, will just open first device. Perhaps implement selection menu for
// users in event that there's more than 1, but for now just hard code this to open the same device
{
//if (dwNumDevices == 2)
//{
Status=pFT2232cMpsseJtag->JTAG_GetDeviceNameLocationID(1,szDeviceName,50,&dwLocationID);
if (Status == FTC_SUCCESS)
{
Status = pFT2232cMpsseJtag->JTAG_OpenSpecifiedDevice(szDeviceName, dwLocationID, &ftHandle);
}
//}
}
 
// Try initialising and obtaining a handle to a specific device
if (Status == FTC_SUCCESS)
{
/usb_functions.c
165,28 → 165,57
uint32_t npc, ppc, r1;
unsigned char stalled;
printf("Stalling or1k\n");
uint32_t zero = 0;
 
printf("Stalling OR1K CPU0\n");
err = dbg_cpu0_write_ctrl(0, 0x01); // stall or1k
err = dbg_cpu0_read_ctrl(0, &stalled);
if (!(stalled & 0x1)) {
printf("or1k should be stalled\n"); // check stall or1k
printf("OR1K CPU0 should be stalled\n"); // check stall or1k
exit(1);
}
uint32_t zero = 0;
/* Clear Debug Reason Register (DRR) 0x3015 */
err = dbg_cpu0_write((6 << 11) + 21, &zero, 4);
err = dbg_cpu0_read((0 << 11) + 16, &npc, 4); /* Read NPC */
err = dbg_cpu0_read((0 << 11) + 18, &ppc, 4); /* Read PPC */
err = dbg_cpu0_read(0x401, &r1, 4); /* Read R1 */
 
if (err)
{
printf("Jtag error %d occured; exiting.", err);
FT2232_USB_JTAG_CloseDevice();
exit(1);
printf("Error %d occured when attempting to stall CPU\n", err);
goto do_exit;
}
/* Clear Debug Reason Register (DRR) 0x3015 */
if (!err)
err = dbg_cpu0_write((6 << 11) + 21, &zero, 4);
if (err)
{
printf("Error %d occured when writing CPU DRR register\n",err);
goto do_exit;
}
if (!err)
err = dbg_cpu0_read((0 << 11) + 16, &npc, 4); /* Read NPC */
if (err)
{
printf("Error %d occured when reading CPU NPC\n",err);
goto do_exit;
}
if (!err)
err = dbg_cpu0_read((0 << 11) + 18, &ppc, 4); /* Read PPC */
if (err)
{
printf("Error %d occured when reading CPU PPC\n",err);
goto do_exit;
}
if (!err)
err = dbg_cpu0_read(0x401, &r1, 4); /* Read R1 */
if (err)
{
printf("Error %d occured when reading CPU GPR1\n",err);
goto do_exit;
}
 
printf("Read npc = %.8x ppc = %.8x r1 = %.8x\n", npc, ppc, r1);
/*
201,6 → 230,11
printf("err = %d\n",err);
*/
return;
 
do_exit:
printf("Exiting\n");
FT2232_USB_JTAG_CloseDevice();
exit(1);
}
 
 
321,9 → 355,16
// uint32_t err;
uint32_t id;
uint32_t reinit_count=0;
retry_jtag_init:
if (init_usb_jtag() > 0)
return DBG_ERR_CRC;
int err;
retry_jtag_init:
err = init_usb_jtag();
if (err)
{
#ifdef DEBUG_USB_DRVR_FUNCS
printf("init_usb_jtag error %d\n",err);
#endif
return DBG_ERR_CRC;
}
// Set ID code instruction in IR
usb_set_tap_ir(JI_IDCODE);
/FT2232c.cpp
446,7 → 446,13
{
 
// To open a device in Linux the FT_OPEN_BY_DESCRIPTION has to be used. Rene
Status = FT_OpenEx((PVOID)lpDeviceName, FT_OPEN_BY_DESCRIPTION, &ftHandle);
Status = FT_OpenEx((PVOID)lpDeviceName, FT_OPEN_BY_DESCRIPTION, &ftHandle);
 
#ifdef DEBUG_USB_DRVR_FUNCS
printf("FT_OpenEx status: %d\n", (int)Status);
#endif
 
//Status = FT_OpenEx((PVOID)lpDeviceName, FT_OPEN_BY_SERIAL_NUMBER, &ftHandle);
// Linux das not return the LocationID
// Status = FT_OpenEx((PVOID)dwLocationID, FT_OPEN_BY_LOCATION, &ftHandle);
 
/or_debug_proxy.c
91,6 → 91,9
/* The chain that should be currently selected. */
int dbg_chain = -1;
 
/* By default, provide access to CPU */
int no_cpu = 0;
 
int main(int argc, char *argv[])
{
 
98,6 → 101,7
int gdb_protocol = GDB_PROTOCOL_NONE;
endpoint_target = ENDPOINT_TARGET_NONE;
int inp_arg = 1;
 
// Check we were compiled with at least one endpoint enabled
#ifndef USB_ENDPOINT_ENABLED
129,6 → 133,8
endpoint_target = ENDPOINT_TARGET_OTHER;
} else if (strcmp(argv[inp_arg], "-k") == 0) {
kernel_debug = 1;
} else if (strcmp(argv[inp_arg], "-b") == 0) {
no_cpu = 1;
} else {
serverPort = strtol(argv[2], &s, 10);
}
163,7 → 169,8
printf("\nConnecting to OR1k via USB debug cable\n\n");
if ((err = usb_dbg_reset()))
goto JtagIfError;
dbg_test(); // Perform some tests
if (!no_cpu)
dbg_test(); // Perform some tests
}
#endif
 
408,6 → 415,8
printf("\tOptions:\n");
printf
("\t-k\tAccesses to 0xC0000000 map to 0x0. Useful for kernel debugging.\n");
printf
("\t-b\tBus access only - do not attempt to talk to the CPU\n");
printf("\n");
printf("\tExample:\n");
#ifdef USB_ENDPOINT_ENABLED
/gdb.c
3581,6 → 3581,11
{
switch (chain) {
case SC_RISC_DEBUG:
if (no_cpu)
return ERR_NONE;
else
gdb_chain = chain;
return ERR_NONE;
case SC_REGISTER:
case SC_TRACE:
case SC_WISHBONE:
3637,6 → 3642,8
/*---------------------------------------------------------------------------*/
static void set_stall_state(int state)
{
if (no_cpu)
return;
 
if (state == 0) {
err = dbg_cpu0_write_ctrl(0, 0); /* unstall or1k */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.