Hi@MultipleMonomials
Thx for your lengthy explanation. I think I can relate to most of what you said.. but....
We are trying to get second flash working, and due to lack of proper understanding of the MCU/flash/and more, we end up with "bricked" boards quite easily. The good news is, that we are able to restore them quite easy nowadays, but I expected exactly what you said. The problem is on the program in flash. We simply should:
- boot to serial download by forcing the boot pins in a certain state,
- connect with JLink, erase,
- and go.
But that doesn't work. It DOES seem to work, when we upload a RAM app (e.g. blinky), and while the RAM app runs, we upload that very same app, but now to flash. Power cycle the board, and we're good to go.
But that's frustrating as hell. I want to know WHY and I can't seem to get to the actual truth.
As a little "proof" of what I am getting at, I hooked up an EVK1024 and:
- set the dipswitches to serial download.
- Power on the EVK,
- JLinkExe => connect
- mem32 0x60000000,10
I would expect some XIP bytes (because I just uploaded the nor flash SDK example a minute ago), but this is what JLink reads back:
J-Link>halt
PC = 0020C3B8, CycleCnt = 7F2B4488
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000010
R4 = 20207A3C, R5 = 401F4400, R6 = 401F4470, R7 = 00000000
R8 = 401F4470, R9 = 20203A00, R10= EE023426, R11= 00000000
R12= 00000001
SP(R13)= 20200FB0, MSP= 20200FB0, PSP= 00000000, R14(LR) = 0020C3B7
XPSR = 41000000: APSR = nZcvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
FPS0 = 00000000, FPS1 = 00000000, FPS2 = 00000000, FPS3 = 00000000
FPS4 = 00000000, FPS5 = 00000000, FPS6 = 00000000, FPS7 = 00000000
FPS8 = 00000000, FPS9 = 00000000, FPS10= 00000000, FPS11= 00000000
FPS12= 00000000, FPS13= 00000000, FPS14= 00000000, FPS15= FFFFFFFF
FPS16= 00000000, FPS17= 00000000, FPS18= 00000000, FPS19= 00000000
FPS20= 00000000, FPS21= 00000000, FPS22= 00000000, FPS23= 00000000
FPS24= 00000000, FPS25= 00000000, FPS26= 00000000, FPS27= 00000000
FPS28= 00000000, FPS29= 00000000, FPS30= 00000000, FPS31= FFFFFFFF
FPSCR= 00000000
J-Link>mem32 0x60000000
Syntax: mem32 <Addr>, <NumItems>
J-Link>mem32 0x60000000,10
60000000 = F3FC7C41 ACE2CBE0 F3FC7C41 ACE2CBE0
60000010 = F3FC7C41 ACE2CBE0 F3FC7C41 ACE2CBE0
60000020 = F3FC7C41 ACE2CBE0 F3FC7C41 ACE2CBE0
60000030 = F3FC7C41 ACE2CBE0 F3FC7C41 ACE2CBE0
That doesn't compute here. What the $%!@ is it reading now?
Well, lets be dumb, and erase anyway
J-Link>erase
No address range specified, 'Erase Chip' will be executed
'erase': Performing implicit reset & halt of MCU.
ResetTarget() start
Core did not halt on flash image verification. Assuming faulty flash settings.
Halting target manually.
ResetTarget() end - Took 316ms
AfterResetTarget() start
MPU was enabled and is now disabled.
AfterResetTarget() end - Took 701us
Erasing device...
****** Error: Timeout while erasing chip, RAMCode did not respond in time (PC = 0x2000048E, XPSR = 0x81000000, SP = 0x20000A48)!
Failed to erase chip.
Failed to execute RAMCode for chip erase!
J-Link: Flash download: Total time needed: 20.114s (Prepare: 0.064s, Compare: 0.000s, Erase: 20.006s, Program: 0.000s, Verify: 0.000s, Restore: 0.044s)
ERROR: Erase returned with error code -5.
It errors out, so it erased, but returns with -5.
When I now switch back to boot from FlexSPI, and read what is on flash, nothing changed, my SDK example is still sitting there, it runs. The first bytes on flash are XIP config bytes.
J-Link>halt
PC = 60006746, CycleCnt = 3B7612B0
R0 = 00000000, R1 = 402A8210, R2 = E000ED00, R3 = 00060200
R4 = 60002000, R5 = 7F907E2C, R6 = 002002C0, R7 = 2000FDF0
R8 = 401F4470, R9 = 20203A00, R10= 7F907E2C, R11= 00000000
R12= 00000000
SP(R13)= 2000FDD0, MSP= 2000FDD0, PSP= 20010000, R14(LR) = FFFFFFF9
XPSR = 61000003: APSR = nZCvq, EPSR = 01000000, IPSR = 003 (HardFault)
CFBP = 00000001, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 01
FPS0 = 00000000, FPS1 = 00000000, FPS2 = 00000000, FPS3 = 00000000
FPS4 = 00000000, FPS5 = 00000000, FPS6 = 00000000, FPS7 = 00000000
FPS8 = 00000000, FPS9 = 00000000, FPS10= 00000000, FPS11= 00000000
FPS12= 00000000, FPS13= 00000000, FPS14= 00000000, FPS15= FFFFFFFF
FPS16= 00000000, FPS17= 00000000, FPS18= 00000000, FPS19= 00000000
FPS20= 00000000, FPS21= 00000000, FPS22= 00000000, FPS23= 00000000
FPS24= 00000000, FPS25= 00000000, FPS26= 00000000, FPS27= 00000000
FPS28= 00000000, FPS29= 00000000, FPS30= 00000000, FPS31= FFFFFFFF
FPSCR= 00000000
J-Link>go
Memory map 'after startup completion point' is active
J-Link>mem32 0x60000000,10
60000000 = 42464346 56010400 00000000 00030300
60000010 = 00000000 00000000 00000000 00000000
60000020 = 00000000 00000000 00000000 00000000
60000030 = 00000000 00000000 00000000 00000000
I can't erase flash in serial download.
I can do whatever I want when booted from FlexSPI.
Why can't I erase flash in SD? Can you? Are you sure? My board is fine, I have many EVKs and custom boards here, they all behave the same. Well. I assume that to be honest, I did this experiment on 1 custom board and one EVK, both fail to erase in SD boot. With CPU in halt, or in run. It just won't erase. And... it reads "garbage".
Is this because we're using 1024s? They have some special note that DQS is not properly setup in ROM. I am just guessing here, dying to here facts from somebody