Skip to main content
Topic: Compiling Bus Pirate firmware (Read 6893 times) previous topic - next topic

Compiling Bus Pirate firmware

Someone is having a hard time compiling the firmware:

Quote
Hello!

Thank you for the quick reply! I really really appreciate it!

As for details, I recently purchased the Pirate Bus so I believe it is version 3 for the hardware.
I have followed the various instructions on the wiki documentary in upgrading both the bootloader and firmware to version 4.1 both.
(I realize the newest version of firmware is currently something like 5.6... but I figured I might as well use this 4.1 version and cut it down to what I need for my project)

As an overview detail, my project overally is using the Pirate Bus to read some fast-spitting data chip and to write the data to a file on my computer via the USB connection--and this should all be autonomous. Currently, with the firmware 4.1, I can very manually configure the board and then read a selected amount of data and write the bits to the terminal.

My most immediate problem would be just the process of getting from .c/.h projects onto the Pirate Bus and having that work as the code programs it to work.

And yep! I have scoured through the Dangerous Prototypes like no other--though there are a lot of things I don't understand and there's a lot of epic programmers out there with awesome projects too! It's a great resource =)


Questions:
-- 1) When you said, "I recommend you use the hex-file that is outputted by the C30 tool chain.
Do not use MPLAB export unless you have a good reason to" -- what's the process of "activating" or using the C30 tool chain? Is this just building/compiling the project? I noticed that a .hex file is made even before I manually do "export"--however, I think it is too big so that when I try to bootload with the DS30 Loader, it tells me that I'm going to overwrite the bootloader.. (in "export," the Pirate Bus manual suggests changing the size of the .hex file and also to unselect "configuration bits"... how would you do the equivalent with the C30 tool chain??)

-- 2) You also asked if my hardware is set up correctly (in relevance to my second question from my previous email).
So with the BPv3-Firmware-v4.1.hex that I found available on the Pirate Bus website as is, all I have to do with it is bootload it with the DS30 Loader, reset (plug/unplug), open Terminal, and then Terminal responds and displays stuff properly with commands.

However, with the .c/.h project libraries (also available on the Pirate Bus website) or my hashed-up versions of .c/.h projects, I have to open up MPLAB and do the compiling and .hex-ing. They all SEEM TO compile successfully and I make them into .hex files and load them up with the DS30 Loader following the instructions online.... but the Terminal fails to do anything.
The Pirate Bus hardware itself is plugged in with just a USB cord and I do the same things in both "experiments".. so I think the error might be in the MPLAB/compiling/.hex-ing steps that I do pre-bootloading or maybe there's something else in code that would make BPv3-Firmware-v4.1.hex different somehow from the .hex that I make out of the .c/.h projects.
I'm just not sure what.

-- 3) When you said, "I'd guess you don't have the correct versions of the hardware set in base.h"--I do recall that instructions somewhere said that I had to go into base.h to change the versions and such... but I never found where I'm supposed to do that?
There isn't any "hardware version" indication in base.h.. (for looking at the actual .c/.h code.. I am currently looking at version C). Is there any more specific place I'm supposed to change with the versions I have now?

And also, would the 4.1 versions be ok as a jumping board off into my own project and coding, or are there things I need to watch out for with them?

Thank you very much for your help! Any advice or suggestions would be very appreciated!!
Got a question? Please ask in the forum for the fastest answers.

Re: Compiling Bus Pirate firmware

Reply #1
Quote
-- 1) When you said, "I recommend you use the hex-file that is outputted by the C30 tool chain.
Do not use MPLAB export unless you have a good reason to" -- what's the process of "activating" or using the C30 tool chain? Is this just building/compiling the project? I noticed that a .hex file is made even before I manually do "export"--however, I think it is too big so that when I try to bootload with the DS30 Loader, it tells me that I'm going to overwrite the bootloader.. (in "export," the Pirate Bus manual suggests changing the size of the .hex file and also to unselect "configuration bits"... how would you do the equivalent with the C30 tool chain??)

The toolchain is just the collection of programs you use to compile the firmware.

