Installing mplab x linux

AVR Debugging with Atmel-ICE in MPLAB X IDE on Linux

In this article I will try to explain howto install and use Microchip’s MPLAB X IDE and an Atmel-ICE prorgammer/debugger to program and debug a ATMega168P using the debugWIRE interface.

Why the ATMega168P? Because that’s the AVR that I’m currently using and the debugWIRE setup can be a bit tricky 1 .

Installation

  1. The MPLAB Compiler(s), There are 3
    1. MPLAB XC8 supports all 8-bit PIC ® and AVR ® microcontrollers (MCUs)
    2. MPLAB XC16 supports all 16-bit PIC MCUs and dsPIC ® Digital Signal Controllers (DSCs)
    3. MPLAB XC32/32++ supports all 32-bit PIC and SAM MCUs and MPUs

    Note: The XC compilers are free but there is a professional license option that gives more features, this is not required and fairly expensive for hobby use.

    Now let’s start the installation of the XC8 Compiler, since that’s the only one I’ll be using.

    I’m using Debian GNU/Linux so if you are using a Debian or Ubuntu based distribution you can copy & paste these instructions, if your distro uses a different package manager you’ll need to use that one to install the required dependencies.

    1. To be able to use MPLAB X IDE and the XC compilers on a 64-bit linux distribution, the 32-bit architecture support needs to be enabled. This is not done by default so you’ll need to add the i386 architecture first: sudo dpkg —add-architecture i386 followed by sudo apt update .sudo dpkg --add-architecture i386
    2. Next we’ll need to add some additional 32-bit packages: sudo apt install libc6-dev:i386 libgcc-10-dev:i386 libexpat1-dev:i386 libx11-dev:i386 libxext-dev:i386
    3. Now we are ready to install the XC8 Compiler: MPLAB XC8 C Compiler

    default install location

    Unless you have a license, use the default «Free mode»

    Ready to start Installation

    You can select «Apply settings to all users» if you have multiple user accounts, adding the xc8 to the PATH environment makes sure you can call these tools from anywhere in your filesystem and not only from the installed location.

    Click Next to start the installationInstallation in progressLicensing Information

    Finisheg installation

    When the installation is complete, you’ll get a message to active or purchase a Professional license, you can just skip this with the Next button.

    Installing MPLAB X IDE

    The compiler is now installed. Repeat this for the other 2 compilers if needed.
    Finally we install the MPLAB X IDE

    Required Hardware

    Since this is an article on using an Atmel-ICE you’ll offcourse need one of those to follow allong. There are other devices that are supported by MPLAB X IDE, but not all devices that are supported by Atmel Studio 7 are supported by MPLAB (for example the ATSTK600 development board contains a STK600 programmer that is supported in Atmel Studio 7, but it’s not listed in the supported hardware section of MPLAB X IDE).

    1. Atmel-ICE Programmer/debugger. There are 3 versions for sale
      1. Atmel-ICE PCBA Debugger (cheapest version without plastic casing and cables
      2. Atmel-ICE Basic Debugger (mid-range with plastic case and USB and flatcable with 10-pin 50mil connector and 6-pin 100mil connector) you’ll need the 6-pin 100mil connector to connect to a standard 6-pin ISP header.
      3. Atmel-ICE Debugger (full version also including an Adapter board (20-pin 100mil connector, 6-pin 50mil connector and 10-pin 100mil connector). The 10-pin 100mil connector can be used to connect to a standard 10-pin JTAG header (ATMega2560 for example).

      To connect the Atmel-ICE debugger connect the flatcable to the 50mil 10-pin header labeled AVR, the red wire should be on the left side (closest to the 3 LEDs). And connect the 100mil 6-pin connector to the ISP header of the microcontroller.

      Power on the Atmel-ICE (connect the USB cable). The middle (red LED) should turn on.

      Power on the target board, if all goes well the leftmost (green) LED should turn on.

      You are now ready to start debugging.

      Putting the AVR in debugWIRE mode to program/debug

      MPLAB X IDE

      Open MPLAB X IDE

      New project

      Write a simple test program (like a blinking LED to test programming/debugging).

      Select the compiler

      Under Tool: all available tools are listed, if the Atmel-ICE is connected it should be listed here, if not there is the default («no tool») and a «simulator», if you want to see all supported Tools check the Show All box and go through the list.

      Project Name

      Select the XC8 compiler, as you can see I’ve also installed the Toolchain under /home/patrick/avr8/bin (version 5.4.0) the other versions are provided by my distribution.

      add new file

      Set a project name and location or use the default MPLAB X IDE project directory.

      new file

      Add a new avr-main.c file (I’ve called mine blinkLED)

      test program

      switch to debugWIRE mode

      Compile and write the project to the microcontroller (you can also press the «Debug Main Project» button to compile, write and start debugging).

      Programming complete

      If this is the first time you’ve started a debugging session the AVR probably still in ISP mode and this makes it not possible to use the debugWIRE interface. Answer Yes to this question and MPLAB will use the ISP mode of the Atmel-ICE to switch to debugWIRE mode.

      Select Communications under Categories and ISP for the Interface . The setting there will be 0.000MHz and the Option Description reads that this setting should be between 0.000 and 0.000MHz (looks like a bug to me).

      Note: I’ve been in contact with Microchip Support about this issue, and they confirm this is a bug in the new version (5.40) here is their reply

      The issue has been reported. Kindly try the below workarounds suggested by our internal team and let us know if it helps.

      In v5.40 the default speed regressed to 0.0 MHz, which causes errors such as:

      Unexpected status code when executing setBaud, expected 0 but got -51 (SPI_STATUS_BAUD_INVALID)

      A valid communication (such as 0.125 MHz or 1/4 of the device clock speed) must be entered when selecting the ISP communication protocol.

      «workaround» #1 — Create the project in v5.35 and then open and use in v5.40.

      «workaround» #2 — manually edit the configurations.xml file in the project to have a valid speed like this:

      Thanks to a post on the AVR Freaks forums I discovered that setting this to a value of 0.01 fixes this problem. MPLAB will say that this is wrong (indicated by the red background) but you can ignore this error message. Now switch the Interface back to debugWIRE and try again.

      It is very important that you don’t manually edit the SPIEN=0 or DEN=0 fuses. When you do this you will be unable to program the microcontroller with a ISP programmer and the microcontroller will become «bricked», the only solution to recover it will be to use a HVPP (High Voltage Parallel Programmer) to reset these fuses. Most people don’t own a HVPP and they are a lot more expensive than the cheap USBasp or USBTinyAVR programmers.

      For example a ATSTK600 starter-kit contains a HVPP that you can use, but in my store it costs €315 and does not come with a socket or router board for the ATMega168P that I’m using here. So adding these 2 to the mix will add €64 for the «Generic Socket Card» and €19 for the «Routing Card»

      Toggle power

      To switch the microcontroller to debugWIRE mode you’ll need to cycle the power and click the OK button within 10 seconds. This will force the AVR to reboot and switch to debugWIRE mode.

      debugging

      Now you can start a debugging session

      Back to ISP Mode

      When you are done debugging you will need to switch back to ISP mode if you want to be able to use a standard ISP programmer. To do this open the Project Properties again, and go to the Atmel-ICE settings. There switch the interface from debugWIRE to ISP.

      before

      Click Apply or Ok and click the Make and Program Device Main Project button.

      Go back to ISP mode

      Click Yes and the microcontroller will be put back into ISP mode again.

      1 at least with version 5.40 of MPLAB X IDE which seems to contain a bug in it’s ISP Speed settings dialog.

      2 Socket Card and Routing Card are not required but I’ve added those for a «shock effect» 😉 There will most likely also be cheaper HVPP programmers than the ATSTK600 since that’s more than just a HVPP.

      CLI Tool van de Week is een initiatief van Linuxgebruikers | Facebook | Contact

      Источник

      postwarrior.com

      MPLABX Integrated Development Environment (IDE) is a free, integrated toolset for the development of embedded applications on Microchip’s PIC and dsPIC microcontrollers.

      MPLAB X is not a new version of the current MPLAB IDE v8 framework but is instead based on Oracle’s open-source NetBeans platform. In addition to its predecessor’s functionalities and compatibility with Microchip’s existing development tools, the new IDE utilises many NetBeans features allowing for user-interface improvements and performance upgrades[1]

      Presumption

      System: Fedora Core 16 — x64

      Downloading

      OR using wget
      wget http://ww1.microchip.com/downloads/mplab/X/mplabx-ide-v1.10-linux-installer.run # mplab X IDE
      wget http://ww1.microchip.com/downloads/mplab/X/mplabc18-v3.40-linux-full-installer.run # C18 Compiler

      Since IDE written in Java we need java run time if you already them installed go to next step if you dont, following the link below

      now we should configure the IDE before we start compiling codes

      from «run» menu —> Set Project Configuration —> customize.

      In left-most click on mcc18 then in right-most scroll down and double-click on «Include directories», a new dialog will be opened,double-click on it and change the default path for header file directories to «/opt/microchip/mplabc18/v3.40/h».

      Compiler Configuration

      Click ok.

      In left-most click on MPLINK then in right-most scroll down and double-click on ‘Library directories’,a new dialog will be opened, double-click on it and change the default path for header file directories to «/opt/microchip/mplabc18/v3.40/lib/».

      Case-Sensitive Problem

      i have notice a small problem when i tried to compile an old project. the error was «Error — could not find file ‘LibName.lib’.

      this problem happen because lib names are written as high-letter on hard disk whereas MPLINK looking for low-letter names. eg ( on disk p18F4550.lib and MPLINK looking for p18f4550.lib).

      to solve this problem we will make all of them low-letter

      Known Bug in Oracle Java JDK 1.6.x

      incorrect mouse pointer position on java menus when running the application
      maximized under gnome-shell.

      1. If I single-click a menu in the menu bar, the menu will flash
      briefly and disappears (instead of staying opened).
      2. If I click and hold on a menu in the menu bar, the menu stays
      opened, but the selection is vertically displaced (I have to move the
      mouse to the third menu item to select the first one, for example).
      3. If I right-click to access a context-menu, the selection is
      displaced as described in the previous case).

      The problem is that when the window is maximized java was not updating the
      window position properly. If the window was at pixel (100,100) then it was
      maximized, AWT thinks that it is still at pixel (100,100) instead of close to
      (0,0). This causes it to miscalculate mouse pointer positions relative to the
      window. [2]

      Solution for this bug

      # yum remove java-1.6.0-openjdk-1.6.0.0-65.1.11.1.fc16.x86_64 java-1.6.0-openjdk-devel-1.6.0.0-65.1.11.1.fc16.x86_64

      # cp /opt/microchip/mplabx/mplab_ide/etc/mplab_ide.conf /opt/microchip/mplabx/mplab_ide/etc/mplab_ide.conf.bk

      search for jdkhome=»/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.3.x86_64/» and replace it with jdkhome=»/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.3.x86_64/»

      *this could be vary from system to another, to know yours

      Источник

      Читайте также:  Open suse enterprise linux
Оцените статью
Adblock
detector