PDA

View Full Version : Help! PIC18F2550 - how to copy the code?


Babalui
Jul 19, 2008, 11:56 AM
Hi all,

I'm posting this message here because this is about the only place where I was able to find so elaborate discussion about PIC18LF2550 programming, and I was hoping someone could help me with a small problem of mine. I have to warn you that I have very basic knowledge about PIC programming. I'm simple everyday electrician.

Few years back I purchased two programmed 2550 that enable about 40 buttons, to be used as input device (joystick/keypad) in my cockpit building project. This chip is on a simple board with pins for inputs, and using 4 MHz oscillator. This board is recognized as standard joystick, no drivers needed.

By the time I started building first components for cockpit, I managed to misplace one chip and slightly damage the other one. The last one is still working (I had to plug it and solder it into DIL socket), but I'm too afraid to work with it. So, I've decided to make a "backup" - I've purchased some blank (?) PIC18LF2550 from ebay (the same type as original) and a serial JDM programmer. Seller claimed that it can be used to program PIC18F* with bunch of programs, but now I wish I ran into your forum sooner.

My JDM programmer is the same as used by your user Malc C, shown in his post:
http://www.rcgroups.com/forums/showpost.php?p=5261232&postcount=7

I've managed to download the code from the chip using following applications:
PICPgm Programmer
WinPic800
PonyProg
icprog
Win Pic Programmer

I was able to upload that hex code into new chip, but when I replace copy with original, nothing happens - ie this "joystick" is not on the list of Gaming devices.

Then I downloaded hex code from a copy and I've compared it with original code. Original and hex were different. Depending on the application used, there was a missing code at the beginning of the hex file, or at the end, or they differed in about 90% of content. I've compared copy and original hex created by the same application. I've tried various combinations, like downloading original with PICpgm, uploading to copy with WinPic, other way around, etc (made a list of all possible combinations and tried that way).

About the closest copy I could get was using Win Pic Programmer (DL4YHF's PIC Programmer for Windows). I downloaded and installed MPLAB so that programmer can used PIC18F2550.dev file. On tab "Device Config" in WinPic I've checked each item to match Configuration bits, as stated in MPLAB.

Finally, hex code from copy and original matched 100%, but copied chip is still not recognized by Windows. Original is instantly recognized (I've checked as often as possible).

I would appreciate any help here, as this in not really my field of knowledge, and all I need is to copy this one chip.

1. Is there some problem with pinout of my JDM board? How do I solve it?
2. Can I use ICSP pins (and how) to connect JDM to PIC via breadboard?
3. Is there some setting in programming apps (and what app) that I'm missing?
4. Do I need to upload some kind of bootloader into PIC18F2550 and how?

Final notes:
- My budget is very tight (incomes are quite low in my country). I'm not sure that I can afford buying another programmer. Still, I would like to hear your recommendations for a… erm… cheapest possible solution. But, I do not need the programmer for anything else but this, so I have second, third and fourth thoughts about investing into expensive programmers that I will use 2 times in my lifetime.
- I definitely cannot afford purchasing another programmed chip from the same source I got the first two (then the price of one original was much higher then the price of 5 chips from ebay).
- I'm afraid to contact the seller, as he did not made the code freely available, and I don't want him to think that I'm trying to resell his code. Therefore, I will not post that code anywhere. I just want to replenish my loss (OK, my stupidity).

Thanks in advance

Malc C
Jul 19, 2008, 12:41 PM
- My budget is very tight (incomes are quite low in my country). I'm not sure that I can afford buying another programmer. Still, I would like to hear your recommendations for a… erm… cheapest possible solution. But, I do not need the programmer for anything else but this, so I have second, third and fourth thoughts about investing into expensive programmers that I will use 2 times in my lifetime.
- I definitely cannot afford purchasing another programmed chip from the same source I got the first two (then the price of one original was much higher then the price of 5 chips from ebay).
- I'm afraid to contact the seller, as he did not made the code freely available, and I don't want him to think that I'm trying to resell his code. Therefore, I will not post that code anywhere. I just want to replenish my loss (OK, my stupidity).

Thanks in advance

Ok here are my observations, but then I'm no expert.

1) unless the guy is really un-reasonable, or the cost of the original PICs were so high, the simple answer would of been to purchase another, or ask him to program another chip for you at a reduced rate if you supplied the PIC.

2) If the original PICs were so expensive then chances are he has code protected the chip, however as you can read and save the HEX code then this would not seem to be the case, otherwise you would not be able to read the code if the PIC was fully code proteced.

3) The JDM programmer is not really the best for the 18F2550 chips, let alone the low voltage programming type. I had issue when programming some with my JDM progremmer, and it seem sthat the fuse settings or config bits can cause this sort of issue.

