chipKIT® Development Platform

Inspired by Arduino™

Compiling the bootloader using the MPIDE compiler

Created Wed, 20 Feb 2013 06:13:07 +0000 by kinsa


kinsa

Wed, 20 Feb 2013 06:13:07 +0000

Here are the steps on how to compile the original bootloader (https://github.com/chipKIT32/pic32-Arduino-Bootloader) without using MPLAB-X.

  • Download source
git clone git://github.com/chipKIT32/pic32-Arduino-Bootloader.git
  • Replace the Makefile with the following code (make sure to edit the BOARD, PROCESSOR and GCCPREFIX):
BOARD     = _BOARD_DIGILENT_MEGA_
PROCESSOR = 32MX795F512LGCCPREFIX = /usr/local/pic32-tools/bin/pic32-
CC        = $(GCCPREFIX)gcc -mprocessor=${PROCESSOR}
BIN2HEX   = $(GCCPREFIX)bin2hexOBJECTFILES=startup.o pic32bootloader.oall: arduino-booloader.elfclean:
rm -rf .deps *.o *.elf *.bin *.dis *.map *.hex *.depstartup.o: startup.S
${CC} -c -o startup.o startup.Spic32bootloader.o: pic32bootloader.c
${CC}  -x c -c -ffunction-sections -fdata-sections -mips16 -D${BOARD} -Os -MMD -MF pic32bootloader.o.d -o pic32bootloader.o pic32bootloader.c
sed -e 's/\\$$/__EOL__/g' -e 's/\\ /__ESCAPED_SPACES__/g' -e 's/\\/\//g' -e 's/__ESCAPED_SPACES__/\\ /g' -e 's/__EOL__$$/\\/g' pic32bootloader.o.d > pic32bootloader.o.tmp
mv pic32bootloader.o.tmp pic32bootloader.o.darduino-booloader.elf: ${OBJECTFILES}
${CC} -nostartfiles -o arduino-booloader.elf ${OBJECTFILES} -Wl,--script=boot-linkerscript.ld,--gc-sections,-Map="map.txt",--cref,-Os
${BIN2HEX} arduino-booloader.elf
  • Compile and burn
make
pic32prog -p arduino-booloader.hex

Cheers!


Jacob Christ

Fri, 22 Feb 2013 07:42:52 +0000

Very cool... thanks for sharing.

Do you know how the resultant bootloader hex file compares in size to the MPLAB bootloader?

Jacob.


kinsa

Fri, 22 Feb 2013 08:58:55 +0000

Very cool... thanks for sharing. Do you know how the resultant bootloader hex file compares in size to the MPLAB bootloader? Jacob.

around 1k smaller for the binary code

XXXX@ux21e:~/Projects/tmp/bootloader/$ ls -l *elf
-rwxr-xr-x 1 XXXX XXXX 177778 Feb 22 16:50 arduino-booloader.elf
-rwxr-xr-x 1 XXXX XXXX 170019 Feb 22 16:51 arduino-booloader.X.production.elf
XXXX@ux21e:~/Projects/tmp/bootloader/$ /usr/local/pic32-tools/bin/pic32-strip *elf
XXXX@ux21e:~/Projects/tmp/bootloader/$ ls -l *elf
-rwxr-xr-x 1 XXXX XXXX 78744 Feb 22 16:51 arduino-booloader.elf
-rwxr-xr-x 1 XXXX XXXX 79240 Feb 22 16:51 arduino-booloader.X.production.elf
XXXX@ux21e:~/Projects/tmp/bootloader/$ ls -l *hex
-rw-r--r-- 1 XXXX XXXX 11976 Feb 22 16:57 arduino-booloader.hex
-rw-r--r-- 1 XXXX XXXX 18692 Feb 22 16:58 arduino-booloader.X.production.hex