He's saying just use the .hex MPLAB makes instead of exporting a specific memory range (my instructions on the wiki). I always follow the wiki procedure, but I think Sjaak has it hooked up to work with the generated .hex file.

Quote
-- 2) You also asked if my hardware is set up correctly (in relevance to my second question from my previous email).
So with the BPv3-Firmware-v4.1.hex that I found available on the Pirate Bus website as is, all I have to do with it is bootload it with the DS30 Loader, reset (plug/unplug), open Terminal, and then Terminal responds and displays stuff properly with commands.
 so I think the error might be in the MPLAB/compiling/.hex-ing steps that I do pre-bootloading or maybe there's something else in code that would make BPv3-Firmware-v4.1.hex different somehow from the .hex that I make out of the .c/.h projects.
I'm just not sure what.

I would guess it's a problem with your compile or export steps. Could be a compiler difference, but I kind of doubt it. Do you have any optimization enabled for the build? That will make it fail. Have you changed any of the project settings and locations from the source code download defaults?

Quote
-- 3) When you said, "I'd guess you don't have the correct versions of the hardware set in base.h"--I do recall that instructions somewhere said that I had to go into base.h to change the versions and such... but I never found where I'm supposed to do that?
There isn't any "hardware version" indication in base.h.. Is there any more specific place I'm supposed to change with the versions I have now?

There is a line here:
http://code.google.com/p/the-bus-pirate ... /base.h#20
like this:
Code: [Select]
//this sets the hardware version
//#define BUSPIRATEV0A //http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/
//#define BUSPIRATEV2A
//#define BUSPIRATEV25 //AKA Bus Pirate v2go
//#define BUSPIRATEV1A //http://hackaday.com/2009/01/22/how-to-bus-pirate-v1-improved-universal-serial-interface/
#define BUSPIRATEV3

Looks to be v3 by default in v4.3 source.

Quote
And also, would the 4.1 versions be ok as a jumping board off into my own project and coding, or are there things I need to watch out for with them?

Sure, probably better than using v5. v5 has some funky additions.
Got a question? Please ask in the forum for the fastest answers.

Re: Compiling Bus Pirate firmware

Reply #2
1) thus far.. the .hex file that is made before manually doing "export" does NOT work either
and who's Sjaak?

