怎样用 "Through Pic Programming" 编程PIC卡/金卡上的eeprom
渔歌QQ6500138翻译


快捷步骤:
----------------------------
1) 使用 JDM 之类的硬件和软件IC-Prog 写 Loader/Boot/Main 文件 XXX.HEX 到 16F84(877,876) 芯片
2) 使用 Phoenix 和软件IC-Prog 写 eeprom 文件 yyy.BIN 到 24c16(64,256) EEPROM芯片
3) 使用 JDM + IC-Prog 写 PIC 程序文件 zzz.HEX 到16F84(877,876) 芯片


要求
-----------
* 带232口的电脑
* 卡。可以是塑料卡片或者自己DIY的PIC卡
* 兼容 JDM 模式的编程器.用来写入PIC程序文件
* 兼容 Phoenix/Smartmouse 模式的编程器。用来写入eeprom
- 如果你只写自己DIY的PICCARD(Gold card/Silve card卡), 并不需要Phoenix/Smouse编程器.
只需要把芯片插在JDM的IC插座上。
- 可以使用分立的编程器,也可以使用N合一的,效果是一样的.
* 支持JDM 编程的软件,例如 IC-pro 1.04A.
* Phoenix/Smartmouse 硬件用的软件,例如 Winphoenix. ICPROG

更多关于不同种类的卡
------------------------------
基本有三种类型.
(1) Wafer cards(塑料片封装的卡片)
传统的塑料封装卡. 即符合国际ISO 7816 标准的卡, 之所以叫"wafer"就是因为它很薄。

这种卡也有不同的类型.

"wafer" 仅包含一个芯片. 常用于加密 D2MAC 模拟通道, and were known as MultiMacI (MM1) cards.

"Goldwafer" 包含2个芯片: 一个 PIC 和 一个 EEPROM. 是第一个流行的可以自动升级的盗版卡, and were known as MultiMacII (MM2) cards. 因为这些卡最初都是金色的封装,大家就都俗称Goldwafer. 但也有个别是白色的。
这种卡的 PIC 是 16F84. 一些老的 D2MAC wafer cards 是 16C84. 该卡程序Ram太少是它致命的缺点.
它的EEPROM 芯片是24C16. 也有用 24LC16 的。这里的"L"代表低功耗".

"Triple-wafer" 包含2个 PICs 和一个EEPROM.

"Quad" 包含2个 PICs 和2个EEPROM.

其中的2个PIC为 "slave" 和"master". , 特别的专为 master/slave模式编写的程序文件越来越多.


"Fun-cards" 一般芯片为Atmel公司的新型risc芯片,如 AT90S8515 和 24c65 EEPROM.我们通常用的YAOWU卡就是这种卡,通常是粉色或紫红色。

(2) SMD cards - 表面封装卡.
采用表面封装元件和表面封装焊接技术制作的卡,体积小,有利于关闭你的机器CAM盖板,但是对于手工DIY来说难度太大,一般是委托工厂批量加工。

(3) PCBs - (PIC-cards) 电路板卡。很容易自己DIY的卡
它的优点很多,适合DIY,可以增加IC插座,这样上面的芯片就可以随时拔插,可以单独的对单个的芯片进行编程,改写等操作。当然也可以不焊接IC插座而是通过我们下面要讲
的”Through Pic Programming“的方法,象写塑料卡一样的写PIC卡。它的缺点也是显而易见的:体积大,机器关不上盖,某些cam模块根本放不进去(除非你单独设计你自己的PCB板)

低廉的价格和优良耐搽写性能,容易购买的零件是PIC卡目前大行其道的原因。其中DIY的乐趣也非言语能形容。

更多关于编程器
---------------------------
大部分的编程器使用电脑的com口和一根标准的232电缆(1-1模式). 还有一些用并口,并且有的要求特殊的电缆,外部的直流电源供给(一般为9~12V 300mA)。
为了写塑料卡, Ludi(JDM兼容的编程器)和 Phoenix 硬件就必须要安装有Smartcard的卡座。单并不是所有的编程器都配备这样的卡座。
如果你只准备给你自己DIY的PCB卡编程,那完全没有必要安装Smartcard卡座。但是建议你的PCB板上最好安装IC座,方便来回的拔插IC芯片。
如果你要写塑料卡,你就必须要有一个Phoenix/Smartmouse硬件设备, 目前我们只能通过它来写入数据到 EEPROM芯片. 通常的频率是 3.57MHz. 6.00MHz的频率是给现代的 modern MOSCs 准备的,但是可能会损坏你的塑料卡.
Note: JDM模式不需要石英晶体.


