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
    from Rev 498 to Rev 529
    Reverse comparison

Rev 498 → Rev 529

/includes/or_debug_proxy.h
85,6 → 85,8
extern int current_chain;
extern int dbg_chain;
 
extern int no_cpu; /* Don't provide access to anything in the cpu */
 
#define DBGCHAIN_SIZE 4 // Renamed from DC_SIZE due to definition clash with something in <windows.h> --jb 090302
#define DC_STATUS_SIZE 4
 
/ChangeLog
1,10 → 1,31
2011-03-07 Julius Baxter, ORSoC AB <julius@orsoc.se>
2011-04-22 Julius Baxter, ORSoC AB <julius@orsoc.se>
* includes/or_debug_proxy.h: <no_cpu>: Adding extern definition.
* src/linux_usb_driver_calls.c: Added debugging output.
(init_usb_jtag): Put in device name listing code. Device open now
uses these identification strings instead of the hardcoded one.
* src/usb_functions.c:
(usb_dbg_test): Added better debugging output.
* src/FT2232c.cpp: Added debugging output.
* src/or_debug_proxy.c: <no_cpu>: Global variable added to determine
if we should initialise CPU on connecting or not.
(main): New option added, -b, to use proxy in bus-only mode, where it
does not initialise CPU and just provides bus access.
* src/gdb.c:
(gdb_set_chain): Check if no_cpu is set, if so, don't allow setting
of scan chain to CPU.
(set_stall_state): Check if no_cpu is set, if so, don't allow setting
of stall bit to CPU.
* Makefile: Change STATIC_LIB back to explicitly require the driver
library version 0.4.16.
* README: Updated with information on new driver problems.
2011-03-07 Julius Baxter, ORSoC AB <julius@orsoc.se>
* Makefile:(STATIC_LDFLAGS): Added -lrt as required by new libftd2xx.
Updated example of downloading static library.
* README: Updated to contain information about latest FTDI libftd2xx
drivers.
 
2011-03-07 Julius Baxter, ORSoC AB <julius@orsoc.se>
2011-03-07 Julius Baxter, ORSoC AB <julius@orsoc.se>
* src/or_debug_proxy.c: Ran indent on code to neaten.
Added -k option to enable kernel debugging option which remaps 0xc0
high address to 0x00.
/src/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)
{
/src/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);
/src/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);
 
/src/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
/src/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 */
/Makefile
1,5 → 1,4
#
#****************************************************************************#
##****************************************************************************#
# #
# H E A D E R I N F O R M A T I O N #
# #
41,12 → 40,12
 
# Common Flags
COMMON_CPPFLAGS = -I./includes
COMMON_CXXFLAGS = -O3
COMMON_CXXFLAGS = -O2 -g
COMMON_LDFLAGS =
 
# Flags for static library
STATIC_LIBDIR = lib
STATIC_LIB = libftd2xx.a
STATIC_LIB = libftd2xx.a.0.4.16
STATIC_LDFLAGS = $(COMMON_LDFLAGS) $(STATIC_LIBDIR)/$(STATIC_LIB) \
-lrt -lpthread -ldl
# Defines to enable certain endpoint handling functions to be used
/README
18,6 → 18,7
0.1.5 090903 jb@orsoc.se
0.1.6 110307 jb@orsoc.se
0.1.7 110308 jb@orsoc.se
0.1.8 110422 jb@orsoc.se
===============================================================================
-- Installation --
===============================================================================
102,6 → 103,23
http://www.ftdichip.com, and is found under the links to "Drivers" and then
"D2XX".
 
WARNING: Later versions of the ftd2xx library appear not to work in the same way
as the earlier versions. Version 1.0.4 does not open the USB device unless the
kernel module ftdi_sio is unloaded (sudo rmmod ftdi_sio), however unloading this
module removes device nodes /dev/ttyUSB0 and /dev/ttyUSB1. These later
libraries can be used with or_debug_proxy but the because the ftdi_sio kernel
module must be unloaded first the serial consoles disappear. With this in mind
it is probably better to use the older driver that does not require this kernel
module be unloaded.
 
FTDI Chip do not make older versions of their drivers available on their website
but there are locations where version the static 0.4.16 library can be obtained.
 
See the discussion at the following URL for a link to the older static library
- http://opencores.org/forum,OpenRISC,0,4170 - which must be downloaded and
placed in the or_debug_proxy/lib path and a static compile performed, as
outline below.
 
Statically linked driver:
 
The simplest way to enable these drivers is to link the application

powered by: WebSVN 2.1.0

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