(newbie) SDCC compile error in Linux

Help
2008-08-20
2013-03-12
  • I am absolutely new at programming a microcontroller. I have tried to compile the following program:

    /*
        toggle_led.c
        Micah Carrick - email@micahcarrick.com
        04.25.2005
       
        Toggles an LED on Pin 1 of PORTB on a PIC16F627.  Written
        as a sample for the article on using SDCC and GPSIM in
        Linux. http://www.micahcarrick.com/v2/content/view/14/4/
       
        Compile:    sdcc --debug -mpic14 -p16f627 toggle_led.c
        Simulate:   gpsim -pp16f627 -s toggle_led.cod toggle_led.asm

    */

    /* Define processor and include header file. */
    #define __16f627
    #include"pic/pic16f627.h"

    /* Setup chip configuration */
    typedef unsigned int config;
    config at 0x2007 __CONFIG = _CP_OFF &
                              _WDT_OFF &
                              _BODEN_OFF &
                              _PWRTE_OFF &
                              _ER_OSC_CLKOUT &
                              _MCLRE_ON &
                              _LVP_OFF;

    #define b1          0x02    /* pin 1 on PORTB */
    #define B_OUTPUTS   0xFD    /* value used to setup TRISB */

    void main(void) {

        /* PORTB.1 is an output pin */   
        TRISB = B_OUTPUTS;      

        while(1) {          /* Loop forever */
               
            /* toggle bit 1 */
            PORTB = (PORTB ^ b1);  
               
        }
    }

    sdcc outputs two warnings and an error:

    toggle_led.asm:164:Warning [231] directive ignored when debug info is disabled
    toggle_led.asm:185:Warning [231] directive ignored when debug info is disabled
    libsdcc.lib: No such file or directory

    and exits, without making the ihx file. I suspect that sdcc does not finish the job because it cannot find the libsdcc.lib file. Running "locate libsdcc.lib" yields a bunch of files with such name:

    /usr/share/sdcc/lib/ds390/libsdcc.lib
    /usr/share/sdcc/lib/ds400/libsdcc.lib
    /usr/share/sdcc/lib/large/libsdcc.lib
    /usr/share/sdcc/lib/medium/libsdcc.lib
    /usr/share/sdcc/lib/small/libsdcc.lib
    /usr/share/sdcc/lib/small-stack-auto/libsdcc.lib

    I have downloaded and installed sdcc and sdcc-libc-sources binary (rpm) packages in Fedora 7 Linux. gpsim and gputils are also installed. I have followed the instructions in the sdcc manual, Section 2.7 - Testing the SDCC Compiler (http://sdcc.sourceforge.net/doc/sdccman.html/node26.html) to test sdcc installation, and the testing went OK.

    What went wrong, and how can I fix it? Any help will be greatly appreciated.

    Thank you,
    Ferdi Badescu.

     
    • Raphael Neider
      Raphael Neider
      2008-08-21

      Fedora 7 shipped an incomplete version of the sdcc-2.6.0 package: Probably due to missing gputils on the package build system, the PIC/PIC16 libraries are not built and thus not included in the .rpm package. ... would be rather old anyways (2.6.0 was released in mid-2006)...

      Recommendation:
      * Download a recent version of sdcc (either 2.8.0 as our latest release or better yet a snapshot from http://sdcc.sourceforge.net/snap.php\)

      * Untar the source archive

      * Build the package (./configure --disable-mcs51-port --disable-gbz80-port --disable-z80-port --disable-avr-port --disable-ds390-port --disable-ds400-port --disable-xa51-port --disable-hc08-port --disable-ucsim --disable-packihx && make -s)
        You might want to add --prefix=$HOME/local to the configure command line in order to install sdcc as non-root user into your home, then add $HOME/local/bin to your $PATH via 'export PATH=$PATH:$HOME/local/bin' (bash) or via 'set PATH $PATH:$HOME/local/bin' (csh)

      * This should build the pic libraries as well iff gputils are available in the $PATH, otherwise add them to your PATH and
        cd device/lib/pic
        ./configure && make

      * Install sdcc using make install (either as root into /usr/share or as yourself having used the --prefix option to configure)

      * Maybe use PORTB ^= b1 instead of PORTB = (PORTB ^ b1), the former *might* result in more compact code

      Good luck,
      Raphael