chipKIT® Development Platform

Inspired by Arduino™

PROGRAMMING uC32 USING MPLAB X WITHOUT PICKIT

Created Wed, 04 Nov 2015 13:20:45 +0000 by panjeta


panjeta

Wed, 04 Nov 2015 13:20:45 +0000

Hi Everyone,

I want to use mplab x to program uc32 instead of mpide. I followed the tutorial, @ http://chipkit.net/programming-chipkit-boards-in-mplabx/ but had no luck . Do I have to select memory address too like starting address and end address. As, it gives me error that address is out of range while trying to write hex file.

Thanks,


l.varani

Tue, 10 Nov 2015 20:14:32 +0000

I think you have the same problem I have: the hex file generated contain four lines like: ............................. :020000041FC01B :1004800000F89B40C0000000009D1B3C64177B27C8 :10049000020060130000000000C09B4000F81B40F9 :0C04A000C00000001F000042000000002F .............................

How I solved the problem? First : I check the option 'normalize hex file' in the window properties->building of the project in MPLAB-X In this way the four lines you see are the last lines of the file and in this way is more simple to find them. Second: ELIMINATING the four lines. I try in a first time manualy via a text editor and then I call the AVRDUDE thru a bat file. In a second time I generate a .exe file that delete the four line . I use then a .bat file that first call the 'remover' an then call AVRDUDE, I call then the .bat thru the MPLAB X line, in the properties->building window in the line "execute this line after build".

I'm foul? Maybe.. but seem everything go better. The question is related to the use of the region of memory specified by the tree lines . I thing the memory region involved (0X1FC00480) is used for debugging (you do analize the default linker script file and the two linker script files and study the memory usage of the micro). In this moment I don't use a debugger... saluti ! and excuse my english... luciano


panjeta

Wed, 11 Nov 2015 12:51:27 +0000

Thanks a lot Luciano, it worked . I was able to program uc32 with mplab x. I really appreciated this.

Sent from my SM-G920W8 using Tapatalk


l.varani

Wed, 11 Nov 2015 18:31:50 +0000

Di niente!

But a duobt remain the four lines I delete

:020000041FC01B :1004800000F89B40C0000000009D1B3C64177B27C8 :10049000020060130000000000C09B4000F81B40F9 :0C04A000C00000001F000042000000002F

What exactly do? (it's very difficult for me interpeter them thru the . hex code) There is somone who can help me?

The question is not very simple I think... I note tha the California University, suggest to CHANGE the bootloader.. (read here)

https://classes.soe.ucsc.edu/cmpe118/Fall14/Labs/Uno32_Stack_Documentation.pdf https://classes.soe.ucsc.edu/cmpe118/Winter12/Labs/MPLABX_NewProjectInstructions.pdf

In this case you do reprogram the board. But many students don't have a programmer.... (I'm an old teacher...)

Luciano


GrahamM242

Thu, 12 Nov 2015 14:41:52 +0000

Been a while since I tried to take intel hex apart... The lines basically write 0x2C bytes to 0x1FC00480. The bytes written are:

00F89B40C0000000009D1B3C64177B27020060130000000000C09B4000F81B40C00000001F00004200000000

