PDA

View Full Version : If you want to use USB bootloader later?



keymuu
- 5th November 2008, 22:07
Hi!

When you have installed a bootloader (4550.hex) in your pic and then you have programmed with it and Microchip USB HID Bootloader v.2.2 an application to it, how can you then afterwards invoke the bootloader ?:confused:

Is it by pulling down RB4?

I have RC5 pulled up to tell the hw that a bootloader is in use "here. Can't remember where from I got that info. Is that correct?

If you can, please help!

Regards
Key

Bruce
- 6th November 2008, 16:01
Ground RB4 then reset the PIC. If RB4=0 at power-up, it should enter loader mode.

keymuu
- 6th November 2008, 20:47
Ground RB4 then reset the PIC. If RB4=0 at power-up, it should enter loader mode.
Thank you Bruce!

Yes, that was true (RB4=0)! It works as it should! I already tested it...:)

My PIC environment seems to work as it should also with RC5 pulled up. I assume that it does not harm, however because it is with a SMD resitor pulled up I can not (want not) remove it just to check the theory. :rolleyes:

My next step is now to invoke the bootloader from my application, not from the boot sequence with RB4=0. In other words, when the real application is running I would like to jump from there to the bootloader, to that location where RB4 is tested and the decision has been made to continue with the bootloader.

To do this one need first to find that point in the bootloader.
MPLAB can dissamble a hex file, can it really?
Is it View/Disassembly listing? I can't see anything in that listing...

Any ideas?
Can one really use MPLAB to disassembly pic.HEX?

Maybe it would be better to start a new thread with completely new approach to this? Or then not...;)

Bruce
- 6th November 2008, 22:06
All of the HID loader loader firmware is available. Just start MPLAB, open the HID loader
project, select MPSIM as the debugger, then select View Program Memory.

As you step through the loader source you can view where it checks for RB4, and jumps
into the loader section if RB4=0.

In the C source it's if(sw2 == 1) then run user program. If (sw2 == 0), it jumps to the
loader section.

An easy way would be to have your own code test RB4, and issue an assembler RESET
instruction if RB4=0.

Or you can step through the C18 source and find the exact location to GOTO & land right
on the loader routine start section.

keymuu
- 7th November 2008, 02:44
All of the HID loader loader firmware is available. Just start MPLAB, open the HID loader
project, select MPSIM as the debugger, then select View Program Memory.

As you step through the loader source you can view where it checks for RB4, and jumps
into the loader section if RB4=0.

In the C source it's if(sw2 == 1) then run user program. If (sw2 == 0), it jumps to the
loader section.

An easy way would be to have your own code test RB4, and issue an assembler RESET
instruction if RB4=0.

Or you can step through the C18 source and find the exact location to GOTO & land right
on the loader routine start section.

Bruce, thanks for the excellent idea.
The only problem seems to be that I have only PICbasicPro but not PIC C-compailer. It seems to me that you can not use MPLAB to run a source code if you do not have a corresponding compiler (in this case C-compiler). :(

What we know at this point is that the decision is made on RB4.
Using MPLAB and choosing first Program Memory and when that is open you choose Machine or Symbolic tab at the bottom of the page and you can then see the disassembled listing.

You cannot find RB4, however you can find PORTB, and in this HID bootloader only in one place, line 1953 and the disassembled code looks like this there:

Line, Address, Opcode, Disassembly
1953 0F40 A881 BTFSS, PORTB, 0x4, ACCESS
1954 0F42 D004 BRA 0xf4c
1955 0F44 0E07 MOVLW 0x7
1956 0F46 6EC1 MOVWF ADCON1, ACCESS
1957 0F48 EF00 GOTO 0x1000
1958 0F4A F008 NOP
1959 0F4C D80E RCALL 0xf6a

So, a jump from the application code to 0x0f4a (NOP) or 0xf4c (RCALL oxf6a) should work, at least one would think so and "the problem" is hence solved. I will tell you if there are other problems... hope not :cool:

The ACCESS on line 1953 and line 1956 refers to access bank? Is this true? Could one find a good PIC18F4550/2550 tutorial on the web somewhere, where all about the assembler would be clearly explained?

Thanks again Bruce for your great support...:)

mister_e
- 7th November 2008, 04:18
C-18 is still kinda free on Microchip website. Not sure if they used their optimizer to generate the .HEX though...

Bruce
- 7th November 2008, 15:16
As Steve mentioned, C18 student version is available for free download, and AFAIK, it
should compile the USB framework. It's handy to have if you need to step-through a
C18 code example, and of course, then you can modifiy the loader for your own apps.


The ACCESS on line 1953 and line 1956 refers to access bank? Is this true? Could one find a good PIC18F4550/2550 tutorial on the web somewhere, where all about the assembler would be clearly explained?
Yes this refers to ACCESS RAM.

The best place to learn about assembler for any given PIC is in the instruction set section
of the datasheet. There are also a lot of examples on the Microchip web forum. For 18F in
general, download this: http://ww1.microchip.com/downloads/en/DeviceDoc/39500a.pdf

If you're looking for a good book on the 18F series, my favorite is Embedded Design and
the PIC18F452 Microcontroller by Peatman. This one is excellent for learning assembler
for the 18F series.

keymuu
- 10th November 2008, 10:24
As Steve mentioned, C18 student version is available for free download, and AFAIK, it
should compile the USB framework. It's handy to have if you need to step-through a
C18 code example, and of course, then you can modifiy the loader for your own apps.


Yes this refers to ACCESS RAM.

The best place to learn about assembler for any given PIC is in the instruction set section
of the datasheet. There are also a lot of examples on the Microchip web forum. For 18F in
general, download this: http://ww1.microchip.com/downloads/en/DeviceDoc/39500a.pdf

If you're looking for a good book on the 18F series, my favorite is Embedded Design and
the PIC18F452 Microcontroller by Peatman. This one is excellent for learning assembler
for the 18F series.

Thank you Bruce!

Nowadays you do not need assembler so ofter, but when you do then it is annoying when you notice that your knowledge is so limited. Compare it with limited knowledge in a foreign language for ex. German, you manage as tourist in Germany but cannot discuss more... How much would you invest to get a really high level of that skill just because you will spend once a year a winter holiday in the Alps German speaking areas.... ?

Books are nice in shelf, but when you need to do something with your computer then it is kind of frustrating to grab a book instead of opening a PDF that has the nice hypertext facility, something that a physical book cannot have (at least yet :p).

That Microchip pdf is so far the best, not so much like a data sheet, thank you again Bruce :)