chipKIT® Development Platform

Inspired by Arduino™

stand alone PIC32MX795F512-bootloader

Created Mon, 26 Dec 2011 16:28:35 +0000 by acmilangr


acmilangr

Mon, 26 Dec 2011 16:28:35 +0000

Hi.

i want to use a fresh PIC32MX795F512 on my own board as standalone and i want to be able to program it by using arduino language (chipkit) becouse i prefer this language.

using rx/tx/reset pins and an FTDI i will be able to program it.

the problem is on bootloader. how can i burn bootloader on that fresh PIC32MX795F512?

i have the PICkit 3 In-Circuit Debugger. is it posible to do that with this?


EmbeddedMan

Mon, 26 Dec 2011 17:56:23 +0000

Yup, your PicKit3 will work just fine. You can either use it from within MPLAB X (or MPLAB 8) or you can download the PicKit3 stand-alone programmer software (if you're on Windows). Then just program the part with the bootloader HEX file, and you'll be good to go.

*Brian


KurtE

Mon, 26 Dec 2011 18:54:16 +0000

Quick question, Sorry if it is slightly off topic.

In a Pic32MX7* design are there good reasons why some boards (like Max32) still use an FTDI chip for the USB versus using the USB that is part of this chip?

Thanks Kurt


EmbeddedMan

Mon, 26 Dec 2011 19:13:45 +0000

Yup, there are. The chipKIT dev team had many heated discussions about this topic (among others). While the FTDI chip adds cost, it has many benefits, including no drivers to install, commonality with existing Arduino boards, and removing the requirement that a full USB stack (like Microchip's MAL USB stack) be compiled into every sketch.

However, the biggest deal was the fact that it gives the chipKIT boards the same exact user experience as the Arduino, in that when the user clicks 'upload' on the PC, the PC is always able to reset the chipKIT and get it into bootloader mode. With a software based USB stack, this is not always possible. Users can create sketches that disable interrupts and sit in a while(1) loop and then you have to physically reset the board in order to upload a new sketch.

We felt that maintaining the utmost in user experience compatibility with the existing Arduino system was our number one goal. Thus the FTDI chip.

Note that there are now several USB based bootloaders available that remove the need for the FTDI chip, so you can 'Arduinoize' any PIC32 that has USB (like the UBW32 or CUI32).

*Brian


KurtE

Mon, 26 Dec 2011 22:52:17 +0000

Thanks,

I thought I totally understood your answer and reasons for including the FTDI chip up until the final paragraph. I now have a UBW32 on order from Sparkfun experiment with to help me better understand.

So I am guessing, but with a USB boot-loader: a) You still need to install a USB device driver. Like you have to do for the UNO... b) The Serial object, will need to include the USB stack. My guess here is that the compiler will do this behind the scenes? That is the end user Sketch source code would not need to know this? Also is most of the code to handle this contained in the bootloader? c) Do you still have the issue that the user program can keep the USB from resetting the board?

Thanks again. I am having fun with the UNO32.

Kurt


Jacob Christ

Tue, 27 Dec 2011 13:57:51 +0000

Thanks, I thought I totally understood your answer and reasons for including the FTDI chip up until the final paragraph. I now have a UBW32 on order from Sparkfun experiment with to help me better understand. So I am guessing, but with a USB boot-loader: a) You still need to install a USB device driver. Like you have to do for the UNO... b) The Serial object, will need to include the USB stack. My guess here is that the compiler will do this behind the scenes? That is the end user Sketch source code would not need to know this? Also is most of the code to handle this contained in the bootloader? c) Do you still have the issue that the user program can keep the USB from resetting the board? Thanks again. I am having fun with the UNO32. Kurt

Kurt,

I have this working on two custom boards. One uses the same processor as the MAX32 and the other uses a PIC32MX440F512H.

The two boards are on the front page of pontech.com right now. Nether board is for sale yet but we have some customers beta testing them. The UAV100 uses the MX440 and the PLAC100 using the same chip on the Max32.

a) A driver is needed, but it is a standard driver from Microsoft? that has just been modified with a custom USB VID/PID. The one I'm using at the moment is from Rick @ CPU Stick. This uses a VID/PID he obtained from FTDI chip. Rick suggested that its fine to use these VID/PID if the bootloader goes unaltered but that you should get your own if make changes.

http://www.cpustick.com/downloads.htm