4) - you don't state exactly what this device does, but hopefully you are not trying to reverse engineer a commercial item such as a dongle similar to those used in top end simulators. - This is not something that should be discussed on the forum.

Try dropping the guy an e-mail and ask him ho much a replacement PIC would be if you provided the chip. You may find it cheaper and less time consuming than trying to re-program one of these PICs with your current programmer

Babalui
Jul 19, 2008, 01:33 PM
Malc C, thanks for fast reply!

Ok here are my observations, but then I'm no expert.
1) unless the guy is really un-reasonable, or the cost of the original PICs were so high, the simple answer would of been to purchase another, or ask him to program another chip for you at a reduced rate if you supplied the PIC.
2) If the original PICs were so expensive then chances are he has code protected the chip, however as you can read and save the HEX code then this would not seem to be the case, otherwise you would not be able to read the code if the PIC was fully code proteced.

The thing is that I've already invested quite a lot of my limited budget into this. I was hoping to save some money into purchasing few blank chips and a cheap programmer. I got three chips and a JDM for a bargain, 20 EUR total with postage. One original chip is about 15 EUR, plus postage, and I need two.
Also, I do not want to put that guy into (legitimate) position of refusing me, and making me totaly angry at myself.
Finally, call it a psychological impact of succes or failure - I would realy like to make this work.


3) The JDM programmer is not really the best for the 18F2550 chips, let alone the low voltage programming type. I had issue when programming some with my JDM progremmer, and it seem sthat the fuse settings or config bits can cause this sort of issue.
Yes, I've read yours and other posts. Hence my wish that I ran into this forum earlier. I was hoping you were able to resolve that issues, either modifying JDM or using some other (cheap) programmer.

4) - you don't state exactly what this device does, but hopefully you are not trying to reverse engineer a commercial item such as a dongle similar to those used in top end simulators. - This is not something that should be discussed on the forum.

It servers as a regular joystick with 40-some buttons. There are some axes, but my prime interest is in buttons for input. I have regular joystick that covers my need for axes, but my fav simulation has hundreds of commands and keyboard is not practical.
I'm not trying to reverse engineer the originals for commercial benefit. Otherwise I would not purchase two at the first place, in a hope I will use them, instead of loose them. I fully respect what that guy has done, the chips were costly (to me), but they work(ed) fine, as described, and I think that he deserves every cent.

Try dropping the guy an e-mail and ask him ho much a replacement PIC would be if you provided the chip. You may find it cheaper and less time consuming than trying to re-program one of these PICs with your current programmer
As I said, I would try to use what I have at this moment. Unless I make some use of these chips, I can throw the chips and the programmer into trash, as I do not need them for anything else, I do not know anybody that knows how to use them, and I do not know enought about 18F2550 or programming to make a hex code of my own for any use, apart from drawing electrical current :(
Also, most of the people I know would rather spend extra money on buying expensive joysticks, throttles and keyboards. When I ordered original chips I was excited as a child and showed them what it can do. They all said "Oh, fine, but all that wiring that you have to do by yourself - it is too much work!". So, even If I manage to program all 3 chips, I would not have a market for that last one.

If you feel that there are legal problems to my question, and I admit that there is as what I am trying to do is the same as making a copy of a game and making copied DVD work, feel free to close this topic. In that case I would like to appologize in advance for bringing this in the open on your forum.

As for the subject in question, can anyone explain why is it that I managed to get hex copy identical to original one, but the chip with copied code is not working?

Could there be some protected content in the chip? If so, then I realy give up...

Janusz
Jul 19, 2008, 02:09 PM
Hi All. http://www.sprut.de/electronic/pic/projekte/brenner8/index.htm

BushmanLA
Jul 19, 2008, 03:48 PM
1. Is there some problem with pinout of my JDM board? How do I solve it?
2. Can I use ICSP pins (and how) to connect JDM to PIC via breadboard?
3. Is there some setting in programming apps (and what app) that I'm missing?
4. Do I need to upload some kind of bootloader into PIC18F2550 and how?




Yes you can use the ICSP pins to connect the programmer to the breadboard. It is a little complicated and if you get it wrong you can nuke the programmer or the circuit it is attached to. Specifically, the MCLR line is brought to 13V to get the PIC into programming mode, and unless you make sure that 13V is isolated from the 5V rail on the breadboard, bad things will happen.

If the HEX files do not match up, perhaps the software is not getting the configuration registers correctly. I forget if that is actually in the HEX file or if you have to set it in the programmer software, or if one will just override the other if they are different.

Even if the chips you purchased do have a bootloader in them, if you can get a good copy of the hex file from the, and the config bits are right, and you can copy all of this into another PIC of the same time, it should work just fine.

Babalui
Jul 19, 2008, 07:28 PM
Hi All. http://www.sprut.de/electronic/pic/projekte/brenner8/index.htm

Thanks Janusz! So, you recommend above one?
Is there any English version of the manual? I don't know any German :(

Yes you can use the ICSP pins to connect the programmer to the breadboard. It is a little complicated and if you get it wrong you can nuke the programmer or the circuit it is attached to. Specifically, the MCLR line is brought to 13V to get the PIC into programming mode, and unless you make sure that 13V is isolated from the 5V rail on the breadboard, bad things will happen.

Can I destroy the PC? I could sacrifice one chip, but PC is a bit more important to me :)
Could you tell me how to connect pins? I hvae some idea, but duing this research I'm starting to get dizzy :(


