Join me as I enjoy mbedding!! 😉 The mbed platform contains the libraries you need to set up a project for ARM microcontrollers, including the FRDM-KL25Z… The Application Programming Interfaces (API’s) above the Hardware abstraction Layer (HAL) that make the process of creating an embedded application trivial. You merely just write C++ code in your main function after including the mbed header file. This means if you have a new target, you can do the HAL, port it to mbed and continue enjoying the API in the platform. What I love about it is that even though the firmware provided by Freescale for programming the KL25Z target in the freedom board is tied to the id of the target on the board, mbed firmware allows you to program an external target chip (i am yet to verify this). Get where I am going with this? I wanna buy the microcontrollers and make custom boards, there are opensource tool-chains, and keep exploring…
-
Go to the working directory:
cd src/git/
-
Create a directory for mbed repo:
mkdir mbed
-
Clone the mbed repo
git clone https://github.com/mbedmicro/mbed.git mbed/
-
Get into the mbed directory:
cd mbed
-
Create a private settings file. this helps set some custom configs instead of editing the main settings file.
gedit workspace_tools/private_settings.py
Set
“GCC_ARM_PATH=&quo;/usr/bin/&quo;”, or the path to where you installed it, save and close. Make sure you use quotation marks, see comment at the end of the post.
-
Generate the mbed appliction sources, which is building the libraries:
python workspace_tools/build.py -m KL25Z -t GCC_ARM >>> BUILD LIBRARY CMSIS (KL25Z, GCC_ARM) >>> BUILD LIBRARY MBED (KL25Z, GCC_ARM) Completed in: (0.26)s Build successes: * GCC_ARM::KL25Z
- Install Eclipse juno as described in this post for the installation of eclipse Kepler. I have no idea if Kepler would work, I just installed juno instead to be on the safe side as it was the release used in the reference post. You should try Kepler and comment here ;).
- create a new eclipse c++ application, choose cross compiler, arm-none-eabi-gcc and arm-none-eabi-g++ select debug and disselect release configuration. finish.
- In the project folder, create a source folder, named src.
-
Copy paste the build/mbed/ folder into the project’s source folder, src
cp -r build/mbed/ ../FRDM_workspace/mbedtest/src/
- Go to project settings, under C/C++ build, uncheck Generate Makefiles automatically and set the Build Location build folder to src in my case: ${workspace_loc:/mbedtest}/src/
- Place this makefile in your src folder
- In the make file, change the variable DEVICE = /media/user/MBED/ replacing “user” with your system username. it is the mount folder of your mbed device. In older Ubuntu versions, the path used to be /media/REMOVABLE_DEVICE_NAME/.
-
Create a file main.cpp in the src folder and paste the following code, save and close
#include "mbed.h" Serial s(USBTX, USBRX); DigitalOut led(LED1); PwmOut ledpwm(LED1); int main() { ledpwm=0; led=1; s.printf("Hey, this is test: "); while(1) { ledpwm=ledpwm+0.1; wait(0.8); if(ledpwm==1){ s.printf("offn"); wait(0.2); ledpwm=0; } } }
- Make sure your FRDM-KL25z board is plugged in then click on the build button. The program should build and get flashed into the target successfully.
This app pulses and dims the LED as well as reporting the status when LED is finally at zero brightness through the UART serial link which can be monitored using a terminal app like gtkterm, and i guess minicom.
Reference:
Update: Tested with Eclipse Kepler, works just fine
CDT Build Console:
20:45:42 **** Incremental Build of configuration Debug for project mbedtest ****
make all
Building file: main.o
Invoking: MCU C++ Compiler
/usr/bin/arm-none-eabi-g++ -g -ggdb -Os -Wall -fno-strict-aliasing -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-delete-null-pointer-checks -fmessage-length=0 -fno-builtin -mthumb -mcpu=cortex-m0 -MMD -MP -DTARGET_KL25Z -DTOOLCHAIN_GCC_ARM -DNDEBUG -MF out/main.d -I. -Imbed -Imbed/TARGET_KL25Z -Imbed/TARGET_KL25Z/TOOLCHAIN_GCC_ARM -I. -std=gnu++98 -c main.cpp -o out/main.o
Finished building: main.o
Building target: out/mbed.elf
Invoking: MCU Linker
/usr/bin/arm-none-eabi-gcc -mcpu=cortex-m0 -mthumb -Os -L mbed/TARGET_KL25Z/TOOLCHAIN_GCC_ARM -T mbed/TARGET_KL25Z/TOOLCHAIN_GCC_ARM/MKL25Z4.ld -I. -Imbed -Imbed/TARGET_KL25Z -Imbed/TARGET_KL25Z/TOOLCHAIN_GCC_ARM -I. -specs=nano.specs -u _printf_float -u _scanf_float -Wl,-Map=out/mbed.map,--gc-sections out/main.o mbed/TARGET_KL25Z/TOOLCHAIN_GCC_ARM/cmsis_nvic.o mbed/TARGET_KL25Z/TOOLCHAIN_GCC_ARM/startup_MKL25Z4.o mbed/TARGET_KL25Z/TOOLCHAIN_GCC_ARM/retarget.o mbed/TARGET_KL25Z/TOOLCHAIN_GCC_ARM/system_MKL25Z4.o -lmbed -lstdc++ -lsupc++ -lm -lgcc -lc -lnosys -o out/mbed.elf
Finished building target: out/mbed.elf
Copying out/mbed.elf to /media/karibe/MBED/
Printing size
arm-none-eabi-size --totals out/mbed.elf
text data bss dec hex filename
43204 224 712 44140 ac6c out/mbed.elf
43204 224 712 44140 ac6c (TOTALS)
arm-none-eabi-objcopy -O srec out/mbed.elf out/mbed.s19
arm-none-eabi-objcopy -O binary -v out/mbed.elf out/mbed.bin
copy from `out/mbed.elf' [elf32-littlearm] to `out/mbed.bin' [binary]
arm-none-eabi-objdump -D out/mbed.elf > out/mbed.lst
arm-none-eabi-nm out/mbed.elf > out/mbed-symbol-table.txt
20:45:43 Build Finished (took 559ms)
Hello,
great it works for you!
Welcome to mbed !
Regards,
0xc0170
hello 0xc0170, mbed is interesting, i will keep a close follow up for my students to adopt implementing projects. Thanks to people like you 🙂
Thanks, it helps me a lot.
Btw, you missed the double quotes for the path configuration of GCC : GCC_ARM_PATH=/usr/bin/ -> GCC_ARM_PATH=”/usr/bin/”
av found the source 4 the original link …at this point my eclipse is not installing the new software…..
On the Help menu, select the Install New Software… option.
On the install dialog, press the Add… button near the upper right hand corner.
Set Name: to Eclipse for ARM.
Set Location: to http://sourceforge.net/projects/gnuarmeclipse/files/Eclipse/updates/
Click the Ok button.
There should now be a CDT GNU Cross Development Tools item listed on the Install dialog. It may take several seconds to populate this item into the list. Once it appears, check it.
Now press the Next button.
At this point an install wizard appears. You can just keep clicking through this wizard to allow it to progress.
At some point it will complain about unsigned content. Ignore this warning by pressing the Ok button.
At the end of the install wizard, press the Restart Now button.
SO I DONT KNOW IF I CAN STILL MOVE FORWARD
Yeah, after you restart eclipse thats what is supposed to happen. you can check that you have the plugin. You can go to Help-> about eclipse [screenshot]: http://karibe.co.ke/?p=1095. You will see a list of icons on that dialog at the bottom, click on the one for GNU-ARM if its there [screenshot]: http://karibe.co.ke/?p=1096
just gives me Pending but no outcome
BTW if you already had Eclipse installed and configured with the GNU-ARM tool-chain plugin, which am sure you have, you don’t need to do it again 🙂