writing to flashrom (2MB rom) and support for emulators

Страница 6/8
1 | 2 | 3 | 4 | 5 | | 7 | 8

By Manuel

Ascended (17075)

Аватар пользователя Manuel

09-05-2020, 19:29

I do wonder why you haven't asked the questions yourself to Alexey... how do you know how to program it without some specifications on how that works?

By norakomi

Paragon (1084)

Аватар пользователя norakomi

10-05-2020, 10:11

I didn't ask Alexey, because I didn't know he was the manufacturer until you asked me (and then I asked the person we buy the cartridges from).
I will sent an email to Alexey right now !!

Quote:

how do you know how to program it without some specifications on how that works?

I used this mostly: http://www.farnell.com/datasheets/40281.pdf
I'm also in contact now with Daniël Vik to see if we can get the emulation working in bluemsx as well !

By Manuel

Ascended (17075)

Аватар пользователя Manuel

10-05-2020, 12:47

A data sheet is one thing, but it doesn't tell you how the chip is interconnected with the MSX... and that's exactly the point here.

I'm curious to hear about Daniel's response.

By norakomi

Paragon (1084)

Аватар пользователя norakomi

13-05-2020, 11:30

@Manuel I got the datasheet:
https://pdf1.alldatasheet.com/datasheet-pdf/view/92562/AMD/A...
There is a .pdf download link there.
First thing I notice on the first page is this:
Group sector protection — Hardware method that disables any combination of sector groups from write or erase operations (a sector group consists of 4 adjacent sectors of 64 Kbytes each)
So it turns out is IS possible to protect the flashrom per 4 adjecent sectors.

By norakomi

Paragon (1084)

Аватар пользователя norakomi

13-05-2020, 13:45

I am a bit confused on how to erase a sector (in total we have 32 sectors of 64kb each).

In the manual I see this:
Sector Erase 6 5555H AAH 2AAAH 55H 5555H 80H 5555H AAH 2AAAH 55H SA 30H

So 6 commands to erase a sector.

The last command is writing value 30H to SA...

SA= Address of the sector to be erased. The combination of A20, A19, A18, A17, and A16 will uniquely select any sector.

A20 A19 A18 A17 A16 Address Range
SA0 0 0 0 0 0 000000h-00FFFFh
SA1 0 0 0 0 1 010000h-01FFFFh
etc..

So if I want to erase sector 1 for instance, would this be the correct way to do it:

  di
;block erase 6 commands
  ld    a,$aa
  ld    ($8555),a
  ld    a,$55
  ld    ($82aa),a
  ld    a,$80
  ld    ($8555),a
  ld    a,$aa
  ld    ($8555),a
  ld    a,$55
  ld    ($82aa),a
  ld    a,$30
  ld    ($8001),a                    ;erase sector 1 
  ei

?

By Manuel

Ascended (17075)

Аватар пользователя Manuel

13-05-2020, 14:26

norakomi wrote:

@Manuel I got the datasheet:
https://pdf1.alldatasheet.com/datasheet-pdf/view/92562/AMD/A...
There is a .pdf download link there.
First thing I notice on the first page is this:
Group sector protection — Hardware method that disables any combination of sector groups from write or erase operations (a sector group consists of 4 adjacent sectors of 64 Kbytes each)
So it turns out is IS possible to protect the flashrom per 4 adjecent sectors.

It's a hardware method. So, you need to connect certain pins on the chip to 5V or so. It's not something you can change by software. What I understand is that the cartridge you're going to use has a jumper for write protect (all or nothing).

By norakomi

Paragon (1084)

Аватар пользователя norakomi

14-05-2020, 12:29

@Manuel We did it. We finally got the saving to flashrom working on the real thing.
Also Daniel Vik implemented the emulation for bluemsx.com.
Do you have enough information to add the emulation to openmsx now ?

So it's basically the same way we write using the fl16.com routines.
And the chip is AM29F016

By S0urceror

Master (138)

Аватар пользователя S0urceror

14-05-2020, 17:38

For my little project I just wrote a C implementation to flash this chip.

Check: https://github.com/S0urceror/MSX-USB/blob/usb-hub/software/src/flash.c

The functions erase_flash_sectors and write_flash_segment show how it is done.

By Manuel

Ascended (17075)

Аватар пользователя Manuel

14-05-2020, 22:22

I know the chip and its configuration. But I don't know how the chip is connected to the MSX hardware. And how the mapper chip is combined with it.

E.g. in S0urcerer's code I see he's writing to 0x4000 in memory to access the flash chip. How does it work for the cartridge of RBSC? For instance, is any address OK? What about the mapper switch addresses? Which addresses are used exactly for the mapper? And those which are not used, do they mean direct write to flash?

By norakomi

Paragon (1084)

Аватар пользователя norakomi

15-05-2020, 11:44

Quote:

E.g. in S0urcerer's code I see he's writing to 0x4000 in memory to access the flash chip. How does it work for the cartridge of RBSC? For instance, is any address OK?

Yep any address is ok.

Quote:

What about the mapper switch addresses?

block1:		
	di
	ld		(memblocks.1),a
	ld		($5000),a
	ei
	ret

block2:		
	di
	ld		(memblocks.2),a
	ld		($7000),a
	ei
	ret

block3:		
	di
	ld		(memblocks.3),a
	ld		($9000),a
	ei
	ret

block4:		
	di
	ld		(memblocks.4),a
	ld		($b000),a
	ei
	ret
Quote:

And those which are not used, do they mean direct write to flash?

Well.. this is how I write 1 byte to flash.

  di
  ld    a,$aa
  ld    ($8555),a
  ld    a,$55
  ld    ($82aa),a
  ld    a,$a0
  ld    ($8555),a                   ;block Program (this is writing the data to the flashrom)
  ld    a,(de)                      ;read save game data from this address in ram
  ld    (hl),a                      ;write save game data to this address in flashrom
ei

and this is how I erase a 64kb sector:

  di
;block erase 6 commands
  ld    a,$aa
  ld    ($8555),a
  ld    a,$55
  ld    ($82aa),a
  ld    a,$80
  ld    ($8555),a
  ld    a,$aa
  ld    ($8555),a
  ld    a,$55
  ld    ($82aa),a
  ld    a,$30
  ld    ($8000),a                    ;erase sector
  ei

Let me know if there is anything else you need to know ! Question

Страница 6/8
1 | 2 | 3 | 4 | 5 | | 7 | 8