The block of memory is within the internal boot flash of the device as far as I can see. Making an assumption or two (as I'm not that familiar with MIPS), the asm code would be something like:

1FC00480                 mtc0    $k1, $31   		 ; k1 to cp0 reg 31 - EJTAG debug exception save register
1FC00484                 ehb		    				 ; Execution hazard barrier
1FC00488                 li      $k1, 0x9D001764   ; 0x9D001764 to k1
1FC00490                 beqz    $k1, loc_1FC0049C ; branch to loc_1FC0049C if k1 = 0
1FC00494                 nop
1FC00498                 mtc0    $k1, $24   		 ; k1 to cp0 reg 24 - Program counter at last EJTAG debug exception
1FC0049C
1FC0049C loc_1FC0049C:
1FC0049C                 mfc0    $k1, $31		 	; k1 to cp0 reg 31 - EJTAG debug exception save register
1FC004A0                 ehb		    		 		; Execution hazard barrier
1FC004A4                 deret						   ; Debug exception return

Alas, I can't tell you what that's good for.


l.varani

Thu, 12 Nov 2015 20:42:42 +0000

many many thanks!! Now I have material.... The ideas are two: work inside MPLAB-X script link files and modify them in mode that the area was left free. I think there are problems. The file p32MX340F128H.ld (2015) from Microchip specify: ................................. /*************************************************************************

  • Memory Regions
  • Memory regions without attributes cannot be used for orphaned sections.
  • Only sections specifically assigned to these regions can be allocated
  • into these regions.
  • The Debug exception vector is located at 0x9FC00480. <<<<<<< read this
  • The config_<address> sections are used to locate the config words at
  • their absolute addresses. *************************************************************************/ MEMORY { kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x20000 kseg0_boot_mem : ORIGIN = 0x9FC00490, LENGTH = 0x970 exception_mem : ORIGIN = 0x9FC01000, LENGTH = 0x1000 kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0x490 debug_exec_mem : ORIGIN = 0xBFC02000, LENGTH = 0xFF0 config3 : ORIGIN = 0xBFC02FF0, LENGTH = 0x4 config2 : ORIGIN = 0xBFC02FF4, LENGTH = 0x4 config1 : ORIGIN = 0xBFC02FF8, LENGTH = 0x4 config0 : ORIGIN = 0xBFC02FFC, LENGTH = 0x4 kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x8000 sfrs : ORIGIN = 0xBF800000, LENGTH = 0x100000 configsfrs : ORIGIN = 0xBFC02FF0, LENGTH = 0x10 }

*************************************************************************/ ..................................

a second idea is to bypass the location 0x1FC00490 ( incompatible with avrdude),rewriting some location near 0x1FC00480 with a Jmp to another line (after 0x1FC004A0 ?? ) where recopy the code ; working 'hard' on the .hex file. but tonight I'm so tired, ..... luciano


GrahamM242

Fri, 13 Nov 2015 09:44:45 +0000

Don't forget that the PIC32 has physical and virtual memory maps that are different. At this point, I am beyond my knowledge of how things fit together in the world of PIC32.


panjeta

Thu, 31 Dec 2015 15:49:35 +0000

Hello Luciano,

Sorry for really late solution. May be you have already found a solution. Anyways, to program with MPLAB X we need to add few line in the chipKIT-application-COMMON.ld linker script. lines are:

SECTION { /DISCARD/ : { *(._debug_exception) } }

for more info see http://microchip.wikidot.com/faq:79

doing this will omit those lines in the hex file that we were manually deleting. This is some issue with xc32 compiler.

hopefully this might help.

Thanks panjeta


l.varani

Tue, 09 Feb 2016 18:58:35 +0000

Many thanks!! I'm doing some test..... but without a 'brute' line remover, the answer is:

avrdude.exe: ERROR: address 0x1fc00490 out of range at line 179 of dist\default\production\LedAcceso.X.production.hex avrdude.exe: write to file 'dist\default\production\LedAcceso.X.production.hex' failed avrdude.exe done. Thank you. make[1]: *** [.build-conf] Error 1 make: *** [.build-impl] Error 2 nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed make[1]: Leaving directory 'C:/temp/SEI_16/PROG_01/LedAcceso.X' nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed BUILD FAILED (exit value 2, total time: 8s)

with the brute remover (named VaroConvert.exe) the answer is:

"User defined post-build step: [\AvrDude\upload.bat COM9 "dist\default\production\LedAcceso.X.production.hex"]" C:\temp\SEI_16\PROG_01\LedAcceso.X>"\AvrDude\VaroConvert.exe" dist\default\production\LedAcceso.X.production.hex

C:\temp\SEI_16\PROG_01\LedAcceso.X>"\AvrDude\avrdude.exe" -C "\AvrDude\avrdude.conf" -v -p32MX320F128H -cstk500v2 -P COM9 -b 115200 -U flash:w:dist\default\production\LedAcceso.X.production.hex

avrdude.exe: Version 5.10, compiled on Jan 19 2010 at 10:45:23 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "\AvrDude\avrdude.conf"

         Using Port                    : COM9
         Using Programmer        : stk500v2

...... .....

and so on. And the led is flashing...... Only remain to read the Microchip document yu suggest Luciano

P.S. Iam using a ChipKit UNO32, not an UC32... But all the experiments I've done go well, not only flashing a led. The question now is:


svs_03

Tue, 31 May 2016 15:48:14 +0000

i used same procedure i am getting fallowing errors

plesae help


vhastorga

Fri, 10 Nov 2017 14:30:32 +0000

222/5000 I'm new to this, I started with UC32 and I want to try it before I see if I buy the PICit 3. But by doing the steps of the manual http://chipkit.net/programming-chipkit-boards-in-mplabx/ by adding the line that removes the hexa. I also always receive the same message.

when compiling

"C:\Program Files (x86)\Microchip\xc32\v1.44\bin\xc32-gcc.exe"   -mprocessor=32MX340F512H  -o dist/default/production/blinky.X.production.elf build/default/production/_ext/327000265/drv_usart_mapping.o build/default/production/_ext/327000265/drv_usart_static.o build/default/production/_ext/327000265/drv_usart_static_byte_model.o build/default/production/_ext/639803181/sys_clk_pic32mx.o build/default/production/_ext/1544295906/sys_console_static.o build/default/production/_ext/340578644/sys_devcon.o build/default/production/_ext/340578644/sys_devcon_pic32mx.o build/default/production/_ext/822048611/sys_ports_static.o build/default/production/_ext/1688732426/system_init.o build/default/production/_ext/1688732426/system_interrupt.o build/default/production/_ext/1688732426/system_exceptions.o build/default/production/_ext/1688732426/system_tasks.o build/default/production/_ext/1360937237/app.o build/default/production/_ext/1360937237/main.o build/default/production/_ext/185269848/drv_tmr.o build/default/production/_ext/1408546951/sys_debug.o build/default/production/_ext/122796885/sys_int_pic32.o build/default/production/_ext/1264926591/sys_tmr.o    ..\..\..\..\bin\framework\peripheral\PIC32MX340F512H_peripherals.a      -DXPRJ_default=default  -no-legacy-libc    -Wl,--defsym=__MPLAB_BUILD=1,--defsym=_min_heap_size=2048,--gc-sections,--no-code-in-dinit,--no-dinit-in-serial-mem,-Map="dist/default/production/blinky.X.production.map",--memorysummary,dist/default/production/memoryfile.xml
"C:\Program Files (x86)\Microchip\xc32\v1.44\bin"\\xc32-bin2hex dist/default/production/blinky.X.production.elf 
make[2]: Leaving directory 'C:/microchip/harmony/v2_04/apps/blinky/firmware/blinky.X'
"--------------------------------------"
"User defined post-build step: ["C:\Program Files (x86)\Microchip\MPLABX\v4.01\mplab_ide\bin\avrdude.exe" -C "C:\Program Files (x86)\Microchip\MPLABX\v4.01\mplab_ide\bin\avrdude.conf" -v -p 32MX340F512H -c stk500v2 -P COM7 -b 115200 -U flash:w:"dist\default\production\blinky.X.production.hex" ]"
nbproject/Makefile-default.mk:103: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/microchip/harmony/v2_04/apps/blinky/firmware/blinky.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[1]: *** [.build-conf] Error -1073741515
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 4s)