Skip to main content
Topic: "Diolan Plus" bootloader. (Read 55156 times) previous topic - next topic

Re: "Diolan Plus" bootloader.

Reply #30
Hi all, great work with the bootloader port!

I am struggling trying to get the code to run on a PIC18F14K50 and would really appreciate any help at all. I have attached a zip with my 2nd attempt, 2 'USBTrace' Logs and a uart debug output file.

The 'USBTrace' Logs show a successful connection to a PIC18F4550 device (a Tiertex dev board) and an unsuccessful attempt to a Microchip Low Pin Count Dev Board.

The UART Debug Output file contains to UART output for both the 4550 and 14K50.

The code I have attached has modifications (from this topics origional 2550 code) to the linker script (USB ram Allocation), the size of the 'SetUpPkt' and control transfer array and some of the RAM address' associated with USB data. I have marked them as !MODIFIED!

I have stripped back all the mods I have tried to this 2nd attempt as nothing I did in the first made any difference.

I do not have a great deal of experience with assembler but I cannot see what is different from the working 2550/4550 code and the not working 14K50 code other than the memory allocations. I have also checked the linker map output file for both setups and also the working HID bootloader in the Microchip examples and have tried several configurations of array sizes for those mentioned above. I have even gone through the HID example C code and checked in back against the 2550 assembler and where I have found differences I have modified the assembler but as none of this changed anything i haven't included it in the zip. If anybody would like to look at it I could upload that also.

I am not just asking for my problem to be solved for me, I would really like to understand what the problem is and why I have missed it. I am used to C and generally have had little experience with linker scripts and such (usually the C compiler just sorts everything out) but I am keen to learn.

Once again any help at all would be greatfully received.

Day

Re: "Diolan Plus" bootloader.

Reply #31
Hi Day,

Just curious - exactly which version are you using? For the 18F24J50 port I had to swap banks for some registers.
Got a question? Please ask in the forum for the fastest answers.

Re: "Diolan Plus" bootloader.

Reply #32
Hi Ian, thanks for that nudge. You must find it very tedious when people like me ask for advice when I really should know better!

Time to get to grips with assembler!

Many thanks

Day

Re: "Diolan Plus" bootloader.

Reply #33
I can't tell if that meant it was helpful or not :) I'm always happy to give google new content to index. If you need an example pls let me know, I'll hunt it down.

Update... Here's an example from version in our svn. You can find the mods in the files by searching the 18F24J50 keyword to see where I had to do it:

http://code.google.com/p/dangerous-prot ... asm.asm#86

Code: [Select]
usb_state_machine_actif
btfss UIR, ACTVIF
bra usb_state_machine_actif_end
;!!!18f24j50 change!!!
movlb 0x0f ;select the correct bank
btfss UIE, ACTVIE
bra usb_state_machine_actif_end
movlb 0x00 ;back to main bank
UD_TX 'A'
bcf UCON, SUSPND
;!!!18f24j50 change!!!
movlb 0x0f ;select the correct bank
bcf UIE, ACTVIE
movlb 0x00 ;back to main bank
bcf UIR, ACTVIF

I do not know if this applies to your chip, but I assume it is not present in the '+' version posted in this thread.
Got a question? Please ask in the forum for the fastest answers.

Re: "Diolan Plus" bootloader.

Reply #34
Hi Ian,

sorry yes i've got it working now. I was grateful you suggested where to start looking rather than giving me working code as I have learnt so much more by working it out myself. I have never used assembly other than to run say a few instructions in a C environment. eg asm{bcf TRISC, 1; bsf PORTC, 1;}

I assume that not understanding bank switching is fairly low on the assembler ability scale and sometimes on forums you get made fun of and told to quit what you are doing "if you don't know something as basic as that", so I appreciate your helpfulness and now I have something useful and relevant from which to learn a new skill.

Thanks

Day

Re: "Diolan Plus" bootloader.

Reply #35
I built the Soldering Iron Driver v1.5 and am trying to get it working. There are some serious button debounce issues with the current hardware/firmware, ie no hardware or firmware debouncing. I am currently debating whether to debounce in hardware vs software. I could add an Arduino to software debounce the switches and send clean signals into the driver board but that would be a truly ugly solution. Or use a 7414 schmitt inverter-- less ugly but that would still require several passives per button.

Ahri seems to have used the hardware approach in his build. I guess I could go that route but I would like to contribute to the project by coding a software debounce so that everyone making the v1.5 board won't have to make a debouncing circuit.

I have very little experience with PICs and no experience with PIC usb bootloaders. I have however programmed an MSP430 to debounce three switches concurrently and independently. If I can get the USB bootloader for the 18F2550 working, it would make testing/reprogramming easy enough that I will try to implement software debouncing.

My question is this: how do I get the USB bootloader to work? In particular:
    1) Will the bootloader.hex file at
http://code.google.com/p/dangerous-prot ... bootloader work without changes or will I need to make changes in particular for the Soldering iron driver?
2) When I burn this to the PIC, do I need to set flags a certain way or is this set in the hex file?
3) When I compile the soldering iron driver firmware, are there certain flags, settings that need to be set, ie start of program in memory, reset/interupt vectors, etc?
[/list]

