Jump to content
Sign in to follow this  
OppaErich

[solved] (PEBCAK) mspgcc - blinky.c fails to compile

Recommended Posts

Hi,

 

I'm trying to compile a simple blinky program but mspgcc gives errors. I don't know what's the problem... :oops:


oppa@oppa-mag:~$ LANG=C && msp430-gcc -c blinky.c -o blinky
blinky.c:7:1: warning: data definition has no type or storage class
blinky.c:7:1: error: conflicting type qualifiers for 'WDTCTL'
/usr/lib/gcc/msp430/4.5.3/../../../../msp430/include/msp430g2231.h:617:1: note: previous declaration of 'WDTCTL' was here
blinky.c:9:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before '|=' token
blinky.c:10:1: warning: data definition has no type or storage class
blinky.c:10:1: error: conflicting type qualifiers for 'P1OUT'
/usr/lib/gcc/msp430/4.5.3/../../../../msp430/include/msp430g2231.h:409:1: note: previous declaration of 'P1OUT' was here
oppa@oppa-mag:~$ cat blinky.c
#include 

#define LED	BIT6				// green LED at 1.6

unsigned volatile int i;			// delay loop counter

WDTCTL = WDTPW + WDTHOLD;			// Watchdog off

P1DIR |= LED;
P1OUT = 0;					// LED off

int main(void){
while(1){
	for(i=20000;i>0;i--);		// delay loop
	P1OUT ^= LED;			// toggle green LED
}
return 0;
}

Share this post


Link to post
Share on other sites

oppa@oppa-mag:~$ msp430-gcc -c blinky.c -o blinky -mmcu=msp430g2231
oppa@oppa-mag:~$ file blinky
blinky: ELF 32-bit LSB relocatable, version 1, not stripped
oppa@oppa-mag:~$ ls -l blinky
-rw-r--r-- 1 oppa oppa 876 Okt 31 17:14 blinky

:thumbup: Cheers guys. Somehow I knew it's my fault... (32-bit makes me wonder though)

 

but it doesn't stop:

oppa@oppa-mag:~$ mspdebug uif
MSPDebug version 0.17 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2011 Daniel Beer 
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This driver does not support raw USB access.

I had this before... :think:

Share this post


Link to post
Share on other sites
\

oppa@oppa-mag:~$ mspdebug uif
MSPDebug version 0.17 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2011 Daniel Beer 
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This driver does not support raw USB access.

I had this before... :think:

Are you using a launchpad? If so, that should be:

mspdebug rf2500

 

-rick

Share this post


Link to post
Share on other sites

Yep, it's a Launchpad (for now) but I have other boards and an UIF too. So I will try to get the latest version running.


oppa@oppa-mag:~$ mspdebug rf2500
MSPDebug version 0.17 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2011 Daniel Beer 
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Trying to open interface 1 on 005
Initializing FET...
FET protocol version is 30066536
Configured for Spy-Bi-Wire
Set Vcc: 3000 mV
Device ID: 0xf201
Device: MSP430G2231
Code memory starts at 0xf800     <---- is that right ?
Number of breakpoints: 1
fet: FET returned NAK
fet: warning: message 0x30 failed

Available commands:
   =         delbreak  gdb       load      opt       reset     simio     
   alias     dis       help      locka     prog      run       step      
   break     erase     hexout    md        read      set       sym       
   cgraph    exit      isearch   mw        regs      setbreak  

Available options:
   color           gdb_loop        iradix          
   fet_block_size  gdbc_xfer_size  quiet           

Type "help " for more information.
Press Ctrl+D to quit.

(mspdebug) prog blinky
Erasing...
Programming...
Writing   66 bytes to 0034...
(mspdebug) run
fet: FET returned error code 17 (Could not run device (to breakpoint))
fet: failed to restart CPU
run: failed to start CPU
(mspdebug) dis 0xf800
i+0xf7fe:
   0f800: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f804: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f808: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f80c: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f810: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f814: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f818: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f81c: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f820: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f824: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f828: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f82c: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f830: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f834: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f838: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
   0f83c: ff ff ff ff               AND.B   @R15+,   i+0xfffd(R15)
(mspdebug) 

That went wrong somehow.

 

oppa@oppa-mag:~/hacking/msp430/mspdebug$ LANG=C && make
cc  -DUSE_READLINE  -O1 -Wall -Wno-char-subscripts -ggdb -I. -Isimio -Iformats -Idrivers -Iutil -Iui -DLIB_DIR=\"/usr/local/lib/\" -o ui/reader.o -c ui/reader.c
ui/reader.c:26:31: fatal error: readline/readline.h: No such file or directory
compilation terminated.
make: *** [ui/reader.o] Error 1

I've tried searching for readline.h, installed about 100MB of stuff with readline in the name but still....

Is there a binary available ?

Share this post


Link to post
Share on other sites

libreadline6-dev was missing. It does compile now but things are worse:


oppa@oppa-mag:~/hacking/msp430/mspdebug$ ./mspdebug rf2500
MSPDebug version 0.17 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2011 Daniel Beer 
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Trying to open interface 1 on 007
rf2500: warning: can't detach kernel driver: No data available
Initializing FET...
FET protocol version is 30066536
Configured for Spy-Bi-Wire
Set Vcc: 3000 mV
fet: FET returned error code 4 (Could not find device (or device not supported))
fet: command C_IDENT1 failed
fet: identify failed
Trying again...
Initializing FET...
FET protocol version is 30066536
Configured for Spy-Bi-Wire
Sending reset...
Set Vcc: 3000 mV
Device ID: 0xf201
Device: MSP430F2012         <--- HUH?
Code memory starts at 0xf800
Number of breakpoints: 2
fet: FET returned NAK
fet: warning: message 0x30 failed
...

