After discussing Linux in the GCC thread, I thought I’d post my notes on how to port the OpenAT SDK to Linux.
I’m using OpenAT SDK v4.22a. For other versions, you’ll probably have to fix up some of the version numbers in the paths.
My Linux distribution is CentOS 5.1, but there’s very little here that should be distrubution-dependent.
Step 1
Install OpenAT on a Windows PC.
From the Cygwin shell, run “arm-elf-gcc -v”. This will tell you what version of GCC you need and how to configure it. This information is used in Step 2.
Step 2
Install the ARM tools (binutils, GCC, and newlib). Here’s a script that I use to build and install the tools.
WARNING: This script has no error checking. It also calls sudo a few times, which means you’ll be prompted for a password without any explination. This script is more of an example of the steps needed, than an automated build tool.
#!/bin/bash
mkdir arm-build
cd arm-build
# Download the files (you may want to use closer mirrors)
wget http://ftp.gnu.org/gnu/binutils/binutils-2.16.1.tar.bz2
lftpget ftp://mirrors.laffeycomputer.com/pub/gcc.gnu.org/pub/gcc/releases/gcc-4.0.1/gcc-core-4.0.1.tar.bz2
lftpget ftp://sources.redhat.com/pub/newlib/newlib-1.13.0.tar.gz
# I don't know if this version of t-arm-elf is needed, but I used it anyway...
wget http://gnuarm.com/t-arm-elf
# Build & Install binutils
tar xvfj binutils-2.16.1.tar.bz2
mkdir binutils-2.16.1-arm
cd binutils-2.16.1-arm/
../binutils-2.16.1/configure --target=arm-elf --enable-shared --enable-threads --enable-interwork --enable-multilib --with-float=soft
make
sudo make install
cd ..
# Extract newlib (gcc needs it)
tar xvfz newlib-1.13.0.tar.gz
# Build & Install gcc
tar xvfj gcc-core-4.0.1.tar.bz2
cp t-arm-elf gcc-4.0.1/gcc/config/arm
mkdir gcc-4.0.1-arm
cd gcc-4.0.1-arm/
../gcc-4.0.1/configure --target=arm-elf --enable-shared --enable-threads --enable-interwork --enable-multilib --enable-languages="c" --with-newlib --without-headers --with-float=soft
make all-gcc
sudo make install-gcc
cd ..
# Finish building & install newlib
mkdir newlib-1.13.0-arm
cd newlib-1.13.0-arm/
../newlib-1.13.0/configure --target=arm-elf --enable-shared --enable-threads --enable-interwork --enable-multilib --with-float=soft
make
sudo make install
cd ..
# Finish building & installing gcc
cd gcc-4.0.1-arm/
../gcc-4.0.1/configure --target=arm-elf --enable-shared --enable-threads --enable-interwork --enable-multilib --enable-languages="c" --with-newlib --with-float=soft
make all
sudo make install
cd ..
# All done. Leave the arm-build directory.
cd ..
Step 3
UPDATE: With the Makefile listed in this topic: viewtopic.php?t=2388 you can skip step 3 all together (except for copying the OpenAT directory to your Linux home directory).
To port OpenAT to Linux, copy the OpenAT directory from the Windows PC to your home directory on the Linux PC and run this script.
WARNING: This script has no error checking. It also calls sudo, which means you’ll be prompted for a password without any explination. This script is more of an example of the steps needed, than an automated build tool.
#!/bin/bash
####################
# create the ~/.oatrc file
cat >~/.oatrc <<OATRC_END
export WM_OAT_IDE_OS_DEFAULT="\$HOME/OpenAT/OS/4.21.01"
export WM_OAT_IDE_FW_DEFAULT="\$HOME/OpenAT/Firmware/663"
export WM_OAT_IDE_PLUGINS="\$HOME/OpenAT/Plug-ins"
export WM_OAT_IDE_GTS_GCC="/usr/local"
export WM_OAT_IDE_ECLIPSE="\$HOME/OpenAT/IDE/Eclipse/3.2.2"
OATRC_END
####################
# modify environment variables
cat >>~/.bash_profile <<BASH_PROFILE_END
export WM_OAT_IDE=\$HOME/OpenAT/IDE/IDE/1.04.06
export WM_OAT_IDE_ENV=linux
export PATH=\$PATH:\$WM_OAT_IDE/bin:\$WM_OAT_IDE/sgt/script_sgt
export SGT_DIR=\$WM_OAT_IDE/sgt
export SGT_SCRIPT=\$WM_OAT_IDE/sgt/script_sgt
export SGT_VER=v1.2.12oat
BASH_PROFILE_END
####################
# fix for building BAT files (which we don't use anyway)
cd ~/OpenAT/IDE/IDE/1.04.06/
touch bin/crlf
chmod +x bin/crlf
####################
# fix embedded scripts with missing semicolons
for mak in `ls sgt/mak/*`; do sed -i "s/done\\\\/done;\\\\/;s/fi\\\\/fi;\\\\/" $mak; done
####################
# move script to where the build environment expects to find it
sudo install -m 755 ../../GCC/4.0.1.0/bin/fromelf /usr/local/bin/
####################
# don't specify the path to zip in the build environment, just use $PATH
sed -i "s./usr/local/bin/zip.zip." sgt/mak/tools.mak
####################
# fix the path to AXFshrinker
sed -i "s:/projet/tools/share/Tatoo/AXFshrinker/V1.0.0.1:\\\${SGT_DIR}/tools/linux:" bin/wmmake
####################
# remove unused directories
cd ~/OpenAT/IDE/
rm -rf Eclipse GCC MINGW IDE/1.04.06/cygwin IDE/1.04.06/MINGWlogger
That’s it. It should be usable. Since ~/.bash_profile was modified, you’ll need to restart bash to get it to reload it.
I haven’t tried Eclipse under Linux, but there’s no reason it shouldn’t work. (I believe building under Eclipse invokes LoadIde.bat, so that’ll need to change, but that eventually calls OpenAT/IDE/IDE/1.04.06/LoadIde.sh so it shouldn’t be hard to change.)
You may way to read chapter 8 in ~/OpenAT/IDE/IDE/1.04.06/doc/TM_Tools_Manual_for_Open_AT.pdf
to learn the command line tools for making new projects, etc. Here’s a quick primer:
To make a new project or to update an existing project, use wmnew.
An example of creating a new project:
wmnew -adl -app -mem 256KB -gts GCC -plugin WIP/3.00.09 -n -name my_new_proj
An example of updating the project:
wmnew -adl -app -mem 256KB -gts GCC -plugin WIP/3.00.09
To build code, use “wmmake”.
To load the code using minicom, I had to edit the file transfer protocols and add these two protocols (you really only need the first one):
J xmodem-1K /usr/bin/sx -vv --1k Y U N Y N
K xmodem-1K /usr/bin/rx -vv --1k Y D N Y N
After typing “AT+WDWL”, I found that hitting Cntl-A a couple of times before starting the file transfer (Cntl-A, S) made the transfer work reliably. I have no idea why this works and I don’t like it. Eventually I’ll spend the time to understand what’s going on, but I usually update via DOTA so I haven’t been using minicom much.
Hopefully, this post isn’t information overkill. It’s a modified cut-and-paste of my notes, so I hope I didn’t get out of hand…
If you use Linux, make sure your Wavecom distributor knows. With enough feedback, the Wavecom developers may be motivated to make this easier. I’ve already bugged my Wavecom contacts.