Author Topic: Compiling a MPLABX pic 18 project using cli, without opening MPLABX  (Read 1297 times)

0 Members and 1 Guest are viewing this topic.

Offline cedric-airTopic starter

  • Newbie
  • Posts: 2
  • Country: nl
I'm trying to compile a PIC18 hex file by running MPLABX and XC8 in a ubuntu 22.04 virtual machine, in a github action. Therefore I'm unable to run MPLABX there.

I'm starting with these files:
Code: [Select]
$ find
.
./Airco
./Airco/nbproject
./Airco/nbproject/configurations.xml
./Airco/nbproject/project.xml
After running prjMakefilesGenerator.sh I have a number of makefiles:
Code: [Select]
werk@cedric cicd]$ /opt/microchip/mplabx/v5.50/mplab_platform/bin/prjMakefilesGenerator.sh Airco/
werk@cedric cicd]$ find
.
./Airco
./Airco/nbproject
./Airco/nbproject/configurations.xml
./Airco/nbproject/project.xml
./Airco/nbproject/Makefile-impl.mk
./Airco/nbproject/Makefile-variables.mk
./Airco/nbproject/Makefile-genesis.properties
.
This is not yet enough to compile the project:
Code: [Select]
$ cd Airco/
[werk@cedric Airco]$ make
make: *** No targets specified and no makefile found. Stop.

For reference here's the github action:
Code: [Select]