and it's still 0.17.

 

With UIF connected to F149 Itead board:


oppa@oppa-mag:~/hacking/msp430/mspdebug$ /usr/local/bin/mspdebug uif
MSPDebug version 0.17 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2011 Daniel Beer 
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Searching for firmware for TI3410...
   - checking /usr/local/lib//mspdebug/ti_3410.fw.ihex
Loaded 13765 byte firmware image (checksum = 0xb5)
Starting download...
ti3410: warning: can't detach kernel driver: Operation not permitted
ti3410: can't claim interface: Operation not permitted
ti3410: firmware download failed

Ah well, back to IAR on XP. :cry:

 

Thanks,

Stephan

Share this post


Link to post
Share on other sites

If it otherwise works (you've cut your paste exactly where it starts to get interesting), it's OK. the 2231 and the F2012 and more or less the same, to such extent that 2231s with F2012 silicon identifications have been spotted out there (I think all my 2231s say they are F2012).

Share this post


Link to post
Share on other sites

that was cut


fet: FET returned NAK
fet: warning: message 0x30 failed

Available commands:
   =         delbreak  gdb       load      opt       reset     simio     
   alias     dis       help      locka     prog      run       step      
   break     erase     hexout    md        read      set       sym       
   cgraph    exit      isearch   mw        regs      setbreak  

Available options:
   color           gdb_loop        iradix          
   fet_block_size  gdbc_xfer_size  quiet           

Type "help " for more information.
Press Ctrl+D to quit.

(mspdebug) ^C
(mspdebug) exit
rf2500: can't send data: No such device
fet: final reset failed
rf2500: can't send data: No such device
fet: close command failed

 

The 'original' mspdebug detected MSP430G2231 and it does not work.


(mspdebug) prog blinky
Erasing...
Programming...
Writing   66 bytes to 0034...
(mspdebug) run
fet: FET returned error code 17 (Could not run device (to breakpoint))
fet: failed to restart CPU
run: failed to start CPU
(mspdebug) dis 0x0034
rf2500: can't send data: No such device
fet: failed to read from 0x0034
(mspdebug) 

No visible action from the Launchpad.

Share this post


Link to post
Share on other sites

This I've never seen. All I can add at this point is that MSPDebug, rf2500 and '2231 do work quite fine (either MSPDebug Git or 0.17 or in fact as far back as I can remember :)).

Share this post


Link to post
Share on other sites

I've mailed the Author of mspdebug and he replied:

Just noticed the addresses that are being written -- 0x0034 is not

within the range of flash memory, so it looks like perhaps you have a

linker problem. How was your program compiled/linked?

Is this linker invoked automagically ? I guess not.

 

So, is there any documentation for newbies ? What steps are needed from source to a running target ?

Share this post


Link to post
Share on other sites

#include 

#define LED BIT3

int main(void)
{
       WDTCTL = WDTPW | WDTHOLD;

       P1OUT &= ~LED;
       P1DIR = LED;

       while(1)
       {
               P1OUT ^= LED;
               {volatile int i = 0; for(i=0; i<16384; i++);}
       }
}

 

msp430-gcc -Os -Wall -W -Wextra -Werror -g -mmcu=msp430g2231 -c main.c -o main.c.o

 

msp430-gcc -mmcu=msp430g2231 -Wl,--sort-common  -o main.elf  main.c.o

 

mspdebug -n rf2500 "prog main.elf"

Share this post


Link to post
Share on other sites

(mspdebug) prog blinky.elf
Erasing...
Programming...
Writing  110 bytes to f800 [section]...
Writing   32 bytes to ffe0 [section]...
(mspdebug) run
Running. Press Ctrl+C to interrupt...

Looking good - thank you gordon.

 

But still, where/how did you aquire your knowledge ?

Share this post


Link to post
Share on other sites

lol - tring FET430UIF connected to 430F149 board


oppa@oppa-mag:~$ msp430-gcc -Os -Wall -W -Wextra -Werror -g -mmcu=msp430f149 -c blinky.c -o blinky.c.o
oppa@oppa-mag:~$ msp430-gcc -mmcu=msp430f149 -Wl,--sort-common  -o blinky149.elf  blinky.c.o
oppa@oppa-mag:~$ mspdebug -j uif
MSPDebug version 0.17 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2011 Daniel Beer 
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Searching for firmware for TI3410...
   - checking /usr/local/lib//mspdebug/ti_3410.fw.ihex
Loaded 13765 byte firmware image (checksum = 0xb5)
Starting download...
ti3410: warning: can't detach kernel driver: Operation not permitted
ti3410: can't claim interface: Operation not permitted
ti3410: firmware download failed
oppa@oppa-mag:~$ su -c 'mspdebug -j uif'
Passwort: 
MSPDebug version 0.17 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2011 Daniel Beer 
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Searching for firmware for TI3410...
   - checking /usr/local/lib//mspdebug/ti_3410.fw.ihex
Loaded 13765 byte firmware image (checksum = 0xb5)
Starting download...
ti3410: warning: can't detach kernel driver: No data available
ti3410: warning: reset failed: No such device
Waiting for TI3410 reset...
TI3410 device is in boot config, setting active
Initializing FET...
FET protocol version is 20408002
Configured for JTAG (2)
ti3410: can't receive data: No such device
warning: fet: set VCC failed
ti3410: can't send data: No such device
fet: command C_IDENT1 failed
fet: identify failed
Trying again...
Initializing FET...
ti3410: can't send data: No such device
fet: open failed
ti3410: warning: TI_CLOSE_PORT failed: No such device

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×