Skip to main content
Topic: Compiling Bus Pirate firmware with MPLABX (under linux, mac, ...) (Read 63312 times) previous topic - next topic

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #30
[quote author="pcfr33k"]That message about use screen what is that all about?  Thanks[/quote]

screen is a command to connect to the serial port (usb) that the buspirate is on. then you could use the 'i' command to print out the firmware version.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #31
Thanks for  all the help.  Now to some obscure questions that to some of you may sound stupid but I am new to this.  Can I use MPLAB X with the Bus Pirate to read and write DATA to an SPI device connected to to BP but using MPLAB X or do I still have to use the terminal to do this?  I was unable to get BusPirategui for Mac to work in OSX 10.6.  I can execute the Open Pirate command in that Gui however when I try to read the SPI it fails.  I cannot generate the voltages on the GUI Application either and that is probably why its not reading the SPI device.  I like the frontend on MPLAB 8 using MPLAB stater kit to read write verify etc using that front end.  Its just kinda neat to see the entire address and working with the SPI in MPLAB 8.

Anyhow I know there is another GUI lurking around but its for Linux not Mac.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #32
Hi pcfr33k,

I'm not aware of anything that will allow the Bus Pirate to be used directly in MPLAB.
Got a question? Please ask in the forum for the fastest answers.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #33
You can write your own firmware using MPLAB X and then use a PICkit or other MPLAB debugger to download the code to the PIC on the Bus Pirate and run your firmware. This would not be interactive, though - not like the terminal. There is no way to interactively input data from MPLAB X to the Bus Pirate. You could change the data in your source code, recompile, and run again, but that's a lot slower than using the terminal. MPLAB X is for firmware developers, but you need some other source of data for interactive control.

