<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Data bus error in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Data-bus-error-solved/m-p/658095#M40348</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you are right on the mark!&lt;/P&gt;&lt;P&gt;Mass erase seems a bit complex on gdb but I'll try.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Jan 2017 15:24:55 GMT</pubDate>
    <dc:creator>Onemars</dc:creator>
    <dc:date>2017-01-31T15:24:55Z</dc:date>
    <item>
      <title>Data bus error (solved)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Data-bus-error-solved/m-p/658093#M40346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;on a FRDM-K64F demoboard I get an Hard Fault when reading the flash from 0xFE0C0 to 0xFE0CF and from 0xFF0C0 to 0xFF0CF, any other nearby byte can be read without errors. Reading a byte or a full word gives the same error.&lt;/P&gt;&lt;P&gt;From the CFSR register it seems the fault is caused by a "precise data bus error" and BFAR is at the location I'm trying to read.&lt;/P&gt;&lt;P&gt;This is the code, I'm using KDS with a new clean Kinetis SDK 2.x project:&lt;/P&gt;&lt;PRE&gt;static uint8_t* ptr;
static uint8_t b;
static uint8_t c[16];

int32_t main(void)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; BOARD_InitPins();
&amp;nbsp;&amp;nbsp;&amp;nbsp; BOARD_BootClockRUN();
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Ok:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptr = (uint8_t*)0xFE0BF;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = *ptr;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c[0] = b;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptr = (uint8_t*)0xFE0D0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = *ptr;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c[1] = b;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptr = (uint8_t*)0xFF0BF;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = *ptr;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c[2] = b;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptr = (uint8_t*)0xFF0D0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = *ptr;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c[3] = b;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Faults:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptr = (uint8_t*)0xFE0C0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = *ptr;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c[4] = b;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptr = (uint8_t*)0xFF0C0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = *ptr;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c[5] = b;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(;;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; __asm("NOP");
}&lt;/PRE&gt;&lt;P&gt;Am I doing something stupid or is my flash gone bad?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2017 13:59:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Data-bus-error-solved/m-p/658093#M40346</guid>
      <dc:creator>Onemars</dc:creator>
      <dc:date>2017-01-31T13:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Data bus error</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Data-bus-error-solved/m-p/658094#M40347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do a complete erase of the flash and try again. Such corruption is due to incorrect programming at some point (eg. trying to write a phrase which has already bits in it programmed to '0'. Afterwards the line of Flash is corrupt and hard-faults. After a complete erase it will be OK again (until any bad operation take place again).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2017 14:14:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Data-bus-error-solved/m-p/658094#M40347</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2017-01-31T14:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: Data bus error</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Data-bus-error-solved/m-p/658095#M40348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you are right on the mark!&lt;/P&gt;&lt;P&gt;Mass erase seems a bit complex on gdb but I'll try.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2017 15:24:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Data-bus-error-solved/m-p/658095#M40348</guid>
      <dc:creator>Onemars</dc:creator>
      <dc:date>2017-01-31T15:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Data bus error</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Data-bus-error-solved/m-p/658096#M40349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have difficulties with erasing, load code from here to the board&lt;BR /&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fkinetis%2FFRDM-K64F.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/kinetis/FRDM-K64F.html&lt;/A&gt;&lt;BR /&gt;and use its command line interface to erase sectors.&lt;BR /&gt;&lt;SPAN&gt;You can also experiment with reading, writing, erasing (and making errors in the process). See around 6:00 mark in this video to see the commands: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dc9GRYXFs9LU" rel="nofollow" target="_blank"&gt;https://www.youtube.com/watch?v=c9GRYXFs9LU&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2017 20:17:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Data-bus-error-solved/m-p/658096#M40349</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2017-01-31T20:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Data bus error</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Data-bus-error-solved/m-p/658097#M40350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark, problem solved! Thank you very much.&lt;BR /&gt;I was absorbed on OpenOCD and I've read your suggestion too late. By the way, good stuff! I'll try it asap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;About the flash erasing with OpenOCD, it is possible that the kinetis driver of OpenOCD is not able to automatically recognizes the second flash bank.&lt;BR /&gt;I'm not sure. I'll try to describe my experience, maybe it'll help somebody.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The chip on demoboard is a MK64FN1M0VLL12, it has 1M bytes flash in 2 blocks of 512K bytes.&lt;BR /&gt;&lt;A href="https://mcuoneclipse.com/2014/11/15/tutorial-how-to-erase-the-flash-with-the-gnu-debugger/"&gt;This article&lt;/A&gt; from Erich Styger was very useful, especially the comment by Joakim Fernstad.&lt;BR /&gt;Following Erich's guide, to fill everything (except m_flash_config) with 0xFF we need to write:&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;.space 0x000FFBF0, 0xff&lt;/SPAN&gt;&lt;BR /&gt;this compiles but gives an OpenOCD error, but if I change the length to 0x00080000 (512Kb) it works (unfortunately it is very slow).&lt;BR /&gt;After connecting with telnet to the debugger, you can list the banks:&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;&amp;gt; flash banks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;#0 : kinetis.flash (kinetis) at 0x00000000, size 0x00080000, buswidth 0, chipwidth 0&lt;/SPAN&gt;&lt;BR /&gt;So or this list is not updated after the automatic recognization or OpenOCD recognizes only the first 512Kb flash bank.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to configure both the two banks of the FDRM-K64F (based on &lt;A href="http://openocd.org/doc/html/Flash-Commands.html"&gt;this&lt;/A&gt;):&lt;BR /&gt;- go to &amp;lt;KDS folder&amp;gt;\openocd\scripts&lt;BR /&gt;- make a copy of 'kinetis.cfg' and rename it to 'kinetis_k64.cfg'&lt;BR /&gt;- open the 'kinetis_k64.cfg' change:&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;# Flash size is detected automatically.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;flash bank $_CHIPNAME.flash kinetis 0 0 0 0 $_TARGETNAME&lt;/SPAN&gt;&lt;BR /&gt;to:&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;# Configure flash banks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;flash bank $_CHIPNAME.flash1 kinetis 0 0x80000 0 0 $_TARGETNAME&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;flash bank $_CHIPNAME.flash2 kinetis 0x80000 0x80000 0 0 $_TARGETNAME&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Test:&lt;BR /&gt;- go to &amp;lt;KDS folder&amp;gt;\openocd\bin&lt;BR /&gt;- launch the debugger with:&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;openocd.exe -f kinetis_k64.cfg&lt;/SPAN&gt;&lt;BR /&gt;- the last line should be (with no errors):&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;Info : kinetis.cpu: hardware has 6 breakpoints, 4 watchpoints&lt;/SPAN&gt;&lt;BR /&gt;- open telnet with (probably you need to install it first, see 'enable disable windows features' or use Putty):&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;telnet localhost 4444&lt;/SPAN&gt;&lt;BR /&gt;- you should see:&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;Open On-Chip Debugger&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;&amp;gt;&lt;/SPAN&gt; &lt;BR /&gt;- type 'flash bank'&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;&amp;gt; flash banks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;#0 : kinetis.flash1 (kinetis) at 0x00000000, size 0x00080000, buswidth 0, chipwidth 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;#1 : kinetis.flash2 (kinetis) at 0x00080000, size 0x00080000, buswidth 0, chipwidth 0&lt;/SPAN&gt;&lt;BR /&gt;- if everything is ok, open your project and in the 'Config options' of the OpenOCD debugger (Debug Configurations window) change '-f kinetis.cfg' to '-f kinetis_k64.cfg'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to erase the second bank:&lt;BR /&gt;- in telnet type 'flash erase_sector 1 0 last':&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;&amp;gt; flash erase_sector 1 0 last&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;Probing flash info for bank 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;Any changes to flash configuration field will not take effect until next reset&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;erased sectors 0 through 127 on flash bank 1 in 3.601000s&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Warning! If you erase the first bank, the MCU will be secured and you need to do a mass erase to unsecure it (or drag and drop a working .bin example on the MBED drive or use Mark's tools!).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On a side note, this has also solved &lt;A _jive_internal="true" href="https://community.nxp.com/thread/442670"&gt;my previous problem&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Gabriele&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 08:48:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Data-bus-error-solved/m-p/658097#M40350</guid>
      <dc:creator>Onemars</dc:creator>
      <dc:date>2017-02-01T08:48:12Z</dc:date>
    </item>
  </channel>
</rss>