Another thing-- where can I find the original code for "diolan plus?" I downloaded the modified version for the 18F2550 from the google code site for dangerousprototypes but can't seem to locate the root diolan plus source code. From the description, it seems that there may be enlightening information in there.

Re: "Diolan Plus" bootloader.

Reply #36
Usually when using a bootloader you have to export the hex file from MPLAB and move the memory to a specific location...We used the same hardware setup(oscilater etc) as the LCD backpack, so the same bootloader should work...I say should because we never got around to testing it yet, stuff always keeps poping up :)

as for the debouncing, I think software is the best way, since that is what we will do for the final release for sure....Thanks for testing it out, and playing around with it. I have mine assembled and will join you in a week tops...

BTW what programer do you have, for programing PICs?
best regards FIlip.

Re: "Diolan Plus" bootloader.

Reply #37
Thanks arakis. I agree that software debouncing is the best solution. I will try out the LCD backpack bootloader. Is this the right one? trunk/ LCD_Backpack_PIC_HD44780/ bootloader

You mentioned moving the memory to a specific location. How do you do this and where do you move it to? Do you have to move anything else such as interrupt vectors? Does anything else need to be changed in the firmware code when using a bootloader? Here is the body of the linker file from the above project:
Code: [Select]
 CODEPAGE   NAME=vectors    START=0x0            END=0x1B         PROTECTED
//CODEPAGE  NAME=bootldr    START=0x1C          END=0x0AFF
CODEPAGE  NAME=bootldr    START=0x1C          END=0x07FF
//CODEPAGE  NAME=apppage    START=0x0B00        END=0x0B01
CODEPAGE  NAME=apppage    START=0x0800        END=0x0801
CODEPAGE  NAME=idlocs    START=0x200000      END=0x200007      PROTECTED
CODEPAGE  NAME=config    START=0x300000      END=0x30000D      PROTECTED
CODEPAGE  NAME=devid      START=0x3FFFFE      END=0x3FFFFF      PROTECTED
CODEPAGE  NAME=eedata    START=0xF00000      END=0xF000FF      PROTECTED

DATABANK  NAME=gpr0      START=0x0            END=0x0FF
//DATABANK  NAME=gpr1      START=0x100          END=0x1FF
//DATABANK  NAME=gpr2      START=0x200          END=0x2FF
//DATABANK  NAME=gpr3      START=0x300          END=0x3FF
DATABANK  NAME=usb4      START=0x400          END=0x490          PROTECTED
DATABANK  NAME=usb5      START=0x500          END=0x580          PROTECTED
//DATABANK  NAME=usb4      START=0x400          END=0x4FF          PROTECTED
//DATABANK  NAME=usb5      START=0x500          END=0x5FF          PROTECTED
//DATABANK  NAME=usb6      START=0x600          END=0x6FF          PROTECTED
//DATABANK  NAME=usb7      START=0x700          END=0x7FF          PROTECTED
ACCESSBANK NAME=accesssfr  START=0xF60          END=0xFFF          PROTECTED
I have an old serial JDM clone from Olimex-- picked it up for about $15 a few years back.

Re: "Diolan Plus" bootloader.

Reply #38
wrt debouncing, I added it (found few minutes today between work): viewtopic.php?f=56&t=2457&p=40688#p40688

as for the bootloader, 18f2550 works perfect with microchip hid bootloader, it's easy to use it and works like a charm. I just don't see a point in soldering iron having usb port so I never bothered adding bootloader to this project :D

Re: "Diolan Plus" bootloader.

Reply #39
[quote author="pjkim"]Thanks arakis. I agree that software debouncing is the best solution. I will try out the LCD backpack bootloader. Is this the right one? trunk/ LCD_Backpack_PIC_HD44780/ bootloader

You mentioned moving the memory to a specific location. How do you do this and where do you move it to? Do you have to move anything else such as interrupt vectors? Does anything else need to be changed in the firmware code when using a bootloader? Here is the body of the linker file from the above project:
Code: [Select]
 CODEPAGE   NAME=vectors    START=0x0            END=0x1B         PROTECTED
//CODEPAGE  NAME=bootldr    START=0x1C          END=0x0AFF
CODEPAGE  NAME=bootldr    START=0x1C          END=0x07FF
//CODEPAGE  NAME=apppage    START=0x0B00        END=0x0B01
CODEPAGE  NAME=apppage    START=0x0800        END=0x0801
CODEPAGE  NAME=idlocs    START=0x200000      END=0x200007      PROTECTED
CODEPAGE  NAME=config    START=0x300000      END=0x30000D      PROTECTED
CODEPAGE  NAME=devid      START=0x3FFFFE      END=0x3FFFFF      PROTECTED
CODEPAGE  NAME=eedata    START=0xF00000      END=0xF000FF      PROTECTED

