Friday, January 10, 2020

Getting Started with FRDM-K82F

FRDM-K82F is a low cost development platform using MK82FN256VLL15 microcontroller. When I started using the board according to its getting started guide at

Get Started with the FRDM-K82F [NXP16],

I found out that its out-of-box demo is not running on my version of FRDM-K82F board. The insturctions on that page are also out of date. And, I could not get it worked.

After spending my time testing, browing the Internet, and experimenting, I found out that the following things might be necessary, in a brief, to make the board worked.
  • Debug adapter - update it
  • IDE - use MCUXpresso instead of Kinetis Studio
  • SDK - use MCUXpresso SDK Builder (make sure to 'drag and drop')
  • Flash - unlock the MCU's flash if required



Figure. FRDM-K82F board.




Debug Adapter

FRDM-K82F has an on-board OpenSDA serial and debug adapter which uses MK20DX128xxx5 microcontroller based circuit. As mentioned at

Freedom OpenSDA Firmware Issues Reported on Windows 10 [NXP17],

the bootloader firmware can be accidentally corrupted by Windows 10. When you connect FRDM-K82F board to a computer using its OpenSDA USB port, you will see a mass storage device and a serial port in the computer. You can drag and drop a firmware in the mass storage drive to update the firmware for the debug adapter. Note that it is to update MK20DX128VLF5 firmware for the debug adapter, not MK82FN256VLL15 for the application.
You might accidentally brick the adapter if you put the wrong firmware there. And if your adapter has an older version bootloader, you need to update it first. The detailed instructions can be seen at

DAPLink bootloader update [MBED17],

When the name of the storage device becomes "MAINTENANCE", the DAPLink bootloader is up to date and you can update the firmware. Visit

OPENSDA: OpenSDA Serial and Debug Adapter [NXP-OpenSDA],

to see some of the latest firmware and instructions to update the firmware.
If you prefer Segger Jlink, you can visit to

Segger - J-Link / J-Trace Downloads [SEGGER-Downloads],

to get them. Install J-Link Software and Documentation Pack on your computer and use OpenSDA_FRDM-K82F for the debugger by dragging and dropping it onto the mass storage device after reconnecting the debugger without pressing the reset button (SW1).

MCUXpresso Integrated Development Environment (IDE)

As an Integrated Development Environment (IDE), you can download and use MCUXpresso which is available MCUXpresso Integrated Development Environment.



SDK

To get MCUXpresso SDK for K82F, you can visit to MCUXpresso SDK Builder,

build the SDK for FRDM-K82F, and download it. To install the SDK, open MCUXpresso IDE, and click on 'Install SDKs' tab which is at the bottom of the IDE. Thereafter, drag and drop the SDK onto it.


Figure. Install SDKs tab.




Unlocking flash

If you run an example that comes with the SDK, Jlink debugger will ask you to unlock the target chip i.e. MK82FN256xxx15. If it could not unlock the flash, you can open command window and enter the following commands to change directory to JLink location, connect to the device, read and unlock if necessary, erase, and load the binary application at address 0 which you want to put into K82 microcontroller.
> cd "C:\Program Files (x86)\SEGGER\JLink"
> .\JLink.exe -speed auto -device 'MK82FN256xxx15' -if SWD
J-Link> r
J-Link> unlock Kinetis
J-Link> erase
J-Link> loadbin prog.bin 0
J-Link> q




Recovering Bricked OpenSDA adapter

FRDM-K82F board has on-board debug adapter and when we use the command
>JLink.exe -speed auto -device 'MK82FN256xxx15' -if SWD
we are using MK20DX128xxx5 as Jlink adapter and MK82FN256xxx15 as a target device as illustrated in the following figure.


Figure. Normal configuration of debugger and target in FRDM-K82F.


When the bootloader in MK20DX128xxx5 is corrupted and is bricked, you can use an external debug probe such as LPC-Link2 to recover it. In that case, you need to connect LPC-Link2 as a debugger and MK20DX128xxx5 as a target as shown below.


Figure. LPC-Link2 as a debugger and MK20DX128xxx5 as a target.


Thereafter, you can use the following commands to load the bootloader firmware into it [NXP17].
> JLink.exe -speed auto -device 'MK20DX128xxx5' -if SWD
J-Link> r
J-Link> unlock Kinetis
J-Link> erase
J-Link> loadbin 0244_k20dx_bl_0x8000.bin 0
J-Link> q




Using External Debug Probe

You can also use an external debug probe to use MK82FN256xxx15 as a target directly as illustrated in the following figure.


Figure. Direct use of MK82FN256xxx15 with LPC-Link2 as a debug probe.


As illustrated in the above figure, J7 of LPC-Link2 is connected to J19 of K82. Jumper J6 and J7 must be removed to disconnect the onboard debugger.

The K82 board can also be used as external debug probe also. In this case, J6 and J7 must be on. And CLK copper trace on J17 (on the back) must be cut.

Producing Binary

MCUXpresso can also produce binary output. For that, you can click Project properties > C/C++ Build > Settings > Build steps tab > Edit button for Post-build steps. Thereafter, remove the comment character (#) as shown below.


Figure. Edit post-build steps.





Figure. Remove comment character '#'.




References

[NXP16] NXP, Get Started with the FRDM-K82F. 2016.
url: https://www.nxp.com/document/guide/get-started-with-the-frdm-k82f:NGS-FRDM-K82F.

[NXP17] NXP, Freedom OpenSDA Firmware Issues Reported on Windows 10. 2017.
url: https://community.nxp.com/docs/DOC-330935.

[MBED17] MBED, DAPLink bootloader update. 2017.
url: https://os.mbed.com/blog/entry/DAPLink-bootloader-update/.

[NXP-OpenSDA] NXP, OPENSDA: OpenSDA Serial and Debug Adapter.
url: https://www.nxp.com/design/microcontrollers-developer-resources/ides-for-kinetis-mcus/opensda-serial-and-debug-adapter:OPENSDA?&tid=vanOpenSDA#FRDM-K82F.

[SEGGER-Downloads] Segger, J-Link / J-Trace Downloads.
url: https://www.segger.com/downloads/jlink.

No comments:

Post a Comment

Comments are moderated and don't be surprised if your comment does not appear promptly.