Linux, gcc, and the FRDM-KL25Z

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Linux, gcc, and the FRDM-KL25Z

12,970 次查看
gdb
Contributor I

Hi all,

 

It took me a while to figure out how to build even a blinky-LED app for the FRDM-KL25Z using gcc from the Linux command-line, so maybe someone else will find the attached tar file useful.  It contains a Makefile, header file, startup code, linker script, and blinky-LED app which I put together from various places.  At least for me, I can now type "make" and "cp main.srec /media/FRDM-KL25Z" to build and upload.  I used the Linux ARM GCC binaries from GCC ARM Embedded in Launchpad

 

Have fun,

G.

Original Attachment has been moved to: test-frdm-kl25z.tar.gz

标签 (1)
标记 (4)
17 回复数

4,185 次查看
kai_liu
Senior Contributor I

Hi, gdb

Do you have any working CPP demo on KL25Z now? I have similar thread here: Re: Any G++ CPP demo project running on KL?

Allan K Liu

0 项奖励
回复

4,185 次查看
kai_liu
Senior Contributor I

For public,

The CPP demo is working now. (arm-gcc-none-eabi + Eclipse Kelper CDT + PEmicro gdbserver basic + Windows XP). Makefile has not been released, but will be available soon.

0 项奖励
回复

4,185 次查看
kai_liu
Senior Contributor I

Hi,

Maybe my question is a little off-topic. I want to run an open source project on Windows as well.

I downloaded Github project payne92/bare-metal-arm · GitHub, and tried to build it in Windows. The windows version of gcc-arm is used and makefile is updated for toolchain path.

GCCBIN = C:/gcc-arm/gcc-arm-none-eabi-4_7-2013q1-20130313-win32/bin

CC = $(GCCBIN)/arm-none-eabi-gcc

AR = $(GCCBIN)/arm-none-eabi-ar

OBJCOPY = $(GCCBIN)/arm-none-eabi-objcopy

OBJDUMP = $(GCCBIN)/arm-none-eabi-objdump

SIZE = $(GCCBIN)/arm-none-eabi-size

RM = rm

DEBUG_OPTS = -g3 -gdwarf-2

OPTS = -Os

TARGET = -mcpu=cortex-m0

CFLAGS = -ffunction-sections -fdata-sections -Wall -Wa,-adhlns=$(addsuffix .lst, $(basename $<)) \

  -fmessage-length=0 $(TARGET) -mthumb -mfloat-abi=soft \

  $(DEBUG_OPTS) $(OPTS) -I .

LIBOBJS = _startup.o syscalls.o uart.o delay.o accel.o touch.o usb.o \

  ring.o tests.o

#LIBOBJS = _startup.o syscalls.o uart.o delay.o accel.o touch.o usb.o ring.o

INCLUDES = freedom.h common.h

#all: demo.srec demo.dump

all: demo.dump demo.srec

libbare.a: $(LIBOBJS)

  $(AR) -rv libbare.a $(LIBOBJS)

clean:

  $(RM) *.o *.lst *.out libbare.a *.srec *.dump

%.o: %.c

  $(CC) $(CFLAGS) -c $<

%.dump: %.out

  $(SIZE) $<

  $(OBJDUMP) --disassemble $< >$@

%.srec: %.out

  $(OBJCOPY) -O srec $< $@

  $(SIZE) $@

%.out: %.o mkl25z4.ld libbare.a

  $(CC) $(CFLAGS) -T mkl25z4.ld -o $@ $< libbare.a

I can build it successfully. but the demo.out demo.o will be removed anyway. But I can not find it in makefile.

C:/gcc-arm/gcc-arm-none-eabi-4_7-2013q1-20130313-win32/bin/arm-none-eabi-size demo.out

   text    data     bss     dec     hex filename

  21644    2268     440   24352    5f20 demo.out

C:/gcc-arm/gcc-arm-none-eabi-4_7-2013q1-20130313-win32/bin/arm-none-eabi-objdump --disassemble demo.out >demo.dump

C:/gcc-arm/gcc-arm-none-eabi-4_7-2013q1-20130313-win32/bin/arm-none-eabi-objcopy -O srec demo.out demo.srec

C:/gcc-arm/gcc-arm-none-eabi-4_7-2013q1-20130313-win32/bin/arm-none-eabi-size demo.srec

   text    data     bss     dec     hex filename

      0   23912       0   23912    5d68 demo.srec

rm demo.o demo.out

How can I keep demo.o demo.out after building project?

0 项奖励
回复

4,185 次查看
BlackNight
NXP Employee
NXP Employee

This is the make file I'm using and this works for me:

DIY Free Toolchain for Kinetis: Part 1 – GNU ARM Build Tools | MCU on Eclipse

0 项奖励
回复

4,185 次查看
kai_liu
Senior Contributor I

Thanks, Erich,

I found many useful code from your Github projects.

Yours sincerely

Allan K Liu

0 项奖励
回复

4,185 次查看
gbd
Contributor II

I'm struggling to get the suggestions mentioned above to work. I've built the "bare-metal-arm" and went through the following to try and get things working-

1. git clone https://github.com/payne92/bare-metal-arm

2. cd bare-metal-arm; make gcc-arm

3. make

4. cd /dev; ls sd*; --> provides me with the sd port (for example 'sdb')

5. plug in the micro usb to the SDA port

6. mkdir ~/kl25z

7. sudo mount -t vfat /dev/sdb ~/kl25z

8. cp ~/bare-metal-arm/demo.srec ~/kl25z

