I have a rather old FRDM-K20D50M dev board, which I was hoping to reuse with Mbed-Studio (this board was once ok with MbedOS 2).
So when I plug it in via the OpenSDA connection, Mbed Studio still recognises the DAPlink connection. Happy days.
However, when I seek the build target it has the FRDM-K20D50M listed, but it is flagged as not compatible.
This is worse actually than not having it listed at all, because when I create a custom_targets.json and use the name FRDM-K20D50M, it still won’t accept.
So (first question) how do I delete that name from the unwanted list to allow me to create my custom target.
Personally, I cannot see why this board would be incompatible as it has same memory as an FRDM-KL25Z board (128 KB flash / 16 KB SRAM) and runs a wee bit faster, clocking at 50MHz rather than 48MHz for KL25Z.
All I have to do is change processor from M0 to, M4 for this board and then fiddle with macros.
So (2nd question) what are the steps after creating the custom_target file. What macro’s do I need to define. Then what about linking etc. to get it to flash onto the device.
Just to note that the documentation page does not look complete… it just stops at defining a custom_target. There has to be more.
In my experience, there’re basically two steps to creating a custom target. The first is to create custom_targets.json in your project root folder, and add your target to it. We can look at the old target definition of your board from Mbed 5.15 to get a pretty good idea of what needs to go in there. I think it would be something like:
The next thing you need to do is create a directory called TARGET_CustomK20D50M in the root directory of your project and put the porting files needed for your custom target in there. It looks like, in Mbed 6, they completely removed the TARGET_K20XX folder from the sources. So you’ll probably need to add both the files from this folder and its K20D50M subfolder to the custom target directory.
Note that these target files are now several years old, so I have no idea if they will work with Mbed 6 out of the box or not. If you do get them working, though, you might want to post them as a custom target so anyone can use the K20D50M!
Thanks! This is really helpful. I’ll let you know if I succeed. I have been experimenting, which is never a good idea. Hopefully I haven’t bricked the board… at the mo’ I’m getting the “mbed has crashed” blinking pattern. No doubt, I’ll find out soon enough with this new guidance.
You would be better off using Mbed2 online for the K20D50.
Since OS5 even with bare metal smaller targets suffer with too much flash and ram resources being used just to flash an LED.
Mbed Studio online should be okay too but haven’t tried it yet on the smaller devices.
I got it to compile after a few tweaks. There was a missing console_tx and console_rx for usb serial and a few missing lines of code but all resolvable.
However, I’m not sure if it’s my board (as in I damaged it in a previous hack attempt) or I’m still missing something as getting a fatal error after mbed studio uploads the binary.
++ MbedOS Error Info ++
Error Status: 0x80FF0144 Code: 324 Module: 255
Error Message: Assertion failed: !are_interrupts_enabled()
Location: 0x173F
File: ./mbed-os/hal/source/mbed_critical_section_api.c+54
Error Value: 0x0
For more info, visit: https://mbed.com/s/error?error=0x80FF0144&tgt=K20D50M
-- MbedOS Error Info --
UPDATE: I just unplugged the device and uploaded the code from Mbed Studio again and it works! Happy days.
I am rather curious to learn why the K20D50 “device_has” does not include “USTICKER” in the targets json file.
If I do not include it then the compiler complains as functions like us_ticker_irq_handler are undefined.
If I do include USTICKER it compiles but then functions like timer and ticker do not work as crashes the MCU.
Also wait_us does not appear to work either.