How to upload firmware to MSP430FG439 by using Olimex MSP430-JTAG-Tiny-V2 on macbook

Started by ysulyw, May 02, 2015, 06:41:23 pm

Previous topic - Next topic

ysulyw

I need to upload firmware to MSP430FG439 by using Olimex MSP430-JTAG-Tiny-V2  on macbook. The MSP430FG439 board is Olimex MOD_PULSE. Below is the information of Olimex MSP430-JTAG_TINY_V2 on macbook.
    MSP430 JTAGTiny ver.2:
    Product ID:   0x0031
    Vendor ID:   0x15ba
    Version:   2.00
    Serial Number:   00000317
    Speed:   Up to 12 Mb/sec
    Manufacturer:   OLIMEX LTD.
    Location ID:   0x14200000 / 4
   Current Available (mA):   500
   Current Required (mA):   100
Which software I can use to complete this´╝č and what should I do?
Thanks!

ysulyw

I have used mspdebug to complete successfully. Thank  Daniel Beer and Lub very much,  without their help I could not do this. Here is the step:

1. Install MacPorts. It is a package manager and will allow us easy access to a huge
   variety of useful software. We can downland this software at:
       https://www.macports.org

2. Use MacPorts to install mspdebug. The latest version of mspdebug is 0.23. In a terminal   
   window, type:
       sudo port install mspdebug
   
3. Connect the Olimex MSP430-JTAG_TINY_V2 and MOD_PULSE board, then plug into usb port on mac.

4. Use 'ls /dev/cu.*' in a terminal to look at the MSP430-JTAG_TINY_V2's ID. Maybe:   
   cu.usbmodemXXXXXXXX (XXXXXXXX is a string of digital number,ig 00000311).

5. Move into the source code directory,and use mspdebug to upload firmare. In a terminal window, type:
   mspdebug olimex -j -d /dev/cu.<ID>
   prog <name>.hex
   run
   exit
   
   Below is the information of my testing.
   #############################################################
   $ mspdebug olimex -j -d /dev/cu.<ID>
   MSPDebug version 0.23 - debugging tool for MSP430 MCUs
   Copyright (C) 2009-2015 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.
   
   Trying to open /dev/cu.<ID> at 115200 bps...
   Resetting Olimex command processor...
   Initializing FET...
   FET protocol version is 20000007
   Set Vcc: 3000 mV
   Configured for JTAG (2)
   Sending reset...
   Using Olimex identification procedure
   Device ID: 0xf439
      Code start address: 0x1100
      Code size         : 61184 byte = 59 kb
      RAM  start address: 0x200
      RAM  end   address: 0x9ff
      RAM  size         : 2048 byte = 2 kb
   Device: MSP430FG43x_F43x
   Number of breakpoints: 2
   fet: FET returned error code 34 (Not supported by selected interface or interface is not initialized)
   fet: warning: message C_IDENT3 failed
   fet: FET returned NAK
   warning: device does not support power profiling
   Chip ID data: f4 39 47
   
   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 <name>.hex
    Erasing...
    Programming...
    Writing 3660 bytes at 1100...
    Writing   32 bytes at ffe0...
    Done, 3692 bytes total
    (mspdebug) run
    Running. Press Ctrl+C to interrupt...
    ^C
        ( PC: 012c2)  ( R4: 017e2)  ( R8: 00008)  (R12: 007fe) 
        ( SP: 00a00)  ( R5: 05a08)  ( R9: 0000d)  (R13: 00279) 
        ( SR: 0000c)  ( R6: 0f2e3)  (R10: 01726)  (R14: 02508) 
        ( R3: 00000)  ( R7: 0fdfa)  (R11: 0188c)  (R15: 00034) 
    0x12c2:
        012c2: 3f f2                     AND     #0x0008, R15
        012c4: 02 24                     JZ      0x12ca
        012c6: 32 d0 10 00               BIS     #0x0010, SR
        012ca: 82 93 14 02               TST     &0x0214
        012ce: 04 24                     JZ      0x12d8
        012d0: b0 12                     
    (mspdebug) run
    Running. Press Ctrl+C to interrupt...
    ^C
        ( PC: 012ce)  ( R4: 017e2)  ( R8: 00008)  (R12: 007fa) 
        ( SP: 00a00)  ( R5: 05a08)  ( R9: 0000d)  (R13: 0027c) 
        ( SR: 0000b)  ( R6: 0f2e3)  (R10: 01726)  (R14: 02553) 
        ( R3: 00000)  ( R7: 0fdfa)  (R11: 0188c)  (R15: 00000) 
    0x12ce:
        012ce: 04 24                     JZ      0x12d8
        012d0: b0 12 4c 14               CALL    #0x144c
        012d4: 82 43 14 02               CLR     &0x0214
        012d8: 82 93 1e 02               TST     &0x021e
        012dc: 04 24                     JZ      0x12e6               
    (mspdebug) exit
   #############################################################
   
