Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PICkit2 / Junebug bootloader, anyone familiar with custom programming?

Status
Not open for further replies.

blueroomelectronics

Well-Known Member
I'd like to have a small program run on the PICkit2 / Junebug using the built in bootloader. After running I'd like to have it reload its original PICkit2 firmware.

It's a very simple routine I need to run, simply a custom EEPROM updater. Once run it's no longer required and I'd like to reload the PICkit2 firmware, so I don't want to disable or destroy the original bootloader program.

I've found Wouter Van Ooijen's site includes details on the bootloader including some C code at the end of the document. I'm simply not familiar enough with C or the USB calls on the PIC (I don't need the USB to function with the program I'm using)

http://www.voti.nl/pickit2faq/index_1.html

Or this thread on Microchips forums. There's PICkit2 to RS232 software.
**broken link removed**
 
Last edited:
For your scenario would you consider the requirement to "press the button while booting" (in order to reset the device and have it re-download it's firmware) an acceptable paradigm? Or are you looking for fully auto-magic?
 
Whether this is very reason microchip PICKIT2 is provided with 2 Nos of EEproms !! whether they had some content at the assembly point??
 
I'm trying to program the 18F2550 internal EEPROM with a calibration value & user name on the Junebug. This will allow for 3.3V support.
The bootloader button on the PICkit2/Junebug allows you to program it to be something else and when you're done it can be a PICkit2 again. :)

I've installed Xianfan Chens FTDI firmware on a Junebug using this method. Turns the Junebug into a dual FTDI compatible USB to dual RS232 UART. Very cool actually
With this firmware Windows XP will see your Junebug as a pair of COM ports. Opens up possibilities for data loggers etc. And whenever you want just hold down the red button and run the PICkit2 2.40 software and it's a PICkit2 again.
 

Attachments

  • PICKit2DualCDC.zip
    106.7 KB · Views: 245
Sooo... minor mod to the "serial port" code ... no? Something that would sniff the packets as they go by and look for the "BlueRoom" key, which denotes here comes the calibration values, (and user name) :D

(That's me... 'handwaving' the solution in front of a whiteboard)

Seems too obvious.. what am I missing in the request?
 
It's something like that, in theory it should be pretty straight forward. It's a simple payload, once it runs it serves no other purpose. Hmm I have an idea... Might be very simple, gotta run for my morning Tim Horton's Coffee first.
 
Thanks August, but that file is just the .hex file (it comes with MPLAB & PICkit2 2.4)
What I'm looking for is a way to reprogram the 18F2550 with user firmware, but not damage the bootloader.
 
It's there somewhere

Oops, Wrong Link! :mad:

It is there somewhere. I will look again, and post it. I know it is somewhere because I have the zip file downloaded here.


Found it under "unsupported software".

https://ww1.microchip.com/downloads/en/DeviceDoc/FirmwareV2.10.00.zip


Go to the PicKit2 page and then look at:

PICkit 2 Programmer software source code is available **broken link removed**.


Duh, just went the wrong place the first time
 
Last edited:
What about the ASM code samples here:
**broken link removed**

The key is in the linker script to make sure your image starts after the boot loader. Then can use the PK2 software loader to download it. Saw details on here:
http://www.voti.nl/pickit2faq/index_1.html

But you pointed me to all of these.. so I think I must still be missing something (other than my Laptop which is at home so I can't test this Junebug just yet.. (if only work didn't get in the way of hobbies so much) ;) )
 
I'm not trying to program the external EEPROMs, I'm trying to modify the internal EEPROM. Turns out according to the Microchip forums that your program must start at 0x2000 and you set a byte to 0x55 to get it to start.
I'll try it shortly, and Pommies GLCD code. :)
 
somehow I could not reach the same site. perhaps i signed In last time. the topic was regarding internal EEproms. those 2 nos of 24LC512.
 
This was from the PICkit2 developer
From boot.h in the PICkit 2 Firmware source code:

#define RM_RESET_VECTOR 0x002000
#define RM_HIGH_INTERRUPT_VECTOR 0x002008
#define RM_LOW_INTERRUPT_VECTOR 0x002018

Program code execution starts at address 0x2000, interrupt vectors are at addresses above as well. You need to compile your code so it starts at 0x2000 and uses the vectors at 0x2008/0x2018.

Also, from the first part of boot_main.c:
void main (void) {
byte Temp;
word Counter;

//----------------------------------------
// Check Bootload Mode Entry Condition
//----------------------------------------

tris_PROG_SWITCH = 1; // RB4 Input
PROG_SWITCH = 1; // initialize port to 1
INTCON2bits.NOT_RBPU = 0; // initialize PORTB pull-ups on

Delay10KTCYx(600); // delay ~500 ms
if (PROG_SWITCH) { // is the push button pressed?
// if no, does program memory location 0x7FFE contain 0x55?
Temp = * ((rom far char *) 0x7FFE);
if(Temp == 0x55) {
_asm goto RM_RESET_VECTOR _endasm
}

From this you can see that in order for the bootloader to recognize that firmware exists and vector to 0x2000 on a reset, you must also write value 0x55 to program memory address 0x7FFE when writing your program via the bootloader.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top