Can anyone explain how the ST determines how much RAM it has on startup?

Troubles with your machine? Just want to speak about the latest improvements? This is the place!

Moderators: Mug UK, Zorro 2, Greenious, spiny, Moderator Team

sean1978
Retro freak
Retro freak
Posts: 14
Joined: Mon May 16, 2016 11:53 pm

Can anyone explain how the ST determines how much RAM it has on startup?

Postby sean1978 » Sat Aug 27, 2016 12:42 am

My failed 4MB upgrade has been reverted and now I am troubleshooting my ST that actually wasn't functioning correctly prior to the upgrade. I didn't realise this because I had not been able to run diagnostics on the system due to no disk drive and it had appeared to be functioning correctly.

Now that I have set my 1040ST back to stock. I can see that only 512KB of the installed 1MB is being detected by the ram test utility.

I have an extra 520ST and was able to swap my MMU and Glue to no difference in behavior.

I have been repairing some problems related to corrosion and may have some under an IC I can't see at the moment. I'm wondering what tells the ST how much RAM it has. to help narrow down my search. I have an oscilloscope and multimeter at home, and any test equipment you could possibly imagine at work.

ijor
Hardware Guru
Hardware Guru
Posts: 3783
Joined: Sat May 29, 2004 7:52 pm
Contact:

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby ijor » Sat Aug 27, 2016 1:37 am

sean1978 wrote:Now that I have set my 1040ST back to stock. I can see that only 512KB of the installed 1MB is being detected by the ram test utility.
I have an extra 520ST and was able to swap my MMU and Glue to no difference in behavior.
...
I'm wondering what tells the ST how much RAM it has.


The OS does. The OS tries different configurations of the MMU controller, and checks what can be read successfully.

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 793
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby mfro » Sat Aug 27, 2016 4:40 am

ijor wrote:The OS does. The OS tries different configurations of the MMU controller, and checks what can be read successfully.


EmuTOS has been overhauled in this regard recently.

Here (line 207 onwards) you can find pretty good documented code on how memory configuration works on STs.

The basic idea is to first assume 4Mb, set the memory configuration accordingly and check if (and where) written test patterns appear at higher addresses as well (which indicates less than 4Mb).

czietz
Hardware Guru
Hardware Guru
Posts: 939
Joined: Tue May 24, 2016 6:47 pm

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby czietz » Sat Aug 27, 2016 10:27 am

A while ago I wrote a short document on memory detection that is also distributed with EmuTOS: https://sourceforge.net/p/emutos/code/c ... detect.txt

czietz
Hardware Guru
Hardware Guru
Posts: 939
Joined: Tue May 24, 2016 6:47 pm

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby czietz » Sat Aug 27, 2016 10:31 am

PS: When only 512k of RAM are detected in a 1 MB machine, this means that the entire upper memory bank is not found upon startup. Concentrate on that, start checking that RAS1, CAS1H and CAS1L are correctly generated and connected to the corresponding RAM chips. Then check the individual RAM chips of the second bank for broken data or address lines.

User avatar
Steven Seagal
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2018
Joined: Sun Dec 04, 2005 9:12 am
Location: Undisclosed
Contact:

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby Steven Seagal » Sun Sep 04, 2016 9:36 pm

czietz wrote:A while ago I wrote a short document on memory detection that is also distributed with EmuTOS: https://sourceforge.net/p/emutos/code/c ... detect.txt


Thx, I finally start to understand this confusing "confused MMU" part of Steem. It's less complicated than I feared. I didn't know there's a difference between STF and STE MMU for that memory test.
In the CIA we learned that ST ruled
Steem SSE: http://sourceforge.net/projects/steemsse

Gunstick
Captain Atari
Captain Atari
Posts: 262
Joined: Thu Jun 20, 2002 6:49 pm
Location: Luxembourg
Contact:

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby Gunstick » Sun Apr 02, 2017 10:54 pm

The links are unfortunately broken. Maybe copy thie parts inline here when sourceforge keeps changing things around. Because now I need this info, and can't find it. I'm on the quest to determine how it was possible to have 2.5M + 0.5M (via some 74xx) in my ST without any software to tell TOS it only has 3MB

ThorstenOtto
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Sun Aug 03, 2014 5:54 pm

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby ThorstenOtto » Sun Apr 02, 2017 11:06 pm

It is on Github now:

https://github.com/emutos/emutos/blob/m ... detect.txt

to have 2.5M + 0.5M (via some 74xx) in my ST without any software to tell TOS it only has 3MB


If i remember right, this is hardly possible. There are only 2 banks, and a single one can't have 2.5 MB.

Gunstick
Captain Atari
Captain Atari
Posts: 262
Joined: Thu Jun 20, 2002 6:49 pm
Location: Luxembourg
Contact:

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby Gunstick » Sun Apr 02, 2017 11:13 pm

Ok, so it goes like this:
A 520ST+ with 2x512M
Upgraded to 2.5MB with the 2nd 512MB disabled and replaced by 2MB
Insertion of some simple TTL logic chip and the disabled 512MB become useable again

Tadaaa: 3MB ST
You could even buy that: http://stcarchiv.de/ai1995/06_ramext.php