6. If you want to debug your c program, you need install a C compiler and debugger.
   I use msp430-gcc and msp430-gdb, you can install them by using of MacPorts:
   sudo port install msp430-gcc msp430-libc msp430-gdb
   Now, you can debug your C program.

ysulyw

1. But the MSP430-JTAG-TINY-V2 is not very stable on mac, and sometimes it can not connect by mspdebug. 
   When I use mspdebug to connect, it shows "Initializing FET..." in the terminal, then the device is not responded. 
   I can only use 'CTRL-C' to terminate. I try to connect many times, the vast majority times are not responded, only serval times are success.
   Below is the information of my testing.
   #############################################################
   $ mspdebug olimex -j -d /dev/cu.usbmodem00000311
   MSPDebug version 0.23 - debugging tool for MSP430 MCUs
   Copyright (C) 2009-2015 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.

   Trying to open /dev/cu.usbmodem00000311 at 115200 bps...
   Resetting Olimex command processor...
   Initializing FET...
   <no response,wait or press Ctrl+C>
   comport: read error: Operation timed out
   fet: open failed
   Trying again...
   <no response,wait or press Ctrl+C>   
   Resetting Olimex command processor...
   Initializing FET...
   comport: read error: Operation timed out
   fet: open failed
   $ 
   #############################################################
   
2. To solve this problem, I download the mspdebug's source code from http://mspdebug.sourceforge.net,
   and enable the DEBUG SERIAL mode. Then I find sometimes MSP430-JTAG-TINY-V2 return a redundant byte(0xff) ,
   when it answer the FET Send Command.   
   Below is the information of connecting failed. 
   #############################################################
   Trying to open /dev/cu.usbmodem00000311 at 115200 bps...
   Resetting Olimex command processor...
   Serial transfer out: [0x1 bytes]
      7e
   Serial transfer out: [0x1 bytes]
      7e
   Resetting Olimex Complete...
   Initializing FET...
   FET Send Command
   Serial transfer out: [0x5 bytes]
      01 01 16 07 7e
   FET Receive packet_
   Serial transfer in [0x1 bytes]
      ff           --------This ff is redundant.
   Serial transfer in [0xf bytes]
      0c 00 01 02 00 00 01 00 07 2d 31 01 18 c5 7e
   comport: read error: Operation timed out
   fet: open failed
   Trying again...
   Resetting Olimex command processor...
   ......
   #############################################################
   Below is the information of connecting succeed. 
   #############################################################   
   Trying to open /dev/cu.usbmodem00000311 at 115200 bps...
   Resetting Olimex command processor...
   Serial transfer out: [0x1 bytes]
      7e
   Serial transfer out: [0x1 bytes]
      7e
   Resetting Olimex Complete...
   Initializing FET...
   FET Send Command _
   Serial transfer out: [0x5 bytes]
      01 01 16 07 7e
   Serial transfer in [0xf bytes]
      0c 00 01 02 00 00 01 00 07 2d 31 01 18 c5 7e
   FET Receive packet_
   FET protocol version is 20000007
   FET Send Command _
   Serial transfer out: [0xb bytes]
      27 02 01 00 04 00 00 00 f1 e8 7e
   Serial transfer in [0x11 bytes]
      0e 00 27 03 00 00 04 00 00 00 ff ff ff ff 02 d2 7e
   ......
   #############################################################   
