From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6959 invoked by alias); 26 Sep 2012 14:42:20 -0000 Received: (qmail 6773 invoked by uid 22791); 26 Sep 2012 14:42:17 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from hagrid.ecoscentric.com (HELO mail.ecoscentric.com) (212.13.207.197) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 26 Sep 2012 14:42:03 +0000 Received: from localhost (hagrid.ecoscentric.com [127.0.0.1]) by mail.ecoscentric.com (Postfix) with ESMTP id 061482FB082E for ; Wed, 26 Sep 2012 15:42:02 +0100 (BST) Received: from mail.ecoscentric.com ([127.0.0.1]) by localhost (hagrid.ecoscentric.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MkWyU3SJz0Rs; Wed, 26 Sep 2012 15:42:00 +0100 (BST) From: bugzilla-daemon@bugs.ecos.sourceware.org To: ecos-patches@ecos.sourceware.org Subject: [Bug 1001561] Internal flash driver for Freescale TWR-K60N512 board X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: eCos X-Bugzilla-Component: Patches and contributions X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jifl@ecoscentric.com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: low X-Bugzilla-Assigned-To: ilijak@siva.com.mk X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: In-Reply-To: References: X-Bugzilla-URL: http://bugs.ecos.sourceware.org/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 26 Sep 2012 14:42:00 -0000 Message-Id: <20120926144200.179E62F78001@mail.ecoscentric.com> Mailing-List: contact ecos-patches-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-patches-owner@ecos.sourceware.org X-SW-Source: 2012-09/txt/msg00014.txt.bz2 Please do not reply to this email. Use the web interface provided at: http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001561 --- Comment #48 from Jonathan Larmour 2012-09-26 15:41:56 BST --- Hi Ilija, Thanks for that. Unfortunately I've just noticed another issue (sorry!), but it's an important one to be resolved. There are calls to HAL_DCACHE_DISABLE(). But if the dcache is in writeback mode, you need to flush any dirty cache lines to memory, so a call to HAL_DCACHE_SYNC() is needed. And, as you'll probably have seen elsewhere in eCos, because of the risk of an interrupt coming in and creating more dirty cache lines after the sync but before the disable, you also need to disable interrupts around it. And you also need to allow for the cache already having been disabled (otherwise you may flush lines to memory which aren't actually valid for what's running). So in other words, you should have something like this: static void __attribute__((__long_call__)) cache_off( cyg_uint32 *cachestate ) { cyg_uint32 intstate, dcachestate, icachestate; HAL_DISABLE_INTERRUPTS(intstate); HAL_DCACHE_IS_ENABLED(dcachestate); HAL_ICACHE_IS_ENABLED(icachestate); *cachestate = (dcachestate?1:0) | (icachestate?2:0); if (dcachestate) { HAL_DCACHE_SYNC(); HAL_DCACHE_DISABLE(); } if (icachestate) { HAL_ICACHE_DISABLE(); } HAL_RESTORE_INTERRUPTS(intstate); #ifdef CYGNUM_DEVS_KINETIS_FLASH_LOGIC_ERROR_BUG disable_flash_optimisation(); #endif } You might also need a HAL_DCACHE_INVALIDATE_ALL() after the sync, before the disable, depending on whether the kinetis cache will still look at cache lines marked as valid in the cache, even when disabled (it may seem like it shouldn't but some cache architectures do do that!). Ditto for the icache. Given the separate cache_on/cache_off functions, you need the extra argument to pass around the cache state instead. To restore, for the Kinetis you probably don't need to disable interrupts I think because IIRC it doesn't do anything which would be a problem on interruption, so: static void __attribute__((__long_call__)) cache_on( cyg_uint32 *cachestate ) { #ifdef CYGNUM_DEVS_KINETIS_FLASH_LOGIC_ERROR_BUG enable_flash_optimisation(); #endif if (*cachestate & 1) HAL_DCACHE_ENABLE(); if (*cachestate & 2) HAL_ICACHE_ENABLE(); } Hopefully at least I've given enough code that this is an easy change for you to try out (since I don't have hardware :-)). Jifl -- Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.