From mboxrd@z Thu Jan 1 00:00:00 1970 From: Angelo Dureghello Date: Mon, 01 Aug 2011 01:12:07 +0200 Subject: [U-Boot] u-boot on mcf5307 In-Reply-To: <4E31DDC9.2060801@gmail.com> References: <4E31DDC9.2060801@gmail.com> Message-ID: <4E35E147.6080602@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 29/07/2011 00:08, Angelo Dureghello wrote: > Dear all, > > i succesfully added support for mcf5307, was quite easy, as you suggested i started from a m68k/cpu model with a very similar memory map. > > I am trying now to have the bootloader running in a custom board i developed: > MCF5307 > SDRAM 16M, mapped at 0x00000000 > FLASH 4M, mapped at 0xffc00000 > > The bootloader works great only if i don't enable timer2 for the clock/timestamp. > If timer2 is enabled i get the following error: > > > U-Boot 2011.06-rc2-dirty (Jul 28 2011 - 23:55:16) > > CPU: Freescale Coldfire MCF5307 at 90 MHz > Board: AMCORE v.001(alpha) > DRAM: 16 MiB > SDRAM test: > testing MB 01 ... > testing MB 02 ... > testing MB 03 ... > testing MB 04 ... > testing MB 05 ... > testing MB 06 ... > testing MB 07 ... > testing MB 08 ... > testing MB 09 ... > testing MB 10 ... > testing MB 11 ... > testing MB 12 ... > testing MB 13 ... > testing MB 14 ... > testing MB 15 ... > testing MB 16 ... > test passed ! > Flash: 4 MiB > > amcore$ > > *** Unexpected exception *** > Vector Number: 3 Format: 04 Fault Status: 4 > > PC: 00fe910a SR: 00002000 SP: 00ed8af0 > D0: 00002c1b D1: 0000001b D2: 00400000 D3: 00ee8b76 > D4: ffc12d08 D5: ffffffff D6: 00ffad57 D7: 00ee8b76 > A0: 00ee8b76 A1: 00fe9604 A2: 00ee8bc6 A3: 00ffd400 > A4: 00ff8167 A5: 00ffbb00 A6: 00ed8b48 > > *** Please Reset Board! *** > > > Debugging seems that the issue is returning from the timer interrupt handler, exactly here: > > > #define RESTORE_ALL \ > moveml %sp@,%d0-%d7/%a0-%a6; \ > addl #60,%sp; /* space for 15 regs */ \ > rte <<< ---- HERE , returning > > _int_handler: > SAVE_ALL > movel %sp,%sp at - > bsr int_handler > addql #4,%sp > RESTORE_ALL > > > The issue is very strange, everything works well, relocation to ram included, i test the SDRAM with cache disabled (then re-enabled), so there must be no issues on the memory. Calls and returning from C functions called in board_init_r also works fine, exception happen only returning from the interrupt. > > I am working on the issue, but every help is really appreciated. > > Regards, > angelo dureghello > > Hello, finally, i solved it. When a cpu behavior is strangely different from what the datasheet says (after reading it carefully many time), it worth a try to see the chip ERRATA: MCF5307ER.pdf says: 35 : Corrupted Return PC in Exception Stack Frame Using the workaround suggested (setting C/I bit of CS MASK register) solve the issue. This explain why all other coldfire models works with the same u-boot code without issues. Really hope this can help for who will have the same issue. I would be happy to share the m530x /cpu files, but i don't know the exact procedure used here. Let me know if and how i can contribute. regards Angelo D.