Hi BlackNight, it's happened again in a different project, but might be slightly different since I'm unable to do anything to get the code to debug.
My MQX application calls into my EEPROM read/write code, for example something like this:
void Test_task(os_task_param_t task_init_data)
{
#ifdef PEX_USE_RTOS
while (1) {
#endif
uint16_t status;
while(1) {
TestNewEepromRead();
}
#ifdef PEX_USE_RTOS
}
#endif
}
int foo( uint32_t i, uint8_t *val)
{
return 0;
}
void TestNewEepromRead()
{
uint32_t max = pow( 2, 17);
for( int i=0; i<max; i++) {
uint8_t val;
//int ret = foo( i, &val);
int ret = Eeprom_Read( i, &val);
/*
assert( ret == 0);
assert( val == 0xFF);
*/
}
}
In my EEPROM C file, the code is completely commented out and just returns 0.
When I try to debug this program, GDB halts, but I'm able to capture the output stream if I copy and paste before the window is cleared.
SEGGER J-Link GDB Server V4.92 Command Line Version
JLinkARM.dll V4.92 (DLL compiled Sep 30 2014 09:33:42)
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: localhost only
Generate logfile: off
Verify download: on
Init regs on start: on
Silent mode: off
Single run mode: on
Target connection timeout: 5 sec.
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: MK22FN512xxx12
Target interface: SWD
Target interface speed: 30kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link OpenSDA 2 compiled Nov 28 2014 10:35:51
Hardware: V1.00
S/N: 621000000
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x00000000 (Data = 0x20010000)
Target interface speed set to 30 kHz
Resetting target
Halting target CPU...
...Target halted (PC = 0x00000410)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20010000, MSP= 20010000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 00000410
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Select auto target interface speed (1429 kHz)
Flash breakpoints enabled
Semi-hosting enabled (VectorAddr = 0x08)
Semihosting I/O set to TELNET Client
Read 4 bytes @ address 0x00000410 (Data = 0x49124811)
Downloading 1024 bytes @ address 0x00000000 - Verified OK
Downloading 16 bytes @ address 0x00000400 - Verified OK
Downloading 16144 bytes @ address 0x00000410 - Verified OK
Downloading 16144 bytes @ address 0x00004320 - Verified OK
Downloading 16092 bytes @ address 0x00008230 - Verified OK
Downloading 8 bytes @ address 0x0000C10C - Verified OK
Downloading 2188 bytes @ address 0x0000C114 - Verified OK
Read 4 bytes @ address 0x00000410 (Data = 0x49124811)
Read 2 bytes @ address 0x00000000 (Data = 0x0000)
Read 2 bytes @ address 0x00000002 (Data = 0x2001)
Read 2 bytes @ address 0x00000004 (Data = 0x0411)
Read 2 bytes @ address 0x00000006 (Data = 0x0000)
Read 2 bytes @ address 0x00000008 (Data = 0x0685)
Read 2 bytes @ address 0x0000000A (Data = 0x0000)
Read 2 bytes @ address 0x0000000C (Data = 0x0685)
Read 2 bytes @ address 0x0000000E (Data = 0x0000)
Read 2 bytes @ address 0x00000010 (Data = 0x0685)
Read 2 bytes @ address 0x00000012 (Data = 0x0000)
Read 2 bytes @ address 0x00000014 (Data = 0x0685)
Read 2 bytes @ address 0x00000016 (Data = 0x0000)
Read 2 bytes @ address 0x00000018 (Data = 0x0685)
Read 2 bytes @ address 0x0000001A (Data = 0x0000)
Read 2 bytes @ address 0x0000001C (Data = 0x0000)
Read 2 bytes @ address 0x0000001E (Data = 0x0000)
Read 2 bytes @ address 0x00000020 (Data = 0x0000)
Read 2 bytes @ address 0x00000022 (Data = 0x0000)
Read 2 bytes @ address 0x00000024 (Data = 0x0000)
Read 2 bytes @ address 0x00000026 (Data = 0x0000)
Read 2 bytes @ address 0x00000028 (Data = 0x0000)
Read 2 bytes @ address 0x0000002A (Data = 0x0000)
Read 2 bytes @ address 0x0000002C (Data = 0x0499)
Read 2 bytes @ address 0x0000002E (Data = 0x0000)
Read 2 bytes @ address 0x00000030 (Data = 0x0685)
Read 2 bytes @ address 0x00000032 (Data = 0x0000)
Read 2 bytes @ address 0x00000034 (Data = 0x0000)
Read 2 bytes @ address 0x00000036 (Data = 0x0000)
Read 2 bytes @ address 0x00000038 (Data = 0x051B)
Read 2 bytes @ address 0x0000003A (Data = 0x0000)
Read 2 bytes @ address 0x0000003C (Data = 0x0455)
Read 2 bytes @ address 0x0000003E (Data = 0x0000)
GDB closed TCP/IP connection
If I comment out the call into my EEPROM C file and just call foo, which has the exact same function signature as Eeprom_Read(), the debugger runs just fine. So this makes me think there is something wrong with linking, but I'm not sure where to go from here. I compared the two MAP files, but to me they look reasonable enough. I've attached them to this post in case they are useful to you.
I've also looked at the output when the debugger works, and there is a lot more traffic over the J-Link connection, i.e. the "bad" scenario cuts off very early. I attached the "good" GDB output as well.
Any assistance you can provide on this would be really appreciated, as I fear this might happen more and more as I continue to create applications. Thank you!