Compilation of pic30 version 3.01
From piklab
If you're using a Debian-based system, John Steele Scott has
made templates that can be readily used: pic30-deb-templates-3.01.tar.bz2.
Here is the procedure I followed (gcc 3.3 and yacc are needed for compiling) :
Compilation of binutils
Steps 1 to 4 can be skipped by downloading the repackaged tarball binutils-pic30-3.01.tar.bz2.
1. Download the tarball called mplabalc30v3_01_A.tar.gz.
2. Unpack:
mkdir binutils-pic30 cd binutils-pic30 tar xvzf ../mplabalc30v3_01_A.tar.gz
3. The files have Windows end-of-line and need to be converted with the following shell command:
find . -type f -exec dos2unix '{}' ';'
4. The following patches should be applied (They can be found here):
patch -p0 < binutils-makefile_in.diff patch -p0 < allow-empty-device-info-file.diff patch -p0 < hardcode-device-info-path.diff patch -p0 < allow-simple-version.diff
5. Compilation (you may need to adjust the exact version of gcc 3.3). Replace pic30-coff by pic30-elf to build executables that compile "elf" files:
cd acme CC="gcc-3.3.6 -DMCHP_VERSION=v3.01" ./configure --prefix=/usr --target=pic30-coff make
6. Installation (as root). Be extra careful with make install since it can erase existing files on your
system (you should do a make -n install first to double-check).
make install cd .. cp c30_resource/src/c30/c30_device.info /usr/share/pic30-support
Compilation of gcc
Steps 1 to 4 can be skipped by downloading the repackaged tarball gcc-pic30-3.01.tar.bz2.
1. Download the tarball called mplabc30v3_01_A.tgz.
2. Unpack:
mkdir gcc-pic30 cd gcc-pic30 tar xvzf ../mplabc30v3_01_A.tgz
3. The files have Windows end-of-line and need to be converted with the following shell command:
find . -type f -exec dos2unix '{}' ';'
4. The following patches should be applied (They can be found here):
patch -p1 < default-include-path.diff patch -p1 < pic30-standard-prefix.diff patch -p1 < resource-path.diff patch -p1 < libiberty-testsuite.diff patch -p1 < t-pic30.diff
5. Compilation. (you may need to adjust the exact version of gcc 3.3). Replace pic30-coff by pic30-elf to build executables that compile "elf" files. Be sure to specify "--prefix=../installdir". Otherwise "make install" will ruin your installed gcc.
cd gcc-4.0.2/ touch gcc-4.0.2/gcc/c-parse.y mkdir installdir mkdir builddir cd builddir echo version_string = \"3.01\" > version-trigger CC="gcc -DMCHP_VERSION=v3.01" ../gcc-4.0.2/configure --prefix=`pwd`/../installdir --target=pic30-coff --enable-languages=c --with-gcc-version-trigger=version-trigger make
6. Fake installation (as a normal user).
make install
7. Installation (as root).
cd ../installdir/bin cp pic30-coff-pic30-coff-cpp /usr/bin/pic30-coff-cpp cp pic30-coff-pic30-coff-gcc /usr/bin/pic30-coff-gcc cp pic30-coff-pic30-coff-gccbug /usr/bin/pic30-coff-gccbug cp pic30-coff-pic30-coff-gcov /usr/bin/pic30-coff-gcov cd ../man/man1 cp pic30-coff-pic30-coff-cpp.1 /usr/share/man/man1/pic30-coff-cpp.1 cp pic30-coff-pic30-coff-gcc.1 /usr/share/man/man1/pic30-coff-gcc.1 cp pic30-coff-pic30-coff-gcov.1 /usr/share/man/man1/pic30-coff-gcov.1 cd ../../libexec/gcc/ cp -R pic30-coff /usr/lib/gcc cd ../../lib/gcc cp -R pic30-coff /usr/lib/gcc
