[RZ/A1H] Deletes debugging prints. Expands the stacks and heap. Deletes the illegal memory access

pull/594/head
AMANUMA Kazuhisa 2014-10-29 15:52:30 +09:00
parent 3f32994343
commit e8b0bd2a2e
3 changed files with 34 additions and 79 deletions

View File

@ -52,7 +52,7 @@ Typedef definitions
/******************************************************************************* /*******************************************************************************
Macro definitions Macro definitions
*******************************************************************************/ *******************************************************************************/
#define DUMMY_ACCESS (*(volatile unsigned long *)(0x40000000)) #define DUMMY_ACCESS (*(volatile unsigned long *)(OSTM0CNT))
/* #define CACHE_WRITEBACK */ /* #define CACHE_WRITEBACK */

View File

@ -33,10 +33,6 @@ extern "C"
//#include "USBRegs_RZ_A1H.h" //#include "USBRegs_RZ_A1H.h"
/*for debug print*/
#define DEBUG_RZ_A1H
/*************************************************************************/ /*************************************************************************/
const struct PIPECFGREC { const struct PIPECFGREC {
uint16_t endpoint; uint16_t endpoint;
@ -51,7 +47,7 @@ const struct PIPECFGREC {
EP1OUT, /*EP1: Host -> Func, INT*/ EP1OUT, /*EP1: Host -> Func, INT*/
6 | USB_FUNCTION_D0FIFO_USE, 6 | USB_FUNCTION_D0FIFO_USE,
USB_FUNCTION_INTERRUPT | USB_FUNCTION_INTERRUPT |
USB_FUNCTION_BFREOFF | USB_FUNCTION_BFREOFF |
USB_FUNCTION_DBLBOFF | USB_FUNCTION_DBLBOFF |
USB_FUNCTION_CNTMDON | USB_FUNCTION_CNTMDON |
USB_FUNCTION_SHTNAKOFF | USB_FUNCTION_SHTNAKOFF |
@ -65,7 +61,7 @@ const struct PIPECFGREC {
EP1IN, /*EP1: Host <- Func, INT*/ EP1IN, /*EP1: Host <- Func, INT*/
7 | USB_FUNCTION_D1FIFO_USE, 7 | USB_FUNCTION_D1FIFO_USE,
USB_FUNCTION_INTERRUPT | USB_FUNCTION_INTERRUPT |
USB_FUNCTION_BFREOFF | USB_FUNCTION_BFREOFF |
USB_FUNCTION_DBLBOFF | USB_FUNCTION_DBLBOFF |
USB_FUNCTION_CNTMDOFF | USB_FUNCTION_CNTMDOFF |
USB_FUNCTION_SHTNAKOFF | USB_FUNCTION_SHTNAKOFF |
@ -79,7 +75,7 @@ const struct PIPECFGREC {
EP2OUT, /*EP2: Host -> Func, BULK*/ EP2OUT, /*EP2: Host -> Func, BULK*/
3 | USB_FUNCTION_D0FIFO_USE, 3 | USB_FUNCTION_D0FIFO_USE,
USB_FUNCTION_BULK | USB_FUNCTION_BULK |
USB_FUNCTION_BFREOFF | USB_FUNCTION_BFREOFF |
USB_FUNCTION_DBLBON | USB_FUNCTION_DBLBON |
USB_FUNCTION_CNTMDON | USB_FUNCTION_CNTMDON |
USB_FUNCTION_SHTNAKON | USB_FUNCTION_SHTNAKON |
@ -93,7 +89,7 @@ const struct PIPECFGREC {
EP2IN, /*EP2: Host <- Func, BULK*/ EP2IN, /*EP2: Host <- Func, BULK*/
4 | USB_FUNCTION_D1FIFO_USE, 4 | USB_FUNCTION_D1FIFO_USE,
USB_FUNCTION_BULK | USB_FUNCTION_BULK |
USB_FUNCTION_BFREOFF | USB_FUNCTION_BFREOFF |
USB_FUNCTION_DBLBOFF | USB_FUNCTION_DBLBOFF |
USB_FUNCTION_CNTMDON | USB_FUNCTION_CNTMDON |
USB_FUNCTION_SHTNAKOFF | USB_FUNCTION_SHTNAKOFF |
@ -107,7 +103,7 @@ const struct PIPECFGREC {
EP3OUT, /*EP3: Host -> Func, ISO*/ EP3OUT, /*EP3: Host -> Func, ISO*/
1 | USB_FUNCTION_D0FIFO_USE, 1 | USB_FUNCTION_D0FIFO_USE,
USB_FUNCTION_ISO | USB_FUNCTION_ISO |
USB_FUNCTION_BFREOFF | USB_FUNCTION_BFREOFF |
USB_FUNCTION_DBLBON | USB_FUNCTION_DBLBON |
USB_FUNCTION_CNTMDON | USB_FUNCTION_CNTMDON |
USB_FUNCTION_SHTNAKON | USB_FUNCTION_SHTNAKON |
@ -121,7 +117,7 @@ const struct PIPECFGREC {
EP3IN, /*EP3: Host <- Func, ISO*/ EP3IN, /*EP3: Host <- Func, ISO*/
2 | USB_FUNCTION_D1FIFO_USE, 2 | USB_FUNCTION_D1FIFO_USE,
USB_FUNCTION_ISO | USB_FUNCTION_ISO |
USB_FUNCTION_BFREOFF | USB_FUNCTION_BFREOFF |
USB_FUNCTION_DBLBON | USB_FUNCTION_DBLBON |
USB_FUNCTION_CNTMDON | USB_FUNCTION_CNTMDON |
USB_FUNCTION_SHTNAKOFF | USB_FUNCTION_SHTNAKOFF |
@ -240,12 +236,12 @@ USBHAL::USBHAL(void)
/* Initialize USB IP */ /* Initialize USB IP */
usb0_api_function_init(int_level, mode, clock_mode); usb0_api_function_init(int_level, mode, clock_mode);
{ {
uint16_t buf; uint16_t buf;
buf = USB200.INTENB0; buf = USB200.INTENB0;
buf |= USB_INTENB0_SOFE; buf |= USB_INTENB0_SOFE;
USB200.INTENB0 = buf; USB200.INTENB0 = buf;
} }
} }
/*************************************************************************/ /*************************************************************************/
@ -405,11 +401,11 @@ void USBHAL::EP0read(void)
uint8_t *buffer; uint8_t *buffer;
uint32_t size; uint32_t size;
/* remain of last writing */ /* remain of last writing */
while (EP0_read_status != DEVDRV_USBF_WRITEEND) { while (EP0_read_status != DEVDRV_USBF_WRITEEND) {
static uint8_t bbb[2] = { 255, 255 }; static uint8_t bbb[2] = { 255, 255 };
EP0write(&bbb[0], 0); EP0write(&bbb[0], 0);
} }
buffer = (uint8_t*)(&setup_buffer[4]); buffer = (uint8_t*)(&setup_buffer[4]);
size = (MAX_PACKET_SIZE_EP0 / 2) - 8; size = (MAX_PACKET_SIZE_EP0 / 2) - 8;
@ -431,41 +427,23 @@ void USBHAL::EP0write(uint8_t *buffer, uint32_t size)
{ {
/* zero byte writing */ /* zero byte writing */
if ( (size == 0) && (EP0_read_status == DEVDRV_USBF_WRITEEND) ) { if ( (size == 0) && (EP0_read_status == DEVDRV_USBF_WRITEEND) ) {
return; return;
} }
if (EP0_read_status == DEVDRV_USBF_WRITEEND) { if (EP0_read_status == DEVDRV_USBF_WRITEEND) {
/*1st block*/ /*1st block*/
EP0_read_status = usb0_api_function_CtrlReadStart(size, buffer); EP0_read_status = usb0_api_function_CtrlReadStart(size, buffer);
} else { } else {
/* waits the last transmission */ /* waits the last transmission */
/*other blocks*/ /*other blocks*/
g_usb0_function_data_count[ USB_FUNCTION_PIPE0 ] = size; g_usb0_function_data_count[ USB_FUNCTION_PIPE0 ] = size;
g_usb0_function_data_pointer [ USB_FUNCTION_PIPE0 ] = buffer; g_usb0_function_data_pointer [ USB_FUNCTION_PIPE0 ] = buffer;
EP0_read_status = usb0_function_write_buffer_c(USB_FUNCTION_PIPE0); EP0_read_status = usb0_function_write_buffer_c(USB_FUNCTION_PIPE0);
} }
/*max size may be deblocking outside*/ /*max size may be deblocking outside*/
if (size == MAX_PACKET_SIZE_EP0) { if (size == MAX_PACKET_SIZE_EP0) {
EP0_read_status = DEVDRV_USBF_WRITING; EP0_read_status = DEVDRV_USBF_WRITING;
}
#if defined(DEBUG_RZ_A1H)
{
static const int8_t *statmesg[] = {
"END",
"SHRT",
"ING",
"DMA",
};
printf(
"call: EP0write(%.4Xh,%d) %s (%d)\n",
(buffer[0] << 8) | buffer[1],
size,
statmesg[ EP0_read_status ],
g_usb0_function_CtrZeroLengthFlag );
} }
#endif
} }
@ -503,11 +481,6 @@ EP_STATUS USBHAL::endpointRead(uint8_t endpoint, uint32_t max_size)
status = EP_PENDING; status = EP_PENDING;
} }
#if defined(DEBUG_RZ_A1H)
printf( "call: endpointRead(%d,%d) pipe=%d status=%d\n",
endpoint, max_size, pipe, pipe_status );
#endif
return status; return status;
} }
@ -548,13 +521,6 @@ EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t *buffer, uint32_t
status = EP_COMPLETED; status = EP_COMPLETED;
} }
#if defined(DEBUG_RZ_A1H)
printf(
"call: endpointReadResult(%d,%p,%u)=%d pipe=%d status=%d\n",
endpoint, buffer, *bytes_read, err, pipe, pipe_status );
#endif
return status; return status;
} }
@ -566,19 +532,19 @@ EP_STATUS USBHAL::endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size)
uint32_t pipe_size; uint32_t pipe_size;
uint16_t pipe_status; uint16_t pipe_status;
uint16_t err; uint16_t err;
uint16_t count; uint16_t count;
EP_STATUS status = EP_PENDING; EP_STATUS status = EP_PENDING;
pipe_status = usb0_api_function_check_pipe_status(pipe, &pipe_size); pipe_status = usb0_api_function_check_pipe_status(pipe, &pipe_size);
/* waits the last transmission */ /* waits the last transmission */
count = 30000; count = 30000;
while ((pipe_status == DEVDRV_USBF_PIPE_WAIT) || (pipe_status == DEVDRV_USBF_PIPE_DONE)) { while ((pipe_status == DEVDRV_USBF_PIPE_WAIT) || (pipe_status == DEVDRV_USBF_PIPE_DONE)) {
pipe_status = usb0_api_function_check_pipe_status(pipe, &pipe_size); pipe_status = usb0_api_function_check_pipe_status(pipe, &pipe_size);
if( --count == 0 ) { if( --count == 0 ) {
pipe_status = DEVDRV_USBF_PIPE_STALL; pipe_status = DEVDRV_USBF_PIPE_STALL;
break; break;
} }
} }
switch (pipe_status) { switch (pipe_status) {
@ -613,12 +579,6 @@ EP_STATUS USBHAL::endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size)
break; break;
} }
#if defined(DEBUG_RZ_A1H)
printf(
"call: endpointWrite(%d,%p,%d)=%d pipe=%d status=%d\n",
endpoint, data, size, err, pipe, pipe_status );
#endif
return status; return status;
} }
@ -759,7 +719,7 @@ void USBHAL::usbisr(void)
(int_sts0 & USB_FUNCTION_BITSOFR) && (int_sts0 & USB_FUNCTION_BITSOFR) &&
(int_enb0 & USB_FUNCTION_BITSOFE)) { (int_enb0 & USB_FUNCTION_BITSOFE)) {
USB200.INTSTS0 = (uint16_t)~USB_FUNCTION_BITSOFR; USB200.INTSTS0 = (uint16_t)~USB_FUNCTION_BITSOFR;
SOF((USB200.FRMNUM & USB_FRMNUM_FRNM) >> USB_FRMNUM_FRNM_SHIFT); SOF((USB200.FRMNUM & USB_FRMNUM_FRNM) >> USB_FRMNUM_FRNM_SHIFT);
} else if ( } else if (
(int_sts0 & USB_FUNCTION_BITDVST) && (int_sts0 & USB_FUNCTION_BITDVST) &&
(int_enb0 & USB_FUNCTION_BITDVSE)) { (int_enb0 & USB_FUNCTION_BITDVSE)) {
@ -959,10 +919,6 @@ void USBHAL::usb0_function_save_request(void)
*bufO++ = USB200.USBINDX; *bufO++ = USB200.USBINDX;
/*data[6] data[6] <= wIndex*/ /*data[6] data[6] <= wIndex*/
*bufO++ = USB200.USBLENG; *bufO++ = USB200.USBLENG;
#if defined(DEBUG_RZ_A1H)
printf( "request: %.4xh\n", setup_buffer[0] );
#endif
} }
/****************************************************************************** /******************************************************************************
@ -1136,7 +1092,6 @@ void USBHAL::usb0_function_BEMPInterrupt(uint16_t status, uint16_t intenb)
USB200.BEMPSTS = (uint16_t)~g_usb0_function_bit_set[USB_FUNCTION_PIPE0]; USB200.BEMPSTS = (uint16_t)~g_usb0_function_bit_set[USB_FUNCTION_PIPE0];
RZA_IO_RegWrite_16(&USB200.CFIFOSEL, USB_FUNCTION_PIPE0, USB_CFIFOSEL_CURPIPE_SHIFT, USB_CFIFOSEL_CURPIPE); RZA_IO_RegWrite_16(&USB200.CFIFOSEL, USB_FUNCTION_PIPE0, USB_CFIFOSEL_CURPIPE_SHIFT, USB_CFIFOSEL_CURPIPE);
/*usb0_function_write_buffer_c(USB_FUNCTION_PIPE0);*/ /*usb0_function_write_buffer_c(USB_FUNCTION_PIPE0);*/
printf("<0>");
EP0in(); EP0in();
} else { } else {
usb0_function_bemp_int(status, intenb); usb0_function_bemp_int(status, intenb);

View File

@ -67,11 +67,11 @@ CS3_PERIPHERAL_BASE EQU 0x1c000000
; </h> ; </h>
UND_Stack_Size EQU 0x00000100 UND_Stack_Size EQU 0x00000100
SVC_Stack_Size EQU 0x00000100 SVC_Stack_Size EQU 0x00008000
ABT_Stack_Size EQU 0x00000100 ABT_Stack_Size EQU 0x00000100
FIQ_Stack_Size EQU 0x00000000 FIQ_Stack_Size EQU 0x00000100
IRQ_Stack_Size EQU 0x00000100 IRQ_Stack_Size EQU 0x00008000
USR_Stack_Size EQU 0x00000100 USR_Stack_Size EQU 0x00004000
ISR_Stack_Size EQU (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \ ISR_Stack_Size EQU (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \
FIQ_Stack_Size + IRQ_Stack_Size) FIQ_Stack_Size + IRQ_Stack_Size)