b) It's not quite automatic. You need to set up a custom boards file for your board that has USB Serial turned on. You can look at the boards.txt file and look for the example of the Max32-USB for Serial as an example. c) The reset via serial such as done with the FTDI is gone once you do this. If you need to reset you will need to add a button to your board or create a command that can be sent over serial. d) Another consideration, once you are finished uploading your code to the board and you launch your application the USB port you are connected to goes away and a new one is created. This is slightly problematic using the Rx/Tx java libs in the MPIDE since they get confused quite easily (but not horrible). Some important things to remember, don't pull or reset the board with the terminal open doing so will require you close all instances of MPIDE and restart before the board can be seen again. Also, there are some minor quirky differences between linux and Win with the java RxTx behavior though I can't think of them off the top of my head but I know them when I see them. e) For the smoothest transition, you should look at the USB Bootloader before designing a board. Namely I think the smoothest transition on the chipKIT platform is to make sure you have a input reserved to put the board into program mode when resetting it. There is a mechanism for have the bootloader hang out for 10 seconds or so but it makes your application sluggish to launch when when not doing development.

At some future point I'll summarize all this and add it to the wiki. I was working on a section on building a custom board but stopped since changes in the MPIDE on how this works were changing. I think they are released now but I haven't had time to look at them yet.

http://www.chipkit.cc/wiki/index.php?title=Customizing_the_chipKIT%E2%84%A2_development_tools_for_your_custom_board

Jacob


KurtE

Tue, 27 Dec 2011 14:34:38 +0000

Thanks,

Gives me lots to think about

Kurt


Jacob Christ

Tue, 03 Jan 2012 20:10:47 +0000

I saw the quirky difference between linux and windows again today.

If you send out several serial string like "Hello World!\r" (that has no newline).

In linux it will print in the terminal and just append the strings.

In Windows it will not even print. Its as if the newline character is needed before it will render the string. I think this is actually in the RxTx lib and not in MPIDE code since I've seen similar things in other places where we use Java RxTx. I think the RxTx lib is a contributed lib and not actually supported by Oracle.

Jacob


andre85

Mon, 09 Jan 2012 10:21:16 +0000

I have a question. I'm try to relaize astand alone PIC32MX320F. The FTDI FT232RL must be programmed? or is sufficinet the copy of the the chipkit schematic?

Thanks to everybody,

Andrea


Jacob Christ

Mon, 09 Jan 2012 18:19:48 +0000

I have a question. I'm try to relaize astand alone PIC32MX320F. The FTDI FT232RL must be programmed? or is sufficinet the copy of the the chipkit schematic?