name: Airco
run-name: ${{ github.actor }} is building Airco
on: [push]
jobs:
  tutorial:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm install -g bats
      - run: bats -v
  tutorial2:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repo
      uses: actions/checkout@v2
      with:
        submodules: 'recursive'
    - name: Install dependencies
      run: |
        sudo apt-get update && \
        sudo apt-get install -y libc6 libx11-6 libxext6 libstdc++6 libexpat1 libusb-dev git make && \
        sudo apt-get clean && \
        sudo apt-get autoremove && \
        sudo rm -rf /var/lib/apt/lists/*
    - name: Install XC8
      run: |
        wget [url]https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/SoftwareTools/xc8-v2.36-full-install-linux-x64-installer.run[/url] &&
        chmod +x xc8-v2.36-full-install-linux-x64-installer.run && \
        sudo ./xc8-v2.36-full-install-linux-x64-installer.run --mode unattended --unattendedmodeui none --netservername localhost --prefix "/opt/microchip-mplabxc8-bin/"
    - name: Install MPLABX
      run: |
        wget -U "Mozilla" [url]https://www.microchip.com/bin/download?f=aHR0cHM6Ly93dzEubWljcm9jaGlwLmNvbS9kb3dubG9hZHMvYWVtRG9jdW1lbnRzL2RvY3VtZW50cy9ERVYvUHJvZHVjdERvY3VtZW50cy9Tb2Z0d2FyZVRvb2xzL01QTEFCWC12Ni4xMC1saW51eC1pbnN0YWxsZXIudGFy[/url] -O MPLABX-v6.10-linux-installer.tar &&
        tar -xf MPLABX-v6.10-linux-installer.tar &&
        sudo ./MPLABX-v6.10-linux-installer.sh --nox11 -- --unattendedmodeui none --mode unattended --ipe 0 --collectInfo 0 --installdir /opt/mplabx
    - name: install device pack
      run: |
        wget -U "Mozilla" [url]https://packs.download.microchip.com/Microchip.PIC18F-J_DFP.1.4.41.atpack[/url] &&
        sh /opt/mplabx/mplab_platform/bin/packmanagercli.sh --install-from-disk Microchip.PIC18F-J_DFP.1.4.41.atpack
    - name: Output results
      run: |
        ls -l
    - name: Compile Source
      run: |
        sh /opt/mplabx/mplab_platform/bin/prjMakefilesGenerator.sh Airco/ &&
        cd cicd/Airco/ &&
        make clean &&
        make &&
        cd ../../ &&
        cp cicd/Airco/dist/default/production/Airco.production.hex . &&
        ls -l
    - name: Store Artifacts
      uses: actions/upload-artifact@v2
      with:
        name: Hex-files
        path: |
          *.hex

how can I generate all the makefiles?
Is there an example with a working github action file?
 

Offline The Chump

  • Contributor
  • Posts: 43
  • Country: gb
Re: Compiling a MPLABX pic 18 project using cli, without opening MPLABX
« Reply #1 on: April 21, 2024, 10:20:16 pm »
Hi Cedric,
The command to use for building on windows is (after setting up PATH to include the path to make.exe)
make.exe -B -f Makefile CONF=default -j 8

You need to run this from the project directory (/Airco)

so I suspect the equivalent on Linux is:
make -B -f Makefile CONF=default -j 8

"default" is the configuration name specified when you used Mplab X to create the project
"Makefile" is a file called "Makefile" in the project directory, which Mplab X should have created for you.
ie there should be a "Makefile" in the /Airco directory

Good Luck,
Alex
 

Offline cedric-airTopic starter

  • Newbie
  • Posts: 2
  • Country: nl
Re: Compiling a MPLABX pic 18 project using cli, without opening MPLABX
« Reply #2 on: April 22, 2024, 09:43:45 am »
Thank you Alex,
I have solved it by opening it in MPLABX on ubuntu 22.04, and then have the following steps in my build.yml file:

Code: [Select]
name: Revomax
run-name: ${{ github.actor }} is building Revomax
on: [push]
jobs:
  Revomax:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repo
      uses: actions/checkout@v2
      with:
        submodules: 'recursive'
    - name: Install dependencies
      run: |
        sudo apt-get update && \
        sudo apt-get install -y libc6 libx11-6 libxext6 libstdc++6 libexpat1 libusb-dev git make && \
        sudo apt-get clean && \
        sudo apt-get autoremove && \
        sudo rm -rf /var/lib/apt/lists/*
    - name: Install XC8
      run: |
        wget [url]https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/SoftwareTools/xc8-v2.36-full-install-linux-x64-installer.run[/url] &&
        chmod +x xc8-v2.36-full-install-linux-x64-installer.run && \
        sudo ./xc8-v2.36-full-install-linux-x64-installer.run --mode unattended --unattendedmodeui none --netservername localhost --prefix "/opt/microchip-mplabxc8-bin/"
    - name: Install MPLABX
      run: |
        wget -U "Mozilla" [url]https://www.microchip.com/bin/download?f=aHR0cHM6Ly93dzEubWljcm9jaGlwLmNvbS9kb3dubG9hZHMvYWVtRG9jdW1lbnRzL2RvY3VtZW50cy9ERVYvUHJvZHVjdERvY3VtZW50cy9Tb2Z0d2FyZVRvb2xzL01QTEFCWC12Ni4xMC1saW51eC1pbnN0YWxsZXIudGFy[/url] -O MPLABX-v6.10-linux-installer.tar &&
        tar -xf MPLABX-v6.10-linux-installer.tar &&
        sudo ./MPLABX-v6.10-linux-installer.sh --nox11 -- --unattendedmodeui none --mode unattended --ipe 0 --collectInfo 0 --installdir /opt/mplabx
    - name: install device pack
      run: |
        wget -U "Mozilla" [url]https://packs.download.microchip.com/Microchip.PIC18F-J_DFP.1.4.41.atpack[/url] &&
        sh /opt/mplabx/mplab_platform/bin/packmanagercli.sh --install-from-disk Microchip.PIC18F-J_DFP.1.4.41.atpack
    - name: Compile Source
      run: |
        sh /opt/mplabx/mplab_platform/bin/prjMakefilesGenerator.sh cicd/Bootload/ &&
        sh /opt/mplabx/mplab_platform/bin/prjMakefilesGenerator.sh cicd/Airco/ &&

        sudo mkdir /opt/PIC18F-J_DFP
        sudo sh /opt/mplabx/mplab_platform/bin/packmanagercli.sh --install-from-disk Microchip.PIC18F-J_DFP.1.4.41.atpack --location /opt/PIC18F-J_DFP
        sudo mkdir /opt/DFP &&
        sudo sh /opt/mplabx/mplab_platform/bin/packmanagercli.sh --install-from-disk Microchip.PIC18F-J_DFP.1.4.41.atpack --location =/opt/microchip &&
        export MP_CC="/opt/microchip-mplabxc8-bin/bin/xc8-cc" &&
        export DFP_DIR="/opt/PIC18F-J_DFP/Microchip/PIC18F-J_DFP/1.4.41/" &&
        find &&
        cd ./cicd/Bootload/ &&
        find &&
        make clean &&
        make &&
        cd ../../ &&
        cp cicd/Bootload/dist/default/production/Bootload.production.unified.hex . &&
        cp cicd/Airco/dist/default/production/Airco.production.hex . &&
        ls -l
    - name: Store Artifacts
      uses: actions/upload-artifact@v2
      with:
        name: Hex-files
        path: |
          *.hex
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3148
  • Country: ca
Re: Compiling a MPLABX pic 18 project using cli, without opening MPLABX
« Reply #3 on: April 23, 2024, 03:37:32 am »
Wouldn't that be easier to write your own makefile? It's just a few lines of text.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf