chipKIT MPIDE Board Variant Mechanism
The chipKIT MPIDE system has been designed to make it relatively easy to adapt the operation of the system to new hardware as boards are designed. We’ve put together a document that describes the mechanisms used in the system to allow a board developer to describe the features of a new board to the system and allow the system to use the new board without the need to modify any of the core hardware abstraction layer code or standard libraries.
The board variant mechanism makes use of a standardized folder structure and set of definition files that can be installed into the MPIDE system that adapt the system to work with new boards. In some cases, these files are distributed with the MPIDE, but board variant files can be easily added into an installation of MPIDE after it has been installed on the client computer.
In addition to the board variant mechanism described here, a developer designing a new board will also need to produce a boot loader for the board. Note that this document does not describe the process required to create a new custom boot loader from the boot loader project, as that process is described in a separate document.
To learn more, download the full guide here.
Header files listed in alphabetical order.
Files are denoted as either (AVR) or (PIC32) specific, if they apply to both platforms they are marked as (AVR|PIC32). For headers that are marked (AVR|PIC32) they can be either “generic” or “ported”. Generic files will work on either platform without modification where ported files are different for AVR or PIC32.
Tools to access program space of the AVR processor, not needed on PIC32, but some macros can be used in its place to make AVR code run on a PIC32.
- if defined(__PIC32MX__)
// neither PROGMEM or PSTR are needed for PIC32, just define them as null
#define PSTR(s) (s)
#define pgm_read_byte(x) (*((char *)x))
#define pgm_read_byte_near(x) (*((char *)x))
#define pgm_read_byte_far(x) (*((char *)x))
#define pgm_read_word(x) (*((short *)x))
#define pgm_read_word_near(x) (*((short *)x))
#define pgm_read_workd_far(x) (*((short *)x))
#define prog_void const void
#define prog_char const char
#define prog_uchar const unsigned char
#define prog_int8_t const int8_t
#define prog_uint8_t const uint8_t
#define prog_int16_t const int16_t
#define prog_uint16_t const uint16_t
#define prog_int32_t const int32_t
#define prog_uint32_t const uint32_t
#define prog_int64_t const int64_t
#define prog_uint64_t const uint64_t
- include <avr/pgmspace.h>
The start of all good programming sessions.
Contains type definitions for PIC32 registers.
SPI.h (AVR|PIC32) ported
Library to provide SPI communications.
stdint.h (AVR|PIC32) ported
This is a dump of the interrupt vector from the Max32 (32MX795F512L)
It gives you an idea what is available and what is already in use.
Arduino-32MX795F512L>V show interrupt Vectors
+++ 0= 02 00---0B4017F0 jump 9D005FC0 _CORE_TIMER_VECTOR
+++ 1= 00 00---FFFFFFFF unused _CORE_SOFTWARE_0_VECTOR
+++ 2= 00 00---FFFFFFFF unused _CORE_SOFTWARE_1_VECTOR
+++ 3= 00 00---FFFFFFFF unused _EXTERNAL_0_VECTOR
+++ 4= 00 00---0B401E5A jump 9D007968 _TIMER_1_VECTOR
+++ 5= 00 00---FFFFFFFF unused _INPUT_CAPTURE_1_VECTOR
+++ 6= 00 00---FFFFFFFF unused _OUTPUT_COMPARE_1_VECTOR
+++ 7= 00 00---FFFFFFFF unused _EXTERNAL_1_VECTOR
+++ 8= 00 00---FFFFFFFF unused _TIMER_2_VECTOR
+++ 9= 00 00---FFFFFFFF unused _INPUT_CAPTURE_2_VECTOR
+++10= 00 00---FFFFFFFF unused _OUTPUT_COMPARE_2_VECTOR
+++11= 00 00---FFFFFFFF unused _EXTERNAL_2_VECTOR
+++12= 00 00---FFFFFFFF unused _TIMER_3_VECTOR
+++13= 00 00---FFFFFFFF unused _INPUT_CAPTURE_3_VECTOR
+++14= 00 00---FFFFFFFF unused _OUTPUT_COMPARE_3_VECTOR
+++15= 00 00---FFFFFFFF unused _EXTERNAL_3_VECTOR
+++16= 00 00---FFFFFFFF unused _TIMER_4_VECTOR
+++17= 00 00---FFFFFFFF unused _INPUT_CAPTURE_4_VECTOR
+++18= 00 00---FFFFFFFF unused _OUTPUT_COMPARE_4_VECTOR
+++19= 00 00---FFFFFFFF unused _EXTERNAL_4_VECTOR
+++20= 00 00---FFFFFFFF unused _TIMER_5_VECTOR
+++21= 00 00---FFFFFFFF unused _INPUT_CAPTURE_5_VECTOR
+++22= 00 00---FFFFFFFF unused _OUTPUT_COMPARE_5_VECTOR
+++23= 00 00---FFFFFFFF unused _SPI_1_VECTOR
+++24= 00 00---0B401B67 jump 9D006D9C _I2C_3_VECTOR _UART_1A_VECTOR _UART_1_VECTOR _SPI_1A_VECTOR _I2C_1A_VECTOR _SPI_3_VECTOR
+++25= 01 00---FFFFFFFF unused _I2C_1_VECTOR
+++26= 00 00---FFFFFFFF unused _CHANGE_NOTICE_VECTOR
+++27= 01 00---FFFFFFFF unused _ADC_VECTOR
+++28= 00 00---FFFFFFFF unused _PMP_VECTOR
+++29= 00 00---FFFFFFFF unused _COMPARATOR_1_VECTOR
+++30= 00 00---FFFFFFFF unused _COMPARATOR_2_VECTOR
+++31= 00 00---0B401BDD jump 9D006F74 _UART_2A_VECTOR _I2C_2A_VECTOR _SPI_2_VECTOR _SPI_2A_VECTOR _I2C_4_VECTOR _UART_3_VECTOR
+++32= 00 00---0B401C53 jump 9D00714C _UART_2_VECTOR _SPI_3A_VECTOR _I2C_3A_VECTOR _UART_3A_VECTOR _SPI_4_VECTOR _I2C_5_VECTOR
+++33= 00 00---FFFFFFFF unused _I2C_2_VECTOR
+++34= 00 00---FFFFFFFF unused _FAIL_SAFE_MONITOR_VECTOR
+++35= 01 00---FFFFFFFF unused _RTCC_VECTOR
===36= 00 00---FFFFFFFF unused _DMA_0_VECTOR
===37= 00 00---FFFFFFFF unused _DMA_1_VECTOR
===38= 00 00---FFFFFFFF unused _DMA_2_VECTOR
===39= 00 00---FFFFFFFF unused _DMA_3_VECTOR
===40= 00 00---FFFFFFFF unused _DMA_4_VECTOR
===41= 00 00---FFFFFFFF unused _DMA_5_VECTOR
===42= 00 00---FFFFFFFF unused _DMA_6_VECTOR
===43= 00 00---FFFFFFFF unused _DMA_7_VECTOR
===44= 00 00---FFFFFFFF unused _FCE_VECTOR
===45= 00 00---FFFFFFFF unused _USB_1_VECTOR
===46= 00 00---FFFFFFFF unused _CAN_1_VECTOR
===47= 00 00---FFFFFFFF unused _CAN_2_VECTOR
===48= 00 00---FFFFFFFF unused _ETH_VECTOR
===49= 00 00---0B401BA2 jump 9D006E88 _UART_4_VECTOR _UART_1B_VECTOR
===50= 00 00---0B401C18 jump 9D007060 _UART_6_VECTOR _UART_2B_VECTOR
===51= 00 00---0B401C8E jump 9D007238 _UART_5_VECTOR _UART_3B_VECTOR
This post is in response to questions about the build process. Some of you are asking very reasonable questions. However, this stuff is specifically hidden to make the entire system easy for the beginner. If you are a beginner, I would recommend ignoring these details to start with.
Nevertheless, to answer your questions, the build process in MPIDE is the same as it is for the original Arduino system. It compiles all of the files in the core/xxx folder, xxx is specified in boards.txt. Normally there is only one and for PIC32, it’s cores/pic32.
It also will compile files from the 2 libraries folders. The 2 locations for libraries are the main one in pic32/libraries–where officially supported libraries go–and the second optional libraries folder in your sketches folder, where you are supposed to put any libraries that you download from 3rd parties. The reason for the second folder is that if you download a new version of MPIDE (or Arduino), you won’t lose those third-party libraries, as happened in earlier versions of Arduino.
It copies all files from your sketch folder, the library folders to a temp folder. You can follow this entire process by holding down the SHIFT key and clicking on COMPILE (the button on the far left). Similarly you can hold down the shift button when you click UPLOAD and you will see the entire UPLOAD process. ONE IMPORTANT NOTE… HITTING UPLOAD ALSO COMPILES SO YOU DO NOT NEED TO DO BOTH.
The compile process uses gcc from a command line. Done differently in MPIDE was the code to drive the compiler; it was totally re-written and is driven by a file called platforms.txt, which spells out the entire compile and link process. In Arduino, this was hard coded and darn near impossible to change.