DATABANK  NAME=gpr0      START=0x0            END=0x0FF
//DATABANK  NAME=gpr1      START=0x100          END=0x1FF
//DATABANK  NAME=gpr2      START=0x200          END=0x2FF
//DATABANK  NAME=gpr3      START=0x300          END=0x3FF
DATABANK  NAME=usb4      START=0x400          END=0x490          PROTECTED
DATABANK  NAME=usb5      START=0x500          END=0x580          PROTECTED
//DATABANK  NAME=usb4      START=0x400          END=0x4FF          PROTECTED
//DATABANK  NAME=usb5      START=0x500          END=0x5FF          PROTECTED
//DATABANK  NAME=usb6      START=0x600          END=0x6FF          PROTECTED
//DATABANK  NAME=usb7      START=0x700          END=0x7FF          PROTECTED
ACCESSBANK NAME=accesssfr  START=0xF60          END=0xFFF          PROTECTED
I have an old serial JDM clone from Olimex-- picked it up for about $15 a few years back.[/quote]

sorry haven't dived into the code yet...I asked about the programmer, because with a better one you could do debugging from MPLAB....which makes life much easier..
best regards FIlip.

Re: "Diolan Plus" bootloader.

Reply #40
1) Will the bootloader.hex file at http://code.google.com/p/dangerous-prot ... bootloader work without changes or will I need to make changes in particular for the Soldering iron driver?

Should work fine. As long as your crystal is 20MHz I would assume.

    2) When I burn this to the PIC, do I need to set flags a certain way or is this set in the hex file?

Should all be in the hex.

    3) When I compile the soldering iron driver firmware, are there certain flags, settings that need to be set, ie start of program in memory, reset/interupt vectors, etc?

You need to use a linker (.lkr) file that preserves the first 800 words of flash for the bootloader, and all interrupts need to be redirected to n+ 800. See the IR Toy firmware or the USB stack echo demo for example interrupt relocation and linker files.


Quote
Another thing-- where can I find the original code for "diolan plus?" I downloaded the modified version for the 18F2550 from the google code site for dangerousprototypes but can't seem to locate the root diolan plus source code. From the description, it seems that there may be enlightening information in there.

The code in our SVN is the original diolan bootloader. JTR did some updates that are included in the plus version, so I guess here.
Got a question? Please ask in the forum for the fastest answers.

Re: "Diolan Plus" bootloader.

Reply #41
Thanks Ian.
I have the 20MHz crystal. If I burn the bootloader onto the SID board, the bootloader seems to work OK. When I short PGD and PGC on the ICSP header, the board enumerates as a USB device. I can use the fw_update program to burn the new firmware built with the .lkr file from the LCD backpack source. The fw_update program recognizes the USB device, burns the new firmware and verifies correctly.

Problem is that the new firmware does not seem to work properly-- the LCD screen remains blank and there are no signs of activity. I reset the low and high priority interrupt vectors the same way as the main.c from the LCD backpack project. When I look at the .hex file, the address does start in low 0x800s.

If the board is recognized as a valid USB device by the OS and the fw_update program burns the new firmware and verifies, can I assume that the bootloader is fine and that it must be a problem in my build of the firmware, i.e. reset/interrupt vectors not set correctly or lkr file contains errors. Any other possibilities?

Peter


Re: "Diolan Plus" bootloader.

Reply #43
the hex in the dp's repo on google in diolan 18f2550 directory, is it compiled with extended or without extended command set?

Re: "Diolan Plus" bootloader.

Reply #44
It works with sid now :)
The new HEX is available on source forge sid project page


The hex for bootloader is compiled in a way that bootloader will start every time you restart the device.
If you just power on device your application will start.

You can burn SID_GEN4.X.production.hex directly in to your PIC18F2550 but if you like to use bootloader, it's now possible.

For the blank 18F2550 you
 - erase chip
 - flash diolan-bootloader.hex provided

and you are ready to upgrade firmware trough USB

In order to upgrade firmware trough USB
- download fw_update from diolan site http://www.diolan.com/pic/bootloader_dwn.html
- connect SID to your USB and to power
- restart SID (by shorting pin1 and pin3 of the ICSP connector and then removing the short - this is pushing MCLR to Vss)
- DIOLAN bootloader will start
- update the firmware using ft_update:
 o ERASE flash
  fw_update.exe -e -vid 0x04d8 -pid 0xfa98 -t no
 o WRITE data
  fw_update.exe -w -t no -vid 0x04d8 -pid 0xfa98 -ix SID_GEN4.X.production.hex
 o VERIFY data
  fw_update.exe -v -t no -vid 0x04d8 -pid 0xfa98 -ix SID_GEN4.X.production.hex

That's it. Now power off SID.

NOTE: There's a bunch of capacitance on the SID's power rails so if you turn SID immediately after this procedure it will think it restarted and will go to bootloader, make sure you wait until all capacitors are empty before you power on the SID. What I do is make sure I disconnected the power and then I short pin's 2 and 3 on the ICSP emptying the cap's on the power rail.

I will look into this diolan bootloader when I catch some time, I just made slight mod to the source so it works with diolan bootloader (it can actually also work with microchip hid bootloader, only you need different linker script, I'll check out how can I use multiple configurations in mplabx and make it possible to select config with bootloader, without bootloader diolan or mchip hid).

Good thing also is that device will work without bootloader also (it adds the jump codes on the proper places :D )