Re: Compiling Bus Pirate firmware with MPLABX (under linux,

Reply #34
I've been trying to compile the firmware on Linux in MPLABX, and while it compiles just fine, I cannot get [tt:]pirate-loader[/tt:] to upload it correctly. With my firmware, everything seems to go fine until:

Code: [Select]
Writing page 26 row 215, 6b80...OK
Erasing page 41, a400...OK
Writing page 41 row 328, a400...OK

Erasing page 42, a800...ERROR [50]

With the released v6.1 firmware there is no “page 42”, and so it works fine:

Code: [Select]
Writing page 40 row 327, a380...OK
Erasing page 41, a400...OK
Writing page 41 row 328, a400...OK

Writing page 41 row 335, a780...OK

I would assume that the problem is because I'm running out of space on the device (i.e, there is no page 42 available?), but no matter what optimizations I try or features I disable, my firmware file always seems to extend to page 41 and 42. Note that in the official firmware release the pages were contiguous from 1 to 41, but in mine they skip from page 26 to 41.

If I try without [tt:]-Os[/tt:], as is the default, and don't disable any normal features like the LCD support that I don't need, my firmware [tt:].hex[/tt:] file is about the same size as the official firmware, but it still exhibits this “page gap” which causes the end to extend to the problematic page 42.

What am I doing wrong, i.e. what makes something want to be on page 42 even if there are over 10 pages free before then?

Or, has anyone been able to compile this succesfully on Linux or OS X with MPLABX, and could they upload their source directory with the MPLABX project? The X-project in SVN does not compile (refers to some obsolete files that don't exist anymore), so I needed to import the MPLAB 8 -version.

P. S. My Bus Pirate is hardware v3.5, bootloader v4.4, [tt:]pirate-loader[/tt:] from the 6.1 binary distribution. After each failed attempt I've always been able to re-upload the official 6.1 firmware.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #35
Page 42 is where the bootloader and configuration bits are, they protect themselves from overwriting and throw error P (0x50?) for protected. You need to export the .hex from 0x00=0xa7fa and exclude the config bits. Then it should work:

http://dangerousprototypes.com/docs/Com ... bootloader
Got a question? Please ask in the forum for the fastest answers.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #36
Yes, I actually figured that out when I finally got tired of fighting with MPLAB X and installed MPLAB 8 in a Windows XP virtual machine. However, I cannot find where in MPLAB X I could set the same configuration; export does not present the pictured dialog.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #37
Hum, I assume someone in this thread will know because some have done it successfully.
Got a question? Please ask in the forum for the fastest answers.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #38
I finally found it in MPLAB X. Instructions for future reference:

First one needs to select a PIC programmer device ([tt:]File -> Project properties[/tt:], then [tt:]Conf: default[/tt:], then select, e.g., [tt:]PICKit3[/tt:] from the list on the right). Then click [tt:]Apply[/tt:] and select the programming device ([tt:]PICKit3[/tt:]) from the list on left. Select [tt:]Memories to Program[/tt:] from the menu on the right, and for the option [tt:]Auto select memories and ranges[/tt:] choose [tt:]Manually select memories and ranges[/tt:]. Tick the box for [tt:]Program Memory[/tt:] and below that enter [tt:]0xa6ff[/tt:] as the end value. (Now wasn't that an obvious place to configure exported hex files? =)

Note that the value [tt:]0xa7fa[/tt:] used for MPLAB 8 is not accepted; MPLAB X requires the value to be either [tt:]0xabfb[/tt:] (which overlaps the bootloader area as described above) or of the form ([tt:]0x100 * n - 1[/tt:]); the largest suitable value of this form is [tt:]0xa6ff[/tt:] (a loss of 251 bytes of program space?).

Re: Compiling Bus Pirate firmware with MPLABX (under linux,

Reply #39
Nice research!

My guess is 0xa7ff is also ok. AFAIK the pirateloader is overwriting the last bytes with the correct jump address before sending it to the bootloader.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #40
I edited the wiki page to include the MPLAB X instructions.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #41
Thanks for the edit Arkku :) I was just about to do it myself, what a pleasant surprise, thanks!
Got a question? Please ask in the forum for the fastest answers.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #42
[quote author="Arkku"]I finally found it in MPLAB X. Instructions for future reference:
...
Note that the value [tt:]0xa7fa[/tt:] used for MPLAB 8 is not accepted; MPLAB X requires the value to be either [tt:]0xabfb[/tt:] (which overlaps the bootloader area as described above) or of the form ([tt:]0x100 * n - 1[/tt:]); the largest suitable value of this form is [tt:]0xa6ff[/tt:] (a loss of 251 bytes of program space?).[/quote]
I used this info to recompile the firmware but whatever value for Program Memory End I set  - the hex file was the same - no diffs.
What other options could be in affect?

MPLABX 1.0 under debian, optimization is set to -O1, Bus Pirate svn code.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #43
[quote author="beeduino"]I used this info to recompile the firmware but whatever value for Program Memory End I set  - the hex file was the same - no diffs. What other options could be in affect?[/quote]

Well, the only thing I can think of is that this change did not take effect, e.g., you only tried to “Export hex” and did not “Clean and build”, or maybe the setting did not get saved for some reason. (Did you click “Apply”?)

Unfortunately the MPLAB user interface is so bad that I cannot even guess what other settings I might have touched that could possibly affect this. If the above suggestions don't work, I would perhaps try re-importing the MPLAB 8 project and redoing the configuration without ever compiling with the incorrect settings.

[quote author="beeduino"]
MPLABX 1.0 under debian, optimization is set to -O1, Bus Pirate svn code.[/quote]

I'm using the same configuration, except I use [tt:]-Os[/tt:] optimization.

Re: Compiling Bus Pirate firmware with MPLABX (under linux,

Reply #44
If anyone is interested I  started from scratch and got BPv4 source with Microchip USB compiled using the latest tools:

IDE:  MPLAB X (v1.6).
CC: XC16 (v1.11)
OS:  Mac OS X 10.6.8
Java: 1.6.0_37

USB
I chose the Microchip USB source since I
a) wanted at least one bit reliable :-) 
b) haven't yet found the open source USB source  (location anyone?)
Apart from some Microchip/include files I used:
  • USB/CDC Device Driver/usb_function_cdc.c
  • USB/usb_device.c
  • a local copy of CDC Basic Demo/Firmware/usb_descriptors.c  (as yet unmodified)

MPLAB X IDE notes
I don't like the idea of dumping my project source code inside the mplab source tree just to get it to compile so I found out how to handle includes and source outside the bus-pirate tree.
Bit long to explain here in detail but in short:
  • Add remote .c files using a (new) logical folder (I called mine 'USB') in projects window (optionally add remote .h files but not required).
  • under "project properties" -> categories: xc16-gcc (compiler) -> Option categories: preprocessing and messages -> C include dirs:  path_to_microchip_apps_lib_source..../Microchip/Include
    Talk about obscure....

And it should all compile....
Haven't tried bootloader.

Newcomer Feedback
Also  some feedback as a new comer there isn't really a PBv4 status page and roadmap so I/we don't know overall what is in the pipeline (and by who) what works and what doesn't, what won't ever work (seen a comment or two) and maybe a simple user-contributed test matrix each major platform.

The issues list is unfortunately also confusing for outsiders because there are BPv4 items added to at least 3 different lists....
I understand that the top one may be the definitive one, in which case perhaps the others should be closed as all have been added to in the last 6ish months...

Question
Not sure what to do next as I can't get my hands on a PBv4c board + parts. Any suggestions or should I just wander off buy a v3 and forget trying to get the v4 working (better)?

best regards
Kim