void NULL_Pointer_Write() { GLOBAL_LOCK(irq); UINT32* ResetVector = 0; lcd_printf("\fERROR:\r\nNULL Pointer write\r\nRESET vector modified to 0x%08x\r\n", *ResetVector); monitor_debug_printf("ERROR: vector area modified\r\n"); // dump many words for(int i = 0; i < 0x100; i++) { monitor_debug_printf("0x%08x=0x%08x\r\n", (UINT32) ResetVector, *ResetVector); } CPU_Halt(); }
void FAULT_HandlerDisplay( UINT32 *registers, UINT32 exception ) { int i; USART_Initialize( ConvertCOM_ComPort(USART_DEFAULT_PORT), USART_DEFAULT_BAUDRATE, USART_PARITY_NONE, 8, USART_STOP_BITS_ONE, USART_FLOW_NONE ); if (exception) { monitor_debug_printf("EXCEPTION 0x%02x:\r\n", exception); } else { monitor_debug_printf("ERROR:\r\n"); } monitor_debug_printf(" cpsr=0x%08x\r\n", registers[15]); monitor_debug_printf(" pc =0x%08x\r\n", registers[14]); monitor_debug_printf(" lr =0x%08x\r\n", registers[13]); monitor_debug_printf(" sp =0x%08x\r\n", registers + 16); for(i = 0; i <= 12; i++) { monitor_debug_printf(" r%02d =0x%08x\r\n", i, registers[i]); } }
void ABORT_HandlerDisplay( UINT32 *registers_const, UINT32 sp, UINT32 lr, UINT32 pc_offset, const char *Title, BOOL SerialOutput ) { UINT32 cpsr; UINT32 pc; int i; int j; #if !defined(PLATFORM_ARM_OS_PORT) UINT8* stackbytes; const UINT32* const stackwords = (UINT32 *)sp; #endif int page; UINT32* registers; #if defined(PLATFORM_ARM_MC9328) UINT32 URXDn_X; MC9328MXL_USART& USART = MC9328MXL::USART( ConvertCOM_ComPort(USART_DEFAULT_PORT) ); #else // TODO ??? #endif ++ABORT_recursion_counter; dump_again: page = 0; registers = registers_const; cpsr = *registers++; pc = (*registers++) - pc_offset; if(SerialOutput) { // unprotect the GPIO pins for USART, allowing USART output USART_Initialize( ConvertCOM_ComPort(USART_DEFAULT_PORT), USART_DEFAULT_BAUDRATE, USART_PARITY_NONE, 8, USART_STOP_BITS_ONE, USART_FLOW_NONE ); monitor_debug_printf("ERROR: %s\r\n", Title); monitor_debug_printf(" cpsr=0x%08x\r\n", cpsr); monitor_debug_printf(" pc =0x%08x\r\n", pc); monitor_debug_printf(" lr =0x%08x\r\n", lr); for(i = 0; i <= 12; i++) { monitor_debug_printf(" r%d=0x%08x\r\n", i, registers[i]); } monitor_debug_printf(" sp =0x%08x\r\n", sp); RegisterDump(); } // don't let the screen go away if the watchdog was enabled. Watchdog_Disable(); //Flash_ChipReadOnly(TRUE); // first dump stuff to the com port, then go interactive with the buttons and LCD if(SerialOutput) { monitor_debug_printf("ERROR: %s\r\n", Title); monitor_debug_printf(" cpsr=0x%08x\r\n", cpsr); monitor_debug_printf(" pc =0x%08x\r\n", pc); monitor_debug_printf(" lr =0x%08x\r\n", lr); for(i = 0; i <= 12; i++) { monitor_debug_printf(" r%d=0x%08x\r\n", i, registers[i]); } monitor_debug_printf(" sp =0x%08x\r\n", sp); #if !defined(PLATFORM_ARM_OS_PORT) stackbytes = (UINT8 *)sp; for(i = 0; i < 16; i++) { monitor_debug_printf("[0x%08x] :", (UINT32)&stackbytes[i*16]); for(j = 0; j < 16; j++) { // don't cause a data abort here! if((UINT32) &stackbytes[i*16 + j] < (UINT32) &StackTop) { monitor_debug_printf(" %02x", stackbytes[i*16 + j]); } else { monitor_debug_printf(" "); } } monitor_debug_printf(" "); for(j = 0; j < 16; j++) { if((UINT32) &stackbytes[i*16 + j] < (UINT32) &StackTop) { monitor_debug_printf("%c", (stackbytes[i*16 + j] >= ' ') ? stackbytes[i*16 + j] : '.'); } } monitor_debug_printf("\r\n"); } #endif } //--// // make sure USART is ready to go (clock enabled, pins set active) regardless of charger state, idem potent call if it was already on CPU_ProtectCommunicationGPIOs( FALSE ); #if defined(PLATFORM_ARM_MC9328) while(USART.URXDn_X[0] & MC9328MXL_USART::URXDn__CHARRDY); #else // TODO ??? #endif //--// // go interactive with the buttons and LCD while(true) { UINT32 CurrentButtonsState; lcd_printf("\f"); switch(page) { case 0: lcd_printf("%-12s \r\n\r\n", Title); lcd_printf("Build Date:\r\n"); lcd_printf("%-12s \r\n" , __DATE__); lcd_printf("%-12s \r\n" , __TIME__); lcd_printf("\r\n"); lcd_printf("cps=0x%08x\r\n", cpsr); lcd_printf("pc =0x%08x\r\n", pc); lcd_printf("lr =0x%08x\r\n", lr); lcd_printf("sp =0x%08x\r\n", sp); break; case 1: lcd_printf("Registers 1\r\n\r\n"); for(i = 0; i < 10; i++) { lcd_printf("r%1d =0x%08x\r\n", i, registers[i]); } break; case 2: lcd_printf("Registers 2\r\n\r\n"); for(i = 10; i < 13; i++) { lcd_printf("r%2d=0x%08x\r\n", i, registers[i]); } break; case 3: default: { #if !defined(PLATFORM_ARM_OS_PORT) UINT32 index = (page-3)*10; lcd_printf("Stack %08x\r\n\r\n", (UINT32)&stackwords[index]); for(i = 0; i < 10; i++) { stackbytes = (UINT8 *)&stackwords[index+i]; // don't cause a data abort displaying past the end of the stack! if((UINT32) &stackwords[index+i] < (UINT32) &StackTop) { lcd_printf("%08x %c%c%c%c\r\n", stackwords[index+i], (stackbytes[0] >= ' ') ? stackbytes[0] : '.', (stackbytes[1] >= ' ') ? stackbytes[1] : '.', (stackbytes[2] >= ' ') ? stackbytes[2] : '.', (stackbytes[3] >= ' ') ? stackbytes[3] : '.' ); } else { lcd_printf(" \r\n"); } } #endif } break; } // wait for a button press while(0 == (CurrentButtonsState = Buttons_CurrentHWState())) { #if defined(PLATFORM_ARM_MC9328) if(USART.URXDn_X[0] & MC9328MXL_USART::URXDn__CHARRDY) { goto StartMonitorMode; } #else // TODO ??? #endif } // wait for 10 mSec HAL_Time_Sleep_MicroSeconds(10000/64); // wait for it to release while(0 == (CurrentButtonsState ^ Buttons_CurrentHWState())); // wait for 10 mSec HAL_Time_Sleep_MicroSeconds(10000/64); if(CurrentButtonsState & BUTTON_B5) { page = (page + 1); // no limit of stack pages LCD_Clear(); } if(CurrentButtonsState & BUTTON_B2) { page = (page > 0) ? page - 1 : 0; LCD_Clear(); } if((CurrentButtonsState & BUTTON_B4) || (CurrentButtonsState & BUTTON_B0)) { goto dump_again; } continue; #if defined(PLATFORM_ARM_MC9328) StartMonitorMode: #endif { char data[16]; UINT32 pos = 0; LCD_Clear(); lcd_printf("\fMONITOR MODE\r\n"); HAL_Time_Sleep_MicroSeconds(10000); while(1) { #if defined(PLATFORM_ARM_MC9328) URXDn_X = USART.URXDn_X[0]; if(URXDn_X & MC9328MXL_USART::URXDn__CHARRDY) { data[pos++] = (char)(URXDn_X & MC9328MXL_USART::URXDn__DATA_mask); #else if(false) { // TODO ??? #endif switch(data[0]) { case 'L': monitor_debug_printf("rb=0x%08x\r\n", HalSystemConfig.RAM1.Base ); monitor_debug_printf("rs=0x%08x\r\n", HalSystemConfig.RAM1.Size ); monitor_debug_printf("fb=0x%08x\r\n", HalSystemConfig.FLASH.Base); monitor_debug_printf("fs=0x%08x\r\n", HalSystemConfig.FLASH.Size); break; case 'M': if(pos < 12) continue; { UINT8* start = *(UINT8**)&data[4]; UINT8* end = *(UINT8**)&data[8]; lcd_printf( "\f\r\n\r\nREAD:\r\n %08x\r\n %08x", (UINT32)start, (UINT32)end ); if(AbortHandler_CheckMemoryRange( start, end )) { while(start < end) { monitor_debug_printf("[0x%08x]", (UINT32)start); for(j = 0; j < 128; j++) { monitor_debug_printf("%02x", *start++); if(start == end) break; } monitor_debug_printf("\r\n"); } } else { monitor_debug_printf("ERROR: invalid range: %08x-%08x\r\n", (UINT32)start, (UINT32)end ); } } break; case 'R': for(i = 0; i <= 12; i++) { monitor_debug_printf("r%d=%08x\r\n", i, registers[i]); } monitor_debug_printf("sp=%08x\r\n", sp); monitor_debug_printf("lr=%08x\r\n", lr); monitor_debug_printf("pc=%08x\r\n", pc); monitor_debug_printf("cpsr=%08x\r\n", cpsr); #if defined(PLATFORM_ARM_MC9328) monitor_debug_printf("BWA=%08x\r\n", 0); monitor_debug_printf("BWC=%08x\r\n", 0); #else // TODO ??? #endif break; case '\r': case '\n': case ' ': break; default: monitor_debug_printf("ERROR: unknown command %c\r\n", data[0] ); break; } pos = 0; } else if(Buttons_CurrentHWState()) { // wait for it to release while (Buttons_CurrentHWState()); LCD_Clear(); break; } } } } } #endif // !defined(ABORTS_REDUCESIZE) extern "C" { void UNDEF_Handler( UINT32* registers, UINT32 sp, UINT32 lr ) { ASSERT_IRQ_MUST_BE_OFF(); #if !defined(ABORTS_REDUCESIZE) Verify_RAMConstants((void *) FALSE); ABORT_HandlerDisplay(registers, sp, lr, 4, "Undef Instr", TRUE); CPU_Halt(); #else CPU_Reset(); #endif // !defined(ABORTS_REDUCESIZE) }