常用的 JDM 模式编程器 (also referred to as a "Hi/Lo programmer" 如 DL20 和 JDM (Jens Dyekj?r Madsen).

更多关于编程软件
------------------------------------
软件提供写,读,擦除等功能,把 HEX or BIN 读入缓存, 通过232口使用标准的串口通讯写进芯片. 大多数软件程序使用 checksums 来校验写入的数据.
这样的软件多种多样.有的还带有一些附加的功能,方便我们使用。例外也有一些编程器使用自己专用的软件,这些软件只能用于特定的硬件设备。不能通用。
Note:无论你使用什么样的Phoenix/Smartmouse 软件, 它必须支持3.57MHz 频率!


哪里有的买? 多少¥?.
--------------------------------
国外,尤其是欧洲的很多网站都有出售,价格不菲,当然。这是对于我们国家的经济水平来说的。做工都不错,都是工厂批量加工的成品或板成品,搭配一些实用的软件。 但是我们难以买到,原因不说大家也心理明白。

过程概况
-------------------
弄到KEY,它将要写入eeprom中
弄到利用上面的KEY进行解密计算程序,将要写入PIC芯片中。

程序软件一般是用十六进制文件保存的。通常为(xxx.HEX)

保存KEY的数据文件通常是二进制的文件 (xxx.BIN)

另外 通过PIC(16F8X)芯片把包含key的数据文件写入eeprom(24CXX)芯片中,还需要一个重要的小程序软件:LOAD.hex(boot,main等,都是一个意思)
通常是一个十六进制文件的 HEX 文件.
一些编程软件可能需要 HEX格式的eeprom数据文件. 如果你找到的文件格式不同,也不要担心,现在有很多软可以进行格式转换, 玩过 MOSC (原版卡,这里是指修改原版本卡片达到能够继续使用目的的意思)的朋友都知道 crd文件,它也是一种数据文件格式. 但是我们不需要理会这些.


什么是loader/hex 文件
-------------------
当你用表面封装的PCB卡或者塑料卡,或者你直接把芯片焊接在PCB板子上又嫌来回焊接麻烦(还容易损坏硬件),就又个问题摆在我们面前: 怎样把数据写入 EEPROM?,仔细看原理图纸就会发现,编程eeprom需要的管脚没有单独的连接线连接到卡片的触片.
解决方案就是 "Through-PIC" 技术. 意思是先写一个特别的程序文件到PIC(16F8x),这个程序是临时的,它的功能只有一个,就是负责和电脑通讯,把eeprom的数据传送给eeprom芯片.起了二传手的作用,目前又很多版本的load文件,例如 LOADER.HEX, MAIN.HEX, 16F84.HEX 等等. 通常PIC应用文件包里面都包含了一个loader. 但是你不一定要必须用它. 如果你曾经使用过一个很好用的loader文件, 可仍然继续使用. 当eeprom文件被正确的传送进eeprom芯片,那么这个loader也就没有用处了,下一步就是用相应的程序文件覆盖它。完成一个卡片的整个编程工作。

什么是 key/bin 文件
----------------
包含一些或全部 MOSC (原版卡)内容的文件. 例如 ATR (通讯协议,决定了卡的兼容性能), 国家代码(使用范围), 卡号码(期限), 密匙数据(授权).

什么是program/hex 文件
--------------------
模拟正版卡的程序, 但是比正版卡要多出很多额外的功能(例如手动更改key,添加频道商,特定频道加密码等,属于开发人额外编写的程序,目前国内能做到这步的人不多).
不同的PIC程序都有自己读取数据文件的方法和格式,不能通用.就是说pic(16F8X) .hex和eeprom(24Cxx).bin是成对使用的,而loader文件基本可以通用。


出错与故障
---------------
即使是购买成品的编程器和配套的软件,也不能保证一点错误不出.种类繁多的编程器硬件和不记其数的软件组合起来,会出现无法预料的故障 我们很难判断一个错误究竟是由于什么引起的一个最愚蠢的问题经常出现在BBS上:我写卡失败。怎么办?
没有人能回答你。非要我回答的话:那你去死好了。你的MM我会去替你照顾好她的。 非常值得注意的几个问题:

* 笔记本电脑的电源管理,经常会使你的硬件COM口出现通讯问题。尽量不使用笔记本电脑或关闭省电模式等。
* 电脑过快也会引起通讯问题,一个可笑的原因,难道要我配一台286?你有吗?好难找。尤其使我们自己DIY的编程器,解决办法使加大延迟时间
* 确保你的软件支持你的编程器硬件和你的芯片!!!
* 电源供给不够,不稳定经常使引起写卡失败的主要原因。
* 不同版本的PIC/eeprom hex文件对应不同的接收机。目前不存在全兼容的hex软件. 你找到的文件包里面一般会有个readme.txt,里面通常会告诉你他的hex都支持什么样的机器

例如for red-cam only ,for humax5400 ,for all-cam等。请仔细阅读。

希望你找到适合你自己的机器的hex,我这里就有一个for p-3800,muse-100,simon92x,red-cam的hex,这样的hex都是经过改写过的。

*确认你的loader工作正常。否则。。嘿嘿。。你的eeprom数据根本没有写进去。卡怎么可能使用。



英文原文:

How to use "Through Pic Programming" to program the Eeprom on a PIC/wafer-card
==============================================================================


v1.0
Sept/2000
by 2old4this
============

Quick step-by-step reference
----------------------------
1) use h/w device like JDM + IC-Prog to write Loader/Boot/Main file xxx.HEX to 16F84 PIC
2) use h/w device Phoenix + IC-Prog to write eeprom file yyy.BIN to 24c16 EEPROM
3) use h/w device JDM + IC-Prog to write PIC pgm file zzz.HEX to 16F84 PIC


Requirments
-----------
* Windows PC with COM port & cable (e.g. COM1 port and the same serial RS232 cable used to connect your PC to a modem)
* Wafer card. Several formats are useable. See below. Typically a "goldwafer" is needed.
* Programmer device which can operate in "JDM" mode for programming loose DIL chips (PIC and/or EEPROM).
* Programmer device which can operate in Phoenix/Smartmouse mode for programming embedded EEPROM chips
- if using a card with dismountable chips, no Phoenix/Smartmouse device is required.
- these Ludi & Phoenix programmers can be 2 separate devices or a single "combi" device.
* PIC programming software to operate the JDM device
* Phoenix/Smartmouse software to operate any Phoenix/Smartmouse programming device you need.

More details on suitable cards
------------------------------
Basically there are three main types.

(1) Wafer cards
These are the traditional plastic credit-card type. They contain chips which are etched into the layer sandwiched between the plastic, and so are invisible.
They follow international (ISO 7816) standards, and their pin layouts are well documented in official literature. The word "wafer" itself arises from the fact that they are wafer thin.

There are various kinds of such cards.

"wafer" (i.e. the simple term, as opposed to, say, goldwafer) usually refers to a card containing just one chip. They used to be in service for decrypting D2MAC analogue channels, and were known as MultiMacI (MM1) cards.

"Goldwafer" is a card that contains 2 chips: one PIC and one EEPROM. They first became popular as auto-updating D2MAC analogue pirate cards, and were known as MultiMacII (MM2) cards. The name arose because most of these class of wafer cards are gold coloured. But not all. Some are white, for example. In fact it doesn't matter what colour they are so long as they contain the right chips. But beware: many (most) of the white wafers are actually single-chip wafers, and that is not sufficient.
The PIC is type 16F84. Some older D2MAC wafer cards have a 16C84. This is NOT ok, since it contains insufficient RAM memory to hold the files that will be loaded.
The EEPROM is a 24C16. Some variations are ok. For example, the 24LC16 where the "L" indicates "low power consumption".

"Triple-wafer" cards contain 2 PICs and one EEPROM.
"Quad" cards contain 2 PICs and 2 EEPROMs.
The 2 PICs are configured as "slave" and "master". Schematics for such cards exist on the internet, some are now also being sold ready-made, and the special master/slave versions of the files to be loaded are also now widely available.

"Fun-cards" are also now available, which not only have a different internal configuration, but also use a different chipset (eg an Amtel AT90S8515 with a 24c65 EEPROM)

(2) SMD cards - Surface Mount Devices.
These are the same dimensions and layout as a plastic wafer card, but they contain visible surface-mounted chips (i.e. chips whose pins are soldered onto the surface of the card rather than through holes. The chips are very low profile, so this card - like the wafers - fits into a CAM slot with the flap (if any) closed. Some SMD cards are badly soldered and can give problems.

(3) PCBs - Printed Circuit Board cards, or Print-cards (or PIC-cards)
These are normal circuit boards shaped to fit into the CAM slot and etched with tracks which match the internally etched tracks of a wafer. They usually hold sockets soldered onto the PCB, into which dismoutable chips are pushed. The disadvantage of PCBs is that the size of socket+chips means they do not slide completely out of sight into the CAM slot. They have to be made longer than a normal card, with the sockets/chips at the end so that they stick out of the CAM. This means that any flap over the CAM can not be closed (a minor inconvenience).
They have two significant advantages though. First, the chips can be removed - and so can be programmed separately on a JDM device. This contrasts with the normal wafers, where the EEPROM chip can only indirectly be programmed using a technique known as "through-PIC". More of that later.
Second, they can be made from standard electronic parts by the hobbyist. Schematics/layouts are downloadable at many internet sites and the chips needed are standard PICs and EEPROMs, available from normal electronics suppliers.
Oh, and they are a bit cheaper too.


More details on programmers
---------------------------
Most but not all programming devices work through the serial port using a standard serial cable. Some (typically the more expensive models) work through the parallel printer port, using a bespoke cable. The required power-supply is typically 9v or 12v DC, delivering 300mA.

In order to program plastic cards, both the Ludi and Phoenix devices should be equipped with a smartcard reader (i.e. a slot into which the wafer can be slid in order to program it). Not all such devices have this as standard.
If you are intending only to work with PCB cards (with dismountable chips) then a Ludi without card-reader will be all you need - assuming it has one or more sockets suitable for inserting loose EEPROMs and PICs.

If you are working with plastic cards, you MUST have a Phoenix/Smartmouse device, since that is the only device which can program the embedded EEPROM. It will also have to operate at the lower speed of 3.57MHz. The higher speed of 6.00MHz is ok for modern MOSCs but can damage wafer cards. Not all such devices have a 3.57MHz oscillator - some only have a 6.00 MHz. But a 6.00MHz programmer can be turned into a 3.57MHz programmer simply by swapping the oscillator crystal - no other modifications are required.
Note: a device in JDM mode does not use the crystal.

Popular JDMs (also referred to as a "Hi/Lo programmer") are the DL20 & JDM (Jens Dyekj?r Madsen).

More details on programming software
------------------------------------
These programs offer features for programming, reading, and erasing the chips. The HEX or BIN file is read from the pc-media (eg hard-disk) into a buffer, and from there piped across the COM-port/cable to the programming device and into the chip. Most programs use checksums to verify what they are writing.
There are a vast range of utilities available, some Ludi-only, some Phoenix-only, some combined. Some have additional handy features such as HEX disassemblers.
Some programming devices come with their own dedicated software.
Note: whatever Phoenix/Smartmouse software you use, it should support the 3.57MHz speed - and not all do!


Where to buy and what they cost.
--------------------------------
Wafer-cards, SMD-cards, PCB-cards are available in many satellite shops throughout Europe, and through many internet retailers. It is perfectly legal to sell such cards and/or chips in the raw, blank state, since they have multiple purposes. Only when the software is loaded, turning it into (say) a pirate satellite card, would its sale or use become illegal.
Price typically GBP 15 each. You really shouldn't pay more. If you are asked for more, you are being ripped-off.

PCB cards can be built by the electronics hobbyist. Schematics/layouts are downloadable at many internet sites and the chips needed are standard PICs and EEPROMs, available from normal electronics suppliers. If you make such a card yourself, expect to pay less than GBP 10 for the parts.
Fun-cards can be made (schematics again are available on the Internet) or purchased ready-made. Trio- and Quad-cards are mainly DIY items at the moment.

Programmers can also be purchased in kit or ready-built format. ready-built ones are still being sold by satellite shops, though some less openly than before the 28th/May/2000 European anti-piracy legislation came into force. There are many retailers selling them online though.
Costs range from about GBP 30 for the cheapest combi (VP-2) up to hundreds of pounds for professional-quality PIC programmers alone. The higher costs usually are indicative of a wider range of supported chips, as well as a better tolerance of the many differences across PCs of COM-port, processor-speed, etc. But if the sole purpose is to program 16f84 and 24c16 chips then the cheapest should suffice.

Overview of process
-------------------
The goal is to get a key file into the EEPROM, and a software file (including key-decryption algorithms) into the PIC.
The software file is usually a hexadecimal (xxx.HEX) file.
The key file is usually a binary (xxx.BIN) file.
A loader (or "boot") file may also be needed in order to pass the key file through the PIC and into the EEPROM. The loader will typically be a HEX file.
Some programming utilities will demand that the file for the EEPROM is indeed a BIN file, and the others are HEX. But if the downloaded files are not in those formats, don't worry: there are utilities available for converting from one to the other.
There are also wafer software files available which allow the keys to be loaded using new pseudo-nano-commands in CRD format as familiar to people who have played with MOSCs. But we will ignore those here.


The loader/hex file
-------------------
When working with non-removable chips (i.e. SMD cards, or plastic wafers), there is a problem to be overcome: how to gain access to the EEPROM, since it sits "behind" the PIC. The solution is to use "Through-PIC" technique. This means loading a special file onto the PIC whose sole purpose is to pass the key/bin file through to the EEPROM. This loader (or boot) file exists in many different versions, with names like LOADER.HEX, MAIN.HEX, 16F84.HEX and so on. Often the wafer-software files are packaged with a loader. But don't think you have to use the loader which comes with the particular package. Once you've found a loader which is reliable for you, save it and reuse it for all future through-PIC programming.
When the EEPROM has been successfully programmed, the loader has fulfilled its purpose and can be overwritten with the program/hex which you really wanted on the PIC in the first place.


The key/bin file
----------------
The key file contains some data which mimic a MOSC (Manufacturer's Original Smart Card). For example, an ATR, a country-code, a hex-serial number, an ascii-serial.

The program/hex file
--------------------
This mimics an official card to a degree, but also offers more functionality.
Many different versions exist and they are constantly being tweaked, to create new versions. More often than not they are matched in some subtle way to the associated key/bin file. So best advice is to use the hex/bin pair as a pair - don't mix and match.


Troubleshooting
---------------
There are so many variations of card, software, programming device, PC, CAMs and receivers, that it is inevitable that problems arise. Sometimes problems are due to faulty hardware, or mismatched hardware. Sometimes bugs in the software, or the firmware of the CAM. When problems do arise, it can be difficult to find out the cause.
Here are a few known problems.

* Some programming devices (such as the VP-2) can not work with laptops. This may be due to the com-port settings, or to power-management of the COM-port. Always switch off any power-management utilities you have running, and ensure that the COM port you are using is powered-up.

* Some programming devices (such as the VP-2) can not work reliably (or at all) with fast computers - which can be anything from a Pentium 90 upwards. Such problems may originate with bad timing pulses generated within the programming software, so that some software will work, others not. Now where have you got that old 286 stored?

* Not all combinations of programming software and programming device are compatible. There are lots of different PIC and EEPROM programming utilities to try out though, so when you find one that works, keep it.

* Often small variations in voltage or timing pulses might cause read/write errors, and verify-failures. The solution will usually be simply to start the operation again (perhaps after re-inserting the chip, or cleaning the card's contacts, or switching the programmer off/on).

* Some wafer software is not compatible with some receivers. Search out specific wafer files for your receiver if they exist.

* Some loaders/boot-hex files work well, some don't. When you have found one that works for you, keep it and always use it in preference to any that is supplied with the other bin/hex wafer files.
返回http://carddiy.126.com

--完--