The RBG led turns green which makes me think the program has loaded correctly... I tried to run 'screen /dev/sdb 115200' but it fails. Could someone please tell me how to get output from the KL25Z board?

Also, I updated the OpenSDA firmware to 1.06 and now I can only see the SDA block in debug mode (holding reset while plugging in the board).

Any help would be greatly appreciated.

Thanks!

0 项奖励
回复

4,185 次查看
larsknudsen
Contributor II

Hi,

The device you are listening on seems wrong. Try /dev/ttyACMn, where n is

the one assigned to the serial connection for the board (check system

messages for which one it is for you)

Be

Lars

On May 28, 2013 12:19 PM, "gregdeemer" <admin@community.freescale.com>

0 项奖励
回复

4,185 次查看
gbd
Contributor II

Should I start by loading DEBUG-APP.SDA or MSD-FRDM.SDA or does it matter? When I run 'dmesg | grep tty' I don't see a ttyAMCn.

Thanks!

0 项奖励
回复

4,185 次查看
larsknudsen
Contributor II

Did you upgrade both bootloader and OpenSDA to the latest? (just to make sure it should run fine with linux)

Anyway - when I attach the board, I get the following in dmesg:

[ 4821.894745] usb 1-1.2: new full-speed USB device number 6 using ehci_hcd

[ 4821.990413] cdc_acm 1-1.2:1.0: This device cannot do calls on its own. It is not a modem.

[ 4821.990452] cdc_acm 1-1.2:1.0: ttyACM3: USB ACM device

[ 4822.033932] Initializing USB Mass Storage driver...

[ 4822.034256] scsi6 : usb-storage 1-1.2:1.2

[ 4822.034422] usbcore: registered new interface driver usb-storage

[ 4822.034424] USB Mass Storage support registered.

[ 4823.034359] scsi 6:0:0:0: Direct-Access     FSL      FSL/PEMICRO MSD  0001 PQ: 0 ANSI: 4

[ 4823.036203] sd 6:0:0:0: Attached scsi generic sg2 type 0

[ 4823.037024] sd 6:0:0:0: [sdb] 1983999 512-byte logical blocks: (1.01 GB/968 MiB)

[ 4823.037703] sd 6:0:0:0: [sdb] Write Protect is off

[ 4823.037710] sd 6:0:0:0: [sdb] Mode Sense: 00 00 00 00

[ 4823.038361] sd 6:0:0:0: [sdb] Asking for cache data failed

[ 4823.038369] sd 6:0:0:0: [sdb] Assuming drive cache: write through

[ 4823.042094] sd 6:0:0:0: [sdb] Asking for cache data failed

[ 4823.042100] sd 6:0:0:0: [sdb] Assuming drive cache: write through

[ 4823.053063]  sdb:

[ 4823.056193] sd 6:0:0:0: [sdb] Asking for cache data failed

[ 4823.056200] sd 6:0:0:0: [sdb] Assuming drive cache: write through

[ 4823.056205] sd 6:0:0:0: [sdb] Attached SCSI removable disk

It attaches both as a mass storage on /dev/sdb and a "modem" on /dev/ttyACM3 (on mine)

I can communicate with the serial comm using minicom or node.js + serialport (remember to set the correct baud rate, etc.)

0 项奖励
回复

4,185 次查看
larsknudsen
Contributor II

WOW - thanks for the effort (all in the thread).  One question though:  How do you get the board to be recognized as mass storage from Linux to begin with? I just got 2 from Farnell and they never get recognized as mass storage under Ubuntu 13.04 (64bit)

0 项奖励
回复

4,185 次查看
BlackNight
NXP Employee
NXP Employee

I think you might need the updated bootloader P&E has relased (BOOTUPDATEAPP.SDA):

PEMicro.com

Most boards I have seen shipping come with v1.02 or v1.01, so you probably need update to v1.08.

From the bootloader release notes:

v1.05 Fixed binary files download to bootloader. Wrong address was used (0x0000 instead of 0x8000)

      Fixed led not coming on upon an error

v1.07 Added Bootloader support for Linux

v1.08 Future feature additions (undocumented)


0 项奖励
回复

4,185 次查看
manish2789
Contributor I

Hello I am working on FRDM 25z freedom board but not able to  load code on freedoboard FRDM KL25Z .How should i do that..?

1.I have copied  MSD-FRDM-KL26Z_Pemicro_v112.SDA file to "/media/BOOTLOADER" and then again repower device but till me not getting how to load code on FRDM KL25Z.:smileysad:

  so please guide me related to that.

0 项奖励
回复

4,185 次查看
larsknudsen
Contributor II

Thanks! -  ... if it works for one board, I just need to figure out how to scale it up to the 1000s :smileywink:  it would be great if the schools could just order the stuff directly.... but we will figure it out.. somehow.

The github project (payne92/bare-metal-arm · GitHub) should be promoted to the front page for the KL25Z on the farnell and freescale pages.  If it works, it's - by far - the simplest solution to get stuff done. 

0 项奖励
回复

4,185 次查看
drew887
Contributor I

This is such a big help :smileygrin: Thanks!!

0 项奖励
回复

4,185 次查看
andrewpayne
Contributor II

Here's a more complete code/bare metal/starutp example, that I just posted:  https://github.com/payne92/bare-metal-arm

4,185 次查看
larsknudsen
Contributor II

Thank you VERY much.  Now, there is a chance we can use the FRDM-KL25Z for our education project:  empiriKit  and Do this at home: Introducing the Education Kit

0 项奖励
回复

4,185 次查看
gdb
Contributor I

Here's an updated version which fixes the Makefile so you can use operators like "/" and "%" in your code.