Patches to Mass Storage emulation in MAXUSB.
[goodfet] / client / M29W640GB.py
1 """
2 http://www.tonews.com/thread/1644423/comp/sys/arm/getting_chip_selects_working_after_remap_on_the_at91r40008.html
3
4 This sets the base to 0x00000000 (illegal).
5 If you would like to have it at 0x00400000, change the register to
6 0x0040203E.
7
8 The base address contains the real top bits of the base address, no offset
9 from the range base.
10
11 I'd start addressing from e.g. 0x01000000, so all sizes will fit in. There
12 are plenty of free addresses with the AT91: you can fill only 64 Mbytes of
13 the 4 Gbytes of address space.
14 """
15
16 class M29W640G:
17     """def __init__(self, addrE, pinE, addrG, pinG, addrW, pinW, chipnum, chip_base_addr=0x1000000):
18         self.addrE = addrE
19         self.pinE = pinE
20         self.addrG = addrG
21         self.pinG = pinG
22         self.addrW = addrW
23         self.pinW pinW
24         self.chipnum = chipnum
25         self.base_addr = chip_base_addr
26         """
27     def __init__(self, gfclient, chipnum, chip_base_addr=0x10000000):
28         self.gfclient = gfclient
29         self.chipnum = chipnum
30         self.base_addr = chip_base_addr
31
32     def ChipErase(self, rusure=False):
33         if rusure:
34             self.gfclient.writeMemByte(self.base_addr + 0x555, [0xaa])
35             self.gfclient.writeMemByte(self.base_addr + 0x2aa, [0x55])
36             self.gfclient.writeMemByte(self.base_addr + 0x555, [0x80])
37             self.gfclient.writeMemByte(self.base_addr + 0x555, [0xaa])
38             self.gfclient.writeMemByte(self.base_addr + 0x2aa, [0x55])
39             self.gfclient.writeMemByte(self.base_addr + 0x555, [0x10])