User avatar
Arne
Captain Atari
Captain Atari
Posts: 499
Joined: Thu Nov 01, 2007 10:01 am

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby Arne » Mon Apr 03, 2017 5:42 am

I used a GAL instead of 74xx and it worked without problems in a 1040STFM with 2.06.
You do not have the required permissions to view the files attached to this post.
Image

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2978
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby AtariZoll » Mon Apr 03, 2017 8:10 am

Interesting solution. But maybe better to go on full 4MB instead it - RAM is really cheap now.
Btw. if MMU chip is IMP brand, 2.5 MB: 1x2MB + 1x512KB combination works not. Only 2MB is available.
Famous Schrodinger's cat hypothetical experiment says that cat is dead or alive until we open box and see condition of poor animal, which deserved better logic. Cat is always in some certain state - regardless from is observer able or not to see what the state is.

User avatar
leonard
Moderator
Moderator
Posts: 642
Joined: Thu May 23, 2002 10:48 pm
Contact:

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby leonard » Mon Apr 03, 2017 8:28 am

This is really interesting. I always used very simple test for my demos, but now I wonder if it could report bad state in some cases. For instance, in We Were @ demo I test "4MiB" machine juste by writing a 32bits at $3ffffc and read it back and compare. But, is that possible that $3ffffc "remaps" to some lower ad on some configurations? so that my test will return "TRUE" even if this is not a 4MiB machine?
PS: I know I should use OS memory reporting, make things easier and compatible, my question is just for curiosity knowledge)
Leonard/OXYGENE.

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2978
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby AtariZoll » Mon Apr 03, 2017 11:35 am

leonard wrote:This is really interesting. I always used very simple test for my demos, but now I wonder if it could report bad state in some cases. For instance, in We Were @ demo I test "4MiB" machine juste by writing a 32bits at $3ffffc and read it back and compare. But, is that possible that $3ffffc "remaps" to some lower ad on some configurations? so that my test will return "TRUE" even if this is not a 4MiB machine?
PS: I know I should use OS memory reporting, make things easier and compatible, my question is just for curiosity knowledge)

If it remaps to some different real RAM loc., it will act still same - of course if it is remapped always in same way.
I see as bigger danger that some RAM cells are damaged, and short tests simply will not detect such errors, including TOS startup RAM check. So, running some forensic RAM test sometimes is useful.
Famous Schrodinger's cat hypothetical experiment says that cat is dead or alive until we open box and see condition of poor animal, which deserved better logic. Cat is always in some certain state - regardless from is observer able or not to see what the state is.

czietz
Hardware Guru
Hardware Guru
Posts: 939
Joined: Tue May 24, 2016 6:47 pm

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby czietz » Mon Apr 03, 2017 6:09 pm

As a matter of fact, after the MMU has been configured for the correct amount of RAM (very early during boot), an access to a non-existing address will not remap to a different address -- confirmed on an STf. The MMU simply does not generate any RAM access signals in such a case. This means that writes are discarded while reads basically return random values -- whatever was on the data bus.

You can read about how I reverse-engineered the complex logic used to generate access signals here: https://listengine.tuxfamily.org/lists. ... 00068.html
I even found/confirmed an inconsistency for a very exotic configuration. Afaik thanks to this work this is now even emulated by Hatari.

Gunstick
Captain Atari
Captain Atari
Posts: 262
Joined: Thu Jun 20, 2002 6:49 pm
Location: Luxembourg
Contact:

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby Gunstick » Thu Apr 06, 2017 6:39 am

Arne wrote:I used a GAL instead of 74xx and it worked without problems in a 1040STFM with 2.06.


This does not explain how the TOS was totally fine with 3MB, whereas this configuration is even not possible with the hardware. I did not need any extra software to tell TOS that 1MB is missing. Somehow it did that by it's own.

ijor
Hardware Guru
Hardware Guru
Posts: 3783
Joined: Sat May 29, 2004 7:52 pm
Contact:

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby ijor » Thu Apr 06, 2017 1:03 pm

Gunstick wrote:This does not explain how the TOS was totally fine with 3MB, whereas this configuration is even not possible with the hardware. I did not need any extra software to tell TOS that 1MB is missing. Somehow it did that by it's own.


TOS is one thing, hardware limitation is another one.

The MMU hardware have some limitations about the possible bank configurations, and it even depends on the MMU version as already mentioned. But, of course, with the right hardware, you can overcome MMU limitations. That's the hardware side ...

TOS memory test is more flexible than the standard hardware. It tests memory in such a way that it can detect memory configurarions not possible without custom hardware.

Edit: In other words. TOS memory test is not restricted to MMU limitations. It might detect 3MB even in some situations with physically 4MB but some bits on the upper MB damaged.

Gunstick
Captain Atari
Captain Atari
Posts: 262
Joined: Thu Jun 20, 2002 6:49 pm
Location: Luxembourg
Contact:

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby Gunstick » Wed Apr 12, 2017 10:17 pm

Cool. Would be interesting to see the disassembly of the TOS code doing the memory configuration checking. If someone is able to dig this up that would be great.

