Thomas,

#2958 just need short look to the code.

Watchdog might be the problem. K22FN1M0 can be programmed without problem because OpenOCD uses program section FTFE command. For programming by longword (FTFA variant) OpenOCD runs async
loader code and watchdog probably shoots it down.
Try to extract kinetis_disable_wdog(), ensure it detects you device and call it before longword programming
instead of cortex_m_poll()

VLPR is not active until you set LPBOOT option FOPT register (0x40d)
Patch should cover much more devices than K22.

FCF protection just protect against unintentional locking the chip if your code failed generate correct flash config field. Good thing to implement, but Freescale patch does not cover device lock after erase of first sector and reset.

Thanks for good work

Tom

On 30.09.2015 4:43, Thomas Schmid wrote:
Looking at the freescale patch that has this particular K22 working (well, partially, as resets don't work), here are a few differences I noticed that are specific to the K22:

- Watchdog: It looks like the K22 needs it's watchdog disabled. The Freescale patch does this in the cortex_m.c file upon a poll. This is clearly not a good place for it. Is there a function in the kinetis.c file that gets called upon a poll of the processor?

- Flash erase: The code checks the current run mode of the K22 before a erase. This might be what is going wrong that the flash in VLPR instead of RUN mode? Will investigate this tomorrow.

- FCF protection: This is not K22 specific, but the freescale code protects the FCF (Flash Control Field) in the flash. It warns if the uploaded code tries to write a different FCF then is stored in the chip. You have to specifically allow the write of the FCF in order to make it work. I think this is a good idea to implement.

And as reference, the Freescale patch is here:

http://openocd.zylin.com/gitweb?p=openocd.git;a=commitdiff;h=9bbb98b97a2dc0f2a5f93883a885388e56381cbd

- Thomas


On Tue, Sep 29, 2015 at 5:35 PM, Thomas Schmid <[email protected] <mailto:[email protected]>> wrote:

    Tomas,

    I am trying to add the new K22s. Detecting the DIEID is easy, and
    I noticed that I can't use the SECTION support to write the flash
    as that needs FlexRAM. The device currently uses the LONGWORD
    method to program the flash, but it doesn't seem to work. For some
    reason, every time I program the device, it ends up in secured state.

    Any idea what's going on? I use the exact same binary with the
    PEMicro programmer and pegdbserver without any issues, so the
    setting of the flash bits inside the elf file are not the problem.
    Do we need a special case for the K22 and erasing those flash
    bits? I remember seeing something like this in the Freescale
    version of openocd.

    - Thomas


    On Tue, Sep 29, 2015 at 4:34 PM, Thomas Schmid
    <[email protected] <mailto:[email protected]>> wrote:

        Tomas,

        Made a review for the earlier patch. Do I need a device with
        flexnvm to test 2958?


        - Thomas


        On Tue, Sep 29, 2015 at 3:21 AM, Paul Fertser
        <[email protected] <mailto:[email protected]>> wrote:

            Hey Tomas :)

            On Tue, Sep 29, 2015 at 11:06:21AM +0200, Tomas Vanek wrote:
            > And if you want to help,
            [2]http://openocd.zylin.com/#/c/2958/
            > needs a review - it is kind of trivial change and I'd like to 
have it merged
            > before I upload
            > new work: I fixed FlexNVM/data flash handling in Kinetis
            driver.

            Please feel free to simply declare kinetis patches ready
            when you feel
            like it, and I'll turn your +1s into +2s.

            --
            Be free, use free
            (http://www.gnu.org/philosophy/free-sw.html) software!
            mailto:[email protected] <mailto:[email protected]>





------------------------------------------------------------------------------
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to