If the HEX files do not match up, perhaps the software is not getting the configuration registers correctly. I forget if that is actually in the HEX file or if you have to set it in the programmer software, or if one will just override the other if they are different.
I think that configuration is set up by application, as I was able to get identical hex files only after setting up Config in WinPic according to Cofig data in MPLAB.
However, it loks that apps are reading some configuration from PIC, but not sure what. I could tell you more if you could tell me where to look.

Even if the chips you purchased do have a bootloader in them, if you can get a good copy of the hex file from the, and the config bits are right, and you can copy all of this into another PIC of the same time, it should work just fine.
Only thing that I can think off is that only a part of PIC content is downloaded. Otherwise, how come I did get matching hex, but copy is still not working.
Unless I have to set up the Config bit properly so the hex could be read?

Question on WinPic800:
This app has separate options to read Code, Data and Setting. Each individual reading is finished with OK mark. Any procedure to write them into PIC?

Thanks for your help!

Tomapowa
Jul 19, 2008, 11:48 PM
Funny to think that the developer of such PIC code would not protect the HEX. As a developer, you can either protect the HEX, the EEPROM (data) or both. So... even though the HEX appears to be copy-able, maybe they have the data (possible some important config stuff) protected instead. I've done this in the past... just to confuse those that like to peek at my HEX. :D

Malc C
Jul 20, 2008, 03:54 AM
Tom, I have to agree, you either make something freely available, or code protect the device. If this is just a normal joystick interface but one that supports loads of buttons, whats so special that it cost so much, unless it something commercially available that he's trying to copy ??

@Babalui - Pic programming is not complicated, but its also not as straight forward as pressing a few buttons and inserting a chip, especisllay with these higher end chips like the 18F2550. If there is nothing special about the code, then contact the developer and offer to send him a PIC if he can program it for you as you have damaged one of the originals. I've receive request from people who purchased program chips from me for various projects and have done the same, often I replace it free of charge, and he he is a decent guy I'm sure will be more ammecable to that than to find you are trying to copy his code yourself

mmormota
Jul 20, 2008, 10:10 AM
Pickit 2 is probably the best PIC programmer/debugger for hobby projects. Inexpensive and reliable, working with MPLAB etc.

Babalui
Jul 20, 2008, 02:13 PM
Hi all,
Thanks for your replies. I was doing some additional reading on the subject. Did not lerarn much, but I will have to agree with your lates conclusion about copy protection. I've copared the hex code with some other hex code for 18F2550 that I've found here (posted by Mac), and there are significant differences. It appears that I only thought that I was downloading the code, but in fact nothing was downloaded.

As I was moaning about this problem of mine to all of my buddies, one mentioned that he knows a guy that is "expert" in programming. I gave him all chips, and I hope that in a few days I will no for sure. I'll keep you posted about that.

Well, it looks like I will have to order new one. Not happy about such cost on top of this one. But as the last chip is still working and I was able to demonstrate it to others during my moaning, I managed to arise intereste in one of my friends. He will place an order tomorrow, and I'll pay him for additional one for me.

Thanks again!

soft2
Jul 20, 2008, 02:47 PM
... I've receive request from people who purchased program chips from me for various projects and have done the same, often I replace it free of charge, and he he is a decent guy I'm sure will be more ammecable to that than to find you are trying to copy his code yourself

I agree 100%. I've reprogrammed chips at no charge for customers just for good will several times. It will take him longer to read your email than re-program or send you a replacement. If he knows you have lots of friends who also might buy similar hardware, then he will come out ahead in the long run. You have nothing to lose by asking. Just tell him the truth: "I screwed up, I'm too poor to buy another, I have lots of friends who want to see this work, any chance you could help me out and re-flash my chip(s)?"

Further, there are probably bugs in his firmware. Like most of us programmers, he will get satisfaction out of knowing you have the latest version because he is proud of his code.