Created Sat, 22 Jun 2013 12:45:37 +0000 by caroper
Sat, 22 Jun 2013 12:45:37 +0000
I was hoping to modify the DP32 Bootloader to relocate the PROG button and free up RB4 for use by the RTCC Xtal.
I downloaded the PIC32-avrdude-bootloader-master Files from Github but the DP32 is not in there.
Are Digilent Keeping it Closed Source as it is also used by Microchip for the pre loaded devices, or am I just a bit to eager and trying to do things faster than the Github can be refreshed :)
It would be a pity if, after all the work to move the Libraries to Open Source we now start to see products with the ChipKIT Brand but with Closed Source Bootloaders :(
I don't see anything in there based on 250F128B at all, and am reluctant to start from scratch and build one, especially as I only want to redefine a single pin, and I lack the experience that the other developers have.
Eventually I would also like to try moving it onto the 150F128B to free up the Pins currently dedicated to USB, for projects that need slightly more pins but can live without USB support, but baby steps are called for.
I installed MPLAB and C32v2.2a specifically for this, I was hoping to make the simple change first to test my tool chain before jumping in with both feet and I need to do it within the 60 day licence period.
[edit] My interim solution is shown in next post, it was not a scary as the BoardConfig.h makes it look.
I still have no idea what things like "blCapVirtualProgramButton" actually mean, but I fortunately didn't have to change it.
Cheers Chris
Sat, 22 Jun 2013 15:32:53 +0000
I decided to go ahead and build my own. I based it on the BOARD_FUBARINO_MINI_USB entry. It appears to work fine in my hardware (a breadboard implementation of the DP32) including the LED indications but I don't have a genuine DP32 Board to test it on.
#elif defined(_BOARD_DP32_USB_)
#if defined(PUT_CONFIG_BITS_HERE)
//* Oscillator Settings
#pragma config FNOSC = PRIPLL // Oscillator selection
#pragma config POSCMOD = XT // Primary oscillator mode
#pragma config FPLLIDIV = DIV_2 // PLL input divider
#pragma config FPLLMUL = MUL_20 // PLL multiplier
#pragma config FPLLODIV = DIV_2 // PLL output divider
#pragma config FPBDIV = DIV_1 // Peripheral bus clock divider
#pragma config FSOSCEN = OFF // Secondary oscillator enable
//* Clock control settings
#pragma config IESO = OFF // Internal/external clock switchover
#pragma config FCKSM = CSECME // Clock switching (CSx)/Clock monitor (CMx)
#pragma config OSCIOFNC = OFF // Clock output on OSCO pin enable
//* USB Settings
#pragma config UPLLEN = ON // USB PLL enable
#pragma config UPLLIDIV = DIV_2 // USB PLL input divider
#pragma config FUSBIDIO = OFF // USB USID pin controlled by port function
#pragma config FVBUSONIO = OFF // USB VBUSON pin controlled by port function
//* Other Peripheral Device settings
#pragma config FWDTEN = OFF // Watchdog timer enable
#pragma config WDTPS = PS1024 // Watchdog timer postscaler
#pragma config WINDIS = OFF
#pragma config JTAGEN = OFF // JTAG port disabled
//* Code Protection settings
#pragma config CP = OFF // Code protection
#pragma config BWP = OFF // Boot flash write protect
#pragma config PWP = OFF // Program flash write protect
//* Debug settings
#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select
//#pragma config DEBUG = ON // DO NOT SET THIS CONFIG BIT, it will break debugging
#pragma config PMDL1WAY = OFF // Allow multiple reconfigurations
#pragma config IOL1WAY = OFF // Allow multiple reconfigurations
#endif
#define CAPABILITIES (blCapDownloadLED | blCapSplitFlashBootloader | blCapUSBInterface | blCapProgramButton | blCapVirtualProgramButton | CAPCOMMON)
// Boot LED
#define EnableBootLED() (TRISBCLR = (1 << 3))
#define DisableBootLED() (TRISBSET = (1 << 3))
#define BootLED_Toggle() (LATBINV = (1 << 3))
#define BootLED_On() (LATBSET = (1 << 3))
#define BootLED_Off() (LATBCLR = (1 << 3))
// Download LED
#define EnableDownLoadLED() (TRISBCLR = (1 << 2))
#define DisableDownLoadLED() (TRISBSET = (1 << 2))
#define DownloadLED_Toggle() (LATBINV = (1 << 2))
#define DownloadLED_On() (LATBSET = (1 << 2))
#define DownloadLED_Off() (LATBCLR = (1 << 2))
// Other capabilities
#define fLoadFromAVRDudeViaProgramButton (PORTBbits.RB4 == 1)
#define fLoadFromAVRDudeViaVirtualProgramButton (LATBbits.LATB4 == 1)
#define ClearVirtualProgramButton() (LATBCLR = (1 << 4))
#define _CPU_NAME_ "32MX250F128B"
#define VEND vendUnknown
#define PROD prodUnknown
#define F_CPU 40000000UL
#define F_PBUS F_CPU
#define FLASH_BYTES (0x20000-0x1000) // Leave room one flash block (for bootloader!)
#define FLASH_PAGE_SIZE 1024 // In bytes
if it is blatantly wrong please let me know :)
I will now use it as a basis now for my experiments.
Cheers Chris
Sat, 22 Jun 2013 17:13:48 +0000
Digilent is not keeping this private. We have not committed to updating GitHub but our sources are available on request. Here are the relevant parts of BoardConfig.h. Our source tree is slowly diverging from GitHub as we have different requirements for our products, so we will not be specifically tracking with GitHub. If this does not solve your problem, let me know and I can get you a snap shot of the whole project; but I think this will work.
The virtual program button is to support executSoftReset (looking in wiring.c). I think all boards support that.
As for a vendor ID, pick one not in use. These is no committee to got to get one so it is difficult to know what is not in use. I have up to 3 in use now that I know about. I have just created a vendExperimental; until you sort of publish yourself as a viable vendor, use a number beyond that. I guess to get a vendor ID go to chipKIT.net and start a discussion on how to get one.
Hope this helps.
#define vendDigilent 0x0001
#define vendExperimental 0x8000
#define prodChipKITDP32 0x0401
#elif defined(BOARD_CHIPKIT_DP32)
#if defined(PUT_CONFIG_BITS_HERE)
//* Oscillator Settings
#pragma config FNOSC = PRIPLL // Oscillator selection
#pragma config POSCMOD = XT // Primary oscillator mode
#pragma config FPLLIDIV = DIV_2 // PLL input divider
#pragma config FPLLMUL = MUL_20 // PLL multiplier
#pragma config FPLLODIV = DIV_2 // PLL output divider
#pragma config FPBDIV = DIV_1 // Peripheral bus clock divider
#pragma config FSOSCEN = OFF // Secondary oscillator enable
//* Clock control settings
#pragma config IESO = OFF // Internal/external clock switchover
#pragma config FCKSM = CSECME // Clock switching (CSx)/Clock monitor (CMx)
#pragma config OSCIOFNC = OFF // Clock output on OSCO pin enable
//* USB Settings
#pragma config UPLLEN = ON // USB PLL enable
#pragma config UPLLIDIV = DIV_2 // USB PLL input divider
#pragma config FVBUSONIO = OFF // Make VBUSON a GPIO pin
#pragma config FUSBIDIO = OFF // Controlled by port function
//* Other Peripheral Device settings
#pragma config FWDTEN = OFF // Watchdog timer enable
#pragma config WDTPS = PS1024 // Watchdog timer postscaler
#pragma config WINDIS = OFF
#pragma config JTAGEN = OFF // JTAG port disabled
//* Code Protection settings
#pragma config CP = OFF // Code protection
#pragma config BWP = OFF // Boot flash write protect
#pragma config PWP = OFF // Program flash write protect
//* Debug settings
#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select
//#pragma config DEBUG = ON // DO NOT SET THIS CONFIG BIT, it will break debugging
#pragma config PMDL1WAY = OFF // Allow multiple reconfigurations
#pragma config IOL1WAY = OFF // Allow multiple reconfigurations
#endif
#define CAPABILITIES (blCapBootLED | blCapDownloadLED | blCapSplitFlashBootloader | blCapUSBInterface | blCapProgramButton | blCapVirtualProgramButton | CAPCOMMON)
// Boot LED
#define EnableBootLED() (TRISBCLR = (1 << 3))
#define DisableBootLED() (TRISBSET = (1 << 3))
#define BootLED_Toggle() (LATBINV = (1 << 3))
#define BootLED_On() (LATBSET = (1 << 3))
#define BootLED_Off() (LATBCLR = (1 << 3))
// Download LED
#define EnableDownLoadLED() (TRISBCLR = (1 << 2))
#define DisableDownLoadLED() (TRISBSET = (1 << 2))
#define DownloadLED_Toggle() (LATBINV = (1 << 2))
#define DownloadLED_On() (LATBSET = (1 << 2))
#define DownloadLED_Off() (LATBCLR = (1 << 2))
// Other capabilities
#define fLoadFromAVRDudeViaProgramButton (PORTBbits.RB4 == 1)
#define fLoadFromAVRDudeViaVirtualProgramButton (LATBbits.LATB4 == 1)
#define ClearVirtualProgramButton() (LATBCLR = (1 << 4))
#define _CPU_NAME_ "32MX250F128B"
#define VEND vendDigilent
#define PROD prodChipKITDP32
#define F_CPU 40000000UL
#define F_PBUS F_CPU
#define FLASH_BYTES (0x20000-0x1000) // Leave room 4 pages (for bootloader!)
#define FLASH_PAGE_SIZE 1024 // In bytes
Sat, 22 Jun 2013 18:54:53 +0000
Thanks Very Much Keith,
I meant no disrespect to Digilent, who I must say have given me nothing but the best customer service and support in the past. I genuinely did wonder if Microchip had blocked it.
I am pleased to see I got it almost identical, I will compare mine and yours and correct mine where I differ.
For my own version I have moved Program Button to RB7 which I believe is Button 2 on the DP32 Board.
I did it so that the RTCC is still usable, far to valuable a peripheral to lose. Do you think that could have any undue side effect that I have not foreseen?
I will have a look into executSoftReset .
Thanks again Cheers Chris
Sat, 22 Jun 2013 19:13:56 +0000
For the sake of closure, here is my final code for MX250F128B with a USB bootloader, PROG Button on RB7 and LEDs on RB2 and RB3.
//************************************************************************#elif defined(_BOARD_DP32_USB_)
#elif defined(_BOARD_BB32_250_USB_)
#if defined(PUT_CONFIG_BITS_HERE)
//* Oscillator Settings
#pragma config FNOSC = PRIPLL // Oscillator selection
#pragma config POSCMOD = XT // Primary oscillator mode
#pragma config FPLLIDIV = DIV_2 // PLL input divider
#pragma config FPLLMUL = MUL_20 // PLL multiplier
#pragma config FPLLODIV = DIV_2 // PLL output divider
#pragma config FPBDIV = DIV_1 // Peripheral bus clock divider
#pragma config FSOSCEN = OFF // Secondary oscillator enable
//* Clock control settings
#pragma config IESO = OFF // Internal/external clock switchover
#pragma config FCKSM = CSECME // Clock switching (CSx)/Clock monitor (CMx)
#pragma config OSCIOFNC = OFF // Clock output on OSCO pin enable
//* USB Settings
#pragma config UPLLEN = ON // USB PLL enable
#pragma config UPLLIDIV = DIV_2 // USB PLL input divider
#pragma config FUSBIDIO = OFF // USB USID pin controlled by port function
#pragma config FVBUSONIO = OFF // USB VBUSON pin controlled by port function
//* Other Peripheral Device settings
#pragma config FWDTEN = OFF // Watchdog timer enable
#pragma config WDTPS = PS1024 // Watchdog timer postscaler
#pragma config WINDIS = OFF
#pragma config JTAGEN = OFF // JTAG port disabled
//* Code Protection settings
#pragma config CP = OFF // Code protection
#pragma config BWP = OFF // Boot flash write protect
#pragma config PWP = OFF // Program flash write protect
//* Debug settings
#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select
//#pragma config DEBUG = ON // DO NOT SET THIS CONFIG BIT, it will break debugging
#pragma config PMDL1WAY = OFF // Allow multiple reconfigurations
#pragma config IOL1WAY = OFF // Allow multiple reconfigurations
#endif
#define CAPABILITIES (blCapDownloadLED | blCapSplitFlashBootloader | blCapUSBInterface | blCapProgramButton | blCapVirtualProgramButton | CAPCOMMON)
// Boot LED
#define EnableBootLED() (TRISBCLR = (1 << 3))
#define DisableBootLED() (TRISBSET = (1 << 3))
#define BootLED_Toggle() (LATBINV = (1 << 3))
#define BootLED_On() (LATBSET = (1 << 3))
#define BootLED_Off() (LATBCLR = (1 << 3))
// Download LED
#define EnableDownLoadLED() (TRISBCLR = (1 << 2))
#define DisableDownLoadLED() (TRISBSET = (1 << 2))
#define DownloadLED_Toggle() (LATBINV = (1 << 2))
#define DownloadLED_On() (LATBSET = (1 << 2))
#define DownloadLED_Off() (LATBCLR = (1 << 2))
// Other capabilities
#define fLoadFromAVRDudeViaProgramButton (PORTBbits.RB7 == 1)
#define fLoadFromAVRDudeViaVirtualProgramButton (LATBbits.LATB7 == 1)
#define ClearVirtualProgramButton() (LATBCLR = (1 << 7))
#define _CPU_NAME_ "32MX250F128B"
#define VEND vendUnknown
#define PROD prodUnknown
#define F_CPU 40000000UL
#define F_PBUS F_CPU
#define FLASH_BYTES (0x20000-0x1000) // Leave room one flash block (for bootloader!)
#define FLASH_PAGE_SIZE 1024 // In bytes
//************************************************************************
Hex File is attached, delete the ".txt" extension to use it, the forum will not allow ".hex" to be attached. In MPIDE select ChipKIT DP32 as the board.
Cheers Chris
Sun, 23 Jun 2013 17:01:28 +0000
Keith,
If you'd like to, I'd be really happy to merge in the DP32 bootloader you've made into the GitHub repo so that people can find it there.
*Brian
Sun, 23 Jun 2013 17:41:20 +0000
caroper
Glad you got things to work. Moving the PGM button should not be an issue if that is what you want. Maybe we missed a better choice on the button. With these low pin count boards, it is hard to get the mix of functionality correct as someone will not like what you picked. Fortunately this is all open source so you can do what you want.
Brian,
Please add this to GitHub if you like. I think the DP32 is an interesting board and it probably should be out there. Brian, notice that I included the FVBUSONIO/FUSBIDIO we talked about in the config bits.
Oh BTW Brian, on my copy of the Mini, I also changed the FVBUSONIO/FUSBIDIO = OFF, not sure how you are officially doing this.
Sun, 23 Jun 2013 21:47:46 +0000
And it has been done. I've created the DP32 projects, added the section (from above) to BoardConfig.h compiled, and checked everything in to the GitHub repo for the DP32.
*Brian
Sun, 23 Jun 2013 21:56:10 +0000
Keith,
About the FVBUSONIO/FUSBIDIO settings - the current bootloader (and the bootloader I sent to Microchip for programming the Fubarino Minis) has both set to OFF, just like the DP32 bootloader. So we should be good there.
*Brian
Mon, 08 Jul 2013 12:02:24 +0000
And it has been done. I've created the DP32 projects, added the section (from above) to BoardConfig.h compiled, and checked everything in to the GitHub repo for the DP32. *Brian
Hi Brian,
I just downloaded the zip file from https://github.com/EmbeddedMan/PIC32-avrdude-bootloader/tree/master/bootloaders but still dont see any referance to DP32.
Am I looking in the wrong place?
Cheers Chris
Tue, 09 Jul 2013 21:55:12 +0000
Yes. You should be looking here : [url]https://github.com/chipKIT32/PIC32-avrdude-bootloader[/url]
Sorry for the confusion.
*Brian
Tue, 09 Jul 2013 22:08:10 +0000
Thanks Brian,
Got it.