3. Now we need to change the serial_recv() function in comport.c of mspdebug source code.
   Add some code to ignore the redundant byte (0xff), like this:   
   static int serial_recv(transport_t tr_base, uint8_t *data, int max_len)
   {
     struct comport_transport *tr = (struct comport_transport *)tr_base;
     int r;

     r = sport_read(tr->serial_fd, data, max_len);
     if (r < 0) {
        pr_error("comport: read error");
       return -1;      
     }
     //Added Code/////////////////////////////////////////////////   
     if ((r == 1)&&(data[0]==0xFF))
     {
        printc_dbg("Return one bytes %d...\n", data[0]);
        return 0;   
     }
          /////////////////////////////////////////////////////////////////
    #ifdef DEBUG_SERIAL
     debug_hexdump("Serial transfer in", data, r);
    #endif
     return r;
    }
4. Recompiling and Reinstall mspdebug. Enter the directory of mspdebug in a Terminal, and type:
     make
     sudo make install
       
5. Now we can use the new mspdebug to connect the MSP430-JTAG-TINY-V2, Then Succeed!       
   #############################################################     
   Trying to open /dev/cu.usbmodem00000311 at 115200 bps...
   Resetting Olimex command processor...
   Serial transfer out: [0x1 bytes]
      7e
   Serial transfer out: [0x1 bytes]
      7e
   Initializing FET...
   Serial transfer out: [0x5 bytes]
      01 01 16 07 7e
   Return one bytes 255...
   Serial transfer in [0xf bytes]
      0c 00 01 02 00 00 01 00 07 2d 31 01 18 c5 7e
   FET protocol version is 20000007
   Serial transfer out: [0xb bytes]
      27 02 01 00 04 00 00 00 f1 e8 7e
   Serial transfer in [0x11 bytes]
      0e 00 27 03 00 00 04 00 00 00 ff ff ff ff 02 d2 7e
   Serial transfer out: [0xb bytes]
      06 02 01 00 b8 0b 00 00 b0 00 7e
   Serial transfer in [0x9 bytes]
      06 00 06 00 00 00 44 b7 7e
   Set Vcc: 3000 mV
   ......
   #############################################################

Note: This is not a very good method, it has bug. If you have a good method, please let we know.

ysulyw

Daniel Beer has assembled a  patch for this. Now we do not need modify the comport.c file, just copy 'mspdebug-chomp-ff.patch' in the root directory of mspdebug,  open a terminal and type:
    patch -p1 < mspdebug-chomp-ff.patch
    make
Then use mspdebug command to connect the MSP430-JTAG-TINY-V2. ig. mspdebug olimex -j -d /dev/cu.usbmodem00000311. Here is the test information.
################################################
Trying to open /dev/cu.usbmodem00000311 at 115200 bps...
Resetting Olimex command processor...
Initializing FET...
FET protocol version is 20000007
Set Vcc: 3000 mV
Configured for JTAG (2)
Sending reset...
Using Olimex identification procedure
......
################################################
The connection is normal.
Thank Daniel Beer very much!

ysulyw

Daniel Beer has modified the fire 'drivers/fet_proto.c' of mspdebug at   http://sourceforge.net/p/mspdebug/code/ci/56318beed1e4ac2cf0189ff77acb3b1582dbfa24/.
Now we just need to replace the old one and make, the the mspdebug can connect with MSP430-JTAG-TINY-V2 on mac.
Thank Daniel Beer very much!