-
Notifications
You must be signed in to change notification settings - Fork 2.6k
MSP430X
The basic MSP430 cannot support more memory (ROM + RAM + peripherals) than its 64K address space. In order to support this, an extended form of the MSP430 uses 20-bit registers and a 20-bit address space, allowing up to 1 MB of memory. Platforms such as, WiSMote are based on MSP430X series CPU, and support more memory than 64K. Unfortunately, current stable release of GCC does not support MSP430X series CPUs. There is an experimental version of GCC that can be used.
The instructions to install the experimental GCC version are shown below. This version will be installed to "/opt/mspgccx". In addition, you also need some modifications in Cooja and to platform specific make file of wismote (contiki/platform/wismote/Makefile.wismote).
- You can check the current version of your msp430-gcc via:
msp430-gcc --version msp430-gcc (GCC) 4.6.3 20120301 (mspgcc LTS 20120406 unpatched)
- After following the instructions of this page you should get this output:
msp430-gcc --version msp430-gcc (GCC) 4.7.0 20120322 (mspgcc dev 20120911)
- NOTE: You might want to use two different compilers during code development, the stable release 4.6.3 and the experimental version 4.7.0. Therefore it makes sense to add the following line to your bash_rc or bash_profile. I am aware of the fact that this introduces a point of failure, but I couldn't come up with an automated way so far. You can just point to the compiler you want to use:
# msp430-gcc (GCC) 4.6.3 # export PATH=/usr/bin/msp430-gcc/bin:$PATH # msp430-gcc (GCC) 4.7.0 export PATH=/opt/mspgccx/bin:$PATH
NOTE: The following instructions are based on an email from Aragosystems, the manufacturer of the WiSMote platform.
Visit here and download the latest source and compile it:
git clone git://mspsim.git.sourceforge.net/gitroot/mspsim/mspsim cd mspsim ant jarCopy mspsim.jar to contiki/tools/mspsim/
cd contiki/tools/cooja && ant clean && ant jar
If you have Mac OSX then you can simply install The following simple script performs the building the new compiler and you should use it at your own risk. You should better understand what it does and you should be very patient (~30min), if your system is not the fastest one like mine.
#! /bin/sh ################################################################# # This script compiles the msp43-gcc 4.7.0 # # The instructions are based on an email from Aragosystems, the # # manufacturer of the WiSMote platform. It has been tested on # # Ubuntu 12 and MAC OS 10.6. # # The running time of this script is depending on your system # # and it can take about 30 minutes. # # # # NOTE ON RECENT PLATFORMS: Using recent compiler (e.g. gcc-5.3)# # or recent versions of texinfo (e.g. texinfo-6.0) with this # # script seems to be non-working. It has been tested with # # gcc-4.6.4 and texinfo-4.13. # # # # IMPORTANT: This script is very simple and requires you # # understanding it and modifying it according to your needs. # # # # IMPORTANT: The ouput file for the new compiler is defined in # # INSTALL_PREFIX and it set to /opt/mspgccx in this script. You # # can later move this dicrectory. However, you MUST create this # # directory before starting the script, e.g.: # # $ mkdir ~/mspgccx && mv ~/mspgccx /opt/ # # # # IMPORTANT: Your system might require root priviliege for # # modifying the defined installion directory, e.g. if is in # # /opt/ make sure INSTALL_PREFIX has the correct access rights. # # # # IMPORTANT: This script creates a tempral directory tmp in # # the current path, remeber to remove it afterwarts. # # # # Author: # # Hossein Shafagh ([email protected]) # # Created: Nov. 19 2012 # ################################################################# INSTALL_PREFIX="/tmp/mspgccx" echo The installatoin prefix:$INSTALL_PREFIX # Switch to the tmp directory mkdir tmp cd tmp # Getting wget http://sourceforge.net/projects/mspgcc/files/mspgcc/DEVEL-4.7.x/mspgcc-20120911.tar.bz2 wget http://sourceforge.net/projects/mspgcc/files/msp430mcu/msp430mcu-20120716.tar.bz2 wget http://sourceforge.net/projects/mspgcc/files/msp430-libc/msp430-libc-20120716.tar.bz2 wget http://sourceforge.net/p/mspgcc/bugs/352/attachment/0001-SF-352-Bad-code-generated-pushing-a20-from-stack.patch wget http://sourceforge.net/p/mspgcc/bugs/_discuss/thread/fd929b9e/db43/attachment/0001-SF-357-Shift-operations-may-produce-incorrect-result.patch wget http://ftpmirror.gnu.org/binutils/binutils-2.22.tar.bz2 wget http://mirror.ibcp.fr/pub/gnu/gcc/gcc-4.7.0/gcc-4.7.0.tar.bz2 # Unpacking the tars tar xvfj binutils-2.22.tar.bz2 tar xvfj gcc-4.7.0.tar.bz2 tar xvfj mspgcc-20120911.tar.bz2 tar xvfj msp430mcu-20120716.tar.bz2 tar xvfj msp430-libc-20120716.tar.bz2 # 1) Incorporating the changes contained in the patch delievered in mspgcc-20120911 cd binutils-2.22 patch -p1<../mspgcc-20120911/msp430-binutils-2.22-20120911.patch cd .. # 2) Incorporating the changes contained in the patch delievered in mspgcc-20120911 cd gcc-4.7.0 patch -p1<../mspgcc-20120911/msp430-gcc-4.7.0-20120911.patch patch -p1<../0001-SF-352-Bad-code-generated-pushing-a20-from-stack.patch patch -p1<../0001-SF-357-Shift-operations-may-produce-incorrect-result.patch cd .. # 3) Creating new directories mkdir binutils-2.22-msp430 mkdir gcc-4.7.0-msp430 # 4) installing binutils in INSTALL_PREFIX cd binutils-2.22-msp430/ ../binutils-2.22/configure --target=msp430 --program-prefix="msp430-" --prefix=$INSTALL_PREFIX make make install # 5) Download the prerequisites cd ../gcc-4.7.0 ./contrib/download_prerequisites # 6) compiling gcc-4.7.0 in INSTALL_PREFIX cd ../gcc-4.7.0-msp430 ../gcc-4.7.0/configure --target=msp430 --enable-languages=c --program-prefix="msp430-" --prefix=$INSTALL_PREFIX make make install # 7) compiping msp430mcu in INSTALL_PREFIX cd ../msp430mcu-20120716 MSP430MCU_ROOT=`pwd` ./scripts/install.sh ${INSTALL_PREFIX}/ # 8) compiling the msp430 lib in INSTALL_PREFIX cd ../msp430-libc-20120716 cd src PATH=${INSTALL_PREFIX}/bin:$PATH make make PREFIX=$INSTALL_PREFIX install # cleanup # no need since everything created in tmp echo Reminder: remove tmp
If you have Mac OSX then you can simply install homebrew https://brew.sh, then use the formulae in beshrns/mspgcc https://github.com/beshrns/homebrew-mspgcc, as following:
First, install homebrew https://brew.sh:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then install msp430-gcc tap:
$ brew tap beshrns/mspgcc $ brew install msp430-libc (takes about 1 hour) $ $(brew --prefix)/Homebrew/Library/Taps/beshrns/homebrew-mspgcc/addlinks.sh
Since `libc` is the top of the dependency chain, this should suffice to get everything you need.
$ msp430-gcc --version msp430-gcc (GCC) 4.7.0 20120322 (mspgcc dev 20120911) ...
This was tested with macOS Sierra and High Sierra, with xcode 9.0.
See this repository: https://github.com/pksec/msp430-gcc-4.7.3
Please note that the commit 3d64b80 takes care of the following modifications by introducing a new variable CPU_HAS_MSP430X. You should not apply the patch below if your version of contiki includes content of that commit.
--- a/platform/wismote/Makefile.wismote +++ b/platform/wismote/Makefile.wismote @@ -36,6 +36,17 @@ include $(CONTIKI)/cpu/msp430/Makefile.msp430 ifdef IAR LDFLAGSNO += -B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl" -l contiki-$(TARGET).map -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 LDFLAGS += $(LDFLAGSNO) -Felf -yn +else # IAR + +ifndef MSPGCC_VERSION + MSPGCC_VERSION := ${shell $(CC) -dumpversion} +endif + +ifneq (,$(findstring 4.7.,$(MSPGCC_VERSION))) +# 20 bits flags for compilation (supported from mspgcc 4.7.0) + CFLAGS += -mmemory-model=large -mcode-region=far -mdata-region=far -msr20 -mc20 -md20 + LDFLAGS += -mmemory-model=large -mcode-region=far -mdata-region=far -msr20 -mc20 -md20 +endif endif contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o}