Electronics > Microcontrollers

Compiling a MPLABX pic 18 project using cli, without opening MPLABX

(1/1)

cedric-air:
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: ---$ find
.
./Airco
./Airco/nbproject
./Airco/nbproject/configurations.xml
./Airco/nbproject/project.xml

--- End code ---
After running prjMakefilesGenerator.sh I have a number of makefiles:

--- Code: ---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
.

--- End code ---
This is not yet enough to compile the project:

--- Code: ---$ cd Airco/
[werk@cedric Airco]$ make
make: *** No targets specified and no makefile found. Stop.

--- End code ---

For reference here's the github action:

--- Code: ---
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

--- End code ---

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

The Chump:
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

cedric-air:
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: ---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

--- End code ---

NorthGuy:
Wouldn't that be easier to write your own makefile? It's just a few lines of text.

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod