Menu

Linker error when trying to build flashforth-USB 5.0 for the PIC18F45K50

Jesito
2019-12-21
2020-01-11
  • Jesito

    Jesito - 2019-12-21

    It's driving me crazy... It has taken me a while to install MPLAB IDE, creating an assembly project, include and modify the source files, and at the end I get an error when linking the project:
    Probably I'm doing something wrong, but I do not know what it is.
    Any help will be very welcome.
    Kind regards.
    Jes.

    Release build of project `C:\Users\jesito_2\projects\FF_USB\FlashForth_USB.mcp' started.
    Language tool versions: MPASMWIN.exe v5.51, mplink.exe v4.49, mplib.exe v4.49
    Fri Dec 20 22:17:53 2019
    ----------------------------------------------------------------------
    Make: The target "C:\Users\jesito_2\projects\FF_USB\ff-pic18.o" is out of date.
    Executing: "C:\Program Files (x86)\Microchip\MPASM Suite\MPASMWIN.exe" /q /p18F45K50 "pic18\src\ff-pic18.asm" /l"ff-pic18.lst" /e"ff-pic18.err" /o"ff-pic18.o"
    Make: The target "C:\Users\jesito_2\projects\FF_USB\usbcdc.o" is up to date.
    Make: The target "C:\Users\jesito_2\projects\FF_USB\FlashForth_USB.cof" is out of date.
    Executing: "C:\Program Files (x86)\Microchip\MPASM Suite\mplink.exe" /p18F45K50 "pic18\lkr\FF_USB_0800.lkr" "ff-pic18.o" "usbcdc.o" /z__MPLAB_BUILD=1 /o"FlashForth_USB.cof" /M"FlashForth_USB.map" /W
    MPLINK 4.49, Linker
    Device Database Version 1.14
    Copyright (c) 1998-2011 Microchip Technology Inc.
    Error - section 'FF_INT_HI' has a memory 'codeih' which can not fit the absolute section. Section 'FF_INT_HI' start=0x00000008, length=0x0000232e.
    Errors    : 1
    
    Link step failed.
    ----------------------------------------------------------------------
    Release build of project `C:\Users\jesito_2\projects\FF_USB\FlashForth_USB.mcp' failed.
    Language tool versions: MPASMWIN.exe v5.51, mplink.exe v4.49, mplib.exe v4.49
    Fri Dec 20 22:17:55 2019
    ----------------------------------------------------------------------
    BUILD FAILED
    
     
  • Mikael Nordman

    Mikael Nordman - 2019-12-21

    Probably you are using the wrong linker file.
    Use FF_USB_0000.lkr

     
  • Jesito

    Jesito - 2019-12-21

    My apologies, I did not tell all the details.
    To try the interrupts stuff I would like to use a PIC18F45K50 that is inside a Pinguino board (an open project that was left unattended since 2017, and that I keep one board). It is interesting because it has an USB interface and a bootloader, so I thought to upload FF on it without affecting the basic structure.
    According the docs for the PIC18 family, I have to create a MPLAB project with ff-pic18.asm and link the FF_USB_xxxx.lib (being xxxx=0800 because the bootloader). I have also to define USB_CDC in the configuration file (p18f24k50-25k50-45k50.cfg) and use the FF_USB_0800.lkr file and define CONFIG_RESET 0x0800 in p18f-main.cfg.
    I've also found out that is necessary to assemble usb_cdc.asm.
    When asking MPLAB to make the project it returns an error message telling "section 'FF_INT_HI' has a memory 'codeih' which can not fit the absolute section. Section 'FF_INT_HI' start=0x00000008, length=0x0000232e." that is beyond my knowledge, but looking in the net it seems there is a max size for code sections and that should be splitted. Or I have some misunderstanding and I have done some wrong assumption :(

    If no other way possible, I would try to assemble, link and flash the non-bootloader version, but it will take me more time because my programmer and other tools are sitting in a box in the garage since the last move (a few years ago).

    Anyway, I got the Arduino UNO version running (thanks, Mikael!) by now, and I'll will be learning FF with it by now. A great platform for microcontroller development.

     

    Last edit: Jesito 2019-12-21
  • Jesito

    Jesito - 2019-12-21

    Just built the non-bootloader version and it seems okay, no errors.
    Maybe I have to begin afresh again...

     
  • Mikael Nordman

    Mikael Nordman - 2019-12-21

    I am sorry, I have broken the linker script by using absolute adresses in sorce file.
    Need to fix that.

    FF_RESET code 0x0800
            nop                      ; 18f252/18f258 ERRATA
            goto    main
    ;;***************************************************
    ;; Interrupt routines
    ;; 1 millisecond tick counter
    FF_INT_HI code 0x0808
    

    Can be used as a quick fix, or check how to refer to linker sections from the code.

     
  • Jesito

    Jesito - 2019-12-21

    No problem :)

    I tried your fix and the build doesn't give that error anymore, but a new one appeared:

    MPLINK 4.49, Linker
    Device Database Version 1.14
    Copyright (c) 1998-2011 Microchip Technology Inc.
    Error - section 'FORTH_VARS' has a memory 'acs_ram' which can not fit the section. Section 'FORTH_VARS' length=0x0000002f.
    Errors    : 1
    

    Looking in the files;

    C:\Users\jesito_2\projects\FF_USB\pic18\src\ff-pic18.asm:171: FORTH_VARS  udata_acs; Variables in Access Ram
    C:\Users\jesito_2\projects\FF_USB\pic18\src\usbcdc.asm:134: FORTH_VARS      udata_acs
    C:\Users\jesito_2\projects\FF_USB\pic18\lkr\FF_USB_0800.lkr:28: SECTION NAME=FORTH_VARS   RAM=acs_ram
    Search complete. 3 matches found.
    

    And looking for acs_ram in the linker USB+bootloader file:

    ACCESSBANK NAME=acs_ram    START=0x10           END=0x38           PROTECTED
    

    But in the linker USB not bootloader the definition is bigger:

    ACCESSBANK NAME=acs_ram    START=0x10           END=0x3F           PROTECTED
    

    If I change the END=0x38 by 0X3F and the START of the next line by 0x40, I get a new error:

    MPLINK 4.49, Linker
    Device Database Version 1.14
    Copyright (c) 1998-2011 Microchip Technology Inc.
    Error - section '.code' can not fit the section. Section '.code' length=0x0000027a
    Errors    : 1
    

    Not able to guess anything else ;)

     
  • Mikael Nordman

    Mikael Nordman - 2019-12-21

    Try these changes to the linker file

    CODEPAGE   NAME=codeih     START=0x0808         END=0x02ED7
    CODEPAGE   NAME=code1      START=0x2ED8         END=0x02EFF        PROTECTED
    CODEPAGE   NAME=code2      START=0x2f00         END=0xFFFFF        PROTECTED
    
     
  • Jesito

    Jesito - 2019-12-21

    Success!!!

    MPLINK 4.49, Linker
    Device Database Version 1.14
    Copyright (c) 1998-2011 Microchip Technology Inc.
    Errors    : 0
    
    MP2HEX 4.49, COFF to HEX File Converter
    Copyright (c) 1998-2011 Microchip Technology Inc.
    Errors    : 0
    

    Now I'll try to upload it to the 18F45K50...

    Thanks a lot!

     
  • Jesito

    Jesito - 2019-12-21

    well, no luck :(
    It seems to upload okay, but the usb-win32 device does not show up on the Device Manager as it does when in upload mode. Let me check the specs of the Pinguino bootloader...

     

    Last edit: Jesito 2019-12-21
  • Jesito

    Jesito - 2020-01-03

    I gave up on this by now, I was blind to see anything with my current setup.
    So I decided to recover my boxes from the garage. I found a box with a lot of nice PICs there, my old programmer/ICSP (wisp628). Took the dust off and tried to program the 45K50 without a bootloader but my programmer's firmware is too old and does not recognize the chip. Went to Voti.nl and found a new firmware version, but it does need the 16f648A instead of the current 16f628A. Ordered a couple from eBay. In the meantime it arrives, I thought on using another chip from the lot I found at the garage. There were a couple of 18F458. According the datasheets, these need a TTL-RS232 converter. Found a MAX232 as well, so I put hands to work and buit a small board on perf pads. First power, then MAX232. Tried with a loopback and from Putty seems to work.
    Next, I wired the processor and the ICSP connection. Not working. To debug it I took out the processor and placed it in a prototype board I have with all the connections ready. I wanted to test the processor with a simple LED blinking on RA1 to ensure the ICSP and the processor are fine.
    Then comes the next question: I have a 20Mhx xtal. In the configuration files of the FF projects, the default clock seems to be 48Mhz, (this might well be due to the use of a 12Mhz xtal and using a PLLx4 feature). But I cannot find any place where to specify I am not going to use the PLLx4 feature...

    ;;;  Specify the cpu clock frequency here
    ;;;  It must be aligned with the processor specific configuration bits 
    ;;;  In case of bootloader, it is the boot loader configuration that
    ;;;  determines the clock frequency.
    
     constant clock=d'48000000'  ; Hz
    

    in P18Fxxxx.cfg the 18F458 definitions are:

    ifdef __18F458
                #include p18f458.inc
                #include p18fxx2xx8.cfg
                #define  p18fxx2xx8_fix_1
                #define  PICTYPE "PIC18F458  "
                #define FLASH_LO  0x0000
                #define FLASH_HI  0x7fff
                #define EEPROM_LO 0xec00
                #define EEPROM_HI 0xecff
                #define RAM_LO    0xf000
                #define RAM_HI    0xf5ff
                #define EEDATA_LO 0xf00000
            endif
    

    so I went to p18fxx2xx8.cfg and saw:

    #if CONFIG_RESET == 0x0000
            config OSC = HS
            config OSCS = OFF
            config PWRT = ON
            config BOR = OFF
            config WDT = ON
            config WDTPS = 128
            config STVR = ON
            config LVP = OFF
            config WRT0 = ON
            config WRTB = ON
            config WRTC = ON
    #endif
    

    that seemed the configuration bits I was looking for.
    According the data sheet, the PLLx4 feature is called HS4. To test it I put OSC = HS4 but it gave me a nice error....
    Keep trying.
    A picture of the board:

     
  • Mikael Nordman

    Mikael Nordman - 2020-01-03

    With a 20 MHz crystal this should work.

    constant clock=d'20000000'  ; Hz 
    config OSC = HS
    
     

Log in to post a comment.