ThorstenOtto
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Sun Aug 03, 2014 5:54 pm

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby ThorstenOtto » Thu Apr 13, 2017 1:37 am

Gunstick wrote:Cool. Would be interesting to see the disassembly of the TOS code doing the memory configuration checking. If someone is able to dig this up that would be great.


Why use the disassembly when you can read the source...

http://gfa.atari-users.net/docs/files/bios.zip
or
http://www.tho-otto.de/download/tos306de.tar.bz2

ijor
Hardware Guru
Hardware Guru
Posts: 3783
Joined: Sat May 29, 2004 7:52 pm
Contact:

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby ijor » Thu Apr 13, 2017 1:56 am

Btw Gunstick, which value you get on the MMU configuration? A shadow copy should be present at address $424

czietz
Hardware Guru
Hardware Guru
Posts: 939
Joined: Tue May 24, 2016 6:47 pm

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby czietz » Thu Apr 13, 2017 6:29 am

ThorstenOtto wrote:Why use the disassembly when you can read the source...

http://gfa.atari-users.net/docs/files/bios.zip
or
http://www.tho-otto.de/download/tos306de.tar.bz2


At least the second file is wrong regarding the memory configuration algorithm on STs and STEs, i.e. it differs from the code actually found in TOS 2.06. Thorsten, didn't you say that your sources completely match the TOS ROMs? Now I wonder what other things also differ...

User avatar
troed
Atari God
Atari God
Posts: 1438
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby troed » Thu Apr 13, 2017 6:54 am

czietz wrote:
ThorstenOtto wrote:Why use the disassembly when you can read the source...

http://gfa.atari-users.net/docs/files/bios.zip
or
http://www.tho-otto.de/download/tos306de.tar.bz2


At least the second file is wrong regarding the memory configuration algorithm on STs and STEs, i.e. it differs from the code actually found in TOS 2.06. Thorsten, didn't you say that your sources completely match the TOS ROMs? Now I wonder what other things also differ...


You can build images from the source and they are a 100% match to the official Atari binaries. I've done so, for both 2.06 and 3.06. They don't differ.

/Troed

czietz
Hardware Guru
Hardware Guru
Posts: 939
Joined: Tue May 24, 2016 6:47 pm

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby czietz » Thu Apr 13, 2017 8:35 am

Strange. This imho can only mean one of three things:

a) Thorsten posted a link to a different version of the sources than you used.
b) The code in startup.S, starting at line 484 ...

Code: Select all

#if TOSVERSION < 0x300
/* First we try to configure the memory controller */

... does not get compiled into the binary. If that's the case: Where is the correct memory detection code for ST and STE located in Thorsten sources?
c) My version of Atari TOS 2.06 -- which contains the same memory detection routine that found in bios.zip and not those from Thorsten's startup.S -- somehow differs from your official Atari binaries.

User avatar
troed
Atari God
Atari God
Posts: 1438
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby troed » Thu Apr 13, 2017 10:51 am

czietz wrote:c) My version of Atari TOS 2.06 -- which contains the same memory detection routine that found in bios.zip and not those from Thorsten's startup.S -- somehow differs from your official Atari binaries.


FWIW I verified against freshly downloaded TOS binaries from narod.ru :)

The easiest test is of course just to compile yourself - it's very plug and play.

/Troed

ThorstenOtto
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Sun Aug 03, 2014 5:54 pm

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby ThorstenOtto » Thu Apr 13, 2017 1:59 pm

czietz wrote:Strange. This imho can only mean one of three things:

a) Thorsten posted a link to a different version of the sources than you used.


The archive is slightly newer, but the only thing that i changed is to remove the compiler sources from the archive, due to space constraints on 16MB filesystems. They are now available as separate archive.

b) The code in startup.S, starting at line 484 ...

Code: Select all

#if TOSVERSION < 0x300
/* First we try to configure the memory controller */

... does not get compiled into the binary.


That might be the case. By default, the 3.06 version is build.

If that's the case: Where is the correct memory detection code for ST and STE located in Thorsten sources?


Both versions are there. For 2.06, you just have to specify make TOSVERSION=206, or change the default in config.mak

czietz
Hardware Guru
Hardware Guru
Posts: 939
Joined: Tue May 24, 2016 6:47 pm

Re: Can anyone explain how the ST determines how much RAM it has on startup?

Postby czietz » Thu Apr 13, 2017 3:43 pm

Looking at the Spanish version of TOS 2.06 compiled from Thorsten's sources (http://www.tho-otto.de/download/toses.zip) I indeed see the correct memory detection routine, the same one as in Atari's original binaries. Maybe I got a bit confused by the comments in Thorsten's sources that do not really reflect what the configuration algorithm does, but the instructions themselves are in fact correct. So, I'm very sorry for the noise!

I'd still recommend Gunstick to look at the STARTUP.S from the bios.zip file because it better explains what TOS actually does to configure memory. Had I only know that file when I puzzled it out myself... (Note that any references to "STPLUS" in the detection algorithm mean "STE".)


Social Media

     

Return to “Hardware”

Who is online

Users browsing this forum: No registered users and 3 guests