No programming in necessary on the FTDI, but if you want you can down load MPROG from ftdichip.com. This will allow you to change the device string that prints when connected to a windows computer. Also you can change the VID and PID if you have your own VID (but you probably shouldn't do this unless your writing your own driver for the FTDI).

Jacob


andre85

Tue, 10 Jan 2012 11:12:15 +0000

Thank you so much. I think that I will leave the VID and PID of the FTDI chip.. Now I'm searching a more cheaper solutions. Do you have one please? The designer of the Chipkit doesn't reccomended the MCP2200 and PIC (with USB module) solutions

Andrea


Jacob Christ

Wed, 11 Jan 2012 07:14:39 +0000

If your designing your own board just use a PIC32 that has the USB module then use the USB for Serial option. If you need help getting this working I've been through the process.

Jacob


andre85

Wed, 11 Jan 2012 07:58:00 +0000

Thank you for the answer, I find the PIC32MX440F512H, the price is much higher than PIC32MX320F128H but I can save cost fot FTDI chip. Do you have USB library for it or equivalent? And is simple make it compatible with MPIDE?


Jacob Christ

Wed, 11 Jan 2012 08:19:58 +0000

The PIC32MX440F512H is exactly the chip I'm using. You can save a buck by using the 128H. But I think the PIC32MX440F512H is a better (easier to get going) option (at this time) since I know the linker file is set up for it.

You just need to add a custom entry into the boards.txt file. Here is mine:

I call it a USBONO as a play on USB and UNO and because I like the band U2 so to pay tribute to Bono.

usbono_pic32.name=chipKIT USBONO

new items

usbono_pic32.platform=pic32 usbono_pic32.board=BOARD_USBONO usbono_pic32.compiler.define=-D_USE_USB_FOR_SERIAL_::-Danything=1 usbono_pic32.ccflags=ffff usbono_pic32.ldscript=chipKIT-application-32MX440F512H.ld

end of new items

Use a high -Gnum for devices that have less than 64K of data memory

For -G1024, objects 1024 bytes or smaller will be accessed by

gp-relative addressing

usbono_pic32.compiler.c.flags=-O2::-c::-mno-smart-io::-w::-ffunction-sections::-fdata-sections::-G1024::-g::-mdebugger::-Wcast-align usbono_pic32.compiler.cpp.flags=-O2::-c::-mno-smart-io::-w::-fno-exceptions::-ffunction-sections::-fdata-sections::-G1024::-g::-mdebugger::-Wcast-align

usbono_pic32.upload.protocol=stk500v2 usbono_pic32.upload.maximum_size=520192 usbono_pic32.upload.speed=115200

usbono_pic32.bootloader.low_fuses=0xff usbono_pic32.bootloader.high_fuses=0xdd usbono_pic32.bootloader.extended_fuses=0x00 usbono_pic32.bootloader.path=not-supported usbono_pic32.bootloader.file=not-supported usbono_pic32.bootloader.unlock_bits=0x3F usbono_pic32.bootloader.lock_bits=0x0F

usbono_pic32.build.mcu=32MX440F512H usbono_pic32.build.f_cpu=80000000L usbono_pic32.build.core=pic32 #usbono_pic32.upload.using=


Jacob Christ

Wed, 11 Jan 2012 08:24:08 +0000

Oh, and you will need to compile a bootloader for it using MPLABX. I've been able to get both USB and Serial Bootloaders to work. There is still one open issue in the USB bootloader, but its only an issue if you use the 10 second timeout rather than a jumper to go into program mode. Oh, make sure you add a jumper to the board to go into program mode if you are going to use USB for you bootloader.

Jacob


andre85

Wed, 11 Jan 2012 11:08:15 +0000

Compliments, really very good! However now I will use a PIC32MX320F128.. I have too little time to revolutionize the project. In the next future I will try the same things that you've made

Thanks for everything Andrea


Jacob Christ

Wed, 11 Jan 2012 23:47:33 +0000

I know what you mean. The first cut of the board I made with the MX440 I put the FTDI on to be safe. But never needed it.

Jacob


andre85

Fri, 20 Jan 2012 13:20:03 +0000

Hi Jacob, Here I am again... I want to migrate to PIC32MX440F512H as soon as possible. I have a question for you please.. I've seen the CUI32 Development Stick in MPIDE. Then I see that CUI32 have the same PIC: the PIC32MX440F512H ... If I realize a PCB with a virgin PIC32MX440F512H, then I will put the CUI32 bootloader (avalaible here http://code.google.com/p/cui32/downloads/list), then I can put on my board my software simply connected USB to my PCB and selected "CUI32 Development Stick" in MPIDE? There will be problems?

Thank you Andrea


Jacob Christ

Fri, 20 Jan 2012 17:02:30 +0000

Andrea,

The biggest things you need to be cognizant of is making sure the USB device port is wired up correctly (you know D+/D- going to the correct pins, and proper power to USB module of PIC) and getting the boatloader LED and program jumpers going to the correct pin. The only reason(s) I needed to recompile the bootloader was:

o Changing LED and program pin mappings around.

o Also I was experimenting with not having to use the program jumper, but I didn't like the boot time so I went back to the jumper (for now). If your interested in this note that there is an open issue in the repo that keeps it form working. The issue is posted but the code has not been updated.

Jacob


andre85

Wed, 01 Feb 2012 10:37:15 +0000

Hi Jacob, So finally I've programmed the PIC32MX440F512H. In the file boards.txt I've put your USBONO text file. I've modifyed the string usbono_pic32.board=BOARD_UNO because I want the same pin mapping of the chipkit UNO... But there is a problem, UART1 doesn't work.. Is a problem of pins mismatch of the two microcontrollers ?

Andrea


Jacob Christ

Wed, 01 Feb 2012 16:06:12 +0000

Use Serial0 for RxTx, Serial is the USB for Serial.

I'm assuming you are using 0822 MPIDE.

Things are a little diferent in 1221.

Jacob


andre85

Thu, 02 Feb 2012 13:04:55 +0000

Thank you Jacob, now my project work well!!!! I'm downloading the new MPIDE 1221... What's the difference? How did you set the boards.txt and How did you use the RxTx and I2C in the MPIDE code?

Thank you, you're very good


andre85

Thu, 02 Feb 2012 13:25:08 +0000

Oh, and do you think that now with MPIDE 0822 and with the following text in boards.txt : usbono_pic32.board=BOARD_UNO my PIC32MX440F523H project will be completely stable and reliable?? Thank you, Andrea


Jacob Christ

Fri, 03 Feb 2012 23:20:58 +0000

Oh, and do you think that now with MPIDE 0822 and with the following text in boards.txt : usbono_pic32.board=BOARD_UNO my PIC32MX440F523H project will be completely stable and reliable?? Thank you, Andrea

My projects are stable and reliable, but I the bootloader and this include tag are not the only contributing factors to reliability and stability so I can't say for sure.

Jacob