LoginSignup
1
1

More than 5 years have passed since last update.

platformioでmsp430

Last updated at Posted at 2016-12-23

ESP8266がうまくいったので、調子に乗ってplatformioを使ってMSP430のビルドも試してみました。環境は雪豹のMacです。

ターゲットはF5529のLaunchPadです。

MSP430.jpg

このLaunchPadはUSB HUBとその先にターゲットとEZFETがぶら下がっています。flashを焼くにはEZFET経由かターゲットのBSL(USB)で可能です。

gccでビルドできるusbスタックがgithubにあったので、これをビルドしてみます。

$ mkdir msp430_usb
$ cd msp430_usb
$ platformio --version 
PlatformIO, version 3.1.0
$ platformio boards | grep MSP430
$ platformio init --board lpmsp430f5529_25
$ git clone https://github.com/jlhonora/usb-mspgcc.git
$ mv usb-mspgcc/src/* src/
$ echo "build_flags = -Isrc/USB" >> platformio.ini
$ platformio run

これでelfできます。--target uploadで実行するとmspdebugをインストールしようとして失敗するので、自前でビルドしたmspdebugのezfetで書き込んでみました。最初に試したときにはうまくできなかったのですが、このメモを確認していてもう一度試したらうまくいきました。

bash-3.2$ ../mspdebug/mspdebug ezfet
MSPDebug version 0.24 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2016 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chip info database from MSP430.dll v3.3.1.4 Copyright (C) 2013 TI, Inc.

Reset communications...
Version: 2.3.0.6, HW: 0x200ff45
Reset firmware...
Set VCC: 3000 mV
Starting interface...
Device count: 1
Fetching JTAG ID...
ID: 91 00 03 01 00 1a 00 00 04 1a 00 00
Reset parameters...
Check JTAG fuse...
Sync JTAG...
Identify (9x)...
Read device ID bytes at 0x01a00...
Read TLV...
  ver_id:         2955
  ver_sub_id:     0000
  revision:       18
  fab:            55
  self:           5555
  config:         12
  fuses:          55
  activation_key: 00000000
Configuring for MSP430F5529...
Device: MSP430F5529

Available commands:
    !               fill            power           setwatch_r      
    =               gdb             prog            setwatch_w      
    alias           help            read            simio           
    blow_jtag_fuse  hexout          regs            step            
    break           isearch         reset           sym             
    cgraph          load            run             verify          
    delbreak        load_raw        save_raw        verify_raw      
    dis             md              set             
    erase           mw              setbreak        
    exit            opt             setwatch        

Available options:
    color                       gdb_default_port            
    enable_bsl_access           gdb_loop                    
    enable_fuse_blow            gdbc_xfer_size              
    enable_locked_flash_access  iradix                      
    fet_block_size              quiet                       

Type "help <topic>" for more information.
Use the "opt" command ("help opt") to set options.
Press Ctrl+D to quit.

(mspdebug) prog .pioenvs/lpmsp430f5529_25/firmware.elf
Erasing...
Erase segment @ 0x243fe
Erase segment @ 0x1c3fe
Erase segment @ 0x143fe
Erase segment @ 0xc3fe
Erase segment @ 0x43fe
Programming...
Writing 4096 bytes at 4400 [section: .text]...
Writing 4096 bytes at 5400 [section: .text]...
Writing  972 bytes at 6400 [section: .text]...
Writing  608 bytes at 67cc [section: .rodata]...
Writing  128 bytes at ff80 [section: .vectors]...
Done, 9900 bytes total
(mspdebug) ^D
bash-3.2$ 

Mac OS XのHIDを使ったコードをマージしてらったので、load-bslでも焼けるのですが、一度目は失敗して二度目はうまくいきます。とりあえず書けているようなので、あまり深追いしてません。BSLを押しながらUSB接続して、二度目の実行で以下のようにうまくいきます。

load-bslでmspdebugを起動すると元々Flashに書いてあったプログラムがつぶれてしまうようなので注意してください。

bash-3.2$ ../mspdebug/mspdebug load-bsl
MSPDebug version 0.24 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2016 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chip info database from MSP430.dll v3.3.1.4 Copyright (C) 2013 TI, Inc.

BSL version: [vendor: 00, int: 05, API: 04, per: 34]
Chip ID data:
  ver_id:         2955
  ver_sub_id:     0000
  revision:       18
  fab:            55
  self:           5555
  config:         12
Device: MSP430F5529

Available commands:
    !               fill            power           setwatch_r      
    =               gdb             prog            setwatch_w      
    alias           help            read            simio           
    blow_jtag_fuse  hexout          regs            step            
    break           isearch         reset           sym             
    cgraph          load            run             verify          
    delbreak        load_raw        save_raw        verify_raw      
    dis             md              set             
    erase           mw              setbreak        
    exit            opt             setwatch        

Available options:
    color                       gdb_default_port            
    enable_bsl_access           gdb_loop                    
    enable_fuse_blow            gdbc_xfer_size              
    enable_locked_flash_access  iradix                      
    fet_block_size              quiet                       

Type "help <topic>" for more information.
Use the "opt" command ("help opt") to set options.
Press Ctrl+D to quit.

(mspdebug) prog .pioenvs/lpmsp430f5529_25/firmware.elf
Erasing...
Programming...
Writing 4096 bytes at 4400 [section: .text]...
Writing 4096 bytes at 5400 [section: .text]...
Writing  972 bytes at 6400 [section: .text]...
Writing  608 bytes at 67cc [section: .rodata]...
Writing  128 bytes at ff80 [section: .vectors]...
Done, 9900 bytes total
(mspdebug) ^D

MSP430をいじり始めたのは5507を使った製品が手元に転がり込んだのがきっかけでした。platformioでは5507をサポートが無いのでカスタムボードの設定を作りました。

.platformio/boards/msp430f5507.json
{
  "platform": "timsp430",
  "build": {
    "core": "msp430",
    "f_cpu": "25000000L",
    "mcu": "msp430f5507",
    "variant": "launchpad_f5529"
  },
  "name": "TI msp430f5507",
  "upload": {
    "maximum_ram_size": 6144,
    "maximum_size": 32768,
    "protocol": "tilib"
  },
  "url": "http://www.tij.co.jp/product/jp/MSP430F5507",
  "vendor": "TI"
}

Ver 3.1ではこれでいけました。この設定はバージョン毎に変わってきているようなので、将来的に使える保証はありません。

秋月で買ってきたG2553をFTなデバイスを使いBSL(シリアル)で焼いてみました。またまたかなり苦労しました。TIはいろいろ用意してかえって混乱しているような気がします。BSLは一般的にはISPと呼ばれる機能と同様と思います。秋月で取り扱いのあるG2452はBSLが無いようなのでSBWでしか焼けないと思われます。

G2553 PIN FT
VCC 1 3.3V
P1.1 3 RXD
P1.5 7 TXD
RST 16 DTR
TEST 17 RTS
GND 20 GND

RSTは47Kでプルアップ

IMGP0091

bash-3.2$ ../mspdebug/mspdebug rom-bsl -d /dev/cu.usbserial-DA0059MQ "prog .pioenvs/lpmsp430g2553/firmware.elf"
MSPDebug version 0.24 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2016 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chip info database from MSP430.dll v3.3.1.4 Copyright (C) 2013 TI, Inc.

rom_bsl: received NAK
rom_bsl: failed on command 0x1e (addr = 0x0000, len = 0x0000)
warning: rom_bsl: failed to read version
Performing mass erase...
Sending password...
Chip ID data:
  ver_id:         5325
  ver_sub_id:     0000
  revision:       00
  fab:            60
  self:           0000
  config:         00
Device: MSP430G2xx3
Erasing...
Programming...
Writing  140 bytes at c000 [section: .text]...
Writing   32 bytes at ffe0 [section: .vectors]...
Done, 172 bytes total

焼いた後にFTの接続外すと動き出します。3.3V系のFTなどのUSBシリアル変換を持っていたら、G2553(210円)だけ買ってきて始められるので結構良い気がします。自分はできるだけ千円以内でやれる事をガイドラインにしています。

余談ですがG2553で無限ループのLチカをおこなって、電流の測定をしたところ不思議なグラフになった。何でなんだろう。

MSP430LCHIKA.jpg

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1