忍者ブログ

Azukish

消えゆく世界と流れる未来に最後の灯を since 2006/4/3

2024/04/29

[PR]

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

コメント

ただいまコメントを受けつけておりません。

2016/12/23

FedoraでMSP430をプログラムしたい。



有志の人がMSP430用のツール群をRPMに固めてくれてるみたい。これでmakeとかしなくていいからだいぶ楽。
nielsenb/msp430-development-tools Copr
↑からrepoファイルをダウンロードして/etc/yum.repos.d/に配置。

で、The Destitute Developer: MSP430 and Fedora 21 - The same but differentにあるように、必要なファイル群をインストール。
# dnf install msp430-elf-gcc msp430-elf-binutils msp430-elf-gdb mspds msp430flasher msp430-gcc-support-files dos2unix



ここではMSP430 Flasherというソフトを使ってMSP430に書き込みを行うように指示されているけれど、できないっぽいので、書き込み・デバッグにはmspdebugを使う。
追加で以下をインストール。
誰が作ったのかは不明。。。
# dnf install mspdebug



で、次みたいなMakefileを書く。上の説明にあるMakefileをいじっただけ。
2017/2/19修正:
MSPFLASHER = MSP430Flasher
→ MSPFLASHER = mspdebug
$(MSPFLASHER) -n $(MCU) -w "$(TARGET).txt" -v -z [VCC]
→ $(MSPFLASHER) -d $(MCU) -v -z [VCC]
あと適宜Tabを追加
#
# Makefile for msp430
#
# 'make' builds everything
# 'make clean' deletes everything except source files and Makefile
# 'make install' builds everything, and programs the MSP430 using MSPFLASHER
# You need to set TARGET, MCU and SOURCES for your project.
# TARGET is the name of the executable file to be produced
# $(TARGET).elf $(TARGET).hex and $(TARGET).txt nad $(TARGET).map are all generated.
# The TXT file is used for BSL loading, the ELF can be used for JTAG use
#
TARGET     = project0
MCU        = msp430g2553
# MSP430Flasher name
MSPFLASHER = mspdebug
# List all the source files here
# eg if you have a source file foo.c then list it here
SOURCES = main.c
# Include are located in the Include directory
INCLUDES = -IInclude
# Add or subtract whatever MSPGCC flags you want. There are plenty more
#######################################################################################
CFLAGS   = -mmcu=$(MCU) -g -Os -Wall -Wunused $(INCLUDES)
ASFLAGS  = -mmcu=$(MCU) -x assembler-with-cpp -Wa,-gstabs
LDFLAGS  = -mmcu=$(MCU) -Wl,-Map=$(TARGET).map
########################################################################################
CC       = msp430-elf-gcc
LD       = msp430-elf-ld
AR       = msp430-elf-ar
AS       = msp430-elf-gcc
NM       = msp430-elf-nm
OBJCOPY  = msp430-elf-objcopy
RANLIB   = msp430-elf-ranlib
STRIP    = msp430-elf-strip
SIZE     = msp430-elf-size
READELF  = msp430-elf-readelf
MAKETXT  = srec_cat
CP       = cp -p
RM       = rm -f
MV       = mv
########################################################################################
# the file which will include dependencies
DEPEND = $(SOURCES:.c=.d)
# all the object files
OBJECTS = $(SOURCES:.c=.o)
all: $(TARGET).elf $(TARGET).hex $(TARGET).txt
$(TARGET).elf: $(OBJECTS)
	echo "Linking $@"
	$(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
	echo
	echo ">>>> Size of Firmware <<<<"
	$(SIZE) $(TARGET).elf
	echo
%.hex: %.elf
	$(OBJCOPY) -O ihex $< $@
%.txt: %.hex
	$(MAKETXT) -O $@ -TITXT $< -I
	unix2dos $(TARGET).txt
#  The above line is required for the DOS based TI BSL tool to be able to read the txt file generated from linux/unix systems.
%.o: %.c
	echo "Compiling $<"
	$(CC) -c $(CFLAGS) -o $@ $<
# rule for making assembler source listing, to see the code
%.lst: %.c
	$(CC) -c $(ASFLAGS) -Wa,-anlhd $< > $@
# include the dependencies unless we're going to clean, then forget about them.
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPEND)
endif
# dependencies file
# includes also considered, since some of these are our own
# (otherwise use -MM instead of -M)
%.d: %.c
	echo "Generating dependencies $@ from $<"
	$(CC) -M ${CFLAGS} $< >$@
.SILENT:
.PHONY: clean
clean:
	-$(RM) $(OBJECTS)
	-$(RM) $(TARGET).*
	-$(RM) $(SOURCES:.c=.lst)
	-$(RM) $(DEPEND)
install: $(TARGET).txt
	$(MSPFLASHER) -d $(MCU) -v -z [VCC]


で、つないで、make→make installで書き込み。

2017/2/19修正: makeしたあとに
# mspdebug rf2500
(mspdebug) load project0.elf
(mspdebug) run
で実行。

あ、ソースファイルはいじれば何でもいけるけど、上のMakefileだとmain.cになってる。
make installはrootじゃないとだめかも。 とりあえず、遊ぶ分には十分に環境が整ったっぽい。というか、これ上手くeclipseに実装できたらIDE使えるんじゃないか?(やるとは言ってない)

拍手

コメント













カレンダー

03 2024/04 05
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

アーカイブ

AD

Azkishはamazon.co.jpを宣伝しリンクすることによって サイトが紹介料を獲得できる手段を提供することを目的に設定されたアフィリエイト宣伝プログラムである、 Amazonアソシエイト・プログラムの参加者です。