2) I am using the C30 Compiler that is integrated in MPLAB currently.. I believe I got this from following various setup links on the Pirate Bus website. I have not changed anything with regards to the C30 Compiler (unless manual-specified... but I don't think there were any..) .. so it should be default I think right now?

And what do you mean in asking, "Have you changed any of the project settings and locations from the source code download defaults?" -- I downloaded the zipfile and extracted it to a folder on my desktop... aside from that, everything is pretty much as is the way I got it.
My own code is in a separate folder with all the different configurations deleted because I don't need them for my project. I only have base, piratebus, main, spi (and .c/.h of each except main only .c)..

As for the compiler and MPLAB and bootloader and other software.. they are in their own but separate folders...?? that shouldn't be a problem right??


3) Uhhhhhh @__@ I think I have an earlier version of base.h than you? The code I am looking at can be found here: http://blog.mahalo.com/hackaday/howto/buspirate.v0c.zip
(or here.. but scroll under the top picture if the above link doesn't work http://hackaday.com/2008/12/01/bus-pira ... -and-more/)


Thanks for all your help!!

Re: Compiling Bus Pirate firmware

Reply #3
Quote
who's Sjaak?

Quote
I have scoured through the Dangerous Prototypes like no other...there's a lot of epic programmers out there with awesome projects too!

one of those

Quote
I figured I might as well use this 4.1 version and cut it down to what I need for my project

Quote
The code I am looking at can be found here: http://blog.mahalo.com/hackaday/howto/buspirate.v0c.zip

I think that is firmware v0c for the second hardware prototype (v0a). More recent code for v2go/v3 hardware can be found on the google code downloads:
http://code.google.com/p/the-bus-pirate/downloads/list
...but I dont see anything for the v4 bootloader. You can check a v4 firmware out of svn. There are some instructions and tutorials for SVN on the documentation wiki.
Got a question? Please ask in the forum for the fastest answers.

Re: Compiling Bus Pirate firmware

Reply #4
@ian, you make me blush!

@ty: Take a look at this pages in the wiki:

http://dangerousprototypes.com/docs/Com ... e_firmware

If you have svn and download that source, the generated hex will work out of the box. Well at least for this epic programmer... The svn also contains the genuine and supported sources. sources from other sources aren't supported ;)

Re: Compiling Bus Pirate firmware

Reply #5
AHA! it works! Thank you all!

Next question would be, for the Pirate Bus, how do you change the baud rate of the USB UART--rate to send data to computer. I would like it to be somewhere around the 40MHz maximum that the FT### chip for the USB says it can do??

Thanks again!

Re: Compiling Bus Pirate firmware

Reply #6
that would be the command 'b'

In the wiki there is more documentation about the commands. Http://dangerousprototype.com/docs

Btw the max baudrate is approx 1-2 Mbaud


Re: Compiling Bus Pirate firmware

Reply #8
the FT232R says it's capable up to 40MHz... how would i access that speed? here's where it says that: http://www.ftdichip.com/Products/ICs/FT232R.htm

the "b" command is for the terminal i think, so after i change the UART speed, i should be able to add in code to increase the speed? they're not the same thing right? they just have to be set at the same speed... so if i can increase the UART speed, i can find some terminal that also can run at that speed..???

Also, checking the datasheet, it DOES say that the RS232 serial connection can only transfer data 1-3MBaud speed.... but i'm using a USB to USB connection... it should not restrict the speed right?

sorry, i am very noob on this topic, and sorry for the maybe-stupid questions.. please explain in detail if you can! Thank you!!

Re: Compiling Bus Pirate firmware

Reply #9
The wiki entry about the 'b' command:

http://dangerousprototypes.com/docs/Bus ... port_speed

with option 10 you can enter the BRG register value exactly. 34 for example is 115200baud. The lower the value the faster the UART speed. On the end there is a link to a baudrate calculator (there are many more on the internet).

The ftdi chip is an USB to serial converter and is thus limited to the maximum baudrate the PIC understands.

Re: Compiling Bus Pirate firmware

Reply #10
Quote
the FT232R says it's capable up to 40MHz... how would i access that speed? here's where it says that: http://www.ftdichip.com/Products/ICs/FT232R.htm

I think the external crystal can be up to 40MHz, that has nothing to do with transfer rates. We use the internal crystal anyways and you can't add one to the Bus Pirate.

Quote
the "b" command is for the terminal i think, so after i change the UART speed, i should be able to add in code to increase the speed? they're not the same thing right? they just have to be set at the same speed... so if i can increase the UART speed, i can find some terminal that also can run at that speed..???

To change the speed of the UART in the PIC refer to the datasheet (linked on the Bus Pirate Wiki), or look through the Bus Pirate UART code. There are several places in the Bus Pirate code that show how to adjust the UART.

Quote
Also, checking the datasheet, it DOES say that the RS232 serial connection can only transfer data 1-3MBaud speed.... but i'm using a USB to USB connection... it should not restrict the speed right?

What is a USB to USB connection?


Quote
please explain in detail if you can!

The most detail you will find is in the PIC24Fj64GA002 datasheet, 24FJ reference manual, and FT232 datasheet.

This should give a good overview of the FT232 USB capabilities and requirements:
http://www.ftdichip.com/Support/Documen ... FT232R.pdf
Got a question? Please ask in the forum for the fastest answers.

Re: Compiling Bus Pirate firmware

Reply #11
Quote
The wiki entry about the 'b' command:

http://dangerousprototypes.com/docs/Bus ... port_speed

with option 10 you can enter the BRG register value exactly. 34 for example is 115200baud. The lower the value the faster the UART speed. On the end there is a link to a baudrate calculator (there are many more on the internet).

The ftdi chip is an USB to serial converter and is thus limited to the maximum baudrate the PIC understands.


Since he's compiling the code, I'm guessing he wants to change the UART settings himself in the source for his own application.

You can look at the source for the 'b' command in the bus pirate that Sjaak posted, it will show you how to adjust the UART speed.
Got a question? Please ask in the forum for the fastest answers.